From e7ce3d1c446e63853068380e7d025ba991817146 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Thu, 19 Jun 2014 21:19:17 -0400 Subject: v6: docbook, code block --- lib/sisu/v6/xml_docbook5.rb | 9 ++++++++ lib/sisu/v6/xml_shared.rb | 51 ++++++++++++++++++++++++--------------------- 2 files changed, 36 insertions(+), 24 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v6/xml_docbook5.rb b/lib/sisu/v6/xml_docbook5.rb index 28fa25ed..b3e9e035 100644 --- a/lib/sisu/v6/xml_docbook5.rb +++ b/lib/sisu/v6/xml_docbook5.rb @@ -197,6 +197,9 @@ module SiSU_XML_Docbook_Book '' ].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]}/) @@ -268,6 +271,12 @@ module SiSU_XML_Docbook_Book 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) diff --git a/lib/sisu/v6/xml_shared.rb b/lib/sisu/v6/xml_shared.rb index b1ebc95f..3e8ddf50 100644 --- a/lib/sisu/v6/xml_shared.rb +++ b/lib/sisu/v6/xml_shared.rb @@ -460,30 +460,33 @@ module SiSU_XML_Munge clean(str) end def markup_docbook(dob='') # work on, initially a copy of fictionbook! - dob.obj=dob.obj.gsub(/#{Mx[:en_a_o]}(\d+)\s*(.+?)#{Mx[:en_a_c]}/m,'\2'). - gsub(/\\\\/,''). - gsub(/&/,'&'). #sort - gsub(/#{Mx[:mk_o]}#([a-zA-Z]+)#{Mx[:mk_c]}/,'&\1;'). - gsub(/(^|#{Mx[:gl_c]}|\s)&\s+/,'\1& '). #sort - gsub(/#{Mx[:mk_o]}(#[0-9]+)#{Mx[:mk_c]}/,'&\1;') - dob.obj=dob.obj.gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,'
') unless dob.is==:table - dob.obj=dob.obj.gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'\1'). - gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'\1'). - gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'\1'). - gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,'\1'). - gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,'\1'). - gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'\1'). - gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'\1'). - gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'\1'). - gsub(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/,'\1'). # tt, kbd - gsub(/#{Mx[:lnk_o]}\s*(\S+?\.(?:png|jpg|gif)).+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}|image)/m, - %{#{Xx[:split]}:spaces0:
\n:spaces1:\n:spaces1:\n:spaces0:
#{Xx[:split]}}). - gsub(/#{Mx[:url_o]}(.+?)#{Mx[:url_c]}/,"#{Dx[:url_o]}\\1#{Dx[:url_c]}"). - gsub(/#{Mx[:mk_o]}:name#(\S+?)#{Mx[:mk_c]}/,''). - gsub(/#{Mx[:gl_bullet]}/m,'● '). #  not available - gsub(/#{Mx[:nbsp]}/,' '). #  not available - gsub(/<(p|br)>/,'<\1 />') - dob.obj=clean(dob.obj) + if dob.is !=:code + dob.obj=dob.obj.gsub(/#{Mx[:en_a_o]}(\d+)\s*(.+?)#{Mx[:en_a_c]}/m,'\2'). + gsub(/\\\\/,'
'). + gsub(/&/,'&'). #sort + gsub(/#{Mx[:mk_o]}#([a-zA-Z]+)#{Mx[:mk_c]}/,'&\1;'). + gsub(/(^|#{Mx[:gl_c]}|\s)&\s+/,'\1& '). #sort + gsub(/#{Mx[:mk_o]}(#[0-9]+)#{Mx[:mk_c]}/,'&\1;') + dob.obj=dob.obj.gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,'
') unless dob.is==:table + dob.obj=dob.obj.gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'\1'). + gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'\1'). + gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'\1'). + gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,'\1'). + gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,'\1'). + gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'\1'). + gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'\1'). + gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'\1'). + gsub(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/,'\1'). # tt, kbd + gsub(/#{Mx[:lnk_o]}\s*(\S+?\.(?:png|jpg|gif)).+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}|image)/m, + %{#{Xx[:split]}:spaces0:
\n:spaces1:\n:spaces1:\n:spaces0:
#{Xx[:split]}}). + gsub(/#{Mx[:url_o]}(.+?)#{Mx[:url_c]}/,"#{Dx[:url_o]}\\1#{Dx[:url_c]}"). + gsub(/#{Mx[:mk_o]}:name#(\S+?)#{Mx[:mk_c]}/,''). + gsub(/#{Mx[:gl_bullet]}/m,'● '). #  not available + gsub(/#{Mx[:nbsp]}/,' '). #  not available + gsub(/<(p|br)>/,'<\1 />') + dob.obj=clean(dob.obj) + else # codeblock + end dob end def markup_group(dob='') -- cgit v1.2.3