aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2014-06-19 21:19:17 -0400
committerRalph Amissah <ralph@amissah.com>2014-06-19 21:19:17 -0400
commite7ce3d1c446e63853068380e7d025ba991817146 (patch)
treee6bbd964dfb17263c40d3309801bc0d1d9593efa
parentv6: docbook, images (diff)
v6: docbook, code block
-rw-r--r--data/doc/sisu/CHANGELOG_v61
-rw-r--r--lib/sisu/v6/xml_docbook5.rb9
-rw-r--r--lib/sisu/v6/xml_shared.rb51
3 files changed, 37 insertions, 24 deletions
diff --git a/data/doc/sisu/CHANGELOG_v6 b/data/doc/sisu/CHANGELOG_v6
index 9152019a..4945c147 100644
--- a/data/doc/sisu/CHANGELOG_v6
+++ b/data/doc/sisu/CHANGELOG_v6
@@ -45,6 +45,7 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_6.0.8.orig.tar.xz
* quotes (blockquote)
* tables
* images
+ * code block
%% 6.0.7.orig.tar.xz (2014-05-25:20/7)
http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/sisu_6.0.7
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
'</docinfo>'
].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)}<para#{id}>"
+ filename_docbook.puts "#{spaces*(@splv+1)}<programlisting>"
+ code_output(o,ocn,filename_docbook)
+ filename_docbook.puts "#{spaces*(@splv+1)}</programlisting>"
+ filename_docbook.puts "#{spaces*(@splv)}</para>"
else
filename_docbook.puts "#{spaces*(@splv)}<para#{id}>"
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,'<footnote><para><!-- fn\1 -->\2</para></footnote>').
- gsub(/\\\\/,'</para><para>').
- gsub(/&/,'&amp;'). #sort
- gsub(/#{Mx[:mk_o]}#([a-zA-Z]+)#{Mx[:mk_c]}/,'&\1;').
- gsub(/(^|#{Mx[:gl_c]}|\s)&\s+/,'\1&amp; '). #sort
- gsub(/#{Mx[:mk_o]}(#[0-9]+)#{Mx[:mk_c]}/,'&\1;')
- dob.obj=dob.obj.gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,'<br />') unless dob.is==:table
- dob.obj=dob.obj.gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'<b>\1</b>').
- gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'<i>\1</i>').
- gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'<u>\1</u>').
- gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,'<sup>\1</sup>').
- gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,'<sub>\1</sub>').
- gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'<ins>\1</ins>').
- gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'<cite>\1</cite>').
- gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'<del>\1</del>').
- gsub(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/,'<tt>\1</tt>'). # 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:<figure id="\\1">\n:spaces1:<title></title>\n:spaces1:<graphic fileref="images/\\1" align="center" width="50%"></graphic>\n:spaces0:</figure>#{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]}/,'<a name="\1"></a>').
- gsub(/#{Mx[:gl_bullet]}/m,'● '). #&nbsp; not available
- gsub(/#{Mx[:nbsp]}/,' '). #&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,'<footnote><para><!-- fn\1 -->\2</para></footnote>').
+ gsub(/\\\\/,'</para><para>').
+ gsub(/&/,'&amp;'). #sort
+ gsub(/#{Mx[:mk_o]}#([a-zA-Z]+)#{Mx[:mk_c]}/,'&\1;').
+ gsub(/(^|#{Mx[:gl_c]}|\s)&\s+/,'\1&amp; '). #sort
+ gsub(/#{Mx[:mk_o]}(#[0-9]+)#{Mx[:mk_c]}/,'&\1;')
+ dob.obj=dob.obj.gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,'<br />') unless dob.is==:table
+ dob.obj=dob.obj.gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'<b>\1</b>').
+ gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'<i>\1</i>').
+ gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'<u>\1</u>').
+ gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,'<sup>\1</sup>').
+ gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,'<sub>\1</sub>').
+ gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'<ins>\1</ins>').
+ gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'<cite>\1</cite>').
+ gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'<del>\1</del>').
+ gsub(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/,'<tt>\1</tt>'). # 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:<figure id="\\1">\n:spaces1:<title></title>\n:spaces1:<graphic fileref="images/\\1" align="center" width="50%"></graphic>\n:spaces0:</figure>#{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]}/,'<a name="\1"></a>').
+ gsub(/#{Mx[:gl_bullet]}/m,'● '). #&nbsp; not available
+ gsub(/#{Mx[:nbsp]}/,' '). #&nbsp; not available
+ gsub(/<(p|br)>/,'<\1 />')
+ dob.obj=clean(dob.obj)
+ else # codeblock
+ end
dob
end
def markup_group(dob='')