From 954419b5ae79efb032d28b145ee40d0b61c80c23 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Tue, 1 Jul 2014 00:33:49 -0400 Subject: v5: merge what was sisu_6.0.8 into v5 * ao, * syntax, able optionally to indicate the language syntax of a code block * syntax, introduce box text block/group * syntax, introduce tics quotes markup (blockquote equivalent) * docbook, * ocn & footnote numbers (as xml comments) * metadata header (docinfo) * quotes (blockquote) * tables * images * code block * vim syntax, add * code block, language syntax, optional * box block * quote block --- lib/sisu/v5/xml_docbook5.rb | 128 ++++++++++++++++++++++++++++++++------------ 1 file changed, 93 insertions(+), 35 deletions(-) (limited to 'lib/sisu/v5/xml_docbook5.rb') diff --git a/lib/sisu/v5/xml_docbook5.rb b/lib/sisu/v5/xml_docbook5.rb index 98450520..3a59f839 100644 --- a/lib/sisu/v5/xml_docbook5.rb +++ b/lib/sisu/v5/xml_docbook5.rb @@ -70,6 +70,7 @@ module SiSU_XML_Docbook_Book include SiSU_TextUtils require_relative 'xml_shared' # xml_shared.rb include SiSU_XML_Munge + require_relative 'shared_metadata' # shared_metadata.rb class Source def initialize(opt) @opt=opt @@ -135,7 +136,7 @@ module SiSU_XML_Docbook_Book def collapsed %w[ 0 1 2 3 4 5 ] end - def docbook(lc,chlv='') + def docbook_tag(lc,chlv='') case lc when 0 then 'book' when 1 then lc==chlv ? 'chapter' : 'section' @@ -162,7 +163,7 @@ module SiSU_XML_Docbook_Book end def markup_text(data) data.each_with_index do |o,i| - if o.is ==:heading || o.is ==:para + if o.is ==:heading || o.is ==:para || o.is ==:open_close_tags o=@trans.markup_docbook(o) #unless o.obj==nil end end @@ -189,6 +190,38 @@ module SiSU_XML_Docbook_Book end #def chapterlevel #end + def xml_head + [ + '', + SiSU_Metadata::Summary.new(@md).xml_docbook.metadata, + '' + ].flatten + end + def code_output(o,ocn,filename_docbook) + filename_docbook.puts o.obj.gsub(/\n?(?:#{Mx[:br_line]}|#{Mx[:br_nl]})\n?/m,"\n") + end + def adjust_output(o,ocn,filename_docbook,splv) + if o.obj =~/#{Xx[:split]}/ + outs=o.obj.split(/#{Xx[:split]}/) + outs.each do |out| + if out =~/
" : '' id=%{ id="o#{o.ocn}" } else @@ -217,16 +251,40 @@ module SiSU_XML_Docbook_Book doc_position=:body_and_tail else filename_docbook.puts structure_build_tag_close(o.lc,h) - filename_docbook.puts %{#{spaces*(o.lc)}<#{tags.docbook(o.lc,chlv)}#{tag_id}> + filename_docbook.puts %{#{spaces*(o.lc)}<#{tags.docbook_tag(o.lc,chlv)}#{tag_id}> #{spaces*o.lc} } end - filename_docbook.puts SiSU_TextUtils::Wrap.new(o.obj + ocn,80,(@splv*2+2)).line_wrap + adjust_output(o,ocn,filename_docbook,@splv) filename_docbook.puts %{#{spaces*o.lc}} h=o.lc - elsif (o.of ==:para or o.of ==:block) + elsif o.of ==:layout \ + and o.is ==:open_close_tags + xml_tag=case o.sym + when :quote_open then '
' + when :quote_close then '
' + else '' + end + unless xml_tag.empty? + filename_docbook.puts "#{spaces*(@splv)}#{xml_tag}" + end + elsif o.of ==:block + if o.is ==:table + filename_docbook.puts SiSU_Tables::TableXMLdocbook.new(o,id).table.obj + elsif o.is ==:code + filename_docbook.puts "#{spaces*(@splv)}" + filename_docbook.puts "#{spaces*(@splv+1)}" + code_output(o,ocn,filename_docbook) + filename_docbook.puts "#{spaces*(@splv+1)}" + filename_docbook.puts "#{spaces*(@splv)}" + else + filename_docbook.puts "#{spaces*(@splv)}" + adjust_output(o,ocn,filename_docbook,@splv) + filename_docbook.puts "#{spaces*(@splv)}" + end + elsif o.of ==:para filename_docbook.puts "#{spaces*(@splv)}" - filename_docbook.puts SiSU_TextUtils::Wrap.new(o.obj + ocn,80,(@splv*2+2)).line_wrap + adjust_output(o,ocn,filename_docbook,@splv) filename_docbook.puts "#{spaces*(@splv)}" end end @@ -237,40 +295,40 @@ module SiSU_XML_Docbook_Book x=[] case h when 0 - x << "#{spaces*0}" if (lc <= 0) + x << "#{spaces*0}" if (lc <= 0) when 1 - x << "#{spaces*1}" if (lc <= 1) - x << "#{spaces*0}" if (lc <= 0) + x << "#{spaces*1}" if (lc <= 1) + x << "#{spaces*0}" if (lc <= 0) when 2 - x << "#{spaces*2}" if (lc <= 2) - x << "#{spaces*1}" if (lc <= 1) - x << "#{spaces*0}" if (lc <= 0) + x << "#{spaces*2}" if (lc <= 2) + x << "#{spaces*1}" if (lc <= 1) + x << "#{spaces*0}" if (lc <= 0) when 3 - x << "#{spaces*3}" if (lc <= 3) - x << "#{spaces*2}" if (lc <= 2) - x << "#{spaces*1}" if (lc <= 1) - x << "#{spaces*0}" if (lc <= 0) + x << "#{spaces*3}" if (lc <= 3) + x << "#{spaces*2}" if (lc <= 2) + x << "#{spaces*1}" if (lc <= 1) + x << "#{spaces*0}" if (lc <= 0) when 4 - x << "#{spaces*4}" if (lc <= 4) - x << "#{spaces*3}" if (lc <= 3) - x << "#{spaces*2}" if (lc <= 2) - x << "#{spaces*1}" if (lc <= 1) - x << "#{spaces*0}" if (lc <= 0) + x << "#{spaces*4}" if (lc <= 4) + x << "#{spaces*3}" if (lc <= 3) + x << "#{spaces*2}" if (lc <= 2) + x << "#{spaces*1}" if (lc <= 1) + x << "#{spaces*0}" if (lc <= 0) when 5 - x << "#{spaces*5}" if (lc <= 5) - x << "#{spaces*4}" if (lc <= 4) - x << "#{spaces*5}" if (lc <= 3) - x << "#{spaces*2}" if (lc <= 2) - x << "#{spaces*1}" if (lc <= 1) - x << "#{spaces*0}" if (lc <= 0) + x << "#{spaces*5}" if (lc <= 5) + x << "#{spaces*4}" if (lc <= 4) + x << "#{spaces*5}" if (lc <= 3) + x << "#{spaces*2}" if (lc <= 2) + x << "#{spaces*1}" if (lc <= 1) + x << "#{spaces*0}" if (lc <= 0) when 6 - x << "#{spaces*6}" if (lc <= 6) - x << "#{spaces*5}" if (lc <= 5) - x << "#{spaces*4}" if (lc <= 4) - x << "#{spaces*3}" if (lc <= 3) - x << "#{spaces*2}" if (lc <= 2) - x << "#{spaces*1}" if (lc <= 1) - x << "#{spaces*0}" if (lc <= 0) + x << "#{spaces*6}" if (lc <= 6) + x << "#{spaces*5}" if (lc <= 5) + x << "#{spaces*4}" if (lc <= 4) + x << "#{spaces*3}" if (lc <= 3) + x << "#{spaces*2}" if (lc <= 2) + x << "#{spaces*1}" if (lc <= 1) + x << "#{spaces*0}" if (lc <= 0) end x.join("\n") end -- cgit v1.2.3