From 108142f5a3b85ddbcd10b3b7c302b5ae2f1da818 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sun, 25 May 2014 09:55:33 -0400 Subject: v5 v6: version & changelog (& rakefile) * will merge v6 into v5, 5.4 version bump --- data/doc/sisu/CHANGELOG_v5 | 7 +++++++ data/doc/sisu/CHANGELOG_v6 | 7 +++++++ data/sisu/v5/v/version.yml | 6 +++--- data/sisu/v6/v/version.yml | 6 +++--- rbuild | 6 +++--- 5 files changed, 23 insertions(+), 9 deletions(-) diff --git a/data/doc/sisu/CHANGELOG_v5 b/data/doc/sisu/CHANGELOG_v5 index 08796bbe..fe2834c2 100644 --- a/data/doc/sisu/CHANGELOG_v5 +++ b/data/doc/sisu/CHANGELOG_v5 @@ -31,6 +31,13 @@ v2 branch is removed; it is available in sisu =< 3.3.2 %% Reverse Chronological: +%% 5.4.0.orig.tar.xz (2014-05-25:20/7) +http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/sisu_5.4.0 +http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/debian/sisu_5.4.0-1 +http://www.jus.uio.no/sisu/pkg/src/sisu_5.4.0.orig.tar.xz + sisu_5.4.0.orig.tar.xz + sisu_5.4.0-1.dsc + %% 5.3.6.orig.tar.xz (2014-05-18:19/7) http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/sisu_5.3.6 http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/debian/sisu_5.3.6-1 diff --git a/data/doc/sisu/CHANGELOG_v6 b/data/doc/sisu/CHANGELOG_v6 index b39da757..d58762a9 100644 --- a/data/doc/sisu/CHANGELOG_v6 +++ b/data/doc/sisu/CHANGELOG_v6 @@ -21,6 +21,13 @@ v2 branch is removed; it is available in sisu =< 3.3.2 %% Reverse Chronological: +%% 6.0.7.orig.tar.xz (2014-05-25:20/7) +http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/sisu_6.0.7 +http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/debian/sisu_6.0.7-1 +http://www.jus.uio.no/sisu/pkg/src/sisu_6.0.7.orig.tar.xz + sisu_6.0.7.orig.tar.xz + sisu_6.0.7-1.dsc + %% 6.0.6.orig.tar.xz (2014-05-18:19/7) http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/sisu_6.0.6 http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/debian/sisu_6.0.6-1 diff --git a/data/sisu/v5/v/version.yml b/data/sisu/v5/v/version.yml index 698bd43a..959947ba 100644 --- a/data/sisu/v5/v/version.yml +++ b/data/sisu/v5/v/version.yml @@ -1,5 +1,5 @@ --- :project: SiSU -:version: 5.3.6 -:date_stamp: 2014w19/7 -:date: "2014-05-18" +:version: 5.4.0 +:date_stamp: 2014w20/7 +:date: "2014-05-25" diff --git a/data/sisu/v6/v/version.yml b/data/sisu/v6/v/version.yml index bdb428f0..098c97b5 100644 --- a/data/sisu/v6/v/version.yml +++ b/data/sisu/v6/v/version.yml @@ -1,5 +1,5 @@ --- :project: SiSU -:version: 6.0.6 -:date_stamp: 2014w19/7 -:date: "2014-05-18" +:version: 6.0.7 +:date_stamp: 2014w20/7 +:date: "2014-05-25" diff --git a/rbuild b/rbuild index 7e17f554..9ee18775 100644 --- a/rbuild +++ b/rbuild @@ -37,10 +37,10 @@ #require 'mkmf' #create_makefile("sisu") #% manual settings, edit/update as required (note current default settings are obtained from sisu version yml file) -SiSU_version_next_stable = '5.3.6' -SiSU_version_next_unstable = '6.0.6' +SiSU_version_next_stable = '5.4.0' +SiSU_version_next_unstable = '6.0.7' #% rake file -SiSU_version_generic_next_stable = '5.3.x' +SiSU_version_generic_next_stable = '5.4.x' SiSU_version_generic_next_unstable = '6.0.x' SiSU_version_dir_stable = 'v5' SiSU_version_dir_unstable = 'v6' -- cgit v1.2.3 From 16c30474f06ed3774ad524a38b55b7840de057d0 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sun, 25 May 2014 10:01:43 -0400 Subject: v5: merge v6 to v5, version bump to 5.4.*, reason adds structure check * ao, document structure check, stop processing on major error (with error message & text at location of failure) [reason for version bump the addition of structure check] * utils, add ok code marker * 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 * 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) * ao, document markup structure check, skip processing file on major error * with error message & text at location of failure * texpdf, urls in creator cause breakage * texpdf, mailto markup links set for normal text objects * texpdf, '&' in heading breaks toc (now removed from toc (not heading)), bug * revisit, bug * texpdf, for urls switch to sans serif (small fontsize) * instead of typewriter, latex default * 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') * texpdf, pdf default font size configurable (cli & sisurc.yml) (no fractions) * --pdf-fontsize-12 --pdf-fontsize-8 * default: texpdf_fontsize: 12 * texpdf, headings and table of contents representation * fixes 1~ and 2~ result in the same formatting 1~ 2~ & 3~ now differentiated, see discussion in sisu.org under #744383 * fixes :A smaller formatted than :B A~ B~ C~ now the same size, see discussion in sisu.org under #744383 * :B and :C result in the same formatting, issue explained see sisu.org * texpdf, (internal coding) fontface, rename texpdf_font texpdf_fontface * texpdf, (internal coding) use symbols to identify page orientation * param, metadata rights, line-breaks instead of semicolons separating rights * fixes remove trailing semicolon after :copyright: * digests sha512 option implemented * options sha512 sha256 md5 * command line --sha512 * rcconf.yml ['defsault']['digest'] = sha512 * xml object citation numbering (docbook fictionbook) --- lib/sisu/v5/ao_doc_objects.rb | 38 ++-- lib/sisu/v5/ao_doc_str.rb | 168 +++++++++++----- lib/sisu/v5/ao_hash_digest.rb | 24 ++- lib/sisu/v5/ao_images.rb | 8 +- lib/sisu/v5/ao_numbering.rb | 2 +- lib/sisu/v5/ao_syntax.rb | 2 +- lib/sisu/v5/cgi_pgsql.rb | 13 +- lib/sisu/v5/composite.rb | 11 +- lib/sisu/v5/db_columns.rb | 4 +- lib/sisu/v5/dbi.rb | 7 +- lib/sisu/v5/digests.rb | 70 ++++--- lib/sisu/v5/hub.rb | 226 +++++++++++---------- lib/sisu/v5/manifest.rb | 14 +- lib/sisu/v5/options.rb | 18 ++ lib/sisu/v5/param.rb | 41 ++-- lib/sisu/v5/qrcode.rb | 17 +- lib/sisu/v5/shared_markup_alt.rb | 20 +- lib/sisu/v5/shared_metadata.rb | 11 ++ lib/sisu/v5/sysenv.rb | 186 ++++++++++++----- lib/sisu/v5/texpdf.rb | 38 ++-- lib/sisu/v5/texpdf_format.rb | 417 ++++++++++++++++++++++----------------- lib/sisu/v5/txt_plain.rb | 5 +- lib/sisu/v5/urls.rb | 2 +- lib/sisu/v5/utils.rb | 14 +- lib/sisu/v5/xml_docbook5.rb | 7 +- lib/sisu/v5/xml_fictionbook2.rb | 9 +- lib/sisu/v5/xml_odf_odt.rb | 7 +- 27 files changed, 867 insertions(+), 512 deletions(-) diff --git a/lib/sisu/v5/ao_doc_objects.rb b/lib/sisu/v5/ao_doc_objects.rb index e711a7d8..216349c1 100644 --- a/lib/sisu/v5/ao_doc_objects.rb +++ b/lib/sisu/v5/ao_doc_objects.rb @@ -94,16 +94,16 @@ 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 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 @@ -164,9 +172,9 @@ 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 + @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) @@ -201,7 +209,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 +233,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 +262,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 +282,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 +302,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 +322,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 +341,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 +373,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 +401,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/v5/ao_doc_str.rb b/lib/sisu/v5/ao_doc_str.rb index dd7f32f3..b66f01d1 100644 --- a/lib/sisu/v5/ao_doc_str.rb +++ b/lib/sisu/v5/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 @@ -847,18 +853,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 +897,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 +907,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 +937,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 +953,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 +968,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 +976,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 +991,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 +999,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 +1030,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 +1064,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 +1093,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 +1101,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 +1138,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 +1146,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 @@ -1129,9 +1199,15 @@ or this level should be 5~ rather #{dob.lv}" #level 6 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 \ @@ -1148,24 +1224,6 @@ or this level should be 5~ rather #{dob.lv}" #level 6 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 \ @@ -1177,6 +1235,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/v5/ao_hash_digest.rb b/lib/sisu/v5/ao_hash_digest.rb index 3f372893..1c20671f 100644 --- a/lib/sisu/v5/ao_hash_digest.rb +++ b/lib/sisu/v5/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/v5/ao_images.rb b/lib/sisu/v5/ao_images.rb index b72f66a3..8eee4b57 100644 --- a/lib/sisu/v5/ao_images.rb +++ b/lib/sisu/v5/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 diff --git a/lib/sisu/v5/ao_numbering.rb b/lib/sisu/v5/ao_numbering.rb index 984675cc..7affbe93 100644 --- a/lib/sisu/v5/ao_numbering.rb +++ b/lib/sisu/v5/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/v5/ao_syntax.rb b/lib/sisu/v5/ao_syntax.rb index 8ff90ae0..a75e2690 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/v5/cgi_pgsql.rb b/lib/sisu/v5/cgi_pgsql.rb index 6c4385e4..1ab04316 100644 --- a/lib/sisu/v5/cgi_pgsql.rb +++ b/lib/sisu/v5/cgi_pgsql.rb @@ -82,16 +82,15 @@ module SiSU_CGI_PgSQL opt.lingual.to_s else 'multi' end - if defined? @rc['search'] \ + @name_of[:db]=if defined? @rc['search'] \ and defined? @rc['search']['sisu'] \ and defined? @rc['search']['sisu']['action'] \ and @rc['search']['sisu']['action'] =~/https?:\/\/\S+?\.cgi/ \ and defined? @rc['search']['sisu']['db'] \ and @rc['search']['sisu']['db'] =~/\S+/ - @name_of[:db]=@rc['search']['sisu']['db'] + @rc['search']['sisu']['db'] else - @name_of[:db]=@env.path.stub_pwd #'sisu' #breaks if not present - false + @env.path.stub_pwd #'sisu' #breaks if not present end @name_of[:host_url_cgi]=%q{http://#{ENV['HTTP_HOST']}#{ENV['PATH_INFO']}} @name_of[:host_url_docs]=%q{http://#{ENV['HTTP_HOST']}} @@ -128,10 +127,6 @@ module SiSU_CGI_PgSQL default database name: #{@cX.green}#{Db[:name_prefix]}#{@name_of[:db]}#{@cX.off} (#{@name_of[:db]}) db user: #{@cX.green}#{@name_of[:user]}#{@cX.off} to modify use: #{@cX.brown}sisu --db-pg --db-user='#{@name_of[:user]}'#{@cX.off} - to create static cgi & db host use: #{@cX.brown}sisu --db-pg --webserv-search='#{@name_of[:host_url_cgi]}'#{@cX.off} - for static location for sisu output use: #{@cX.brown}sisu --db-pg --webserv-output='#{@name_of[:host_url_docs]}'#{@cX.off} - for static cgi search form link name use: #{@cX.brown}sisu --db-pg --cgi-search-form-name='#{@name_of[:cgi_script]}'#{@cX.off} - #{@cX.fuchsia}(settings priority: command line; sisurc.yml; else defaults)#{@cX.off} #{@cX.fuchsia}BASED ON ALREADY EXISTING databases#{@cX.off} (default database name: #{@db.psql.db}) NOTE it is first necessary to createdb, @@ -153,7 +148,7 @@ module SiSU_CGI_PgSQL sisu --pg --dropall # removes existing postgresql db & tables sisu --pg --createall -v # creates postgresql db & tables sisu --pg --update -v *.sst *.ssm # populate the db - sisu --sample-search-form --pg # creates the postgresql search form + sisu --sample-search-form --db-pg # creates the postgresql search form # this should be done after creating the db # to be searched sisu --webrick & # starts ruby webrick web server diff --git a/lib/sisu/v5/composite.rb b/lib/sisu/v5/composite.rb index adc88e52..9f722799 100644 --- a/lib/sisu/v5/composite.rb +++ b/lib/sisu/v5/composite.rb @@ -166,10 +166,7 @@ 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 \ @@ -201,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 @@ -256,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/v5/db_columns.rb b/lib/sisu/v5/db_columns.rb index 0b06e212..42c23cfc 100644 --- a/lib/sisu/v5/db_columns.rb +++ b/lib/sisu/v5/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/v5/dbi.rb b/lib/sisu/v5/dbi.rb index 737f02fd..0e438c3e 100644 --- a/lib/sisu/v5/dbi.rb +++ b/lib/sisu/v5/dbi.rb @@ -71,7 +71,6 @@ module SiSU_DBI include SiSU_FormatShared class SQL def initialize(opt) - SiSU_Env::Load.new('dbi',true).prog @opt=opt @db=SiSU_Env::InfoDb.new if @opt.cmd =~/[Dd]/ \ @@ -96,6 +95,9 @@ module SiSU_DBI maintenance_check(@opt,__FILE__,__LINE__) if @opt.act[:maintenance][:set]==:on :sqlite end + if @sql_type==:pg then SiSU_Env::Load.new('pg',true).prog + elsif @sql_type==:sqlite then SiSU_Env::Load.new('sqlite3',true).prog + end end end def maintenance_check(opt,file,line) @@ -105,7 +107,8 @@ module SiSU_DBI end def read_psql begin - @conn=@db.psql.conn_dbi + require 'pg' + @conn=@db.psql.conn_pg rescue if @opt.mod.inspect=~/--(?:createall|create)/ cX=SiSU_Screen::Ansi.new(@opt.act[:color_state][:set]).cX diff --git a/lib/sisu/v5/digests.rb b/lib/sisu/v5/digests.rb index b3dd40bd..6cea7c3e 100644 --- a/lib/sisu/v5/digests.rb +++ b/lib/sisu/v5/digests.rb @@ -108,9 +108,14 @@ module SiSU_DigestView private class Scroll 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/v5/manifest.rb b/lib/sisu/v5/manifest.rb index f6e76ec0..e1b6ce80 100644 --- a/lib/sisu/v5/manifest.rb +++ b/lib/sisu/v5/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/v5/options.rb b/lib/sisu/v5/options.rb index 85e71f40..091f7665 100644 --- a/lib/sisu/v5/options.rb +++ b/lib/sisu/v5/options.rb @@ -968,6 +968,24 @@ 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[: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"/ + :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/v5/param.rb b/lib/sisu/v5/param.rb index adc9350f..9dcdfc26 100644 --- a/lib/sisu/v5/param.rb +++ b/lib/sisu/v5/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 @@ -1118,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 \ @@ -1281,14 +1279,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/v5/qrcode.rb b/lib/sisu/v5/qrcode.rb index a5888365..66584198 100644 --- a/lib/sisu/v5/qrcode.rb +++ b/lib/sisu/v5/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/v5/shared_markup_alt.rb b/lib/sisu/v5/shared_markup_alt.rb index 5a37c934..1fb078c6 100644 --- a/lib/sisu/v5/shared_markup_alt.rb +++ b/lib/sisu/v5/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/v5/shared_metadata.rb b/lib/sisu/v5/shared_metadata.rb index da396040..4ada2db1 100644 --- a/lib/sisu/v5/shared_metadata.rb +++ b/lib/sisu/v5/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}

} diff --git a/lib/sisu/v5/sysenv.rb b/lib/sisu/v5/sysenv.rb index 4b94003c..cfd40460 100644 --- a/lib/sisu/v5/sysenv.rb +++ b/lib/sisu/v5/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 !!! @@ -249,7 +249,9 @@ module SiSU_Env $:.each do |reqpath| if FileTest.exist?("#{reqpath}/#{@prog}.rb") load_prog=true + #SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).ok("#{reqpath}/#{@prog}.rb loaded") break + #else SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).warn("#{reqpath}/#{@prog}.rb not found") end end if load_prog \ @@ -806,6 +808,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" @@ -1861,59 +1876,123 @@ 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 + 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" # 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 + 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 @@ -2519,6 +2598,7 @@ WOK end end http=http.strip + #%q{http://#{ENV['HTTP_HOST']}} end def webrick #must have a port #REMOVE if defined? @rc['webserv_cgi']['host'] \ @@ -2581,6 +2661,7 @@ WOK else webserv_base_cgi(opt) end end + #%q{http://#{ENV['HTTP_HOST']}/cgi-bin} end def cgi_sample_search_form_name(opt=nil) if opt.mod.inspect =~/--(?:cgi-)?search-form-name[=-]["']?(\S+?\.cgi)/ @@ -2713,27 +2794,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 @@ -4335,6 +4430,9 @@ WOK : '' end def dbi + PG::Connection.open(:dbname => psql.db) + end + def dbi_ (psql.host =~/(?:\S{1,3}\.){3}\S{1,3}|\S+?\.\S+/) \ ? "DBI:Pg:database=#{psql.db};host=#{psql.host};port=#{psql.port}" : "DBI:Pg:database=#{psql.db};port=#{psql.port}" @@ -4342,19 +4440,11 @@ WOK def conn_dbi DBI.connect(psql.dbi,psql.user,psql.db) end - self - end - def mysql - def db - #"#{Db[:name_prefix]}#{@pwd_stub}" - end - def port - '**' + def conn_pg + require 'pg' + PG::Connection.new(dbname: psql.db, port: psql.port) end - def dbi - "dbi:Mysql:database=#{mysql.db};port=#{mysql.port}" - end - self + self end def sqlite def db diff --git a/lib/sisu/v5/texpdf.rb b/lib/sisu/v5/texpdf.rb index b67bb545..7f6bbaa6 100644 --- a/lib/sisu/v5/texpdf.rb +++ b/lib/sisu/v5/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: '' } @@ -746,12 +752,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 +849,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/v5/texpdf_format.rb b/lib/sisu/v5/texpdf_format.rb index d97f3618..4693059d 100644 --- a/lib/sisu/v5/texpdf_format.rb +++ b/lib/sisu/v5/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}") @@ -219,95 +219,110 @@ 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) + cont_ln=cont_ln.gsub(/\{[\\]+(&)\}/,'\\1') + 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) + cont_ln=cont_ln.gsub(/\{[\\]+(&)\}/,'\\1') + 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*/,' ') - end - dob.tmp=dob.tmp.gsub(/^(.*)?\n?$/m, - "\\subsubsection*{\\1} -\\addcontentsline{toc}{subsubsection}{#{cont_ln} \\\\ -}") + def heading_dev_null(dob) + dob.tmp,dob.obj='','' 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 + def heading_sublevels(dob) + if dob.lv=='1' + sect='section' + tocadd=%{\\addcontentsline{toc}{section}} + pre='' + post='' + headadd=%{\n\\markright{#{@md.title.full}}} + elsif dob.lv=='2' + sect='subsection' + tocadd=%{\\addcontentsline{toc}{subsection}} + pre='' + post=" \\\\\n" + headadd='' + elsif dob.lv=='3' + sect='subsubsection' + tocadd=%{\\addcontentsline{toc}{subsubsection}} + pre='' #pre='~~~~' + post=" \\\\\n" + headadd='' + end 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) + cont_ln=cont_ln.gsub(/\{[\\]+(&)\}/,'\\1') 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 + if not @dob.use_ == :dummy + heading_sublevels(@dob) + else + heading_dev_null(@dob) + end + end + def heading_level_2 + heading_sublevels(@dob) + end + def heading_level_3 + heading_sublevels(@dob) + end def hang case @dob.indent when /0/ @@ -771,50 +786,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 +847,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/ @@ -919,60 +934,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' + when :portrait + 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' + when :landscape + 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 @@ -980,37 +1014,63 @@ 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/ + 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 + 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 - if @layout =~/portrait|landscape/ <<-WOK \\usepackage{alltt} \\usepackage{thumbpdf} \\usepackage[#{@tex2pdf}, - #{color.strip} + #{hyperlinks_color?.strip} pdftitle={#{@txt}}, - pdfauthor={#{@author}}, + pdfauthor={#{author}}, pdfsubject={#{@subject}}, pdfkeywords={#{@keywords}}, pageanchor=true, @@ -1042,30 +1102,9 @@ module SiSU_TeX_Pdf \\definecolor{myblue}{rgb}{0,0,0.5} \\definecolor{mywhite}{rgb}{1,1,1} \\usepackage{url} +\\urlstyle{sf} %\\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' @@ -1103,7 +1142,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} @@ -1188,16 +1227,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 +1249,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 +1284,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 +1303,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 @@ -1315,14 +1354,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 @@ -1412,6 +1454,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? @@ -1484,11 +1533,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 diff --git a/lib/sisu/v5/txt_plain.rb b/lib/sisu/v5/txt_plain.rb index e27e9231..211e66d9 100644 --- a/lib/sisu/v5/txt_plain.rb +++ b/lib/sisu/v5/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/v5/urls.rb b/lib/sisu/v5/urls.rb index cff69c93..9a828440 100644 --- a/lib/sisu/v5/urls.rb +++ b/lib/sisu/v5/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], diff --git a/lib/sisu/v5/utils.rb b/lib/sisu/v5/utils.rb index 4894df9d..9d9a3a51 100644 --- a/lib/sisu/v5/utils.rb +++ b/lib/sisu/v5/utils.rb @@ -133,6 +133,18 @@ module SiSU_Utils def mark(v=nil,x=nil) puts set(v,x) end + def ok(v=nil,x=nil) + if (v.is_a?(Symbol) \ + and x.is_a?(String)) + x= '*OK* ' + x + elsif v.is_a?(String) + v='*OK* ' + v + x=nil + else + v,x='*OK*',nil + end + puts set(v,x) + end def warn(v=nil,x=nil) if (v.is_a?(Symbol) \ and x.is_a?(String)) @@ -143,7 +155,7 @@ module SiSU_Utils else v,x='*WARN*',nil end - STDERR.puts set(v,x) + puts set(v,x) end def error(v=nil,x=nil) if (v.is_a?(Symbol) \ diff --git a/lib/sisu/v5/xml_docbook5.rb b/lib/sisu/v5/xml_docbook5.rb index be9ad802..45e6f0cf 100644 --- a/lib/sisu/v5/xml_docbook5.rb +++ b/lib/sisu/v5/xml_docbook5.rb @@ -110,9 +110,10 @@ module SiSU_XML_Docbook_Book class Scroll [#{o.ocn}] #{o.ln} #{o.obj}#{comment}" : "<#{o.lc}>[#{o.ocn}] #{o.ln} #{o.obj}#{comment}" end @@ -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) diff --git a/lib/sisu/v5/xml_odf_odt.rb b/lib/sisu/v5/xml_odf_odt.rb index d2ab0477..e05fc9f7 100644 --- a/lib/sisu/v5/xml_odf_odt.rb +++ b/lib/sisu/v5/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