From e38554e5acad9b3dd93b0e6e4cedd39d5ff2f1a2 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 12 May 2014 20:31:23 -0400 Subject: v5 v6: coding, various minor cosmetic --- lib/sisu/v5/constants.rb | 2 +- lib/sisu/v5/digests.rb | 12 +++++------ lib/sisu/v5/html_format.rb | 2 +- lib/sisu/v5/html_minitoc.rb | 3 ++- lib/sisu/v6/constants.rb | 2 +- lib/sisu/v6/digests.rb | 12 +++++------ lib/sisu/v6/html_format.rb | 2 +- lib/sisu/v6/html_minitoc.rb | 3 ++- lib/sisu/v6/texpdf_format.rb | 46 ++++++++++++++++++++--------------------- lib/sisu/v6/xml_docbook5.rb | 2 +- lib/sisu/v6/xml_fictionbook2.rb | 2 +- 11 files changed, 45 insertions(+), 43 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v5/constants.rb b/lib/sisu/v5/constants.rb index a9be54f0..d47d9a7e 100644 --- a/lib/sisu/v5/constants.rb +++ b/lib/sisu/v5/constants.rb @@ -353,7 +353,7 @@ check: ♩ ♭  ✠  ▭ ▬ ▪ 【】〖〗◢ ◣ ◀ ▶ ◘ ◙ 《》「」 - ‹ › ∗  + ‹ › ∗  ∴ ∷ '〔lv1〕','〔lv2〕','〔lv3〕','〔lv4〕','〔lv5〕','〔lv6〕','〔lv7〕','〔lv8〕','〔lv9〕' '〔 Ѳ1〕','〔 Ѳ2〕','〔 Ѳ3〕','〔 Ѳ4〕','〔 Ѳ5〕','〔Ѳ6〕','〔Ѳ7〕','〔Ѳ8〕','〔Ѳ9〕' ◁▷ diff --git a/lib/sisu/v5/digests.rb b/lib/sisu/v5/digests.rb index 7099b646..3acd51eb 100644 --- a/lib/sisu/v5/digests.rb +++ b/lib/sisu/v5/digests.rb @@ -91,13 +91,13 @@ module SiSU_DigestView if @opt.act[:verbose_plus][:set]==:on \ or @opt.act[:maintenance][:set]==:on SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],@opt.fns,"file://#{@md.file.output_path.hash_digest.dir}/#{@md.file.base_filename.hash_digest}").flow - end - end - if SiSU_Env::SystemCall.new.openssl - SiSU_DigestView::Source::Scroll.new(@particulars).songsheet - else - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('*EXITED* hash digests will not run without openssl') end + end + if SiSU_Env::SystemCall.new.openssl + SiSU_DigestView::Source::Scroll.new(@particulars).songsheet + else + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('*EXITED* hash digests will not run without openssl') + end rescue SiSU_Errors::Rescued.new($!,$@,@opt.cmd,@opt.fns).location do __LINE__.to_s + ':' + __FILE__ diff --git a/lib/sisu/v5/html_format.rb b/lib/sisu/v5/html_format.rb index e244bbb8..058a8f34 100644 --- a/lib/sisu/v5/html_format.rb +++ b/lib/sisu/v5/html_format.rb @@ -217,7 +217,7 @@ module SiSU_HTML_Format @env=SiSU_Env::InfoEnv.new(md.fns) @file=SiSU_Env::FileOp.new(md) @o_str ||=SiSU_Env::ProcessingSettings.new(md).output_dir_structure - @make=SiSU_Env::ProcessingSettings.new(@md) + @make=SiSU_Env::ProcessingSettings.new(md) end def home %{ diff --git a/lib/sisu/v5/html_minitoc.rb b/lib/sisu/v5/html_minitoc.rb index 5366b127..8b802a81 100644 --- a/lib/sisu/v5/html_minitoc.rb +++ b/lib/sisu/v5/html_minitoc.rb @@ -143,7 +143,8 @@ end txt_obj={ txt: title } format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) - toc_mini=if txt.name =~/^meta/ and txt.obj=~/Document Information/ + toc_mini=if txt.name =~/^meta/ \ + and txt.obj=~/Document Information/ format_toc.mini_tail else format_toc.mini_lev1 end diff --git a/lib/sisu/v6/constants.rb b/lib/sisu/v6/constants.rb index e70a2f98..0f76ed59 100644 --- a/lib/sisu/v6/constants.rb +++ b/lib/sisu/v6/constants.rb @@ -353,7 +353,7 @@ check: ♩ ♭  ✠  ▭ ▬ ▪ 【】〖〗◢ ◣ ◀ ▶ ◘ ◙ 《》「」 - ‹ › ∗  + ‹ › ∗  ∴ ∷ '〔lv1〕','〔lv2〕','〔lv3〕','〔lv4〕','〔lv5〕','〔lv6〕','〔lv7〕','〔lv8〕','〔lv9〕' '〔 Ѳ1〕','〔 Ѳ2〕','〔 Ѳ3〕','〔 Ѳ4〕','〔 Ѳ5〕','〔Ѳ6〕','〔Ѳ7〕','〔Ѳ8〕','〔Ѳ9〕' ◁▷ diff --git a/lib/sisu/v6/digests.rb b/lib/sisu/v6/digests.rb index e708e4e9..1fa2c80f 100644 --- a/lib/sisu/v6/digests.rb +++ b/lib/sisu/v6/digests.rb @@ -91,13 +91,13 @@ module SiSU_DigestView if @opt.act[:verbose_plus][:set]==:on \ or @opt.act[:maintenance][:set]==:on SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],@opt.fns,"file://#{@md.file.output_path.hash_digest.dir}/#{@md.file.base_filename.hash_digest}").flow - end - end - if SiSU_Env::SystemCall.new.openssl - SiSU_DigestView::Source::Scroll.new(@particulars).songsheet - else - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('*EXITED* hash digests will not run without openssl') end + end + if SiSU_Env::SystemCall.new.openssl + SiSU_DigestView::Source::Scroll.new(@particulars).songsheet + else + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('*EXITED* hash digests will not run without openssl') + end rescue SiSU_Errors::Rescued.new($!,$@,@opt.cmd,@opt.fns).location do __LINE__.to_s + ':' + __FILE__ diff --git a/lib/sisu/v6/html_format.rb b/lib/sisu/v6/html_format.rb index de5a7144..2f7b030e 100644 --- a/lib/sisu/v6/html_format.rb +++ b/lib/sisu/v6/html_format.rb @@ -217,7 +217,7 @@ module SiSU_HTML_Format @env=SiSU_Env::InfoEnv.new(md.fns) @file=SiSU_Env::FileOp.new(md) @o_str ||=SiSU_Env::ProcessingSettings.new(md).output_dir_structure - @make=SiSU_Env::ProcessingSettings.new(@md) + @make=SiSU_Env::ProcessingSettings.new(md) end def home %{ diff --git a/lib/sisu/v6/html_minitoc.rb b/lib/sisu/v6/html_minitoc.rb index 13045b0d..b36188ec 100644 --- a/lib/sisu/v6/html_minitoc.rb +++ b/lib/sisu/v6/html_minitoc.rb @@ -143,7 +143,8 @@ end txt_obj={ txt: title } format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) - toc_mini=if txt.name =~/^meta/ and txt.obj=~/Document Information/ + toc_mini=if txt.name =~/^meta/ \ + and txt.obj=~/Document Information/ format_toc.mini_tail else format_toc.mini_lev1 end diff --git a/lib/sisu/v6/texpdf_format.rb b/lib/sisu/v6/texpdf_format.rb index 97007d17..c1bd0f1c 100644 --- a/lib/sisu/v6/texpdf_format.rb +++ b/lib/sisu/v6/texpdf_format.rb @@ -1188,16 +1188,16 @@ module SiSU_TeX_Pdf @brace_url=SiSU_Viz::Defaults.new.url_decoration @tex2pdf=@@tex3pdf ||=SiSU_Env::SystemCall.new.tex2pdf_engine end - def xetex_code_listings(str,is=:default) # ~ ^ $ & % _ { } #LaTeX special characters - KEEP list + def xetex_code_listings(str,is=:default) # ~ ^ $ & % _ { } #LaTeX special characters - KEEP list word=str.scan(/\S+|\n/) #unless line =~/^(?:@\S|%+\s)/ para_array=[] str=if word word.each do |w| # _ - / # | : ! ^ ~ w=w.gsub(/#{Mx[:gl_o]}#lt#{Mx[:gl_c]}/,'<').gsub(/#{Mx[:gl_o]}#gt#{Mx[:gl_c]}/,'>'). gsub(/[\\]?~/,'~'). - gsub(/[#{Mx[:br_line]}#{Mx[:br_paragraph]}]/,"\n"). #watch - gsub(/#{Mx[:gl_o]}#(?:126|152)#{Mx[:gl_c]}/,'~'). #126 usual - gsub(/\\?\||#{Mx[:gl_o]}#124#{Mx[:gl_c]}/,'|') #unless is=='code' #unless w=~/<~\d+;(?:[ohmu]|[0-6]:)\d+;\w\d+>/ # | SiSU not really special sisu character but done, also LaTeX + gsub(/[#{Mx[:br_line]}#{Mx[:br_paragraph]}]/,"\n"). #watch + gsub(/#{Mx[:gl_o]}#(?:126|152)#{Mx[:gl_c]}/,'~'). #126 usual + gsub(/\\?\||#{Mx[:gl_o]}#124#{Mx[:gl_c]}/,'|') #unless is=='code' #unless w=~/<~\d+;(?:[ohmu]|[0-6]:)\d+;\w\d+>/ # | SiSU not really special sisu character but done, also LaTeX para_array << w end str=para_array.join(' ') @@ -1210,30 +1210,30 @@ module SiSU_TeX_Pdf gsub(/#{Mx[:br_eof]}/,''). gsub(/#{Mx[:br_endnotes]}/,''). #problem sequence -> - gsub(/&(?:lt|#060);/,'<'). # < SiSU special character also LaTeX - gsub(/#{Mx[:gl_o]}#(?:gt|062)#{Mx[:gl_c]}/,'>'). # > SiSU special character also LaTeX - gsub(/#{Mx[:gl_o]}#123#{Mx[:gl_c]}/,'{'). # { SiSU special character also LaTeX - gsub(/#{Mx[:gl_o]}#125#{Mx[:gl_c]}/,'}'). # } SiSU special character also LaTeX - gsub(/#{Mx[:gl_o]}#(?:126|152)#{Mx[:gl_c]}/,'~'). # ~ SiSU special character also LaTeX - gsub(/#{Mx[:gl_o]}#035#{Mx[:gl_c]}/,'#'). # # SiSU special character also LaTeX + gsub(/&(?:lt|#060);/,'<'). # < SiSU special character also LaTeX + gsub(/#{Mx[:gl_o]}#(?:gt|062)#{Mx[:gl_c]}/,'>'). # > SiSU special character also LaTeX + gsub(/#{Mx[:gl_o]}#123#{Mx[:gl_c]}/,'{'). # { SiSU special character also LaTeX + gsub(/#{Mx[:gl_o]}#125#{Mx[:gl_c]}/,'}'). # } SiSU special character also LaTeX + gsub(/#{Mx[:gl_o]}#(?:126|152)#{Mx[:gl_c]}/,'~'). # ~ SiSU special character also LaTeX + gsub(/#{Mx[:gl_o]}#035#{Mx[:gl_c]}/,'#'). # SiSU special character also LaTeX gsub(/#{Mx[:gl_o]}#033#{Mx[:gl_c]}/,'!'). # ! SiSU not really special sisu character but done, also LaTeX #gsub(/(^|\s)\*\s/,'\1\asterisk '). # * should you wish to escape astrisk e.g. describing \*{bold}* - gsub(/#{Mx[:gl_o]}#042#{Mx[:gl_c]}/,'*'). # * should you wish to escape astrisk e.g. describing \*{bold}* + gsub(/#{Mx[:gl_o]}#042#{Mx[:gl_c]}/,'*'). # * should you wish to escape astrisk e.g. describing \*{bold}* gsub(/#{Mx[:gl_o]}#045#{Mx[:gl_c]}/,'-'). # - SiSU special character also LaTeX gsub(/#{Mx[:gl_o]}#043#{Mx[:gl_c]}/,'+'). # + SiSU special character also LaTeX gsub(/#{Mx[:gl_o]}#044#{Mx[:gl_c]}/,','). # + SiSU special character also LaTeX - gsub(/#{Mx[:gl_o]}#038#{Mx[:gl_c]}/,'&'). #unless @txt=~/<:code>/ # / SiSU special character also LaTeX - gsub(/#{Mx[:gl_o]}#047#{Mx[:gl_c]}/,'/'). # / SiSU special character also LaTeX - gsub(/#{Mx[:gl_o]}#092#{Mx[:gl_c]}/,'\\'). # \ SiSU special character also LaTeX - gsub(/#{Mx[:gl_o]}#095#{Mx[:gl_c]}/,'_'). # _ SiSU special character also LaTeX + gsub(/#{Mx[:gl_o]}#038#{Mx[:gl_c]}/,'&'). #unless @txt=~/<:code>/ # / SiSU special character also LaTeX + gsub(/#{Mx[:gl_o]}#047#{Mx[:gl_c]}/,'/'). # / SiSU special character also LaTeX + gsub(/#{Mx[:gl_o]}#092#{Mx[:gl_c]}/,'\\'). # \ SiSU special character also LaTeX + gsub(/#{Mx[:gl_o]}#095#{Mx[:gl_c]}/,'_'). # _ SiSU special character also LaTeX gsub(/#{Mx[:gl_o]}#124#{Mx[:gl_c]}/,'|'). # | SiSU not really special sisu character but done, also LaTeX gsub(/#{Mx[:gl_o]}#058#{Mx[:gl_c]}/,':'). # : SiSU not really special sisu character but done, also LaTeX - gsub(/#{Mx[:gl_o]}#094#{Mx[:gl_c]}|\^/,'^'). # ^ SiSU not really special sisu character but done, also LaTeX + gsub(/#{Mx[:gl_o]}#094#{Mx[:gl_c]}|\^/,'^'). # ^ SiSU not really special sisu character but done, also LaTeX ##watch placement, problem sequence ^ gsub(/&atild;<\/font><\/sup>/,' '). - gsub(/\\copy(right|mark)?/,'<=copymark>') # ok problem with superscript + gsub(/\\copy(right|mark)?/,'<=copymark>') # ok problem with superscript end - def xetex_special_characters_1(str,is=:default) # ~ ^ $ & % _ { } #LaTeX special characters - KEEP list + def xetex_special_characters_1(str,is=:default) # ~ ^ $ & % _ { } #LaTeX special characters - KEEP list word=str.scan(/\S+|\n/) #unless line =~/^(?:@\S|%+\s)/ para_array=[] str=if word @@ -1245,9 +1245,9 @@ module SiSU_TeX_Pdf end w=w.gsub(/#{Mx[:gl_o]}#lt#{Mx[:gl_c]}/,'<').gsub(/#{Mx[:gl_o]}#gt#{Mx[:gl_c]}/,'>'). gsub(/[\\]?~/,'<=tilde>'). - gsub(/[#{Mx[:br_line]}#{Mx[:br_paragraph]}]/,' \newline '). #watch - gsub(/#{Mx[:gl_o]}#(?:126|152)#{Mx[:gl_c]}/,'<=tilde>'). #126 usual - gsub(/\\?\||#{Mx[:gl_o]}#124#{Mx[:gl_c]}/,'\pipe') #unless is=='code' #unless w=~/<~\d+;(?:[ohmu]|[0-6]:)\d+;\w\d+>/ # | SiSU not really special sisu character but done, also LaTeX + gsub(/[#{Mx[:br_line]}#{Mx[:br_paragraph]}]/,' \newline '). #watch + gsub(/#{Mx[:gl_o]}#(?:126|152)#{Mx[:gl_c]}/,'<=tilde>'). #126 usual + gsub(/\\?\||#{Mx[:gl_o]}#124#{Mx[:gl_c]}/,'\pipe') #unless is=='code' #unless w=~/<~\d+;(?:[ohmu]|[0-6]:)\d+;\w\d+>/ # | SiSU not really special sisu character but done, also LaTeX if w !~/#{Mx[:rel_o]}/ \ and w !~/#{Mx[:gl_o]}#/ w=w.gsub(/\#/,'<=hash>') @@ -1264,8 +1264,8 @@ module SiSU_TeX_Pdf gsub(/#{Mx[:br_eof]}/,''). gsub(/#{Mx[:br_endnotes]}/,'') #problem sequence -> - str=str.gsub(/&(?:nbsp);|#{Mx[:nbsp]}/,'\hardspace') unless is==:code # < SiSU special character also LaTeX - str=str.gsub(/&(?:lt|#060);/,'\lt'). # < SiSU special character also LaTeX + str=str.gsub(/&(?:nbsp);|#{Mx[:nbsp]}/,'\hardspace') unless is==:code # < SiSU special character also LaTeX + str=str.gsub(/&(?:lt|#060);/,'\lt'). # < SiSU special character also LaTeX gsub(/#{Mx[:gl_o]}#(?:gt|062)#{Mx[:gl_c]}/,'\gt'). # > SiSU special character also LaTeX gsub(/#{Mx[:gl_o]}#123#{Mx[:gl_c]}/,'\curlyopen'). # { SiSU special character also LaTeX gsub(/#{Mx[:gl_o]}#125#{Mx[:gl_c]}/,'\curlyclose'). # } SiSU special character also LaTeX diff --git a/lib/sisu/v6/xml_docbook5.rb b/lib/sisu/v6/xml_docbook5.rb index 84c2181c..98369836 100644 --- a/lib/sisu/v6/xml_docbook5.rb +++ b/lib/sisu/v6/xml_docbook5.rb @@ -110,7 +110,7 @@ module SiSU_XML_Docbook_Book class Scroll [#{o.ocn}] #{o.ln} #{o.obj}#{comment}" : "<#{o.lc}>[#{o.ocn}] #{o.ln} #{o.obj}#{comment}" end -- cgit v1.2.3 From f06613bb90d370053963d544b14ee7c3e8706671 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 12 May 2014 20:33:11 -0400 Subject: v6: xml object citation numbering (docbook fictionbook) --- lib/sisu/v6/xml_docbook5.rb | 5 ++++- lib/sisu/v6/xml_fictionbook2.rb | 7 ++++++- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v6/xml_docbook5.rb b/lib/sisu/v6/xml_docbook5.rb index 98369836..f5dba87a 100644 --- a/lib/sisu/v6/xml_docbook5.rb +++ b/lib/sisu/v6/xml_docbook5.rb @@ -113,6 +113,7 @@ module SiSU_XML_Docbook_Book @trans=SiSU_XML_Munge::Trans.new(md) @particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(md.opt) @env=@particulars.env + @make ||=SiSU_Env::ProcessingSettings.new(md) end def songsheet @t='sisu' @@ -198,7 +199,9 @@ module SiSU_XML_Docbook_Book filename_docbook.puts head data.each_with_index do |o,i| if (defined? o.ocn and not o.ocn.nil?) - ocn="\n#{Dx[:ocn_o]}#{o.ocn}#{Dx[:ocn_c]}" + ocn=(@make.build.ocn?) \ + ? "\n#{Dx[:ocn_o]}#{o.ocn}#{Dx[:ocn_c]}" + : '' id=%{ id="o#{o.ocn}" } else ocn,id='','' diff --git a/lib/sisu/v6/xml_fictionbook2.rb b/lib/sisu/v6/xml_fictionbook2.rb index 7d86e9f9..d0ad4a7f 100644 --- a/lib/sisu/v6/xml_fictionbook2.rb +++ b/lib/sisu/v6/xml_fictionbook2.rb @@ -304,7 +304,12 @@ module SiSU_XML_Fictionbook doc_position=:head filename_fictionbook.puts head 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]}" : '' + ocn=if @make.build.ocn? + (defined? o.ocn and not o.ocn.nil?) \ + ? "\n#{Dx[:ocn_o]}#{o.ocn}#{Dx[:ocn_c]}" + : '' + else '' + end if o.is ==:heading unless doc_position==:head filename_fictionbook.puts structure_build_tag_close(o.lc,h) -- cgit v1.2.3 From 5b6073188a8859780b69c0300958dc7219dcc340 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 12 May 2014 20:41:02 -0400 Subject: =?UTF-8?q?v5=20v6:=20ao=5Fsyntax,=20address=20possible=20manual?= =?UTF-8?q?=20use=20of=20url=20delimiters=E3=80=8C=E3=80=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/sisu/v5/ao_syntax.rb | 2 +- lib/sisu/v6/ao_syntax.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v5/ao_syntax.rb b/lib/sisu/v5/ao_syntax.rb index cdcb3883..8ff90ae0 100644 --- a/lib/sisu/v5/ao_syntax.rb +++ b/lib/sisu/v5/ao_syntax.rb @@ -333,7 +333,7 @@ module SiSU_AO_Syntax dob end def fontface(dob) - leader=/^|#{Mx[:gl_c]}|\s+|['"]|[#{Mx[:nbsp]}#{Mx[:fa_o_c]}#{Mx[:fa_c]}#{Mx[:lnk_o]}#{Mx[:br_nl]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:tc_c]}#{Mx[:tc_p]}]|[\(\[\{]|[、。]|\>/ + leader=/^|#{Mx[:gl_c]}|\s+|['"]|[#{Mx[:nbsp]}#{Mx[:fa_o_c]}#{Mx[:fa_c]}#{Mx[:lnk_o]}#{Mx[:br_nl]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:tc_c]}#{Mx[:tc_p]}]|[\(\[\{]|[、。「」]|\>/ dob=fontface_lines(dob,leader) dob.obj=dob.obj.gsub(/(#{leader})\*\{(.+?)\}\*/m, "\\1#{@emph[:o]}\\2#{@emph[:c]}"). #emphasis diff --git a/lib/sisu/v6/ao_syntax.rb b/lib/sisu/v6/ao_syntax.rb index e3777f50..8a13e406 100644 --- a/lib/sisu/v6/ao_syntax.rb +++ b/lib/sisu/v6/ao_syntax.rb @@ -333,7 +333,7 @@ module SiSU_AO_Syntax dob end def fontface(dob) - leader=/^|#{Mx[:gl_c]}|\s+|['"]|[#{Mx[:nbsp]}#{Mx[:fa_o_c]}#{Mx[:fa_c]}#{Mx[:lnk_o]}#{Mx[:br_nl]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:tc_c]}#{Mx[:tc_p]}]|[\(\[\{]|[、。]|\>/ + leader=/^|#{Mx[:gl_c]}|\s+|['"]|[#{Mx[:nbsp]}#{Mx[:fa_o_c]}#{Mx[:fa_c]}#{Mx[:lnk_o]}#{Mx[:br_nl]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:tc_c]}#{Mx[:tc_p]}]|[\(\[\{]|[、。「‹«¿¡]|\>/ dob=fontface_lines(dob,leader) dob.obj=dob.obj.gsub(/(#{leader})\*\{(.+?)\}\*/m, "\\1#{@emph[:o]}\\2#{@emph[:c]}"). #emphasis -- cgit v1.2.3 From b28cf1c5cf4be19a5869ddfabf83e0b81f778860 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 12 May 2014 20:54:28 -0400 Subject: v5 v6: composite, fix includes, provide extra newline after inserted comment * (Closes: #744360) [n|u] sisu: includes do not work properly --- lib/sisu/v5/composite.rb | 2 +- lib/sisu/v6/composite.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v5/composite.rb b/lib/sisu/v5/composite.rb index 9e7ccb5c..cd281e26 100644 --- a/lib/sisu/v5/composite.rb +++ b/lib/sisu/v5/composite.rb @@ -132,7 +132,7 @@ module SiSU_Assemble def insertion(fni,insert_array) file={ prepared: [], images: [] } rgx_image=/(?:^|[^_\\])\{\s*(\S+?\.(?:png|jpg|gif))/ - file[:prepared] << "\n% |#{fni}|@|^|>>ok\n" + file[:prepared] << "\n% |#{fni}|@|^|>>ok\n\n" @code_flag=false insert_array.each do |i| @code_flag=if i =~/^code\{/ then true diff --git a/lib/sisu/v6/composite.rb b/lib/sisu/v6/composite.rb index ebbd14f6..02e9543e 100644 --- a/lib/sisu/v6/composite.rb +++ b/lib/sisu/v6/composite.rb @@ -132,7 +132,7 @@ module SiSU_Assemble def insertion(fni,insert_array) file={ prepared: [], images: [] } rgx_image=/(?:^|[^_\\])\{\s*(\S+?\.(?:png|jpg|gif))/ - file[:prepared] << "\n% |#{fni}|@|^|>>ok\n" + file[:prepared] << "\n% |#{fni}|@|^|>>ok\n\n" @code_flag=false insert_array.each do |i| @code_flag=if i =~/^code\{/ then true -- cgit v1.2.3 From 90d3eab4409a446adfc16f23da215855cba7ea6b Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 12 May 2014 21:03:25 -0400 Subject: v5 v6: composite (inserts), missing includes doesn't give an error, fix * (Closes: #744379) see sisu.org for comment --- lib/sisu/v5/composite.rb | 9 +++++---- lib/sisu/v6/composite.rb | 14 ++++++-------- 2 files changed, 11 insertions(+), 12 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v5/composite.rb b/lib/sisu/v5/composite.rb index cd281e26..adc88e52 100644 --- a/lib/sisu/v5/composite.rb +++ b/lib/sisu/v5/composite.rb @@ -141,11 +141,11 @@ module SiSU_Assemble end if not @code_flag \ and i !~/^%+\s/ - i=i.gsub(/^([123]|:?[ABC])~\? /,'% [conditional heading:] \1~ ') #off conditional heading (consider syntax) + i=i.gsub(/^([123]|:?[ABCD])~\? /,'% [conditional heading:] \1~ ') #off conditional heading (consider syntax) if i =~/^@\S+?:/ i=i.gsub(/\n/m,"\n% "). gsub(/\n%\s+$/m,''). - gsub(/^@\S+?:/m,"\n% [imported header:] ") #off imported headers + gsub(/^@\S+?:/m,"\n% [imported header:] ") #off imported headers end end file[:prepared] << i @@ -171,6 +171,7 @@ module SiSU_Assemble or para =~/^(?:<<\s*)\|(\S+?)\|@\|.+?\|(?:req(?:quire)?\b|\s*\})?/ \ or para =~/^r\{(.+?)\}/ #depreciated loadfile=$1.strip + src_ssm=@opt.fns.sub(/\.ssm\.sst/,'.ssm') if (@opt.act[:verbose][:set]==:on \ || @opt.act[:verbose_plus][:set]==:on \ || @opt.act[:maintenance][:set]==:on) @@ -200,7 +201,7 @@ module SiSU_Assemble file[:prepared] else cX=SiSU_Screen::Ansi.new(@opt.act[:color_state][:set]).cX - STDERR.puts "\t #{cX.fuchsia}ERROR#{cX.off} #{cX.brown}#{@opt.fns}#{cX.off} #{cX.fuchsia}requires invalid or non-existent file:#{cX.off} #{cX.brown}#{loadfile}#{cX.off}" + STDERR.puts "\t #{cX.fuchsia}ERROR#{cX.off} #{cX.brown}#{@opt.fns}#{cX.off} #{cX.fuchsia}requires an invalid or non-existent file:#{cX.off} #{cX.brown}#{loadfile}#{cX.off}" para end else tuned_file << para @@ -255,7 +256,7 @@ module SiSU_Assemble @ssm << loadfile else cX=SiSU_Screen::Ansi.new(@opt.act[:color_state][:set]).cX - STDERR.puts "\t #{cX.fuchsia}ERROR#{cX.off} #{cX.brown}#{@opt.fns}#{cX.off} #{cX.fuchsia}requires invalid or non-existent file:#{cX.off} #{cX.brown}#{loadfile}#{cX.off}" + STDERR.puts "\t #{cX.fuchsia}ERROR#{cX.off} #{cX.brown}#{@opt.fns}#{cX.off} #{cX.fuchsia}requires an invalid or non-existent file:#{cX.off} #{cX.brown}#{loadfile}#{cX.off}" para end end diff --git a/lib/sisu/v6/composite.rb b/lib/sisu/v6/composite.rb index 02e9543e..79603e26 100644 --- a/lib/sisu/v6/composite.rb +++ b/lib/sisu/v6/composite.rb @@ -141,11 +141,11 @@ module SiSU_Assemble end if not @code_flag \ and i !~/^%+\s/ - i=i.gsub(/^([123]|:?[ABC])~\? /,'% [conditional heading:] \1~ ') #off conditional heading (consider syntax) + i=i.gsub(/^([123]|:?[ABCD])~\? /,'% [conditional heading:] \1~ ') #off conditional heading (consider syntax) if i =~/^@\S+?:/ i=i.gsub(/\n/m,"\n% "). gsub(/\n%\s+$/m,''). - gsub(/^@\S+?:/m,"\n% [imported header:] ") #off imported headers + gsub(/^@\S+?:/m,"\n% [imported header:] ") #off imported headers end end file[:prepared] << i @@ -166,11 +166,9 @@ module SiSU_Assemble tuned_file,imagedir=[],[] SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Composite Document',"[#{@opt.f_pth[:lng_is]}] #{@opt.fno}").grey_title_hi unless @opt.act[:quiet][:set]==:on data.each do |para| - if para =~/^<<\s+(\S+?\.ss[it])$/ \ - or para =~/^<<\{(\S+?\.ss[it])\}$/ \ - or para =~/^(?:<<\s*)\|(\S+?)\|@\|.+?\|(?:req(?:quire)?\b|\s*\})?/ \ - or para =~/^r\{(.+?)\}/ #depreciated + if para =~/^<<\s+(\S+?\.ss[it])$/ loadfile=$1.strip + src_ssm=@opt.fns.sub(/\.ssm\.sst/,'.ssm') if (@opt.act[:verbose][:set]==:on \ || @opt.act[:verbose_plus][:set]==:on \ || @opt.act[:maintenance][:set]==:on) @@ -200,7 +198,7 @@ module SiSU_Assemble file[:prepared] else cX=SiSU_Screen::Ansi.new(@opt.act[:color_state][:set]).cX - STDERR.puts "\t #{cX.fuchsia}ERROR#{cX.off} #{cX.brown}#{@opt.fns}#{cX.off} #{cX.fuchsia}requires invalid or non-existent file:#{cX.off} #{cX.brown}#{loadfile}#{cX.off}" + STDERR.puts "\t #{cX.fuchsia}ERROR#{cX.off} #{cX.brown}#{@opt.fns}#{cX.off} #{cX.fuchsia}requires an invalid or non-existent file:#{cX.off} #{cX.brown}#{loadfile}#{cX.off}" para end else tuned_file << para @@ -255,7 +253,7 @@ module SiSU_Assemble @ssm << loadfile else cX=SiSU_Screen::Ansi.new(@opt.act[:color_state][:set]).cX - STDERR.puts "\t #{cX.fuchsia}ERROR#{cX.off} #{cX.brown}#{@opt.fns}#{cX.off} #{cX.fuchsia}requires invalid or non-existent file:#{cX.off} #{cX.brown}#{loadfile}#{cX.off}" + STDERR.puts "\t #{cX.fuchsia}ERROR#{cX.off} #{cX.brown}#{@opt.fns}#{cX.off} #{cX.fuchsia}requires an invalid or non-existent file:#{cX.off} #{cX.brown}#{loadfile}#{cX.off}" para end end -- cgit v1.2.3 From d5b2fa8c360d4f790f72dbcf3058e7eaa06c60fd Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 12 May 2014 21:07:03 -0400 Subject: v5 v6: metadata, pdf, remove link to manifest page where --no-manifest is used * (Closes: #744378) --- lib/sisu/v5/shared_metadata.rb | 11 ++++++++--- lib/sisu/v6/shared_metadata.rb | 11 ++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v5/shared_metadata.rb b/lib/sisu/v5/shared_metadata.rb index b7ba2f1f..da396040 100644 --- a/lib/sisu/v5/shared_metadata.rb +++ b/lib/sisu/v5/shared_metadata.rb @@ -886,6 +886,8 @@ WOK def initialize(md) @md=md @br="\\\\\n" + @make=SiSU_Env::ProcessingSettings.new(md) + @o_str ||=SiSU_Env::ProcessingSettings.new(md).output_dir_structure end def meta_para(tag,inf,sc=true) inf=((inf.is_a?(String) && sc) ? spec_char(inf) : inf) @@ -906,9 +908,12 @@ WOK l=SiSU_Env::StandardiseLanguage.new(@md.opt.lng).language language=l[:n] tr=SiSU_Translate::Source.new(@md,language) - tag="Document Manifest @" - inf="#{@br}#{@md.file.output_path.manifest.url}/#{@md.file.base_filename.manifest}" - meta << meta_para(tag,inf) + if @make.build.links_to_manifest? \ + and not @o_str.dump_or_redirect? + tag="Document Manifest @" + inf="#{@br}#{@md.file.output_path.manifest.url}/#{@md.file.base_filename.manifest}" + meta << meta_para(tag,inf) + end if defined? @md.title.full \ and @md.title.full=~/\S+/ tag,inf=tr.full_title,@md.title.full diff --git a/lib/sisu/v6/shared_metadata.rb b/lib/sisu/v6/shared_metadata.rb index 546eb788..c2fe06b9 100644 --- a/lib/sisu/v6/shared_metadata.rb +++ b/lib/sisu/v6/shared_metadata.rb @@ -886,6 +886,8 @@ WOK def initialize(md) @md=md @br="\\\\\n" + @make=SiSU_Env::ProcessingSettings.new(md) + @o_str ||=SiSU_Env::ProcessingSettings.new(md).output_dir_structure end def meta_para(tag,inf,sc=true) inf=((inf.is_a?(String) && sc) ? spec_char(inf) : inf) @@ -906,9 +908,12 @@ WOK l=SiSU_Env::StandardiseLanguage.new(@md.opt.lng).language language=l[:n] tr=SiSU_Translate::Source.new(@md,language) - tag="Document Manifest @" - inf="#{@br}#{@md.file.output_path.manifest.url}/#{@md.file.base_filename.manifest}" - meta << meta_para(tag,inf) + if @make.build.links_to_manifest? \ + and not @o_str.dump_or_redirect? + tag="Document Manifest @" + inf="#{@br}#{@md.file.output_path.manifest.url}/#{@md.file.base_filename.manifest}" + meta << meta_para(tag,inf) + end if defined? @md.title.full \ and @md.title.full=~/\S+/ tag,inf=tr.full_title,@md.title.full -- cgit v1.2.3 From 58020c13d503a6c8724ac4a2f26b8d33f0a0c6f5 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 12 May 2014 21:10:22 -0400 Subject: v5: digests cleaning --- lib/sisu/v5/digests.rb | 158 +++++-------------------------------------------- 1 file changed, 16 insertions(+), 142 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v5/digests.rb b/lib/sisu/v5/digests.rb index 3acd51eb..b3dd40bd 100644 --- a/lib/sisu/v5/digests.rb +++ b/lib/sisu/v5/digests.rb @@ -71,7 +71,7 @@ module SiSU_DigestView @fnb=@opt.fnb @@endnotes_para=[] @@dg=nil - @dg=@@dg ||=SiSU_Env::InfoEnv.new.digest.type + @dg=@@dg ||=SiSU_Env::InfoEnv.new.digest(opt).type @particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt) end def read @@ -114,8 +114,8 @@ module SiSU_DigestView @particulars=particulars @data,@env,@md=@particulars.ao_array,@particulars.env,@particulars.md SiSU_Env::FileOp.new(@md).mkdir - @@dg ||=@env.digest.type - @@dl ||=@env.digest.length + @@dg ||=@env.digest(@md.opt).type + @@dl ||=@env.digest(@md.opt).length @dg,@dl=@@dg,@@dl l=SiSU_Env::StandardiseLanguage.new(@md.opt.lng).language @language=l[:n] @@ -158,135 +158,6 @@ module SiSU_DigestView txt=txt.gsub(/([()])/,"\\\\\\1") end def message_digest - data=@data - sys=SiSU_Env::SystemCall.new - @p=[] - @g,@v,@r='','','' - data.each do |para| - x=nil - y,para_endnotes=[],[] - if para =~/#{Mx[:id_o]}~(\d+);(?:(?:\w|[0-6]:)\d+);(?:\w\d+)#{Mx[:id_c]}#{Mx[:id_o]}([0-9a-f]{#{@dl}}):([0-9a-f]{#{@dl}})#{Mx[:id_c]}/ - ocn,d_clean,d_all=$1,$2,$3 - @ocn=ocn unless ocn.to_i==0 - para=para.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') - if para=~/#{Mx[:en_a_o]}[\d*+]+.+?#{Mx[:id_o]}[0-9a-f]{#{@dl}}#{Mx[:id_c]}#{Mx[:en_a_c]}/ - para_endnotes << para.scan(/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]})([\d*+]+).+?#{Mx[:id_o]}([0-9a-f]{#{@dl}})#{Mx[:id_c]}(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/) - end - images=[] - if para !~/^%+\s/ \ - and para =~/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+\.(png|jpg|gif))\s.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/ - images=para.scan(/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+\.(?:png|jpg|gif))\s.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/).flatten - else nil - end - x=case para - when /^#{Mx[:meta_o]}title#{Mx[:meta_c]}/ - "\n" << ' '*0 << '@' << ' '*9 - when /^#{Mx[:meta_o]}subtitle#{Mx[:meta_c]}/ - "\n" << ' '*1 << '@' << ' '*8 - when /^#{Mx[:lv_o]}1:/ #fix Mx[:lv_o] - "\n" << ' '*2 << ':A ' << ' '*6 << '- ' << ocn << ' '*(10-ocn.length) << d_clean << ' ' << d_all - when /^#{Mx[:lv_o]}2:/ #fix Mx[:lv_o] - "\n" << ' '*3 << ':B ' << ' '*5 << '- ' << ocn << ' '*(10-ocn.length) << d_clean << ' ' << d_all - when /^#{Mx[:lv_o]}3:/ #fix Mx[:lv_o] - "\n" << ' '*4 << ':C ' << ' '*4 << '- ' << ocn << ' '*(10-ocn.length) << d_clean << ' ' << d_all - when /^#{Mx[:lv_o]}4:/ #fix Mx[:lv_o] - "\n" << ' '*5 << '1' << ' '*4 << '- ' << ocn << ' '*(10-ocn.length) << d_clean << ' ' << d_all - when /^#{Mx[:lv_o]}5:/ #fix Mx[:lv_o] - "\n" << ' '*6 << '2' << ' '*3 << '- ' << ocn << ' '*(10-ocn.length) << d_clean << ' ' << d_all - when /^#{Mx[:lv_o]}6:/ #fix Mx[:lv_o] - "\n" << ' '*7 << '3' << ' '*2 << '- ' << ocn << ' '*(10-ocn.length) << d_clean << ' ' << d_all - else - if para =~/MD5\(\S+?\.sst\)=\s*([0-9a-f]{#{@dl}})<\/u>/ #watch - @n,@s=/MD5\((\S+?\.sst)\)=\s*([0-9a-f]{#{@dl}})<\/u>/.match(para)[1,2] - end - x=unless ocn =~ /^0$/ - if images \ - and images.length > 0 # then get path of image & produce digest - @image_name,@image_dgst,@img=[],[],[] - images.each do |i| - image_source=if FileTest.file?("#{@env.path.image_source_include_local}/#{i}") - @env.path.image_source_include_local - elsif FileTest.file?("#{@env.path.image_source_include_remote}/#{i}") - @env.path.image_source_include_remote - elsif FileTest.file?("#{@env.path.image_source_include}/#{i}") - @env.path.image_source_include - else - SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],"ERROR - image:", %{"#{i}" missing}, "search locations: #{@env.path.image_source_include_local}, #{@env.path.image_source_include_remote} and #{@env.path.image_source_include}").error2 unless @md.opt.act[:quiet][:set]==:on - nil - end - @img << /\S+\.(png|jpg|gif)/.match(i)[1] - not_found_msg='image not found' - if image_source - para_image = image_source + '/' + i - @image_name << i - @image_dgst << (@dg =~/^sha(?:2|256)$/) \ - ? sys.sha256(para_image) - : sys.md5(para_image) - else - @image_name << ' '*16 + i + ' [image missing]' - @image_dgst << '' - @image_dgst[1]=not_found_msg + ' '*(32-not_found_msg.length) - end - end - line= "\n" + ' '*9 + ' - ' + ocn + ' '*(10-ocn.length) + d_clean + ' ' + d_all + "\n" - line_image=[] - c=0 - @image_name.each do |ok| - line_image << %{ #{@img[c]} #{@image_dgst[c][1]} #{@image_name[c]}} - c +=1 - end - line=line + line_image.join("\n") - else "\n" + ' '*9 + ' - ' + ocn + ' '*(10-ocn.length) + d_clean + ' ' + d_all - end - else - prefix='' - metad=[@tr.full_title,@tr.author,@tr.translator,@tr.illustrator,@tr.prepared_by,@tr.digitized_by,@tr.description,@tr.subject,@tr.abstract,@tr.publisher,@tr.contributor,@tr.date_created,@tr.date_issued,@tr.date_available,@tr.date_modified,@tr.date_valid,@tr.date,@tr.type,@tr.format,@tr.rights,@tr.identifier,@tr.source,@tr.language,@tr.language_original,@tr.relation,@tr.coverage,@tr.keywords,@tr.comments,@tr.cls_loc,@tr.cls_dewey,@tr.cls_gutenberg,@tr.cls_isbn,@tr.prefix_a,@tr.prefix_b,@tr.sourcefile,@tr.sourcefile_digest,@tr.last_generated,@tr.sisu_version,@tr.ruby_version,@tr.sc_number,@tr.sc_date,'Generated by: ','Ruby version: '] - metad.each do |n| - m=rgx_txt(n) - if m=~/\S+/ \ - and para=~/^#{m}:/ - x,o=0,18 - while x < 2; o = o + 2 - x=o - n.length - end - space=' '*x - prefix="#{n.downcase}#{space}" - break - else prefix=' '*9 - end - end - m_title=rgx_txt(@tr.full_title) - m_author=rgx_txt(@tr.author) - m_sourcefile_digest=rgx_txt(@tr.sourcefile_digest) - m_sisu_version=rgx_txt(@tr.sisu_version) - m_last_generated=rgx_txt(@tr.last_generated) - m_ruby_version=rgx_txt(@tr.ruby_version) - case para - when /#{m_title}: / - @t=/#{m_title}: (.+?)#{Mx[:id_o]}~\d;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}[0-9a-f]{#{@dl}}:[0-9a-f]{#{@dl}}#{Mx[:id_c]}/.match(para)[1].gsub(/<\/?u>/,'').strip - when /#{m_author}: / - @c=/#{m_author}: (.+?)#{Mx[:id_o]}~\d;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}[0-9a-f]{#{@dl}}:[0-9a-f]{#{@dl}}#{Mx[:id_c]}/.match(para)[1].gsub(/<\/?u>/,'').strip - when /#{m_sourcefile_digest}.+?/ #watch - dgst_extra="\n" << ' '*21 << 'source' << ' '*4 << @md.dgst[1] << ' '*34 << @md.fns - when /#{m_sisu_version}: / - @v=/#{m_sisu_version}: (.+?)#{Mx[:id_o]}~\d;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}[0-9a-f]{#{@dl}}:[0-9a-f]{#{@dl}}#{Mx[:id_c]}/.match(para)[1].gsub(/<\/?u>/,'').strip - when /#{m_last_generated}: / - @g=/#{m_last_generated}: (.+?)#{Mx[:id_o]}~\d;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}[0-9a-f]{#{@dl}}:[0-9a-f]{#{@dl}}#{Mx[:id_c]}/.match(para)[1].gsub(/<\/?u>/,'').strip - when /#{m_ruby_version}: / - @r=/#{m_ruby_version}: (.+?)#{Mx[:id_o]}~\d;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}[0-9a-f]{#{@dl}}:[0-9a-f]{#{@dl}}#{Mx[:id_c]}/.match(para)[1].gsub(/<\/?u>/,'').strip - end - dgst_extra ||='' - "\n" << prefix << ' - ' << ocn << ' '*(10-ocn.length) << d_clean << ' ' << d_all << dgst_extra << "\n" - end - end - para_endnotes[0].each { |e| y << "\n" + ' '*(28-e[0].length) + "[#{e[0].to_s}] #{e[1].to_s}" } if para_endnotes[0] - if y; digests(x,y) - else digests(x) - end - end - end manifest="#{@env.url.root}/#{@md.fnb}/sisu_manifest.html" a=%{ocn digest clean (no markup/notes),#{@sp*33}digest all (includes markup & endnotes)\n} description("#{@md.title.full}\n") @@ -340,18 +211,20 @@ module SiSU_DigestView data.each do |t_o| if t_o.is==:heading x=case t_o.ln - when 1 then l[1] +=1 #fix Mx[:lv_o] + when 1 then l[0] +=1 #fix Mx[:lv_o] ' '*0 << ':A' - when 2 then l[2] +=1 #fix Mx[:lv_o] + when 1 then l[1] +=1 #fix Mx[:lv_o] ' '*1 << ':B' - when 3 then l[3] +=1 #fix Mx[:lv_o] + when 2 then l[2] +=1 #fix Mx[:lv_o] ' '*2 << ':C' + when 3 then l[3] +=1 #fix Mx[:lv_o] + ' '*3 << ':D' when 4 then l[4] +=1 #fix Mx[:lv_o] - ' '*3 << '1' + ' '*4 << '1' when 5 then l[5] +=1 #fix Mx[:lv_o] - ' '*4 << '2' + ' '*5 << '2' when 6 then l[6] +=1 #fix Mx[:lv_o] - ' '*5 << '3' + ' '*6 << '3' else nil end end @@ -363,9 +236,10 @@ module SiSU_DigestView ao_structure_summary("document structure[*]\n") [0,1,2,3,4,5,6].each do |y| v=case y - when 1 then ':A' - when 2 then ':B' - when 3 then ':C' + when 0 then ':A' + when 1 then ':B' + when 2 then ':C' + when 3 then ':D' when 4 then '1 ' when 5 then '2 ' when 6 then '3 ' @@ -374,7 +248,7 @@ module SiSU_DigestView end ao_structure_summary("objects (ocn) = #{ocn}\n") ao_structure_summary("endnotes = #{endnotes}\n") - ao_structure_summary(" [*] number of headers (@) and of each heading level (:A to :C and 1 to 3)\n") + ao_structure_summary(" [*] number of headers (@) and of each heading level (:A to :D and 1 to 3)\n") end def supplementary if defined? @md.sc_number \ -- cgit v1.2.3 From 3ea16523f1a3cbbdcd451a3845725417ee2141d8 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 12 May 2014 21:22:19 -0400 Subject: v6: digests sha512 option implemented * options sha512 sha256 md5 * command line --sha512 * rcconf.yml ['defsault']['digest'] = sha512 * (Closes: #744402) --- lib/sisu/v5/constants.rb | 6 +- lib/sisu/v6/ao_doc_objects.rb | 22 ++-- lib/sisu/v6/ao_hash_digest.rb | 24 +++-- lib/sisu/v6/constants.rb | 6 +- lib/sisu/v6/db_columns.rb | 4 +- lib/sisu/v6/digests.rb | 216 ++++++++++----------------------------- lib/sisu/v6/manifest.rb | 14 ++- lib/sisu/v6/options.rb | 8 ++ lib/sisu/v6/param.rb | 13 ++- lib/sisu/v6/qrcode.rb | 17 +-- lib/sisu/v6/shared_markup_alt.rb | 20 +++- lib/sisu/v6/sysenv.rb | 53 +++++++--- lib/sisu/v6/urls.rb | 2 +- 13 files changed, 189 insertions(+), 216 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v5/constants.rb b/lib/sisu/v5/constants.rb index d47d9a7e..748051b6 100644 --- a/lib/sisu/v5/constants.rb +++ b/lib/sisu/v5/constants.rb @@ -260,8 +260,8 @@ else } end Db={ - name_prefix: "SiSU#{SiSU_is[:version_dir]}a_", - name_prefix_db: "sisu_#{SiSU_is[:version_dir]}a_", + name_prefix: "SiSU#{SiSU_is[:version_dir]}b_", + name_prefix_db: "sisu_#{SiSU_is[:version_dir]}b_", col_title: 800, col_title_part: 400, col_title_edition: 10, @@ -276,7 +276,7 @@ Db={ col_library: 30, col_small: 16, col_filename: 256, - col_digest: 64, + col_digest: 128, col_filesize: 10, col_info_note: 2500, } diff --git a/lib/sisu/v6/ao_doc_objects.rb b/lib/sisu/v6/ao_doc_objects.rb index 15e949c4..8dbdedc3 100644 --- a/lib/sisu/v6/ao_doc_objects.rb +++ b/lib/sisu/v6/ao_doc_objects.rb @@ -94,7 +94,7 @@ module SiSU_AO_DocumentStructure tag= h[:tag] || ((defined? o.tag) ? o.tag : nil) #String, metadata type/tag obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use - digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, either sha256 or md5 + digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, sha512, sha256 or md5 @of,@is,@tag,@obj,@digest,@tmp=of,is,tag,obj,digest,tmp self end @@ -164,7 +164,7 @@ module SiSU_AO_DocumentStructure else h[:autonum_] end note_= h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) - digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, either sha256 or md5 + digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, sha512, sha256 or md5 tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use @of,@is,@lv,@ln,@lc,@name,@tags,@obj,@idx,@ocn,@odv,@osp,@node,@parent,@toc_,@ocn_,@note_,@autonum_,@digest,@tmp=of,is,lv,ln,lc,name,tags,obj,idx,ocn,odv,osp,node,parent,toc_,ocn_,note_,autonum_,digest,tmp self @@ -201,7 +201,7 @@ 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 - digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, either sha256 or md5 + digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, sha512, sha256 or md5 tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use @of,@is,@name,@tags,@obj,@indent,@hang,@bullet_,@idx,@ocn,@odv,@osp,@parent,@image_,@note_,@ocn_,@digest,@tmp=of,is,name,tags,obj,indent,hang,bullet_,idx,ocn,odv,osp,parent,image_,note_,ocn_,digest,tmp self @@ -225,7 +225,7 @@ 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 - digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, either sha256 or md5 + digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, sha512, sha256 or md5 tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use @of,@is,@name,@tags,@obj,@indent,@hang,@bullet_,@idx,@ocn,@odv,@osp,@parent,@image_,@note_,@ocn_,@digest,@tmp=of,is,name,tags,obj,indent,hang,bullet_,idx,ocn,odv,osp,parent,image_,note_,ocn_,digest,tmp self @@ -254,7 +254,7 @@ module SiSU_AO_DocumentStructure 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 + digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, sha512, 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_,@num,@digest,@tmp=of,is,tags,obj,idx,ocn,odv,osp,parent,number_,note_,ocn_,num,digest,tmp self @@ -274,7 +274,7 @@ module SiSU_AO_DocumentStructure 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 + digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, sha512, 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_,@num,@digest,@tmp=of,is,tags,obj,idx,ocn,odv,osp,parent,note_,ocn_,num,digest,tmp self @@ -294,7 +294,7 @@ module SiSU_AO_DocumentStructure 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 + digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, sha512, 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_,@num,@digest,@tmp=of,is,tags,obj,idx,ocn,odv,osp,parent,note_,ocn_,num,digest,tmp self @@ -314,7 +314,7 @@ module SiSU_AO_DocumentStructure 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 + digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, sha512, 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_,@num,@digest,@tmp=of,is,tags,obj,idx,ocn,odv,osp,parent,note_,ocn_,num,digest,tmp self @@ -333,7 +333,7 @@ module SiSU_AO_DocumentStructure 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 + digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, sha512, 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_,@num,@digest,@tmp=of,is,tags,obj,idx,ocn,odv,osp,parent,note_,ocn_,num,digest,tmp @h=nil @@ -365,7 +365,7 @@ module SiSU_AO_DocumentStructure 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 + digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, sha512, 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_,@num,@digest,@tmp=of,is,tags,cols,widths,obj,idx,ocn,odv,osp,parent,head_,note_,ocn_,num,digest,tmp self @@ -393,7 +393,7 @@ 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 - digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, either sha256 or md5 + digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, sha512, sha256 or md5 tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use @of,@is,@tags,@obj,@size,@idx,@ocn,@odv,@osp,@parent,@note_,@ocn_,@digest,@tmp=of,is,tags,obj,size,idx,ocn,odv,osp,parent,note_,ocn_,digest,tmp self diff --git a/lib/sisu/v6/ao_hash_digest.rb b/lib/sisu/v6/ao_hash_digest.rb index ce45b9e4..257902f4 100644 --- a/lib/sisu/v6/ao_hash_digest.rb +++ b/lib/sisu/v6/ao_hash_digest.rb @@ -65,7 +65,7 @@ module SiSU_AO_Hash class ObjectDigest def initialize(md,data,env=nil) @md,@data,@env=md,data,env - @env ||=SiSU_Env::InfoEnv.new(@md.fns) + @env ||=SiSU_Env::InfoEnv.new(@md.fns,@md) end def object_digest # 1. clean/stripped text without any markup, paragraph, headings etc. without endnotes @@ -74,11 +74,11 @@ module SiSU_AO_Hash # [digests should not include other digests] data=@data.compact @tuned_file=[] - sha_ =(@env.digest.type=='sha256' ? true : false) + sha_ =@env.digest(@md.opt).type begin sha_ ? (require 'digest/sha2') : (require 'digest/md5') rescue LoadError - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error((sha_ ? 'digest/sha2' : 'digest/md5') + ' NOT FOUND') + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error(sha_ + ' NOT FOUND') end data.each do |t_o| unless t_o.obj.is_a?(Array) @@ -88,11 +88,16 @@ module SiSU_AO_Hash && t_o.of !=:comment \ && t_o.of !=:layout) \ && t_o.ocn.is_a?(Fixnum) - if sha_ + case sha_ + when :sha512 + for hash_class in [ Digest::SHA512 ] + @tuned_file << stamped(t_o,hash_class) + end + when :sha256 for hash_class in [ Digest::SHA256 ] @tuned_file << stamped(t_o,hash_class) end - else + when :md5 for hash_class in [ Digest::MD5 ] @tuned_file << stamped(t_o,hash_class) end @@ -111,10 +116,15 @@ module SiSU_AO_Hash if en_plus =~/#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]}/ t_o_txt,en_open,en_txt,en_close=/(.*?)(#{Mx[:en_a_o]}|#{Mx[:en_b_o]})(.+?)(#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/m.match(en_plus)[1..4] stripped_en=SiSU_TextRepresentation::Alter.new(en_txt).strip_clean_of_markup - digest_en_strip=if @env.digest.type =~/sha256/ + digest_en_strip=case @env.digest(@md.opt).type + when :sha512 + Digest::SHA512.hexdigest(stripped_en) + when :sha256 Digest::SHA256.hexdigest(stripped_en) - else + when :md5 Digest::MD5.hexdigest(stripped_en) + else + Digest::SHA256.hexdigest(stripped_en) end t_o_txt + en_open + en_txt + Mx[:id_o] + digest_en_strip + Mx[:id_c] + en_close else STDERR.puts "Error Exception - problem encountered with:\n#{en_plus}" #arbitrary exception, tidy up diff --git a/lib/sisu/v6/constants.rb b/lib/sisu/v6/constants.rb index 0f76ed59..be60431e 100644 --- a/lib/sisu/v6/constants.rb +++ b/lib/sisu/v6/constants.rb @@ -260,8 +260,8 @@ else } end Db={ - name_prefix: "SiSU#{SiSU_is[:version_dir]}a_", - name_prefix_db: "sisu_#{SiSU_is[:version_dir]}a_", + name_prefix: "SiSU#{SiSU_is[:version_dir]}b_", + name_prefix_db: "sisu_#{SiSU_is[:version_dir]}b_", col_title: 800, col_title_part: 400, col_title_edition: 10, @@ -276,7 +276,7 @@ Db={ col_library: 30, col_small: 16, col_filename: 256, - col_digest: 64, + col_digest: 128, col_filesize: 10, col_info_note: 2500, } diff --git a/lib/sisu/v6/db_columns.rb b/lib/sisu/v6/db_columns.rb index 1b21cf96..8dd14ddb 100644 --- a/lib/sisu/v6/db_columns.rb +++ b/lib/sisu/v6/db_columns.rb @@ -1843,7 +1843,7 @@ module SiSU_DbColumns end def src_fingerprint def name - 'src_fingerprint' #hash/digest, sha256 or md5 + 'src_fingerprint' #hash/digest, sha512, sha256 or md5 end def create_column "#{name} VARCHAR(#{Db[:col_digest]}) NULL," @@ -1851,7 +1851,7 @@ module SiSU_DbColumns end def column_comment %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'sisu markup source text fingerprint, hash digest sha256 (or md5)';} + IS 'sisu markup source text fingerprint, hash digest sha512, sha256 or md5';} end def tuple if defined? @md.dgst \ diff --git a/lib/sisu/v6/digests.rb b/lib/sisu/v6/digests.rb index 1fa2c80f..24ddc32e 100644 --- a/lib/sisu/v6/digests.rb +++ b/lib/sisu/v6/digests.rb @@ -71,7 +71,7 @@ module SiSU_DigestView @fnb=@opt.fnb @@endnotes_para=[] @@dg=nil - @dg=@@dg ||=SiSU_Env::InfoEnv.new.digest.type + @dg=@@dg ||=SiSU_Env::InfoEnv.new.digest(opt).type @particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt) end def read @@ -108,14 +108,19 @@ module SiSU_DigestView private class Scroll \1'). - gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'\1'). - gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'\1') - if para=~/#{Mx[:en_a_o]}[\d*+]+.+?#{Mx[:id_o]}[0-9a-f]{#{@dl}}#{Mx[:id_c]}#{Mx[:en_a_c]}/ - para_endnotes << para.scan(/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]})([\d*+]+).+?#{Mx[:id_o]}([0-9a-f]{#{@dl}})#{Mx[:id_c]}(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/) - end - images=[] - if para !~/^%+\s/ \ - and para =~/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+\.(png|jpg|gif))\s.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/ - images=para.scan(/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+\.(?:png|jpg|gif))\s.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/).flatten - else nil - end - x=case para - when /^#{Mx[:meta_o]}title#{Mx[:meta_c]}/ - "\n" << ' '*0 << '@' << ' '*9 - when /^#{Mx[:meta_o]}subtitle#{Mx[:meta_c]}/ - "\n" << ' '*1 << '@' << ' '*8 - when /^#{Mx[:lv_o]}1:/ #fix Mx[:lv_o] - "\n" << ' '*2 << ':A ' << ' '*6 << '- ' << ocn << ' '*(10-ocn.length) << d_clean << ' ' << d_all - when /^#{Mx[:lv_o]}2:/ #fix Mx[:lv_o] - "\n" << ' '*3 << ':B ' << ' '*5 << '- ' << ocn << ' '*(10-ocn.length) << d_clean << ' ' << d_all - when /^#{Mx[:lv_o]}3:/ #fix Mx[:lv_o] - "\n" << ' '*4 << ':C ' << ' '*4 << '- ' << ocn << ' '*(10-ocn.length) << d_clean << ' ' << d_all - when /^#{Mx[:lv_o]}4:/ #fix Mx[:lv_o] - "\n" << ' '*5 << '1' << ' '*4 << '- ' << ocn << ' '*(10-ocn.length) << d_clean << ' ' << d_all - when /^#{Mx[:lv_o]}5:/ #fix Mx[:lv_o] - "\n" << ' '*6 << '2' << ' '*3 << '- ' << ocn << ' '*(10-ocn.length) << d_clean << ' ' << d_all - when /^#{Mx[:lv_o]}6:/ #fix Mx[:lv_o] - "\n" << ' '*7 << '3' << ' '*2 << '- ' << ocn << ' '*(10-ocn.length) << d_clean << ' ' << d_all - else - if para =~/MD5\(\S+?\.sst\)=\s*([0-9a-f]{#{@dl}})<\/u>/ #watch - @n,@s=/MD5\((\S+?\.sst)\)=\s*([0-9a-f]{#{@dl}})<\/u>/.match(para)[1,2] - end - x=unless ocn =~ /^0$/ - if images \ - and images.length > 0 # then get path of image & produce digest - @image_name,@image_dgst,@img=[],[],[] - images.each do |i| - image_source=if FileTest.file?("#{@env.path.image_source_include_local}/#{i}") - @env.path.image_source_include_local - elsif FileTest.file?("#{@env.path.image_source_include_remote}/#{i}") - @env.path.image_source_include_remote - elsif FileTest.file?("#{@env.path.image_source_include}/#{i}") - @env.path.image_source_include - else - SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],"ERROR - image:", %{"#{i}" missing}, "search locations: #{@env.path.image_source_include_local}, #{@env.path.image_source_include_remote} and #{@env.path.image_source_include}").error2 unless @md.opt.act[:quiet][:set]==:on - nil - end - @img << /\S+\.(png|jpg|gif)/.match(i)[1] - not_found_msg='image not found' - if image_source - para_image = image_source + '/' + i - @image_name << i - @image_dgst << (@dg =~/^sha(?:2|256)$/) \ - ? sys.sha256(para_image) - : sys.md5(para_image) - else - @image_name << ' '*16 + i + ' [image missing]' - @image_dgst << '' - @image_dgst[1]=not_found_msg + ' '*(32-not_found_msg.length) - end - end - line= "\n" + ' '*9 + ' - ' + ocn + ' '*(10-ocn.length) + d_clean + ' ' + d_all + "\n" - line_image=[] - c=0 - @image_name.each do |ok| - line_image << %{ #{@img[c]} #{@image_dgst[c][1]} #{@image_name[c]}} - c +=1 - end - line=line + line_image.join("\n") - else "\n" + ' '*9 + ' - ' + ocn + ' '*(10-ocn.length) + d_clean + ' ' + d_all - end - else - prefix='' - metad=[@tr.full_title,@tr.author,@tr.translator,@tr.illustrator,@tr.prepared_by,@tr.digitized_by,@tr.description,@tr.subject,@tr.abstract,@tr.publisher,@tr.contributor,@tr.date_created,@tr.date_issued,@tr.date_available,@tr.date_modified,@tr.date_valid,@tr.date,@tr.type,@tr.format,@tr.rights,@tr.identifier,@tr.source,@tr.language,@tr.language_original,@tr.relation,@tr.coverage,@tr.keywords,@tr.comments,@tr.cls_loc,@tr.cls_dewey,@tr.cls_gutenberg,@tr.cls_isbn,@tr.prefix_a,@tr.prefix_b,@tr.sourcefile,@tr.sourcefile_digest,@tr.last_generated,@tr.sisu_version,@tr.ruby_version,@tr.sc_number,@tr.sc_date,'Generated by: ','Ruby version: '] - metad.each do |n| - m=rgx_txt(n) - if m=~/\S+/ \ - and para=~/^#{m}:/ - x,o=0,18 - while x < 2; o = o + 2 - x=o - n.length - end - space=' '*x - prefix="#{n.downcase}#{space}" - break - else prefix=' '*9 - end - end - m_title=rgx_txt(@tr.full_title) - m_author=rgx_txt(@tr.author) - m_sourcefile_digest=rgx_txt(@tr.sourcefile_digest) - m_sisu_version=rgx_txt(@tr.sisu_version) - m_last_generated=rgx_txt(@tr.last_generated) - m_ruby_version=rgx_txt(@tr.ruby_version) - case para - when /#{m_title}: / - @t=/#{m_title}: (.+?)#{Mx[:id_o]}~\d;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}[0-9a-f]{#{@dl}}:[0-9a-f]{#{@dl}}#{Mx[:id_c]}/.match(para)[1].gsub(/<\/?u>/,'').strip - when /#{m_author}: / - @c=/#{m_author}: (.+?)#{Mx[:id_o]}~\d;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}[0-9a-f]{#{@dl}}:[0-9a-f]{#{@dl}}#{Mx[:id_c]}/.match(para)[1].gsub(/<\/?u>/,'').strip - when /#{m_sourcefile_digest}.+?/ #watch - dgst_extra="\n" << ' '*21 << 'source' << ' '*4 << @md.dgst[1] << ' '*34 << @md.fns - when /#{m_sisu_version}: / - @v=/#{m_sisu_version}: (.+?)#{Mx[:id_o]}~\d;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}[0-9a-f]{#{@dl}}:[0-9a-f]{#{@dl}}#{Mx[:id_c]}/.match(para)[1].gsub(/<\/?u>/,'').strip - when /#{m_last_generated}: / - @g=/#{m_last_generated}: (.+?)#{Mx[:id_o]}~\d;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}[0-9a-f]{#{@dl}}:[0-9a-f]{#{@dl}}#{Mx[:id_c]}/.match(para)[1].gsub(/<\/?u>/,'').strip - when /#{m_ruby_version}: / - @r=/#{m_ruby_version}: (.+?)#{Mx[:id_o]}~\d;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}[0-9a-f]{#{@dl}}:[0-9a-f]{#{@dl}}#{Mx[:id_c]}/.match(para)[1].gsub(/<\/?u>/,'').strip - end - dgst_extra ||='' - "\n" << prefix << ' - ' << ocn << ' '*(10-ocn.length) << d_clean << ' ' << d_all << dgst_extra << "\n" - end - end - para_endnotes[0].each { |e| y << "\n" + ' '*(28-e[0].length) + "[#{e[0].to_s}] #{e[1].to_s}" } if para_endnotes[0] - if y; digests(x,y) - else digests(x) - end - end - end manifest="#{@env.url.root}/#{@md.fnb}/sisu_manifest.html" - a=%{ocn digest clean (no markup/notes),#{@sp*33}digest all (includes markup & endnotes)\n} description("#{@md.title.full}\n") description("#{@md.author}\n") description("#{@md.fns}\n") @@ -300,39 +181,51 @@ module SiSU_DigestView description("Sourcefile digest: #{@md.dgst[1]}\n") description(" source filename: #{@md.fns}\n") description("available outputs: #{manifest}\n") - #description(" time generated: #{@g}\n") - #description(" SiSU version used: #{@v}\n") - #description(" Ruby version used: #{@r}\n") description("------------\n") description("Document Digests\n") - description(a) end def ao_structure + a=%{\nocn digests (#{@dg}) clean text (stripped markup)} + digests_clean(a) data=@data endnotes=nil data.each do |t_o| dgst=SiSU_TextRepresentation::ModifiedTextPlusHashDigest.new(@md,t_o).composite.dgst if dgst if t_o.is==:heading - digests("#{@sp*0}#{dgst[:ocn]}#{@sp*(8-dgst[:ocn].to_s.length)}#{dgst[:dgst_stripped_txt]} #{dgst[:dgst_markedup_txt]} #{dgst[:is]} #{t_o.lv}") + digests_clean("#{@sp*0}#{dgst[:ocn]}#{@sp*(8-dgst[:ocn].to_s.length)}#{dgst[:dgst_stripped_txt]} #{dgst[:is]} #{t_o.lv}") elsif t_o.is==:heading_insert - digests("#{@sp*0}[#{dgst[:ocn]}]#{@sp*(6-dgst[:ocn].to_s.length)}#{dgst[:dgst_stripped_txt]} #{dgst[:dgst_markedup_txt]} #{dgst[:is]} #{t_o.lv}") + digests_clean("#{@sp*0}[#{dgst[:ocn]}]#{@sp*(6-dgst[:ocn].to_s.length)}#{dgst[:dgst_stripped_txt]} #{dgst[:is]} #{t_o.lv}") else - digests("#{@sp*0}#{dgst[:ocn]}#{@sp*(8-dgst[:ocn].to_s.length)}#{dgst[:dgst_stripped_txt]} #{dgst[:dgst_markedup_txt]} #{dgst[:is]}") + digests_clean("#{@sp*0}#{dgst[:ocn]}#{@sp*(8-dgst[:ocn].to_s.length)}#{dgst[:dgst_stripped_txt]} #{dgst[:is]}") if dgst[:images] dgst[:images].each do |img| - digests("#{@sp*8}#{img[:img_dgst]}#{@sp*66}#{img[:img_type]} #{img[:img_name]}") + digests_clean("#{@sp*8}#{img[:img_dgst]}#{@sp*66}#{img[:img_type]} #{img[:img_name]}") end end end if dgst[:endnotes] dgst[:endnotes].each do |en| - digests("#{@sp*8}#{en[:note_dgst]}#{@sp*66}note [#{en[:note_number]}]") + digests_clean("#{@sp*8}#{en[:note_dgst]} note [#{en[:note_number]}]") endnotes=en[:note_number] end end end end + b=%{\nocn object (#{@dg}) digests (object includes its markup & endnotes (if any))} + digests_with_markup(b) + data.each do |t_o| + dgst=SiSU_TextRepresentation::ModifiedTextPlusHashDigest.new(@md,t_o).composite.dgst + if dgst + if t_o.is==:heading + digests_with_markup("#{@sp*0}#{dgst[:ocn]}#{@sp*(8-dgst[:ocn].to_s.length)}#{dgst[:dgst_markedup_txt]} #{dgst[:is]} #{t_o.lv}") + elsif t_o.is==:heading_insert + digests_with_markup("#{@sp*0}[#{dgst[:ocn]}]#{@sp*(6-dgst[:ocn].to_s.length)}#{dgst[:dgst_markedup_txt]} #{dgst[:is]} #{t_o.lv}") + else + digests_with_markup("#{@sp*0}#{dgst[:ocn]}#{@sp*(8-dgst[:ocn].to_s.length)}#{dgst[:dgst_markedup_txt]} #{dgst[:is]}") + end + end + end l=Hash.new(0) ocn=nil ao_structure_tree("------------\n") @@ -340,18 +233,20 @@ module SiSU_DigestView data.each do |t_o| if t_o.is==:heading x=case t_o.ln - when 1 then l[1] +=1 #fix Mx[:lv_o] + when 0 then l[0] +=1 ' '*0 << ':A' - when 2 then l[2] +=1 #fix Mx[:lv_o] + when 1 then l[1] +=1 ' '*1 << ':B' - when 3 then l[3] +=1 #fix Mx[:lv_o] + when 2 then l[2] +=1 ' '*2 << ':C' - when 4 then l[4] +=1 #fix Mx[:lv_o] - ' '*3 << '1' - when 5 then l[5] +=1 #fix Mx[:lv_o] - ' '*4 << '2' - when 6 then l[6] +=1 #fix Mx[:lv_o] - ' '*5 << '3' + when 3 then l[3] +=1 + ' '*3 << ':D' + when 4 then l[4] +=1 + ' '*4 << '1' + when 5 then l[5] +=1 + ' '*5 << '2' + when 6 then l[6] +=1 + ' '*6 << '3' else nil end end @@ -363,9 +258,10 @@ module SiSU_DigestView ao_structure_summary("document structure[*]\n") [0,1,2,3,4,5,6].each do |y| v=case y - when 1 then ':A' - when 2 then ':B' - when 3 then ':C' + when 0 then ':A' + when 1 then ':B' + when 2 then ':C' + when 3 then ':D' when 4 then '1 ' when 5 then '2 ' when 6 then '3 ' @@ -374,7 +270,7 @@ module SiSU_DigestView end ao_structure_summary("objects (ocn) = #{ocn}\n") ao_structure_summary("endnotes = #{endnotes}\n") - ao_structure_summary(" [*] number of headers (@) and of each heading level (:A to :C and 1 to 3)\n") + ao_structure_summary(" [*] number of headers (@) and of each heading level (:A to :D and 1 to 3)\n") end def supplementary if defined? @md.sc_number \ diff --git a/lib/sisu/v6/manifest.rb b/lib/sisu/v6/manifest.rb index 1d6bc6a9..27b90eda 100644 --- a/lib/sisu/v6/manifest.rb +++ b/lib/sisu/v6/manifest.rb @@ -123,7 +123,7 @@ module SiSU_Manifest ? './image' : %{#{@f.path_rel_links.html_scroll_2}_sisu/image_sys} @base_path=@f.output_path.manifest.dir - @@dg ||=SiSU_Env::InfoEnv.new.digest.type + @@dg ||=SiSU_Env::InfoEnv.new(md.fns,md).digest(md.opt).type @dg=@@dg l=SiSU_Env::StandardiseLanguage.new(md.opt.lng).language @language=l[:n] @@ -165,9 +165,15 @@ module SiSU_Manifest end def summarize_sources(id,file,pth,rel,url) sys=SiSU_Env::SystemCall.new - dgst=(@dg =~/^sha(?:2|256)$/) \ - ? sys.sha256("#{pth}/#{file}") - : sys.md5("#{pth}/#{file}") + dgst=case @dg + when :sha512 + sys.sha512("#{pth}/#{file}") + when :sha256 + sys.sha256("#{pth}/#{file}") + when :md5 + sys.md5("#{pth}/#{file}") + else + end if (@md.opt.act[:verbose][:set]==:on \ || @md.opt.act[:verbose_plus][:set]==:on \ || @md.opt.act[:maintenance][:set]==:on) diff --git a/lib/sisu/v6/options.rb b/lib/sisu/v6/options.rb index aacfcbe6..115281c7 100644 --- a/lib/sisu/v6/options.rb +++ b/lib/sisu/v6/options.rb @@ -968,6 +968,14 @@ module SiSU_Commandline || mod.inspect =~/"--hash-digests"/) \ ? { bool: true, set: :on } : { bool: false, set: :na } + act[:hash_digest_algo]=if mod.inspect =~/"--hash-(?:sha)?512"/ + :sha512 + elsif mod.inspect =~/"--hash-(?:sha)?256"/ + :sha256 + elsif mod.inspect =~/"--hash-md5"/ + :md5 + else :na + end act[:sample_search_form]=(cmd =~/F/ \ || mod.inspect =~/"--sample-search-form"/) \ ? { bool: true, set: :on } diff --git a/lib/sisu/v6/param.rb b/lib/sisu/v6/param.rb index e3eaebae..9d310f7c 100644 --- a/lib/sisu/v6/param.rb +++ b/lib/sisu/v6/param.rb @@ -1281,14 +1281,23 @@ module SiSU_Param if @sys.openssl !=false \ and FileTest.file?(@env.source_file_with_path) @dgst=[] - if @env.digest.type =~/sha256/ + case @env.digest(@opt).type + when :sha512 + dgst=@sys.sha512(@env.source_file_with_path) + @dgst=dgst[1].length==128 ? dgst : nil + puts 'check document (sha512) digest' if not @dgst + when :sha256 dgst=@sys.sha256(@env.source_file_with_path) @dgst=dgst[1].length==64 ? dgst : nil puts 'check document (sha256) digest' if not @dgst - else + when :md5 dgst=@sys.md5(@env.source_file_with_path) @dgst=dgst[1].length==32 ? dgst : nil puts 'check document (md5) digest' if not @dgst + else + dgst=@sys.sha256(@env.source_file_with_path) + @dgst=dgst[1].length==64 ? dgst : nil + puts 'check document (sha256) digest' if not @dgst end elsif not FileTest.file?(@env.source_file_with_path) #puts SiSU_Utils::CodeMarker.new(__LINE__,__FILE__).set(:fuchsia) diff --git a/lib/sisu/v6/qrcode.rb b/lib/sisu/v6/qrcode.rb index 067d3d64..73feaf3f 100644 --- a/lib/sisu/v6/qrcode.rb +++ b/lib/sisu/v6/qrcode.rb @@ -80,7 +80,7 @@ module SiSU_QRcode end def read begin - @env=SiSU_Env::InfoEnv.new(@opt.fns) + @env=SiSU_Env::InfoEnv.new(@opt.fns,@opt) @md=SiSU_Param::Parameters.new(@opt).get xbrowser=@env.program.web_browser browser=@env.program.console_web_browser @@ -111,12 +111,12 @@ module SiSU_QRcode def initialize(md) @manifest={ txt: [], txt_title: [] } @md,@fns=md,md.fns - @env=SiSU_Env::InfoEnv.new(@md.fns) + @env=SiSU_Env::InfoEnv.new(@md.fns,@md.opt) @fnb=@md.fnb @base_url="#{@env.url.root}/#{@fnb}" @f=SiSU_Env::FileOp.new(@md) @base_path=@f.output_path.manifest.dir - @@dg ||=SiSU_Env::InfoEnv.new.digest.type + @@dg ||=SiSU_Env::InfoEnv.new.digest(@md.opt).type @dg=@@dg l=SiSU_Env::StandardiseLanguage.new(@md.opt.lng).language @language=l[:n] @@ -167,9 +167,14 @@ WOK end def summarize_sources(id,file,pth,rel,url) sys=SiSU_Env::SystemCall.new - dgst=(@dg =~/^sha(?:2|256)$/) \ - ? (sys.sha256("#{pth}/#{file}")) - : (sys.md5("#{pth}/#{file}")) + dgst=case @dg + when :sha512 + (sys.sha516("#{pth}/#{file}")) #check + when :md5 + (sys.md5("#{pth}/#{file}")) + else + (sys.sha256("#{pth}/#{file}")) + end if (@md.opt.act[:verbose][:set]==:on \ || @md.opt.act[:verbose_plus][:set]==:on \ || @md.opt.act[:maintenance][:set]==:on) diff --git a/lib/sisu/v6/shared_markup_alt.rb b/lib/sisu/v6/shared_markup_alt.rb index 4971dde0..3bf3c7e4 100644 --- a/lib/sisu/v6/shared_markup_alt.rb +++ b/lib/sisu/v6/shared_markup_alt.rb @@ -207,20 +207,32 @@ module SiSU_TextRepresentation @t_o,@s=x,x.obj.dup end @env ||=SiSU_Env::InfoEnv.new(@md.fns) - @sha_ =((@env.digest.type =='sha256') ? true : false) + @sha_ = @env.digest(@md.opt).type begin - @sha_ ? (require 'digest/sha2') : (require 'digest/md5') + case @sha_ + when :sha512 + require 'digest/sha2' + when :sha256 + require 'digest/sha2' + when :md5 + require 'digest/md5' + end rescue LoadError SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error((@sha_ ? 'digest/sha2' : 'digest/md5') + ' NOT FOUND') end end def digest(txt) d=nil - if @sha_ + case @sha_ + when :sha512 + for hash_class in [ Digest::SHA512 ] + d=hash_class.hexdigest(txt) + end + when :sha256 for hash_class in [ Digest::SHA256 ] d=hash_class.hexdigest(txt) end - else + when :md5 for hash_class in [ Digest::MD5 ] d=hash_class.hexdigest(txt) end diff --git a/lib/sisu/v6/sysenv.rb b/lib/sisu/v6/sysenv.rb index ece3ca79..bc3f1a74 100644 --- a/lib/sisu/v6/sysenv.rb +++ b/lib/sisu/v6/sysenv.rb @@ -214,7 +214,7 @@ module SiSU_Env MULTILINGUAL => false, BUNDLE => false, CONCORD_MAX => 260000, - DIGEST => 'sha256', + DIGEST => :sha256, WEBSERV_HOST_CGI => 'http://localhost', WEBSERV_PORT_CGI => 8081, #8111,8123,8081 POSTGRESQL_USER => @@user, #'ralph', # change user !!! @@ -806,6 +806,19 @@ module SiSU_Env false end end + def sha512(filename) #sha dgst + program='openssl' + program_ref="\n\t\tsha digest requested" + if program_found?(program) + pwd=Dir.pwd + Dir.chdir(File.dirname(filename)) + dgst=%x{openssl dgst -sha512 #{File.basename(filename)}}.strip #use file name without file path + Dir.chdir(pwd) + dgst.scan(/\S+/) + else SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).warn("#{program} is not installed #{program_ref}") + false + end + end def psql #psql program='psql' program_ref="\n\t\tpsql requested" @@ -2715,27 +2728,41 @@ WOK end self end - def digest + def digest_conf? + if defined? @rc['default']['digest'] \ + and @rc['default']['digest'] != nil + case @rc['default']['digest'] + when /^sha(?:5|512)?$/ then :sha512 + when /^sha(?:2|256)?$/ then :sha256 + when /^md5$/ then :md5 + else :sha256 + end + else :sha256 + end + end + def digest(opt=nil) + @opt=opt def type - if defined? @rc['default']['digest'] \ - and @rc['default']['digest'] != nil - case @rc['default']['digest'] - when /^sha(?:2|256)?$/ then 'sha256' - when /^md5$/ then 'md5' - else 'sha256' + if @opt + case @opt.act[:hash_digest_algo] + when :sha512 then :sha512 + when :sha256 then :sha256 + when :md5 then :md5 + else digest_conf? end - else 'sha256' + else digest_conf? end end def length - case digest.type - when /sha256/ then 64 - when /md5/ then 32 + case digest(@opt).type + when :sha512 then 128 + when :sha256 then 64 + when :md5 then 32 else 64 end end def pattern - "[0-9a-f]{#{digest.length}}" #/[0-9a-f]{#{digest.length}}/ + "[0-9a-f]{#{digest(@opt).length}}" #/[0-9a-f]{#{digest.length}}/ end self end diff --git a/lib/sisu/v6/urls.rb b/lib/sisu/v6/urls.rb index 5327a9bb..29671dca 100644 --- a/lib/sisu/v6/urls.rb +++ b/lib/sisu/v6/urls.rb @@ -107,7 +107,7 @@ module SiSU_Urls 'I --texinfo (Info file)'=>'info', 'i --manpage (manpage)'=>'manpage', 'm --ao (Document Abstraction)'=>'ao', - 'N --hash-digests (Digests md5/sha256)'=>@fn[:digest], + 'N --hash-digests (Digests sha512/sha256/md5)'=>@fn[:digest], 'o --odt (ODF:ODT - Open Document)'=>@fn[:odf], 'p --pdf (PDF landscape)'=>@fn[:pdf_l], 'p --pdf (PDF portrait)'=>@fn[:pdf_p], -- cgit v1.2.3 From 369b764eb0eca1c2aae7b2dd8a53a7eadbeb902d Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 12 May 2014 21:27:06 -0400 Subject: v5 v6: param, metadata add 'Copyright:' tag to output related to copyright * (Closes: #744381) syntax: inconsistency \:copyright: and \:license: --- lib/sisu/v5/param.rb | 2 +- lib/sisu/v6/param.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v5/param.rb b/lib/sisu/v5/param.rb index ba75bfb0..1167d5ee 100644 --- a/lib/sisu/v5/param.rb +++ b/lib/sisu/v5/param.rb @@ -568,7 +568,7 @@ module SiSU_Param and copyright.text \ and not copyright.text.empty? v=sep(copyright.text) - s +=copyright.text + v + s +='Copyright: ' + copyright.text + v end if defined? copyright.translation \ and copyright.translation \ diff --git a/lib/sisu/v6/param.rb b/lib/sisu/v6/param.rb index 9d310f7c..7cbb6ba7 100644 --- a/lib/sisu/v6/param.rb +++ b/lib/sisu/v6/param.rb @@ -568,7 +568,7 @@ module SiSU_Param and copyright.text \ and not copyright.text.empty? v=sep(copyright.text) - s +=copyright.text + v + s +='Copyright: ' + copyright.text + v end if defined? copyright.translation \ and copyright.translation \ -- cgit v1.2.3 From d5b13ca5b8d041c13ef8fa8f8fe4764a9e24166b Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 12 May 2014 21:32:33 -0400 Subject: v6: param, metadata rights, line-breaks instead of semicolons separating rights * (Closes: #744358) remove trailing semicolon after :copyright: --- lib/sisu/v6/param.rb | 25 +++++++++++-------------- lib/sisu/v6/shared_metadata.rb | 11 +++++++++++ 2 files changed, 22 insertions(+), 14 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v6/param.rb b/lib/sisu/v6/param.rb index 7cbb6ba7..60c9bb54 100644 --- a/lib/sisu/v6/param.rb +++ b/lib/sisu/v6/param.rb @@ -500,12 +500,9 @@ module SiSU_Param @h=build_hash(a) def copyright def text #you may wish to expand to take from all - s=if @h['copyright'] - @h['copyright'] - elsif @h['text'] - @h['text'] - elsif @h['main'] - @h['main'] + s=if @h['copyright'] then @h['copyright'] + elsif @h['text'] then @h['text'] + elsif @h['main'] then @h['main'] else SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'WARNING Document Copyright missing; provide @rights: :copyright:').warn unless @opt.act[:quiet][:set]==:on '' @@ -558,7 +555,7 @@ module SiSU_Param validate_length(s,l,n) end def sep(str) - (str =~/https?:\/\/\S+$/) ? ' ;' : ';' + ' \\\\ ' end def all s=if @h['all'] then @h['all'] @@ -574,36 +571,36 @@ module SiSU_Param and copyright.translation \ and not copyright.translation.empty? v=sep(copyright.translation) - s +='\\\\ translation ' + copyright.translation + v + s +='translation: ' + copyright.translation + v end if defined? copyright.illustrations \ and copyright.illustrations \ and not copyright.illustrations.empty? v=sep(copyright.illustrations) - s +='\\\\ illustrations ' + copyright.illustrations + v + s +='illustrations: ' + copyright.illustrations + v end if defined? copyright.photographs \ and copyright.photographs \ and not copyright.photographs.empty? v=sep(copyright.photographs) - s +='\\\\ photographs ' + copyright.photographs + v + s +='photographs: ' + copyright.photographs + v end if defined? copyright.digitization \ and copyright.digitization \ and not copyright.digitization.empty? v=sep(copyright.digitization) - s +='\\\\ digitization ' + copyright.digitization + v + s +='digitization: ' + copyright.digitization + v end if defined? copyright.audio \ and copyright.audio \ and not copyright.audio.empty? v=sep(copyright.audio) - s +='\\\\ audio ' + copyright.audio + v + s +='audio: ' + copyright.audio + v end if defined? copyright.license \ and copyright.license \ and not copyright.license.empty? - s +='\\\\ License: ' + copyright.license + s +='License: ' + copyright.license end if s.empty? SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'WARNING Document Rights information missing; provide @rights: :copyright:').warn unless @opt.act[:quiet][:set]==:on @@ -611,7 +608,7 @@ module SiSU_Param l,n=Db[:col_info_note],'rights.all' validate_length(s,l,n) end - s + s=s.gsub(/ [\\]+\s+$/,'') end s end diff --git a/lib/sisu/v6/shared_metadata.rb b/lib/sisu/v6/shared_metadata.rb index c2fe06b9..1fa57fa7 100644 --- a/lib/sisu/v6/shared_metadata.rb +++ b/lib/sisu/v6/shared_metadata.rb @@ -735,6 +735,13 @@ module SiSU_Metadata end @s end + def br + if @s \ + and @s.is_a?(String) + @s=@s.gsub(/(?:#{Mx[:br_line]}|\\\\)+/,'
') + end + @s + end def utf8 if @s \ and @s.is_a?(String) @@ -752,6 +759,7 @@ module SiSU_Metadata def xml_sax def meta_para inf_xml=char_enc(@inf).utf8 + inf_xml=char_enc(inf_xml).br < #{Ax[:tab]}#{@tag.capitalize}: @@ -769,6 +777,7 @@ WOK def xml_dom def meta_para inf_xml=char_enc(@inf).utf8 + inf_xml=char_enc(inf_xml).br < #{Ax[:tab]*2}#{@tag.capitalize}: @@ -786,6 +795,7 @@ WOK def xhtml_scroll def meta_para inf_xml=char_enc(@inf).utf8 + inf_xml=char_enc(inf_xml).br < #{Ax[:tab]}#{@tag.capitalize}: @@ -805,6 +815,7 @@ WOK def meta_para inf_xml=char_enc(@inf).amp inf_xml=char_enc(inf_xml).utf8 + inf_xml=char_enc(inf_xml).br %{

#{@tag}: #{inf_xml}

} -- cgit v1.2.3 From 1716ccd079dc399190804ede2b2b08bf19c0a3b3 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 12 May 2014 21:38:34 -0400 Subject: v6: texpdf, (internal coding) use symbols to identify page orientation --- lib/sisu/v6/texpdf.rb | 16 ++++++++-------- lib/sisu/v6/texpdf_format.rb | 21 +++++++++++---------- 2 files changed, 19 insertions(+), 18 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v6/texpdf.rb b/lib/sisu/v6/texpdf.rb index 97961701..b3636154 100644 --- a/lib/sisu/v6/texpdf.rb +++ b/lib/sisu/v6/texpdf.rb @@ -746,12 +746,12 @@ module SiSU_TeX title=@md.title.full.gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}|#{Mx[:br_paragraph]}|\\\\/,' - ') #no line splitting in heading neither html nor latex @md.papersize_array.each do |ps| if @md.opt.act[:pdf_p][:set]==:on - txt_obj={ txt: "#{home}: - #{title}", paper_size: ps, orientation: 'portrait' } + txt_obj={ txt: "#{home}: - #{title}", paper_size: ps, orientation: :portrait } orient_portrait=SiSU_TeX_Pdf::FormatHead.new(@md,txt_obj) @@tex_head[ps][:p]=orient_portrait.document_head_with_orientation(@codeblock_box) end if @md.opt.act[:pdf_l][:set]==:on - txt_obj={ txt: "#{home}: - #{title}", paper_size: ps, orientation: 'landscape' } + txt_obj={ txt: "#{home}: - #{title}", paper_size: ps, orientation: :landscape } orient_landscape=SiSU_TeX_Pdf::FormatHead.new(@md,txt_obj) @@tex_head[ps][:l]=orient_landscape.document_head_with_orientation(@codeblock_box) end @@ -843,30 +843,30 @@ module SiSU_TeX \\renewcommand{\\contentsname}{#{@translate.contents}} \\tableofcontents WOK - toc_pb={ l: @tex_ml.newpage('landscape'), p: @tex_ml.newpage('portrait') } + toc_pb={ l: @tex_ml.newpage(:landscape), p: @tex_ml.newpage(:portrait) } else toc='' toc_pb={ l: '', p: '' } end if @md.opt.act[:pdf_l][:set]==:on x[:l] =<<-WOK -#{@tex_ml.newpage('landscape')} +#{@tex_ml.newpage(:landscape)} \\pagestyle{fancy} #{toc}#{toc_pb[:l]} \\pagenumbering{arabic} #{@tex_ml.paraskip_normal} -#{@tex_ml.newpage('landscape')} +#{@tex_ml.newpage(:landscape)} WOK end if @md.opt.act[:pdf_p][:set]==:on x[:p] =<<-WOK -#{@tex_ml.newpage('portrait')} +#{@tex_ml.newpage(:portrait)} \\pagestyle{fancy} #{toc}#{toc_pb[:p]} -#{@tex_ml.newpage('portrait')} +#{@tex_ml.newpage(:portrait)} \\pagenumbering{arabic} #{@tex_ml.paraskip_normal} -#{@tex_ml.newpage('portrait')} +#{@tex_ml.newpage(:portrait)} WOK end @tex_file << x diff --git a/lib/sisu/v6/texpdf_format.rb b/lib/sisu/v6/texpdf_format.rb index c1bd0f1c..ea5f383f 100644 --- a/lib/sisu/v6/texpdf_format.rb +++ b/lib/sisu/v6/texpdf_format.rb @@ -920,7 +920,7 @@ module SiSU_TeX_Pdf def tex_head_paper_dimensions d={} case @layout - when /portrait/ + when :portrait d[:papertype],d[:fontsize]='a4paper','11pt' d[:oddsidemargin],d[:evensidemargin],d[:topmargin]='0mm','0mm','-12pt' d[:headheight],d[:headsep],d[:columnsep]='12pt','35pt','' @@ -950,7 +950,7 @@ module SiSU_TeX_Pdf d[:papertype],d[:fontsize]='a4paper','12pt' d[:textheight],d[:textwidth]=@tx.a4.portrait.h,@tx.a4.portrait.w end - when /landscape/ + when :landscape d[:papertype],d[:fontsize]='a4paper','11pt' d[:oddsidemargin],d[:evensidemargin],d[:topmargin]='6mm','6mm','-12mm' d[:headheight],d[:headsep],d[:columnsep]='12pt','20pt','40pt' @@ -980,22 +980,22 @@ module SiSU_TeX_Pdf end def tex_head_paper case @layout - when /portrait/ + when :portrait tex_head_paper_portrait(tex_head_paper_dimensions) - when /landscape/ + when :landscape tex_head_paper_landscape(tex_head_paper_dimensions) end end def tex_head_pdftex_dvi color=case @layout - when /portrait/ + when :portrait <<-WOK colorlinks=true, urlcolor=myblack, filecolor=myblack, linkcolor=myblack, WOK - when /landscape/ + when :landscape <<-WOK colorlinks=true, urlcolor=myblue, % \\href{...}{...} external url @@ -1003,8 +1003,9 @@ module SiSU_TeX_Pdf linkcolor=myred, % \\href{...} and \\pageref{...} WOK end - if @layout =~/portrait|landscape/ - <<-WOK + if @layout == :portrait \ + or @layout == :landscape + <<-WOK \\usepackage{alltt} \\usepackage{thumbpdf} \\usepackage[#{@tex2pdf}, @@ -1484,11 +1485,11 @@ module SiSU_TeX_Pdf #BOOK standard dimensions - 229x156 def newpage(orientation) case orientation - when /landscape/ # using longtable latex package + when :landscape # using longtable latex package <<-WOK \\clearpage WOK - when /portrait/ + when :portrait <<-WOK \\newpage WOK -- cgit v1.2.3 From 09fc878f67e525519901fdf8aec9a615984bab95 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 12 May 2014 21:41:53 -0400 Subject: v6: texpdf, (internal coding) fontface, rename texpdf_font texpdf_fontface --- lib/sisu/v6/sysenv.rb | 46 ++++++++++++------------- lib/sisu/v6/texpdf_format.rb | 80 ++++++++++++++++++++++---------------------- 2 files changed, 63 insertions(+), 63 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v6/sysenv.rb b/lib/sisu/v6/sysenv.rb index bc3f1a74..fd36691e 100644 --- a/lib/sisu/v6/sysenv.rb +++ b/lib/sisu/v6/sysenv.rb @@ -1880,51 +1880,51 @@ WOK # fc-list :outline -f "%{family}\n" # fc-list :lang=ja def main - (defined? @rc['default']['texpdf_font']) \ - && (@rc['default']['texpdf_font']=~/\S{3,}/) \ - ? @rc['default']['texpdf_font'] + (defined? @rc['default']['texpdf_fontface']) \ + && (@rc['default']['texpdf_fontface']=~/\S{3,}/) \ + ? @rc['default']['texpdf_fontface'] : 'Liberation Sans' end def sans # not used - (defined? @rc['default']['texpdf_font_sans']) \ - && (@rc['default']['texpdf_font_sans']=~/\S{3,}/) \ - ? @rc['default']['texpdf_font_sans'] + (defined? @rc['default']['texpdf_fontface_sans']) \ + && (@rc['default']['texpdf_fontface_sans']=~/\S{3,}/) \ + ? @rc['default']['texpdf_fontface_sans'] : 'Liberation Sans' end def serif # not used - (defined? @rc['default']['texpdf_font_serif']) \ + (defined? @rc['default']['texpdf_fontface_serif']) \ && (@rc['default']['texpdf_font_serif']=~/\S{3,}/) \ - ? @rc['default']['texpdf_font_serif'] + ? @rc['default']['texpdf_fontface_serif'] : 'Liberation Serif' end def mono - (defined? @rc['default']['texpdf_font_mono']) \ - && (@rc['default']['texpdf_font_mono']=~/\S{3,}/) \ - ? @rc['default']['texpdf_font_mono'] + (defined? @rc['default']['texpdf_fontface_mono']) \ + && (@rc['default']['texpdf_fontface_mono']=~/\S{3,}/) \ + ? @rc['default']['texpdf_fontface_mono'] : 'Liberation Mono' end def cjk - (defined? @rc['default']['texpdf_font_cjk']) \ - && (@rc['default']['texpdf_font_cjk']=~/\S{3,}/) \ - ? @rc['default']['texpdf_font_cjk'] + (defined? @rc['default']['texpdf_fontface_cjk']) \ + && (@rc['default']['texpdf_fontface_cjk']=~/\S{3,}/) \ + ? @rc['default']['texpdf_fontface_cjk'] : 'IPAGothic' # 'IPAGothic' # 'IPAMincho' # 'TakaoMincho' # 'VL Gothic' end def cjk_zh - (defined? @rc['default']['texpdf_font_cjk_zh']) \ - && (@rc['default']['texpdf_font_cjk_zh']=~/\S{3,}/) \ - ? @rc['default']['texpdf_font_cjk_zh'] + (defined? @rc['default']['texpdf_fontface_cjk_zh']) \ + && (@rc['default']['texpdf_fontface_cjk_zh']=~/\S{3,}/) \ + ? @rc['default']['texpdf_fontface_cjk_zh'] : 'IPAGothic' end def cjk_ja - (defined? @rc['default']['texpdf_font_cjk_ja']) \ - && (@rc['default']['texpdf_font_cjk_ja']=~/\S{3,}/) \ - ? @rc['default']['texpdf_font_cjk_ja'] + (defined? @rc['default']['texpdf_fontface_cjk_ja']) \ + && (@rc['default']['texpdf_fontface_cjk_ja']=~/\S{3,}/) \ + ? @rc['default']['texpdf_fontface_cjk_ja'] : 'IPAGothic' end def cjk_ko - (defined? @rc['default']['texpdf_font_cjk_ko']) \ - && (@rc['default']['texpdf_font_cjk_ko']=~/\S{3,}/) \ - ? @rc['default']['texpdf_font_cjk_ko'] + (defined? @rc['default']['texpdf_fontface_cjk_ko']) \ + && (@rc['default']['texpdf_fontface_cjk_ko']=~/\S{3,}/) \ + ? @rc['default']['texpdf_fontface_cjk_ko'] : 'IPAGothic' end self diff --git a/lib/sisu/v6/texpdf_format.rb b/lib/sisu/v6/texpdf_format.rb index ea5f383f..f7e18dc8 100644 --- a/lib/sisu/v6/texpdf_format.rb +++ b/lib/sisu/v6/texpdf_format.rb @@ -771,50 +771,50 @@ module SiSU_TeX_Pdf { mainlang: mainlang, otherlang: otherlang } end def tex_head_encode - texpdf_font=if defined? @md.make.texpdf_font.main \ - and not @md.make.texpdf_font.main.nil? \ - and @md.make.texpdf_font.main=~/\S{3,}/ - @md.make.texpdf_font.main + texpdf_fontface=if defined? @md.make.texpdf_fontface.main \ + and not @md.make.texpdf_fontface.main.nil? \ + and @md.make.texpdf_fontface.main=~/\S{3,}/ + @md.make.texpdf_fontface.main else @env.font.texpdf.main end - texpdf_font_sans=if defined? @md.make.texpdf_font.sans \ - and not @md.make.texpdf_font.sans.nil? \ - and @md.make.texpdf_font.sans=~/\S{3,}/ # not used - @md.make.texpdf_font.sans + texpdf_fontface_sans=if defined? @md.make.texpdf_fontface.sans \ + and not @md.make.texpdf_fontface.sans.nil? \ + and @md.make.texpdf_fontface.sans=~/\S{3,}/ # not used + @md.make.texpdf_fontface.sans else @env.font.texpdf.sans end - texpdf_font_serif=if defined? @md.make.texpdf_font.serif \ - and not @md.make.texpdf_font.serif.nil? \ - and @md.make.texpdf_font.serif=~/\S{3,}/ # not used - @md.make.texpdf_font.serif + texpdf_fontface_serif=if defined? @md.make.texpdf_fontface.serif \ + and not @md.make.texpdf_fontface.serif.nil? \ + and @md.make.texpdf_fontface.serif=~/\S{3,}/ # not used + @md.make.texpdf_fontface.serif else @env.font.texpdf.serif end - texpdf_font_mono=if defined? @md.make.texpdf_font.mono \ - and not @md.make.texpdf_font.mono.nil? \ - and @md.make.texpdf_font.mono=~/\S{3,}/ - @md.make.texpdf_font.mono + texpdf_fontface_mono=if defined? @md.make.texpdf_fontface.mono \ + and not @md.make.texpdf_fontface.mono.nil? \ + and @md.make.texpdf_fontface.mono=~/\S{3,}/ + @md.make.texpdf_fontface.mono else @env.font.texpdf.mono end - texpdf_font_cjk=if @md.opt.lng =~/zh/ \ - and defined? @md.make.texpdf_font.cjk_zh \ - and not @md.make.texpdf_font.cjk_zh.nil? \ - and @md.make.texpdf_font.cjk_zh=~/\S{3,}/ - @md.make.texpdf_font.cjk_zh + texpdf_fontface_cjk=if @md.opt.lng =~/zh/ \ + and defined? @md.make.texpdf_fontface.cjk_zh \ + and not @md.make.texpdf_fontface.cjk_zh.nil? \ + and @md.make.texpdf_fontface.cjk_zh=~/\S{3,}/ + @md.make.texpdf_fontface.cjk_zh elsif @md.opt.lng =~/ja/ \ - and defined? @md.make.texpdf_font.cjk_ja \ - and not @md.make.texpdf_font.cjk_ja.nil? \ - and @md.make.texpdf_font.cjk_ja=~/\S{3,}/ - @md.make.texpdf_font.cjk_ja + and defined? @md.make.texpdf_fontface.cjk_ja \ + and not @md.make.texpdf_fontface.cjk_ja.nil? \ + and @md.make.texpdf_fontface.cjk_ja=~/\S{3,}/ + @md.make.texpdf_fontface.cjk_ja elsif @md.opt.lng =~/ko/ \ - and defined? @md.make.texpdf_font.cjk_ko \ - and not @md.make.texpdf_font.cjk_ko.nil? \ - and @md.make.texpdf_font.cjk_ko=~/\S{3,}/ - @md.make.texpdf_font.cjk_ko + and defined? @md.make.texpdf_fontface.cjk_ko \ + and not @md.make.texpdf_fontface.cjk_ko.nil? \ + and @md.make.texpdf_fontface.cjk_ko=~/\S{3,}/ + @md.make.texpdf_fontface.cjk_ko elsif @md.opt.lng =~/(?:zh|ja|ko)/ \ - and defined? @md.make.texpdf_font.cjk \ - and not @md.make.texpdf_font.cjk.nil? \ - and @md.make.texpdf_font.cjk=~/\S{3,}/ - @md.make.texpdf_font.cjk + and defined? @md.make.texpdf_fontface.cjk \ + and not @md.make.texpdf_fontface.cjk.nil? \ + and @md.make.texpdf_fontface.cjk=~/\S{3,}/ + @md.make.texpdf_fontface.cjk else case @md.opt.lng when /zh/ then @env.font.texpdf.cjk_zh @@ -832,22 +832,22 @@ module SiSU_TeX_Pdf <<-WOK \\usepackage{ucs, fontspec, xltxtra, xunicode, xeCJK} \\setmainCJKlanguage{#{tex_head_lang[:mainlang]}} -\\setCJKmainfont{#{texpdf_font_cjk}} +\\setCJKmainfont{#{texpdf_fontface_cjk}} \\XeTeXlinebreaklocale "#{tex_head_lang[:mainlang]}" \\XeTeXlinebreakskip = 0pt plus 1pt \\setotherlanguage{#{tex_head_lang[:otherlang]}} -\\setmainfont{#{texpdf_font}} -\\setmonofont[Scale=0.85]{#{texpdf_font_mono}} +\\setmainfont{#{texpdf_fontface}} +\\setmonofont[Scale=0.85]{#{texpdf_fontface_mono}} WOK else <<-WOK \\usepackage{polyglossia, ucs, fontspec, xltxtra, xunicode} \\setmainlanguage{#{tex_head_lang[:mainlang]}} \\setotherlanguage{#{tex_head_lang[:otherlang]}} -\\setmainfont{#{texpdf_font}} -\\setmonofont[Scale=0.85]{#{texpdf_font_mono}} -% \\setsansfont{#{texpdf_font_sans}} -% \\setromanfont{#{texpdf_font_serif}} +\\setmainfont{#{texpdf_fontface}} +\\setmonofont[Scale=0.85]{#{texpdf_fontface_mono}} +% \\setsansfont{#{texpdf_fontface_sans}} +% \\setromanfont{#{texpdf_fontface_serif}} WOK end when /pdf/ -- cgit v1.2.3 From 2b2e66c1b6c44ecb55e98ea4316b51f32c51ee80 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 12 May 2014 21:50:42 -0400 Subject: v6: texpdf, headings and table of contents representation * (Closes: #744386) 1~ and 2~ result in the same formatting 1~ 2~ & 3~ now differentiated, see discussion in sisu.org under #744383 * (Closes: #744399) :A smaller formatted than :B A~ B~ C~ now the same size, see discussion in sisu.org under #744383 * #744383 :B and :C result in the same formatting, issue explained see sisu.org --- lib/sisu/v6/texpdf.rb | 22 +++++--- lib/sisu/v6/texpdf_format.rb | 122 ++++++++++++++++++++++--------------------- 2 files changed, 77 insertions(+), 67 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v6/texpdf.rb b/lib/sisu/v6/texpdf.rb index b3636154..5654e6df 100644 --- a/lib/sisu/v6/texpdf.rb +++ b/lib/sisu/v6/texpdf.rb @@ -594,20 +594,26 @@ module SiSU_TeX case dob.is when :heading case dob.ln - when 1..3 - tst.heading_major + when 0 + tst.title_level_A + when 1 + tst.section_heading_level_B + when 2 + tst.section_heading_level_C + when 3 + tst.section_heading_level_D when 4 - tst.level4 + tst.heading_level_1 when 5 - tst.level5 + tst.heading_level_2 when 6 - tst.level6 + tst.heading_level_3 else dob end when :heading_insert br="\n\\\\\n" if dob.name=='book_index' - h=tst.heading_major + h=tst.section_heading_level_B heading="\\clearpage\n" + h.tmp idx_arr=[] idx=SiSU_Particulars::CombinedSingleton.instance.get_idx_raw(@md.opt).raw_idx @@ -628,10 +634,10 @@ module SiSU_TeX dob.tmp={ l: l, p: p } elsif dob.ln==2 \ and dob.obj=~/Metadata\b/ - tst.heading_major + tst.section_heading_level_B elsif dob.ln==4 \ and dob.obj=~/Metadata\b/ - h=tst.level4 + h=tst.heading_level_1 metadata=SiSU_Metadata::TeX_Metadata.new(@md).metadata_tex dob.tmp=h.tmp + ' ' + '\begin{scriptsize}' + metadata.join(br) + '\end{scriptsize}' else dob.tmp='' # dob.tmp={ l: '', p: '' } diff --git a/lib/sisu/v6/texpdf_format.rb b/lib/sisu/v6/texpdf_format.rb index f7e18dc8..015a9934 100644 --- a/lib/sisu/v6/texpdf_format.rb +++ b/lib/sisu/v6/texpdf_format.rb @@ -219,95 +219,99 @@ module SiSU_TeX_Pdf else '' end end - def heading_major + def remove_footnotes(cont_ln) + cont_ln=if cont_ln =~/\\[Ff]ootnote/m + cont_ln.gsub(/\s*\\[Ff]ootnote\[\d+\]\{%\s+.+?\}\s*/m,' '). + gsub(/\s*\\[Ff]ootnote[A]\{[*+]+\d*\}\{%\S+.+?\}\s*/m,' ') + else cont_ln + end + end + def title_level_A dob=@dob - title=@md.title.full dob.tmp=dob.tmp.strip if dob.tmp dob.tmp=dob.tmp.gsub(/\\begin\{(bfseries|itshape)\}(.+?)\\end\{\1\}/m,'\2'). gsub(/#{Mx[:url_o]}|#{Mx[:url_c]}/,'') cont_ln=dob.tmp.dup cont_ln=cont_ln.gsub(/\\begin\{(monosp)\}(.+?)\\end\{\1\}/m,'\2'). gsub(@@tex_pattern_margin_number,'') - clearp=(dob.lv =~/B/ && dob.obj =='Metadata') ? "\\clearpage\n" : '' - if dob.tmp =~/\\[Ff]ootnote/ #and dob =~/^[1-6]#{Tex[:tilde]}/ # removing footnotes from headings! - cont_ln=cont_ln.gsub(/\s*\\footnote\[\d+\]\{%\n .+? \}\s*/,' '). - gsub(/\s*\\Footnote[A]\{[*+]+\d*\}\{%\n .+? \}\s*/,' ') - end + cont_ln=remove_footnotes(cont_ln) + titleset='' dob.tmp=dob.tmp.gsub(/^(.*)\n?$/m, - "#{clearp}\\part*{\\1} -\\addcontentsline{toc}{section}{#{cont_ln}} -\\markboth{#{title}}\n") + "#{titleset}\\part*{\\1} +\\markboth{#{@md.title.full}}\n") dob end - def level4 - dob=@dob + def section_heading_level(dob) dob.tmp=dob.tmp.strip if dob.tmp dob.tmp=dob.tmp.gsub(/\\begin\{(bfseries|itshape)\}(.+?)\\end\{\1\}/m,'\2'). gsub(/#{Mx[:url_o]}|#{Mx[:url_c]}/,'') cont_ln=dob.tmp.dup cont_ln=cont_ln.gsub(/\\begin\{(monosp)\}(.+?)\\end\{\1\}/m,'\2'). - gsub(@@tex_pattern_margin_number,''). - gsub(/#{Tex[:backslash]*2}/,"#{Tex[:backslash]*4}"). # added w42 - gsub(/\\footnote\[\d+\]\{%.+?\\end\{scriptsize\}\s*\}/m,''). #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22 - gsub(/\\Footnote[A]\{[*+]+\d*\}\{%.+?\\end\{scriptsize\}\s*\}/m,'') #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22 - title=@md.title.full - if dob.name =~/endnotes/ - dob.tmp=dob.tmp.gsub(/.+/m,'') - end - if dob.tmp =~/\\footnote/ #and dob =~/^[1-6]#{Tex[:tilde]}/ # removing footnotes from headings! - cont_ln=cont_ln.gsub(/\s*\\footnote\[\d+\]\{%\n .+? \}\s*/,' '). - gsub(/\s*\\Footnote[A]\{[*+]+\d*\}\{%\n .+? \}\s*/,' ') - end - dob.tmp=dob.tmp.gsub(/^(.*)?\n?$/m,"\\subsubsection*{\\1} -\\addcontentsline{toc}{subsection}{#{cont_ln}} -\\markright{#{title}}") + gsub(@@tex_pattern_margin_number,'') + cont_ln=remove_footnotes(cont_ln) + dob.tmp=dob.tmp.gsub(/^(.*)\n?$/m, + "\\clearpage +\\part*{\\1} +\\addcontentsline{toc}{part}{#{cont_ln}} +\\markboth{#{@md.title.full}}\n") dob end - def level5 - dob=@dob - # there is a problem here with creation of headers does not do what you would want it to header starts with a * and is not in bold work on \\@txt*, same for next section 2002w46 - dob.tmp=dob.tmp.strip if dob.tmp - dob.tmp=dob.tmp.gsub(/\\begin\{(bfseries|itshape)\}(.+?)\\end\{\1\}/m,'\2'). - gsub(/#{Mx[:url_o]}|#{Mx[:url_c]}/,'') - cont_ln=dob.tmp.dup - cont_ln=cont_ln.gsub(/\\begin\{(monosp)\}(.+?)\\end\{\1\}/m,'\2'). - gsub(@@tex_pattern_margin_number,''). - gsub(/\\footnote\[\d+\]\{%.+?\\end\{scriptsize\}\s*\}/m,''). #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22 - gsub(/\\Footnote[A]\{[*+]+\d*\}\{%.+?\\end\{scriptsize\}\s*\}/m,''). #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22 - gsub(/\\\&/,' and ') #revisit: tmp bugfix 200507, substitutes & with 'and' in toc, needed e.g. for AT&T, see ffa - if dob.tmp =~/\\footnote/ #and dob =~/^[1-6]#{Tex[:tilde]}/ # removing footnotes from headings! - cont_ln=cont_ln.gsub(/\s*\\footnote\[\d+\]\{%\n .+? \}\s*/,' '). - gsub(/\s*\\Footnote[A]\{[*+]+\d*\}\{%\n .+? \}\s*/,' ') + def heading_sublevels(dob,sublev) + if sublev==:lev1 + sect='section' + tocadd=%{\\addcontentsline{toc}{section}} + pre='' + post='' + headadd=%{\n\\markright{#{@md.title.full}}} + elsif sublev==:lev2 + sect='subsection' + tocadd=%{\\addcontentsline{toc}{subsection}} + pre='' + post=" \\\\\n" + headadd='' + elsif sublev==:lev3 + sect='subsubsection' + tocadd=%{\\addcontentsline{toc}{subsubsection}} + pre='' #pre='~~~~' + post=" \\\\\n" + headadd='' end - dob.tmp=dob.tmp.gsub(/^(.*)?\n?$/m, - "\\subsubsection*{\\1} -\\addcontentsline{toc}{subsubsection}{#{cont_ln} \\\\ -}") - dob - end - def level6 - dob=@dob - # there is a problem here with creation of headers does not do what you would want it to header starts with a * and is not in bold work on \\sub@txt*, same for previous section 2002w46 dob.tmp=dob.tmp.strip if dob.tmp dob.tmp=dob.tmp.gsub(/\\begin\{(bfseries|itshape)\}(.+?)\\end\{\1\}/m,'\2'). gsub(/#{Mx[:url_o]}|#{Mx[:url_c]}/,'') cont_ln=dob.tmp.dup cont_ln=cont_ln.gsub(/\\begin\{(monosp)\}(.+?)\\end\{\1\}/m,'\2'). gsub(@@tex_pattern_margin_number,''). + gsub(/#{Tex[:backslash]*2}/,"#{Tex[:backslash]*4}"). # added w42 gsub(/\\footnote\[\d+\]\{%.+?\\end\{scriptsize\}\s*\}/m,''). #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22 gsub(/\\Footnote[A]\{[*+]+\d*\}\{%.+?\\end\{scriptsize\}\s*\}/m,'') #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22 - if dob.tmp =~/\\footnote/ #and dob =~/^[1-6]#{Tex[:tilde]}/ # removing footnotes from headings! - cont_ln=cont_ln.gsub(/\s*\\footnote\[\d+\]\{%\n .+? \}\s*/,' '). - gsub(/\s*\\Footnote[A]\{[*+]+\d*\}\{%\n .+? \}\s*/,' ') + if dob.name =~/endnotes/ + dob.tmp=dob.tmp.gsub(/.+/m,'') end + cont_ln=remove_footnotes(cont_ln) dob.tmp=dob.tmp.gsub(/^(.*)?\n?$/m, - "\\subsubsection*{\\1} -\\addcontentsline{toc}{subsubsection}{~~~~#{cont_ln} \\\\ -}") - #dob.tmp.gsub(/^(.*)?\n?$/m, - # '\subsubsection*{\1}') + "\\#{sect}*{\\1} +#{tocadd}{#{pre}#{cont_ln}#{post}}#{headadd}") dob end + def section_heading_level_B + section_heading_level(@dob) + end + def section_heading_level_C + section_heading_level(@dob) + end + def section_heading_level_D + section_heading_level(@dob) + end + def heading_level_1 + heading_sublevels(@dob,:lev1) + end + def heading_level_2 + heading_sublevels(@dob,:lev2) + end + def heading_level_3 + heading_sublevels(@dob,:lev3) + end def hang case @dob.indent when /0/ -- cgit v1.2.3 From df9e4219258cd799a11be6f2d18f2af5b88d8352 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 12 May 2014 21:56:28 -0400 Subject: v6: texpdf, pdf default font size configurable (cli & sisurc.yml) (no fractions) * --pdf-fontsize-12 --pdf-fontsize-8 * default: texpdf_fontsize: 12 * (Closes: #744405) --- lib/sisu/v6/options.rb | 4 ++++ lib/sisu/v6/sysenv.rb | 22 +++++++++++++++++++++ lib/sisu/v6/texpdf_format.rb | 47 +++++++++++++++++++++++++++++++------------- 3 files changed, 59 insertions(+), 14 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v6/options.rb b/lib/sisu/v6/options.rb index 115281c7..462d9166 100644 --- a/lib/sisu/v6/options.rb +++ b/lib/sisu/v6/options.rb @@ -968,6 +968,10 @@ module SiSU_Commandline || mod.inspect =~/"--hash-digests"/) \ ? { bool: true, set: :on } : { bool: false, set: :na } + act[:pdf_font_size]=if mod.inspect =~/"--(?:pdf-)?font-?size[=-](\d{1,2})(?:pt)?"/ + $1 + else :na + end act[:hash_digest_algo]=if mod.inspect =~/"--hash-(?:sha)?512"/ :sha512 elsif mod.inspect =~/"--hash-(?:sha)?256"/ diff --git a/lib/sisu/v6/sysenv.rb b/lib/sisu/v6/sysenv.rb index fd36691e..6136d248 100644 --- a/lib/sisu/v6/sysenv.rb +++ b/lib/sisu/v6/sysenv.rb @@ -1875,6 +1875,15 @@ WOK "#{source_file_path}/#{file}" end def font + def size(pt=nil) + if pt && pt != :na + pt + elsif defined? @rc['default']['fontsize'] \ + && @rc['default']['fontsize']=~/\d{1,2}/ + @rc['default']['fontsize'] + else :na + end + end def texpdf # you may wish to check selected font against available fonts: # fc-list :outline -f "%{family}\n" @@ -1927,6 +1936,19 @@ WOK ? @rc['default']['texpdf_fontface_cjk_ko'] : 'IPAGothic' end + def size(pt=nil) + if pt && pt != :na + pt + elsif (defined? @rc['default']['texpdf_fontsize']) \ + && (@rc['default']['texpdf_fontsize']=~/\d{1,2}/) + @rc['default']['texpdf_fontsize'] + elsif (defined? @rc['default']['fontsize']) \ + && (@rc['default']['fontsize']=~/\d{1,2}/) + @rc['default']['fontsize'] + else + :na + end + end self end self diff --git a/lib/sisu/v6/texpdf_format.rb b/lib/sisu/v6/texpdf_format.rb index 015a9934..56bb1c0b 100644 --- a/lib/sisu/v6/texpdf_format.rb +++ b/lib/sisu/v6/texpdf_format.rb @@ -923,60 +923,79 @@ module SiSU_TeX_Pdf end def tex_head_paper_dimensions d={} + fontsize_set=if defined? @env.font.texpdf.size(@md.opt.act[:pdf_font_size]) \ + and not @env.font.texpdf.size(@md.opt.act[:pdf_font_size]).nil? + @env.font.texpdf.size(@md.opt.act[:pdf_font_size]) + else :na + end case @layout when :portrait - d[:papertype],d[:fontsize]='a4paper','11pt' + fontsize=(fontsize_set==:na) ? '11pt' : (fontsize_set + 'pt') + d[:papertype],d[:fontsize]='a4paper',fontsize d[:oddsidemargin],d[:evensidemargin],d[:topmargin]='0mm','0mm','-12pt' d[:headheight],d[:headsep],d[:columnsep]='12pt','35pt','' d[:marginparsep],d[:marginparwidth]='4mm','8mm' case @ps #@md.papersize when /a4/i #European default, SiSU default - d[:papertype],d[:fontsize]='a4paper','12pt' + fontsize=(fontsize_set==:na) ? '12pt' : (fontsize_set + 'pt') + d[:papertype],d[:fontsize]='a4paper',fontsize d[:textheight],d[:textwidth]=@tx.a4.portrait.h,@tx.a4.portrait.w when /letter/i #U.S. default - d[:papertype],d[:fontsize]='letterpaper','12pt' + fontsize=(fontsize_set==:na) ? '12pt' : (fontsize_set + 'pt') + d[:papertype],d[:fontsize]='letterpaper',fontsize d[:textheight],d[:textwidth]=@tx.letter.portrait.h,@tx.letter.portrait.w when /legal/i #U.S. alternative - d[:papertype],d[:fontsize]='legalpaper','12pt' + fontsize=(fontsize_set==:na) ? '12pt' : (fontsize_set + 'pt') + d[:papertype],d[:fontsize]='legalpaper',fontsize d[:textheight],d[:textwidth]=@tx.legal.portrait.h,@tx.legal.portrait.w when /book|b5/i #book default - larger - d[:papertype],d[:fontsize]='b5paper','11pt' + fontsize=(fontsize_set==:na) ? '11pt' : (fontsize_set + 'pt') + d[:papertype],d[:fontsize]='b5paper',fontsize d[:oddsidemargin],d[:evensidemargin],d[:topmargin]='-4mm','-4mm','-36pt' d[:headheight],d[:headsep],d[:columnsep]='12pt','20pt','' d[:textheight],d[:textwidth]=@tx.b5.portrait.h,@tx.b5.portrait.w when /a5/i - d[:papertype],d[:fontsize]='a5paper','11pt' + fontsize=(fontsize_set==:na) ? '11pt' : (fontsize_set + 'pt') + d[:papertype],d[:fontsize]='a5paper',fontsize d[:oddsidemargin],d[:evensidemargin],d[:topmargin]='-4mm','-4mm','-36pt' d[:headheight],d[:headsep],d[:columnsep]='11pt','12pt','' d[:marginparsep],d[:marginparwidth]='4mm','6mm' d[:textheight],d[:textwidth]=@tx.a5.portrait.h,@tx.a5.portrait.w else #default currently A4 - d[:papertype],d[:fontsize]='a4paper','12pt' + fontsize=(fontsize_set==:na) ? '12pt' : (fontsize_set + 'pt') + d[:papertype],d[:fontsize]='a4paper',fontsize d[:textheight],d[:textwidth]=@tx.a4.portrait.h,@tx.a4.portrait.w end when :landscape - d[:papertype],d[:fontsize]='a4paper','11pt' + fontsize=(fontsize_set==:na) ? '11pt' : (fontsize_set + 'pt') + d[:papertype],d[:fontsize]='a4paper',fontsize d[:oddsidemargin],d[:evensidemargin],d[:topmargin]='6mm','6mm','-12mm' d[:headheight],d[:headsep],d[:columnsep]='12pt','20pt','40pt' d[:marginparsep],d[:marginparwidth]='4mm','8mm' case @ps #@md.papersize when /a4/i #European default, SiSU default - d[:papertype],d[:fontsize]='a4paper','11pt' + fontsize=(fontsize_set==:na) ? '11pt' : (fontsize_set + 'pt') + d[:papertype],d[:fontsize]='a4paper',fontsize d[:textheight],d[:textwidth]=@tx.a4.landscape.h,@tx.a4.landscape.w when /letter/i #U.S. default - d[:papertype],d[:fontsize]='letterpaper','11pt' + fontsize=(fontsize_set==:na) ? '11pt' : (fontsize_set + 'pt') + d[:papertype],d[:fontsize]='letterpaper',fontsize d[:textheight],d[:textwidth]=@tx.letter.landscape.h,@tx.letter.landscape.w when /legal/i #U.S. alternative - d[:papertype],d[:fontsize],d[:columnsep]='legalpaper','11pt','48pt' + fontsize=(fontsize_set==:na) ? '11pt' : (fontsize_set + 'pt') + d[:papertype],d[:fontsize],d[:columnsep]='legalpaper',fontsize,'48pt' d[:textheight],d[:textwidth]=@tx.legal.landscape.h,@tx.legal.landscape.w when /book|b5/i #book default - larger - d[:papertype],d[:fontsize],d[:columnsep]='b5paper','11pt','35pt' + fontsize=(fontsize_set==:na) ? '11pt' : (fontsize_set + 'pt') + d[:papertype],d[:fontsize],d[:columnsep]='b5paper',fontsize,'35pt' d[:textheight],d[:textwidth]=@tx.b5.landscape.h,@tx.b5.landscape.w when /a5/i - d[:papertype],d[:fontsize],d[:columnsep]='a5paper','10pt','32pt' + fontsize=(fontsize_set==:na) ? '10pt' : (fontsize_set + 'pt') + d[:papertype],d[:fontsize],d[:columnsep]='a5paper',fontsize,'32pt' d[:textheight],d[:textwidth]=@tx.a5.landscape.h,@tx.a5.landscape.w else #default currently A4 - d[:papertype],d[:fontsize]='a4paper','12pt' + fontsize=(fontsize_set==:na) ? '12pt' : (fontsize_set + 'pt') + d[:papertype],d[:fontsize]='a4paper',fontsize d[:textheight],d[:textwidth]=@tx.a4.landscape.h,@tx.a4.landscape.w end end -- cgit v1.2.3 From 9d76329a6203dbb2b48b926d764b3429ac04ea5c Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 12 May 2014 22:43:02 -0400 Subject: v6: texpdf, pdf colored hyperlinks configurable * --pdf-hyperlinks-color --pdf-hyperlinks-no-color or --pdf-hyperlinks-monochrome * ['default']['pdf_hyperlinks']='color' (other options switch hyperlink color off 'no-color' 'color-off' 'monochrome') * (Closes: #744391) no color on a4 portrait see discussion in sisu.org --- lib/sisu/v6/options.rb | 6 ++++ lib/sisu/v6/sysenv.rb | 42 ++++++++++++++++++++++++++++ lib/sisu/v6/texpdf_format.rb | 66 +++++++++++++++++++++----------------------- 3 files changed, 80 insertions(+), 34 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v6/options.rb b/lib/sisu/v6/options.rb index 462d9166..d7719ea4 100644 --- a/lib/sisu/v6/options.rb +++ b/lib/sisu/v6/options.rb @@ -972,6 +972,12 @@ module SiSU_Commandline $1 else :na end + act[:pdf_hyperlink_colors]=if mod.inspect =~/"--pdf-hyperlinks-(?:mono(?:chrome)?|no-color)"/ + :mono + elsif mod.inspect =~/"--pdf-hyperlinks-color"/ + :color + else :na + end act[:hash_digest_algo]=if mod.inspect =~/"--hash-(?:sha)?512"/ :sha512 elsif mod.inspect =~/"--hash-(?:sha)?256"/ diff --git a/lib/sisu/v6/sysenv.rb b/lib/sisu/v6/sysenv.rb index 6136d248..8c819d9b 100644 --- a/lib/sisu/v6/sysenv.rb +++ b/lib/sisu/v6/sysenv.rb @@ -1874,6 +1874,48 @@ WOK file=@fns.gsub(/\.ssm(?:\.sst)?/,'.ssm.sst') "#{source_file_path}/#{file}" end + def texpdf_hyperlinks(cli) + @cli=cli + @hyplnks=if cli != :na + cli + elsif (defined? @rc['default']['pdf_hyperlinks']) \ + && (@rc['default']['pdf_hyperlinks']=~/color/) + :color + elsif (defined? @rc['default']['pdf_hyperlinks']) \ + && (@rc['default']['pdf_hyperlinks']=~/(?:no-color|color-off|mono(?:chrome)?)/) + :mono + else :na + end + def landscape + if @cli != :na + @cli + elsif (defined? @rc['default']['pdf_hyperlinks_landscape']) \ + && (@rc['default']['pdf_hyperlinks_landscape']=~/color/) + :color + elsif (defined? @rc['default']['pdf_hyperlinks_landscape']) \ + && (@rc['default']['pdf_hyperlinks_landscape']=~/(?:no-color|color-off|mono(?:chrome)?)/) + :mono + elsif @hyplnks != :na + @hyplnks + else :na + end + end + def portrait + if @cli != :na + @cli + elsif (defined? @rc['default']['pdf_hyperlinks_portrait']) \ + && (@rc['default']['pdf_hyperlinks_portrait']=~/color/) + :color + elsif (defined? @rc['default']['pdf_hyperlinks_portrait']) \ + && (@rc['default']['pdf_hyperlinks_portrait']=~/(?:no-color|color-off|mono(?:chrome)?)/) + :mono + elsif @hyplnks != :na + @hyprlnks + else :na + end + end + self + end def font def size(pt=nil) if pt && pt != :na diff --git a/lib/sisu/v6/texpdf_format.rb b/lib/sisu/v6/texpdf_format.rb index 56bb1c0b..47829581 100644 --- a/lib/sisu/v6/texpdf_format.rb +++ b/lib/sisu/v6/texpdf_format.rb @@ -1009,30 +1009,50 @@ module SiSU_TeX_Pdf tex_head_paper_landscape(tex_head_paper_dimensions) end end - def tex_head_pdftex_dvi - color=case @layout - when :portrait + def hyperlinks_monochrome <<-WOK colorlinks=true, urlcolor=myblack, filecolor=myblack, linkcolor=myblack, - WOK - when :landscape + WOK + end + def hyperlinks_colored <<-WOK colorlinks=true, urlcolor=myblue, % \\href{...}{...} external url - filecolor=mygreen, % \\href{...} local file + filecolor=mygreen, % \\href{...} local file linkcolor=myred, % \\href{...} and \\pageref{...} - WOK + WOK + end + def hyperlinks_color? + case @layout + when :portrait then hyperlinks_monochrome + if @env.texpdf_hyperlinks(@md.opt.act[:pdf_hyperlink_colors]).portrait != :na + case @env.texpdf_hyperlinks(@md.opt.act[:pdf_hyperlink_colors]).portrait + when :color then hyperlinks_colored + when :mono then hyperlinks_monochrome + else p __LINE__.to_s + ':error' + end + else hyperlinks_monochrome + end + when :landscape + if @env.texpdf_hyperlinks(@md.opt.act[:pdf_hyperlink_colors]).landscape != :na + case @env.texpdf_hyperlinks(@md.opt.act[:pdf_hyperlink_colors]).landscape + when :color then hyperlinks_colored + when :mono then hyperlinks_monochrome + else p __LINE__.to_s + ':error' + end + else hyperlinks_colored + end end - if @layout == :portrait \ - or @layout == :landscape - <<-WOK + end + def tex_head_pdftex + <<-WOK \\usepackage{alltt} \\usepackage{thumbpdf} \\usepackage[#{@tex2pdf}, - #{color.strip} + #{hyperlinks_color?.strip} pdftitle={#{@txt}}, pdfauthor={#{@author}}, pdfsubject={#{@subject}}, @@ -1068,28 +1088,6 @@ module SiSU_TeX_Pdf \\usepackage{url} %\\usepackage{breakurl} WOK - elsif @txt =~/dvi/ - <<-WOK -\\usepackage{alltt} - #{color.strip} - pageanchor=true, - plainpages=true, - pagebackref, - bookmarks=true, - bookmarksopen=true, - plainpages=false, -] -{hyperref} -\\usepackage[usenames]{color} -\\definecolor{myblack}{rgb}{0,0,0} -\\definecolor{myred}{rgb}{0.75,0,0} -\\definecolor{mygreen}{rgb}{0,0.5,0} -\\definecolor{myblue}{rgb}{0,0,0.5} -\\definecolor{mywhite}{rgb}{1,1,1} -\\usepackage{url} -%\\usepackage{breakurl} - WOK - end end def tex_head_codeblock(codeblock_box_type) codeblock_box=if codeblock_box_type=='listings' @@ -1127,7 +1125,7 @@ module SiSU_TeX_Pdf <<-WOK #{tex_head_paper} #{tex_head_encode} -#{tex_head_pdftex_dvi} +#{tex_head_pdftex} #{tex_head_misc} #{tex_head_codeblock(codeblock_box_type)} \\setcounter{secnumdepth}{2} -- cgit v1.2.3 From 4c27c79289f5c59f2c350249519379192785c2a1 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 12 May 2014 22:48:09 -0400 Subject: v6: texpdf, for urls switch to sans serif (small fontsize) * instead of typewriter, latex default * (Closes: #744353) --- lib/sisu/v6/texpdf_format.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'lib') diff --git a/lib/sisu/v6/texpdf_format.rb b/lib/sisu/v6/texpdf_format.rb index 47829581..a16b39b9 100644 --- a/lib/sisu/v6/texpdf_format.rb +++ b/lib/sisu/v6/texpdf_format.rb @@ -1086,6 +1086,7 @@ module SiSU_TeX_Pdf \\definecolor{myblue}{rgb}{0,0,0.5} \\definecolor{mywhite}{rgb}{1,1,1} \\usepackage{url} +\\urlstyle{sf} %\\usepackage{breakurl} WOK end -- cgit v1.2.3 From 41d62d53264b7af387361e27bc5d1ff874e9d3fa Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 12 May 2014 22:52:04 -0400 Subject: v6: texpdf, '&' in heading breaks toc (now removed from toc (not heading)), bug * revisit, bug --- lib/sisu/v6/texpdf_format.rb | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib') diff --git a/lib/sisu/v6/texpdf_format.rb b/lib/sisu/v6/texpdf_format.rb index a16b39b9..eab84823 100644 --- a/lib/sisu/v6/texpdf_format.rb +++ b/lib/sisu/v6/texpdf_format.rb @@ -235,6 +235,7 @@ module SiSU_TeX_Pdf cont_ln=cont_ln.gsub(/\\begin\{(monosp)\}(.+?)\\end\{\1\}/m,'\2'). gsub(@@tex_pattern_margin_number,'') cont_ln=remove_footnotes(cont_ln) + cont_ln=cont_ln.gsub(/\{[\\]+(&)\}/,'\\1') titleset='' dob.tmp=dob.tmp.gsub(/^(.*)\n?$/m, "#{titleset}\\part*{\\1} @@ -249,6 +250,7 @@ module SiSU_TeX_Pdf cont_ln=cont_ln.gsub(/\\begin\{(monosp)\}(.+?)\\end\{\1\}/m,'\2'). gsub(@@tex_pattern_margin_number,'') cont_ln=remove_footnotes(cont_ln) + cont_ln=cont_ln.gsub(/\{[\\]+(&)\}/,'\\1') dob.tmp=dob.tmp.gsub(/^(.*)\n?$/m, "\\clearpage \\part*{\\1} @@ -289,6 +291,7 @@ module SiSU_TeX_Pdf dob.tmp=dob.tmp.gsub(/.+/m,'') end cont_ln=remove_footnotes(cont_ln) + cont_ln=cont_ln.gsub(/\{[\\]+(&)\}/,'\\1') dob.tmp=dob.tmp.gsub(/^(.*)?\n?$/m, "\\#{sect}*{\\1} #{tocadd}{#{pre}#{cont_ln}#{post}}#{headadd}") -- cgit v1.2.3 From f9fb402000465b36c2be03ca3d61c8820d7d9169 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 12 May 2014 22:54:25 -0400 Subject: v6: texpdf, mailto markup links set for normal text objects * (Closes: #744357) but testing required --- lib/sisu/v6/texpdf_format.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v6/texpdf_format.rb b/lib/sisu/v6/texpdf_format.rb index eab84823..a0955478 100644 --- a/lib/sisu/v6/texpdf_format.rb +++ b/lib/sisu/v6/texpdf_format.rb @@ -69,8 +69,8 @@ module SiSU_TeX_Pdf @brace_url=SiSU_Viz::Defaults.new.url_decoration end def bare_urls - @dob.obj=@dob.obj.gsub(/#{Mx[:url_o]}([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)#{Mx[:url_c]}/, - "#{@brace_url.tex_open}\\1#{@brace_url.tex_close}") + @dob.obj=@dob.obj.gsub(/#{Mx[:url_o]}([a-zA-Z0-9._-]+\@[a-zA-Z0-9_-]+?\.[a-zA-Z0-9._-]+)#{Mx[:url_c]}/, + "#{@brace_url.tex_open}\\begin{scriptsize}\\email{\\1}#{@brace_url.tex_close}") @dob.tmp=@dob.tmp.gsub(/(^|[^\\])_/m,'\1\_'). #watch may not work gsub(/(^|[^#{Mx[:lnk_c]}])#{Mx[:url_o]}_?(?:\\?_)?(\S+?)#{Mx[:url_c]}/m, "\\1#{@brace_url.tex_open}\\begin{scriptsize}\\url{\\2}\\end{scriptsize}#{@brace_url.tex_close}") -- cgit v1.2.3 From 62c48aca4793f8f9b9af4114a6ba84a0a477f789 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 12 May 2014 22:56:57 -0400 Subject: v6: texpdf, urls in creator cause breakage * (Closes: #744541) --- lib/sisu/v6/texpdf_format.rb | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v6/texpdf_format.rb b/lib/sisu/v6/texpdf_format.rb index a0955478..e680bc00 100644 --- a/lib/sisu/v6/texpdf_format.rb +++ b/lib/sisu/v6/texpdf_format.rb @@ -1051,13 +1051,18 @@ module SiSU_TeX_Pdf end end def tex_head_pdftex + author=if defined? @md.creator.author \ + and @md.creator.author=~/\S+/ + SiSU_TeX_Pdf::SpecialCharacters.new(@md,@md.creator.author).special_characters_safe_no_urls + else '' + end <<-WOK \\usepackage{alltt} \\usepackage{thumbpdf} \\usepackage[#{@tex2pdf}, #{hyperlinks_color?.strip} pdftitle={#{@txt}}, - pdfauthor={#{@author}}, + pdfauthor={#{author}}, pdfsubject={#{@subject}}, pdfkeywords={#{@keywords}}, pageanchor=true, @@ -1341,14 +1346,17 @@ module SiSU_TeX_Pdf gsub(/§/u,'\S'). #latex: space between next character not preserved? #str.gsub(/§ /,'\S ') gsub(/£/u,'\pounds'). gsub(//,' '). - gsub(/<\/a>/,' '). - gsub(/((?:^|\s)#{Mx[:lnk_c]})#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/, - '\1\begin{scriptsize}\url{\2}\end{scriptsize}\3'). #special case \{ e.g. \}http://url - gsub(/#{Mx[:url_o]}\\_(\S+?)#{Mx[:url_c]}/, - '\begin{scriptsize}\url{\1}\end{scriptsize}'). #special case \{ e.g. \}http://url - gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/, - '\begin{scriptsize}\\url{\1}\end{scriptsize}') #specially escaped url no decoration - unless is==:code + gsub(/<\/a>/,' ') + unless is==:no_urls + str=str.gsub(/((?:^|\s)#{Mx[:lnk_c]})#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/, + '\1\begin{scriptsize}\url{\2}\end{scriptsize}\3'). #special case \{ e.g. \}http://url + gsub(/#{Mx[:url_o]}\\_(\S+?)#{Mx[:url_c]}/, + '\begin{scriptsize}\url{\1}\end{scriptsize}'). #special case \{ e.g. \}http://url + gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/, + '\begin{scriptsize}\\url{\1}\end{scriptsize}') #specially escaped url no decoration + end + if is !=:code \ + and is !=:no_urls str=str.gsub(/(^|#{Mx[:gl_c]}|\s)((?:https?|file|ftp):\/\/\S+?\.[^'"\s]+?)([;.,]?(?=\s|$))/, "\\1#{@brace_url.tex_open}\\begin{scriptsize}\\url{\\2}\\end{scriptsize}#{@brace_url.tex_close}\\3") #url matching with decoration positive lookahead, sequence issue with { linked }http://url cannot use \b at start end @@ -1438,6 +1446,13 @@ module SiSU_TeX_Pdf str=special_characters_safe_close(str) unless str.nil? @txt=str end + def special_characters_safe_no_urls + str,is=@txt,:no_urls + str=xetex_special_characters_1(str,is) unless str.nil? + str=xetex_special_characters_2(str,is) unless str.nil? # remove this to start with, causes issues + str=special_characters_safe_close(str) unless str.nil? + @txt=str + end def characters_code_listings #special characters - some substitutions are sequence sensitive, rearrange with care. str,is=@txt,@is str=xetex_code_listings(str,is) unless str.nil? -- cgit v1.2.3 From f408992e0acf1a962478886fd968dd71f47b115e Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 12 May 2014 23:03:31 -0400 Subject: v6: ao, document markup structure check, skip processing file on major error * with error message & text at location of failure --- lib/sisu/v5/param.rb | 6 +- lib/sisu/v6/ao_doc_str.rb | 88 ++++++++++++++++-- lib/sisu/v6/composite.rb | 6 +- lib/sisu/v6/hub.rb | 226 +++++++++++++++++++++++++--------------------- lib/sisu/v6/param.rb | 9 +- 5 files changed, 217 insertions(+), 118 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v5/param.rb b/lib/sisu/v5/param.rb index 1167d5ee..adc9350f 100644 --- a/lib/sisu/v5/param.rb +++ b/lib/sisu/v5/param.rb @@ -1311,7 +1311,7 @@ module SiSU_Param if @en[:note] > 0 \ and @en[:sum] > 0 if @en[:sum] > 0 - else SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'*WARN* both endnote styles used',"~{ #{@en[:sum]} }~ and ^~ #{@en[:mark]}").warn unless @opt.act[:unless][:set]==:on + else SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'*WARN* both endnote styles used',"~{ #{@en[:sum]} }~ and ^~ #{@en[:mark]}").warn unless @opt.act[:quiet][:set]==:on end end if @en[:mark] != @en[:note] \ @@ -1328,7 +1328,7 @@ module SiSU_Param and @opt.inspect =~/P/ #@title=Md.new('Text Insert',@opt,@env).title else - SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'WARNING: Document Title missing','please provide @title:').warn unless @opt.act[:unless][:set]==:on + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'WARNING: Document Title missing','please provide @title:').warn unless @opt.act[:quiet][:set]==:on end end if @author !~/[\S]/ @@ -1336,7 +1336,7 @@ module SiSU_Param and @opt.inspect =~/P/ #@creator=SiSU_Param::Md.new('Text Insert',@opt,@env).creator else - SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'WARNING: Document Author missing','please provide @creator: :author:').warn unless @opt.act[:unless][:set]==:on + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'WARNING: Document Author missing','please provide @creator: :author:').warn unless @opt.act[:quiet][:set]==:on end end @struct={} diff --git a/lib/sisu/v6/ao_doc_str.rb b/lib/sisu/v6/ao_doc_str.rb index d8c012fd..3eb4a804 100644 --- a/lib/sisu/v6/ao_doc_str.rb +++ b/lib/sisu/v6/ao_doc_str.rb @@ -847,18 +847,43 @@ module SiSU_AO_DocumentStructureExtract if status==:error node_ln=/^([0-6])/.match(node)[1].to_i node_parent_ln=/^([0-6])/.match(node_parent)[1].to_i - puts %{current level: #{structure_info.lv[node_ln]} (possible parent levels: #{structure_info.possible_parents(structure_info.lv[node_ln])}) + STDERR.puts %{current level: #{structure_info.lv[node_ln]} (possible parent levels: #{structure_info.possible_parents(structure_info.lv[node_ln])}) parent level: #{structure_info.lv[node_parent_ln]} (possible child levels: #{structure_info.possible_children(structure_info.lv[node_parent_ln])}) --- } +SKIPPED processing file: [#{@md.opt.lng}] "#{@md.fns}"} + $process_document = :skip end end end def warning_incorrect_parent_level_or_level(txt) - puts %{warning, -#{txt} -has incorrect level and/or parent level} + puts %{ERROR. There is an error in markup of heading levels either here or in the parent heading. +The current header reads: +"#{txt}" +has incorrect level and/or parent level +--} + end + def required_headers_present? + unless (defined? @md.title \ + and @md.title.full) + STDERR.puts %{required header missing: + +@title: +SKIPPED processing file: [#{@md.opt.lng}] "#{@md.fns}" +} + $process_document = :skip + end + unless (defined? @md.creator.author \ + and @md.creator.author) + STDERR.puts %{required header missing: + +@creator: + :author: anonymous? +SKIPPED processing file: [#{@md.opt.lng}] "#{@md.fns}" +} + $process_document = :skip + end end def ocn #and auto segment numbering increment + required_headers_present? data=@data @o_array=[] node=ocn=ocn_dv=ocn_sp=ocnh=ocnh0=ocnh1=ocnh2=ocnh3=ocnh4=ocnh5=ocnh6=ocno=ocnp=ocnt=ocnc=ocng=ocni=ocnu=0 # h heading, o other, t table, g group, i image @@ -866,6 +891,7 @@ has incorrect level and/or parent level} parent=node1=node2=node3=node4=node5=node6=nil node0='0:0;0' @collapsed_lv0=0 + @lev_occurences={ a: 0, b: 0, c: 0, d: 0, l1: 0, l2: 0, l3: 0 } data.each do |dob| h={} if (dob.obj !~ regex_exclude_ocn_and_node || dob.is==:code) \ @@ -875,7 +901,7 @@ has incorrect level and/or parent level} && dob.ocn_ #dob.ln now is determined, and set earlier, check how best to remove this --> if dob.is==:heading - ln=case dob.lv + @ln=ln=case dob.lv when 'A' then 0 when 'B' then 1 when 'C' then 2 @@ -905,11 +931,13 @@ has incorrect level and/or parent level} end if ln==0 \ or ln=~@md.lv0 + @lev_occurences[:a] += 1 if not dob.obj =~/~#|-#/ ocn_flag=true ocnh0+=1 #heading node0="0:#{ocnh0};#{ocn}" else + #document_structure_check_info(node0,node0,:error) #fix ocn_flag=false node0="0:0;0" end @@ -919,11 +947,13 @@ has incorrect level and/or parent level} node,ocn_sp,parent=node0,"h#{ocnh}",'ROOT' elsif ln==1 \ or ln=~@md.lv1 + @lev_occurences[:b] += 1 if not dob.obj =~/~#|-#/ ocn_flag=true ocnh1+=1 #heading node1="1:#{ocnh1};#{ocn}" else + #document_structure_check_info(node0,node0,:error) #fix ocn_flag=false node1="1:0;0" end @@ -932,6 +962,7 @@ has incorrect level and/or parent level} @collapsed_lv1=@collapsed_lv0+1 node0 else + warning_incorrect_parent_level_or_level(dob.obj) document_structure_check_info(node0,node0,:error) node0 end @@ -939,11 +970,13 @@ has incorrect level and/or parent level} node,ocn_sp,parent=node1,"h#{ocnh}",node0 #FIX elsif ln==2 \ or ln=~@md.lv2 + @lev_occurences[:c] += 1 if not dob.obj =~/~#|-#/ ocn_flag=true ocnh2+=1 node2="2:#{ocnh2};#{ocn}" else + #document_structure_check_info(node0,node0,:error) #fix ocn_flag=false node2="2:0;0" end @@ -952,6 +985,7 @@ has incorrect level and/or parent level} @collapsed_lv2=@collapsed_lv1+1 node1 else + warning_incorrect_parent_level_or_level(dob.obj) document_structure_check_info(node2,node0,:error) node0 end @@ -959,11 +993,13 @@ has incorrect level and/or parent level} node,ocn_sp=node2,"h#{ocnh}" elsif ln==3 \ or ln=~@md.lv3 + @lev_occurences[:d] += 1 if not dob.obj =~/~#|-#/ ocn_flag=true ocnh3+=1 node3="3:#{ocnh3};#{ocn}" else + #document_structure_check_info(node0,node0,:error) #fix ocn_flag=false node3="3:0;0" end @@ -988,6 +1024,7 @@ or this level should be level :B~ rather than #{dob.lv}} node,ocn_sp=node3,"h#{ocnh}" elsif ln==4 \ or ln=~@md.lv4 + @lev_occurences[:l1] += 1 if not dob.obj =~/~#|-#/ ocn_flag=true ocnh4+=1 @@ -1021,6 +1058,7 @@ or this level should be level :B~ rather than #{dob.lv}} node,ocn_sp=node4,"h#{ocnh}" elsif ln==5 \ or ln=~@md.lv5 + @lev_occurences[:l2] += 1 if not dob.obj =~/~#|-#/ ocn_flag=true ocnh5+=1 @@ -1049,6 +1087,7 @@ or this level should be level :B~ rather than #{dob.lv}} @collapsed_lv5=@collapsed_lv1+1 node1 else + warning_incorrect_parent_level_or_level(dob.obj) document_structure_check_info(node5,node0,:error) node0 end @@ -1056,6 +1095,7 @@ or this level should be level :B~ rather than #{dob.lv}} node,ocn_sp=node5,"h#{ocnh}" elsif ln==6 \ or ln=~@md.lv6 + @lev_occurences[:l3] += 1 if not dob.obj =~/~#|-#/ ocn_flag=true ocnh6+=1 @@ -1092,6 +1132,7 @@ or this level should be 5~ rather #{dob.lv}" #level 6 @collapsed_lv6=@collapsed_lv1+1 node1 else + warning_incorrect_parent_level_or_level(dob.obj) document_structure_check_info(node6,node0,:error) node0 end @@ -1099,6 +1140,29 @@ or this level should be 5~ rather #{dob.lv}" #level 6 node,ocn_sp=node6,"h#{ocnh}" end else + unless @lev_occurences[:l1] > 0 + STDERR.puts %{Substantive text objects must follow a level 1~ heading and there are none at this point in processing: #{@lev_occurences[:l1]} +} + end + unless @ln >= 4 + lev=case @ln + when 0 then 'A' + when 1 then 'B' + when 2 then 'C' + when 3 then 'D' + when 4 then '1' + when 5 then '2' + when 6 then '3' + when 7 then '4' + when 8 then '5' + when 9 then '6' + end + STDERR.puts %{Substantive text objects must follow a level 1~ 2~ or 3~ heading: #{lev}~ +SKIPPED processing file: [#{@md.opt.lng}] "#{@md.fns}"} + puts dob.obj.gsub(/^(.{1,80})/,'"\1"') + $process_document = :skip + break + end if not dob.obj =~/~#|-#/ ocn_flag=true else @@ -1177,6 +1241,18 @@ or this level should be 5~ rather #{dob.lv}" #level 6 end @o_array << dob end + unless @lev_occurences[:a] == 1 + STDERR.puts %{The number of level A~ in this document: #{@lev_occurences[:a]} +There must be one level A~ (no more and no less) +SKIPPED processing file: [#{@md.opt.lng}] "#{@md.fns}"} + $process_document = :skip + end + unless @lev_occurences[:l1] > 0 + STDERR.puts %{The number of level 1~ in this document: #{@lev_occurences[:l1]} +There must be at least one level 1~ (and as many as required) +SKIPPED processing file: [#{@md.opt.lng}] "#{@md.fns}"} + $process_document = :skip + end @o_array end end diff --git a/lib/sisu/v6/composite.rb b/lib/sisu/v6/composite.rb index 79603e26..2afff1bf 100644 --- a/lib/sisu/v6/composite.rb +++ b/lib/sisu/v6/composite.rb @@ -198,7 +198,8 @@ module SiSU_Assemble file[:prepared] else cX=SiSU_Screen::Ansi.new(@opt.act[:color_state][:set]).cX - STDERR.puts "\t #{cX.fuchsia}ERROR#{cX.off} #{cX.brown}#{@opt.fns}#{cX.off} #{cX.fuchsia}requires an invalid or non-existent file:#{cX.off} #{cX.brown}#{loadfile}#{cX.off}" + STDERR.puts %{SKIPPED processing file: [#{@opt.lng}] "#{@opt.fns}" it requires an invalid or non-existent file: "#{loadfile}"} + $process_document = :skip; break #remove this line to continue processing documents that have missing include files para end else tuned_file << para @@ -253,7 +254,8 @@ module SiSU_Assemble @ssm << loadfile else cX=SiSU_Screen::Ansi.new(@opt.act[:color_state][:set]).cX - STDERR.puts "\t #{cX.fuchsia}ERROR#{cX.off} #{cX.brown}#{@opt.fns}#{cX.off} #{cX.fuchsia}requires an invalid or non-existent file:#{cX.off} #{cX.brown}#{loadfile}#{cX.off}" + STDERR.puts %{SKIPPED processing file: [#{@opt.lng}] "#{@opt.fns}" it requires an invalid or non-existent file: "#{loadfile}"} + $process_document = :skip; break #remove this line to continue processing documents that have missing include files para end end diff --git a/lib/sisu/v6/hub.rb b/lib/sisu/v6/hub.rb index 35e9140d..736fa8bc 100644 --- a/lib/sisu/v6/hub.rb +++ b/lib/sisu/v6/hub.rb @@ -264,12 +264,26 @@ module SiSU @msg,@msgs='',nil @tell=lambda { SiSU_Screen::Ansi.new(@opt.cmd,@msg,"#{@msgs.inspect if @msgs}") } end + def remove_skipped_files_if_any_from_processing_files_array + if @remove_faulty_markup_files_array.length > 0 + @opt.files = (@opt.files - @remove_faulty_markup_files_array) + end + end + def print_error_message_if_files_skipped + if @remove_faulty_markup_files_array.length > 0 + puts '---' + STDERR.puts 'ERROR with file(s), did not process: ' + @remove_faulty_markup_files_array.join(',') + end + end def do_loops + @remove_faulty_markup_files_array=[] if @opt.act[:zap][:set]==:on #% --zap, -Z do_loop_files_on_given_option_pre end do_each_file_loop_options + remove_skipped_files_if_any_from_processing_files_array do_loop_files_on_given_option_post + print_error_message_if_files_skipped end def do_each_file_loop_options @opt.files.each_with_index do |fno,i| @@ -290,6 +304,7 @@ module SiSU end @env=SiSU_Env::InfoEnv.new(@opt.fns) if @opt.act[:ao][:set]==:on #% --ao --dal, -m + $process_document = :ok unless @opt.act[:po4a][:set]==:on # --po4a, -P if @opt.fno =~ /\.ssm$/ require_relative 'composite' # composite.rb #pre-processing @@ -299,112 +314,117 @@ module SiSU SiSU_AO::Source.new(@opt).read end end - if @opt.act[:qrcode][:set]==:on #% --qrcode, -Q - require_relative 'qrcode' # qrcode.rb - SiSU_QRcode::Source.new(@opt).read - end - if @opt.act[:hash_digests][:set]==:on #% --hash-digests, -N digest tree - require_relative 'digests' # digests.rb - SiSU_DigestView::Source.new(@opt).read - end - if @opt.act[:txt][:set]==:on #% --txt, -t -a - require_relative 'txt_plain' # txt_plain.rb - SiSU_Txt_Plain::Source.new(@opt).read - end - if @opt.act[:txt_textile][:set]==:on #% --textile - require_relative 'txt_textile' # txt_textile.rb - SiSU_Txt_Textile::Source.new(@opt).read - end - if @opt.act[:txt_asciidoc][:set]==:on #% --asciidoc - require_relative 'txt_asciidoc' # txt_asciidoc.rb - SiSU_Txt_AsciiDoc::Source.new(@opt).read - end - if @opt.act[:txt_markdown][:set]==:on #% --markdown - require_relative 'txt_markdown' # txt_markdown.rb - SiSU_Txt_Markdown::Source.new(@opt).read - end - if @opt.act[:txt_rst][:set]==:on #% --rst, --rest - require_relative 'txt_rst' # txt_rst.rb - SiSU_Txt_rST::Source.new(@opt).read - end - if @opt.act[:html][:set]==:on #% --html, -h -H - require_relative 'html' # html.rb - SiSU_HTML::Source.new(@opt).read - else - if @opt.act[:html_seg][:set]==:on #% --html-seg (-h -H) - require_relative 'html' # html.rb - SiSU_HTML::Source.new(@opt).read + if $process_document == :ok + if @opt.act[:qrcode][:set]==:on #% --qrcode, -Q + require_relative 'qrcode' # qrcode.rb + SiSU_QRcode::Source.new(@opt).read + end + if @opt.act[:hash_digests][:set]==:on #% --hash-digests, -N digest tree + require_relative 'digests' # digests.rb + SiSU_DigestView::Source.new(@opt).read end - if @opt.act[:html_scroll][:set]==:on #% --html-scroll (-h -H) - require_relative 'html' # html.rb + if @opt.act[:txt][:set]==:on #% --txt, -t -a + require_relative 'txt_plain' # txt_plain.rb + SiSU_Txt_Plain::Source.new(@opt).read + end + if @opt.act[:txt_textile][:set]==:on #% --textile + require_relative 'txt_textile' # txt_textile.rb + SiSU_Txt_Textile::Source.new(@opt).read + end + if @opt.act[:txt_asciidoc][:set]==:on #% --asciidoc + require_relative 'txt_asciidoc' # txt_asciidoc.rb + SiSU_Txt_AsciiDoc::Source.new(@opt).read + end + if @opt.act[:txt_markdown][:set]==:on #% --markdown + require_relative 'txt_markdown' # txt_markdown.rb + SiSU_Txt_Markdown::Source.new(@opt).read + end + if @opt.act[:txt_rst][:set]==:on #% --rst, --rest + require_relative 'txt_rst' # txt_rst.rb + SiSU_Txt_rST::Source.new(@opt).read + end + if @opt.act[:html][:set]==:on #% --html, -h -H + require_relative 'html' # html.rb SiSU_HTML::Source.new(@opt).read + else + if @opt.act[:html_seg][:set]==:on #% --html-seg (-h -H) + require_relative 'html' # html.rb + SiSU_HTML::Source.new(@opt).read + end + if @opt.act[:html_scroll][:set]==:on #% --html-scroll (-h -H) + require_relative 'html' # html.rb + SiSU_HTML::Source.new(@opt).read + end end - end - if @opt.act[:concordance][:set]==:on #% --concordance, -w - require_relative 'concordance' # concordance.rb - SiSU_Concordance::Source.new(@opt).read - end - if @opt.act[:epub][:set]==:on #% --epub, -e - require_relative 'xhtml_epub2' # xhtml_epub2.rb - SiSU_XHTML_EPUB2::Source.new(@opt).read - end - if @opt.act[:odt][:set]==:on #% --odt, -o opendocument - require_relative 'xml_odf_odt' # xml_odf_odt.rb - SiSU_XML_ODF_ODT::Source.new(@opt).read - end - if @opt.act[:xhtml][:set]==:on #% --xhtml, -b xhtml - require_relative 'xhtml' # xhtml.rb - SiSU_XHTML::Source.new(@opt).read - end - if @opt.act[:xml_scaffold_structure_sisu][:set]==:on #% --xml-scaffold --xml-scaffold-sisu - require_relative 'xml_scaffold_structure_sisu' # xml_scaffold_structure_sisu.rb - SiSU_XML_Scaffold_Structure_Sisu::Source.new(@opt).read - end - if @opt.act[:xml_scaffold_structure_collapse][:set]==:on #% --xml-scaffold-collapse - require_relative 'xml_scaffold_structure_collapsed' # xml_scaffold_structure_collapsed.rb - SiSU_XML_Scaffold_Structure_Collapse::Source.new(@opt).read - end - if @opt.act[:xml_docbook_book][:set]==:on #% --xml-docbook - require_relative 'xml_docbook5' # xml_docbook5.rb - SiSU_XML_Docbook_Book::Source.new(@opt).read - end - if @opt.act[:xml_fictionbook][:set]==:on #% --xml-fictionbook - require_relative 'xml_fictionbook2' # xml_fictionbook2.rb - SiSU_XML_Fictionbook::Source.new(@opt).read - end - if @opt.act[:xml_sax][:set]==:on #% --xml-sax, -x xml sax type - require_relative 'xml_sax' # xml_sax.rb - SiSU_XML_SAX::Source.new(@opt).read - end - if @opt.act[:xml_dom][:set]==:on #% --xml-dom, -X xml dom type - require_relative 'xml_dom' # xml_dom.rb - SiSU_XML_DOM::Source.new(@opt).read - end - if @opt.act[:pdf][:set]==:on \ - or @opt.act[:pdf_p][:set]==:on \ - or @opt.act[:pdf_l][:set]==:on #% --pdf-l --pdf, -p latex/ texpdf - require_relative 'texpdf' # texpdf.rb - SiSU_TeX::Source.new(@opt).read - end - if @opt.act[:manpage][:set]==:on #% --manpage, -i - require_relative 'manpage' # manpage.rb - SiSU_Manpage::Source.new(@opt).read - end - if @opt.act[:texinfo][:set]==:on #% --texinfo, -I - require_relative 'texinfo' # texinfo.rb - SiSU_TexInfo::Source.new(@opt).read - end - if @opt.act[:sqlite_discrete][:set]==:on #% --sqlite, -d DB sqlite - require_relative 'dbi_discrete' # dbi_discrete.rb - SiSU_DBI_Discrete::SQL.new(@opt).build - end - if @opt.act[:manifest][:set]==:on #% --manifest, -y - require_relative 'manifest' # manifest.rb - ((@opt.act[:sisupod][:set]==:on \ - || @opt.act[:share_source][:set]==:on) \ - && @opt.files.length < 2 ) \ - ? nil - : SiSU_Manifest::Source.new(@opt).read + if @opt.act[:concordance][:set]==:on #% --concordance, -w + require_relative 'concordance' # concordance.rb + SiSU_Concordance::Source.new(@opt).read + end + if @opt.act[:epub][:set]==:on #% --epub, -e + require_relative 'xhtml_epub2' # xhtml_epub2.rb + SiSU_XHTML_EPUB2::Source.new(@opt).read + end + if @opt.act[:odt][:set]==:on #% --odt, -o opendocument + require_relative 'xml_odf_odt' # xml_odf_odt.rb + SiSU_XML_ODF_ODT::Source.new(@opt).read + end + if @opt.act[:xhtml][:set]==:on #% --xhtml, -b xhtml + require_relative 'xhtml' # xhtml.rb + SiSU_XHTML::Source.new(@opt).read + end + if @opt.act[:xml_scaffold_structure_sisu][:set]==:on #% --xml-scaffold --xml-scaffold-sisu + require_relative 'xml_scaffold_structure_sisu' # xml_scaffold_structure_sisu.rb + SiSU_XML_Scaffold_Structure_Sisu::Source.new(@opt).read + end + if @opt.act[:xml_scaffold_structure_collapse][:set]==:on #% --xml-scaffold-collapse + require_relative 'xml_scaffold_structure_collapsed' # xml_scaffold_structure_collapsed.rb + SiSU_XML_Scaffold_Structure_Collapse::Source.new(@opt).read + end + if @opt.act[:xml_docbook_book][:set]==:on #% --xml-docbook + require_relative 'xml_docbook5' # xml_docbook5.rb + SiSU_XML_Docbook_Book::Source.new(@opt).read + end + if @opt.act[:xml_fictionbook][:set]==:on #% --xml-fictionbook + require_relative 'xml_fictionbook2' # xml_fictionbook2.rb + SiSU_XML_Fictionbook::Source.new(@opt).read + end + if @opt.act[:xml_sax][:set]==:on #% --xml-sax, -x xml sax type + require_relative 'xml_sax' # xml_sax.rb + SiSU_XML_SAX::Source.new(@opt).read + end + if @opt.act[:xml_dom][:set]==:on #% --xml-dom, -X xml dom type + require_relative 'xml_dom' # xml_dom.rb + SiSU_XML_DOM::Source.new(@opt).read + end + if @opt.act[:pdf][:set]==:on \ + or @opt.act[:pdf_p][:set]==:on \ + or @opt.act[:pdf_l][:set]==:on #% --pdf-l --pdf, -p latex/ texpdf + require_relative 'texpdf' # texpdf.rb + SiSU_TeX::Source.new(@opt).read + end + if @opt.act[:manpage][:set]==:on #% --manpage, -i + require_relative 'manpage' # manpage.rb + SiSU_Manpage::Source.new(@opt).read + end + if @opt.act[:texinfo][:set]==:on #% --texinfo, -I + require_relative 'texinfo' # texinfo.rb + SiSU_TexInfo::Source.new(@opt).read + end + if @opt.act[:sqlite_discrete][:set]==:on #% --sqlite, -d DB sqlite + require_relative 'dbi_discrete' # dbi_discrete.rb + SiSU_DBI_Discrete::SQL.new(@opt).build + end + if @opt.act[:manifest][:set]==:on #% --manifest, -y + require_relative 'manifest' # manifest.rb + ((@opt.act[:sisupod][:set]==:on \ + || @opt.act[:share_source][:set]==:on) \ + && @opt.files.length < 2 ) \ + ? nil + : SiSU_Manifest::Source.new(@opt).read + end + else + @remove_faulty_markup_files_array << fno + $process_document=:ok end end end diff --git a/lib/sisu/v6/param.rb b/lib/sisu/v6/param.rb index 60c9bb54..19769027 100644 --- a/lib/sisu/v6/param.rb +++ b/lib/sisu/v6/param.rb @@ -1115,7 +1115,8 @@ module SiSU_Param && @creator.author.is_a?(String)) \ ? " #{@creator.author}" : '' - title=%{"#{@title.full.gsub(/(

|

|
|
)/,'')}",} + title=@title.full.gsub(/\s*(?:

|

|
|
)\s*/,' '). + gsub(/~\{.+?\}~/,'') SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Parameters',%{#{title}#{creator}}).txt_grey if @opt.act[:verbose][:set]==:on end if not @book_idx \ @@ -1317,7 +1318,7 @@ module SiSU_Param if @en[:note] > 0 \ and @en[:sum] > 0 if @en[:sum] > 0 - else SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'*WARN* both endnote styles used',"~{ #{@en[:sum]} }~ and ^~ #{@en[:mark]}").warn unless @opt.act[:unless][:set]==:on + else SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'*WARN* both endnote styles used',"~{ #{@en[:sum]} }~ and ^~ #{@en[:mark]}").warn unless @opt.act[:quiet][:set]==:on end end if @en[:mark] != @en[:note] \ @@ -1334,7 +1335,7 @@ module SiSU_Param and @opt.inspect =~/P/ #@title=Md.new('Text Insert',@opt,@env).title else - SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'WARNING: Document Title missing','please provide @title:').warn unless @opt.act[:unless][:set]==:on + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'WARNING: Document Title missing','please provide @title:').warn unless @opt.act[:quiet][:set]==:on end end if @author !~/[\S]/ @@ -1342,7 +1343,7 @@ module SiSU_Param and @opt.inspect =~/P/ #@creator=SiSU_Param::Md.new('Text Insert',@opt,@env).creator else - SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'WARNING: Document Author missing','please provide @creator: :author:').warn unless @opt.act[:unless][:set]==:on + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'WARNING: Document Author missing','please provide @creator: :author:').warn unless @opt.act[:quiet][:set]==:on end end @struct={} -- cgit v1.2.3 From d6f28e09d7517df9e15c375f61a2e481bda534f1 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 12 May 2014 23:06:54 -0400 Subject: v6: ao_images, reduce warnings when ruby RMagic absent as program used directly * reduced dependency on ruby RMagic library (as some time way back had issues) --- lib/sisu/v6/ao_images.rb | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v6/ao_images.rb b/lib/sisu/v6/ao_images.rb index 05bc8e63..030dbd19 100644 --- a/lib/sisu/v6/ao_images.rb +++ b/lib/sisu/v6/ao_images.rb @@ -66,7 +66,7 @@ module SiSU_AO_Images require 'RMagick' include Magick rescue LoadError - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).mark('RMagic NOT FOUND') + #SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).mark('RMagic NOT FOUND') end def initialize(md,data) @md,@data=md,data @@ -83,8 +83,7 @@ module SiSU_AO_Images @rmgk=false end else - if (@md.opt.act[:verbose][:set]==:on \ - || @md.opt.act[:verbose_plus][:set]==:on \ + if (@md.opt.act[:verbose_plus][:set]==:on \ || @md.opt.act[:maintenance][:set]==:on) SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],'*WARN* use of RMagick is not enabled in sisurc.yml').warn end @@ -111,8 +110,7 @@ module SiSU_AO_Images img=Magick::ImageList.new("#{image_path}/#{image}") img_col,img_row=img.columns,img.rows else - if (@md.opt.act[:verbose][:set]==:on \ - || @md.opt.act[:verbose_plus][:set]==:on \ + if (@md.opt.act[:verbose_plus][:set]==:on \ || @md.opt.act[:maintenance][:set]==:on) SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],'*WARN* RMagick not present, will attempt to use imagemagick (identify) directly').warn end -- cgit v1.2.3 From cd4b4e42386f781c14e5c8c945d11e7c08cf98c5 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 12 May 2014 23:13:42 -0400 Subject: v6: ao, heading with no ocn, distinguish ~# from -# * ~# is general & means no ocn (for any object to which it is applied) * -# is relevant only for 1~ dummy headings & instructs that they should be removed from output where possible * applied so far to pdf, odt & plaintext --- lib/sisu/v6/ao_doc_objects.rb | 16 ++++++--- lib/sisu/v6/ao_doc_str.rb | 80 ++++++++++++++++++++----------------------- lib/sisu/v6/ao_numbering.rb | 2 +- lib/sisu/v6/texpdf_format.rb | 22 ++++++++---- lib/sisu/v6/txt_plain.rb | 5 ++- lib/sisu/v6/xml_odf_odt.rb | 7 ++-- 6 files changed, 74 insertions(+), 58 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v6/ao_doc_objects.rb b/lib/sisu/v6/ao_doc_objects.rb index 8dbdedc3..9555ab5e 100644 --- a/lib/sisu/v6/ao_doc_objects.rb +++ b/lib/sisu/v6/ao_doc_objects.rb @@ -100,10 +100,10 @@ module SiSU_AO_DocumentStructure end end class ObjectHeading - attr_accessor :obj,:is,:tags,:of,:lv,:ln,:lc,:toc_,:name,:idx,:ocn,:odv,:osp,:node,:parent,:ocn_,:note_,:autonum_,:digest,:tmp + attr_accessor :obj,:is,:tags,:of,:lv,:ln,:lc,:use_,:name,:idx,:ocn,:odv,:osp,:node,:parent,:ocn_,:note_,:autonum_,:digest,:tmp def initialize @of=:para - @is=@obj=@lv=@ln=@lc=@toc_=@name=@idx=@size=@ocn=@odv=@osp=@node=@parent=@ocn_=@note_=@autonum_=@digest=@tmp=nil + @is=@obj=@lv=@ln=@lc=@use_=@name=@idx=@size=@ocn=@odv=@osp=@node=@parent=@ocn_=@note_=@autonum_=@digest=@tmp=nil @tags=[] end def heading_ln(lv) @@ -156,7 +156,15 @@ module SiSU_AO_DocumentStructure lv= h[:lv] || ((defined? o.lv) ? o.lv : nil) #Alpha-numeric, document structure as used in markup, A-D then 1-6 ln= h[:ln] || ((defined? o.ln) ? o.ln : nil) #Integer, document structure level, for convenience in processing 1-9 lc= h[:lc] || ((defined? o.lc) ? o.lc : nil) #Integer, document structure collapsed level, convenience (collapse sisu's dual level document structure for markup with simple linear structure) - toc_= h[:toc_] || ((defined? o.toc_) ? o.toc_ : false) #Bool, do not include in toc, (relevant to headings) + use_=if lv \ + and lv == '1' + h[:use_] || ((defined? o.use_) ? o.use_ : :ok) + elsif not lv.empty? \ + and lv =~ /[A-D2-3]/ + :ok + else + h[:use_] || ((defined? o.use_) ? o.use_ : :ok) + end 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 @@ -166,7 +174,7 @@ module SiSU_AO_DocumentStructure note_= h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, sha512, sha256 or md5 tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use - @of,@is,@lv,@ln,@lc,@name,@tags,@obj,@idx,@ocn,@odv,@osp,@node,@parent,@toc_,@ocn_,@note_,@autonum_,@digest,@tmp=of,is,lv,ln,lc,name,tags,obj,idx,ocn,odv,osp,node,parent,toc_,ocn_,note_,autonum_,digest,tmp + @of,@is,@lv,@ln,@lc,@name,@tags,@obj,@idx,@ocn,@odv,@osp,@node,@parent,@use_,@ocn_,@note_,@autonum_,@digest,@tmp=of,is,lv,ln,lc,name,tags,obj,idx,ocn,odv,osp,node,parent,use_,ocn_,note_,autonum_,digest,tmp self end def heading_insert(h,o=nil) diff --git a/lib/sisu/v6/ao_doc_str.rb b/lib/sisu/v6/ao_doc_str.rb index 3eb4a804..d060d89c 100644 --- a/lib/sisu/v6/ao_doc_str.rb +++ b/lib/sisu/v6/ao_doc_str.rb @@ -234,10 +234,10 @@ module SiSU_AO_DocumentStructureExtract @@flag[:ocn]=:on {flag: :ocn_on} when /[~]/ - @@flag[:ocn]=:off_headings_substantive - {flag: :ocn_off, mod: :headings_substantive} - when /[-]/ - @@flag[:ocn]=:off_headings_exclude + @@flag[:ocn]=:ocn_off_headings_keep + {flag: :ocn_off, mod: :headings_keep} + when /[-]/ #of particular relevance with level 1~ which is required to precede substantive text & used e.g. in html segmented text + @@flag[:ocn]=:ocn_off_headings_dummy_lev1 {flag: :ocn_off, mod: :headings_exclude} else @@flag[:ocn]=:on @@ -286,12 +286,14 @@ module SiSU_AO_DocumentStructureExtract obj=$1 note=endnote_test?(obj) obj,tags=extract_tags(obj) - if @@flag[:ocn]==:off_headings_exclude \ - or @@flag[:ocn]==:off_headings_substantive + if @@flag[:ocn]==:ocn_off_headings_dummy_lev1 \ + or @@flag[:ocn]==:ocn_off_headings_keep unless obj =~ /[~-][#]\s*$/ - if @@flag[:ocn]==:off_headings_exclude + if @@flag[:ocn]==:ocn_off_headings_dummy_lev1 \ + and t_o =~/^1\~\S*\s+/m obj << ' -#' - elsif @@flag[:ocn]==:off_headings_substantive + elsif @@flag[:ocn]==:ocn_off_headings_dummy_lev1 \ + or @@flag[:ocn]==:ocn_off_headings_keep obj << ' ~#' end end @@ -302,12 +304,14 @@ module SiSU_AO_DocumentStructureExtract name,obj=$1,$2 note=endnote_test?(obj) obj,tags=extract_tags(obj) - if @@flag[:ocn]==:off_headings_exclude \ - or @@flag[:ocn]==:off_headings_substantive + if @@flag[:ocn]==:ocn_off_headings_dummy_lev1 \ + or @@flag[:ocn]==:ocn_off_headings_keep unless obj =~ /[~-][#]\s*$/ - if @@flag[:ocn]==:off_headings_exclude + if @@flag[:ocn]==:ocn_off_headings_dummy_lev1 \ + and t_o =~/^1\~\S*\s+/m obj << ' -#' - elsif @@flag[:ocn]==:off_headings_substantive + elsif @@flag[:ocn]==:ocn_off_headings_dummy_lev1 \ + or @@flag[:ocn]==:ocn_off_headings_keep obj << ' ~#' end end @@ -318,12 +322,14 @@ module SiSU_AO_DocumentStructureExtract name,obj=$1,$2 note=endnote_test?(obj) obj,tags=extract_tags(obj,name) - if @@flag[:ocn]==:off_headings_exclude \ - or @@flag[:ocn]==:off_headings_substantive + if @@flag[:ocn]==:ocn_off_headings_dummy_lev1 \ + or @@flag[:ocn]==:ocn_off_headings_keep unless obj =~ /[~-][#]\s*$/ - if @@flag[:ocn]==:off_headings_exclude + if @@flag[:ocn]==:ocn_off_headings_dummy_lev1 \ + and t_o =~/^1\~\S*\s+/m obj << ' -#' - elsif @@flag[:ocn]==:off_headings_substantive + elsif @@flag[:ocn]==:ocn_off_headings_dummy_lev1 \ + or @@flag[:ocn]==:ocn_off_headings_keep obj << ' ~#' end end @@ -345,8 +351,8 @@ module SiSU_AO_DocumentStructureExtract note=endnote_test?(obj) obj,tags=extract_tags(obj) unless obj=~/\A\s*\Z/m - if @@flag[:ocn]==:off_headings_exclude \ - or @@flag[:ocn]==:off_headings_substantive + if @@flag[:ocn]==:ocn_off_headings_dummy_lev1 \ + or @@flag[:ocn]==:ocn_off_headings_keep unless obj =~ /[~-][#]\s*$/ obj << ' ~#' end @@ -368,8 +374,8 @@ module SiSU_AO_DocumentStructureExtract note=endnote_test?(obj) obj,tags=extract_tags(obj) unless obj=~/\A\s*\Z/m - if @@flag[:ocn]==:off_headings_exclude \ - or @@flag[:ocn]==:off_headings_substantive + if @@flag[:ocn]==:ocn_off_headings_dummy_lev1 \ + or @@flag[:ocn]==:ocn_off_headings_keep unless obj =~ /[~-][#]\s*$/ obj << ' ~#' end @@ -391,8 +397,8 @@ module SiSU_AO_DocumentStructureExtract image=image_test(t_o) note=endnote_test?(t_o) obj,tags=extract_tags(t_o) - if @@flag[:ocn]==:off_headings_exclude \ - or @@flag[:ocn]==:off_headings_substantive + if @@flag[:ocn]==:ocn_off_headings_dummy_lev1 \ + or @@flag[:ocn]==:ocn_off_headings_keep unless obj =~ /[~-][#]\s*$/ obj << ' ~#' end @@ -1193,9 +1199,15 @@ SKIPPED processing file: [#{@md.opt.lng}] "#{@md.fns}"} dob.ln,dob.node,dob.ocn,dob.ocn_,dob.odv,dob.osp,dob.parent,dob.lc=ln,node,ocn,ocn_flag,ocn_dv,ocn_sp,parent,collapsed_level else ocnu+=1 - dob.obj=dob.obj.gsub(/#{Mx[:fa_o]}[~-]##{Mx[:fa_c]}/,'') if dob.obj - ocn_dv,ocn_sp="u#{ocnu}","u#{ocnu}" - dob.ln,dob.node,dob.ocn,dob.ocn_,dob.odv,dob.osp,dob.parent,dob.lc=ln,node,nil,ocn_flag,ocn_dv,ocn_sp,parent,collapsed_level + heading_use=:ok + if dob.obj=~/#{Mx[:pa_non_object_no_heading]}/ + dob.obj=dob.obj.gsub(/#{Mx[:pa_non_object_no_heading]}/,'') + heading_use=:ok + elsif dob.obj=~/#{Mx[:pa_non_object_dummy_heading]}/ + dob.obj=dob.obj.gsub(/#{Mx[:pa_non_object_dummy_heading]}/,'') + heading_use=:dummy + end + dob.ln,dob.node,dob.ocn,dob.ocn_,dob.use_,dob.odv,dob.osp,dob.parent,dob.lc=ln,node,nil,ocn_flag,heading_use,ocn_dv,ocn_sp,parent,collapsed_level end else if dob.of !=:meta \ @@ -1212,24 +1224,6 @@ SKIPPED processing file: [#{@md.opt.lng}] "#{@md.fns}"} end end h - elsif dob.obj=~/#{Mx[:pa_non_object_no_heading]}/ - dob.obj=dob.obj.gsub(/#{Mx[:pa_non_object_no_heading]}/,'') - if dob.is==:para - h={ obj: dob.obj, ocn_: false, ocn: nil, hang: dob.hang, indent: dob.indent, bullet_: dob.bullet_, tags: dob.tags, parent: dob.parent } - dob=SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h,dob) - elsif dob.is==:heading - h={ obj: dob.obj, ocn_: false, ocn: nil, toc_: true, parent: dob.parent } - dob=SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,dob) - end - elsif dob.obj=~/#{Mx[:pa_non_object_dummy_heading]}/ - dob.obj=dob.obj.gsub(/#{Mx[:pa_non_object_dummy_heading]}/,'') - if dob.is==:para - h={ obj: dob.obj, ocn_: false, ocn: nil, hang: dob.hang, indent: dob.indent, bullet_: dob.bullet_, tags: dob.tags, parent: dob.parent } - dob=SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h,dob) - elsif dob.is==:heading - h={ obj: dob.obj, ocn_: false, ocn: nil, toc_: false, parent: dob.parent } - dob=SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,dob) - end else dob end if dob.is==:code \ diff --git a/lib/sisu/v6/ao_numbering.rb b/lib/sisu/v6/ao_numbering.rb index acb2351a..e04befb0 100644 --- a/lib/sisu/v6/ao_numbering.rb +++ b/lib/sisu/v6/ao_numbering.rb @@ -167,7 +167,7 @@ module SiSU_AO_Numbering @subnumber=0 if dob.ln==no1 end if dob.ln.to_s =~/^[0-6]/ \ - and not dob.toc_ \ + and not dob.use_ ==:dummy \ and dob.obj !~/#{Mx[:fa_o]}(?:~#|-#)#{Mx[:fa_c]}/ # <-- fix if dob.ln==no1 t_no1+=1; t_no2=0; t_no3=0 diff --git a/lib/sisu/v6/texpdf_format.rb b/lib/sisu/v6/texpdf_format.rb index e680bc00..ce027718 100644 --- a/lib/sisu/v6/texpdf_format.rb +++ b/lib/sisu/v6/texpdf_format.rb @@ -258,20 +258,24 @@ module SiSU_TeX_Pdf \\markboth{#{@md.title.full}}\n") dob end - def heading_sublevels(dob,sublev) - if sublev==:lev1 + def heading_dev_null(dob) + dob.tmp,dob.obj='','' + dob + end + def heading_sublevels(dob) + if dob.lv=='1' sect='section' tocadd=%{\\addcontentsline{toc}{section}} pre='' post='' headadd=%{\n\\markright{#{@md.title.full}}} - elsif sublev==:lev2 + elsif dob.lv=='2' sect='subsection' tocadd=%{\\addcontentsline{toc}{subsection}} pre='' post=" \\\\\n" headadd='' - elsif sublev==:lev3 + elsif dob.lv=='3' sect='subsubsection' tocadd=%{\\addcontentsline{toc}{subsubsection}} pre='' #pre='~~~~' @@ -307,13 +311,17 @@ module SiSU_TeX_Pdf section_heading_level(@dob) end def heading_level_1 - heading_sublevels(@dob,:lev1) + if not @dob.use_ == :dummy + heading_sublevels(@dob) + else + heading_dev_null(@dob) + end end def heading_level_2 - heading_sublevels(@dob,:lev2) + heading_sublevels(@dob) end def heading_level_3 - heading_sublevels(@dob,:lev3) + heading_sublevels(@dob) end def hang case @dob.indent diff --git a/lib/sisu/v6/txt_plain.rb b/lib/sisu/v6/txt_plain.rb index 1aa08f0e..a56f5ac9 100644 --- a/lib/sisu/v6/txt_plain.rb +++ b/lib/sisu/v6/txt_plain.rb @@ -384,7 +384,10 @@ WOK when 1 then wrapped.upcase << break_line << decorate.heading_underscore.l1*times + p_num << break_line*2 when 2 then wrapped.upcase << break_line << decorate.heading_underscore.l2*times + p_num << break_line*2 when 3 then wrapped.upcase << break_line << decorate.heading_underscore.l3*times + p_num << break_line*2 - when 4 then wrapped.upcase << break_line << decorate.heading_underscore.l4*times + p_num << break_line*2 + when 4 + unless dob.use_ == :dummy + wrapped.upcase << break_line << decorate.heading_underscore.l4*times + p_num << break_line*2 + end when 5 then wrapped.upcase << break_line << decorate.heading_underscore.l5*times + p_num << break_line*2 when 6 then wrapped.upcase << break_line << decorate.heading_underscore.l6*times + p_num << break_line*2 end diff --git a/lib/sisu/v6/xml_odf_odt.rb b/lib/sisu/v6/xml_odf_odt.rb index 0457ad7d..0fe880c0 100644 --- a/lib/sisu/v6/xml_odf_odt.rb +++ b/lib/sisu/v6/xml_odf_odt.rb @@ -209,8 +209,11 @@ module SiSU_XML_ODF_ODT end end @@docstart=false - dob.tmp=dob.obj - dob.obj=%{#{breakpage}#{p_num[:set_ref]}#{set_bookmark_tag(dob)}#{dob.obj}#{p_num[:display]}} + if dob.use_ != :dummy + dob.tmp=dob.obj + dob.obj=%{#{breakpage}#{p_num[:set_ref]}#{set_bookmark_tag(dob)}#{dob.obj}#{p_num[:display]}} + else dob.tmp,dob.obj='','' + end dob end def toc(dob,p_num) -- cgit v1.2.3