From fbf1b64379de0539a0661edbe8a84e8ba48591f9 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sun, 12 Jan 2014 21:16:18 -0500 Subject: v4 v5: texinfo, fixes --- lib/sisu/v5/texinfo_format.rb | 89 +++++++++++++++---------------------------- 1 file changed, 31 insertions(+), 58 deletions(-) (limited to 'lib/sisu/v5/texinfo_format.rb') diff --git a/lib/sisu/v5/texinfo_format.rb b/lib/sisu/v5/texinfo_format.rb index 5e920475..5d513041 100644 --- a/lib/sisu/v5/texinfo_format.rb +++ b/lib/sisu/v5/texinfo_format.rb @@ -69,8 +69,8 @@ module SiSU_TexInfoFormat @@tex_1='\\\\~' #?? debug @@tabular="{tabular}" @@tex_pattern_margin_number="\\\\marginpar.+?\s+" - def initialize(md,dob=nil) - @md,@dob=md,dob + def initialize(md,dob=nil,up='') + @md,@dob,@up=md,dob,up if dob.is_a?(Hash) p dob.class p caller @@ -92,7 +92,7 @@ module SiSU_TexInfoFormat subtitle=subtitle.gsub(/<(br|p|i)>|<\/\s*(br|p|i)>|<(br|p)\s*\/>/," #{Tex[:backslash]*2} "). gsub(/\$/,"\\$"). gsub(/[,]\s*/,' - ') - subtitle="@subtitle @value{VERSION}, @value{UPDATED}\n" #bugwatch + subtitle="\n@subtitle #{subtitle}\n" end subtitle ||='' author=@md.author if @md.author @@ -103,7 +103,7 @@ module SiSU_TexInfoFormat \\input texinfo @c -*-texinfo-*- @comment %**start of header @setfilename #{@md.fnb}.info -@settitle #{title} @value{VERSION} +@settitle #{title} @syncodeindex pg cp @comment %**end of header @c %% 2 @@ -139,7 +139,6 @@ WOK @c %% 3 @titlepage @title #{title} -@value{VERSION}, @value{UPDATED} @author #{author} @page @vskip 0pt plus 1filll @@ -283,77 +282,52 @@ WOK end def clean(dob) if dob.is==:heading \ - and dob.obj !~/##{dob.ocn}/ - dob.obj="#{dob.obj} ##{dob.ocn}" + and dob.obj !~/#{Dx[:ocn_o]}#{dob.ocn}#{Dx[:ocn_c]}/ + dob.obj=dob.ocn.is_a?(Fixnum) \ + ? "#{dob.obj} #{Dx[:ocn_o]}#{dob.ocn}#{Dx[:ocn_c]}" : dob.obj end dob.obj=dob.obj.gsub(/\n/m,' '). - gsub(/<:#>/,''). gsub(/,\s+/,' - '). strip dob end def menu dob=clean(@dob) - m=dob.obj - m=m.gsub(/[:,]\s*/,' - '). + m=dob.obj.gsub(/[:,]\s*/,' - '). gsub(/@footnote\{.+?\}\s+/,'') m="* #{m}::" end - def level1 + def level_common dob=clean(@dob) - nd=dob.obj.gsub(/@footnote\{.+?\}\s+/,'') - dob.obj="@node #{nd}\n@unnumbered #{nd}\n@cindex chapter, #{nd}\n" + nd=dob.obj.gsub(/@footnote\{.+?\}\s+/,''). + gsub(/: \s*/,' - ') + dob.obj="@node #{nd}\n@unnumbered #{nd}\n@cindex chapter, #{nd}\n\n" dob end - def level2 + def level_sub(up) dob=clean(@dob) - nd=dob.obj.gsub(/@footnote\{.+?\}\s+/,'') - dob.obj="@node #{nd}\n@unnumbered #{nd}\n@cindex chapter, #{nd}\n" + nd=dob.obj.gsub(/@footnote\{.+?\}\s+/,''). + gsub(/: \s*/,' - ') + dob.obj="@node #{nd}, #{up}\n@comment node-name, up\n@unnumbered #{nd}\n@cindex chapter, #{nd}\n\n" dob end + def level1 + level_common + end + def level2 + level_common + end def level3 - dob=clean(@dob) - nd=dob.obj.gsub(/@footnote\{.+?\}\s+/,'') - dob.obj="@node #{nd}\n@unnumbered #{nd}\n@cindex chapter, #{nd}\n" - dob + level_common end def level4 - dob=clean(@dob) - nd=dob.obj.gsub(/@footnote\{.+?\}\s+/,'') - dob.obj="@node #{nd}\n@unnumbered #{nd}\n@cindex chapter, #{nd}\n" - dob + level_common end def level5 - dob=clean(@dob) - nd=dob.obj.gsub(/@footnote\{.+?\}\s+/,'') - dob.obj="@node #{nd}\n@unnumbered #{nd}\n@cindex chapter, #{nd}\n" - dob + level_sub(@up) end def level6 - dob=clean(@dob) - nd=dob.obj.gsub(/@footnote\{.+?\}\s+/,'') - dob.obj="@node #{nd}\n@unnumbered #{nd}\n@cindex chapter, #{nd}\n" - dob - end - def submenu - @dob.obj=@dob.obj.join("\n") - @dob.obj=@dob.obj.gsub(/[5]\\+~\S+/,'') - dob=clean(@dob) - dob.obj="@menu\n#{dob.obj}\n@end menu\n\n". - gsub(/.+/m,"#{dob.obj}") - end - def subsubmenu - @dob.obj=@dob.obj.join("\n") - @dob.obj=@dob.obj.gsub(/[6]\\+~\S+/,'') - dob=clean(@dob) - dob.obj="@menu\n#{dob.obj}\n@end menu\n\n". - gsub(/.+/m,"#{dob.obj}") - end - def indent1 - @dob.obj=@dob.obj.gsub(/<:i1>(.*)/,'\1') - end - def indent2 - @dob.obj=@dob.obj.gsub(/<:i2>(.*)/,'\1') + level_sub(@up) end def spec_char(txt) # special characters txt=txt.gsub(/#{Mx[:br_eof]}/i,''). @@ -548,23 +522,22 @@ WOK end def clean(dob,txt) if dob.is==:heading \ - and txt !~/##{dob.ocn}/ - txt="#{dob.obj} ##{dob.ocn}" + and txt !~/#{Dx[:ocn_o]}#{dob.ocn}#{Dx[:ocn_c]}/ + txt=dob.ocn.is_a?(Fixnum) \ + ? "#{dob.obj} #{Dx[:ocn_o]}#{dob.ocn}#{Dx[:ocn_c]}" : dob.obj end - txt=txt.gsub(/<:#>/,'').strip + txt.strip end def submenu txt=@txt.join("\n") - txt=txt.gsub(/[5]\\+~\S+/,'') txt=clean(@dob,txt) txt="@menu\n#{txt}\n@end menu\n\n" txt=txt.gsub(/.+/m,"#{txt}") end def subsubmenu txt=@txt.join("\n") - txt=txt.gsub(/[6]\\+~\S+/,'') txt=clean(@dob,txt) - txt="@menu\n#{dob.obj}\n@end menu\n\n" + txt="@menu\n#{txt}\n@end menu\n\n" txt=txt.gsub(/.+/m,"#{txt}") end end -- cgit v1.2.3