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/v4/texinfo.rb | 16 +++++--- lib/sisu/v4/texinfo_format.rb | 76 ++++++++++++------------------------ lib/sisu/v5/texinfo.rb | 25 +++++++----- lib/sisu/v5/texinfo_format.rb | 89 +++++++++++++++---------------------------- lib/sisu/v5/urls.rb | 2 +- 5 files changed, 82 insertions(+), 126 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v4/texinfo.rb b/lib/sisu/v4/texinfo.rb index b0f44a1f..f48ecebe 100644 --- a/lib/sisu/v4/texinfo.rb +++ b/lib/sisu/v4/texinfo.rb @@ -303,32 +303,36 @@ module SiSU_TexInfo @@do_submenu,@@do_subsubmenu=1,1 data_new=[] data.each do |dob| - mono=SiSU_TexInfoFormat::Texinfo.new(@md,dob) + unless defined? dob.ln and dob.ln == (5..6) + mono=SiSU_TexInfoFormat::Texinfo.new(@md,dob) + end if dob.is==:heading case dob.ln when 1; dob=mono.level1 when 2; dob=mono.level2 when 3; dob=mono.level3 when 4; + @@n4_txt=dob.obj dob=mono.level4 n_menu+=1 @@do_submenu,@@do_subsubmenu=1,1 when 5; n_submenu+=1 @@do_subsubmenu=1 + @@n5_txt=dob.obj if @@do_submenu==1 menu=SiSU_TexInfoFormat::TeXinfoTxt.new(@md,dob,@submenu[n_menu]) - dob.obj="#{menu.submenu}#{mono.level5.obj}" + dob.obj="#{menu.submenu}#{SiSU_TexInfoFormat::Texinfo.new(@md,dob,@@n4_txt).level5.obj}" @@do_submenu=0 - else dob=mono.level5 + else dob.obj="#{SiSU_TexInfoFormat::Texinfo.new(@md,dob,@@n4_txt).level5.obj}" end when 6; if @@do_submenu==1 menu=SiSU_TexInfoFormat::TeXinfoTxt.new(@md,dob,@submenu[n_menu]) + dob.obj="#{menu.submenu}#{SiSU_TexInfoFormat::Texinfo.new(@md,dob,@@n5_txt).level6.obj}" dob.obj="#{menu.subsubmenu}#{mono.level6.obj}" @@do_subsubmenu=0 - else - dob=mono.level6 + else dob.obj="#{SiSU_TexInfoFormat::Texinfo.new(@md,dob,@@n5_txt).level6.obj}" end end else @@ -337,7 +341,7 @@ module SiSU_TexInfo else if dob.is==:para \ && (dob.obj !~/##{dob.ocn}/) - dob.obj="#{dob.obj} ##{dob.ocn}" + dob.obj="#{dob.obj} ##{dob.ocn}\n\n" end end end diff --git a/lib/sisu/v4/texinfo_format.rb b/lib/sisu/v4/texinfo_format.rb index 04fb06f6..7bfa4e39 100644 --- a/lib/sisu/v4/texinfo_format.rb +++ b/lib/sisu/v4/texinfo_format.rb @@ -68,8 +68,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 @@ -91,7 +91,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 @@ -102,7 +102,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 @@ -138,7 +138,6 @@ WOK @c %% 3 @titlepage @title #{title} -@value{VERSION}, @value{UPDATED} @author #{author} @page @vskip 0pt plus 1filll @@ -293,66 +292,41 @@ WOK 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,''). @@ -554,16 +528,14 @@ WOK 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 diff --git a/lib/sisu/v5/texinfo.rb b/lib/sisu/v5/texinfo.rb index ba890be3..c18b4b1e 100644 --- a/lib/sisu/v5/texinfo.rb +++ b/lib/sisu/v5/texinfo.rb @@ -107,7 +107,7 @@ module SiSU_TexInfo tool=(@opt.act[:verbose][:set]==:on \ || @opt.act[:verbose_plus][:set]==:on \ || @opt.act[:maintenance][:set]==:on) \ - ? "#{@env.program.texinfo} #{@md.file.output_path.texinfo.dir}/#{@md.file.base_filename.info}" + ? "cd #{@md.file.output_path.texinfo.dir} && #{@env.program.texinfo} #{@md.file.base_filename.info}; cd -" : "[#{@opt.f_pth[:lng_is]}] #{@opt.fno}" (@opt.act[:verbose][:set]==:on \ || @opt.act[:verbose_plus][:set]==:on \ @@ -308,32 +308,36 @@ module SiSU_TexInfo @@do_submenu,@@do_subsubmenu=1,1 data_new=[] data.each do |dob| - mono=SiSU_TexInfoFormat::Texinfo.new(@md,dob) + unless defined? dob.ln and dob.ln == (5..6) + mono=SiSU_TexInfoFormat::Texinfo.new(@md,dob) + end if dob.is==:heading case dob.ln when 1 then dob=mono.level1 when 2 then dob=mono.level2 when 3 then dob=mono.level3 when 4; + @@n4_txt=dob.obj dob=mono.level4 n_menu+=1 @@do_submenu,@@do_subsubmenu=1,1 when 5; n_submenu+=1 @@do_subsubmenu=1 + @@n5_txt=dob.obj if @@do_submenu==1 menu=SiSU_TexInfoFormat::TeXinfoTxt.new(@md,dob,@submenu[n_menu]) - dob.obj="#{menu.submenu}#{mono.level5.obj}" + dob.obj="#{menu.submenu}#{SiSU_TexInfoFormat::Texinfo.new(@md,dob,@@n4_txt).level5.obj}" @@do_submenu=0 - else dob=mono.level5 + else dob.obj="#{SiSU_TexInfoFormat::Texinfo.new(@md,dob,@@n4_txt).level5.obj}" end when 6; if @@do_submenu==1 menu=SiSU_TexInfoFormat::TeXinfoTxt.new(@md,dob,@submenu[n_menu]) + dob.obj="#{menu.submenu}#{SiSU_TexInfoFormat::Texinfo.new(@md,dob,@@n5_txt).level6.obj}" dob.obj="#{menu.subsubmenu}#{mono.level6.obj}" @@do_subsubmenu=0 - else - dob=mono.level6 + else dob.obj="#{SiSU_TexInfoFormat::Texinfo.new(@md,dob,@@n5_txt).level6.obj}" end end else @@ -341,8 +345,9 @@ module SiSU_TexInfo dob.obj=nil else if dob.is==:para \ - && (dob.obj !~/##{dob.ocn}/) - dob.obj="#{dob.obj} ##{dob.ocn}" + && (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]}\n\n" : "#{dob.obj}\n\n" end end end @@ -412,7 +417,9 @@ module SiSU_TexInfo FileUtils::mkdir_p(@f.output_path.texinfo.dir) end info_src=%{#{@env.processing_path.texi}/#{@md.fnb}.info} - FileUtils::cp(info_src, @f.place_file.info.dir) + Dir.glob("#{info_src}*").sort.each do |f| + FileUtils::cp(f, File.dirname(@f.place_file.info.dir)) # bug should provide dir without need to extract it! + end end end end 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 diff --git a/lib/sisu/v5/urls.rb b/lib/sisu/v5/urls.rb index d814965f..e9d611ff 100644 --- a/lib/sisu/v5/urls.rb +++ b/lib/sisu/v5/urls.rb @@ -209,7 +209,7 @@ module SiSU_Urls SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"[#{@opt.f_pth[:lng_is]}] -#{x}","#{@prog.manpage_viewer} #{@md.file.output_path.manpage.dir}/#{@md.file.base_filename.manpage}").result end def pinfo(x,y) - SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"[#{@opt.f_pth[:lng_is]}] -#{x}","pinfo -f #{@md.file.output_path.texinfo.dir}/#{@md.file.base_filename.info}").result + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"[#{@opt.f_pth[:lng_is]}] -#{x}","cd #{@md.file.output_path.texinfo.dir} && #{@env.program.texinfo} #{@md.file.base_filename.info}; cd -").result end def po4a def po(x,y) -- cgit v1.2.3 From 0edc0d30bc5503e911ec80c30f2c94eed780bbfc Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sun, 12 Jan 2014 21:18:22 -0500 Subject: v4 v5: texpdf, report to screen on pdf output, link to a generated file-size * decide how to deal with as multiple document file-sizes may be produced --- lib/sisu/v4/texpdf.rb | 4 ++-- lib/sisu/v4/urls.rb | 4 ++-- lib/sisu/v5/texpdf.rb | 4 ++-- lib/sisu/v5/urls.rb | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v4/texpdf.rb b/lib/sisu/v4/texpdf.rb index 3d226533..edefac31 100644 --- a/lib/sisu/v4/texpdf.rb +++ b/lib/sisu/v4/texpdf.rb @@ -114,10 +114,10 @@ module SiSU_TeX if @opt.cmd =~/[MVv]/ @env.url.output_tell if @md.opt.act[:pdf_l][:set]==:on - SiSU_Screen::Ansi.new(@opt.cmd,@opt.fns,"#{@env.program.pdf_viewer} #{@md.file.output_path.pdf.dir}/#{@md.file.base_filename.pdf_l}pdf").flow + SiSU_Screen::Ansi.new(@opt.cmd,@opt.fns,"#{@env.program.pdf_viewer} #{@md.file.output_path.pdf.dir}/#{@md.file.base_filename.pdf_l}#{@md.papersize_array[0]}.pdf").flow end if @md.opt.act[:pdf_p][:set]==:on - SiSU_Screen::Ansi.new(@opt.cmd,@opt.fns,"#{@opt.fns} #{@env.program.pdf_viewer} #{@md.file.output_path.pdf.dir}/#{@md.file.base_filename.pdf_p}pdf").flow + SiSU_Screen::Ansi.new(@opt.cmd,@opt.fns,"#{@opt.fns} #{@env.program.pdf_viewer} #{@md.file.output_path.pdf.dir}/#{@md.file.base_filename.pdf_p}#{@md.papersize_array[0]}.pdf").flow end end @md=@particulars.md diff --git a/lib/sisu/v4/urls.rb b/lib/sisu/v4/urls.rb index af586c52..2af3a5b6 100644 --- a/lib/sisu/v4/urls.rb +++ b/lib/sisu/v4/urls.rb @@ -177,10 +177,10 @@ module SiSU_Urls end def pdf def portrait(x) - SiSU_Screen::Ansi.new(@opt.cmd,"[#{@opt.f_pth[:lng_is]}] -#{x}","#{@prog.pdf_viewer} #{@md.file.output_path.pdf.dir}/#{@md.file.base_filename.pdf_p}pdf").result + SiSU_Screen::Ansi.new(@opt.cmd,"[#{@opt.f_pth[:lng_is]}] -#{x}","#{@prog.pdf_viewer} #{@md.file.output_path.pdf.dir}/#{@md.file.base_filename.pdf_p}#{@md.papersize_array[0]}.pdf").result end def landscape(x) - SiSU_Screen::Ansi.new(@opt.cmd,"[#{@opt.f_pth[:lng_is]}] -#{x}","#{@prog.pdf_viewer} #{@md.file.output_path.pdf.dir}/#{@md.file.base_filename.pdf_l}pdf").result + SiSU_Screen::Ansi.new(@opt.cmd,"[#{@opt.f_pth[:lng_is]}] -#{x}","#{@prog.pdf_viewer} #{@md.file.output_path.pdf.dir}/#{@md.file.base_filename.pdf_l}#{@md.papersize_array[0]}.pdf").result end self end diff --git a/lib/sisu/v5/texpdf.rb b/lib/sisu/v5/texpdf.rb index 4239fac2..d0d88886 100644 --- a/lib/sisu/v5/texpdf.rb +++ b/lib/sisu/v5/texpdf.rb @@ -117,10 +117,10 @@ module SiSU_TeX || @opt.act[:maintenance][:set]==:on) @env.url.output_tell if @md.opt.act[:pdf_l][:set]==:on - SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],@opt.fns,"#{@env.program.pdf_viewer} #{@md.file.output_path.pdf.dir}/#{@md.file.base_filename.pdf_l}pdf").flow + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],@opt.fns,"#{@env.program.pdf_viewer} #{@md.file.output_path.pdf.dir}/#{@md.file.base_filename.pdf_l}#{@md.papersize_array[0]}.pdf").flow end if @md.opt.act[:pdf_p][:set]==:on - SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],@opt.fns,"#{@opt.fns} #{@env.program.pdf_viewer} #{@md.file.output_path.pdf.dir}/#{@md.file.base_filename.pdf_p}pdf").flow + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],@opt.fns,"#{@opt.fns} #{@env.program.pdf_viewer} #{@md.file.output_path.pdf.dir}/#{@md.file.base_filename.pdf_p}#{@md.papersize_array[0]}.pdf").flow end end @md=@particulars.md diff --git a/lib/sisu/v5/urls.rb b/lib/sisu/v5/urls.rb index e9d611ff..cff69c93 100644 --- a/lib/sisu/v5/urls.rb +++ b/lib/sisu/v5/urls.rb @@ -198,10 +198,10 @@ module SiSU_Urls end def pdf def portrait(x) - SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"[#{@opt.f_pth[:lng_is]}] -#{x}","#{@prog.pdf_viewer} #{@md.file.output_path.pdf.dir}/#{@md.file.base_filename.pdf_p}pdf").result + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"[#{@opt.f_pth[:lng_is]}] -#{x}","#{@prog.pdf_viewer} #{@md.file.output_path.pdf.dir}/#{@md.file.base_filename.pdf_p}#{@md.papersize_array[0]}.pdf").result end def landscape(x) - SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"[#{@opt.f_pth[:lng_is]}] -#{x}","#{@prog.pdf_viewer} #{@md.file.output_path.pdf.dir}/#{@md.file.base_filename.pdf_l}pdf").result + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"[#{@opt.f_pth[:lng_is]}] -#{x}","#{@prog.pdf_viewer} #{@md.file.output_path.pdf.dir}/#{@md.file.base_filename.pdf_l}#{@md.papersize_array[0]}.pdf").result end self end -- cgit v1.2.3 From 81108043bb80beeb47214014b07993f0e2a48c9f Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sun, 12 Jan 2014 21:21:25 -0500 Subject: v5: ao, counter for various grouped / blocked texts & tables * of particular use for poems which are broken into verse --- lib/sisu/v5/ao_doc_objects.rb | 20 ++++++++++------ lib/sisu/v5/ao_doc_str.rb | 54 ++++++++++++++++++++++++------------------- 2 files changed, 43 insertions(+), 31 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v5/ao_doc_objects.rb b/lib/sisu/v5/ao_doc_objects.rb index 70696d37..e711a7d8 100644 --- a/lib/sisu/v5/ao_doc_objects.rb +++ b/lib/sisu/v5/ao_doc_objects.rb @@ -253,9 +253,10 @@ module SiSU_AO_DocumentStructure ocn_= if h[:ocn_].nil? then ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider else h[:ocn_] end + num= h[:num] || ((defined? o.num) ? o.num : nil) digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, either sha256 or md5 tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use - @of,@is,@tags,@obj,@idx,@ocn,@odv,@osp,@parent,@number_,@note_,@ocn_,@digest,@tmp=of,is,tags,obj,idx,ocn,odv,osp,parent,number_,note_,ocn_,digest,tmp + @of,@is,@tags,@obj,@idx,@ocn,@odv,@osp,@parent,@number_,@note_,@ocn_,@num,@digest,@tmp=of,is,tags,obj,idx,ocn,odv,osp,parent,number_,note_,ocn_,num,digest,tmp self end def block(h,o=nil) @@ -272,9 +273,10 @@ module SiSU_AO_DocumentStructure ocn_= if h[:ocn_].nil? then ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider else h[:ocn_] end + num= h[:num] || ((defined? o.num) ? o.num : nil) digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, either sha256 or md5 tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use - @of,@is,@tags,@obj,@idx,@ocn,@odv,@osp,@parent,@note_,@ocn_,@digest,@tmp=of,is,tags,obj,idx,ocn,odv,osp,parent,note_,ocn_,digest,tmp + @of,@is,@tags,@obj,@idx,@ocn,@odv,@osp,@parent,@note_,@ocn_,@num,@digest,@tmp=of,is,tags,obj,idx,ocn,odv,osp,parent,note_,ocn_,num,digest,tmp self end def group(h,o=nil) @@ -291,9 +293,10 @@ module SiSU_AO_DocumentStructure ocn_= if h[:ocn_].nil? then ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider else h[:ocn_] end + num= h[:num] || ((defined? o.num) ? o.num : nil) digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, either sha256 or md5 tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use - @of,@is,@tags,@obj,@idx,@ocn,@odv,@osp,@parent,@note_,@ocn_,@digest,@tmp=of,is,tags,obj,idx,ocn,odv,osp,parent,note_,ocn_,digest,tmp + @of,@is,@tags,@obj,@idx,@ocn,@odv,@osp,@parent,@note_,@ocn_,@num,@digest,@tmp=of,is,tags,obj,idx,ocn,odv,osp,parent,note_,ocn_,num,digest,tmp self end def alt(h,o=nil) #see block @@ -310,9 +313,10 @@ module SiSU_AO_DocumentStructure ocn_= if h[:ocn_].nil? then ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider else h[:ocn_] end + num= h[:num] || ((defined? o.num) ? o.num : nil) digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, either sha256 or md5 tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use - @of,@is,@tags,@obj,@idx,@ocn,@odv,@osp,@parent,@note_,@ocn_,@digest,@tmp=of,is,tags,obj,idx,ocn,odv,osp,parent,note_,ocn_,digest,tmp + @of,@is,@tags,@obj,@idx,@ocn,@odv,@osp,@parent,@note_,@ocn_,@num,@digest,@tmp=of,is,tags,obj,idx,ocn,odv,osp,parent,note_,ocn_,num,digest,tmp self end def verse(h,o=nil) #part of poem decide how you deal with this @@ -328,9 +332,10 @@ module SiSU_AO_DocumentStructure ocn_= if h[:ocn_].nil? then ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider else h[:ocn_] end + num= h[:num] || ((defined? o.num) ? o.num : nil) digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, either sha256 or md5 tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use - @of,@is,@tags,@obj,@idx,@ocn,@odv,@osp,@parent,@note_,@ocn_,@digest,@tmp=of,is,tags,obj,idx,ocn,odv,osp,parent,note_,ocn_,digest,tmp + @of,@is,@tags,@obj,@idx,@ocn,@odv,@osp,@parent,@note_,@ocn_,@num,@digest,@tmp=of,is,tags,obj,idx,ocn,odv,osp,parent,note_,ocn_,num,digest,tmp @h=nil self end @@ -339,7 +344,7 @@ module SiSU_AO_DocumentStructure attr_accessor :obj,:is,:of,:lv,:tags,:name,:idx,:indent,:hang,:size,:ocn,:number,:head_,:cols,:widths,:odv,:osp,:parent,:note_,:ocn_,:digest,:tmp def initialize @of=:block - @is=@obj=@lv=@name=@idx=@indent=@hang=@size=@ocn,@number,@head_,@cols,@widths=@odv=@osp=@parent=@note_=@ocn_=@digest=@tmp=nil + @is=@obj=@lv=@name=@idx=@indent=@hang=@size=@ocn,@number,@head_,@cols,@widths=@odv=@osp=@parent=@note_=@ocn_=@num=@digest=@tmp=nil @tags=[] end def table(h,o=nil) @@ -359,9 +364,10 @@ module SiSU_AO_DocumentStructure ocn_=if h[:ocn_].nil? then ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider else h[:ocn_] end + num= h[:num] || ((defined? o.num) ? o.num : nil) digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, either sha256 or md5 tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use - @of,@is,@tags,@cols,@widths,@obj,@idx,@ocn,@odv,@osp,@parent,@head_,@note_,@ocn_,@digest,@tmp=of,is,tags,cols,widths,obj,idx,ocn,odv,osp,parent,head_,note_,ocn_,digest,tmp + @of,@is,@tags,@cols,@widths,@obj,@idx,@ocn,@odv,@osp,@parent,@head_,@note_,@ocn_,@num,@digest,@tmp=of,is,tags,cols,widths,obj,idx,ocn,odv,osp,parent,head_,note_,ocn_,num,digest,tmp self end end diff --git a/lib/sisu/v5/ao_doc_str.rb b/lib/sisu/v5/ao_doc_str.rb index 31479252..f7168c26 100644 --- a/lib/sisu/v5/ao_doc_str.rb +++ b/lib/sisu/v5/ao_doc_str.rb @@ -222,7 +222,7 @@ module SiSU_AO_DocumentStructureExtract def identify_parts tuned_file=[] @tuned_block,@tuned_code=[],[] - @@counter,@verse_count=0,0 + @@counter,@verse_count,@num_code_block,@num_poem,@num_group,@num_block,@num_alt,@num_table=0,0,0,0,0,0,0,0 @metadata={} @data.each do |t_o| if t_o =~/^--([+~-])[#]$/ @@ -408,7 +408,8 @@ module SiSU_AO_DocumentStructureExtract end @@counter=1 @codeblock_numbered=(t_o =~/^(?:code\{#|[`]{3}\s+code\s[#])/) ? true : false - h={ obj: 'code block start' } #introduce a counter + @num_code_block +=1 + h={ obj: "code block start #{@num_code_block}" } t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) elsif t_o =~/^(?:poem\{|[`]{3}\s+poem)/ @@flag[:poem]=case t_o @@ -416,7 +417,8 @@ module SiSU_AO_DocumentStructureExtract when /^[`]{3}\s+poem/ then :tics else @@flag[:poem] #error end - h={ obj: 'poem start' } #introduce a counter + @num_poem +=1 + h={ obj: "poem start #{@num_poem}" } t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) tuned_file << t_o elsif t_o =~/^(?:group\{|[`]{3}\s+group)/ @@ -425,7 +427,8 @@ module SiSU_AO_DocumentStructureExtract when /^[`]{3}\s+group/ then :tics else @@flag[:group] #error end - h={ obj: 'group text start' } #introduce a counter + @num_group +=1 + h={ obj: "group text start #{@num_group}" } t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) tuned_file << t_o elsif t_o =~/^(?:block\{|[`]{3}\s+block)/ @@ -434,7 +437,8 @@ module SiSU_AO_DocumentStructureExtract when /^[`]{3}\s+block/ then :tics else @@flag[:block] #error end - h={ obj: 'block text start' } #introduce a counter + @num_block +=1 + h={ obj: "block text start #{@num_block}" } t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) tuned_file << t_o elsif t_o =~/^(?:alt\{|[`]{3}\s+alt)/ @@ -443,11 +447,13 @@ module SiSU_AO_DocumentStructureExtract when /^[`]{3}\s+alt/ then :tics else @@flag[:alt] #error end - h={ obj: 'alt text start' } #introduce a counter + @num_alt +=1 + h={ obj: "alt text start #{@num_alt}" } t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) tuned_file << t_o elsif t_o =~/^(?:table\{|[`]{3}\s+table|\{table)[ ~]/ - h={ obj: 'table start' } #introduce a counter + @num_table +=1 + h={ obj: "table start #{@num_table}" } ins=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) tuned_file << ins if t_o=~/^table\{(?:~h)?\s+/ @@ -501,10 +507,10 @@ module SiSU_AO_DocumentStructureExtract width=100.00/cols cols.times { col << width } end - h={ head_: hd, cols: cols, widths: col, obj: rows, idx: idx, tags: tags } + h={ head_: hd, cols: cols, widths: col, obj: rows, idx: idx, tags: tags, num: @num_table } t_o=SiSU_AO_DocumentStructure::ObjectTable.new.table(h) unless h.nil? tuned_file << t_o - h={ obj: 'table end' } #introduce a counter + h={ obj: "table end #{@num_table}" } t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) t_o elsif t_o=~/^[`]{3}\s+table(?:~h)?\s+/ @@ -524,10 +530,10 @@ module SiSU_AO_DocumentStructureExtract r=r.gsub(/\s*\|\s*/m,"#{Mx[:tc_p]}") #r.gsub!(/\|/m,"#{Mx[:tc_p]}") rows += r + Mx[:tc_c] end - h={ head_: hd, cols: col.length, widths: col, obj: rows, idx: idx, tags: tags } + h={ head_: hd, cols: col.length, widths: col, obj: rows, idx: idx, tags: tags, num: @num_table } t_o=SiSU_AO_DocumentStructure::ObjectTable.new.table(h) unless h.nil? tuned_file << t_o - h={ obj: 'table end' } #introduce a counter + h={ obj: "table end #{@num_table}" } t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) t_o elsif t_o=~/^\{table(?:~h)?\s+/ @@ -547,10 +553,10 @@ module SiSU_AO_DocumentStructureExtract r=r.gsub(/\s*\|\s*/m,"#{Mx[:tc_p]}") #r.gsub!(/\|/m,"#{Mx[:tc_p]}") rows += r + Mx[:tc_c] end - h={ head_: hd, cols: col.length, widths: col, obj: rows, idx: idx, tags: tags } + h={ head_: hd, cols: col.length, widths: col, obj: rows, idx: idx, tags: tags, num: @num_table } t_o=SiSU_AO_DocumentStructure::ObjectTable.new.table(h) unless h.nil? tuned_file << t_o - h={ obj: 'table end' } #introduce a counter + h={ obj: "table end #{@num_table}" } t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) t_o end @@ -568,7 +574,7 @@ module SiSU_AO_DocumentStructureExtract t_o=SiSU_AO_DocumentStructure::ObjectTable.new.table(@h) tuned_file << t_o @h,@rows=nil,'' - h={ obj: 'table end' } #introduce a counter + h={ obj: "table end #{@num_table}" } t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) t_o else @@ -587,11 +593,11 @@ module SiSU_AO_DocumentStructureExtract @@flag[:code]=:off obj=@tuned_code.join("\n") tags=[] - h={ obj: obj, tags: tags, number_: @codeblock_numbered } + h={ obj: obj, tags: tags, num: @num_code_block, number_: @codeblock_numbered } t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.code(h) @tuned_code=[] tuned_file << t_o - h={ obj: 'code block end' } #introduce a counter + h={ obj: "code block end #{@num_code_block}" } t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) end if (@@flag[:code]==:curls or @@flag[:code]==:tics) \ @@ -610,37 +616,37 @@ module SiSU_AO_DocumentStructureExtract if (@@flag[:poem]==:curls and t_o =~/^\}poem/) \ or (@@flag[:poem]==:tics and t_o =~/^[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) @@flag[:poem]=:off - h={ obj: 'poem end' } #introduce a counter + h={ obj: "poem end #{@num_poem}" } t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) elsif (@@flag[:group]==:curls and t_o =~/^\}group/) \ or (@@flag[:group]==:tics and t_o =~/^[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) @@flag[:group]=:off obj,tags=extract_tags(@tuned_block.join("\n")) - h={ obj: obj, tags: tags } + h={ obj: obj, tags: tags, num: @num_group } @tuned_block=[] t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.group(h) tuned_file << t_o - h={ obj: 'group text end' } #introduce a counter + h={ obj: "group text end #{@num_group}" } t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) elsif (@@flag[:block]==:curls and t_o =~/^\}block/) \ or (@@flag[:block]==:tics and t_o =~/^[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) @@flag[:block]=:off obj,tags=extract_tags(@tuned_block.join("\n")) - h={ obj: obj, tags: tags } + h={ obj: obj, tags: tags, num: @num_block } @tuned_block=[] t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.block(h) tuned_file << t_o - h={ obj: 'block text end' } #introduce a counter + h={ obj: "block text end #{@num_block}" } t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) elsif (@@flag[:alt]==:curls and t_o =~/^\}alt/) \ or (@@flag[:alt]==:tics and t_o =~/^[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) @@flag[:alt]=:off obj,tags=extract_tags(@tuned_block.join("\n")) - h={ obj: obj, tags: tags } + h={ obj: obj, tags: tags, num: @num_alt } t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.alt(h) @tuned_block=[] tuned_file << t_o - h={ obj: 'alt text end' } #introduce a counter + h={ obj: "alt text end #{@num_alt}" } t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) end if (@@flag[:poem]==:curls or @@flag[:poem]==:tics \ @@ -657,7 +663,7 @@ module SiSU_AO_DocumentStructureExtract poem.each do |v| v=v.gsub(/\n/m,"#{Mx[:br_nl]}\n") obj,tags=extract_tags(v) - h={ obj: obj, tags: tags } + h={ obj: obj, tags: tags, num: @num_poem } t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.verse(h) tuned_file << t_o end -- cgit v1.2.3 From 4aa58e16055fd24b7958c50397a27795105743e6 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sun, 12 Jan 2014 21:25:51 -0500 Subject: v5: heading recalibration, code (downstream) changes, continue --- lib/sisu/v5/constants.rb | 4 +++- lib/sisu/v5/manpage.rb | 12 ++---------- lib/sisu/v5/manpage_format.rb | 14 -------------- lib/sisu/v5/texinfo.rb | 3 ++- lib/sisu/v5/texinfo_format.rb | 3 +++ lib/sisu/v5/txt_asciidoc.rb | 4 +++- lib/sisu/v5/txt_markdown.rb | 2 ++ lib/sisu/v5/txt_rst.rb | 1 + lib/sisu/v5/txt_textile.rb | 1 + lib/sisu/v5/xml_docbook5.rb | 23 ++++++++--------------- 10 files changed, 25 insertions(+), 42 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v5/constants.rb b/lib/sisu/v5/constants.rb index 1b7cccea..b89f9be8 100644 --- a/lib/sisu/v5/constants.rb +++ b/lib/sisu/v5/constants.rb @@ -102,6 +102,7 @@ Xx={ } Mx={ meta_o: '〔@', meta_c: '〕', + lv_o_0: 0, lv_o_1: 1, lv_o_2: 2, lv_o_3: 3, @@ -175,7 +176,8 @@ Hx={ #Mx[:sm_subset_o]='∈ '; Mx[:sm_subset_c]='∋ ' Rx={ mx_fa_clean: /#{Mx[:fa_o]}.+?#{Mx[:fa_c]}|#{Mx[:pa_o]}.+?#{Mx[:pa_c]}|#{Mx[:mk_o]}.+?#{Mx[:mk_c]}/, - lv: /〔([1-9]):(\S*?)〕/, + lv: /〔([0-9]):(\S*?)〕/, + lv_0: /#{Mx[:lv_o_0]}(\S*?)#{Mx[:lv_c]}/, lv_1: /#{Mx[:lv_o_1]}(\S*?)#{Mx[:lv_c]}/, lv_2: /#{Mx[:lv_o_2]}(\S*?)#{Mx[:lv_c]}/, lv_3: /#{Mx[:lv_o_3]}(\S*?)#{Mx[:lv_c]}/, diff --git a/lib/sisu/v5/manpage.rb b/lib/sisu/v5/manpage.rb index 0fe2b0b1..e675da3b 100644 --- a/lib/sisu/v5/manpage.rb +++ b/lib/sisu/v5/manpage.rb @@ -238,8 +238,8 @@ WOK times=wrapped.length times=78 if times > 78 @manpage[:body] << case lv - when 1 then '.SH ' << wrapped.upcase << break_line << break_line - when 2..3 then '.SH ' << wrapped.upcase << break_line << break_line + when 0 then '.SH ' << wrapped.upcase << break_line << break_line + when 1..3 then '.SH ' << wrapped.upcase << break_line << break_line when 4 then '.SH ' << wrapped.upcase << break_line << break_line when 5..6 then '.SH ' << wrapped.upcase << break_line << break_line end @@ -340,14 +340,6 @@ WOK x=SiSU_ManpageFormat::FormatTextObject.new(@md,dob) if dob.is==:heading manpage_structure(dob) - dob.obj=case dob.ln - when 1 then x.heading_body1 - when 2 then x.heading_body2 - when 3 then x.heading_body3 - when 4 then x.heading_body4 - when 5 then x.heading_body5 - when 6 then x.heading_body6 - end elsif dob.is==:para manpage_structure(dob) else diff --git a/lib/sisu/v5/manpage_format.rb b/lib/sisu/v5/manpage_format.rb index dae1d6b3..7a9ea98b 100644 --- a/lib/sisu/v5/manpage_format.rb +++ b/lib/sisu/v5/manpage_format.rb @@ -88,20 +88,6 @@ module SiSU_ManpageFormat def scr_endnote_body "#{@dob.obj} " end - def heading_body1 - end - def heading_body2 - end - def heading_body3 - end - def heading_body4 - end - def heading_body5 - end - def heading_body6 - end - end - class XML end end __END__ diff --git a/lib/sisu/v5/texinfo.rb b/lib/sisu/v5/texinfo.rb index c18b4b1e..955b1060 100644 --- a/lib/sisu/v5/texinfo.rb +++ b/lib/sisu/v5/texinfo.rb @@ -272,7 +272,7 @@ module SiSU_TexInfo @submenu,@subsubmenu={},{} data.each do |dob| if dob.is ==:heading \ - && (dob.ln.to_s =~ /^[1-3]$/) + && (dob.ln.to_s =~ /^[0-3]$/) toc=SiSU_TexInfoFormat::Texinfo.new(@md,dob) texinfo_menu << toc.menu elsif dob.is ==:heading \ @@ -313,6 +313,7 @@ module SiSU_TexInfo end if dob.is==:heading case dob.ln + when 0 then dob=mono.level0 when 1 then dob=mono.level1 when 2 then dob=mono.level2 when 3 then dob=mono.level3 diff --git a/lib/sisu/v5/texinfo_format.rb b/lib/sisu/v5/texinfo_format.rb index 5d513041..4286f50b 100644 --- a/lib/sisu/v5/texinfo_format.rb +++ b/lib/sisu/v5/texinfo_format.rb @@ -311,6 +311,9 @@ WOK dob.obj="@node #{nd}, #{up}\n@comment node-name, up\n@unnumbered #{nd}\n@cindex chapter, #{nd}\n\n" dob end + def level0 + level_common + end def level1 level_common end diff --git a/lib/sisu/v5/txt_asciidoc.rb b/lib/sisu/v5/txt_asciidoc.rb index 07b8832f..8bdca1a2 100644 --- a/lib/sisu/v5/txt_asciidoc.rb +++ b/lib/sisu/v5/txt_asciidoc.rb @@ -258,7 +258,7 @@ WOK '+' end def l5 - '' #'.' #proposed + '.' #'.' #proposed end self end @@ -368,6 +368,7 @@ WOK def heading_decorated_inline(dob) if dob.is==:heading heading_inline = case dob.lc + when 0 then decorate.heading.inline.l0 when 1 then decorate.heading.inline.l1 when 2 then decorate.heading.inline.l2 when 3 then decorate.heading.inline.l3 @@ -382,6 +383,7 @@ WOK if dob.is==:heading #times=@wrap_width if times > @wrap_width case dob.lc + when 0 then decorate.heading.underscore.l0*times + p_num << break_line*2 when 1 then decorate.heading.underscore.l1*times + p_num << break_line*2 when 2 then decorate.heading.underscore.l2*times + p_num << break_line*2 when 3 then decorate.heading.underscore.l3*times + p_num << break_line*2 diff --git a/lib/sisu/v5/txt_markdown.rb b/lib/sisu/v5/txt_markdown.rb index 96aca820..8b081349 100644 --- a/lib/sisu/v5/txt_markdown.rb +++ b/lib/sisu/v5/txt_markdown.rb @@ -368,6 +368,7 @@ WOK def heading_decorated_inline(dob) if dob.is==:heading heading_inline = case dob.lc + when 0 then decorate.heading.inline.l0 when 1 then decorate.heading.inline.l1 when 2 then decorate.heading.inline.l2 when 3 then decorate.heading.inline.l3 @@ -382,6 +383,7 @@ WOK if dob.is==:heading #times=@wrap_width if times > @wrap_width case dob.lc + when 0 then decorate.heading.underscore.l0*times + p_num << break_line*2 when 1 then decorate.heading.underscore.l1*times + p_num << break_line*2 when 2 then decorate.heading.underscore.l2*times + p_num << break_line*2 when 3 then decorate.heading.underscore.l3*times + p_num << break_line*2 diff --git a/lib/sisu/v5/txt_rst.rb b/lib/sisu/v5/txt_rst.rb index 56a34de2..8565de5f 100644 --- a/lib/sisu/v5/txt_rst.rb +++ b/lib/sisu/v5/txt_rst.rb @@ -348,6 +348,7 @@ WOK if dob.is==:heading #times=@wrap_width if times > @wrap_width case dob.lc + when 0 then decorate.heading.underscore.l0*times + p_num << break_line*2 when 1 then decorate.heading.underscore.l1*times + p_num << break_line*2 when 2 then decorate.heading.underscore.l2*times + p_num << break_line*2 when 3 then decorate.heading.underscore.l3*times + p_num << break_line*2 diff --git a/lib/sisu/v5/txt_textile.rb b/lib/sisu/v5/txt_textile.rb index 5645f490..7b9f10a8 100644 --- a/lib/sisu/v5/txt_textile.rb +++ b/lib/sisu/v5/txt_textile.rb @@ -346,6 +346,7 @@ WOK end def heading_decorated_inline(dob) heading_inline = case dob.lc + when 0 then decorate.heading.inline.l0 when 1 then decorate.heading.inline.l1 when 2 then decorate.heading.inline.l2 when 3 then decorate.heading.inline.l3 diff --git a/lib/sisu/v5/xml_docbook5.rb b/lib/sisu/v5/xml_docbook5.rb index 0dddf264..be9ad802 100644 --- a/lib/sisu/v5/xml_docbook5.rb +++ b/lib/sisu/v5/xml_docbook5.rb @@ -136,20 +136,13 @@ module SiSU_XML_Docbook_Book end def docbook(lc,chlv='') case lc - when 0 - 'book' - when 1 - lc==chlv ? 'chapter' : 'section' - when 2 - lc==chlv ? 'chapter' : 'section' - when 3 - lc==chlv ? 'chapter' : 'section' - when 4 - 'section' - when 5 - 'section' - when 6 - 'section' + when 0 then 'book' + when 1 then lc==chlv ? 'chapter' : 'section' + when 2 then lc==chlv ? 'chapter' : 'section' + when 3 then lc==chlv ? 'chapter' : 'section' + when 4 then 'section' + when 5 then 'section' + when 6 then 'section' end end self @@ -181,7 +174,7 @@ module SiSU_XML_Docbook_Book put(tail) end def output(o,comment='') - puts o.lc == 0..6 \ + puts o.lc == (0..6) \ ? "#{space*o.lc}<#{o.lc}>[#{o.ocn}] #{o.ln} #{o.obj}#{comment}" : "<#{o.lc}>[#{o.ocn}] #{o.ln} #{o.obj}#{comment}" end -- cgit v1.2.3 From 593766d8dff3c31e8bcf25f02a37606ac537aa21 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sun, 12 Jan 2014 21:28:18 -0500 Subject: v5: asciidoc, file extension (for now .ad), inline footnotes, minor --- lib/sisu/v5/constants.rb | 2 +- lib/sisu/v5/txt_asciidoc.rb | 41 +++-------------------------------------- 2 files changed, 4 insertions(+), 39 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v5/constants.rb b/lib/sisu/v5/constants.rb index b89f9be8..04c0358a 100644 --- a/lib/sisu/v5/constants.rb +++ b/lib/sisu/v5/constants.rb @@ -66,7 +66,7 @@ YEAR='2014' Sfx={ txt: '.txt', txt_textile: '.textile', - txt_asciidoc: '.asciidoc.txt', + txt_asciidoc: '.ad', txt_markdown: '.md', txt_rst: '.rst', html: '.html', diff --git a/lib/sisu/v5/txt_asciidoc.rb b/lib/sisu/v5/txt_asciidoc.rb index 8bdca1a2..98df1cfc 100644 --- a/lib/sisu/v5/txt_asciidoc.rb +++ b/lib/sisu/v5/txt_asciidoc.rb @@ -141,42 +141,6 @@ module SiSU_Txt_AsciiDoc "\n" end # Used for extraction of endnotes from paragraphs - def extract_endnotes(dob='') - notes=dob.obj.scan(/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]})([\d*+]+\s+.+?)(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/) - @n=[] - notes.flatten.each do |n| #high cost to deal with
appropriately within plaintext, consider - n=n.dup.to_s - if n =~/#{Mx[:br_line]}|#{Mx[:br_nl]}/ - fix = n.split(/#{Mx[:br_line]}|#{Mx[:br_nl]}/) #watch #added - fix.each do |x| - unless x.empty?; @n << x - end - end - else @n << n - end - end - notes=@n.flatten - notes.each do |e| - util=(e.to_s =~/^\[[\d*+]+\]:/) \ - ? (SiSU_TextUtils::Wrap.new(e.to_s,@wrap_width,4,1)) - : (SiSU_TextUtils::Wrap.new(e.to_s,@wrap_width,1,1)) - wrap=util.line_wrap - wrap=if wrap =~ /^\s*[\d*+]+\s+.+?\s*\Z/m - wrap.gsub(/^(\s*)([\d*+]+)\s+(.+?)\s*\Z/m, <<-GSUB -\\1[\\2]: \\3 - GSUB - ) - else - wrap.gsub(/^(.+)\Z/m, <<-GSUB -\\1 - GSUB - ) - end - @@endnotes[:para] << "-#{wrap}" - @@endnotes[:end] << '' << wrap - end - @@endnotes - end def plaintext_metadata array=SiSU_Metadata::Summary.new(@md).plaintext.metadata array.each do |meta| @@ -473,7 +437,8 @@ WOK gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,'\1 [link: <\2>]'). gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}image/,'\1 [link: local image]'). gsub(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,"#{@brace_url.txt_open}\\1#{@brace_url.txt_close}") - extract_endnotes(dob) + dob.obj=dob.obj.gsub(/\s*#{Mx[:en_a_o]}([\d*+]+)\s+(.+?)#{Mx[:en_a_c]}/,' footnote:[note\1,\2]'). + gsub(/\s*#{Mx[:en_b_o]}([\d*+]+\s+.+?)#{Mx[:en_b_c]}/,' footnote:[\1]') dob.obj=dob.obj.gsub(/#{Mx[:en_a_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_a_c]}/,'[^\1]'). # endnote marker marked up gsub(/#{Mx[:en_b_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_b_c]}/,'[^\1]'). # endnote marker marked up gsub(/#{Mx[:gl_o]}(?:#lt|#060)#{Mx[:gl_c]}/,'<'). @@ -521,7 +486,7 @@ WOK @plaintext[:body] << dob.obj + p_num << break_line elsif dob.is==:break sp=' ' - ln='-' + ln='<' #ln='-' @plaintext[:body] <<=if dob.obj==Mx[:br_page] \ or dob.obj==Mx[:br_page_new] \ or dob.obj==Mx[:br_page_line] -- cgit v1.2.3