aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2014-01-06 22:36:13 -0500
committerRalph Amissah <ralph@amissah.com>2014-01-06 22:40:17 -0500
commit557d7378ac7ab1e4a5a9b50a0289ef2195d38a81 (patch)
tree80cec85677fe232cea7acd0aa08e03433a83c87f /lib
parentv5: asciidoc, rename AsciiDoc module, & recalibrate headings (diff)
v5: docbook, fictionbook, some tidying
Diffstat (limited to 'lib')
-rw-r--r--lib/sisu/v5/xml_docbook5.rb69
-rw-r--r--lib/sisu/v5/xml_fictionbook2.rb70
2 files changed, 67 insertions, 72 deletions
diff --git a/lib/sisu/v5/xml_docbook5.rb b/lib/sisu/v5/xml_docbook5.rb
index c6cc85e0..dc5de48a 100644
--- a/lib/sisu/v5/xml_docbook5.rb
+++ b/lib/sisu/v5/xml_docbook5.rb
@@ -178,16 +178,16 @@ module SiSU_XML_Docbook_Book
WOK
put(tail)
end
- def output(o,lev=nil,comment='')
- puts lev == 0..6 \
- ? "#{space*lev}<#{lev}>[#{o.ocn}] #{o.ln} #{o.obj}</#{lev}>#{comment}"
- : "<#{lev}>[#{o.ocn}] #{o.ln} #{o.obj}</#{lev}>#{comment}"
+ def output(o,comment='')
+ puts o.lc == 0..6 \
+ ? "#{space*o.lc}<#{o.lc}>[#{o.ocn}] #{o.ln} #{o.obj}</#{o.lc}>#{comment}"
+ : "<#{o.lc}>[#{o.ocn}] #{o.ln} #{o.obj}</#{o.lc}>#{comment}"
end
def structure_collapsed(data)
puts "\ncollapsed structure, heading outline --->\n\n"
data.each_with_index do |o,i|
if (o.is ==:heading || o.is ==:heading_insert)
- output(o,o.lc)
+ output(o)
end
end
end
@@ -209,24 +209,23 @@ module SiSU_XML_Docbook_Book
ocn,id='',''
end
if (o.is ==:heading || o.is ==:heading_insert)
- lev=o.lc
chlv=(o.lv.to_i == 1) \
? @chlv=o.lc.to_i
: 0
- @splv=lev
+ @splv=o.lc
tag_id=o.tags[0] ? %{ id="#{o.tags[0]}" } : ''
if doc_position ==:head
- filename_docbook.puts %{#{space*lev}<title#{id}>}
+ filename_docbook.puts %{#{space*o.lc}<title#{id}>}
doc_position=:body_and_tail
else
- filename_docbook.puts structure_build_tag_close(lev,h)
- filename_docbook.puts %{#{space*(lev-1)}<#{tags.docbook(lev,chlv)}#{tag_id}>
-#{space*lev}<title#{id}>
+ filename_docbook.puts structure_build_tag_close(o.lc,h)
+ filename_docbook.puts %{#{space*(o.lc-1)}<#{tags.docbook(o.lc,chlv)}#{tag_id}>
+#{space*o.lc}<title#{id}>
}
end
filename_docbook.puts SiSU_TextUtils::Wrap.new(o.obj + ocn,80,(@splv*2+2)).line_wrap
- filename_docbook.puts %{#{space*lev}</title>}
- h=lev
+ filename_docbook.puts %{#{space*o.lc}</title>}
+ h=o.lc
elsif (o.of ==:para or o.of ==:block)
filename_docbook.puts "#{space*(@splv)}<para#{id}>"
filename_docbook.puts SiSU_TextUtils::Wrap.new(o.obj + ocn,80,(@splv*2+2)).line_wrap
@@ -236,36 +235,36 @@ module SiSU_XML_Docbook_Book
filename_docbook.puts structure_build_tag_close(0,h)
filename_docbook.close
end
- def structure_build_tag_close(lev,h)
+ def structure_build_tag_close(lc,h)
x=[]
case h
when 1
- x << "#{space*0}</#{tags.docbook(1)}>" if (lev <= 1)
+ x << "#{space*0}</#{tags.docbook(1)}>" if (lc <= 1)
when 2
- x << "#{space*1}</#{tags.docbook(2,@chlv)}>" if (lev <= 2)
- x << "#{space*0}</#{tags.docbook(1)}>" if (lev <= 1)
+ x << "#{space*1}</#{tags.docbook(2,@chlv)}>" if (lc <= 2)
+ x << "#{space*0}</#{tags.docbook(1)}>" if (lc <= 1)
when 3
- x << "#{space*2}</#{tags.docbook(3,@chlv)}>" if (lev <= 3)
- x << "#{space*1}</#{tags.docbook(2,@chlv)}>" if (lev <= 2)
- x << "#{space*0}</#{tags.docbook(1)}>" if (lev <= 1)
+ x << "#{space*2}</#{tags.docbook(3,@chlv)}>" if (lc <= 3)
+ x << "#{space*1}</#{tags.docbook(2,@chlv)}>" if (lc <= 2)
+ x << "#{space*0}</#{tags.docbook(1)}>" if (lc <= 1)
when 4
- x << "#{space*3}</#{tags.docbook(4,@chlv)}>" if (lev <= 4)
- x << "#{space*2}</#{tags.docbook(3,@chlv)}>" if (lev <= 3)
- x << "#{space*1}</#{tags.docbook(2,@chlv)}>" if (lev <= 2)
- x << "#{space*0}</#{tags.docbook(1)}>" if (lev <= 1)
+ x << "#{space*3}</#{tags.docbook(4,@chlv)}>" if (lc <= 4)
+ x << "#{space*2}</#{tags.docbook(3,@chlv)}>" if (lc <= 3)
+ x << "#{space*1}</#{tags.docbook(2,@chlv)}>" if (lc <= 2)
+ x << "#{space*0}</#{tags.docbook(1)}>" if (lc <= 1)
when 5
- x << "#{space*4}</#{tags.docbook(5)}>" if (lev <= 5)
- x << "#{space*3}</#{tags.docbook(4,@chlv)}>" if (lev <= 4)
- x << "#{space*2}</#{tags.docbook(3,@chlv)}>" if (lev <= 3)
- x << "#{space*1}</#{tags.docbook(2,@chlv)}>" if (lev <= 2)
- x << "#{space*0}</#{tags.docbook(1)}>" if (lev <= 1)
+ x << "#{space*4}</#{tags.docbook(5)}>" if (lc <= 5)
+ x << "#{space*3}</#{tags.docbook(4,@chlv)}>" if (lc <= 4)
+ x << "#{space*2}</#{tags.docbook(3,@chlv)}>" if (lc <= 3)
+ x << "#{space*1}</#{tags.docbook(2,@chlv)}>" if (lc <= 2)
+ x << "#{space*0}</#{tags.docbook(1)}>" if (lc <= 1)
when 6
- x << "#{space*5}</#{tags.docbook(6)}>" if (lev <= 6)
- x << "#{space*4}</#{tags.docbook(5)}>" if (lev <= 5)
- x << "#{space*3}</#{tags.docbook(4,@chlv)}>" if (lev <= 4)
- x << "#{space*2}</#{tags.docbook(3,@chlv)}>" if (lev <= 3)
- x << "#{space*1}</#{tags.docbook(2,@chlv)}>" if (lev <= 2)
- x << "#{space*0}</#{tags.docbook(1)}>" if (lev <= 1)
+ x << "#{space*5}</#{tags.docbook(6)}>" if (lc <= 6)
+ x << "#{space*4}</#{tags.docbook(5)}>" if (lc <= 5)
+ x << "#{space*3}</#{tags.docbook(4,@chlv)}>" if (lc <= 4)
+ x << "#{space*2}</#{tags.docbook(3,@chlv)}>" if (lc <= 3)
+ x << "#{space*1}</#{tags.docbook(2,@chlv)}>" if (lc <= 2)
+ x << "#{space*0}</#{tags.docbook(1)}>" if (lc <= 1)
end
x.join("\n")
end
diff --git a/lib/sisu/v5/xml_fictionbook2.rb b/lib/sisu/v5/xml_fictionbook2.rb
index 63167032..aeb74ef3 100644
--- a/lib/sisu/v5/xml_fictionbook2.rb
+++ b/lib/sisu/v5/xml_fictionbook2.rb
@@ -271,16 +271,16 @@ module SiSU_XML_Fictionbook
</FictionBook>
WOK
end
- def output(o,lev=nil,comment='')
- puts lev == 0..6 \
- ? "#{space*lev}<#{lev}>[#{o.ocn}] #{o.ln} #{o.obj}</#{lev}>#{comment}"
- : "<#{lev}>[#{o.ocn}] #{o.ln} #{o.obj}</#{lev}>#{comment}"
+ def output(o,comment='')
+ puts o.lc == 0..6 \
+ ? "#{space*o.lc}<#{o.lc}>[#{o.ocn}] #{o.ln} #{o.obj}</#{o.lc}>#{comment}"
+ : "<#{o.lc}>[#{o.ocn}] #{o.ln} #{o.obj}</#{o.lc}>#{comment}"
end
def structure_collapsed(data)
puts "\ncollapsed structure, heading outline --->\n\n"
data.each_with_index do |o,i|
if (o.is ==:heading || o.is ==:heading_insert)
- output(o,o.lc)
+ output(o)
end
end
end
@@ -301,20 +301,16 @@ module SiSU_XML_Fictionbook
data.each_with_index do |o,i|
ocn=(defined? o.ocn and not o.ocn.nil?) ? "\n#{Dx[:ocn_o]}#{o.ocn}#{Dx[:ocn_c]}" : ''
if o.is ==:heading
- lev=o.lc
- chlv=(o.lv.to_i == 1) \
- ? @chlv=o.lc.to_i
- : 0
unless doc_position==:head
- filename_fictionbook.puts structure_build_tag_close(lev,h)
+ filename_fictionbook.puts structure_build_tag_close(o.lc,h)
end
doc_position=:body_and_tail
- filename_fictionbook.puts %{#{space*lev}<#{tags.fictionbook[lev]}>
-#{space*lev}<title>
+ filename_fictionbook.puts %{#{space*o.lc}<#{tags.fictionbook[o.lc]}>
+#{space*o.lc}<title>
}
- filename_fictionbook.puts SiSU_TextUtils::Wrap.new("<p>#{o.obj}#{ocn}</p>",80,(lev*2+2)).line_wrap
- filename_fictionbook.puts %{#{space*lev}</title>}
- h=lev
+ filename_fictionbook.puts SiSU_TextUtils::Wrap.new("<p>#{o.obj}#{ocn}</p>",80,(o.lc*2+2)).line_wrap
+ filename_fictionbook.puts %{#{space*o.lc}</title>}
+ h=o.lc
elsif o.is ==:heading_insert \
and o.obj =~/Endnotes/ \
and o.ln == 2
@@ -328,36 +324,36 @@ module SiSU_XML_Fictionbook
filename_fictionbook.puts tail(images_base64)
filename_fictionbook.close
end
- def structure_build_tag_close(lev,h)
+ def structure_build_tag_close(lc,h)
x=[]
case h
when 1
- x << "#{space*1}</#{tags.fictionbook[1]}>" if (lev <= 1)
+ x << "#{space*1}</#{tags.fictionbook[1]}>" if (lc <= 1)
when 2
- x << "#{space*2}</#{tags.fictionbook[2]}>" if (lev <= 2)
- x << "#{space*1}</#{tags.fictionbook[1]}>" if (lev <= 1)
+ x << "#{space*2}</#{tags.fictionbook[2]}>" if (lc <= 2)
+ x << "#{space*1}</#{tags.fictionbook[1]}>" if (lc <= 1)
when 3
- x << "#{space*3}</#{tags.fictionbook[3]}>" if (lev <= 3)
- x << "#{space*2}</#{tags.fictionbook[2]}>" if (lev <= 2)
- x << "#{space*1}</#{tags.fictionbook[1]}>" if (lev <= 1)
+ x << "#{space*3}</#{tags.fictionbook[3]}>" if (lc <= 3)
+ x << "#{space*2}</#{tags.fictionbook[2]}>" if (lc <= 2)
+ x << "#{space*1}</#{tags.fictionbook[1]}>" if (lc <= 1)
when 4
- x << "#{space*4}</#{tags.fictionbook[4]}>" if (lev <= 4)
- x << "#{space*3}</#{tags.fictionbook[3]}>" if (lev <= 3)
- x << "#{space*2}</#{tags.fictionbook[2]}>" if (lev <= 2)
- x << "#{space*1}</#{tags.fictionbook[1]}>" if (lev <= 1)
+ x << "#{space*4}</#{tags.fictionbook[4]}>" if (lc <= 4)
+ x << "#{space*3}</#{tags.fictionbook[3]}>" if (lc <= 3)
+ x << "#{space*2}</#{tags.fictionbook[2]}>" if (lc <= 2)
+ x << "#{space*1}</#{tags.fictionbook[1]}>" if (lc <= 1)
when 5
- x << "#{space*5}</#{tags.fictionbook[5]}>" if (lev <= 5)
- x << "#{space*4}</#{tags.fictionbook[4]}>" if (lev <= 4)
- x << "#{space*3}</#{tags.fictionbook[3]}>" if (lev <= 3)
- x << "#{space*2}</#{tags.fictionbook[2]}>" if (lev <= 2)
- x << "#{space*1}</#{tags.fictionbook[1]}>" if (lev <= 1)
+ x << "#{space*5}</#{tags.fictionbook[5]}>" if (lc <= 5)
+ x << "#{space*4}</#{tags.fictionbook[4]}>" if (lc <= 4)
+ x << "#{space*3}</#{tags.fictionbook[3]}>" if (lc <= 3)
+ x << "#{space*2}</#{tags.fictionbook[2]}>" if (lc <= 2)
+ x << "#{space*1}</#{tags.fictionbook[1]}>" if (lc <= 1)
when 6
- x << "#{space*6}</#{tags.fictionbook[6]}>" if (lev <= 6)
- x << "#{space*5}</#{tags.fictionbook[5]}>" if (lev <= 5)
- x << "#{space*4}</#{tags.fictionbook[4]}>" if (lev <= 4)
- x << "#{space*3}</#{tags.fictionbook[3]}>" if (lev <= 3)
- x << "#{space*2}</#{tags.fictionbook[2]}>" if (lev <= 2)
- x << "#{space*1}</#{tags.fictionbook[1]}>" if (lev <= 1)
+ x << "#{space*6}</#{tags.fictionbook[6]}>" if (lc <= 6)
+ x << "#{space*5}</#{tags.fictionbook[5]}>" if (lc <= 5)
+ x << "#{space*4}</#{tags.fictionbook[4]}>" if (lc <= 4)
+ x << "#{space*3}</#{tags.fictionbook[3]}>" if (lc <= 3)
+ x << "#{space*2}</#{tags.fictionbook[2]}>" if (lc <= 2)
+ x << "#{space*1}</#{tags.fictionbook[1]}>" if (lc <= 1)
end
x.join("\n")
end