From 0c4188237f63d2be97e62150257f750c4b7b3aec Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Tue, 1 Jul 2014 00:29:11 -0400 Subject: v5 v6: version & changelog (& rakefile) --- 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 | 4 ++-- 5 files changed, 22 insertions(+), 8 deletions(-) diff --git a/data/doc/sisu/CHANGELOG_v5 b/data/doc/sisu/CHANGELOG_v5 index e3cab630..7f876e7c 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.3.orig.tar.xz (2014-07-01:26/2) +http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/sisu_5.4.3 +http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/debian/sisu_5.4.3-1 +http://www.jus.uio.no/sisu/pkg/src/sisu_5.4.3.orig.tar.xz + sisu_5.4.3.orig.tar.xz + sisu_5.4.3-1.dsc + %% 5.4.2.orig.tar.xz (2014-06-22:24/7) http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/sisu_5.4.2 http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/debian/sisu_5.4.2-1 diff --git a/data/doc/sisu/CHANGELOG_v6 b/data/doc/sisu/CHANGELOG_v6 index 4d324faa..794edfdb 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.9.orig.tar.xz (2014-07-01:26/2) +http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/sisu_6.0.9 +http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/debian/sisu_6.0.9-1 +http://www.jus.uio.no/sisu/pkg/src/sisu_6.0.9.orig.tar.xz + sisu_6.0.9.orig.tar.xz + sisu_6.0.9-1.dsc + %% 6.0.8.orig.tar.xz (2014-06-19:24/4) http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/sisu_6.0.8 http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/debian/sisu_6.0.8-1 diff --git a/data/sisu/v5/v/version.yml b/data/sisu/v5/v/version.yml index a6fa41e7..b6d8dfa8 100644 --- a/data/sisu/v5/v/version.yml +++ b/data/sisu/v5/v/version.yml @@ -1,5 +1,5 @@ --- :project: SiSU -:version: 5.4.2 -:date_stamp: 2014w24/7 -:date: "2014-06-22" +:version: 5.4.3 +:date_stamp: 2014w26/2 +:date: "2014-07-01" diff --git a/data/sisu/v6/v/version.yml b/data/sisu/v6/v/version.yml index 563a9713..fb9cc955 100644 --- a/data/sisu/v6/v/version.yml +++ b/data/sisu/v6/v/version.yml @@ -1,5 +1,5 @@ --- :project: SiSU -:version: 6.0.8 -:date_stamp: 2014w24/4 -:date: "2014-06-19" +:version: 6.0.9 +:date_stamp: 2014w26/2 +:date: "2014-07-01" diff --git a/rbuild b/rbuild index f9098868..540bc568 100644 --- a/rbuild +++ b/rbuild @@ -37,8 +37,8 @@ #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.4.2' -SiSU_version_next_unstable = '6.0.8' +SiSU_version_next_stable = '5.4.3' +SiSU_version_next_unstable = '6.0.9' #% rake file SiSU_version_generic_next_stable = '5.4.x' SiSU_version_generic_next_unstable = '6.0.x' -- cgit v1.2.3 From cc39efe54a31e316d1e857df2a9ecac26a4deaaf Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Tue, 1 Jul 2014 00:30:43 -0400 Subject: sisu.org minor --- data/doc/sisu/sisu.org | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/data/doc/sisu/sisu.org b/data/doc/sisu/sisu.org index 341cdd52..83e74f11 100644 --- a/data/doc/sisu/sisu.org +++ b/data/doc/sisu/sisu.org @@ -1459,7 +1459,7 @@ That said re pdf, LaTeX XeTeX are flexible, it may be possible to drop the ocn at the start of a code block lower on its line so that it is closer to the code that follows -**** DONE (6.0.5) [#D] #744353 [w|u] sisu output: please do not use typewriter for urls :output:consider: +**** DONE (5.3.5::6.0.5) [#D] #744353 [w|u] sisu output: please do not use typewriter for urls :output:consider: From: Daniel Baumann @@ -1640,7 +1640,7 @@ Daniel for pdf fix/implement mailto links done but requires further testing & possibly refinement -**** DONE (6.0.5) [#C] #744358 [w|u] sisu output: please do not add ';' after \:copyright: :output:fix: +**** DONE (5.3.5::6.0.5) [#C] #744358 [w|u] sisu output: please do not add ';' after \:copyright: :output:fix: From: Daniel Baumann @@ -1864,7 +1864,7 @@ there has been no rule to the contrary (i.e. that headings should be on a single consider, should there be such a rule? -**** DONE (6.0.5) [#B] #744386 [w|u] sisu syntax: 1~ and 2~ result in the same formatting :output:pdf:fix: (see #744383) +**** DONE (5.3.5::6.0.5) [#B] #744386 [w|u] sisu syntax: 1~ and 2~ result in the same formatting :output:pdf:fix: (see #744383) From: Daniel Baumann @@ -1931,7 +1931,7 @@ seemed to work (checked pdf & html (scroll & seg)) was not able to reproduce will look again -**** DONE (6.0.5) [#C] #744391 [w|u] sisu output: no color on a4 portrait :output:pdf:contemplate: +**** DONE (5.3.5::6.0.5) [#C] #744391 [w|u] sisu output: no color on a4 portrait :output:pdf:contemplate: From: Daniel Baumann @@ -2062,7 +2062,7 @@ Daniel will look at: should be possible; requires a configuration option -**** DONE (6.0.5) [#B] #744399 [w|u] sisu syntax: :A smaller formatted than :B :output:fix: (see #744383) (partial solution) +**** DONE (5.3.5::6.0.5) [#B] #744399 [w|u] sisu syntax: :A smaller formatted than :B :output:fix: (see #744383) (partial solution) From: Daniel Baumann @@ -2099,7 +2099,7 @@ now is same size see #744383 \subsection (level 2) \subsubsection (level 3) -**** DONE (6.0.5) [#C] #744402 [w|u] sisu: support sha512 :implement: +**** DONE (5.3.5::6.0.5) [#C] #744402 [w|u] sisu: support sha512 :implement: From: Daniel Baumann @@ -2124,7 +2124,7 @@ Daniel implemented document command line option --sha512 -**** DONE (6.0.5) [#C] #744405 [w|u] sisu: set default font size :configuration:pdf:implement: +**** DONE (5.3.5::6.0.5) [#C] #744405 [w|u] sisu: set default font size :configuration:pdf:implement: From: Daniel Baumann -- cgit v1.2.3 From 954419b5ae79efb032d28b145ee40d0b61c80c23 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Tue, 1 Jul 2014 00:33:49 -0400 Subject: v5: merge what was sisu_6.0.8 into v5 * ao, * syntax, able optionally to indicate the language syntax of a code block * syntax, introduce box text block/group * syntax, introduce tics quotes markup (blockquote equivalent) * docbook, * ocn & footnote numbers (as xml comments) * metadata header (docinfo) * quotes (blockquote) * tables * images * code block * vim syntax, add * code block, language syntax, optional * box block * quote block --- data/doc/sisu/CHANGELOG_v5 | 17 ++++ lib/sisu/v5/ao_doc_objects.rb | 49 +++++++++-- lib/sisu/v5/ao_doc_str.rb | 164 +++++++++++++++++++++++++----------- lib/sisu/v5/ao_expand_insertions.rb | 2 +- lib/sisu/v5/ao_misc_arrange.rb | 48 ++++++++--- lib/sisu/v5/ao_syntax.rb | 3 +- lib/sisu/v5/shared_metadata.rb | 66 +++++++++++++++ lib/sisu/v5/txt_shared.rb | 9 +- lib/sisu/v5/xml_docbook5.rb | 128 ++++++++++++++++++++-------- lib/sisu/v5/xml_shared.rb | 49 ++++++----- lib/sisu/v5/xml_tables.rb | 58 +++++++++++++ 11 files changed, 461 insertions(+), 132 deletions(-) diff --git a/data/doc/sisu/CHANGELOG_v5 b/data/doc/sisu/CHANGELOG_v5 index 7f876e7c..07221ecf 100644 --- a/data/doc/sisu/CHANGELOG_v5 +++ b/data/doc/sisu/CHANGELOG_v5 @@ -38,6 +38,23 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_5.4.3.orig.tar.xz sisu_5.4.3.orig.tar.xz sisu_5.4.3-1.dsc +* merge what was sisu_6.0.8 into v5 + * ao, + * syntax, able optionally to indicate the language syntax of a code block + * syntax, introduce box text block/group + * syntax, introduce tics quotes markup (blockquote equivalent) + * docbook, + * ocn & footnote numbers (as xml comments) + * metadata header (docinfo) + * quotes (blockquote) + * tables + * images + * code block + * vim syntax, add + * code block, language syntax, optional + * box block + * quote block + %% 5.4.2.orig.tar.xz (2014-06-22:24/7) http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/sisu_5.4.2 http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/debian/sisu_5.4.2-1 diff --git a/lib/sisu/v5/ao_doc_objects.rb b/lib/sisu/v5/ao_doc_objects.rb index c53c60d6..dd0a44cd 100644 --- a/lib/sisu/v5/ao_doc_objects.rb +++ b/lib/sisu/v5/ao_doc_objects.rb @@ -184,10 +184,10 @@ module SiSU_AO_DocumentStructure end end class ObjectPara - attr_accessor :obj,:is,:tags,:of,:name,:idx,:bullet_,:indent,:hang,:ocn,:odv,:osp,:parent,:note_,:image_,:ocn_,:digest,:tmp + attr_accessor :obj,:is,:tags,:of,:name,:idx,:quote_,:bullet_,:indent,:hang,:ocn,:odv,:osp,:parent,:note_,:image_,:ocn_,:digest,:tmp def initialize @of=:para - @is=@obj=@name=@idx=@bullet_=@indent=@hang=@size=@ocn=@odv=@osp=@parent=@note_=@image_=@ocn_=@digest=@tmp=nil + @is=@obj=@name=@idx=@quote_=@bullet_=@indent=@hang=@size=@ocn=@odv=@osp=@parent=@note_=@image_=@ocn_=@digest=@tmp=nil @tags=[] end def paragraph(h,o=nil) @@ -204,6 +204,7 @@ module SiSU_AO_DocumentStructure indent= h[:indent].to_s || ((defined? o.indent) ? o.indent.to_s : nil) #Integer, indent level hang= h[:hang].to_s || ((defined? o.hang) ? o.hang.to_s : nil) #Integer, hanging indent level bullet_=h[:bullet_] || ((defined? o.bullet_) ? o.bullet_ : false) #Bool, bulleted? + quote_= h[:quote_] || ((defined? o.quote_) ? o.quote_ : false) #Bool, quote (blockquote)? note_= h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) image_= h[:image_] || ((defined? o.image_) ? o.image_ : false) #Bool, images? (processing optimization) ocn_=if h[:ocn_].nil? then ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider @@ -211,7 +212,7 @@ module SiSU_AO_DocumentStructure end 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 + @of,@is,@name,@tags,@obj,@indent,@hang,@bullet_,@quote_,@idx,@ocn,@odv,@osp,@parent,@image_,@note_,@ocn_,@digest,@tmp=of,is,name,tags,obj,indent,hang,bullet_,quote_,idx,ocn,odv,osp,parent,image_,note_,ocn_,digest,tmp self end def docinfo(h,o=nil) @@ -240,10 +241,10 @@ module SiSU_AO_DocumentStructure end end class ObjectBlockTxt - attr_accessor :obj,:is,:of,:tags,:idx,:ocn,:odv,:osp,:parent,:note_,:number_,:ocn_,:digest,:tmp + attr_accessor :obj,:is,:of,:tags,:lngsyn,:idx,:ocn,:odv,:osp,:parent,:note_,:number_,:ocn_,:digest,:tmp def initialize @of=:block - @is=@obj=@idx=@ocn=@odv=@osp=@parent=@note_=@number_=@ocn_=@digest=@tmp=nil + @is=@obj=@lngsyn=@idx=@ocn=@odv=@osp=@parent=@note_=@number_=@ocn_=@digest=@tmp=nil @tags=[] end def code(h,o=nil) @@ -251,6 +252,7 @@ module SiSU_AO_DocumentStructure is= :code #Symbol, classification - specific type tags= h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content + lngsyn= h[:lngsyn] || ((defined? o.lngsyn) ? o.lngsyn : :txt) #symbol, code lngsyn idx= h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? ocn= h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects odv= h[:odv] || ((defined? o.odv) ? o.odv : nil) @@ -264,7 +266,27 @@ module SiSU_AO_DocumentStructure num= h[:num] || ((defined? o.num) ? o.num : nil) 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 + @of,@is,@tags,@obj,@lngsyn,@idx,@ocn,@odv,@osp,@parent,@number_,@note_,@ocn_,@num,@digest,@tmp=of,is,tags,obj,lngsyn,idx,ocn,odv,osp,parent,number_,note_,ocn_,num,digest,tmp + self + end + def box(h,o=nil) + of= @of #Symbol, classification - group + is= :box #Symbol, classification - specific type + tags= h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any + obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content + idx= h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? + ocn= h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects + odv= h[:odv] || ((defined? o.odv) ? o.odv : nil) + osp= h[:osp] || ((defined? o.osp) ? o.osp : nil) + parent= h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] + note_= h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) + ocn_= if h[:ocn_].nil? then ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider + else h[:ocn_] + end + num= h[:num] || ((defined? o.num) ? o.num : nil) + digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, 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 end def block(h,o=nil) @@ -455,10 +477,10 @@ module SiSU_AO_DocumentStructure end end class ObjectLayout - attr_accessor :obj,:is,:of,:from,:tmp + attr_accessor :obj,:sym,:attr,:is,:of,:from,:tmp,:num def initialize @of=:layout - @is=@obj=@from=@tmp=nil + @is=@obj=@from=@tmp=@num=nil end def break(h,f=nil) #decide how to deal with of= @of #Symbol, classification - group @@ -477,6 +499,17 @@ module SiSU_AO_DocumentStructure @of,@is,@obj,@tmp=of,is,obj,tmp self end + def open_close(h,o=nil) #useful for poem & quote + of= @of #Symbol, classification - group + is= :open_close_tags #Symbol, classification - specific type + obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content + sym= h[:sym] || ((defined? o.sym) ? o.sym : nil) #Symbol tag_open, tag_close + attr= h[:attr] || ((defined? o.attr) ? o.attr : nil) #String, text content + tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use + num= h[:num] || ((defined? o.num) ? o.num : nil) + @of,@is,@obj,@sym,@attr,@tmp,@num=of,is,obj,sym,attr,tmp,num + self + end end class ObjectComment attr_accessor :obj,:is,:of,:tmp diff --git a/lib/sisu/v5/ao_doc_str.rb b/lib/sisu/v5/ao_doc_str.rb index 4708a126..e5ed0fd0 100644 --- a/lib/sisu/v5/ao_doc_str.rb +++ b/lib/sisu/v5/ao_doc_str.rb @@ -65,10 +65,13 @@ module SiSU_AO_DocumentStructureExtract @@flag={ ocn: :on, code: :off, + lngsyn: :txt, poem: :off, block: :off, + box: :off, group: :off, alt: :off, + quote: :off, table: :off, table_to: :off, } @@ -81,10 +84,13 @@ module SiSU_AO_DocumentStructureExtract @@flag={ ocn: :on, code: :off, + lngsyn: :txt, poem: :off, block: :off, + box: :off, group: :off, alt: :off, + quote: :off, table: :off, table_to: :off, } @@ -119,6 +125,11 @@ module SiSU_AO_DocumentStructureExtract ? true : false end + def quotes? + @@flag[:quote]==:open \ + ? true + : false + end def hang_and_indent_test(str) hang_indent=if str=~/^_([1-9])[^_]/ [$1,$1] @@ -229,8 +240,10 @@ module SiSU_AO_DocumentStructureExtract @num_id={ code_block: 0, poem: 0, + box: 0, group: 0, alt: 0, + quote: 0, table: 0, } @metadata={} @@ -254,13 +267,14 @@ module SiSU_AO_DocumentStructureExtract next end t_o=t_o.gsub(/(?:\n\s*\n)+/m,"\n") if @@flag[:code]==:off - if t_o !~/^(?:code|poem|alt|group|block)\{|^\}(?:code|poem|alt|group|block)|^(?:table\{|\{table)[ ~]/ \ - and t_o !~/^```[ ]+(?:code|poem|alt|group|block|table)|^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/ \ + if t_o !~/^(?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block)\{|^\}(?:code|poem|alt|group|block)|^(?:table\{|\{table)[ ~]/ \ + and t_o !~/^```[ ]+(?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block|table)|^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$|^`:quote_(?:open|close)`/ \ and @@flag[:code]==:off \ and @@flag[:poem]==:off \ and @@flag[:group]==:off \ and @@flag[:block]==:off \ and @@flag[:alt]==:off \ + and @@flag[:box]==:off \ and @@flag[:table]==:off unless t_o =~/^(?:@\S+?:|%+)\s/ # extract book index for paragraph if any idx=if t_o=~/^=\{(.+)\}\s*$\Z/m; m=$1 @@ -364,7 +378,7 @@ module SiSU_AO_DocumentStructureExtract obj << ' ~#' end end - h={ bullet_: bullet, hang: hang, indent: indent, obj: obj, idx: idx, note_: note, image_: image, tags: tags } + h={ bullet_: bullet, hang: hang, indent: indent, obj: obj, idx: idx, note_: note, image_: image, tags: tags, quote: quotes? } SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h) end else nil @@ -387,7 +401,7 @@ module SiSU_AO_DocumentStructureExtract obj << ' ~#' end end - h={ hang: hang, indent: indent, obj: obj, idx: idx, note_: note, image_: image, tags: tags } + h={ hang: hang, indent: indent, obj: obj, idx: idx, note_: note, image_: image, tags: tags, quote: quotes? } SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h) end else nil @@ -411,22 +425,32 @@ module SiSU_AO_DocumentStructureExtract end end unless obj=~/\A\s*\Z/m - h={ bullet_: false, indent: 0, hang: 0, obj: obj, idx: idx, note_: note, image_: image, tags: tags } + h={ bullet_: false, indent: 0, hang: 0, obj: obj, idx: idx, note_: note, image_: image, tags: tags, quote: quotes? } SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h) end end elsif @@flag[:code]==:off - if t_o =~/^(?:code\{|```[ ]+code)/ + if t_o =~/^(?:code(?:\.[a-z][0-9a-z_]+)?\{|```[ ]+code(?:\.[a-z][0-9a-z_]+)?)/ @@flag[:code]=case t_o - when /^code\{/ then :curls - when /^```[ ]+code/ then :tics - else @@flag[:code] #error + when /^code(?:\.[a-z][0-9a-z_]+)?\{/ then :curls + when /^```[ ]+code/ then :tics + else @@flag[:code] #error + end + @@flag[:lngsyn]=if t_o =~/^(?:code\.[a-z][0-9a-z_]+\{|```[ ]+code\.[a-z_]+)/ + case t_o + when /^code\.([a-z][0-9a-z_]+)\{/ + :"#{$1}" + when /^```[ ]+code\.([a-z][0-9a-z_]+)/ + :"#{$1}" + else :txt + end + else :txt end @@counter=1 - @codeblock_numbered=(t_o =~/^(?:code\{#|```[ ]+code\s[#])/) ? true : false + @codeblock_numbered=(t_o =~/^(?:code(?:\.[a-z][0-9a-z_]+)?\{#|```[ ]+code(?:\.[a-z][0-9a-z_]+)?\s[#])/) ? true : false @num_id[:code_block] +=1 - h={ obj: "group text start #{@num_id[:code_block]}" } - t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) + h={ obj: '', sym: :code_block_open, num: @num_id[:code_block], syntax: @@flag[:lngsyn] } + t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) elsif t_o =~/^(?:poem\{|```[ ]+poem)/ @@flag[:poem]=case t_o when /^poem\{/ then :curls @@ -434,8 +458,18 @@ module SiSU_AO_DocumentStructureExtract else @@flag[:poem] #error end @num_id[:poem] +=1 - h={ obj: "poem start #{@num_id[:poem]}" } - t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) + h={ obj: '', sym: :poem_open, num: @num_id[:poem] } + t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) + tuned_file << t_o + elsif t_o =~/^(?:box(?:\.[a-z_]+)?\{|```[ ]+box(?:\.[a-z_]+)?)/ + @@flag[:box]=case t_o + when /^box\{/ then :curls + when /^```[ ]+box/ then :tics + else @@flag[:box] #error + end + @num_id[:box] +=1 + h={ obj: '', sym: :box_open, num: @num_id[:box] } + t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) tuned_file << t_o elsif t_o =~/^(?:group\{|```[ ]+group)/ @@flag[:group]=case t_o @@ -444,8 +478,8 @@ module SiSU_AO_DocumentStructureExtract else @@flag[:group] #error end @num_id[:group] +=1 - h={ obj: "group text start #{@num_id[:group]}" } - t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) + h={ obj: '', sym: :group_open, num: @num_id[:group] } + t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) tuned_file << t_o elsif t_o =~/^(?:block\{|```[ ]+block)/ @@flag[:block]=case t_o @@ -454,8 +488,8 @@ module SiSU_AO_DocumentStructureExtract else @@flag[:block] #error end @num_id[:block] +=1 - h={ obj: "block text start #{@num_id[:block]}" } - t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) + h={ obj: '', sym: :block_open, num: @num_id[:block] } + t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) tuned_file << t_o elsif t_o =~/^(?:alt\{|```[ ]+alt)/ @@flag[:alt]=case t_o @@ -464,14 +498,20 @@ module SiSU_AO_DocumentStructureExtract else @@flag[:alt] #error end @num_id[:alt] +=1 - h={ obj: "alt text start #{@num_id[:alt]}" } - t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) + h={ obj: '', sym: :alt_open, num: @num_id[:alt] } + t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) tuned_file << t_o + elsif t_o =~/^`:quote_open`/ + @@flag[:quote]=:open + @num_id[:quote] +=1 + h={ obj: '', sym: :quote_open, num: @num_id[:quote] } + t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) + #tuned_file << t_o #% find second source, entered twice, should be once so closed off here elsif t_o =~/^(?:table\{|```[ ]+table|\{table)[ ~]/ @num_id[:table] +=1 - h={ obj: "table start #{@num_id[:table]}" } - ins=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) - tuned_file << ins + h={ obj: '', sym: :table_open, num: @num_id[:table] } + ins_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) + tuned_file << ins_o if t_o=~/^table\{(?:~h)?\s+/ @@flag[:table]=:curls @rows='' @@ -526,8 +566,8 @@ module SiSU_AO_DocumentStructureExtract h={ head_: hd, cols: cols, widths: col, obj: rows, idx: idx, tags: tags, num: @num_id[:table] } t_o=SiSU_AO_DocumentStructure::ObjectTable.new.table(h) unless h.nil? tuned_file << t_o - h={ obj: "table end #{@num_id[:table]}" } - t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) + h={ obj: '', sym: :table_close, num: @num_id[:table] } + t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) t_o elsif t_o=~/^```[ ]+table(?:~h)?\s+/ m1,m2,hd=nil,nil,nil @@ -549,8 +589,8 @@ module SiSU_AO_DocumentStructureExtract h={ head_: hd, cols: col.length, widths: col, obj: rows, idx: idx, tags: tags, num: @num_id[:table] } t_o=SiSU_AO_DocumentStructure::ObjectTable.new.table(h) unless h.nil? tuned_file << t_o - h={ obj: "table end #{@num_id[:table]}" } - t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) + h={ obj: '', sym: :table_close, num: @num_id[:table] } + t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) t_o elsif t_o=~/^\{table(?:~h)?\s+/ m1,m2,hd=nil,nil,nil @@ -572,8 +612,8 @@ module SiSU_AO_DocumentStructureExtract h={ head_: hd, cols: col.length, widths: col, obj: rows, idx: idx, tags: tags, num: @num_id[:table] } t_o=SiSU_AO_DocumentStructure::ObjectTable.new.table(h) unless h.nil? tuned_file << t_o - h={ obj: "table end #{@num_id[:table]}" } - t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) + h={ obj: '', sym: :table_close, num: @num_id[:table] } + t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) t_o end end @@ -590,13 +630,13 @@ module SiSU_AO_DocumentStructureExtract t_o=SiSU_AO_DocumentStructure::ObjectTable.new.table(@h) tuned_file << t_o @h,@rows=nil,'' - h={ obj: "table end #{@num_id[:table]}" } - t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) + h={ obj: '', sym: :table_close, num: @num_id[:table] } + t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) t_o else if t_o.is_a?(String) \ and t_o !~/^(?:table\{|```[ ]+table)/ - t_o=t_o.gsub(/^\n+/m,''). #check added for ruby 1.9.2 not needed in 1.8 series (tested in v2) + t_o=t_o.gsub(/^\n+/m,''). gsub(/\n+/m,"#{Mx[:tc_p]}") @rows += t_o + Mx[:tc_c] end @@ -610,12 +650,13 @@ module SiSU_AO_DocumentStructureExtract @tuned_code[-1].gsub!(/\s*(?:#{Mx[:br_line]}|#{Mx[:br_nl]})\s*\Z/m,'') obj=@tuned_code.join("\n") tags=[] - h={ obj: obj, tags: tags, num: @num_id[:code_block], number_: @codeblock_numbered } + h={ obj: obj, syntax: @@flag[:lngsyn], tags: tags, num: @num_id[:code_block], number_: @codeblock_numbered } + @@flag[:lngsyn]=:txt t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.code(h) @tuned_code=[] tuned_file << t_o - h={ obj: "code block end #{@num_id[:code_block]}" } - t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) + h={ obj: '', sym: :code_close, num: @num_id[:code_block] } + t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) end if (@@flag[:code]==:curls or @@flag[:code]==:tics) \ and t_o.is_a?(String) @@ -627,14 +668,26 @@ module SiSU_AO_DocumentStructureExtract t_o=nil end elsif (@@flag[:poem]==:curls or @@flag[:poem]==:tics) \ + or (@@flag[:box]==:curls or @@flag[:box]==:tics) \ or (@@flag[:group]==:curls or @@flag[:group]==:tics) \ or (@@flag[:block]==:curls or @@flag[:block]==:tics) \ - or (@@flag[:alt]==:curls or @@flag[:alt]==:tics) + or (@@flag[:alt]==:curls or @@flag[:alt]==:tics) \ + or (@@flag[:quote]==:open and t_o =~/`:quote_close`/m) #not if (@@flag[:poem]==:curls and t_o =~/^\}poem/) \ or (@@flag[:poem]==:tics and t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) @@flag[:poem]=:off - h={ obj: "poem end #{@num_id[:poem]}" } - t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) + h={ obj: '', sym: :poem_close, num: @num_id[:poem] } + t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) + elsif (@@flag[:box]==:curls and t_o =~/^\}box/) \ + or (@@flag[:box]==:tics and t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) + @@flag[:box]=:off + obj,tags=extract_tags(@tuned_block.join("\n")) + h={ obj: obj, tags: tags, num: @num_id[:box] } + @tuned_block=[] + t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.box(h) + tuned_file << t_o + h={ obj: '', sym: :box_close, num: @num_id[:box] } + t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) elsif (@@flag[:group]==:curls and t_o =~/^\}group/) \ or (@@flag[:group]==:tics and t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) @@flag[:group]=:off @@ -643,8 +696,8 @@ module SiSU_AO_DocumentStructureExtract @tuned_block=[] t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.group(h) tuned_file << t_o - h={ obj: "group text end #{@num_id[:group]}" } - t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) + h={ obj: '', sym: :group_close, num: @num_id[:group] } + t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) elsif (@@flag[:block]==:curls and t_o =~/^\}block/) \ or (@@flag[:block]==:tics and t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) @@flag[:block]=:off @@ -653,8 +706,8 @@ module SiSU_AO_DocumentStructureExtract @tuned_block=[] t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.block(h) tuned_file << t_o - h={ obj: "block text end #{@num_id[:block]}" } - t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) + h={ obj: '', sym: :block_close, num: @num_id[:block] } + t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) elsif (@@flag[:alt]==:curls and t_o =~/^\}alt/) \ or (@@flag[:alt]==:tics and t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) @@flag[:alt]=:off @@ -663,15 +716,23 @@ module SiSU_AO_DocumentStructureExtract t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.alt(h) @tuned_block=[] tuned_file << t_o - h={ obj: "alt text end #{@num_id[:alt]}" } - t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) + h={ obj: '', sym: :alt_close, num: @num_id[:alt] } + t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) + elsif @@flag[:quote]==:open and t_o =~/`:quote_close`/m + @@flag[:quote]=:off + h={ obj: '', sym: :quote_close, num: @num_id[:quote] } + t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) + elsif @@flag[:quote]==:open + t_o,tags=extract_tags(t_o) + h={ indent: 1, obj: t_o, idx: idx, note_: note, image_: image, tags: tags, quote: quotes? } + SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h) end if (@@flag[:poem]==:curls or @@flag[:poem]==:tics \ or @@flag[:group]==:curls or @@flag[:group]==:tics \ or @@flag[:alt]==:curls or @@flag[:alt]==:tics) \ and t_o =~/\S/ \ - and t_o !~/^(?:\}(?:verse|code|alt|group|block)|(?:verse|code|alt|group|block)\{)/ \ - and t_o !~/^```[ ]+(?:code|poem|alt|group|block)|^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/ # fix logic + and t_o !~/^(?:\}(?:verse|code|box|alt|group|block)|(?:verse|code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|alt|group|block)\{)/ \ + and t_o !~/^```[ ]+(?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block)|^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/ # fix logic sub_array=t_o.dup @line_mode=sub_array.scan(/.+/) type=if @@flag[:poem]==:curls or @@flag[:poem]==:tics @@ -692,8 +753,10 @@ module SiSU_AO_DocumentStructureExtract end if @@flag[:code]==:off if @@flag[:poem]==:curls or @@flag[:poem]==:tics \ + or @@flag[:box]==:curls or @@flag[:box]==:tics \ or @@flag[:group]==:curls or @@flag[:group]==:tics \ - or @@flag[:alt]==:curls or @@flag[:alt]==:tics + or @@flag[:alt]==:curls or @@flag[:alt]==:tics \ + or (@@flag[:quote]==:open and t_o =~/`:quote_close`/m) if t_o.is_a?(String) t_o=t_o.gsub(/\n/m,"#{Mx[:br_nl]}"). gsub(/[ ][ ]/m,"#{Mx[:nbsp]*2}"). @@ -702,6 +765,7 @@ module SiSU_AO_DocumentStructureExtract elsif t_o.is==:group \ || t_o.is==:block \ || t_o.is==:alt \ + || t_o.is==:box \ || t_o.is==:verse t_o.obj=t_o.obj.gsub(/\n/m,"#{Mx[:br_nl]}"). gsub(/[ ][ ]/m,"#{Mx[:nbsp]*2}"). @@ -758,8 +822,8 @@ module SiSU_AO_DocumentStructureExtract lines,lines_new=@data,[] lines.each do |line| line=if line =~/\S/ \ - and line !~/^(?:code\{|\}code)/ \ - and line !~/^(?:```[ ]+code|```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$)/ \ + and line !~/^(?:code(?:\.[a-z][0-9a-z_]+)?\{|\}code)/ \ + and line !~/^(?:```[ ]+code(?:\.[a-z][0-9a-z_]+)?|```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$)/ \ and not line.is_a?(Hash) #watch @@counter+=1 if @@flag[:code]==:curls or @@flag[:code]==:tics line=line.gsub(/\s\s/,"#{Mx[:nbsp]*2}"). @@ -1190,6 +1254,7 @@ SKIPPED processing file: [#{@md.opt.lng}] "#{@md.fns}"} ocnc+=1 ocn_sp,parent="c#{ocnc}",node elsif dob.is==:group \ + || dob.is==:box \ || dob.is==:block \ || dob.is==:alt \ || dob.is==:verse @@ -1237,6 +1302,7 @@ SKIPPED processing file: [#{@md.opt.lng}] "#{@md.fns}"} if dob.is==:code \ || dob.is==:verse \ || dob.is==:alt \ + || dob.is==:box \ || dob.is==:group \ || dob.is==:block dob.obj=dob.obj.gsub(/\n+/,"\n") #newlines taken out diff --git a/lib/sisu/v5/ao_expand_insertions.rb b/lib/sisu/v5/ao_expand_insertions.rb index ea499119..f47823b6 100644 --- a/lib/sisu/v5/ao_expand_insertions.rb +++ b/lib/sisu/v5/ao_expand_insertions.rb @@ -333,7 +333,7 @@ module SiSU_AO_Insertions tuned_file,tuned_file_tmp=[],[] codeblock_=false data.each do |para| - codeblock_=if para =~/^(?:code\{|```[ ]+code)/ + codeblock_=if para =~/^(?:code(?:\.[a-z][0-9a-z_]+)?\{|```[ ]+code(?:\.[a-z][0-9a-z_]+)?)/ true elsif para =~/^(?:\}code|```(?:\s|$))/m false diff --git a/lib/sisu/v5/ao_misc_arrange.rb b/lib/sisu/v5/ao_misc_arrange.rb index 419241e1..48b421c6 100644 --- a/lib/sisu/v5/ao_misc_arrange.rb +++ b/lib/sisu/v5/ao_misc_arrange.rb @@ -77,14 +77,14 @@ module SiSU_AO_MiscArrangeText def markup_blocks(para) def ticks(para) block_open,block_close,text=nil,nil,nil - if para =~/\A```[ ]+(?:code|poem|alt|group|block|table).*?\n.+?\n```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*\Z/m + if para =~/\A```[ ]+(?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block|table).*?\n.+?\n```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*\Z/m @flag=:close - block_open,text,block_close=/\A(```[ ]+(?:code|poem|alt|group|block|table).*?)\n(.+?)\n(```([ ]+[~-][#]|\s+\~\{.+?\}\~)?)\s*\Z/m.match(para)[1..3] + block_open,text,block_close=/\A(```[ ]+(?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block|table).*?)\n(.+?)\n(```([ ]+[~-][#]|\s+\~\{.+?\}\~)?)\s*\Z/m.match(para)[1..3] ((para=~/^```[ ]+table(?:~h)?\s+/) \ and (para !~/^```[ ]+table(?:~h)?\s+c\d+/)) \ ? para : (para=[]; para << block_open << text << block_close) - elsif para =~/\A```[ ]+(?:code|poem|alt|group|block|table).*?\n.*?\Z/m #look at, study + elsif para =~/\A```[ ]+(?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block|table).*?\n.*?\Z/m #look at, study @flag=:open block_open,text=/\A(```(?:[ ]+.+?))\n(.*?)\Z/m.match(para)[1,2] para=[] @@ -115,22 +115,38 @@ module SiSU_AO_MiscArrangeText gsub(/```\s*/m,''). strip end + def ticks_quote(para) + @flag=:quote_open + text=para + para=[] + if text =~ /```[ ]+quote/m + para << '`:quote_open`' + text=text.gsub(/```[ ]+quote/m,'') + end + text=text.gsub(/(?:\n|\A)([^`=\n]+)/m,'_1 \1') #not a perfect match for book index \n={ + para << text.gsub(/```/m,'') + if text =~/```/m + @flag=:quote_close + para << '`:quote_close`' + end + para + end def curly_braces(para) block_open,block_close,text=nil,nil,nil - para=if para =~/\A(?:code|poem|alt|group|block|table)\{ .+?\n.+?\n\}(?:code|poem|alt|group|block|table)(?: [~-][#])?\s*\Z/m - block_open,text,block_close=/\A((?:code|poem|alt|group|block|table)\{ .+?)\n(.+?)\n(\}(?:code|poem|alt|group|block|table)(?: [~-][#])?)\s*\Z/m.match(para)[1..3] + para=if para =~/\A(?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block|table)\{ .+?\n.+?\n\}(?:code|box|poem|alt|group|block|table)(?: [~-][#])?\s*\Z/m + block_open,text,block_close=/\A((?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block|table)\{ .+?)\n(.+?)\n(\}(?:code|box|poem|alt|group|block|table)(?: [~-][#])?)\s*\Z/m.match(para)[1..3] para=[] para << block_open << text << block_close - elsif para =~/\A(?:code|poem|alt|group|block|table)\{ .+?\n.+?\Z/m - block_open,text=/\A((?:code|poem|alt|group|block|table)\{ .+?)\n(.+?)\Z/m.match(para)[1,2] + elsif para =~/\A(?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block|table)\{ .+?\n.+?\Z/m + block_open,text=/\A((?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block|table)\{ .+?)\n(.+?)\Z/m.match(para)[1,2] para=[] if not text.to_s.empty? para << block_open << text else para << block_open end - elsif para =~/\A.+?\n\}(?:code|poem|alt|group|block|table)(?: [~-][#])?\s*\Z/m - text,block_close=/\A(.+?)\n(\}(?:code|poem|alt|group|block|table)(?: [~-][#])?)\s*\Z/m.match(para)[1,2] + elsif para =~/\A.+?\n\}(?:code|box|poem|alt|group|block|table)(?: [~-][#])?\s*\Z/m + text,block_close=/\A(.+?)\n(\}(?:code|box|poem|alt|group|block|table)(?: [~-][#])?)\s*\Z/m.match(para)[1,2] para=[] if not text.to_s.empty? para << text.to_s << block_close @@ -141,7 +157,11 @@ module SiSU_AO_MiscArrangeText end para end - para=if para =~/\A```[ ]+(?:code|poem|alt|group|block|table).*?\n.*?\Z/m \ + para=if (para =~/\A```[ ]+quote/m \ + and @flag !=:open) \ + or @flag==:quote_open + ticks_quote(para) + elsif para =~/\A```[ ]+(?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block|table).*?\n.*?\Z/m \ or @flag==:open ticks(para) elsif para =~/```/m @@ -149,9 +169,11 @@ module SiSU_AO_MiscArrangeText else para end - para=(para =~/^(?:code|poem|alt|group|block|table)\{|^\}(?:code|poem|alt|group|block|table)/m) \ - ? curly_braces(para) - : para + para=if para =~/^(?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block|table)\{|^\}(?:code|box|poem|alt|group|block|table)/m + curly_braces(para) + else + para + end end def prepare_text data=@data diff --git a/lib/sisu/v5/ao_syntax.rb b/lib/sisu/v5/ao_syntax.rb index a75e2690..619c5ac0 100644 --- a/lib/sisu/v5/ao_syntax.rb +++ b/lib/sisu/v5/ao_syntax.rb @@ -91,7 +91,7 @@ module SiSU_AO_Syntax { o: Mx[:fa_underscore_o], c: Mx[:fa_underscore_c] } else p __LINE__.to_s + '::' + __FILE__ end - @http_m=%r{\{.+?\}https?://\S+|https?:\S+|:\S+|\.\.\/\S+|#\S+|\S+?\.png\b|[*]~\S+|^#{Mx[:meta_o]}.+|#{Mx[:gr_o]}(?:code|block|group|alt|verse)(?:-end)?#{Mx[:gr_c]}|#{Mx[:fa_o]}:br#{Mx[:fa_c]}} + @http_m=%r{\{.+?\}https?://\S+|https?:\S+|:\S+|\.\.\/\S+|#\S+|\S+?\.png\b|[*]~\S+|^#{Mx[:meta_o]}.+|#{Mx[:gr_o]}(?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|block|group|alt|verse)(?:-end)?#{Mx[:gr_c]}|#{Mx[:fa_o]}:br#{Mx[:fa_c]}} @manmkp_ital=emph_italics \ ? '[i/*]\\{.+?\\}[i/*]' : '[i/]\\{.+?\\}[i/]' @@ -163,6 +163,7 @@ module SiSU_AO_Syntax && dob.is !=:heading \ && dob.is !=:heading_insert \ && dob.is !=:code \ + && dob.is !=:layout \ && dob.is !=:comment word=dob.obj.scan(@line_scan_ital) word=word.flatten.compact diff --git a/lib/sisu/v5/shared_metadata.rb b/lib/sisu/v5/shared_metadata.rb index 4ada2db1..1f21af3f 100644 --- a/lib/sisu/v5/shared_metadata.rb +++ b/lib/sisu/v5/shared_metadata.rb @@ -297,6 +297,57 @@ module SiSU_Metadata end meta end + def metadata_alt + meta=[] + if @display_heading + @tag,@inf=%{Document Metadata},'' + meta << self.meta_para + end + if defined? @md.title.main \ + and @md.title.main=~/\S+/ + @tag='title' + @inf=@md.title.main + meta << self.meta_para + end + if defined? @md.title.sub \ + and @md.title.sub=~/\S+/ + @tag='subtitle' + @inf=@md.title.sub + meta << self.meta_para + end + if defined? @md.creator.author \ + and @md.creator.author=~/\S+/ + @tag='author' + @inf=@md.creator.author + meta << self.meta_para + end + if defined? @md.creator.translator \ + and @md.creator.translator=~/\S+/ + @tag='translator' + @inf=@md.creator.translator + meta << self.meta_para + end + if defined? @md.creator.illustrator \ + and @md.creator.illustrator=~/\S+/ + @tag='illustrator' + @inf=@md.creator.illustrator + meta << self.meta_para + end + if defined? @md.rights.copyright.text \ + and @md.rights.copyright.text=~/\S+/ + @tag='copyright' + @inf=@md.rights.copyright.text # year & holder + @inf=@inf.gsub(/(?:Copyright|\(C\))+\s*/,'') + meta << self.meta_para + end + if defined? @md.rights.license \ + and @md.rights.license=~/\S+/ + @tag='license' + @inf=@md.rights.license + meta << self.meta_para + end + meta + end def processing_tags def make def language @@ -756,6 +807,21 @@ module SiSU_Metadata end self end + def xml_docbook + def meta_para + inf_xml=char_enc(@inf).utf8 + inf_xml=char_enc(inf_xml).br + < +#{Ax[:tab]*2}#{inf_xml} +#{Ax[:tab]} +WOK + end + def metadata + SiSU_Metadata::Summary.new(@md).metadata_alt + end + self + end def xml_sax def meta_para inf_xml=char_enc(@inf).utf8 diff --git a/lib/sisu/v5/txt_shared.rb b/lib/sisu/v5/txt_shared.rb index 0b6c1953..2bf633ea 100644 --- a/lib/sisu/v5/txt_shared.rb +++ b/lib/sisu/v5/txt_shared.rb @@ -62,8 +62,8 @@ =end module SiSU_TextUtils class Wrap - def initialize(para='',n_char_max=76,n_indent=0,n_hang=nil) - @para,@n_char_max,@n_indent=para,n_char_max,n_indent + def initialize(para='',n_char_max=76,n_indent=0,n_hang=nil,post='') + @para,@n_char_max,@n_indent,@post,=para,n_char_max,n_indent,post @n_char_max_extend = n_char_max @n_hang=n_hang ? n_hang : @n_indent end @@ -110,7 +110,10 @@ module SiSU_TextUtils end @oldword=word if word =~/\S+/ end - spaces_hang + out.join(spaces_indent) + post=(@post.empty?) \ + ? '' + : "\n" + (' '*@n_indent) +@post + spaces_hang + out.join(spaces_indent) + post end def line_wrap_indent1 @n_indent,@n_hang=2,2 diff --git a/lib/sisu/v5/xml_docbook5.rb b/lib/sisu/v5/xml_docbook5.rb index 98450520..3a59f839 100644 --- a/lib/sisu/v5/xml_docbook5.rb +++ b/lib/sisu/v5/xml_docbook5.rb @@ -70,6 +70,7 @@ module SiSU_XML_Docbook_Book include SiSU_TextUtils require_relative 'xml_shared' # xml_shared.rb include SiSU_XML_Munge + require_relative 'shared_metadata' # shared_metadata.rb class Source def initialize(opt) @opt=opt @@ -135,7 +136,7 @@ module SiSU_XML_Docbook_Book def collapsed %w[ 0 1 2 3 4 5 ] end - def docbook(lc,chlv='') + def docbook_tag(lc,chlv='') case lc when 0 then 'book' when 1 then lc==chlv ? 'chapter' : 'section' @@ -162,7 +163,7 @@ module SiSU_XML_Docbook_Book end def markup_text(data) data.each_with_index do |o,i| - if o.is ==:heading || o.is ==:para + if o.is ==:heading || o.is ==:para || o.is ==:open_close_tags o=@trans.markup_docbook(o) #unless o.obj==nil end end @@ -189,6 +190,38 @@ module SiSU_XML_Docbook_Book end #def chapterlevel #end + def xml_head + [ + '', + SiSU_Metadata::Summary.new(@md).xml_docbook.metadata, + '' + ].flatten + end + def code_output(o,ocn,filename_docbook) + filename_docbook.puts o.obj.gsub(/\n?(?:#{Mx[:br_line]}|#{Mx[:br_nl]})\n?/m,"\n") + end + def adjust_output(o,ocn,filename_docbook,splv) + if o.obj =~/#{Xx[:split]}/ + outs=o.obj.split(/#{Xx[:split]}/) + outs.each do |out| + if out =~/
" : '' id=%{ id="o#{o.ocn}" } else @@ -217,16 +251,40 @@ module SiSU_XML_Docbook_Book doc_position=:body_and_tail else filename_docbook.puts structure_build_tag_close(o.lc,h) - filename_docbook.puts %{#{spaces*(o.lc)}<#{tags.docbook(o.lc,chlv)}#{tag_id}> + filename_docbook.puts %{#{spaces*(o.lc)}<#{tags.docbook_tag(o.lc,chlv)}#{tag_id}> #{spaces*o.lc} } end - filename_docbook.puts SiSU_TextUtils::Wrap.new(o.obj + ocn,80,(@splv*2+2)).line_wrap + adjust_output(o,ocn,filename_docbook,@splv) filename_docbook.puts %{#{spaces*o.lc}} h=o.lc - elsif (o.of ==:para or o.of ==:block) + elsif o.of ==:layout \ + and o.is ==:open_close_tags + xml_tag=case o.sym + when :quote_open then '
' + when :quote_close then '
' + else '' + end + unless xml_tag.empty? + filename_docbook.puts "#{spaces*(@splv)}#{xml_tag}" + end + elsif o.of ==:block + if o.is ==:table + filename_docbook.puts SiSU_Tables::TableXMLdocbook.new(o,id).table.obj + elsif o.is ==:code + filename_docbook.puts "#{spaces*(@splv)}" + filename_docbook.puts "#{spaces*(@splv+1)}" + code_output(o,ocn,filename_docbook) + filename_docbook.puts "#{spaces*(@splv+1)}" + filename_docbook.puts "#{spaces*(@splv)}" + else + filename_docbook.puts "#{spaces*(@splv)}" + adjust_output(o,ocn,filename_docbook,@splv) + filename_docbook.puts "#{spaces*(@splv)}" + end + elsif o.of ==:para filename_docbook.puts "#{spaces*(@splv)}" - filename_docbook.puts SiSU_TextUtils::Wrap.new(o.obj + ocn,80,(@splv*2+2)).line_wrap + adjust_output(o,ocn,filename_docbook,@splv) filename_docbook.puts "#{spaces*(@splv)}" end end @@ -237,40 +295,40 @@ module SiSU_XML_Docbook_Book x=[] case h when 0 - x << "#{spaces*0}" if (lc <= 0) + x << "#{spaces*0}" if (lc <= 0) when 1 - x << "#{spaces*1}" if (lc <= 1) - x << "#{spaces*0}" if (lc <= 0) + x << "#{spaces*1}" if (lc <= 1) + x << "#{spaces*0}" if (lc <= 0) when 2 - x << "#{spaces*2}" if (lc <= 2) - x << "#{spaces*1}" if (lc <= 1) - x << "#{spaces*0}" if (lc <= 0) + x << "#{spaces*2}" if (lc <= 2) + x << "#{spaces*1}" if (lc <= 1) + x << "#{spaces*0}" if (lc <= 0) when 3 - x << "#{spaces*3}" if (lc <= 3) - x << "#{spaces*2}" if (lc <= 2) - x << "#{spaces*1}" if (lc <= 1) - x << "#{spaces*0}" if (lc <= 0) + x << "#{spaces*3}" if (lc <= 3) + x << "#{spaces*2}" if (lc <= 2) + x << "#{spaces*1}" if (lc <= 1) + x << "#{spaces*0}" if (lc <= 0) when 4 - x << "#{spaces*4}" if (lc <= 4) - x << "#{spaces*3}" if (lc <= 3) - x << "#{spaces*2}" if (lc <= 2) - x << "#{spaces*1}" if (lc <= 1) - x << "#{spaces*0}" if (lc <= 0) + x << "#{spaces*4}" if (lc <= 4) + x << "#{spaces*3}" if (lc <= 3) + x << "#{spaces*2}" if (lc <= 2) + x << "#{spaces*1}" if (lc <= 1) + x << "#{spaces*0}" if (lc <= 0) when 5 - x << "#{spaces*5}" if (lc <= 5) - x << "#{spaces*4}" if (lc <= 4) - x << "#{spaces*5}" if (lc <= 3) - x << "#{spaces*2}" if (lc <= 2) - x << "#{spaces*1}" if (lc <= 1) - x << "#{spaces*0}" if (lc <= 0) + x << "#{spaces*5}" if (lc <= 5) + x << "#{spaces*4}" if (lc <= 4) + x << "#{spaces*5}" if (lc <= 3) + x << "#{spaces*2}" if (lc <= 2) + x << "#{spaces*1}" if (lc <= 1) + x << "#{spaces*0}" if (lc <= 0) when 6 - x << "#{spaces*6}" if (lc <= 6) - x << "#{spaces*5}" if (lc <= 5) - x << "#{spaces*4}" if (lc <= 4) - x << "#{spaces*3}" if (lc <= 3) - x << "#{spaces*2}" if (lc <= 2) - x << "#{spaces*1}" if (lc <= 1) - x << "#{spaces*0}" if (lc <= 0) + x << "#{spaces*6}" if (lc <= 6) + x << "#{spaces*5}" if (lc <= 5) + x << "#{spaces*4}" if (lc <= 4) + x << "#{spaces*3}" if (lc <= 3) + x << "#{spaces*2}" if (lc <= 2) + x << "#{spaces*1}" if (lc <= 1) + x << "#{spaces*0}" if (lc <= 0) end x.join("\n") end diff --git a/lib/sisu/v5/xml_shared.rb b/lib/sisu/v5/xml_shared.rb index fc972833..f1113495 100644 --- a/lib/sisu/v5/xml_shared.rb +++ b/lib/sisu/v5/xml_shared.rb @@ -460,28 +460,33 @@ module SiSU_XML_Munge clean(str) end def markup_docbook(dob='') # work on, initially a copy of fictionbook! - dob.obj=dob.obj.gsub(/#{Mx[:en_a_o]}(.+?)#{Mx[:en_a_c]}/m,'\1'). - gsub(/&/,'&'). #sort - gsub(/#{Mx[:mk_o]}#([a-zA-Z]+)#{Mx[:mk_c]}/,'&\1;'). - gsub(/(^|#{Mx[:gl_c]}|\s)&\s+/,'\1& '). #sort - gsub(/#{Mx[:mk_o]}(#[0-9]+)#{Mx[:mk_c]}/,'&\1;') - dob.obj=dob.obj.gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,'
') unless dob.is==:table - dob.obj=dob.obj.gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'\1'). - gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'\1'). - gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'\1'). - gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,'\1'). - gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,'\1'). - gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'\1'). - gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'\1'). - gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'\1'). - gsub(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/,'\1'). # tt, kbd - gsub(/#{Mx[:lnk_o]}\s*(\S+?\.(?:png|jpg|gif)).+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}|image)/m,''). #taken unmodified except path from fictionbook - gsub(/#{Mx[:url_o]}(.+?)#{Mx[:url_c]}/,"#{Dx[:url_o]}\\1#{Dx[:url_c]}"). - gsub(/#{Mx[:mk_o]}:name#(\S+?)#{Mx[:mk_c]}/,''). - gsub(/#{Mx[:gl_bullet]}/m,'● '). #  not available - gsub(/#{Mx[:nbsp]}/,' '). #  not available - gsub(/<(p|br)>/,'<\1 />') - dob.obj=clean(dob.obj) + if dob.is !=:code + dob.obj=dob.obj.gsub(/#{Mx[:en_a_o]}(\d+)\s*(.+?)#{Mx[:en_a_c]}/m,'\2'). + gsub(/\\\\/,''). + gsub(/&/,'&'). #sort + gsub(/#{Mx[:mk_o]}#([a-zA-Z]+)#{Mx[:mk_c]}/,'&\1;'). + gsub(/(^|#{Mx[:gl_c]}|\s)&\s+/,'\1& '). #sort + gsub(/#{Mx[:mk_o]}(#[0-9]+)#{Mx[:mk_c]}/,'&\1;') + dob.obj=dob.obj.gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,'
') unless dob.is==:table + dob.obj=dob.obj.gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'\1'). + gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'\1'). + gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'\1'). + gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,'\1'). + gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,'\1'). + gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'\1'). + gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'\1'). + gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'\1'). + gsub(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/,'\1'). # tt, kbd + gsub(/#{Mx[:lnk_o]}\s*(\S+?\.(?:png|jpg|gif)).+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}|image)/m, + %{#{Xx[:split]}:spaces0:
\n:spaces1:\n:spaces1:\n:spaces0:
#{Xx[:split]}}). + gsub(/#{Mx[:url_o]}(.+?)#{Mx[:url_c]}/,"#{Dx[:url_o]}\\1#{Dx[:url_c]}"). + gsub(/#{Mx[:mk_o]}:name#(\S+?)#{Mx[:mk_c]}/,''). + gsub(/#{Mx[:gl_bullet]}/m,'● '). #  not available + gsub(/#{Mx[:nbsp]}/,' '). #  not available + gsub(/<(p|br)>/,'<\1 />') + dob.obj=clean(dob.obj) + else # codeblock + end dob end def markup_group(dob='') diff --git a/lib/sisu/v5/xml_tables.rb b/lib/sisu/v5/xml_tables.rb index 4ae41190..1587afbc 100644 --- a/lib/sisu/v5/xml_tables.rb +++ b/lib/sisu/v5/xml_tables.rb @@ -122,6 +122,64 @@ module SiSU_Tables @parablock end end + class TableXMLdocbook + @@tablehead=0 + @@tablefoot=[] #watch + def initialize(table,id='') + @table_obj,@id=table,id + @vz=SiSU_Viz::Defaults.new + end + def spaces + Ax[:spaces] + end + def table + table_obj=@table_obj + if table_obj.obj !~/^/,'
') + trc <<= if table_obj.head_ and nr==0 + %{#{spaces*6}#{c}\n} + else %{#{spaces*6}#{c}\n} + end + nc+=1 + end + trc=(trc.is_a?(Array)) ? trc.flatten.join : trc + trc = if table_obj.head_ and nr==0 + "#{spaces*4}\n#{spaces*5}\n#{trc}#{spaces*5}\n#{spaces*4}\n#{spaces*4}\n" + else + "#{spaces*5}\n#{trc}#{spaces*5}\n" + end + nr+=1 + table_rows << trc + end + tbody_close=if table_obj.head_ + "#{spaces*4}" + else '' + end + table_rows=table_rows.flatten.join + # include table_id + table_obj.obj=%{#{spaces*3} +#{spaces*4}
+#{spaces*4} +#{table_rows}#{tbody_close} +#{spaces*4} +#{spaces*4}
+#{spaces*3}
} + table_obj + end + end class TableXMLexp Date: Tue, 1 Jul 2014 00:35:33 -0400 Subject: vim syntax, version & date (code block, language syntax; box group; quote) * now applies to v5 branch --- data/sisu/conf/editor-syntax-etc/vim/syntax/sisu.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/sisu/conf/editor-syntax-etc/vim/syntax/sisu.vim b/data/sisu/conf/editor-syntax-etc/vim/syntax/sisu.vim index 03e1766f..3bb1a5ea 100644 --- a/data/sisu/conf/editor-syntax-etc/vim/syntax/sisu.vim +++ b/data/sisu/conf/editor-syntax-etc/vim/syntax/sisu.vim @@ -1,7 +1,7 @@ " SiSU Vim syntax file " SiSU Maintainer: Ralph Amissah -" SiSU Markup: SiSU (sisu-6.0.8) -" Last Change: 2014-06-19 +" SiSU Markup: SiSU (sisu-5.4.3) +" Last Change: 2014-07-01 " URL: "(originally looked at Ruby Vim by Mirko Nasato) -- cgit v1.2.3 From 418716166677579b407653959f5d7e8947a4579d Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Tue, 1 Jul 2014 00:39:28 -0400 Subject: v5 v6: files renamed: ao_composite.rb, html_concordance.rb * ao_composite.rb (from composite.rb) * html_concordance.rb (from concordance.rb) --- lib/sisu/v5/ao_composite.rb | 267 ++++++++++++++++++++++++++++ lib/sisu/v5/composite.rb | 267 ---------------------------- lib/sisu/v5/concordance.rb | 382 ---------------------------------------- lib/sisu/v5/html_concordance.rb | 382 ++++++++++++++++++++++++++++++++++++++++ lib/sisu/v5/hub.rb | 4 +- lib/sisu/v5/po4a.rb | 2 +- lib/sisu/v5/remote.rb | 2 +- lib/sisu/v6/ao_composite.rb | 267 ++++++++++++++++++++++++++++ lib/sisu/v6/composite.rb | 267 ---------------------------- lib/sisu/v6/concordance.rb | 382 ---------------------------------------- lib/sisu/v6/html_concordance.rb | 382 ++++++++++++++++++++++++++++++++++++++++ lib/sisu/v6/hub.rb | 4 +- lib/sisu/v6/po4a.rb | 2 +- lib/sisu/v6/remote.rb | 2 +- 14 files changed, 1306 insertions(+), 1306 deletions(-) create mode 100644 lib/sisu/v5/ao_composite.rb delete mode 100644 lib/sisu/v5/composite.rb delete mode 100644 lib/sisu/v5/concordance.rb create mode 100644 lib/sisu/v5/html_concordance.rb create mode 100644 lib/sisu/v6/ao_composite.rb delete mode 100644 lib/sisu/v6/composite.rb delete mode 100644 lib/sisu/v6/concordance.rb create mode 100644 lib/sisu/v6/html_concordance.rb diff --git a/lib/sisu/v5/ao_composite.rb b/lib/sisu/v5/ao_composite.rb new file mode 100644 index 00000000..9fd42672 --- /dev/null +++ b/lib/sisu/v5/ao_composite.rb @@ -0,0 +1,267 @@ +# encoding: utf-8 +=begin + + * Name: SiSU + + * Description: a framework for document structuring, publishing and search + + * Author: Ralph Amissah + + * Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. + + * License: GPL 3 or later: + + SiSU, a framework for document structuring, publishing and search + + Copyright (C) Ralph Amissah + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program. If not, see . + + If you have Internet connection, the latest version of the GPL should be + available at these locations: + + + + + + * SiSU uses: + * Standard SiSU markup syntax, + * Standard SiSU meta-markup syntax, and the + * Standard SiSU object citation numbering and system + + * Hompages: + + + + * Download: + + + * Git + + + + * Ralph Amissah + + + + ** Description: composite documents, assemble/build documents from other + documents or parts of marked up text + +=end +module SiSU_Assemble + require_relative 'sysenv' # sysenv.rb + class RemoteImage + def initialize + @env=SiSU_Env::InfoEnv.new + end + def image(dir) + images=[] + images[0]=dir + images + end + def download_images(images_info) + path="#{@env.processing_path.processing}/external_document/image" + FileUtils::mkdir_p(path) unless FileTest.directory?(path) + download_from=images_info.shift + images_info.each do |i| + image="#{path}/#{i}" + imagefile=File.new(image,'w+') + open("#{download_from}/#{i}") do |g| + imagefile << g.read + end + imagefile.close + end + output_path="#{@env.path.webserv}/#{@env.path.stub_pwd}/_sisu/image_external" + FileUtils::mkdir_p(output_path) unless FileTest.directory?(output_path) + SiSU_Env::SystemCall.new("#{path}/*",output_path,'q').rsync + end + end + class Composite + @@imager={} + def initialize(opt) + @opt=opt + @env=SiSU_Env::InfoEnv.new + end + def read + begin + pwd=Dir.pwd + Dir.chdir(@opt.f_pth[:pth]) + @fns_array=IO.readlines(@opt.fno,'') + assembled=insertions? + write(assembled) + Dir.chdir(pwd) + rescue + SiSU_Errors::Rescued.new($!,$@,@opt.cmd,@opt.fns).location do + __LINE__.to_s + ':' + __FILE__ + end + ensure + end + end + def write(assembled) + assembled_file=File.new("#{@env.processing_path.composite_file}/#{@opt.fnb}.ssm.sst",'w+') + assembled.each {|a| assembled_file << a } + assembled_file.close + end + def download_images(download_from,images_array) + path="#{@env.processing_path.processing}/external_document/image" + FileUtils::mkdir_p(path) unless FileTest.directory?(path) + images_array.each do |i| + image="#{path}/#{i}" + unless FileTest.exists?(image) + imagefile=File.new(image,'w+') + open("#{download_from}/#{i}") do |g| + imagefile << g.read + end + imagefile.close + end + end + end + def insertion(fni,insert_array) + file={ prepared: [], images: [] } + rgx_image=/(?:^|[^_\\])\{\s*(\S+?\.(?:png|jpg|gif))/ + file[:prepared] << "\n% |#{fni}|@|^|>>ok\n\n" + @code_flag=false + insert_array.each do |i| + @code_flag=if i =~/^code\{/ then true + elsif i =~/^\}code/ then false + else @code_flag + end + if not @code_flag \ + and i !~/^%+\s/ + i=i.gsub(/^([123]|:?[ABCD])~\? /,'% [conditional heading:] \1~ ') #off conditional heading (consider syntax) + if i =~/^@\S+?:/ + i=i.gsub(/\n/m,"\n% "). + gsub(/\n%\s+$/m,''). + gsub(/^@\S+?:/m,"\n% [imported header:] ") #off imported headers + end + end + file[:prepared] << i + if i !~/^%+\s/ \ + and i =~rgx_image + file[:images] << i.scan(rgx_image).uniq + end + end + file[:prepared] << "\n% end import" << "\n\n" + if file[:images].length > 0 + file[:images]=file[:images].flatten.uniq + file[:images].delete_if {|x| x =~/https?:\/\// } + end + file + end + def insertions? + data=@fns_array + 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])$/ + loadfile=$1.strip + src_ssm=@opt.fns.sub(/\.ssm\.sst/,'.ssm') + if (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'loading:',loadfile).txt_grey + end + tuned_file << if loadfile =~ /(?:https?|file):\/\/\S+?\.ss[ti]$/ # and NetTest + imagedir = /((?:https?|file):\/\/\S+?)\/[^\/]+?\.ss[ti]$/.match(loadfile).captures.join + '/_sisu/image' #watch + begin + require 'uri' + require 'open-uri' + require 'pp' + rescue LoadError + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('uri, open-uri or pp NOT FOUND (LoadError)') + end + image_uri=URI.parse(imagedir) + insert=open(loadfile) + insert_array=insert.dup + insert.close + file=insertion(loadfile,insert_array) + @@imager[image_uri] ||=[] + @@imager[image_uri] << file[:images] + file[:prepared] + elsif loadfile =~ /\.ss[ti]$/ \ + and FileTest.file?(loadfile) + insert_array=IO.readlines(loadfile,'') + file=insertion(loadfile,insert_array) + file[:prepared] + else + cX=SiSU_Screen::Ansi.new(@opt.act[:color_state][:set]).cX + 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 + end + tuned_file=tuned_file.flatten.compact + end + if @@imager.length >0 + @@imager.each do |d,i| + i=i.flatten.uniq + image_info=d + i + download_images(image_info.flatten) + end + end + tuned_file + end + end + class CompositeFileList + @@imager={} + def initialize(opt) + @opt=opt + @env=SiSU_Env::InfoEnv.new + end + def read + begin + @opt.fns=@opt.fns.gsub(/\.ssm\.sst$/,'.ssm') #FIX earlier, hub + @fns_array=IO.readlines(@opt.fns,'') + insertions? + rescue + SiSU_Errors::Rescued.new($!,$@,@opt.cmd,@opt.fns).location do + __LINE__.to_s + ':' + __FILE__ + end + ensure + end + end + def insertions? + data=@fns_array + tuned_file=[] + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Composite Document',@opt.fno).grey_title_hi unless @opt.act[:quiet][:set]==:on + @ssm=[@opt.fns] + data.each do |para| + if para =~/^<<\s+(\S+?\.ss[it])$/ + loadfile=$1.strip + if (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'loading:',loadfile).txt_grey + end + tuned_file << if loadfile =~ /(?:https?|file):\/\/\S+?\.ss[ti]$/ + @ssm << loadfile + elsif loadfile =~ /\.ss[ti]$/ \ + and FileTest.file?(loadfile) + @ssm << loadfile + else + cX=SiSU_Screen::Ansi.new(@opt.act[:color_state][:set]).cX + 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 + end + @ssm + end + end +end +__END__ diff --git a/lib/sisu/v5/composite.rb b/lib/sisu/v5/composite.rb deleted file mode 100644 index 9f722799..00000000 --- a/lib/sisu/v5/composite.rb +++ /dev/null @@ -1,267 +0,0 @@ -# encoding: utf-8 -=begin - - * Name: SiSU - - * Description: a framework for document structuring, publishing and search - - * Author: Ralph Amissah - - * Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, - All Rights Reserved. - - * License: GPL 3 or later: - - SiSU, a framework for document structuring, publishing and search - - Copyright (C) Ralph Amissah - - This program is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. - - You should have received a copy of the GNU General Public License along with - this program. If not, see . - - If you have Internet connection, the latest version of the GPL should be - available at these locations: - - - - - - * SiSU uses: - * Standard SiSU markup syntax, - * Standard SiSU meta-markup syntax, and the - * Standard SiSU object citation numbering and system - - * Hompages: - - - - * Download: - - - * Git - - - - * Ralph Amissah - - - - ** Description: composite documents, assemble/build documents from other - documents or parts of marked up text - -=end -module SiSU_Assemble - require_relative 'sysenv' # sysenv.rb - class RemoteImage - def initialize - @env=SiSU_Env::InfoEnv.new - end - def image(dir) - images=[] - images[0]=dir - images - end - def download_images(images_info) - path="#{@env.processing_path.processing}/external_document/image" - FileUtils::mkdir_p(path) unless FileTest.directory?(path) - download_from=images_info.shift - images_info.each do |i| - image="#{path}/#{i}" - imagefile=File.new(image,'w+') - open("#{download_from}/#{i}") do |g| - imagefile << g.read - end - imagefile.close - end - output_path="#{@env.path.webserv}/#{@env.path.stub_pwd}/_sisu/image_external" - FileUtils::mkdir_p(output_path) unless FileTest.directory?(output_path) - SiSU_Env::SystemCall.new("#{path}/*",output_path,'q').rsync - end - end - class Composite - @@imager={} - def initialize(opt) - @opt=opt - @env=SiSU_Env::InfoEnv.new - end - def read - begin - pwd=Dir.pwd - Dir.chdir(@opt.f_pth[:pth]) - @fns_array=IO.readlines(@opt.fno,'') - assembled=insertions? - write(assembled) - Dir.chdir(pwd) - rescue - SiSU_Errors::Rescued.new($!,$@,@opt.cmd,@opt.fns).location do - __LINE__.to_s + ':' + __FILE__ - end - ensure - end - end - def write(assembled) - assembled_file=File.new("#{@env.processing_path.composite_file}/#{@opt.fnb}.ssm.sst",'w+') - assembled.each {|a| assembled_file << a } - assembled_file.close - end - def download_images(download_from,images_array) - path="#{@env.processing_path.processing}/external_document/image" - FileUtils::mkdir_p(path) unless FileTest.directory?(path) - images_array.each do |i| - image="#{path}/#{i}" - unless FileTest.exists?(image) - imagefile=File.new(image,'w+') - open("#{download_from}/#{i}") do |g| - imagefile << g.read - end - imagefile.close - end - end - end - def insertion(fni,insert_array) - file={ prepared: [], images: [] } - rgx_image=/(?:^|[^_\\])\{\s*(\S+?\.(?:png|jpg|gif))/ - file[:prepared] << "\n% |#{fni}|@|^|>>ok\n\n" - @code_flag=false - insert_array.each do |i| - @code_flag=if i =~/^code\{/ then true - elsif i =~/^\}code/ then false - else @code_flag - end - if not @code_flag \ - and i !~/^%+\s/ - i=i.gsub(/^([123]|:?[ABCD])~\? /,'% [conditional heading:] \1~ ') #off conditional heading (consider syntax) - if i =~/^@\S+?:/ - i=i.gsub(/\n/m,"\n% "). - gsub(/\n%\s+$/m,''). - gsub(/^@\S+?:/m,"\n% [imported header:] ") #off imported headers - end - end - file[:prepared] << i - if i !~/^%+\s/ \ - and i =~rgx_image - file[:images] << i.scan(rgx_image).uniq - end - end - file[:prepared] << "\n% end import" << "\n\n" - if file[:images].length > 0 - file[:images]=file[:images].flatten.uniq - file[:images].delete_if {|x| x =~/https?:\/\// } - end - file - end - def insertions? - data=@fns_array - 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])$/ - loadfile=$1.strip - src_ssm=@opt.fns.sub(/\.ssm\.sst/,'.ssm') - if (@opt.act[:verbose][:set]==:on \ - || @opt.act[:verbose_plus][:set]==:on \ - || @opt.act[:maintenance][:set]==:on) - SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'loading:',loadfile).txt_grey - end - tuned_file << if loadfile =~ /(?:https?|file):\/\/\S+?\.ss[ti]$/ # and NetTest - imagedir = /((?:https?|file):\/\/\S+?)\/[^\/]+?\.ss[ti]$/.match(loadfile).captures.join + '/_sisu/image' #watch - begin - require 'uri' - require 'open-uri' - require 'pp' - rescue LoadError - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('uri, open-uri or pp NOT FOUND (LoadError)') - end - image_uri=URI.parse(imagedir) - insert=open(loadfile) - insert_array=insert.dup - insert.close - file=insertion(loadfile,insert_array) - @@imager[image_uri] ||=[] - @@imager[image_uri] << file[:images] - file[:prepared] - elsif loadfile =~ /\.ss[ti]$/ \ - and FileTest.file?(loadfile) - insert_array=IO.readlines(loadfile,'') - file=insertion(loadfile,insert_array) - file[:prepared] - else - cX=SiSU_Screen::Ansi.new(@opt.act[:color_state][:set]).cX - 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 - end - tuned_file=tuned_file.flatten.compact - end - if @@imager.length >0 - @@imager.each do |d,i| - i=i.flatten.uniq - image_info=d + i - download_images(image_info.flatten) - end - end - tuned_file - end - end - class CompositeFileList - @@imager={} - def initialize(opt) - @opt=opt - @env=SiSU_Env::InfoEnv.new - end - def read - begin - @opt.fns=@opt.fns.gsub(/\.ssm\.sst$/,'.ssm') #FIX earlier, hub - @fns_array=IO.readlines(@opt.fns,'') - insertions? - rescue - SiSU_Errors::Rescued.new($!,$@,@opt.cmd,@opt.fns).location do - __LINE__.to_s + ':' + __FILE__ - end - ensure - end - end - def insertions? - data=@fns_array - tuned_file=[] - SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Composite Document',@opt.fno).grey_title_hi unless @opt.act[:quiet][:set]==:on - @ssm=[@opt.fns] - data.each do |para| - if para =~/^<<\s+(\S+?\.ss[it])$/ - loadfile=$1.strip - if (@opt.act[:verbose][:set]==:on \ - || @opt.act[:verbose_plus][:set]==:on \ - || @opt.act[:maintenance][:set]==:on) - SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'loading:',loadfile).txt_grey - end - tuned_file << if loadfile =~ /(?:https?|file):\/\/\S+?\.ss[ti]$/ - @ssm << loadfile - elsif loadfile =~ /\.ss[ti]$/ \ - and FileTest.file?(loadfile) - @ssm << loadfile - else - cX=SiSU_Screen::Ansi.new(@opt.act[:color_state][:set]).cX - 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 - end - @ssm - end - end -end -__END__ diff --git a/lib/sisu/v5/concordance.rb b/lib/sisu/v5/concordance.rb deleted file mode 100644 index b9030123..00000000 --- a/lib/sisu/v5/concordance.rb +++ /dev/null @@ -1,382 +0,0 @@ -# encoding: utf-8 -=begin - - * Name: SiSU - - * Description: a framework for document structuring, publishing and search - - * Author: Ralph Amissah - - * Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, - All Rights Reserved. - - * License: GPL 3 or later: - - SiSU, a framework for document structuring, publishing and search - - Copyright (C) Ralph Amissah - - This program is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. - - You should have received a copy of the GNU General Public License along with - this program. If not, see . - - If you have Internet connection, the latest version of the GPL should be - available at these locations: - - - - - - * SiSU uses: - * Standard SiSU markup syntax, - * Standard SiSU meta-markup syntax, and the - * Standard SiSU object citation numbering and system - - * Hompages: - - - - * Download: - - - * Git - - - - * Ralph Amissah - - - - ** Description: concordance file (html concordance, wordmap, linked index of - words in document) - -=end -module SiSU_Concordance - require_relative 'particulars' # particulars.rb - include SiSU_Particulars - require_relative 'sysenv' # sysenv.rb - include SiSU_Env - require_relative 'defaults' # defaults.rb - include SiSU_Viz - require_relative 'html_format' # html_format.rb - include SiSU_HTML_Format - require_relative 'html_minitoc' # html_minitoc.rb - class Source - def initialize(opt) - @opt=opt - @particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt) - end - def read - begin - @env,@md=@particulars.env,@particulars.md - @env.url.output_tell - unless @md.opt.act[:quiet][:set]==:on - tool=(@md.opt.act[:verbose][:set]==:on \ - || @md.opt.act[:verbose_plus][:set]==:on \ - || @md.opt.act[:maintenance][:set]==:on) \ - ? "#{@env.program.web_browser} #{@md.file.output_path.html_concordance.dir}/#{@md.file.base_filename.html_concordance}" - : "[#{@opt.f_pth[:lng_is]}] #{@opt.fno}" - (@md.opt.act[:verbose][:set]==:on \ - || @md.opt.act[:verbose_plus][:set]==:on \ - || @md.opt.act[:maintenance][:set]==:on) \ - ? SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"Concordance",tool).green_hi_blue - : SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Concordance',tool).green_title_hi - end - wordmax=@env.concord_max - unless @md.wc_words.nil? - if @md.wc_words < wordmax - SiSU_Concordance::Source::Words.new(@particulars).songsheet - else - SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],"concordance skipped, large document has over #{wordmax} words (#{@md.wc_words})").warn unless @md.opt.act[:quiet][:set]==:on - end - else - SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],"wc (word count) is off, concordance will be processed for all files including those over the max set size of: #{wordmax} words").warn unless @md.opt.act[:quiet][:set]==:on - SiSU_Concordance::Source::Words.new(@particulars).songsheet - end - rescue - SiSU_Errors::Rescued.new($!,$@,@md.opt.cmd,@md.fns).location do - __LINE__.to_s + ':' + __FILE__ - end - ensure - SiSU_Env::CreateSite.new(@opt.cmd).cp_css - end - end - private - class DocTitle - include SiSU_Viz - #revisit, both requires (html & xml_shared) needed for stand alone operation (sisu -w [filename]) - require_relative 'xml_shared' # xml_shared.rb - require_relative 'html' # html.rb - def initialize(particulars) - @particulars,@md=particulars,particulars.md - @data=SiSU_HTML::Source::HTML_Environment.new(particulars).tuned_file_instructions - @file=SiSU_Env::FileOp.new(@md) - @fnb=@md.fnb - @lex_button=%{SiSU home -->} - @doc_details =<
 

#{@md.title.full}

#{@md.author}

-WOK - @make=SiSU_Env::ProcessingSettings.new(@md) - end - def create - head_banner=SiSU_HTML_Format::HeadToc.new(@md) - minitoc=SiSU_HTML_MiniToc::TocMini.new(@md,@data).songsheet.join("\n") - stylesheet=SiSU_Style::CSS_HeadInfo.new(@md).stylesheet - if @make.build.manifest_minitoc? - toc='
' + minitoc + '
' - div_class='content' - else - toc='' - div_class='content0' - end - top_band=if @make.build.html_top_band? - head_banner.concordance_navigation_band - else '' - end - < - - - - SiSU created WordIndex for: #{@md.title.full} - - - - - - - - #{stylesheet.css_head_seg} - - - #{top_band} - #{toc} -
- #{@doc_details} -

Word index links are to html versions of the text the segmented version followed by the scroll (single document) version.
[For segmented text references [T1], [T2] or [T3] appearing without a link, indicates that the word appears in a title (or subtitle) of the text (that is identifiable by the appended object citation number).]

-

(The word listing/index is Case sensitive: Capitalized words appear before lower case)

-

- word (number of occurences)
linked references to word within document
- [if number of occurences exceed number of references - word occurs more than once in at least one reference. Footnote/endnotes are either assigned to the paragraph from which they are referenced or ignored, so it is relevant to check the footnotes referenced from within a paragraph as well.] -

-

- (After the page is fully loaded) you can jump directly to a word by appending a hash (#) and the word to the url for this text, (do not forget that words are case sensitive, and may be listed twice (starting with and without an upper case letter)), #your_word # [ http://[web host]/#{@fnb}/concordance.html#your_word ] -

-WOK - end - end - class Word - @@word_previous='' - def initialize(word,freq) - @word,@freq=word,freq - end - def html - w=if @word.capitalize==@@word_previous - %{\n

#{@word}

(#{@freq})

\n\t

} - else n=@word.strip.gsub(/\s+/,'_') #also need to convert extended character set to html - %{\n

#{@word}

(#{@freq})

\n\t

} - end - @@word_previous=@word.capitalize - w - end - end - class Words - require_relative 'i18n' # i18n.rb - include SiSU_i18n - require_relative 'defaults' # defaults.rb - include SiSU_Viz - require_relative 'html_format' # html_format.rb - include SiSU_HTML_Format - require_relative 'sysenv' # sysenv.rb - include SiSU_Screen - @@dp=nil - def initialize(particulars) - @particulars=particulars - begin - @env,@md,@ao_array=particulars.env,particulars.md,particulars.ao_array - @file=SiSU_Env::FileOp.new(@md) - @freq=Hash.new(0) - @dp=@@dp ||=SiSU_Env::InfoEnv.new.digest.pattern - @rxp_lv1=/^#{Mx[:lv_o]}1:/ #fix @rxp_lv # Mx[:lv_o] - @rxp_lv2=/^#{Mx[:lv_o]}2:/ #fix @rxp_lv # Mx[:lv_o] - @rxp_lv3=/^#{Mx[:lv_o]}3:/ #fix @rxp_lv # Mx[:lv_o] - @rxp_title=Regexp.new("^#{Mx[:meta_o]}title#{Mx[:meta_c]}\s*(.+?)\s*$") - @rxp_t1=Regexp.new('^T1') - @rxp_t2=Regexp.new('^T2') - @rxp_t3=Regexp.new('^T3') - @rxp_excluded1=/#{Mx[:url_o]}\S+?#{Mx[:url_c]}|#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/ - @rxp_excluded0=/^(?:#{Mx[:fa_bold_o]}|#{Mx[:fa_italics_o]})?(?:to\d+|\d+| |#{Mx[:br_endnotes]}|EOF|#{Mx[:br_eof]}|thumb_\S+|snap_\S+|_+|-+|[(]?(?:ii+|iv|vi+|ix|xi+|xiv|xv|xvi+|xix|xx)[).]?|\S+?_\S+|[\d_]+\w\S+|[\w\d]{1,2}|\d{1,3}\w?|#{@dp}|[0-9a-f]{16,64}|\d{2,3}x\d{2,3}|\S{0,2}sha\d|\S{0,3}\d{4}w\d\d|\b\w\d+|\d_all\b|e\.?g\.?)(?:#{Mx[:fa_bold_c]}|#{Mx[:fa_italics_c]})?$/mi #this regex causes and cures a stack dump in ruby 1.9 !!! - @rgx_splitlist=%r{[—.,;:#{Mx[:nbsp]}-]}mi - @alph=SiSU_i18n::Alphabet.new(@md.opt.lng).hash_arrays - @alphlst=SiSU_i18n::Alphabet.new(@md.opt.lng).hash_strings - @rgx_scanlist=%r{#{Mx[:fa_italics_o]}[#{@alphlst[:l]}#{@alphlst[:u]}0-9"\s]{2,12}#{Mx[:fa_italics_c]}|#{Mx[:fa_bold_o]}[#{@alphlst[:l]}#{@alphlst[:u]}0-9"\s]{2,12}#{Mx[:fa_bold_c]}|(?:https?|file)://\S+|<\S+?>|[#{@alphlst[:l]}#{@alphlst[:u]}]+|\w+}mi - rescue - SiSU_Errors::Rescued.new($!,$@,@md.opt.cmd,@md.fns).location do - __LINE__.to_s + ':' + __FILE__ - end - end - end - def songsheet - begin - FileUtils::mkdir_p(@file.output_path.html_concordance.dir) unless FileTest.directory?(@file.output_path.html_concordance.dir) - @file_concordance=File.open(@file.place_file.html_concordance.dir,'w') - map_para - rescue - SiSU_Errors::Rescued.new($!,$@,@md.opt.cmd,@md.fns).location do - __LINE__.to_s + ':' + __FILE__ - end - ensure - @file_concordance.close - end - end - protected - def location_scroll(wordlocation,show) # not used - %{#{wordlocation}; } - end - def location_seg(wordlocation,show) - unless wordlocation.nil? - wl=wordlocation.gsub(/(.+?)\#(\d+)/, - "\\1#{@md.lang_code_insert}#{Sfx[:html]}##{Mx[:ocn_id_char]}\\2") # id="o\d+" always available; a name="\d+" not available if html strict used - case wordlocation - when /#{@rxp_t1}|@rxp_t2}|#{@rxp_t3}/ - %{[H]#{show}, } - when /(.+?)\#(\d+)/ - %{#{show}, } - end - end - end - def map_para - @seg,ocn=nil,nil - @word_map={} - @ao_array.each do |line| - if defined? line.ocn \ - and line.ocn.to_s =~/\d/ - if (line.is ==:heading \ - || line.is ==:heading_insert) \ - && line.ln==4 - @seg=line.name - end - ocn=line.ocn.to_s - if ocn =~/\d+/ \ - and ocn !~/^0$/ - line.obj=line.obj.gsub(/#{@rxp_excluded1}/,' ') - line.obj=line.obj.split(@rgx_splitlist).join(' ') #%take in word or other match - for word in line.obj.scan(@rgx_scanlist) #%take in word or other match - if word =~ /^([#{@alphlst[:l]}])/ - firstletter=$1 - flu=firstletter.tr(@alphlst[:l],@alphlst[:u]) - word=word.gsub(/^#{firstletter}/,flu ) - end - word=word.gsub(/#{Mx[:lnk_o]}|#{Mx[:lnk_c]}|#{Mx[:url_o]}|#{Mx[:url_c]}/,''). - gsub(/#{Mx[:fa_o]}\S+?#{Mx[:fa_o_c]}/,''). - gsub(/#{Mx[:fa_c_o]}\S+?#{Mx[:fa_c]}/,''). - gsub(/#{Mx[:gl_o]}#[a-z]+#{Mx[:gl_c]}/,''). - gsub(/#{Mx[:gl_o]}#[0-9]+#{Mx[:gl_c]}/,'') - word=word.gsub(/[0-9a-f]{10,}/,' ') if word =~/[0-9]/ - word=word.gsub(/#{Mx[:br_line]}/,' '). - gsub(/^ +/,''). - gsub(/^\S$/,'') - word=nil if word.empty? - word=nil if word =~@rxp_excluded0 #watch - word=nil if word =~/^\S$/ - if word - word=word.gsub(/#{Mx[:br_nl]}|#{Mx[:br_line]}/,' '). - gsub(/#{Mx[:fa_o]}[a-z]{1,7}#{Mx[:fa_o_c]}|#{Mx[:fa_c_o]}[a-z]{1,7}#{Mx[:fa_c]}/,''). - gsub(/#{Mx[:en_a_o]}(?:\d|[*+])*|#{Mx[:en_b_o]}(?:\d|[*+])*|#{Mx[:en_a_c]}|#{Mx[:en_b_c]}/mi,''). - gsub(/#{Mx[:fa_o]}\S+?#{Mx[:fa_o_c]}/,''). - gsub(/#{Mx[:fa_c_o]}\S+?#{Mx[:fa_c]}/,''). - gsub(/<\/?\S+?>/,''). - gsub(/^\@+/,''). - strip. - gsub(/#{Mx[:tc_p]}.+/,''). - gsub(/[\.,;:"]$/,''). - gsub(/["]/,''). - gsub(/^\s*[\(]/,''). - gsub(/[\(]\s*$/,''). - gsub(/^(?:See|e\.?g\.?).+/,''). - gsub(/^\s*[.,;:]\s*/,''). - strip. - gsub(/^\(?[a-zA-Z]\)$/,''). - gsub(/^\d+(st|nd|rd|th)$/,''). - gsub(/^(\d+\.?)+$/, ''). - gsub(/#{Mx[:mk_o]}|#{Mx[:mk_c]}/,''). - gsub(/:name#\S+/,''). - gsub(/^\S$/,'') - word=nil if word =~/^\S$/ - word=nil if word =~/^\s*$/ #watch - if word - unless word =~/[A-Z][A-Z]/ \ - or word =~/\w+\s\w+/ - word=word.capitalize - end - @freq[word] +=1 - @word_map[word] ||= [] - if line !~ /#{@rxp_lv1}|#{@rxp_lv2}|#{@rxp_lv3}/ - loc_=%{#{location_seg("#{@seg}\##{ocn}",ocn).to_s}} - unless loc_.empty? - @word_map[word] << loc_ - end - else - @word_map[word] << case line - when @rxp_lv1 then location_seg('T1',ocn) #fix @rxp_lv # Mx[:lv_o] - when @rxp_lv2 then location_seg('T2',ocn) #fix @rxp_lv # Mx[:lv_o] - when @rxp_lv3 then location_seg('T3',ocn) #fix @rxp_lv # Mx[:lv_o] - end - end - end - end - end - end - end - end - seg='' - head=SiSU_Concordance::Source::DocTitle.new(@particulars).create - head=head.gsub(/#{Xx[:html_relative2]}/m,@file.path_rel_links.html_seg_2). - gsub(/#{Xx[:html_relative1]}/m,@file.path_rel_links.html_seg_1) - @file_concordance << head - @file_concordance << '

' - alph=@alph[:u] - alph.each {|x| @file_concordance << %{#{x}, }} - @file_concordance << '

' - letter=alph.shift - @file_concordance << %{\n

A

} - for word in @freq.keys.sort! {|a,b| a.downcase<=>b.downcase} - f=/^(\S)/.match(word)[1] - if letter < f.upcase - while letter < f.upcase - if alph.length > 0 - letter=alph.shift - @file_concordance << %{\n

#{letter}

} - else break - end - end - end - keyword=SiSU_Concordance::Source::Word.new(word,@freq[word]).html - if keyword !~ @rxp_excluded0 - if @word_map[word][0] =~ /\d+/ - @file_concordance << %{#{keyword}#{seg}#{@word_map[word].uniq.compact.join}} - end - @file_concordance << '

' - end - # special cases endnotes and header levels 1 - 3 - end - @file_concordance << %{
\n} # footer - if @md.opt.act[:verbose_plus][:set]==:on \ - || @md.opt.act[:maintenance][:set]==:on - SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],@md.fns,"#{@md.file.output_path.html_concordance.dir}/#{@md.file.base_filename.html_concordance}").flow - end - end - end - end -end -__END__ diff --git a/lib/sisu/v5/html_concordance.rb b/lib/sisu/v5/html_concordance.rb new file mode 100644 index 00000000..b9030123 --- /dev/null +++ b/lib/sisu/v5/html_concordance.rb @@ -0,0 +1,382 @@ +# encoding: utf-8 +=begin + + * Name: SiSU + + * Description: a framework for document structuring, publishing and search + + * Author: Ralph Amissah + + * Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. + + * License: GPL 3 or later: + + SiSU, a framework for document structuring, publishing and search + + Copyright (C) Ralph Amissah + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program. If not, see . + + If you have Internet connection, the latest version of the GPL should be + available at these locations: + + + + + + * SiSU uses: + * Standard SiSU markup syntax, + * Standard SiSU meta-markup syntax, and the + * Standard SiSU object citation numbering and system + + * Hompages: + + + + * Download: + + + * Git + + + + * Ralph Amissah + + + + ** Description: concordance file (html concordance, wordmap, linked index of + words in document) + +=end +module SiSU_Concordance + require_relative 'particulars' # particulars.rb + include SiSU_Particulars + require_relative 'sysenv' # sysenv.rb + include SiSU_Env + require_relative 'defaults' # defaults.rb + include SiSU_Viz + require_relative 'html_format' # html_format.rb + include SiSU_HTML_Format + require_relative 'html_minitoc' # html_minitoc.rb + class Source + def initialize(opt) + @opt=opt + @particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt) + end + def read + begin + @env,@md=@particulars.env,@particulars.md + @env.url.output_tell + unless @md.opt.act[:quiet][:set]==:on + tool=(@md.opt.act[:verbose][:set]==:on \ + || @md.opt.act[:verbose_plus][:set]==:on \ + || @md.opt.act[:maintenance][:set]==:on) \ + ? "#{@env.program.web_browser} #{@md.file.output_path.html_concordance.dir}/#{@md.file.base_filename.html_concordance}" + : "[#{@opt.f_pth[:lng_is]}] #{@opt.fno}" + (@md.opt.act[:verbose][:set]==:on \ + || @md.opt.act[:verbose_plus][:set]==:on \ + || @md.opt.act[:maintenance][:set]==:on) \ + ? SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"Concordance",tool).green_hi_blue + : SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Concordance',tool).green_title_hi + end + wordmax=@env.concord_max + unless @md.wc_words.nil? + if @md.wc_words < wordmax + SiSU_Concordance::Source::Words.new(@particulars).songsheet + else + SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],"concordance skipped, large document has over #{wordmax} words (#{@md.wc_words})").warn unless @md.opt.act[:quiet][:set]==:on + end + else + SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],"wc (word count) is off, concordance will be processed for all files including those over the max set size of: #{wordmax} words").warn unless @md.opt.act[:quiet][:set]==:on + SiSU_Concordance::Source::Words.new(@particulars).songsheet + end + rescue + SiSU_Errors::Rescued.new($!,$@,@md.opt.cmd,@md.fns).location do + __LINE__.to_s + ':' + __FILE__ + end + ensure + SiSU_Env::CreateSite.new(@opt.cmd).cp_css + end + end + private + class DocTitle + include SiSU_Viz + #revisit, both requires (html & xml_shared) needed for stand alone operation (sisu -w [filename]) + require_relative 'xml_shared' # xml_shared.rb + require_relative 'html' # html.rb + def initialize(particulars) + @particulars,@md=particulars,particulars.md + @data=SiSU_HTML::Source::HTML_Environment.new(particulars).tuned_file_instructions + @file=SiSU_Env::FileOp.new(@md) + @fnb=@md.fnb + @lex_button=%{SiSU home -->} + @doc_details =< 

#{@md.title.full}

#{@md.author}

+WOK + @make=SiSU_Env::ProcessingSettings.new(@md) + end + def create + head_banner=SiSU_HTML_Format::HeadToc.new(@md) + minitoc=SiSU_HTML_MiniToc::TocMini.new(@md,@data).songsheet.join("\n") + stylesheet=SiSU_Style::CSS_HeadInfo.new(@md).stylesheet + if @make.build.manifest_minitoc? + toc='
' + minitoc + '
' + div_class='content' + else + toc='' + div_class='content0' + end + top_band=if @make.build.html_top_band? + head_banner.concordance_navigation_band + else '' + end + < + + + + SiSU created WordIndex for: #{@md.title.full} + + + + + + + + #{stylesheet.css_head_seg} + + + #{top_band} + #{toc} +
+ #{@doc_details} +

Word index links are to html versions of the text the segmented version followed by the scroll (single document) version.
[For segmented text references [T1], [T2] or [T3] appearing without a link, indicates that the word appears in a title (or subtitle) of the text (that is identifiable by the appended object citation number).]

+

(The word listing/index is Case sensitive: Capitalized words appear before lower case)

+

+ word (number of occurences)
linked references to word within document
+ [if number of occurences exceed number of references - word occurs more than once in at least one reference. Footnote/endnotes are either assigned to the paragraph from which they are referenced or ignored, so it is relevant to check the footnotes referenced from within a paragraph as well.] +

+

+ (After the page is fully loaded) you can jump directly to a word by appending a hash (#) and the word to the url for this text, (do not forget that words are case sensitive, and may be listed twice (starting with and without an upper case letter)), #your_word # [ http://[web host]/#{@fnb}/concordance.html#your_word ] +

+WOK + end + end + class Word + @@word_previous='' + def initialize(word,freq) + @word,@freq=word,freq + end + def html + w=if @word.capitalize==@@word_previous + %{\n

#{@word}

(#{@freq})

\n\t

} + else n=@word.strip.gsub(/\s+/,'_') #also need to convert extended character set to html + %{\n

#{@word}

(#{@freq})

\n\t

} + end + @@word_previous=@word.capitalize + w + end + end + class Words + require_relative 'i18n' # i18n.rb + include SiSU_i18n + require_relative 'defaults' # defaults.rb + include SiSU_Viz + require_relative 'html_format' # html_format.rb + include SiSU_HTML_Format + require_relative 'sysenv' # sysenv.rb + include SiSU_Screen + @@dp=nil + def initialize(particulars) + @particulars=particulars + begin + @env,@md,@ao_array=particulars.env,particulars.md,particulars.ao_array + @file=SiSU_Env::FileOp.new(@md) + @freq=Hash.new(0) + @dp=@@dp ||=SiSU_Env::InfoEnv.new.digest.pattern + @rxp_lv1=/^#{Mx[:lv_o]}1:/ #fix @rxp_lv # Mx[:lv_o] + @rxp_lv2=/^#{Mx[:lv_o]}2:/ #fix @rxp_lv # Mx[:lv_o] + @rxp_lv3=/^#{Mx[:lv_o]}3:/ #fix @rxp_lv # Mx[:lv_o] + @rxp_title=Regexp.new("^#{Mx[:meta_o]}title#{Mx[:meta_c]}\s*(.+?)\s*$") + @rxp_t1=Regexp.new('^T1') + @rxp_t2=Regexp.new('^T2') + @rxp_t3=Regexp.new('^T3') + @rxp_excluded1=/#{Mx[:url_o]}\S+?#{Mx[:url_c]}|#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/ + @rxp_excluded0=/^(?:#{Mx[:fa_bold_o]}|#{Mx[:fa_italics_o]})?(?:to\d+|\d+| |#{Mx[:br_endnotes]}|EOF|#{Mx[:br_eof]}|thumb_\S+|snap_\S+|_+|-+|[(]?(?:ii+|iv|vi+|ix|xi+|xiv|xv|xvi+|xix|xx)[).]?|\S+?_\S+|[\d_]+\w\S+|[\w\d]{1,2}|\d{1,3}\w?|#{@dp}|[0-9a-f]{16,64}|\d{2,3}x\d{2,3}|\S{0,2}sha\d|\S{0,3}\d{4}w\d\d|\b\w\d+|\d_all\b|e\.?g\.?)(?:#{Mx[:fa_bold_c]}|#{Mx[:fa_italics_c]})?$/mi #this regex causes and cures a stack dump in ruby 1.9 !!! + @rgx_splitlist=%r{[—.,;:#{Mx[:nbsp]}-]}mi + @alph=SiSU_i18n::Alphabet.new(@md.opt.lng).hash_arrays + @alphlst=SiSU_i18n::Alphabet.new(@md.opt.lng).hash_strings + @rgx_scanlist=%r{#{Mx[:fa_italics_o]}[#{@alphlst[:l]}#{@alphlst[:u]}0-9"\s]{2,12}#{Mx[:fa_italics_c]}|#{Mx[:fa_bold_o]}[#{@alphlst[:l]}#{@alphlst[:u]}0-9"\s]{2,12}#{Mx[:fa_bold_c]}|(?:https?|file)://\S+|<\S+?>|[#{@alphlst[:l]}#{@alphlst[:u]}]+|\w+}mi + rescue + SiSU_Errors::Rescued.new($!,$@,@md.opt.cmd,@md.fns).location do + __LINE__.to_s + ':' + __FILE__ + end + end + end + def songsheet + begin + FileUtils::mkdir_p(@file.output_path.html_concordance.dir) unless FileTest.directory?(@file.output_path.html_concordance.dir) + @file_concordance=File.open(@file.place_file.html_concordance.dir,'w') + map_para + rescue + SiSU_Errors::Rescued.new($!,$@,@md.opt.cmd,@md.fns).location do + __LINE__.to_s + ':' + __FILE__ + end + ensure + @file_concordance.close + end + end + protected + def location_scroll(wordlocation,show) # not used + %{#{wordlocation}; } + end + def location_seg(wordlocation,show) + unless wordlocation.nil? + wl=wordlocation.gsub(/(.+?)\#(\d+)/, + "\\1#{@md.lang_code_insert}#{Sfx[:html]}##{Mx[:ocn_id_char]}\\2") # id="o\d+" always available; a name="\d+" not available if html strict used + case wordlocation + when /#{@rxp_t1}|@rxp_t2}|#{@rxp_t3}/ + %{[H]#{show}, } + when /(.+?)\#(\d+)/ + %{#{show}, } + end + end + end + def map_para + @seg,ocn=nil,nil + @word_map={} + @ao_array.each do |line| + if defined? line.ocn \ + and line.ocn.to_s =~/\d/ + if (line.is ==:heading \ + || line.is ==:heading_insert) \ + && line.ln==4 + @seg=line.name + end + ocn=line.ocn.to_s + if ocn =~/\d+/ \ + and ocn !~/^0$/ + line.obj=line.obj.gsub(/#{@rxp_excluded1}/,' ') + line.obj=line.obj.split(@rgx_splitlist).join(' ') #%take in word or other match + for word in line.obj.scan(@rgx_scanlist) #%take in word or other match + if word =~ /^([#{@alphlst[:l]}])/ + firstletter=$1 + flu=firstletter.tr(@alphlst[:l],@alphlst[:u]) + word=word.gsub(/^#{firstletter}/,flu ) + end + word=word.gsub(/#{Mx[:lnk_o]}|#{Mx[:lnk_c]}|#{Mx[:url_o]}|#{Mx[:url_c]}/,''). + gsub(/#{Mx[:fa_o]}\S+?#{Mx[:fa_o_c]}/,''). + gsub(/#{Mx[:fa_c_o]}\S+?#{Mx[:fa_c]}/,''). + gsub(/#{Mx[:gl_o]}#[a-z]+#{Mx[:gl_c]}/,''). + gsub(/#{Mx[:gl_o]}#[0-9]+#{Mx[:gl_c]}/,'') + word=word.gsub(/[0-9a-f]{10,}/,' ') if word =~/[0-9]/ + word=word.gsub(/#{Mx[:br_line]}/,' '). + gsub(/^ +/,''). + gsub(/^\S$/,'') + word=nil if word.empty? + word=nil if word =~@rxp_excluded0 #watch + word=nil if word =~/^\S$/ + if word + word=word.gsub(/#{Mx[:br_nl]}|#{Mx[:br_line]}/,' '). + gsub(/#{Mx[:fa_o]}[a-z]{1,7}#{Mx[:fa_o_c]}|#{Mx[:fa_c_o]}[a-z]{1,7}#{Mx[:fa_c]}/,''). + gsub(/#{Mx[:en_a_o]}(?:\d|[*+])*|#{Mx[:en_b_o]}(?:\d|[*+])*|#{Mx[:en_a_c]}|#{Mx[:en_b_c]}/mi,''). + gsub(/#{Mx[:fa_o]}\S+?#{Mx[:fa_o_c]}/,''). + gsub(/#{Mx[:fa_c_o]}\S+?#{Mx[:fa_c]}/,''). + gsub(/<\/?\S+?>/,''). + gsub(/^\@+/,''). + strip. + gsub(/#{Mx[:tc_p]}.+/,''). + gsub(/[\.,;:"]$/,''). + gsub(/["]/,''). + gsub(/^\s*[\(]/,''). + gsub(/[\(]\s*$/,''). + gsub(/^(?:See|e\.?g\.?).+/,''). + gsub(/^\s*[.,;:]\s*/,''). + strip. + gsub(/^\(?[a-zA-Z]\)$/,''). + gsub(/^\d+(st|nd|rd|th)$/,''). + gsub(/^(\d+\.?)+$/, ''). + gsub(/#{Mx[:mk_o]}|#{Mx[:mk_c]}/,''). + gsub(/:name#\S+/,''). + gsub(/^\S$/,'') + word=nil if word =~/^\S$/ + word=nil if word =~/^\s*$/ #watch + if word + unless word =~/[A-Z][A-Z]/ \ + or word =~/\w+\s\w+/ + word=word.capitalize + end + @freq[word] +=1 + @word_map[word] ||= [] + if line !~ /#{@rxp_lv1}|#{@rxp_lv2}|#{@rxp_lv3}/ + loc_=%{#{location_seg("#{@seg}\##{ocn}",ocn).to_s}} + unless loc_.empty? + @word_map[word] << loc_ + end + else + @word_map[word] << case line + when @rxp_lv1 then location_seg('T1',ocn) #fix @rxp_lv # Mx[:lv_o] + when @rxp_lv2 then location_seg('T2',ocn) #fix @rxp_lv # Mx[:lv_o] + when @rxp_lv3 then location_seg('T3',ocn) #fix @rxp_lv # Mx[:lv_o] + end + end + end + end + end + end + end + end + seg='' + head=SiSU_Concordance::Source::DocTitle.new(@particulars).create + head=head.gsub(/#{Xx[:html_relative2]}/m,@file.path_rel_links.html_seg_2). + gsub(/#{Xx[:html_relative1]}/m,@file.path_rel_links.html_seg_1) + @file_concordance << head + @file_concordance << '

' + alph=@alph[:u] + alph.each {|x| @file_concordance << %{#{x}, }} + @file_concordance << '

' + letter=alph.shift + @file_concordance << %{\n

A

} + for word in @freq.keys.sort! {|a,b| a.downcase<=>b.downcase} + f=/^(\S)/.match(word)[1] + if letter < f.upcase + while letter < f.upcase + if alph.length > 0 + letter=alph.shift + @file_concordance << %{\n

#{letter}

} + else break + end + end + end + keyword=SiSU_Concordance::Source::Word.new(word,@freq[word]).html + if keyword !~ @rxp_excluded0 + if @word_map[word][0] =~ /\d+/ + @file_concordance << %{#{keyword}#{seg}#{@word_map[word].uniq.compact.join}} + end + @file_concordance << '

' + end + # special cases endnotes and header levels 1 - 3 + end + @file_concordance << %{
\n} # footer + if @md.opt.act[:verbose_plus][:set]==:on \ + || @md.opt.act[:maintenance][:set]==:on + SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],@md.fns,"#{@md.file.output_path.html_concordance.dir}/#{@md.file.base_filename.html_concordance}").flow + end + end + end + end +end +__END__ diff --git a/lib/sisu/v5/hub.rb b/lib/sisu/v5/hub.rb index 152de391..f57274ad 100644 --- a/lib/sisu/v5/hub.rb +++ b/lib/sisu/v5/hub.rb @@ -307,7 +307,7 @@ module SiSU $process_document = :ok unless @opt.act[:po4a][:set]==:on # --po4a, -P if @opt.fno =~ /\.ssm$/ - require_relative 'composite' # composite.rb #pre-processing + require_relative 'ao_composite' # ao_composite.rb #pre-processing SiSU_Assemble::Composite.new(@opt).read end require_relative 'ao' # -m ao.rb @@ -357,7 +357,7 @@ module SiSU end end if @opt.act[:concordance][:set]==:on #% --concordance, -w - require_relative 'concordance' # concordance.rb + require_relative 'html_concordance' # html_concordance.rb SiSU_Concordance::Source.new(@opt).read end if @opt.act[:epub][:set]==:on #% --epub, -e diff --git a/lib/sisu/v5/po4a.rb b/lib/sisu/v5/po4a.rb index 990600aa..0b11600a 100644 --- a/lib/sisu/v5/po4a.rb +++ b/lib/sisu/v5/po4a.rb @@ -65,7 +65,7 @@ module SiSU_Po4a require_relative 'ao' # ao.rb require_relative 'sysenv' # sysenv.rb include SiSU_Env - require_relative 'composite' # composite.rb + require_relative 'ao_composite' # ao_composite.rb require_relative 'shared_metadata' # shared_metadata.rb require_relative 'po4a_set' # po4a_set.rb include SiSU_Param diff --git a/lib/sisu/v5/remote.rb b/lib/sisu/v5/remote.rb index e06e7b33..191b2edc 100644 --- a/lib/sisu/v5/remote.rb +++ b/lib/sisu/v5/remote.rb @@ -118,7 +118,7 @@ module SiSU_Remote rescue LoadError SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('open-uri or pp NOT FOUND (LoadError)') end - require_relative 'composite' # composite.rb + require_relative 'ao_composite' # ao_composite.rb @rgx_image=/(?:^|[^_\\])\{\s*(\S+?\.(?:png|jpg|gif))/ threads=[] for requested_page in @get_s diff --git a/lib/sisu/v6/ao_composite.rb b/lib/sisu/v6/ao_composite.rb new file mode 100644 index 00000000..f8c4b396 --- /dev/null +++ b/lib/sisu/v6/ao_composite.rb @@ -0,0 +1,267 @@ +# encoding: utf-8 +=begin + + * Name: SiSU + + * Description: a framework for document structuring, publishing and search + + * Author: Ralph Amissah + + * Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. + + * License: GPL 3 or later: + + SiSU, a framework for document structuring, publishing and search + + Copyright (C) Ralph Amissah + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program. If not, see . + + If you have Internet connection, the latest version of the GPL should be + available at these locations: + + + + + + * SiSU uses: + * Standard SiSU markup syntax, + * Standard SiSU meta-markup syntax, and the + * Standard SiSU object citation numbering and system + + * Hompages: + + + + * Download: + + + * Git + + + + * Ralph Amissah + + + + ** Description: composite documents, assemble/build documents from other + documents or parts of marked up text + +=end +module SiSU_Assemble + require_relative 'sysenv' # sysenv.rb + class RemoteImage + def initialize + @env=SiSU_Env::InfoEnv.new + end + def image(dir) + images=[] + images[0]=dir + images + end + def download_images(images_info) + path="#{@env.processing_path.processing}/external_document/image" + FileUtils::mkdir_p(path) unless FileTest.directory?(path) + download_from=images_info.shift + images_info.each do |i| + image="#{path}/#{i}" + imagefile=File.new(image,'w+') + open("#{download_from}/#{i}") do |g| + imagefile << g.read + end + imagefile.close + end + output_path="#{@env.path.webserv}/#{@env.path.stub_pwd}/_sisu/image_external" + FileUtils::mkdir_p(output_path) unless FileTest.directory?(output_path) + SiSU_Env::SystemCall.new("#{path}/*",output_path,'q').rsync + end + end + class Composite + @@imager={} + def initialize(opt) + @opt=opt + @env=SiSU_Env::InfoEnv.new + end + def read + begin + pwd=Dir.pwd + Dir.chdir(@opt.f_pth[:pth]) + @fns_array=IO.readlines(@opt.fno,'') + assembled=insertions? + write(assembled) + Dir.chdir(pwd) + rescue + SiSU_Errors::Rescued.new($!,$@,@opt.cmd,@opt.fns).location do + __LINE__.to_s + ':' + __FILE__ + end + ensure + end + end + def write(assembled) + assembled_file=File.new("#{@env.processing_path.composite_file}/#{@opt.fnb}.ssm.sst",'w+') + assembled.each {|a| assembled_file << a } + assembled_file.close + end + def download_images(download_from,images_array) + path="#{@env.processing_path.processing}/external_document/image" + FileUtils::mkdir_p(path) unless FileTest.directory?(path) + images_array.each do |i| + image="#{path}/#{i}" + unless FileTest.exists?(image) + imagefile=File.new(image,'w+') + open("#{download_from}/#{i}") do |g| + imagefile << g.read + end + imagefile.close + end + end + end + def insertion(fni,insert_array) + file={ prepared: [], images: [] } + rgx_image=/(?:^|[^_\\])\{\s*(\S+?\.(?:png|jpg|gif))/ + file[:prepared] << "\n% |#{fni}|@|^|>>ok\n\n" + @code_flag=false + insert_array.each do |i| + @code_flag=if i =~/^code\{/ then true + elsif i =~/^\}code/ then false + else @code_flag + end + if not @code_flag \ + and i !~/^%+\s/ + i=i.gsub(/^([123]|:?[ABCD])~\? /,'% [conditional heading:] \1~ ') #off conditional heading (consider syntax) + if i =~/^@\S+?:/ + i=i.gsub(/\n/m,"\n% "). + gsub(/\n%\s+$/m,''). + gsub(/^@\S+?:/m,"\n% [imported header:] ") #off imported headers + end + end + file[:prepared] << i + if i !~/^%+\s/ \ + and i =~rgx_image + file[:images] << i.scan(rgx_image).uniq + end + end + file[:prepared] << "\n% end import" << "\n\n" + if file[:images].length > 0 + file[:images]=file[:images].flatten.uniq + file[:images].delete_if {|x| x =~/https?:\/\// } + end + file + end + def insertions? + data=@fns_array + 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])$/ + loadfile=$1.strip + src_ssm=@opt.fns.sub(/\.ssm\.sst/,'.ssm') + if (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'loading:',loadfile).txt_grey + end + tuned_file << if loadfile =~ /(?:https?|file):\/\/\S+?\.ss[ti]$/ # and NetTest + imagedir = /((?:https?|file):\/\/\S+?)\/[^\/]+?\.ss[ti]$/.match(loadfile).captures.join + '/_sisu/image' #watch + begin + require 'uri' + require 'open-uri' + require 'pp' + rescue LoadError + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('uri, open-uri or pp NOT FOUND (LoadError)') + end + image_uri=URI.parse(imagedir) + insert=open(loadfile) + insert_array=insert.dup + insert.close + file=insertion(loadfile,insert_array) + @@imager[image_uri] ||=[] + @@imager[image_uri] << file[:images] + file[:prepared] + elsif loadfile =~ /\.ss[ti]$/ \ + and FileTest.file?(loadfile) + insert_array=IO.readlines(loadfile,'') + file=insertion(loadfile,insert_array) + file[:prepared] + else + cX=SiSU_Screen::Ansi.new(@opt.act[:color_state][:set]).cX + 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 + end + tuned_file=tuned_file.flatten.compact + end + if @@imager.length >0 + @@imager.each do |d,i| + i=i.flatten.uniq + image_info=d + i + download_images(image_info.flatten) + end + end + tuned_file + end + end + class CompositeFileList + @@imager={} + def initialize(opt) + @opt=opt + @env=SiSU_Env::InfoEnv.new + end + def read + begin + @opt.fns=@opt.fns.gsub(/\.ssm\.sst$/,'.ssm') #FIX earlier, hub + @fns_array=IO.readlines(@opt.fns,'') + insertions? + rescue + SiSU_Errors::Rescued.new($!,$@,@opt.cmd,@opt.fns).location do + __LINE__.to_s + ':' + __FILE__ + end + ensure + end + end + def insertions? + data=@fns_array + tuned_file=[] + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Composite Document',@opt.fno).grey_title_hi unless @opt.act[:quiet][:set]==:on + @ssm=[@opt.fns] + data.each do |para| + if para =~/^<<\s+(\S+?\.ss[it])$/ + loadfile=$1.strip + if (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'loading:',loadfile).txt_grey + end + tuned_file << if loadfile =~ /(?:https?|file):\/\/\S+?\.ss[ti]$/ + @ssm << loadfile + elsif loadfile =~ /\.ss[ti]$/ \ + and FileTest.file?(loadfile) + @ssm << loadfile + else + cX=SiSU_Screen::Ansi.new(@opt.act[:color_state][:set]).cX + 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 + end + @ssm + end + end +end +__END__ diff --git a/lib/sisu/v6/composite.rb b/lib/sisu/v6/composite.rb deleted file mode 100644 index 2afff1bf..00000000 --- a/lib/sisu/v6/composite.rb +++ /dev/null @@ -1,267 +0,0 @@ -# encoding: utf-8 -=begin - - * Name: SiSU - - * Description: a framework for document structuring, publishing and search - - * Author: Ralph Amissah - - * Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, - All Rights Reserved. - - * License: GPL 3 or later: - - SiSU, a framework for document structuring, publishing and search - - Copyright (C) Ralph Amissah - - This program is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. - - You should have received a copy of the GNU General Public License along with - this program. If not, see . - - If you have Internet connection, the latest version of the GPL should be - available at these locations: - - - - - - * SiSU uses: - * Standard SiSU markup syntax, - * Standard SiSU meta-markup syntax, and the - * Standard SiSU object citation numbering and system - - * Hompages: - - - - * Download: - - - * Git - - - - * Ralph Amissah - - - - ** Description: composite documents, assemble/build documents from other - documents or parts of marked up text - -=end -module SiSU_Assemble - require_relative 'sysenv' # sysenv.rb - class RemoteImage - def initialize - @env=SiSU_Env::InfoEnv.new - end - def image(dir) - images=[] - images[0]=dir - images - end - def download_images(images_info) - path="#{@env.processing_path.processing}/external_document/image" - FileUtils::mkdir_p(path) unless FileTest.directory?(path) - download_from=images_info.shift - images_info.each do |i| - image="#{path}/#{i}" - imagefile=File.new(image,'w+') - open("#{download_from}/#{i}") do |g| - imagefile << g.read - end - imagefile.close - end - output_path="#{@env.path.webserv}/#{@env.path.stub_pwd}/_sisu/image_external" - FileUtils::mkdir_p(output_path) unless FileTest.directory?(output_path) - SiSU_Env::SystemCall.new("#{path}/*",output_path,'q').rsync - end - end - class Composite - @@imager={} - def initialize(opt) - @opt=opt - @env=SiSU_Env::InfoEnv.new - end - def read - begin - pwd=Dir.pwd - Dir.chdir(@opt.f_pth[:pth]) - @fns_array=IO.readlines(@opt.fno,'') - assembled=insertions? - write(assembled) - Dir.chdir(pwd) - rescue - SiSU_Errors::Rescued.new($!,$@,@opt.cmd,@opt.fns).location do - __LINE__.to_s + ':' + __FILE__ - end - ensure - end - end - def write(assembled) - assembled_file=File.new("#{@env.processing_path.composite_file}/#{@opt.fnb}.ssm.sst",'w+') - assembled.each {|a| assembled_file << a } - assembled_file.close - end - def download_images(download_from,images_array) - path="#{@env.processing_path.processing}/external_document/image" - FileUtils::mkdir_p(path) unless FileTest.directory?(path) - images_array.each do |i| - image="#{path}/#{i}" - unless FileTest.exists?(image) - imagefile=File.new(image,'w+') - open("#{download_from}/#{i}") do |g| - imagefile << g.read - end - imagefile.close - end - end - end - def insertion(fni,insert_array) - file={ prepared: [], images: [] } - rgx_image=/(?:^|[^_\\])\{\s*(\S+?\.(?:png|jpg|gif))/ - file[:prepared] << "\n% |#{fni}|@|^|>>ok\n\n" - @code_flag=false - insert_array.each do |i| - @code_flag=if i =~/^code\{/ then true - elsif i =~/^\}code/ then false - else @code_flag - end - if not @code_flag \ - and i !~/^%+\s/ - i=i.gsub(/^([123]|:?[ABCD])~\? /,'% [conditional heading:] \1~ ') #off conditional heading (consider syntax) - if i =~/^@\S+?:/ - i=i.gsub(/\n/m,"\n% "). - gsub(/\n%\s+$/m,''). - gsub(/^@\S+?:/m,"\n% [imported header:] ") #off imported headers - end - end - file[:prepared] << i - if i !~/^%+\s/ \ - and i =~rgx_image - file[:images] << i.scan(rgx_image).uniq - end - end - file[:prepared] << "\n% end import" << "\n\n" - if file[:images].length > 0 - file[:images]=file[:images].flatten.uniq - file[:images].delete_if {|x| x =~/https?:\/\// } - end - file - end - def insertions? - data=@fns_array - 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])$/ - loadfile=$1.strip - src_ssm=@opt.fns.sub(/\.ssm\.sst/,'.ssm') - if (@opt.act[:verbose][:set]==:on \ - || @opt.act[:verbose_plus][:set]==:on \ - || @opt.act[:maintenance][:set]==:on) - SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'loading:',loadfile).txt_grey - end - tuned_file << if loadfile =~ /(?:https?|file):\/\/\S+?\.ss[ti]$/ # and NetTest - imagedir = /((?:https?|file):\/\/\S+?)\/[^\/]+?\.ss[ti]$/.match(loadfile).captures.join + '/_sisu/image' #watch - begin - require 'uri' - require 'open-uri' - require 'pp' - rescue LoadError - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('uri, open-uri or pp NOT FOUND (LoadError)') - end - image_uri=URI.parse(imagedir) - insert=open(loadfile) - insert_array=insert.dup - insert.close - file=insertion(loadfile,insert_array) - @@imager[image_uri] ||=[] - @@imager[image_uri] << file[:images] - file[:prepared] - elsif loadfile =~ /\.ss[ti]$/ \ - and FileTest.file?(loadfile) - insert_array=IO.readlines(loadfile,'') - file=insertion(loadfile,insert_array) - file[:prepared] - else - cX=SiSU_Screen::Ansi.new(@opt.act[:color_state][:set]).cX - 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 - end - tuned_file=tuned_file.flatten.compact - end - if @@imager.length >0 - @@imager.each do |d,i| - i=i.flatten.uniq - image_info=d + i - download_images(image_info.flatten) - end - end - tuned_file - end - end - class CompositeFileList - @@imager={} - def initialize(opt) - @opt=opt - @env=SiSU_Env::InfoEnv.new - end - def read - begin - @opt.fns=@opt.fns.gsub(/\.ssm\.sst$/,'.ssm') #FIX earlier, hub - @fns_array=IO.readlines(@opt.fns,'') - insertions? - rescue - SiSU_Errors::Rescued.new($!,$@,@opt.cmd,@opt.fns).location do - __LINE__.to_s + ':' + __FILE__ - end - ensure - end - end - def insertions? - data=@fns_array - tuned_file=[] - SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Composite Document',@opt.fno).grey_title_hi unless @opt.act[:quiet][:set]==:on - @ssm=[@opt.fns] - data.each do |para| - if para =~/^<<\s+(\S+?\.ss[it])$/ - loadfile=$1.strip - if (@opt.act[:verbose][:set]==:on \ - || @opt.act[:verbose_plus][:set]==:on \ - || @opt.act[:maintenance][:set]==:on) - SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'loading:',loadfile).txt_grey - end - tuned_file << if loadfile =~ /(?:https?|file):\/\/\S+?\.ss[ti]$/ - @ssm << loadfile - elsif loadfile =~ /\.ss[ti]$/ \ - and FileTest.file?(loadfile) - @ssm << loadfile - else - cX=SiSU_Screen::Ansi.new(@opt.act[:color_state][:set]).cX - 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 - end - @ssm - end - end -end -__END__ diff --git a/lib/sisu/v6/concordance.rb b/lib/sisu/v6/concordance.rb deleted file mode 100644 index 5422056f..00000000 --- a/lib/sisu/v6/concordance.rb +++ /dev/null @@ -1,382 +0,0 @@ -# encoding: utf-8 -=begin - - * Name: SiSU - - * Description: a framework for document structuring, publishing and search - - * Author: Ralph Amissah - - * Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, - All Rights Reserved. - - * License: GPL 3 or later: - - SiSU, a framework for document structuring, publishing and search - - Copyright (C) Ralph Amissah - - This program is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. - - You should have received a copy of the GNU General Public License along with - this program. If not, see . - - If you have Internet connection, the latest version of the GPL should be - available at these locations: - - - - - - * SiSU uses: - * Standard SiSU markup syntax, - * Standard SiSU meta-markup syntax, and the - * Standard SiSU object citation numbering and system - - * Hompages: - - - - * Download: - - - * Git - - - - * Ralph Amissah - - - - ** Description: concordance file (html concordance, wordmap, linked index of - words in document) - -=end -module SiSU_Concordance - require_relative 'particulars' # particulars.rb - include SiSU_Particulars - require_relative 'sysenv' # sysenv.rb - include SiSU_Env - require_relative 'defaults' # defaults.rb - include SiSU_Viz - require_relative 'html_format' # html_format.rb - include SiSU_HTML_Format - require_relative 'html_minitoc' # html_minitoc.rb - class Source - def initialize(opt) - @opt=opt - @particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt) - end - def read - begin - @env,@md=@particulars.env,@particulars.md - @env.url.output_tell - unless @md.opt.act[:quiet][:set]==:on - tool=(@md.opt.act[:verbose][:set]==:on \ - || @md.opt.act[:verbose_plus][:set]==:on \ - || @md.opt.act[:maintenance][:set]==:on) \ - ? "#{@env.program.web_browser} #{@md.file.output_path.html_concordance.dir}/#{@md.file.base_filename.html_concordance}" - : "[#{@opt.f_pth[:lng_is]}] #{@opt.fno}" - (@md.opt.act[:verbose][:set]==:on \ - || @md.opt.act[:verbose_plus][:set]==:on \ - || @md.opt.act[:maintenance][:set]==:on) \ - ? SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"Concordance",tool).green_hi_blue - : SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Concordance',tool).green_title_hi - end - wordmax=@env.concord_max - unless @md.wc_words.nil? - if @md.wc_words < wordmax - SiSU_Concordance::Source::Words.new(@particulars).songsheet - else - SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],"concordance skipped, large document has over #{wordmax} words (#{@md.wc_words})").warn unless @md.opt.act[:quiet][:set]==:on - end - else - SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],"wc (word count) is off, concordance will be processed for all files including those over the max set size of: #{wordmax} words").warn unless @md.opt.act[:quiet][:set]==:on - SiSU_Concordance::Source::Words.new(@particulars).songsheet - end - rescue - SiSU_Errors::Rescued.new($!,$@,@md.opt.cmd,@md.fns).location do - __LINE__.to_s + ':' + __FILE__ - end - ensure - SiSU_Env::CreateSite.new(@opt.cmd).cp_css - end - end - private - class DocTitle - include SiSU_Viz - #revisit, both requires (html & xml_shared) needed for stand alone operation (sisu -w [filename]) - require_relative 'xml_shared' # xml_shared.rb - require_relative 'html' # html.rb - def initialize(particulars) - @particulars,@md=particulars,particulars.md - @data=SiSU_HTML::Source::HTML_Environment.new(particulars).tuned_file_instructions - @file=SiSU_Env::FileOp.new(@md) - @fnb=@md.fnb - @lex_button=%{SiSU home -->} - @doc_details =< 

#{@md.title.full}

#{@md.author}

-WOK - @make=SiSU_Env::ProcessingSettings.new(@md) - end - def create - head_banner=SiSU_HTML_Format::HeadToc.new(@md) - minitoc=SiSU_HTML_MiniToc::TocMini.new(@md,@data).songsheet.join("\n") - stylesheet=SiSU_Style::CSS_HeadInfo.new(@md).stylesheet - if @make.build.manifest_minitoc? - toc='
' + minitoc + '
' - div_class='content' - else - toc='' - div_class='content0' - end - top_band=if @make.build.html_top_band? - head_banner.concordance_navigation_band - else '' - end - < - - - - SiSU created WordIndex for: #{@md.title.full} - - - - - - - - #{stylesheet.css_head_seg} - - - #{top_band} - #{toc} -
- #{@doc_details} -

Word index links are to html versions of the text the segmented version followed by the scroll (single document) version.
[For segmented text references [T1], [T2] or [T3] appearing without a link, indicates that the word appears in a title (or subtitle) of the text (that is identifiable by the appended object citation number).]

-

(The word listing/index is Case sensitive: Capitalized words appear before lower case)

-

- word (number of occurences)
linked references to word within document
- [if number of occurences exceed number of references - word occurs more than once in at least one reference. Footnote/endnotes are either assigned to the paragraph from which they are referenced or ignored, so it is relevant to check the footnotes referenced from within a paragraph as well.] -

-

- (After the page is fully loaded) you can jump directly to a word by appending a hash (#) and the word to the url for this text, (do not forget that words are case sensitive, and may be listed twice (starting with and without an upper case letter)), #your_word # [ http://[web host]/#{@fnb}/concordance.html#your_word ] -

-WOK - end - end - class Word - @@word_previous='' - def initialize(word,freq) - @word,@freq=word,freq - end - def html - w=if @word.capitalize==@@word_previous - %{\n

#{@word}

(#{@freq})

\n\t

} - else n=@word.strip.gsub(/\s+/,'_') #also need to convert extended character set to html - %{\n

#{@word}

(#{@freq})

\n\t

} - end - @@word_previous=@word.capitalize - w - end - end - class Words - require_relative 'i18n' # i18n.rb - include SiSU_i18n - require_relative 'defaults' # defaults.rb - include SiSU_Viz - require_relative 'html_format' # html_format.rb - include SiSU_HTML_Format - require_relative 'sysenv' # sysenv.rb - include SiSU_Screen - @@dp=nil - def initialize(particulars) - @particulars=particulars - begin - @env,@md,@ao_array=particulars.env,particulars.md,particulars.ao_array - @file=SiSU_Env::FileOp.new(@md) - @freq=Hash.new(0) - @dp=@@dp ||=SiSU_Env::InfoEnv.new.digest.pattern - @rxp_lv1=/^#{Mx[:lv_o]}1:/ #fix @rxp_lv # Mx[:lv_o] - @rxp_lv2=/^#{Mx[:lv_o]}2:/ #fix @rxp_lv # Mx[:lv_o] - @rxp_lv3=/^#{Mx[:lv_o]}3:/ #fix @rxp_lv # Mx[:lv_o] - @rxp_title=Regexp.new("^#{Mx[:meta_o]}title#{Mx[:meta_c]}\s*(.+?)\s*$") - @rxp_t1=Regexp.new('^T1') - @rxp_t2=Regexp.new('^T2') - @rxp_t3=Regexp.new('^T3') - @rxp_excluded1=/#{Mx[:url_o]}\S+?#{Mx[:url_c]}|#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/ - @rxp_excluded0=/^(?:#{Mx[:fa_bold_o]}|#{Mx[:fa_italics_o]})?(?:to\d+|\d+| |#{Mx[:br_endnotes]}|EOF|#{Mx[:br_eof]}|thumb_\S+|snap_\S+|_+|-+|[(]?(?:ii+|iv|vi+|ix|xi+|xiv|xv|xvi+|xix|xx)[).]?|\S+?_\S+|[\d_]+\w\S+|[\w\d]{1,2}|\d{1,3}\w?|#{@dp}|[0-9a-f]{16,64}|\d{2,3}x\d{2,3}|\S{0,2}sha\d|\S{0,3}\d{4}w\d\d|\b\w\d+|\d_all\b|e\.?g\.?)(?:#{Mx[:fa_bold_c]}|#{Mx[:fa_italics_c]})?$/mi #this regex causes and cures a stack dump in ruby 1.9 !!! - @rgx_splitlist=%r{[—.,;:#{Mx[:nbsp]}-]}mi - @alph=SiSU_i18n::Alphabet.new(@md.opt.lng).hash_arrays - @alphlst=SiSU_i18n::Alphabet.new(@md.opt.lng).hash_strings - @rgx_scanlist=%r{#{Mx[:fa_italics_o]}[#{@alphlst[:l]}#{@alphlst[:u]}0-9"\s]{2,12}#{Mx[:fa_italics_c]}|#{Mx[:fa_bold_o]}[#{@alphlst[:l]}#{@alphlst[:u]}0-9"\s]{2,12}#{Mx[:fa_bold_c]}|(?:https?|file)://\S+|<\S+?>|[#{@alphlst[:l]}#{@alphlst[:u]}]+|\w+}mi - rescue - SiSU_Errors::Rescued.new($!,$@,@md.opt.cmd,@md.fns).location do - __LINE__.to_s + ':' + __FILE__ - end - end - end - def songsheet - begin - FileUtils::mkdir_p(@file.output_path.html_concordance.dir) unless FileTest.directory?(@file.output_path.html_concordance.dir) - @file_concordance=File.open(@file.place_file.html_concordance.dir,'w') - map_para - rescue - SiSU_Errors::Rescued.new($!,$@,@md.opt.cmd,@md.fns).location do - __LINE__.to_s + ':' + __FILE__ - end - ensure - @file_concordance.close - end - end - protected - def location_scroll(wordlocation,show) # not used - %{#{wordlocation}; } - end - def location_seg(wordlocation,show) - unless wordlocation.nil? - wl=wordlocation.gsub(/(.+?)\#(\d+)/, - "\\1#{@md.lang_code_insert}#{Sfx[:html]}##{Mx[:ocn_id_char]}\\2") # id="o\d+" always available; a name="\d+" not available if html strict used - case wordlocation - when /#{@rxp_t1}|@rxp_t2}|#{@rxp_t3}/ - %{[H]#{show}, } - when /(.+?)\#(\d+)/ - %{#{show}, } - end - end - end - def map_para - @seg,ocn=nil,nil - @word_map={} - @ao_array.each do |line| - if defined? line.ocn \ - and line.ocn.to_s =~/\d/ - if (line.is ==:heading \ - || line.is ==:heading_insert) \ - && line.ln==4 - @seg=line.name - end - ocn=line.ocn.to_s - if ocn =~/\d+/ \ - and ocn !~/^0$/ - line.obj=line.obj.gsub(/#{@rxp_excluded1}/,' ') - line.obj=line.obj.split(@rgx_splitlist).join(' ') #%take in word or other match - for word in line.obj.scan(@rgx_scanlist) #%take in word or other match - if word =~ /^([#{@alphlst[:l]}])/ - firstletter=$1 - flu=firstletter.tr(@alphlst[:l],@alphlst[:u]) - word=word.gsub(/^#{firstletter}/,flu ) - end - word=word.gsub(/#{Mx[:lnk_o]}|#{Mx[:lnk_c]}|#{Mx[:url_o]}|#{Mx[:url_c]}/,''). - gsub(/#{Mx[:fa_o]}\S+?#{Mx[:fa_o_c]}/,''). - gsub(/#{Mx[:fa_c_o]}\S+?#{Mx[:fa_c]}/,''). - gsub(/#{Mx[:gl_o]}#[a-z]+#{Mx[:gl_c]}/,''). - gsub(/#{Mx[:gl_o]}#[0-9]+#{Mx[:gl_c]}/,'') - word=word.gsub(/[0-9a-f]{10,}/,' ') if word =~/[0-9]/ - word=word.gsub(/#{Mx[:br_line]}/,' '). - gsub(/^ +/,''). - gsub(/^\S$/,'') - word=nil if word.empty? - word=nil if word =~@rxp_excluded0 #watch - word=nil if word =~/^\S$/ - if word - word=word.gsub(/#{Mx[:br_nl]}|#{Mx[:br_line]}/,' '). - gsub(/#{Mx[:fa_o]}[a-z]{1,7}#{Mx[:fa_o_c]}|#{Mx[:fa_c_o]}[a-z]{1,7}#{Mx[:fa_c]}/,''). - gsub(/#{Mx[:en_a_o]}(?:\d|[*+])*|#{Mx[:en_b_o]}(?:\d|[*+])*|#{Mx[:en_a_c]}|#{Mx[:en_b_c]}/mi,''). - gsub(/#{Mx[:fa_o]}\S+?#{Mx[:fa_o_c]}/,''). - gsub(/#{Mx[:fa_c_o]}\S+?#{Mx[:fa_c]}/,''). - gsub(/<\/?\S+?>/,''). - gsub(/^\@+/,''). - strip. - gsub(/#{Mx[:tc_p]}.+/,''). - gsub(/[\.,;:"]$/,''). - gsub(/["]/,''). - gsub(/^\s*[\(]/,''). - gsub(/[\(]\s*$/,''). - gsub(/^(?:See|e\.?g\.?).+/,''). - gsub(/^\s*[.,;:]\s*/,''). - strip. - gsub(/^\(?[a-zA-Z]\)$/,''). - gsub(/^\d+(st|nd|rd|th)$/,''). - gsub(/^(\d+\.?)+$/, ''). - gsub(/#{Mx[:mk_o]}|#{Mx[:mk_c]}/,''). - gsub(/:name#\S+/,''). - gsub(/^\S$/,'') - word=nil if word =~/^\S$/ - word=nil if word =~/^\s*$/ #watch - if word - unless word =~/[A-Z][A-Z]/ \ - or word =~/\w+\s\w+/ - word=word.capitalize - end - @freq[word] +=1 - @word_map[word] ||= [] - if line !~ /#{@rxp_lv1}|#{@rxp_lv2}|#{@rxp_lv3}/ - loc_=%{#{location_seg("#{@seg}\##{ocn}",ocn).to_s}} - unless loc_.empty? - @word_map[word] << loc_ - end - else - @word_map[word] << case line - when @rxp_lv1 then location_seg('T1',ocn) #fix @rxp_lv # Mx[:lv_o] - when @rxp_lv2 then location_seg('T2',ocn) #fix @rxp_lv # Mx[:lv_o] - when @rxp_lv3 then location_seg('T3',ocn) #fix @rxp_lv # Mx[:lv_o] - end - end - end - end - end - end - end - end - seg='' - head=SiSU_Concordance::Source::DocTitle.new(@particulars).create - head=head.gsub(/#{Xx[:html_relative2]}/m,@file.path_rel_links.html_seg_2). - gsub(/#{Xx[:html_relative1]}/m,@file.path_rel_links.html_seg_1) - @file_concordance << head - @file_concordance << '

' - alph=@alph[:u] - alph.each {|x| @file_concordance << %{#{x}, }} - @file_concordance << '

' - letter=alph.shift - @file_concordance << %{\n

A

} - for word in @freq.keys.sort! {|a,b| a.downcase<=>b.downcase} - f=/^(\S)/.match(word)[1] - if letter < f.upcase - while letter < f.upcase - if alph.length > 0 - letter=alph.shift - @file_concordance << %{\n

#{letter}

} - else break - end - end - end - keyword=SiSU_Concordance::Source::Word.new(word,@freq[word]).html - if keyword !~ @rxp_excluded0 - if @word_map[word][0] =~ /\d+/ - @file_concordance << %{#{keyword}#{seg}#{@word_map[word].uniq.compact.join}} - end - @file_concordance << '

' - end - # special cases endnotes and header levels 1 - 3 - end - @file_concordance << %{
\n} # footer - if @md.opt.act[:verbose_plus][:set]==:on \ - || @md.opt.act[:maintenance][:set]==:on - SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],@md.fns,"#{@md.file.output_path.html_concordance.dir}/#{@md.file.base_filename.html_concordance}").flow - end - end - end - end -end -__END__ diff --git a/lib/sisu/v6/html_concordance.rb b/lib/sisu/v6/html_concordance.rb new file mode 100644 index 00000000..b94949b9 --- /dev/null +++ b/lib/sisu/v6/html_concordance.rb @@ -0,0 +1,382 @@ +# encoding: utf-8 +=begin + + * Name: SiSU + + * Description: a framework for document structuring, publishing and search + + * Author: Ralph Amissah + + * Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. + + * License: GPL 3 or later: + + SiSU, a framework for document structuring, publishing and search + + Copyright (C) Ralph Amissah + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program. If not, see . + + If you have Internet connection, the latest version of the GPL should be + available at these locations: + + + + + + * SiSU uses: + * Standard SiSU markup syntax, + * Standard SiSU meta-markup syntax, and the + * Standard SiSU object citation numbering and system + + * Hompages: + + + + * Download: + + + * Git + + + + * Ralph Amissah + + + + ** Description: concordance file (html concordance, wordmap, linked index of + words in document) + +=end +module SiSU_Concordance + require_relative 'particulars' # particulars.rb + include SiSU_Particulars + require_relative 'sysenv' # sysenv.rb + include SiSU_Env + require_relative 'defaults' # defaults.rb + include SiSU_Viz + require_relative 'html_format' # html_format.rb + include SiSU_HTML_Format + require_relative 'html_minitoc' # html_minitoc.rb + class Source + def initialize(opt) + @opt=opt + @particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt) + end + def read + begin + @env,@md=@particulars.env,@particulars.md + @env.url.output_tell + unless @md.opt.act[:quiet][:set]==:on + tool=(@md.opt.act[:verbose][:set]==:on \ + || @md.opt.act[:verbose_plus][:set]==:on \ + || @md.opt.act[:maintenance][:set]==:on) \ + ? "#{@env.program.web_browser} #{@md.file.output_path.html_concordance.dir}/#{@md.file.base_filename.html_concordance}" + : "[#{@opt.f_pth[:lng_is]}] #{@opt.fno}" + (@md.opt.act[:verbose][:set]==:on \ + || @md.opt.act[:verbose_plus][:set]==:on \ + || @md.opt.act[:maintenance][:set]==:on) \ + ? SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"Concordance",tool).green_hi_blue + : SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Concordance',tool).green_title_hi + end + wordmax=@env.concord_max + unless @md.wc_words.nil? + if @md.wc_words < wordmax + SiSU_Concordance::Source::Words.new(@particulars).songsheet + else + SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],"concordance skipped, large document has over #{wordmax} words (#{@md.wc_words})").warn unless @md.opt.act[:quiet][:set]==:on + end + else + SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],"wc (word count) is off, concordance will be processed for all files including those over the max set size of: #{wordmax} words").warn unless @md.opt.act[:quiet][:set]==:on + SiSU_Concordance::Source::Words.new(@particulars).songsheet + end + rescue + SiSU_Errors::Rescued.new($!,$@,@md.opt.cmd,@md.fns).location do + __LINE__.to_s + ':' + __FILE__ + end + ensure + SiSU_Env::CreateSite.new(@opt.cmd).cp_css + end + end + private + class DocTitle + include SiSU_Viz + #revisit, both requires (html & xml_shared) needed for stand alone operation (sisu -w [filename]) + require_relative 'xml_shared' # xml_shared.rb + require_relative 'html' # html.rb + def initialize(particulars) + @particulars,@md=particulars,particulars.md + @data=SiSU_HTML::Source::HTML_Environment.new(particulars).tuned_file_instructions + @file=SiSU_Env::FileOp.new(@md) + @fnb=@md.fnb + @lex_button=%{SiSU home -->} + @doc_details =< 

#{@md.title.full}

#{@md.author}

+WOK + @make=SiSU_Env::ProcessingSettings.new(@md) + end + def create + head_banner=SiSU_HTML_Format::HeadToc.new(@md) + minitoc=SiSU_HTML_MiniToc::TocMini.new(@md,@data).songsheet.join("\n") + stylesheet=SiSU_Style::CSS_HeadInfo.new(@md).stylesheet + if @make.build.manifest_minitoc? + toc='
' + minitoc + '
' + div_class='content' + else + toc='' + div_class='content0' + end + top_band=if @make.build.html_top_band? + head_banner.concordance_navigation_band + else '' + end + < + + + + SiSU created WordIndex for: #{@md.title.full} + + + + + + + + #{stylesheet.css_head_seg} + + + #{top_band} + #{toc} +
+ #{@doc_details} +

Word index links are to html versions of the text the segmented version followed by the scroll (single document) version.
[For segmented text references [T1], [T2] or [T3] appearing without a link, indicates that the word appears in a title (or subtitle) of the text (that is identifiable by the appended object citation number).]

+

(The word listing/index is Case sensitive: Capitalized words appear before lower case)

+

+ word (number of occurences)
linked references to word within document
+ [if number of occurences exceed number of references - word occurs more than once in at least one reference. Footnote/endnotes are either assigned to the paragraph from which they are referenced or ignored, so it is relevant to check the footnotes referenced from within a paragraph as well.] +

+

+ (After the page is fully loaded) you can jump directly to a word by appending a hash (#) and the word to the url for this text, (do not forget that words are case sensitive, and may be listed twice (starting with and without an upper case letter)), #your_word # [ http://[web host]/#{@fnb}/concordance.html#your_word ] +

+WOK + end + end + class Word + @@word_previous='' + def initialize(word,freq) + @word,@freq=word,freq + end + def html + w=if @word.capitalize==@@word_previous + %{\n

#{@word}

(#{@freq})

\n\t

} + else n=@word.strip.gsub(/\s+/,'_') #also need to convert extended character set to html + %{\n

#{@word}

(#{@freq})

\n\t

} + end + @@word_previous=@word.capitalize + w + end + end + class Words + require_relative 'i18n' # i18n.rb + include SiSU_i18n + require_relative 'defaults' # defaults.rb + include SiSU_Viz + require_relative 'html_format' # html_format.rb + include SiSU_HTML_Format + require_relative 'sysenv' # sysenv.rb + include SiSU_Screen + @@dp=nil + def initialize(particulars) + @particulars=particulars + begin + @env,@md,@ao_array=particulars.env,particulars.md,particulars.ao_array + @file=SiSU_Env::FileOp.new(@md) + @freq=Hash.new(0) + @dp=@@dp ||=SiSU_Env::InfoEnv.new.digest.pattern + @rxp_lv1=/^#{Mx[:lv_o]}1:/ #fix @rxp_lv # Mx[:lv_o] + @rxp_lv2=/^#{Mx[:lv_o]}2:/ #fix @rxp_lv # Mx[:lv_o] + @rxp_lv3=/^#{Mx[:lv_o]}3:/ #fix @rxp_lv # Mx[:lv_o] + @rxp_title=Regexp.new("^#{Mx[:meta_o]}title#{Mx[:meta_c]}\s*(.+?)\s*$") + @rxp_t1=Regexp.new('^T1') + @rxp_t2=Regexp.new('^T2') + @rxp_t3=Regexp.new('^T3') + @rxp_excluded1=/#{Mx[:url_o]}\S+?#{Mx[:url_c]}|#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/ + @rxp_excluded0=/^(?:#{Mx[:fa_bold_o]}|#{Mx[:fa_italics_o]})?(?:to\d+|\d+| |#{Mx[:br_endnotes]}|EOF|#{Mx[:br_eof]}|thumb_\S+|snap_\S+|_+|-+|[(]?(?:ii+|iv|vi+|ix|xi+|xiv|xv|xvi+|xix|xx)[).]?|\S+?_\S+|[\d_]+\w\S+|[\w\d]{1,2}|\d{1,3}\w?|#{@dp}|[0-9a-f]{16,64}|\d{2,3}x\d{2,3}|\S{0,2}sha\d|\S{0,3}\d{4}w\d\d|\b\w\d+|\d_all\b|e\.?g\.?)(?:#{Mx[:fa_bold_c]}|#{Mx[:fa_italics_c]})?$/mi #this regex causes and cures a stack dump in ruby 1.9 !!! + @rgx_splitlist=%r{[—.,;:#{Mx[:nbsp]}-]}mi + @alph=SiSU_i18n::Alphabet.new(@md.opt.lng).hash_arrays + @alphlst=SiSU_i18n::Alphabet.new(@md.opt.lng).hash_strings + @rgx_scanlist=%r{#{Mx[:fa_italics_o]}[#{@alphlst[:l]}#{@alphlst[:u]}0-9"\s]{2,12}#{Mx[:fa_italics_c]}|#{Mx[:fa_bold_o]}[#{@alphlst[:l]}#{@alphlst[:u]}0-9"\s]{2,12}#{Mx[:fa_bold_c]}|(?:https?|file)://\S+|<\S+?>|[#{@alphlst[:l]}#{@alphlst[:u]}]+|\w+}mi + rescue + SiSU_Errors::Rescued.new($!,$@,@md.opt.cmd,@md.fns).location do + __LINE__.to_s + ':' + __FILE__ + end + end + end + def songsheet + begin + FileUtils::mkdir_p(@file.output_path.html_concordance.dir) unless FileTest.directory?(@file.output_path.html_concordance.dir) + @file_concordance=File.open(@file.place_file.html_concordance.dir,'w') + map_para + rescue + SiSU_Errors::Rescued.new($!,$@,@md.opt.cmd,@md.fns).location do + __LINE__.to_s + ':' + __FILE__ + end + ensure + @file_concordance.close + end + end + protected + def location_scroll(wordlocation,show) # not used + %{#{wordlocation}; } + end + def location_seg(wordlocation,show) + unless wordlocation.nil? + wl=wordlocation.gsub(/(.+?)\#(\d+)/, + "\\1#{@md.lang_code_insert}#{Sfx[:html]}##{Mx[:ocn_id_char]}\\2") # id="o\d+" always available; a name="\d+" not available if html strict used + case wordlocation + when /#{@rxp_t1}|@rxp_t2}|#{@rxp_t3}/ + %{[H]#{show}, } + when /(.+?)\#(\d+)/ + %{#{show}, } + end + end + end + def map_para + @seg,ocn=nil,nil + @word_map={} + @ao_array.each do |line| + if defined? line.ocn \ + and line.ocn.to_s =~/\d/ + if (line.is ==:heading \ + || line.is ==:heading_insert) \ + && line.ln==4 + @seg=line.name + end + ocn=line.ocn.to_s + if ocn =~/\d+/ \ + and ocn !~/^0$/ + line.obj=line.obj.gsub(/#{@rxp_excluded1}/,' ') + line.obj=line.obj.split(@rgx_splitlist).join(' ') #%take in word or other match + for word in line.obj.scan(@rgx_scanlist) #%take in word or other match + if word =~ /^([#{@alphlst[:l]}])/ + firstletter=$1 + flu=firstletter.tr(@alphlst[:l],@alphlst[:u]) + word=word.gsub(/^#{firstletter}/,flu ) + end + word=word.gsub(/#{Mx[:lnk_o]}|#{Mx[:lnk_c]}|#{Mx[:url_o]}|#{Mx[:url_c]}/,''). + gsub(/#{Mx[:fa_o]}\S+?#{Mx[:fa_o_c]}/,''). + gsub(/#{Mx[:fa_c_o]}\S+?#{Mx[:fa_c]}/,''). + gsub(/#{Mx[:gl_o]}#[a-z]+#{Mx[:gl_c]}/,''). + gsub(/#{Mx[:gl_o]}#[0-9]+#{Mx[:gl_c]}/,'') + word=word.gsub(/[0-9a-f]{10,}/,' ') if word =~/[0-9]/ + word=word.gsub(/#{Mx[:br_line]}/,' '). + gsub(/^ +/,''). + gsub(/^\S$/,'') + word=nil if word.empty? + word=nil if word =~@rxp_excluded0 #watch + word=nil if word =~/^\S$/ + if word + word=word.gsub(/#{Mx[:br_nl]}|#{Mx[:br_line]}/,' '). + gsub(/#{Mx[:fa_o]}[a-z]{1,7}#{Mx[:fa_o_c]}|#{Mx[:fa_c_o]}[a-z]{1,7}#{Mx[:fa_c]}/,''). + gsub(/#{Mx[:en_a_o]}(?:\d|[*+])*|#{Mx[:en_b_o]}(?:\d|[*+])*|#{Mx[:en_a_c]}|#{Mx[:en_b_c]}/mi,''). + gsub(/#{Mx[:fa_o]}\S+?#{Mx[:fa_o_c]}/,''). + gsub(/#{Mx[:fa_c_o]}\S+?#{Mx[:fa_c]}/,''). + gsub(/<\/?\S+?>/,''). + gsub(/^\@+/,''). + strip. + gsub(/#{Mx[:tc_p]}.+/,''). + gsub(/[\.,;:"]$/,''). + gsub(/["]/,''). + gsub(/^\s*[\(]/,''). + gsub(/[\(]\s*$/,''). + gsub(/^(?:See|e\.?g\.?).+/,''). + gsub(/^\s*[.,;:]\s*/,''). + strip. + gsub(/^\(?[a-zA-Z]\)$/,''). + gsub(/^\d+(st|nd|rd|th)$/,''). + gsub(/^(\d+\.?)+$/, ''). + gsub(/#{Mx[:mk_o]}|#{Mx[:mk_c]}/,''). + gsub(/:name#\S+/,''). + gsub(/^\S$/,'') + word=nil if word =~/^\S$/ + word=nil if word =~/^\s*$/ #watch + if word + unless word =~/[A-Z][A-Z]/ \ + or word =~/\w+\s\w+/ + word=word.capitalize + end + @freq[word] +=1 + @word_map[word] ||= [] + if line !~ /#{@rxp_lv1}|#{@rxp_lv2}|#{@rxp_lv3}/ + loc_=%{#{location_seg("#{@seg}\##{ocn}",ocn).to_s}} + unless loc_.empty? + @word_map[word] << loc_ + end + else + @word_map[word] << case line + when @rxp_lv1 then location_seg('T1',ocn) #fix @rxp_lv # Mx[:lv_o] + when @rxp_lv2 then location_seg('T2',ocn) #fix @rxp_lv # Mx[:lv_o] + when @rxp_lv3 then location_seg('T3',ocn) #fix @rxp_lv # Mx[:lv_o] + end + end + end + end + end + end + end + end + seg='' + head=SiSU_Concordance::Source::DocTitle.new(@particulars).create + head=head.gsub(/#{Xx[:html_relative2]}/m,@file.path_rel_links.html_seg_2). + gsub(/#{Xx[:html_relative1]}/m,@file.path_rel_links.html_seg_1) + @file_concordance << head + @file_concordance << '

' + alph=@alph[:u] + alph.each {|x| @file_concordance << %{#{x}, }} + @file_concordance << '

' + letter=alph.shift + @file_concordance << %{\n

A

} + for word in @freq.keys.sort! {|a,b| a.downcase<=>b.downcase} + f=/^(\S)/.match(word)[1] + if letter < f.upcase + while letter < f.upcase + if alph.length > 0 + letter=alph.shift + @file_concordance << %{\n

#{letter}

} + else break + end + end + end + keyword=SiSU_Concordance::Source::Word.new(word,@freq[word]).html + if keyword !~ @rxp_excluded0 + if @word_map[word][0] =~ /\d+/ + @file_concordance << %{#{keyword}#{seg}#{@word_map[word].uniq.compact.join}} + end + @file_concordance << '

' + end + # special cases endnotes and header levels 1 - 3 + end + @file_concordance << %{
\n} # footer + if @md.opt.act[:verbose_plus][:set]==:on \ + || @md.opt.act[:maintenance][:set]==:on + SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],@md.fns,"#{@md.file.output_path.html_concordance.dir}/#{@md.file.base_filename.html_concordance}").flow + end + end + end + end +end +__END__ diff --git a/lib/sisu/v6/hub.rb b/lib/sisu/v6/hub.rb index 736fa8bc..bfe0cbe2 100644 --- a/lib/sisu/v6/hub.rb +++ b/lib/sisu/v6/hub.rb @@ -307,7 +307,7 @@ module SiSU $process_document = :ok unless @opt.act[:po4a][:set]==:on # --po4a, -P if @opt.fno =~ /\.ssm$/ - require_relative 'composite' # composite.rb #pre-processing + require_relative 'ao_composite' # ao_composite.rb #pre-processing SiSU_Assemble::Composite.new(@opt).read end require_relative 'ao' # -m ao.rb @@ -357,7 +357,7 @@ module SiSU end end if @opt.act[:concordance][:set]==:on #% --concordance, -w - require_relative 'concordance' # concordance.rb + require_relative 'html_concordance' # html_concordance.rb SiSU_Concordance::Source.new(@opt).read end if @opt.act[:epub][:set]==:on #% --epub, -e diff --git a/lib/sisu/v6/po4a.rb b/lib/sisu/v6/po4a.rb index 3f890cec..66c68fce 100644 --- a/lib/sisu/v6/po4a.rb +++ b/lib/sisu/v6/po4a.rb @@ -65,7 +65,7 @@ module SiSU_Po4a require_relative 'ao' # ao.rb require_relative 'sysenv' # sysenv.rb include SiSU_Env - require_relative 'composite' # composite.rb + require_relative 'ao_composite' # ao_composite.rb require_relative 'shared_metadata' # shared_metadata.rb require_relative 'po4a_set' # po4a_set.rb include SiSU_Param diff --git a/lib/sisu/v6/remote.rb b/lib/sisu/v6/remote.rb index ed5d7fba..37ff723f 100644 --- a/lib/sisu/v6/remote.rb +++ b/lib/sisu/v6/remote.rb @@ -118,7 +118,7 @@ module SiSU_Remote rescue LoadError SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('open-uri or pp NOT FOUND (LoadError)') end - require_relative 'composite' # composite.rb + require_relative 'ao_composite' # ao_composite.rb @rgx_image=/(?:^|[^_\\])\{\s*(\S+?\.(?:png|jpg|gif))/ threads=[] for requested_page in @get_s -- cgit v1.2.3 From 9347018753e818b49980651df3b77352c5f3792f Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Tue, 1 Jul 2014 00:45:40 -0400 Subject: v5 v6: ao, code cosmetic rearrangement --- data/doc/sisu/CHANGELOG_v5 | 6 + data/doc/sisu/CHANGELOG_v6 | 6 + lib/sisu/v5/ao.rb | 88 +++-- lib/sisu/v5/ao_character_check.rb | 9 +- lib/sisu/v5/ao_composite.rb | 70 ++-- lib/sisu/v5/ao_doc_objects.rb | 435 +++++++++++++------------ lib/sisu/v5/ao_doc_str.rb | 634 +++++++++++++++++++++++++++++------- lib/sisu/v5/ao_endnotes.rb | 34 +- lib/sisu/v5/ao_expand_insertions.rb | 48 ++- lib/sisu/v5/ao_hash_digest.rb | 22 +- lib/sisu/v5/ao_idx.rb | 194 ++++++++--- lib/sisu/v5/ao_images.rb | 26 +- lib/sisu/v5/ao_metadata.rb | 13 +- lib/sisu/v5/ao_misc_arrange.rb | 31 +- lib/sisu/v5/ao_numbering.rb | 43 ++- lib/sisu/v5/ao_syntax.rb | 66 ++-- lib/sisu/v5/hub.rb | 56 +++- lib/sisu/v5/options.rb | 36 +- lib/sisu/v5/param.rb | 154 +++++++-- lib/sisu/v6/ao.rb | 88 +++-- lib/sisu/v6/ao_character_check.rb | 9 +- lib/sisu/v6/ao_composite.rb | 70 ++-- lib/sisu/v6/ao_doc_objects.rb | 435 +++++++++++++------------ lib/sisu/v6/ao_doc_str.rb | 634 +++++++++++++++++++++++++++++------- lib/sisu/v6/ao_endnotes.rb | 34 +- lib/sisu/v6/ao_expand_insertions.rb | 48 ++- lib/sisu/v6/ao_hash_digest.rb | 22 +- lib/sisu/v6/ao_idx.rb | 194 ++++++++--- lib/sisu/v6/ao_images.rb | 26 +- lib/sisu/v6/ao_metadata.rb | 13 +- lib/sisu/v6/ao_misc_arrange.rb | 31 +- lib/sisu/v6/ao_numbering.rb | 43 ++- lib/sisu/v6/ao_syntax.rb | 66 ++-- lib/sisu/v6/hub.rb | 56 +++- lib/sisu/v6/options.rb | 36 +- lib/sisu/v6/param.rb | 154 +++++++-- 36 files changed, 2810 insertions(+), 1120 deletions(-) diff --git a/data/doc/sisu/CHANGELOG_v5 b/data/doc/sisu/CHANGELOG_v5 index 07221ecf..f4c824f5 100644 --- a/data/doc/sisu/CHANGELOG_v5 +++ b/data/doc/sisu/CHANGELOG_v5 @@ -38,6 +38,12 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_5.4.3.orig.tar.xz sisu_5.4.3.orig.tar.xz sisu_5.4.3-1.dsc +* ao, + * code cosmetic rearrangement + +* code cosmetic rearrangement + * ao*, param, hub, options, composite + * merge what was sisu_6.0.8 into v5 * ao, * syntax, able optionally to indicate the language syntax of a code block diff --git a/data/doc/sisu/CHANGELOG_v6 b/data/doc/sisu/CHANGELOG_v6 index 794edfdb..81420f21 100644 --- a/data/doc/sisu/CHANGELOG_v6 +++ b/data/doc/sisu/CHANGELOG_v6 @@ -28,6 +28,12 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_6.0.9.orig.tar.xz sisu_6.0.9.orig.tar.xz sisu_6.0.9-1.dsc +* ao, + * code cosmetic rearrangement + +* code cosmetic rearrangement + * ao*, param, hub, options, composite + %% 6.0.8.orig.tar.xz (2014-06-19:24/4) http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/sisu_6.0.8 http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/debian/sisu_6.0.8-1 diff --git a/lib/sisu/v5/ao.rb b/lib/sisu/v5/ao.rb index c69e3be9..ee99805d 100644 --- a/lib/sisu/v5/ao.rb +++ b/lib/sisu/v5/ao.rb @@ -162,7 +162,9 @@ module SiSU_AO : @opt.fns @@idx_arr[:sst]=[] end - ao=(@@idx_arr[:sst].empty?) ? read_idx_sst : @@idx_arr[:sst].dup #check + ao=(@@idx_arr[:sst].empty?) \ + ? read_idx_sst + : @@idx_arr[:sst].dup #check rescue SiSU_Errors::Rescued.new($!,$@,@opt.cmd,@opt.fns).location do __LINE__.to_s + ':' + __FILE__ @@ -181,7 +183,9 @@ module SiSU_AO : @opt.fns @@idx_arr[:tex]=[] end - ao=(@@idx_arr[:tex].empty?) ? read_idx_raw : @@idx_arr[:tex].dup #check + ao=(@@idx_arr[:tex].empty?) \ + ? read_idx_raw + : @@idx_arr[:tex].dup #check rescue SiSU_Errors::Rescued.new($!,$@,@opt.cmd,@opt.fns).location do __LINE__.to_s + ':' + __FILE__ @@ -200,7 +204,9 @@ module SiSU_AO : @opt.fns @@idx_arr[:html]=[] end - ao=(@@idx_arr[:html].empty?) ? read_idx_html : @@idx_arr[:html].dup + ao=(@@idx_arr[:html].empty?) \ + ? read_idx_html + : @@idx_arr[:html].dup rescue SiSU_Errors::Rescued.new($!,$@,@opt.cmd,@opt.fns).location do __LINE__.to_s + ':' + __FILE__ @@ -219,7 +225,9 @@ module SiSU_AO : @opt.fns @@idx_arr[:xthml]=[] end - ao=(@@idx_arr[:xhtml].empty?) ? read_idx_xhtml : @@idx_arr[:xhtml].dup + ao=(@@idx_arr[:xhtml].empty?) \ + ? read_idx_xhtml + : @@idx_arr[:xhtml].dup rescue SiSU_Errors::Rescued.new($!,$@,@opt.cmd,@opt.fns).location do __LINE__.to_s + ':' + __FILE__ @@ -238,7 +246,9 @@ module SiSU_AO : @opt.fns @@map_arr[:nametags]=[] end - ao=(@@map_arr[:nametags].empty?) ? read_map_nametags : @@map_arr[:nametags].dup + ao=(@@map_arr[:nametags].empty?) \ + ? read_map_nametags + : @@map_arr[:nametags].dup rescue SiSU_Errors::Rescued.new($!,$@,@opt.cmd,@opt.fns).location do __LINE__.to_s + ':' + __FILE__ @@ -257,7 +267,9 @@ module SiSU_AO : @opt.fns @@map_arr[:ocn_htmlseg]=[] end - ao=(@@map_arr[:ocn_htmlseg].empty?) ? read_map_ocn_htmlseg : @@map_arr[:ocn_htmlseg].dup + ao=(@@map_arr[:ocn_htmlseg].empty?) \ + ? read_map_ocn_htmlseg + : @@map_arr[:ocn_htmlseg].dup rescue SiSU_Errors::Rescued.new($!,$@,@opt.cmd,@opt.fns).location do __LINE__.to_s + ':' + __FILE__ @@ -273,8 +285,14 @@ module SiSU_AO tell=(@opt.act[:verbose][:set]==:on \ || @opt.act[:verbose_plus][:set]==:on \ || @opt.act[:maintenance][:set]==:on) \ - ? SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Document Abstraction') - : SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Document Abstraction',"[#{@opt.f_pth[:lng_is]}] #{@opt.fno}") + ? SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + 'Document Abstraction' + ) + : SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + 'Document Abstraction',"[#{@opt.f_pth[:lng_is]}] #{@opt.fno}" + ) tell.blue_title_hi end fn=(@fnx && @fnx =~/\.ss[tmi]$/) \ @@ -293,9 +311,16 @@ module SiSU_AO cf=SiSU_Env::CreateFile.new(fn) if (@opt.act[:verbose][:set]==:on \ || @opt.act[:verbose_plus][:set]==:on) - SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],@opt.fns,"~meta/#{@opt.fns}.meta").output + SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + @opt.fns, + "~meta/#{@opt.fns}.meta" + ).output elsif @opt.act[:maintenance][:set]==:on - SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"ao -> #{cf.meta}").txt_grey + SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + "ao -> #{cf.meta}" + ).txt_grey end end ao.each {|s| ao_array << s} @@ -435,7 +460,8 @@ module SiSU_AO if defined? o.ocn case o.is when :heading - filename_debug.puts "#{o.is.to_s} #{o.lv}~#{o.name} odv=#{o.odv} osp=#{o.osp} [#{o.ocn}] -->\n\t#{o.obj}" + filename_debug.puts + "#{o.is.to_s} #{o.lv}~#{o.name} odv=#{o.odv} osp=#{o.osp} [#{o.ocn}] -->\n\t#{o.obj}" end end end @@ -507,23 +533,37 @@ module SiSU_AO reset data_txt=@data data_txt= - SiSU_AO_Insertions::Insertions.new(@md,data_txt).expand_insertions? # ao_expand_insertions.rb + SiSU_AO_Insertions::Insertions.new(@md,data_txt). # ao_expand_insertions.rb + expand_insertions? data_txt= - SiSU_AO_MiscArrangeText::SI.new(@md,data_txt).prepare_text # ao_misc_arrange.rb - data_obj,metadata= - SiSU_AO_DocumentStructureExtract::Build.new(@md,data_txt).identify_parts # ao_doc_str.rb + SiSU_AO_MiscArrangeText::SI.new(@md,data_txt). # ao_misc_arrange.rb + prepare_text + data_obj, + metadata= + SiSU_AO_DocumentStructureExtract::Build.new(@md,data_txt). # ao_doc_str.rb + identify_parts data_obj= - SiSU_AO_Syntax::Markup.new(@md,data_obj).songsheet # ao_syntax.rb - data_obj,endnote_array= - SiSU_AO_CharacterCheck::Check.new(data_obj).character_check_and_oldstyle_endnote_array # ao_character_check.rb + SiSU_AO_Syntax::Markup.new(@md,data_obj).songsheet # ao_syntax.rb + data_obj, + endnote_array= + SiSU_AO_CharacterCheck::Check.new(data_obj). # ao_character_check.rb + character_check_and_oldstyle_endnote_array data_obj= - SiSU_AO_Images::Images.new(@md,data_obj).images # ao_images.rb - data_obj,tags_map,ocn_html_seg_map= - SiSU_AO_Numbering::Numbering.new(@md,data_obj).numbering_song # ao_numbering.rb - data_obj,book_index_rel,book_index_rel_html_seg,html_idx,xhtml_idx= - SiSU_AO_BookIndex::BookIndex.new(@md,data_obj,@env).indexing_song if @md.book_idx # ao_idx.rb + SiSU_AO_Images::Images.new(@md,data_obj).images # ao_images.rb + data_obj, + tags_map, + ocn_html_seg_map= + SiSU_AO_Numbering::Numbering.new(@md,data_obj). # ao_numbering.rb + numbering_song + data_obj, + book_index_rel, + book_index_rel_html_seg, + html_idx,xhtml_idx= + SiSU_AO_BookIndex::BookIndex.new(@md,data_obj,@env). # ao_idx.rb + indexing_song if @md.book_idx data_obj= - SiSU_AO_Endnotes::Endnotes.new(@md,data_obj,endnote_array).endnotes # ao_endnotes.rb + SiSU_AO_Endnotes::Endnotes.new(@md,data_obj,endnote_array). # ao_endnotes.rb + endnotes outputdata=data_obj if (@md.opt.act[:ao][:set]==:on \ || @md.opt.act[:maintenance][:set]==:on) diff --git a/lib/sisu/v5/ao_character_check.rb b/lib/sisu/v5/ao_character_check.rb index ef45679a..d32b3d4b 100644 --- a/lib/sisu/v5/ao_character_check.rb +++ b/lib/sisu/v5/ao_character_check.rb @@ -80,9 +80,9 @@ module SiSU_AO_CharacterCheck gsub(/(#{Mx[:en_a_o]})\s*\s+/,'\1 '). gsub(/(~\{\s*)\s+/,'\1 '). gsub(/ \/\//,"#{Mx[:br_line]}"). - gsub(/
/,"#{Mx[:br_line]}"). #needed by xml, xhtml etc. + gsub(/
/,"#{Mx[:br_line]}"). #needed by xml, xhtml etc. gsub(/\t/,' '). - gsub(/\342\200\231/u,"'"). #if dob =~/’/ #Avoid #‘ ’ #“ ” + gsub(/\342\200\231/u,"'"). #if dob =~/’/ #Avoid #‘ ’ #“ ” gsub(/\\copy(?:right)?\b/,'©'). gsub(/\\trademark\b|\\tm\b/,'®') dob.obj=dob.obj + "\n" @@ -91,8 +91,9 @@ module SiSU_AO_CharacterCheck when /\^~/ #% Note must do this first (earlier loop) and then enter gathered data into ~^\d+ sub_dob=dob.obj.dup @endnote_array << sub_dob.gsub(/\n/,''). - gsub(/\^~\s+(.+)\s*/,%{#{Mx[:en_a_o]}#{endnote_no} \\1 #{Mx[:en_a_c]}}). - strip + gsub(/\^~\s+(.+)\s*/, + %{#{Mx[:en_a_o]}#{endnote_no} \\1 #{Mx[:en_a_c]}}). + strip endnote_no+=1 dob=nil if dob.obj =~/\^~ .+/ #watch, removes 'binary' endnote now in endnote array for later insertion end diff --git a/lib/sisu/v5/ao_composite.rb b/lib/sisu/v5/ao_composite.rb index 9fd42672..a7d0e48c 100644 --- a/lib/sisu/v5/ao_composite.rb +++ b/lib/sisu/v5/ao_composite.rb @@ -74,7 +74,8 @@ module SiSU_Assemble end def download_images(images_info) path="#{@env.processing_path.processing}/external_document/image" - FileUtils::mkdir_p(path) unless FileTest.directory?(path) + FileUtils::mkdir_p(path) \ + unless FileTest.directory?(path) download_from=images_info.shift images_info.each do |i| image="#{path}/#{i}" @@ -85,7 +86,8 @@ module SiSU_Assemble imagefile.close end output_path="#{@env.path.webserv}/#{@env.path.stub_pwd}/_sisu/image_external" - FileUtils::mkdir_p(output_path) unless FileTest.directory?(output_path) + FileUtils::mkdir_p(output_path) \ + unless FileTest.directory?(output_path) SiSU_Env::SystemCall.new("#{path}/*",output_path,'q').rsync end end @@ -99,8 +101,8 @@ module SiSU_Assemble begin pwd=Dir.pwd Dir.chdir(@opt.f_pth[:pth]) - @fns_array=IO.readlines(@opt.fno,'') - assembled=insertions? + fns_array=IO.readlines(@opt.fno,'') + assembled=insertions?(fns_array) write(assembled) Dir.chdir(pwd) rescue @@ -141,7 +143,9 @@ module SiSU_Assemble end if not @code_flag \ and i !~/^%+\s/ - i=i.gsub(/^([123]|:?[ABCD])~\? /,'% [conditional heading:] \1~ ') #off conditional heading (consider syntax) + i=i. + gsub(/^([123]|:?[ABCD])~\? /, + '% [conditional heading:] \1~ ') #off conditional heading (consider syntax) if i =~/^@\S+?:/ i=i.gsub(/\n/m,"\n% "). gsub(/\n%\s+$/m,''). @@ -161,27 +165,36 @@ module SiSU_Assemble end file end - def insertions? - data=@fns_array + def insertions?(fns_array) 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| + 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 + fns_array.each do |para| if para =~/^<<\s+(\S+?\.ss[it])$/ loadfile=$1.strip - src_ssm=@opt.fns.sub(/\.ssm\.sst/,'.ssm') if (@opt.act[:verbose][:set]==:on \ || @opt.act[:verbose_plus][:set]==:on \ || @opt.act[:maintenance][:set]==:on) - SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'loading:',loadfile).txt_grey + SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + 'loading:', + loadfile, + ).txt_grey end - tuned_file << if loadfile =~ /(?:https?|file):\/\/\S+?\.ss[ti]$/ # and NetTest - imagedir = /((?:https?|file):\/\/\S+?)\/[^\/]+?\.ss[ti]$/.match(loadfile).captures.join + '/_sisu/image' #watch + tuned_file << if loadfile =~ /(?:https?|file):\/\/\S+?\.ss[it]$/ # and NetTest + imagedir = /((?:https?|file):\/\/\S+?)\/[^\/]+?\.ss[it]$/. + match(loadfile).captures.join + + '/_sisu/image' #watch begin require 'uri' require 'open-uri' require 'pp' rescue LoadError - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('uri, open-uri or pp NOT FOUND (LoadError)') + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). + error('uri, open-uri or pp NOT FOUND (LoadError)') end image_uri=URI.parse(imagedir) insert=open(loadfile) @@ -191,13 +204,12 @@ module SiSU_Assemble @@imager[image_uri] ||=[] @@imager[image_uri] << file[:images] file[:prepared] - elsif loadfile =~ /\.ss[ti]$/ \ + elsif loadfile =~ /\.ss[it]$/ \ and FileTest.file?(loadfile) insert_array=IO.readlines(loadfile,'') file=insertion(loadfile,insert_array) file[:prepared] else - cX=SiSU_Screen::Ansi.new(@opt.act[:color_state][:set]).cX 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 @@ -225,8 +237,8 @@ module SiSU_Assemble def read begin @opt.fns=@opt.fns.gsub(/\.ssm\.sst$/,'.ssm') #FIX earlier, hub - @fns_array=IO.readlines(@opt.fns,'') - insertions? + fns_array=IO.readlines(@opt.fns,'') + insertions?(fns_array) rescue SiSU_Errors::Rescued.new($!,$@,@opt.cmd,@opt.fns).location do __LINE__.to_s + ':' + __FILE__ @@ -234,26 +246,32 @@ module SiSU_Assemble ensure end end - def insertions? - data=@fns_array + def insertions?(fns_array) tuned_file=[] - SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Composite Document',@opt.fno).grey_title_hi unless @opt.act[:quiet][:set]==:on + SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + 'Composite Document', + @opt.fno + ).grey_title_hi unless @opt.act[:quiet][:set]==:on @ssm=[@opt.fns] - data.each do |para| + fns_array.each do |para| if para =~/^<<\s+(\S+?\.ss[it])$/ loadfile=$1.strip if (@opt.act[:verbose][:set]==:on \ || @opt.act[:verbose_plus][:set]==:on \ || @opt.act[:maintenance][:set]==:on) - SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'loading:',loadfile).txt_grey + SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + 'loading:', + loadfile, + ).txt_grey end - tuned_file << if loadfile =~ /(?:https?|file):\/\/\S+?\.ss[ti]$/ + tuned_file << if loadfile =~ /(?:https?|file):\/\/\S+?\.ss[it]$/ @ssm << loadfile - elsif loadfile =~ /\.ss[ti]$/ \ + elsif loadfile =~ /\.ss[it]$/ \ and FileTest.file?(loadfile) @ssm << loadfile else - cX=SiSU_Screen::Ansi.new(@opt.act[:color_state][:set]).cX 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 diff --git a/lib/sisu/v5/ao_doc_objects.rb b/lib/sisu/v5/ao_doc_objects.rb index dd0a44cd..1357ee90 100644 --- a/lib/sisu/v5/ao_doc_objects.rb +++ b/lib/sisu/v5/ao_doc_objects.rb @@ -74,10 +74,10 @@ module SiSU_AO_DocumentStructure @of=:meta end def metadata(tags) - of= @of #Symbol, classification - group - is= :meta #Symbol, classification - specific type - tags= tags || ((defined? o.tags) ? o.tags : {}) #String, metadata type/tag - obj= nil + of = @of #Symbol, classification - group + is = :meta #Symbol, classification - specific type + tags = tags || ((defined? o.tags) ? o.tags : {}) #String, metadata type/tag + obj = nil @of,@is,@tags,@obj=of,is,tags,obj self end @@ -89,12 +89,12 @@ module SiSU_AO_DocumentStructure @of=:meta end def metadata(h,o=nil) - of= @of #Symbol, classification - group - is= :meta #Symbol, classification - specific type - 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, sha512, sha256 or md5 + of = @of #Symbol, classification - group + is = :meta #Symbol, classification - specific type + 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, sha512, sha256 or md5 @of,@is,@tag,@obj,@digest,@tmp=of,is,tag,obj,digest,tmp self end @@ -142,44 +142,47 @@ module SiSU_AO_DocumentStructure and (h[:ln] and h[:ln].to_s=~/[0-9]/) h[:lv]=heading_lv(h[:ln]) end - of= @of #Symbol, classification - group - is= :heading #Symbol, classification - specific type - name= h[:name] || ((defined? o.name) ? o.name : nil) #String, named object? - tags= h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any - obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content - idx= h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? - ocn= h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects - odv= h[:odv] || ((defined? o.odv) ? o.odv : nil) - osp= h[:osp] || ((defined? o.osp) ? o.osp : nil) - node= h[:node] || ((defined? o.node) ? o.node : nil) #[Node relationship doc structure info] - parent= h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] - 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) - 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 - autonum_= if h[:autonum_].nil? then ((defined? o.autonum_) ? o.autonum_ : true) #Bool? auto-numbering if requested default on, false suppresses - 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, 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,@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 + of = @of #Symbol, classification - group + is = :heading #Symbol, classification - specific type + name = h[:name] || ((defined? o.name) ? o.name : nil) #String, named object? + tags = h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any + obj = h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content + idx = h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? + ocn = h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects + odv = h[:odv] || ((defined? o.odv) ? o.odv : nil) + osp = h[:osp] || ((defined? o.osp) ? o.osp : nil) + node = h[:node] || ((defined? o.node) ? o.node : nil) #[Node relationship doc structure info] + parent = h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] + 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) + 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? + ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider + else h[:ocn_] + end + autonum_ = if h[:autonum_].nil? + ((defined? o.autonum_) ? o.autonum_ : true) #Bool? auto-numbering if requested default on, false suppresses + 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, 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,@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) heading(h,o=nil) - @is= :heading_insert #String, classification - specific type + @is = :heading_insert #String, classification - specific type self end end @@ -191,52 +194,56 @@ module SiSU_AO_DocumentStructure @tags=[] end def paragraph(h,o=nil) - of= @of #Symbol, classification - group - is= :para #Symbol, classification - specific type - name= h[:name] || ((defined? o.name) ? o.name : nil) #String, named object? - tags= h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any - obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content - idx= h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? - ocn= h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects - odv= h[:odv] || ((defined? o.odv) ? o.odv : nil) - osp= h[:osp] || ((defined? o.osp) ? o.osp : nil) - parent= h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] - indent= h[:indent].to_s || ((defined? o.indent) ? o.indent.to_s : nil) #Integer, indent level - hang= h[:hang].to_s || ((defined? o.hang) ? o.hang.to_s : nil) #Integer, hanging indent level - bullet_=h[:bullet_] || ((defined? o.bullet_) ? o.bullet_ : false) #Bool, bulleted? - quote_= h[:quote_] || ((defined? o.quote_) ? o.quote_ : false) #Bool, quote (blockquote)? - note_= h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) - image_= h[:image_] || ((defined? o.image_) ? o.image_ : false) #Bool, images? (processing optimization) - 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_] + of = @of #Symbol, classification - group + is = :para #Symbol, classification - specific type + name = h[:name] || ((defined? o.name) ? o.name : nil) #String, named object? + tags = h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any + obj = h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content + idx = h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? + ocn = h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects + odv = h[:odv] || ((defined? o.odv) ? o.odv : nil) + osp = h[:osp] || ((defined? o.osp) ? o.osp : nil) + parent = h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] + indent = h[:indent].to_s || ((defined? o.indent) ? o.indent.to_s : nil) #Integer, indent level + hang = h[:hang].to_s || ((defined? o.hang) ? o.hang.to_s : nil) #Integer, hanging indent level + bullet_ = h[:bullet_] || ((defined? o.bullet_) ? o.bullet_ : false) #Bool, bulleted? + quote_ = h[:quote_] || ((defined? o.quote_) ? o.quote_ : false) #Bool, quote (blockquote)? + note_ = h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) + image_ = h[:image_] || ((defined? o.image_) ? o.image_ : false) #Bool, images? (processing optimization) + ocn_ = if h[:ocn_].nil? + ((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, 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_,@quote_,@idx,@ocn,@odv,@osp,@parent,@image_,@note_,@ocn_,@digest,@tmp=of,is,name,tags,obj,indent,hang,bullet_,quote_,idx,ocn,odv,osp,parent,image_,note_,ocn_,digest,tmp + 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_,@quote_,@idx,@ocn,@odv,@osp,@parent,@image_,@note_,@ocn_,@digest,@tmp= + of, is, name, tags, obj, indent, hang, bullet_, quote_, idx, ocn, odv, osp, parent, image_, note_, ocn_, digest, tmp self end def docinfo(h,o=nil) - of= @of #String, classification - group - is= :docinfo #String, classification - specific type - name= h[:name] || ((defined? o.name) ? o.name : nil) #String, named object? - tags= h[:tags] || ((defined? o.tags) ? o.tags : nil) #Array, associated object tags, names if any - obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content - idx= nil #String, book index provided? - ocn= nil #Integer, sequential on substantive-content objects - odv= h[:odv] || ((defined? o.odv) ? o.odv : nil) - osp= h[:osp] || ((defined? o.osp) ? o.osp : nil) - parent= h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] - indent= nil #Integer, indent level - hang= nil #Integer, indent level - bullet_=false #Bool, bulleted? - note_= false #Bool, endnotes/footnotes? (processing optimization) - image_= h[:image_] || ((defined? o.image_) ? o.image_ : false) #Bool, images? (processing optimization) - 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_] + of = @of #String, classification - group + is = :docinfo #String, classification - specific type + name = h[:name] || ((defined? o.name) ? o.name : nil) #String, named object? + tags = h[:tags] || ((defined? o.tags) ? o.tags : nil) #Array, associated object tags, names if any + obj = h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content + idx = nil #String, book index provided? + ocn = nil #Integer, sequential on substantive-content objects + odv = h[:odv] || ((defined? o.odv) ? o.odv : nil) + osp = h[:osp] || ((defined? o.osp) ? o.osp : nil) + parent = h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] + indent = nil #Integer, indent level + hang = nil #Integer, indent level + bullet_ = false #Bool, bulleted? + note_ = false #Bool, endnotes/footnotes? (processing optimization) + image_ = h[:image_] || ((defined? o.image_) ? o.image_ : false) #Bool, images? (processing optimization) + ocn_ = if h[:ocn_].nil? + ((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, 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 + 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 end end @@ -248,124 +255,136 @@ module SiSU_AO_DocumentStructure @tags=[] end def code(h,o=nil) - of= @of #Symbol, classification - group #alt 'code' - is= :code #Symbol, classification - specific type - tags= h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any - obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content - lngsyn= h[:lngsyn] || ((defined? o.lngsyn) ? o.lngsyn : :txt) #symbol, code lngsyn - idx= h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? - ocn= h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects - odv= h[:odv] || ((defined? o.odv) ? o.odv : nil) - osp= h[:osp] || ((defined? o.osp) ? o.osp : nil) - parent= h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] - number_= h[:number_] || ((defined? o.number_) ? o.number_ : false) #Bool, numbered or not? - note_= h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) - 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_] + of = @of #Symbol, classification - group #alt 'code' + is = :code #Symbol, classification - specific type + tags = h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any + obj = h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content + lngsyn = h[:lngsyn] || ((defined? o.lngsyn) ? o.lngsyn : :txt) #symbol, code lngsyn + idx = h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? + ocn = h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects + odv = h[:odv] || ((defined? o.odv) ? o.odv : nil) + osp = h[:osp] || ((defined? o.osp) ? o.osp : nil) + parent = h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] + number_ = h[:number_] || ((defined? o.number_) ? o.number_ : false) #Bool, numbered or not? + note_ = h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) + ocn_ = if h[:ocn_].nil? + ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider + else h[:ocn_] end - num= h[:num] || ((defined? o.num) ? o.num : nil) - digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, sha512, sha256 or md5 - tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use - @of,@is,@tags,@obj,@lngsyn,@idx,@ocn,@odv,@osp,@parent,@number_,@note_,@ocn_,@num,@digest,@tmp=of,is,tags,obj,lngsyn,idx,ocn,odv,osp,parent,number_,note_,ocn_,num,digest,tmp + num = h[:num] || ((defined? o.num) ? o.num : nil) + 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,@lngsyn,@idx,@ocn,@odv,@osp,@parent,@number_,@note_,@ocn_,@num,@digest,@tmp= + of, is, tags, obj, lngsyn, idx, ocn, odv, osp, parent, number_, note_, ocn_, num, digest, tmp self end def box(h,o=nil) - of= @of #Symbol, classification - group - is= :box #Symbol, classification - specific type - tags= h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any - obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content - idx= h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? - ocn= h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects - odv= h[:odv] || ((defined? o.odv) ? o.odv : nil) - osp= h[:osp] || ((defined? o.osp) ? o.osp : nil) - parent= h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] - note_= h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) - 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_] + of = @of #Symbol, classification - group + is = :box #Symbol, classification - specific type + tags = h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any + obj = h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content + idx = h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? + ocn = h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects + odv = h[:odv] || ((defined? o.odv) ? o.odv : nil) + osp = h[:osp] || ((defined? o.osp) ? o.osp : nil) + parent = h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] + note_ = h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) + ocn_ = if h[:ocn_].nil? + ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider + else h[:ocn_] end - num= h[:num] || ((defined? o.num) ? o.num : nil) - digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, 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 + num = h[:num] || ((defined? o.num) ? o.num : nil) + 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 end def block(h,o=nil) - of= @of #Symbol, classification - group - is= :block #Symbol, classification - specific type - tags= h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any - obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content - idx= h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? - ocn= h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects - odv= h[:odv] || ((defined? o.odv) ? o.odv : nil) - osp= h[:osp] || ((defined? o.osp) ? o.osp : nil) - parent= h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] - note_= h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) - 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_] + of = @of #Symbol, classification - group + is = :block #Symbol, classification - specific type + tags = h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any + obj = h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content + idx = h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? + ocn = h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects + odv = h[:odv] || ((defined? o.odv) ? o.odv : nil) + osp = h[:osp] || ((defined? o.osp) ? o.osp : nil) + parent = h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] + note_ = h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) + ocn_ = if h[:ocn_].nil? + ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider + else h[:ocn_] end - num= h[:num] || ((defined? o.num) ? o.num : nil) - digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, 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 + num = h[:num] || ((defined? o.num) ? o.num : nil) + 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 end def group(h,o=nil) - of= @of #Symbol, classification - group - is= :group #Symbol, classification - specific type - tags= h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any - obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content - idx= h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? - ocn= h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects - odv= h[:odv] || ((defined? o.odv) ? o.odv : nil) - osp= h[:osp] || ((defined? o.osp) ? o.osp : nil) - parent= h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] - note_= h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) - 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_] + of = @of #Symbol, classification - group + is = :group #Symbol, classification - specific type + tags = h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any + obj = h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content + idx = h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? + ocn = h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects + odv = h[:odv] || ((defined? o.odv) ? o.odv : nil) + osp = h[:osp] || ((defined? o.osp) ? o.osp : nil) + parent = h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] + note_ = h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) + ocn_ = if h[:ocn_].nil? + ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider + else h[:ocn_] end - num= h[:num] || ((defined? o.num) ? o.num : nil) - digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, 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 + num = h[:num] || ((defined? o.num) ? o.num : nil) + 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 end - def alt(h,o=nil) #see block - of= @of #Symbol, classification - group - is= :alt #Symbol, classification - specific type - tags= h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any - obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content - idx= h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? - ocn= h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects - odv= h[:odv] || ((defined? o.odv) ? o.odv : nil) - osp= h[:osp] || ((defined? o.osp) ? o.osp : nil) - parent= h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] - note_= h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) - 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_] + def alt(h,o=nil) #see block + of = @of #Symbol, classification - group + is = :alt #Symbol, classification - specific type + tags = h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any + obj = h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content + idx = h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? + ocn = h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects + odv = h[:odv] || ((defined? o.odv) ? o.odv : nil) + osp = h[:osp] || ((defined? o.osp) ? o.osp : nil) + parent = h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] + note_ = h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) + ocn_ = if h[:ocn_].nil? + ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider + else h[:ocn_] end - num= h[:num] || ((defined? o.num) ? o.num : nil) - digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, 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 + num = h[:num] || ((defined? o.num) ? o.num : nil) + 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 end - def verse(h,o=nil) #part of poem decide how you deal with this - of= @of #Symbol, classification - group - is= :verse #Symbol, classification - specific type - tags= h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any - obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content - idx= h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? - ocn= h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects - odv= h[:odv] || ((defined? o.odv) ? o.odv : nil) - osp= h[:osp] || ((defined? o.osp) ? o.osp : nil) - parent= h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] - 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_] + def verse(h,o=nil) #part of poem decide how you deal with this + of = @of #Symbol, classification - group + is = :verse #Symbol, classification - specific type + tags = h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any + obj = h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content + idx = h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? + ocn = h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects + odv = h[:odv] || ((defined? o.odv) ? o.odv : nil) + osp = h[:osp] || ((defined? o.osp) ? o.osp : nil) + parent = h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] + ocn_ = if h[:ocn_].nil? + ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider + else h[:ocn_] end - num= h[:num] || ((defined? o.num) ? o.num : nil) - digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, 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 + num = h[:num] || ((defined? o.num) ? o.num : nil) + 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 self end @@ -378,26 +397,28 @@ module SiSU_AO_DocumentStructure @tags=[] end def table(h,o=nil) - of= @of #Symbol, classification - group - is= :table #Symbol, classification - specific type - tags= h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any - cols= h[:cols] || ((defined? o.cols) ? o.cols : nil) - widths= h[:widths] || ((defined? o.widths) ? o.widths : nil) - obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content - idx= h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? - ocn= h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects - odv= h[:odv] || ((defined? o.odv) ? o.odv : nil) - osp= h[:osp] || ((defined? o.osp) ? o.osp : nil) - parent= h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] - head_= h[:head_] || ((defined? o.head_) ? o.head_ : false) - note_= h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) - 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_] + of = @of #Symbol, classification - group + is = :table #Symbol, classification - specific type + tags = h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any + cols = h[:cols] || ((defined? o.cols) ? o.cols : nil) + widths = h[:widths] || ((defined? o.widths) ? o.widths : nil) + obj = h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content + idx = h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? + ocn = h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects + odv = h[:odv] || ((defined? o.odv) ? o.odv : nil) + osp = h[:osp] || ((defined? o.osp) ? o.osp : nil) + parent = h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] + head_ = h[:head_] || ((defined? o.head_) ? o.head_ : false) + note_ = h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) + ocn_ = if h[:ocn_].nil? + ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider + else h[:ocn_] end - num= h[:num] || ((defined? o.num) ? o.num : nil) - digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, 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 + num = h[:num] || ((defined? o.num) ? o.num : nil) + 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 end end @@ -420,8 +441,9 @@ module SiSU_AO_DocumentStructure osp= h[:osp] || ((defined? o.osp) ? o.osp : nil) parent= h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] note_= h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) - 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_] + ocn_=if h[:ocn_].nil? + ((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, sha512, sha256 or md5 tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use @@ -507,7 +529,8 @@ module SiSU_AO_DocumentStructure attr= h[:attr] || ((defined? o.attr) ? o.attr : nil) #String, text content tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use num= h[:num] || ((defined? o.num) ? o.num : nil) - @of,@is,@obj,@sym,@attr,@tmp,@num=of,is,obj,sym,attr,tmp,num + @of,@is,@obj,@sym,@attr,@tmp,@num= + of, is, obj, sym, attr, tmp, num self end end diff --git a/lib/sisu/v5/ao_doc_str.rb b/lib/sisu/v5/ao_doc_str.rb index e5ed0fd0..9743f794 100644 --- a/lib/sisu/v5/ao_doc_str.rb +++ b/lib/sisu/v5/ao_doc_str.rb @@ -154,12 +154,18 @@ module SiSU_AO_DocumentStructureExtract [0,0] end obj=if str2 =~/^(.+?)\s+\\\\(?:\s+|\n)/ - str2.gsub(/^(.+?)(\s+\\\\(?:\s+|\n))/,"#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}\\2") + str2.gsub(/^(.+?)(\s+\\\\(?:\s+|\n))/, + "#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}\\2") else - str2.gsub(/^(.+?)\n/,"#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}\n") + str2.gsub(/^(.+?)\n/, + "#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}\n") end hang,indent=hang_indent[0],hang_indent[1] - [hang,indent,obj] + [ + hang, + indent, + obj, + ] end def endnote_test?(str) (str=~/~\{.+?\}~|~\[.+?\]~/) \ @@ -182,7 +188,10 @@ module SiSU_AO_DocumentStructureExtract t.gsub!(/[^a-z0-9._-]/,'') end end - [str,tags] + [ + str, + tags, + ] end def rgx_idx_ocn_seg @rgx_idx_ocn_seg=/(.+?)\s*[+](\d+)/ @@ -196,9 +205,13 @@ module SiSU_AO_DocumentStructureExtract idx_couplet_tmp=[] idx_couplet=idx.scan(/\s*[^:]+\s*/) if idx_couplet[1] =~/[|]/ - idx_couplet_tmp << idx_couplet[0] << idx_couplet[1].scan(/\s*[^|]+\s*/) + idx_couplet_tmp << + idx_couplet[0] << + idx_couplet[1].scan(/\s*[^|]+\s*/) else - idx_couplet_tmp << idx_couplet[0] << [idx_couplet[1]] + idx_couplet_tmp << + idx_couplet[0] << + [idx_couplet[1]] end idx_couplet=idx_couplet_tmp else [idx] @@ -207,14 +220,17 @@ module SiSU_AO_DocumentStructureExtract idx_lst.each do |term_node| case term_node when String - term_node=term_node[0].chr.capitalize + term_node[1,term_node.length] + term_node= + term_node[0].chr.capitalize + + term_node[1,term_node.length] term_node=(term_node =~/.+?[+]\d+/) \ ? term_node : (term_node + '+0') term_nodes << term_node use,plus=rgx_idx_ocn_seg.match(term_node)[1,2] @use=use.strip - idx_hash[@use]={ sub: [], plus: plus } unless idx_hash[@use] and defined? idx_hash[@use] + idx_hash[@use]= + { sub: [], plus: plus } unless idx_hash[@use] and defined? idx_hash[@use] when Array subterm_nodes=[] term_node.each do |subterm_node| @@ -223,15 +239,20 @@ module SiSU_AO_DocumentStructureExtract : (subterm_node + '+0') subterm_nodes << subterm_node sub,sub_plus=rgx_idx_ocn_seg.match(subterm_node)[1,2] - idx_hash[@use]={ sub: [], plus: 0 } unless idx_hash[@use] and defined? idx_hash[@use] - idx_hash[@use][:sub] << {sub.strip => { plus: sub_plus }} + idx_hash[@use]= + { sub: [], plus: 0 } unless idx_hash[@use] and defined? idx_hash[@use] + idx_hash[@use][:sub] << + { sub.strip => { plus: sub_plus } } end term_nodes << subterm_nodes end end idx_array << term_nodes end - { hash: idx_hash, array: idx_array } + { + hash: idx_hash, + array: idx_array, + } end def identify_parts tuned_file=[] @@ -252,16 +273,26 @@ module SiSU_AO_DocumentStructureExtract h=case $1 when /[+]/ @@flag[:ocn]=:on - {flag: :ocn_on} + { + flag: :ocn_on, + } when /[~]/ @@flag[:ocn]=:ocn_off_headings_keep - {flag: :ocn_off, mod: :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} + { + flag: :ocn_off, + mod: :headings_exclude, + } else @@flag[:ocn]=:on - {flag: :ocn_on} + { + flag: :ocn_on, + } end t_o=SiSU_AO_DocumentStructure::ObjectFlag.new.flag_ocn(h) next @@ -296,7 +327,7 @@ module SiSU_AO_DocumentStructureExtract t_o=nil when /^%+\s/ #comment t_o=if t_o=~/^%+\s+(.+)/ - h={obj: $1} + h={ obj: $1 } SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) else nil end @@ -319,7 +350,13 @@ module SiSU_AO_DocumentStructureExtract end end end - h={ lv: lv, ln: ln, obj: obj, idx: idx, tags: tags } + h={ + lv: lv, + ln: ln, + obj: obj, + idx: idx, + tags: tags, + } SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h) elsif t_o=~/^:?[A-D1-6]\~(\S+?)-\s+(.+)/m name,obj=$1,$2 @@ -337,7 +374,14 @@ module SiSU_AO_DocumentStructureExtract end end end - h={ lv: lv, name: name, obj: obj, idx: idx, autonum_: false, tags: tags} + h={ + lv: lv, + name: name, + obj: obj, + idx: idx, + autonum_: false, + tags: tags, + } SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h) elsif t_o=~/^:?[A-D1-6]\~(\S+)\s+(.+)/m name,obj=$1,$2 @@ -355,7 +399,13 @@ module SiSU_AO_DocumentStructureExtract end end end - h={ lv: lv, name: name, obj: obj, idx: idx, tags: tags } + h={ + lv: lv, + name: name, + obj: obj, + idx: idx, + tags: tags, + } SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h) else nil end @@ -378,7 +428,17 @@ module SiSU_AO_DocumentStructureExtract obj << ' ~#' end end - h={ bullet_: bullet, hang: hang, indent: indent, obj: obj, idx: idx, note_: note, image_: image, tags: tags, quote: quotes? } + h={ + bullet_: bullet, + hang: hang, + indent: indent, + obj: obj, + idx: idx, + note_: note, + image_: image, + tags: tags, + quote: quotes?, + } SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h) end else nil @@ -401,7 +461,16 @@ module SiSU_AO_DocumentStructureExtract obj << ' ~#' end end - h={ hang: hang, indent: indent, obj: obj, idx: idx, note_: note, image_: image, tags: tags, quote: quotes? } + h={ + hang: hang, + indent: indent, + obj: obj, + idx: idx, + note_: note, + image_: image, + tags: tags, + quote: quotes?, + } SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h) end else nil @@ -425,7 +494,17 @@ module SiSU_AO_DocumentStructureExtract end end unless obj=~/\A\s*\Z/m - h={ bullet_: false, indent: 0, hang: 0, obj: obj, idx: idx, note_: note, image_: image, tags: tags, quote: quotes? } + h={ + bullet_: false, + indent: 0, + hang: 0, + obj: obj, + idx: idx, + note_: note, + image_: image, + tags: tags, + quote: quotes?, + } SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h) end end @@ -447,9 +526,17 @@ module SiSU_AO_DocumentStructureExtract else :txt end @@counter=1 - @codeblock_numbered=(t_o =~/^(?:code(?:\.[a-z][0-9a-z_]+)?\{#|```[ ]+code(?:\.[a-z][0-9a-z_]+)?\s[#])/) ? true : false + @codeblock_numbered= + (t_o =~/^(?:code(?:\.[a-z][0-9a-z_]+)?\{#|```[ ]+code(?:\.[a-z][0-9a-z_]+)?\s[#])/) \ + ? true + : false @num_id[:code_block] +=1 - h={ obj: '', sym: :code_block_open, num: @num_id[:code_block], syntax: @@flag[:lngsyn] } + h={ + obj: '', + sym: :code_block_open, + num: @num_id[:code_block], + syntax: @@flag[:lngsyn], + } t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) elsif t_o =~/^(?:poem\{|```[ ]+poem)/ @@flag[:poem]=case t_o @@ -458,58 +545,86 @@ module SiSU_AO_DocumentStructureExtract else @@flag[:poem] #error end @num_id[:poem] +=1 - h={ obj: '', sym: :poem_open, num: @num_id[:poem] } + h={ + obj: '', + sym: :poem_open, + num: @num_id[:poem], + } t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) tuned_file << t_o elsif t_o =~/^(?:box(?:\.[a-z_]+)?\{|```[ ]+box(?:\.[a-z_]+)?)/ @@flag[:box]=case t_o when /^box\{/ then :curls when /^```[ ]+box/ then :tics - else @@flag[:box] #error + else @@flag[:box] #error end @num_id[:box] +=1 - h={ obj: '', sym: :box_open, num: @num_id[:box] } + h={ + obj: '', + sym: :box_open, + num: @num_id[:box], + } t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) tuned_file << t_o elsif t_o =~/^(?:group\{|```[ ]+group)/ @@flag[:group]=case t_o when /^group\{/ then :curls when /^```[ ]+group/ then :tics - else @@flag[:group] #error + else @@flag[:group] #error end @num_id[:group] +=1 - h={ obj: '', sym: :group_open, num: @num_id[:group] } + h={ + obj: '', + sym: :group_open, + num: @num_id[:group], + } t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) tuned_file << t_o elsif t_o =~/^(?:block\{|```[ ]+block)/ @@flag[:block]=case t_o when /^block\{/ then :curls when /^```[ ]+block/ then :tics - else @@flag[:block] #error + else @@flag[:block] #error end @num_id[:block] +=1 - h={ obj: '', sym: :block_open, num: @num_id[:block] } + h={ + obj: '', + sym: :block_open, + num: @num_id[:block], + } t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) tuned_file << t_o elsif t_o =~/^(?:alt\{|```[ ]+alt)/ @@flag[:alt]=case t_o when /^alt\{/ then :curls when /^```[ ]+alt/ then :tics - else @@flag[:alt] #error + else @@flag[:alt] #error end @num_id[:alt] +=1 - h={ obj: '', sym: :alt_open, num: @num_id[:alt] } + h={ + obj: '', + sym: :alt_open, + num: @num_id[:alt], + } t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) tuned_file << t_o elsif t_o =~/^`:quote_open`/ @@flag[:quote]=:open @num_id[:quote] +=1 - h={ obj: '', sym: :quote_open, num: @num_id[:quote] } + h={ + obj: '', + sym: :quote_open, + num: @num_id[:quote], + } t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) #tuned_file << t_o #% find second source, entered twice, should be once so closed off here elsif t_o =~/^(?:table\{|```[ ]+table|\{table)[ ~]/ @num_id[:table] +=1 - h={ obj: '', sym: :table_open, num: @num_id[:table] } + h={ + obj: '', + sym: :table_open, + num: @num_id[:table], + } ins_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) tuned_file << ins_o if t_o=~/^table\{(?:~h)?\s+/ @@ -525,7 +640,12 @@ module SiSU_AO_DocumentStructureExtract col=$2.scan(/\d+/) heading=false end - @h={ head_: heading, cols: cols, widths: col, idx: idx } + @h={ + head_: heading, + cols: cols, + widths: col, + idx: idx, + } elsif t_o=~/^```[ ]+table(?:~h)?\s+c\d+/ @@flag[:table]=:tics @rows='' @@ -539,7 +659,12 @@ module SiSU_AO_DocumentStructureExtract col=$2.scan(/\d+/) heading=false end - @h={ head_: heading, cols: cols, widths: col, idx: idx } + @h={ + head_: heading, + cols: cols, + widths: col, + idx: idx, + } elsif t_o=~/^\{table(?:~h)?(?:\s+\d+;?)?\}\n.+\Z/m m1,m2,hd=nil,nil,nil tbl=/^\{table(?:~h)?(?:\s+\d+;?)?\}\n(.+)\Z/m.match(t_o)[1] @@ -550,7 +675,7 @@ module SiSU_AO_DocumentStructureExtract cols=nil rws.each do |r| cols=(cols ? cols : (r.scan('|').length) +1) - r=r.gsub(/\s*\|\s*/m,"#{Mx[:tc_p]}") #r.gsub!(/\|/m,"#{Mx[:tc_p]}") + r=r.gsub(/\s*\|\s*/m,"#{Mx[:tc_p]}") #r.gsub!(/\|/m,"#{Mx[:tc_p]}") rows += r + Mx[:tc_c] end col=[] @@ -563,18 +688,30 @@ module SiSU_AO_DocumentStructureExtract width=100.00/cols cols.times { col << width } end - h={ head_: hd, cols: cols, widths: col, obj: rows, idx: idx, tags: tags, num: @num_id[:table] } + h={ + head_: hd, + cols: cols, + widths: col, + obj: rows, + idx: idx, + tags: tags, + num: @num_id[:table], + } t_o=SiSU_AO_DocumentStructure::ObjectTable.new.table(h) unless h.nil? tuned_file << t_o - h={ obj: '', sym: :table_close, num: @num_id[:table] } + h={ + obj: '', + sym: :table_close, + num: @num_id[:table], + } t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) t_o elsif t_o=~/^```[ ]+table(?:~h)?\s+/ m1,m2,hd=nil,nil,nil h=case t_o - when /^```[ ]+table~h\s+(.+?)\n(.+)\Z/m #two table representations should be consolidated as one + when /^```[ ]+table~h\s+(.+?)\n(.+)\Z/m #two table representations should be consolidated as one m1,tbl,hd=$1,$2,true - when /^```[ ]+table\s+(.+?)\n(.+)\Z/m #two table representations should be consolidated as one + when /^```[ ]+table\s+(.+?)\n(.+)\Z/m #two table representations should be consolidated as one m1,tbl,hd=$1,$2,false else nil end @@ -583,13 +720,25 @@ module SiSU_AO_DocumentStructureExtract rws=tbl.split(/\n/) rows='' rws.each do |r| - r=r.gsub(/\s*\|\s*/m,"#{Mx[:tc_p]}") #r.gsub!(/\|/m,"#{Mx[:tc_p]}") + r=r.gsub(/\s*\|\s*/m,"#{Mx[:tc_p]}") #r.gsub!(/\|/m,"#{Mx[:tc_p]}") rows += r + Mx[:tc_c] end - h={ head_: hd, cols: col.length, widths: col, obj: rows, idx: idx, tags: tags, num: @num_id[:table] } + h={ + head_: hd, + cols: col.length, + widths: col, + obj: rows, + idx: idx, + tags: tags, + num: @num_id[:table], + } t_o=SiSU_AO_DocumentStructure::ObjectTable.new.table(h) unless h.nil? tuned_file << t_o - h={ obj: '', sym: :table_close, num: @num_id[:table] } + h={ + obj: '', + sym: :table_close, + num: @num_id[:table], + } t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) t_o elsif t_o=~/^\{table(?:~h)?\s+/ @@ -606,13 +755,25 @@ module SiSU_AO_DocumentStructureExtract rws=tbl.split(/\n/) rows='' rws.each do |r| - r=r.gsub(/\s*\|\s*/m,"#{Mx[:tc_p]}") #r.gsub!(/\|/m,"#{Mx[:tc_p]}") + r=r.gsub(/\s*\|\s*/m,"#{Mx[:tc_p]}") #r.gsub!(/\|/m,"#{Mx[:tc_p]}") rows += r + Mx[:tc_c] end - h={ head_: hd, cols: col.length, widths: col, obj: rows, idx: idx, tags: tags, num: @num_id[:table] } + h={ + head_: hd, + cols: col.length, + widths: col, + obj: rows, + idx: idx, + tags: tags, + num: @num_id[:table], + } t_o=SiSU_AO_DocumentStructure::ObjectTable.new.table(h) unless h.nil? tuned_file << t_o - h={ obj: '', sym: :table_close, num: @num_id[:table] } + h={ + obj: '', + sym: :table_close, + num: @num_id[:table], + } t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) t_o end @@ -626,11 +787,21 @@ module SiSU_AO_DocumentStructureExtract and t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) @@flag[:table]=:off headings,columns,widths,idx=@h[:head_],@h[:cols],@h[:widths],@h[:idx] - @h={ head_: headings, cols: columns, widths: widths, idx: idx, obj: @rows } + @h={ + head_: headings, + cols: columns, + widths: widths, + idx: idx, + obj: @rows, + } t_o=SiSU_AO_DocumentStructure::ObjectTable.new.table(@h) tuned_file << t_o @h,@rows=nil,'' - h={ obj: '', sym: :table_close, num: @num_id[:table] } + h={ + obj: '', + sym: :table_close, + num: @num_id[:table], + } t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) t_o else @@ -650,12 +821,22 @@ module SiSU_AO_DocumentStructureExtract @tuned_code[-1].gsub!(/\s*(?:#{Mx[:br_line]}|#{Mx[:br_nl]})\s*\Z/m,'') obj=@tuned_code.join("\n") tags=[] - h={ obj: obj, syntax: @@flag[:lngsyn], tags: tags, num: @num_id[:code_block], number_: @codeblock_numbered } + h={ + obj: obj, + syntax: @@flag[:lngsyn], + tags: tags, + num: @num_id[:code_block], + number_: @codeblock_numbered, + } @@flag[:lngsyn]=:txt t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.code(h) @tuned_code=[] tuned_file << t_o - h={ obj: '', sym: :code_close, num: @num_id[:code_block] } + h={ + obj: '', + sym: :code_close, + num: @num_id[:code_block], + } t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) end if (@@flag[:code]==:curls or @@flag[:code]==:tics) \ @@ -676,55 +857,102 @@ module SiSU_AO_DocumentStructureExtract if (@@flag[:poem]==:curls and t_o =~/^\}poem/) \ or (@@flag[:poem]==:tics and t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) @@flag[:poem]=:off - h={ obj: '', sym: :poem_close, num: @num_id[:poem] } + h={ + obj: '', + sym: :poem_close, + num: @num_id[:poem], + } t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) elsif (@@flag[:box]==:curls and t_o =~/^\}box/) \ or (@@flag[:box]==:tics and t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) @@flag[:box]=:off obj,tags=extract_tags(@tuned_block.join("\n")) - h={ obj: obj, tags: tags, num: @num_id[:box] } + h={ + obj: obj, + tags: tags, + num: @num_id[:box], + } @tuned_block=[] t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.box(h) tuned_file << t_o - h={ obj: '', sym: :box_close, num: @num_id[:box] } + h={ + obj: '', + sym: :box_close, + num: @num_id[:box], + } t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) elsif (@@flag[:group]==:curls and t_o =~/^\}group/) \ or (@@flag[:group]==:tics and t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) @@flag[:group]=:off obj,tags=extract_tags(@tuned_block.join("\n")) - h={ obj: obj, tags: tags, num: @num_id[:group] } + h={ + obj: obj, + tags: tags, + num: @num_id[:group], + } @tuned_block=[] t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.group(h) tuned_file << t_o - h={ obj: '', sym: :group_close, num: @num_id[:group] } + h={ + obj: '', + sym: :group_close, + num: @num_id[:group], + } t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) elsif (@@flag[:block]==:curls and t_o =~/^\}block/) \ or (@@flag[:block]==:tics and t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) @@flag[:block]=:off obj,tags=extract_tags(@tuned_block.join("\n")) - h={ obj: obj, tags: tags, num: @num_id[:block] } + h={ + obj: obj, + tags: tags, + num: @num_id[:block], + } @tuned_block=[] t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.block(h) tuned_file << t_o - h={ obj: '', sym: :block_close, num: @num_id[:block] } + h={ obj: '', + sym: :block_close, + num: @num_id[:block], + } t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) elsif (@@flag[:alt]==:curls and t_o =~/^\}alt/) \ or (@@flag[:alt]==:tics and t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) @@flag[:alt]=:off obj,tags=extract_tags(@tuned_block.join("\n")) - h={ obj: obj, tags: tags, num: @num_id[:alt] } + h={ + obj: obj, + tags: tags, + num: @num_id[:alt], + } t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.alt(h) @tuned_block=[] tuned_file << t_o - h={ obj: '', sym: :alt_close, num: @num_id[:alt] } + h={ + obj: '', + sym: :alt_close, + num: @num_id[:alt], + } t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) elsif @@flag[:quote]==:open and t_o =~/`:quote_close`/m @@flag[:quote]=:off - h={ obj: '', sym: :quote_close, num: @num_id[:quote] } + h={ + obj: '', + sym: :quote_close, + num: @num_id[:quote], + } t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) elsif @@flag[:quote]==:open t_o,tags=extract_tags(t_o) - h={ indent: 1, obj: t_o, idx: idx, note_: note, image_: image, tags: tags, quote: quotes? } + h={ + indent: 1, + obj: t_o, + idx: idx, + note_: note, + image_: image, + tags: tags, + quote: quotes?, + } SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h) end if (@@flag[:poem]==:curls or @@flag[:poem]==:tics \ @@ -741,7 +969,11 @@ module SiSU_AO_DocumentStructureExtract poem.each do |v| v=v.gsub(/\n/m,"#{Mx[:br_nl]}\n") obj,tags=extract_tags(v) - h={ obj: obj, tags: tags, num: @num_id[:poem] } + h={ + obj: obj, + tags: tags, + num: @num_id[:poem], + } t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.verse(h) tuned_file << t_o end @@ -779,26 +1011,67 @@ module SiSU_AO_DocumentStructureExtract end if @md.flag_endnotes tuned_file << @pb - h={ ln: 1, lc: 1, obj: 'Endnotes', autonum_: false } + h={ + ln: 1, + lc: 1, + obj: 'Endnotes', + autonum_: false, + } tuned_file << SiSU_AO_DocumentStructure::ObjectHeading.new.heading_insert(h) - h={ ln: 4, lc: 2, obj: 'Endnotes', name: 'endnotes', autonum_: false } + h={ + ln: 4, + lc: 2, + obj: 'Endnotes', + name: 'endnotes', + autonum_: false, + } tuned_file << SiSU_AO_DocumentStructure::ObjectHeading.new.heading_insert(h) - h={ obj: 'Endnotes' } + h={ + obj: 'Endnotes' + } end if @md.book_idx tuned_file << @pb - h={ ln: 1, lc: 1, obj: 'Index', autonum_: false } + h={ + ln: 1, + lc: 1, + obj: 'Index', + autonum_: false, + } tuned_file << SiSU_AO_DocumentStructure::ObjectHeading.new.heading_insert(h) - h={ ln: 4, lc: 2, obj: 'Index', name: 'book_index', autonum_: false } + h={ + ln: 4, + lc: 2, + obj: 'Index', + name: 'book_index', + autonum_: false, + } tuned_file << SiSU_AO_DocumentStructure::ObjectHeading.new.heading_insert(h) - h={ obj: 'Index' } + h={ + obj: 'Index' + } end tuned_file << @pb - h={ ln: 1, lc: 1, obj: 'Metadata', autonum_: false, ocn_: false } + h={ + ln: 1, + lc: 1, + obj: 'Metadata', + autonum_: false, + ocn_: false, + } tuned_file << SiSU_AO_DocumentStructure::ObjectHeading.new.heading_insert(h) - h={ ln: 4, lc: 2, obj: 'SiSU Metadata, document information', name: 'metadata', autonum_: false, ocn_: false } + h={ + ln: 4, + lc: 2, + obj: 'SiSU Metadata, document information', + name: 'metadata', + autonum_: false, + ocn_: false, + } tuned_file << SiSU_AO_DocumentStructure::ObjectHeading.new.heading_insert(h) - h={ obj: 'eof' } + h={ + obj: 'eof', + } meta=SiSU_AO_DocumentStructure::ObjectMetadata.new.metadata(@metadata) [tuned_file,meta] end @@ -811,11 +1084,20 @@ module SiSU_AO_DocumentStructureExtract table end def meta_heading(h) - h={ lv: h[:lv], ln: h[:ln], name: h[:name], obj: h[:obj], ocn: '0' } + h={ + lv: h[:lv], + ln: h[:ln], + name: h[:name], + obj: h[:obj], + ocn: '0', + } SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h) end def meta_para(str) - h={ obj: str, ocn_: false } + h={ + obj: str, + ocn_: false, + } SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h) end def build_lines(type=:none) @@ -831,7 +1113,7 @@ module SiSU_AO_DocumentStructureExtract line=line.gsub(/^/,"#{Mx[:gr_o]}codeline#{Mx[:gr_c]}") if type==:code # REMOVE try sort for texpdf special case line=if line =~/(?:https?|file|ftp):\/\/\S+$/ line.gsub(/\s*$/," #{Mx[:br_nl]}") - else line.gsub(/\s*$/,"#{Mx[:br_nl]}") #unless type=='code' + else line.gsub(/\s*$/,"#{Mx[:br_nl]}") #unless type=='code' end elsif line =~/^\s*$/ line.gsub(/\s*$/,"#{Mx[:br_nl]}") @@ -857,25 +1139,46 @@ module SiSU_AO_DocumentStructureExtract and not @dob.bullet_ @dob=case @dob.obj when /^#{@md.lv0}/ - h={ lv: 'A', ln: 0 } + h={ + lv: 'A', + ln: 0, + } SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,@dob) when /^#{@md.lv1}/ - h={ lv: 'B', ln: 1 } + h={ + lv: 'B', + ln: 1, + } SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,@dob) when /^#{@md.lv2}/ - h={ lv: 'C', ln: 2 } + h={ + lv: 'C', + ln: 2, + } SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,@dob) when /^#{@md.lv3}/ - h={ lv: 'D', ln: 3 } + h={ + lv: 'D', + ln: 3, + } SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,@dob) when /^#{@md.lv4}/ - h={ lv: '1', ln: 4 } + h={ + lv: '1', + ln: 4, + } SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,@dob) when /^#{@md.lv5}/ - h={ lv: '2', ln: 5 } + h={ + lv: '2', + ln: 5, + } SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,@dob) when /^#{@md.lv6}/ - h={ lv: '3', ln: 6 } + h={ + lv: '3', + ln: 6, + } SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,@dob) else @dob end @@ -1269,7 +1572,8 @@ SKIPPED processing file: [#{@md.opt.lng}] "#{@md.fns}"} end if dob.is==:heading if ocn_flag==true - 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 + 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 heading_use=:ok @@ -1280,19 +1584,22 @@ SKIPPED processing file: [#{@md.opt.lng}] "#{@md.fns}"} 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 + 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 \ && dob.of !=:comment \ && dob.of !=:layout if ocn_flag == true - dob.ocn,dob.ocn_,dob.odv,dob.osp,dob.parent=ocn,ocn_flag,ocn_dv,ocn_sp,parent + dob.ocn,dob.ocn_,dob.odv,dob.osp,dob.parent= + ocn, ocn_flag,ocn_dv, ocn_sp, parent 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.ocn,dob.ocn_,dob.odv,dob.osp,dob.parent=nil,ocn_flag,ocn_dv,ocn_sp,parent + dob.ocn,dob.ocn_,dob.odv,dob.osp,dob.parent= + nil, ocn_flag,ocn_dv, ocn_sp, parent end end end @@ -1340,7 +1647,10 @@ SKIPPED processing file: [#{@md.opt.lng}] "#{@md.fns}"} data=@data tuned_file=[] hs=[0,false,false,false] - t={ lv: @s[0], status: :open } + t={ + lv: @s[0], + status: :open, + } tuned_file << tags(t) if @md.opt.act[:verbose_plus][:set]==:on puts "\nXML sisu structure outline --->\n" @@ -1432,7 +1742,13 @@ SKIPPED processing file: [#{@md.opt.lng}] "#{@md.fns}"} when '5' then 8 when '6' then 9 end - h={ tag: tag, node: o[:node], lv: o[:lv], ln: ln, status: o[:status] } + h={ + tag: tag, + node: o[:node], + lv: o[:lv], + ln: ln, + status: o[:status], + } SiSU_AO_DocumentStructure::ObjectStructure.new.xml_dom(h) #downstream code utilise else ignore like comments end def tag_open(o,tag) @@ -1445,121 +1761,205 @@ SKIPPED processing file: [#{@md.opt.lng}] "#{@md.fns}"} case hs[0] when 0 if (lev <= 0) and hs[0] - t={ lv: @s[0], status: :close } + t={ + lv: @s[0], + status: :close, + } ary << tags(t) end when 1 if (lev <= 1) and hs[1] - t={ lv: @s[1], status: :close } + t={ + lv: @s[1], + status: :close, + } ary << tags(t) end if (lev==0) - t={ lv: @s[0], status: :close } + t={ + lv: @s[0], + status: :close, + } ary << tags(t) end when 2 if (lev <= 2) and hs[2] - t={ lv: @s[2], status: :close } + t={ + lv: @s[2], + status: :close, + } ary << tags(t) end if (lev <= 1) and hs[1] - t={ lv: @s[1], status: :close } + t={ + lv: @s[1], + status: :close, + } ary << tags(t) end if (lev==0) - t={ lv: @s[0], status: :close } + t={ + lv: @s[0], + status: :close, + } ary << tags(t) end when 3 if (lev <= 3) and hs[3] - t={ lv: @s[3], status: :close } + t={ + lv: @s[3], + status: :close, + } ary << tags(t) end if (lev <= 2) and hs[2] - t={ lv: @s[2], status: :close } + t={ + lv: @s[2], + status: :close, + } ary << tags(t) end if (lev <= 1) and hs[1] - t={ lv: @s[1], status: :close } + t={ + lv: @s[1], + status: :close, + } ary << tags(t) end if (lev==0) - t={ lv: @s[0], status: :close } + t={ + lv: @s[0], + status: :close, + } ary << tags(t) end when 4 if (lev <= 4) - t={ lv: @s[4], status: :close } + t={ + lv: @s[4], + status: :close, + } ary << tags(t) end if (lev <= 3) and hs[3] - t={ lv: @s[3], status: :close } + t={ + lv: @s[3], + status: :close, + } ary << tags(t) end if (lev <= 2) and hs[2] - t={ lv: @s[2], status: :close } + t={ + lv: @s[2], + status: :close, + } ary << tags(t) end if (lev <= 1) and hs[1] - t={ lv: @s[1], status: :close } + t={ + lv: @s[1], + status: :close, + } ary << tags(t) end if (lev==0) - t={ lv: @s[0], status: :close } + t={ + lv: @s[0], + status: :close, + } ary << tags(t) end when 5 if (lev <= 5) - t={ lv: @s[5], status: :close } + t={ + lv: @s[5], + status: :close, + } ary << tags(t) end if (lev <= 4) - t={ lv: @s[4], status: :close } + t={ + lv: @s[4], + status: :close, + } ary << tags(t) end if (lev <= 3) and hs[3] - t={ lv: @s[3], status: :close } + t={ + lv: @s[3], + status: :close, + } ary << tags(t) end if (lev <= 2) and hs[2] - t={ lv: @s[2], status: :close } + t={ + lv: @s[2], + status: :close, + } ary << tags(t) end if (lev <= 1) and hs[1] - t={ lv: @s[1], status: :close } + t={ + lv: @s[1], + status: :close, + } ary << tags(t) end if (lev==0) - t={ lv: @s[0], status: :close } + t={ + lv: @s[0], + status: :close, + } ary << tags(t) end when 6 if (lev <= 6) - t={ lv: @s[6], status: :close } + t={ + lv: @s[6], + status: :close, + } ary << tags(t) end if (lev <= 5) - t={ lv: @s[5], status: :close } + t={ + lv: @s[5], + status: :close, + } ary << tags(t) end if (lev <= 4) - t={ lv: @s[4], status: :close } + t={ + lv: @s[4], + status: :close, + } ary << tags(t) end if (lev <= 3) and hs[3] - t={ lv: @s[3], status: :close } + t={ + lv: @s[3], + status: :close, + } ary << tags(t) end if (lev <= 2) and hs[2] - t={ lv: @s[2], status: :close } + t={ + lv: @s[2], + status: :close, + } ary << tags(t) end if (lev <= 1) and hs[1] - t={ lv: @s[1], status: :close } + t={ + lv: @s[1], + status: :close, + } ary << tags(t) end if (lev==0) - t={ lv: @s[0], status: :close } + t={ + lv: @s[0], + status: :close, + } ary << tags(t) end end diff --git a/lib/sisu/v5/ao_endnotes.rb b/lib/sisu/v5/ao_endnotes.rb index a662370c..5517cd87 100644 --- a/lib/sisu/v5/ao_endnotes.rb +++ b/lib/sisu/v5/ao_endnotes.rb @@ -63,8 +63,12 @@ module SiSU_AO_Endnotes class Endnotes def initialize(md,data,endnote_array=nil) - @md,@data,@endnote_array=md,data,endnote_array - @endnote_counter,@endnote_counter_asterisk,@endnote_counter_dag=1,1,1 + @md,@data,@endnote_array= + md, data, endnote_array + @endnote_counter, + @endnote_counter_asterisk, + @endnote_counter_dag= + 1,1,1 end def endnotes data=@data @@ -73,17 +77,20 @@ module SiSU_AO_Endnotes data.each do |dob| # manually numbered endnotes --> if @md.opt.mod.inspect =~/--no-asterisk|--no-annotate/ - dob.obj=dob.obj.gsub(/#{Mx[:en_b_o]}\s.+?#{Mx[:en_b_c]}/,'') + dob.obj=dob.obj. + gsub(/#{Mx[:en_b_o]}\s.+?#{Mx[:en_b_c]}/,'') end if @md.opt.mod.inspect =~/--no-dagger|--no-annotate/ - dob.obj=dob.obj.gsub(/#{Mx[:en_b_o]}[+]\s.+?#{Mx[:en_b_c]}/,'') + dob.obj=dob.obj. + gsub(/#{Mx[:en_b_o]}[+]\s.+?#{Mx[:en_b_c]}/,'') end if (defined? dob.obj) \ && (defined? dob.is) \ && dob.is !=:code case dob.obj # auto-numbered endnotes --> when /#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}[*+]\s+.+?#{Mx[:en_b_c]}/ - dob.obj=dob.obj.gsub(/\s*(#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/,'\1') + dob.obj=dob.obj. + gsub(/\s*(#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/,'\1') word_mode=dob.obj.scan(/\S+/m) word_mode=endnote_call_number(word_mode) dob.obj=word_mode.join(' ') @@ -97,7 +104,10 @@ module SiSU_AO_Endnotes end @tuned_file << dob end - @endnote_counter,@endnote_counter_asterisk,@endnote_counter_dag=1,1,1 + @endnote_counter, + @endnote_counter_asterisk, + @endnote_counter_dag= + 1,1,1 @tuned_file=@tuned_file.flatten end def endnote_call_number(words) @@ -105,20 +115,24 @@ module SiSU_AO_Endnotes case word when /#{Mx[:en_a_o]}/ unless word =~/#{Mx[:en_a_o]}[*+]+/ - word.gsub!(/#{Mx[:en_a_o]}/,"#{Mx[:en_a_o]}#{@endnote_counter} ") + word.gsub!(/#{Mx[:en_a_o]}/, + "#{Mx[:en_a_o]}#{@endnote_counter} ") @endnote_counter+=1 end when /#{Mx[:en_b_o]}/ if word =~/#{Mx[:en_b_o]}[+]/ - word.gsub!(/#{Mx[:en_b_o]}[+]/,"#{Mx[:en_b_o]}\+#{@endnote_counter_dag} ") + word.gsub!(/#{Mx[:en_b_o]}[+]/, + "#{Mx[:en_b_o]}\+#{@endnote_counter_dag} ") @endnote_counter_dag+=1 else - word.gsub!(/#{Mx[:en_b_o]}[*]?/,"#{Mx[:en_b_o]}\*#{@endnote_counter_asterisk} ") + word.gsub!(/#{Mx[:en_b_o]}[*]?/, + "#{Mx[:en_b_o]}\*#{@endnote_counter_asterisk} ") @endnote_counter_asterisk+=1 end when /~\^|<:e>/ if @endnote_array - word.gsub!(/~\^|<:e>/,"#{@endnote_array[@endnote_counter-1]}") + word.gsub!(/~\^|<:e>/, + "#{@endnote_array[@endnote_counter-1]}") @endnote_counter+=1 end end diff --git a/lib/sisu/v5/ao_expand_insertions.rb b/lib/sisu/v5/ao_expand_insertions.rb index f47823b6..dce14ee4 100644 --- a/lib/sisu/v5/ao_expand_insertions.rb +++ b/lib/sisu/v5/ao_expand_insertions.rb @@ -77,33 +77,53 @@ module SiSU_AO_Insertions end file_type_names={} file_type_names[:gen],file_type_names[:src]=[],[] - file_type_names[:gen] <<= if cmd_list =~ /y/ then "~^ { document manifest }#{lnk[:manifest]}" + file_type_names[:gen] <<= if cmd_list =~ /y/ + "~^ { document manifest }#{lnk[:manifest]}" end - file_type_names[:gen] <<= if cmd_list =~ /h/ then [" { html, segmented text }#{lnk[:html_toc]}"," { html, scroll, document in one }#{lnk[:html_doc]}"] + file_type_names[:gen] <<= if cmd_list =~ /h/ + [ + " { html, segmented text }#{lnk[:html_toc]}", + " { html, scroll, document in one }#{lnk[:html_doc]}", + ] end - file_type_names[:gen] <<= if cmd_list =~ /e/ then [" { epub }#{lnk[:epub]}"] + file_type_names[:gen] <<= if cmd_list =~ /e/ + [" { epub }#{lnk[:epub]}"] end - file_type_names[:gen] <<= if cmd_list =~ /p/ then [" { pdf, landscape }#{lnk[:pdf_landscape]}"," { pdf, portrait }#{lnk[:pdf_portrait]}"] + file_type_names[:gen] <<= if cmd_list =~ /p/ + [ + " { pdf, landscape }#{lnk[:pdf_landscape]}", + " { pdf, portrait }#{lnk[:pdf_portrait]}", + ] end - file_type_names[:gen] <<= if cmd_list =~ /o/ then " { odf:odt, open document text }#{lnk[:odt]}" + file_type_names[:gen] <<= if cmd_list =~ /o/ + " { odf:odt, open document text }#{lnk[:odt]}" end - file_type_names[:gen] <<= if cmd_list =~ /b/ then " { xhtml scroll }#{lnk[:xhtml]}" + file_type_names[:gen] <<= if cmd_list =~ /b/ + " { xhtml scroll }#{lnk[:xhtml]}" end - file_type_names[:gen] <<= if cmd_list =~ /x/ then " { xml, sax }#{lnk[:xml_sax]}" + file_type_names[:gen] <<= if cmd_list =~ /x/ + " { xml, sax }#{lnk[:xml_sax]}" end - file_type_names[:gen] <<= if cmd_list =~ /X/ then " { xml, dom }#{lnk[:xml_dom]}" + file_type_names[:gen] <<= if cmd_list =~ /X/ + " { xml, dom }#{lnk[:xml_dom]}" end - file_type_names[:gen] <<= if cmd_list =~ /a/ then " { plain text utf-8 }#{lnk[:txt]}" + file_type_names[:gen] <<= if cmd_list =~ /a/ + " { plain text utf-8 }#{lnk[:txt]}" end - file_type_names[:gen] <<= if cmd_list =~ /g/ then 'wiki.txt' + file_type_names[:gen] <<= if cmd_list =~ /g/ + 'wiki.txt' end - file_type_names[:gen] <<= if cmd_list =~ /w/ then " { concordance }#{lnk[:html_concordance]}" + file_type_names[:gen] <<= if cmd_list =~ /w/ + " { concordance }#{lnk[:html_concordance]}" end - file_type_names[:gen] <<= if cmd_list =~ /N/ then " { dcc, document content certificate (digests) }#{lnk[:digest]}" + file_type_names[:gen] <<= if cmd_list =~ /N/ + " { dcc, document content certificate (digests) }#{lnk[:digest]}" end - file_type_names[:src] <<= if source and cmd_shortcut =~ /s/ then " { markup source text }#{lnk[:source]}" + file_type_names[:src] <<= if source and cmd_shortcut =~ /s/ + " { markup source text }#{lnk[:source]}" end - file_type_names[:src] <<= if cmd_shortcut =~ /S/ then " { markup source (zipped) pod }#{lnk[:sisupod]}" + file_type_names[:src] <<= if cmd_shortcut =~ /S/ + " { markup source (zipped) pod }#{lnk[:sisupod]}" end file_type_names[:gen]=file_type_names[:gen].flatten file_type_names[:src]=file_type_names[:src].flatten diff --git a/lib/sisu/v5/ao_hash_digest.rb b/lib/sisu/v5/ao_hash_digest.rb index 1c20671f..6675474c 100644 --- a/lib/sisu/v5/ao_hash_digest.rb +++ b/lib/sisu/v5/ao_hash_digest.rb @@ -85,8 +85,8 @@ module SiSU_AO_Hash t_o.obj=t_o.obj.strip end if (t_o.of !=:structure \ - && t_o.of !=:comment \ - && t_o.of !=:layout) \ + && t_o.of !=:comment \ + && t_o.of !=:layout) \ && t_o.ocn.is_a?(Fixnum) case sha_ when :sha512 @@ -114,7 +114,9 @@ module SiSU_AO_Hash t_o_bit <<= case en_plus when /#{Mx[:en_a_o]}|#{Mx[:en_b_o]}/ 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] + 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=case @env.digest(@md.opt).type when :sha512 @@ -126,7 +128,13 @@ module SiSU_AO_Hash 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 + 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 end else en_plus @@ -143,8 +151,10 @@ module SiSU_AO_Hash case t_o.obj when /#{Mx[:en_a_o]}[\d*+]+\s+.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}[*+]\d+\s+.+?#{Mx[:en_b_c]}/m en_and_t_o_digest=[] - t_o.obj=t_o.obj.gsub(/\s*(#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/m,' \1') #watch - t_o_plus_en=t_o.obj.scan(/.*?#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|.*?#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]}/m) + t_o.obj=t_o.obj. + gsub(/\s*(#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/m,' \1') #watch + t_o_plus_en=t_o.obj. + scan(/.*?#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|.*?#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]}/m) t_o_tail=if t_o.obj =~/(?:.*?#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|.*?#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})+([\s\S]+)/m /(?:.*?#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|.*?#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})+.*/m.match(t_o.obj)[1] else '' diff --git a/lib/sisu/v5/ao_idx.rb b/lib/sisu/v5/ao_idx.rb index 43d5aeda..c0dba12a 100644 --- a/lib/sisu/v5/ao_idx.rb +++ b/lib/sisu/v5/ao_idx.rb @@ -67,14 +67,26 @@ module SiSU_AO_BookIndex @rgx_idx=/#{Mx[:idx_o]}(?:.+?)#{Mx[:idx_c]}\s*/ @rgx_idx_ocn_seg=/(.+?)~(\d+)~(\S+)/ @rgx_idx_ocn=/(.+?)~(\d+)/ - @ocn_html_identifier=SiSU_Env::ProcessingSettings.new(@md).ocn_html_identifier + @ocn_html_identifier= + SiSU_Env::ProcessingSettings.new(@md).ocn_html_identifier @env ||=SiSU_Env::InfoEnv.new(@md.fns) end def indexing_song data=@data - data,sisu_markup_idx_rel,sisu_markup_idx_rel_html_seg,html_idx,xhtml_idx=extract_book_index(data) - data=clean_and_insert_index(data,sisu_markup_idx_rel_html_seg) - [data,sisu_markup_idx_rel,sisu_markup_idx_rel_html_seg,html_idx,xhtml_idx] + data, + sisu_markup_idx_rel, + sisu_markup_idx_rel_html_seg, + html_idx,xhtml_idx= + extract_book_index(data) + data= + clean_and_insert_index(data,sisu_markup_idx_rel_html_seg) + [ + data, + sisu_markup_idx_rel, + sisu_markup_idx_rel_html_seg, + html_idx, + xhtml_idx, + ] end def extract_book_index(data) tuned_file=[] @@ -93,13 +105,25 @@ module SiSU_AO_BookIndex end if idx_array.length > 0 the_idx=construct_book_index(idx_array) - sisu_markup_idx_rel,sisu_markup_idx_rel_html_seg,html_idx,xhtml_idx=nil,nil,nil,nil if @md.book_idx idx=index(the_idx) - sisu_markup_idx_rel,sisu_markup_idx_rel_html_seg,html_idx,xhtml_idx=idx[:sst_rel],idx[:sst_rel_html_seg],idx[:html],idx[:xhtml] + sisu_markup_idx_rel,sisu_markup_idx_rel_html_seg,html_idx, xhtml_idx= + idx[:sst_rel], idx[:sst_rel_html_seg], idx[:html],idx[:xhtml] + else + sisu_markup_idx_rel= + sisu_markup_idx_rel_html_seg= + html_idx= + xhtml_idx= + nil end end - [tuned_file,sisu_markup_idx_rel,sisu_markup_idx_rel_html_seg,html_idx,xhtml_idx] + [ + tuned_file, + sisu_markup_idx_rel, + sisu_markup_idx_rel_html_seg, + html_idx, + xhtml_idx, + ] end def construct_book_index(idx_array) the_idx={} @@ -108,8 +132,12 @@ module SiSU_AO_BookIndex location=(term_info[:plus].to_i > 0) \ ? (%{#{idx[:ocn]}-#{idx[:ocn].to_i + term_info[:plus].to_i}}) : idx[:ocn].to_s - the_idx[term]={} unless the_idx[term] and defined? the_idx[term] - the_idx[term]['node_0_terms']=[] unless the_idx[term]['node_0_terms'] and defined? the_idx[term]['node_0_terms'] + the_idx[term]={} \ + unless the_idx[term] \ + and defined? the_idx[term] + the_idx[term]['node_0_terms']=[] \ + unless the_idx[term]['node_0_terms'] \ + and defined? the_idx[term]['node_0_terms'] the_idx[term]['node_0_terms'] << { ocn: idx[:ocn], range: location, seg: idx[:seg] } if term_info[:sub].is_a?(Array) \ and term_info[:sub].length > 0 @@ -118,11 +146,20 @@ module SiSU_AO_BookIndex location=(subterm_info[:plus].to_i > 0) \ ? (%{#{idx[:ocn]}-#{idx[:ocn].to_i + subterm_info[:plus].to_i}}) : idx[:ocn].to_s - the_idx[term]={} unless the_idx[term] and defined? the_idx[term] - the_idx[term]['node_0_terms']=[] unless the_idx[term]['node_0_terms'] and defined? the_idx[term]['node_0_terms'] - the_idx[term]['node_1_subterms']={} unless the_idx[term]['node_1_subterms'] and defined? the_idx[term]['node_1_subterms'] - the_idx[term]['node_1_subterms'][subterm]=[] unless the_idx[term]['node_1_subterms'][subterm] and defined? the_idx[term]['node_1_subterms'][subterm] - the_idx[term]['node_1_subterms'][subterm] << { ocn: idx[:ocn], range: location, seg: idx[:seg] } + the_idx[term]={} \ + unless the_idx[term] \ + and defined? the_idx[term] + the_idx[term]['node_0_terms']=[] \ + unless the_idx[term]['node_0_terms']\ + and defined? the_idx[term]['node_0_terms'] + the_idx[term]['node_1_subterms']={} \ + unless the_idx[term]['node_1_subterms'] \ + and defined? the_idx[term]['node_1_subterms'] + the_idx[term]['node_1_subterms'][subterm]=[] \ + unless the_idx[term]['node_1_subterms'][subterm] \ + and defined? the_idx[term]['node_1_subterms'][subterm] + the_idx[term]['node_1_subterms'][subterm] << + { ocn: idx[:ocn], range: location, seg: idx[:seg] } end end end @@ -138,16 +175,27 @@ module SiSU_AO_BookIndex def index(the_idx) @x=1 idx={} - idx[:sst_rel_html_seg],idx[:sst_rel],idx[:html],idx[:xhtml]=[],[],[],[] - h={obj: Mx[:br_page]} + idx[:sst_rel_html_seg],idx[:sst_rel],idx[:html],idx[:xhtml]= + [], [], [], [] + h={ + obj: Mx[:br_page] + } o=SiSU_AO_DocumentStructure::ObjectLayout.new.break(h) idx[:sst_rel_html_seg] << o idx[:sst_rel] << o - h={lv: '1', name: 'index', obj: "Index"} + h={ + lv: '1', + name: 'index', + obj: "Index" + } o=SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h) idx[:sst_rel_html_seg] << o idx[:sst_rel] << o - h={lv: '4', name: 'idx', obj: " [Index] #{Mx[:pa_non_object_dummy_heading]}"} + h={ + lv: '4', + name: 'idx', + obj: " [Index] #{Mx[:pa_non_object_dummy_heading]}" + } o=SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h) idx[:sst_rel_html_seg] << o idx[:sst_rel] << o @@ -159,15 +207,19 @@ module SiSU_AO_BookIndex idx[:html] << '' idx[:xhtml] << '' else - idx[:html] << %{#{x},#{$ep[:hsp]}} - idx[:xhtml] << %{#{x},#{$ep[:hsp]}} + idx[:html] << + %{#{x},#{$ep[:hsp]}} + idx[:xhtml] << + %{#{x},#{$ep[:hsp]}} end end idx[:html] << '

' idx[:xhtml] << '

' letter=alph.shift - idx[:html] << %{\n

} - idx[:xhtml] << %{\n

0 - 9

} + idx[:html] << + %{\n

} + idx[:xhtml] << + %{\n

0 - 9

} the_idx.each do |i| i.each do |x| if x.is_a?(String) @@ -176,18 +228,24 @@ module SiSU_AO_BookIndex while letter < f if alph.length > 0 letter=alph.shift - idx[:html] << %{\n

#{letter}

} - idx[:xhtml] << %{\n

#{letter}

} + idx[:html] << + %{\n

#{letter}

} + idx[:xhtml] << + %{\n

#{letter}

} else break end end end - idx[:sst_rel_html_seg] << %{\n\n#{Mx[:fa_bold_o]}#{x},#{Mx[:fa_bold_c]} } - idx[:sst_rel] << %{\n\n#{Mx[:fa_bold_o]}#{x},#{Mx[:fa_bold_c]} } + idx[:sst_rel_html_seg] << + %{\n\n#{Mx[:fa_bold_o]}#{x},#{Mx[:fa_bold_c]} } + idx[:sst_rel] << + %{\n\n#{Mx[:fa_bold_o]}#{x},#{Mx[:fa_bold_c]} } aname=x.gsub(/\s+/,'_') - idx[:html] << %{\n

#{x}, } + idx[:html] << + %{\n

#{x}, } c=clean_xml(x.dup) - idx[:xhtml] << %{\n

#{c}, } + idx[:xhtml] << + %{\n

#{c}, } @o=idx[:sst_rel_html_seg].index(idx[:sst_rel_html_seg].last) @t=idx[:sst_rel].index(idx[:sst_rel].last) @q=idx[:html].index(idx[:html].last) @@ -200,16 +258,32 @@ module SiSU_AO_BookIndex if x['node_0_terms'].is_a?(Array) x['node_0_terms'].each do |a| if a[:range] - idx[:sst_rel_html_seg][@o]=idx[:sst_rel_html_seg][@o] + %{#{Mx[:lnk_o]}#{a[:range]}#{Mx[:lnk_c]}#{Mx[:rel_o]}/#{a[:seg]}.html##{@ocn_html_identifier}#{a[:ocn]}#{Mx[:rel_c]}, } - idx[:sst_rel][@t]=idx[:sst_rel][@t] + %{#{Mx[:lnk_o]}#{a[:range]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{a[:ocn]}#{Mx[:rel_c]}, } - idx[:html][@q]=idx[:html][@q] + %{#{a[:range]}, } - idx[:xhtml][@q]=idx[:xhtml][@q] + %{#{a[:range]}, } + idx[:sst_rel_html_seg][@o]= + idx[:sst_rel_html_seg][@o] + + %{#{Mx[:lnk_o]}#{a[:range]}#{Mx[:lnk_c]}#{Mx[:rel_o]}/#{a[:seg]}.html##{@ocn_html_identifier}#{a[:ocn]}#{Mx[:rel_c]}, } + idx[:sst_rel][@t]= + idx[:sst_rel][@t] + + %{#{Mx[:lnk_o]}#{a[:range]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{a[:ocn]}#{Mx[:rel_c]}, } + idx[:html][@q]= + idx[:html][@q] + + %{#{a[:range]}, } + idx[:xhtml][@q]= + idx[:xhtml][@q] + + %{#{a[:range]}, } print a[:range] + ', ' if @md.opt.act[:verbose_plus][:set]==:on elsif a[:ocn] - idx[:sst_rel_html_seg][@o]=idx[:sst_rel_html_seg][@o] + %{#{Mx[:lnk_o]}#{a[:ocn]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{a[:seg]}.html##{@ocn_html_identifier}#{a[:ocn]}#{Mx[:rel_c]}, } - idx[:sst_rel][@t]=idx[:sst_rel][@t] + %{#{Mx[:lnk_o]}#{a[:ocn]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{a[:ocn]}#{Mx[:rel_c]}, } - idx[:html][@q]=idx[:html][@q] + %{#{a[:ocn]}, } - idx[:xhtml][@q]=idx[:xhtml][@q] + %{#{a[:ocn]}, } + idx[:sst_rel_html_seg][@o]= + idx[:sst_rel_html_seg][@o] + + %{#{Mx[:lnk_o]}#{a[:ocn]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{a[:seg]}.html##{@ocn_html_identifier}#{a[:ocn]}#{Mx[:rel_c]}, } + idx[:sst_rel][@t]= + idx[:sst_rel][@t] + + %{#{Mx[:lnk_o]}#{a[:ocn]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{a[:ocn]}#{Mx[:rel_c]}, } + idx[:html][@q]= + idx[:html][@q] + + %{#{a[:ocn]}, } + idx[:xhtml][@q]= + idx[:xhtml][@q] + + %{#{a[:ocn]}, } print a[:ocn] + ', ' if @md.opt.act[:verbose_plus][:set]==:on else p 'error' end @@ -220,24 +294,48 @@ module SiSU_AO_BookIndex if x['node_1_subterms'] x['node_1_subterms'].sort.each do |k,y| if k !~/node_0_terms/ - idx[:sst_rel_html_seg][@o]=idx[:sst_rel_html_seg][@o] + %{#{k}, } - idx[:sst_rel][@t]=idx[:sst_rel][@t] + %{#{k}, } - idx[:html][@q]=idx[:html][@q] + %{\n

#{k}, } + idx[:sst_rel_html_seg][@o]= + idx[:sst_rel_html_seg][@o] + + %{#{k}, } + idx[:sst_rel][@t]= + idx[:sst_rel][@t] + + %{#{k}, } + idx[:html][@q]= + idx[:html][@q] + + %{\n

#{k}, } c=clean_xml(k.dup) - idx[:xhtml][@r]=idx[:xhtml][@r] + %{\n

#{c}, } + idx[:xhtml][@r]= + idx[:xhtml][@r] + + %{\n

#{c}, } print "\n\t" + k + ', ' if @md.opt.act[:verbose_plus][:set]==:on y.each do |z| if z[:range] - idx[:sst_rel_html_seg][@o]=idx[:sst_rel_html_seg][@o] + %{#{Mx[:lnk_o]}#{z[:range]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{z[:seg]}.html##{@ocn_html_identifier}#{z[:ocn]}#{Mx[:rel_c]}, } - idx[:sst_rel][@t]=idx[:sst_rel][@t] + %{#{Mx[:lnk_o]}#{z[:range]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{z[:ocn]}#{Mx[:rel_c]}, } - idx[:html][@q]=idx[:html][@q] + %{#{z[:range]}, } - idx[:xhtml][@q]=idx[:xhtml][@q] + %{#{z[:range]}, } + idx[:sst_rel_html_seg][@o]= + idx[:sst_rel_html_seg][@o] + + %{#{Mx[:lnk_o]}#{z[:range]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{z[:seg]}.html##{@ocn_html_identifier}#{z[:ocn]}#{Mx[:rel_c]}, } + idx[:sst_rel][@t]= + idx[:sst_rel][@t] + + %{#{Mx[:lnk_o]}#{z[:range]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{z[:ocn]}#{Mx[:rel_c]}, } + idx[:html][@q]= + idx[:html][@q] + + %{#{z[:range]}, } + idx[:xhtml][@q]= + idx[:xhtml][@q] + + %{#{z[:range]}, } print z[:range] + ', ' if @md.opt.act[:verbose_plus][:set]==:on elsif z[:ocn] - idx[:sst_rel_html_seg][@o]=idx[:sst_rel_html_seg][@o] + %{#{Mx[:lnk_o]}#{z[:ocn]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{z[:seg]}.html##{@ocn_html_identifier}#{z[:ocn]}#{Mx[:rel_c]}, } - idx[:sst_rel][@t]=idx[:sst_rel][@t] + %{#{Mx[:lnk_o]}#{z[:ocn]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{z[:ocn]}#{Mx[:rel_c]}, } - idx[:html][@q]=idx[:html][@q] + %{#{z[:ocn]}, } - idx[:xhtml][@q]=idx[:xhtml][@q] + %{#{z[:ocn]}, } + idx[:sst_rel_html_seg][@o]= + idx[:sst_rel_html_seg][@o] + + %{#{Mx[:lnk_o]}#{z[:ocn]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{z[:seg]}.html##{@ocn_html_identifier}#{z[:ocn]}#{Mx[:rel_c]}, } + idx[:sst_rel][@t]= + idx[:sst_rel][@t] + + %{#{Mx[:lnk_o]}#{z[:ocn]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{z[:ocn]}#{Mx[:rel_c]}, } + idx[:html][@q]= + idx[:html][@q] + + %{#{z[:ocn]}, } + idx[:xhtml][@q]= + idx[:xhtml][@q] + + %{#{z[:ocn]}, } print z[:ocn] + ', ' if @md.opt.act[:verbose_plus][:set]==:on else p 'error' end diff --git a/lib/sisu/v5/ao_images.rb b/lib/sisu/v5/ao_images.rb index 8eee4b57..dce92fc5 100644 --- a/lib/sisu/v5/ao_images.rb +++ b/lib/sisu/v5/ao_images.rb @@ -85,7 +85,10 @@ module SiSU_AO_Images else 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 + SiSU_Screen::Ansi.new( + @md.opt.act[:color_state][:set], + '*WARN* use of RMagick is not enabled in sisurc.yml' + ).warn end end data.each do |dob| @@ -99,7 +102,11 @@ module SiSU_AO_Images img_col=img_row=nil images=imgs.each do |image| dir=SiSU_Env::InfoEnv.new(@md.fns) - path_image=[dir.path.image_source_include_local,dir.path.image_source_include_remote,dir.path.image_source_include] + path_image=[ + dir.path.image_source_include_local, + dir.path.image_source_include_remote, + dir.path.image_source_include + ] image_path=nil path_image.each do |img_pth| image_path=img_pth @@ -112,7 +119,10 @@ module SiSU_AO_Images else 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 + SiSU_Screen::Ansi.new( + @md.opt.act[:color_state][:set], + '*WARN* RMagick not present, will attempt to use imagemagick (identify) directly' + ).warn end imgk=SiSU_Env::SystemCall.new.imagemagick gmgk=SiSU_Env::SystemCall.new.graphicksmagick @@ -144,12 +154,18 @@ module SiSU_AO_Images end end dob.obj=dob.obj.gsub(/(#{image})/,"#{image} #{img_col}x#{img_row}") - else dob.obj=dob.obj.gsub(/#{Mx[:lnk_o]}\s*(\S+)\.(png|jpg|gif).+?#{Mx[:lnk_c]}(#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/,'[ \1 (\2 missing) ]') + else + dob.obj=dob.obj. + gsub(/#{Mx[:lnk_o]}\s*(\S+)\.(png|jpg|gif).+?#{Mx[:lnk_c]}(#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/, + '[ \1 (\2 missing) ]') end end else images=dob.obj.scan(m) do |image| - SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],'*WARN* where image dimensions have not been provided RMagick or imagemagick is required',image).warn unless @md.opt.act[:quiet][:set]==:on + SiSU_Screen::Ansi.new( + @md.opt.act[:color_state][:set], + '*WARN* where image dimensions have not been provided RMagick or imagemagick is required',image + ).warn unless @md.opt.act[:quiet][:set]==:on end end end diff --git a/lib/sisu/v5/ao_metadata.rb b/lib/sisu/v5/ao_metadata.rb index c51c40dc..a4f8fcc2 100644 --- a/lib/sisu/v5/ao_metadata.rb +++ b/lib/sisu/v5/ao_metadata.rb @@ -69,11 +69,20 @@ module SiSU_AO_Metadata @tr=SiSU_Translate::Source.new(md,language) end def make_para(obj,ocn) - h={ obj: obj, ocn: 0 } + h={ + obj: obj, + ocn: 0 + } SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h) end def make_heading(obj,ocn,name,lv,ln) - h={ lv: lv, ln: ln, name: name, obj: obj, ocn: 0 } + h={ + lv: lv, + ln: ln, + name: name, + obj: obj, + ocn: 0 + } SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h) end def metadata diff --git a/lib/sisu/v5/ao_misc_arrange.rb b/lib/sisu/v5/ao_misc_arrange.rb index 48b421c6..a053f37e 100644 --- a/lib/sisu/v5/ao_misc_arrange.rb +++ b/lib/sisu/v5/ao_misc_arrange.rb @@ -67,10 +67,13 @@ module SiSU_AO_MiscArrangeText end def conditional_headings(para) para=para.gsub(/^(:?A~)\s*$/,'\1~ @title @author'). #conditional header - gsub(/^((?:[1-9]|:?[A-D])~\S*)\s*$/,'\1~ [Note: heading marker::required title missing]~#') #conditional header for incorporated document 2004w12 + gsub(/^((?:[1-9]|:?[A-D])~\S*)\s*$/, + '\1~ [Note: heading marker::required title missing]~#') #conditional header for incorporated document 2004w12 if para =~/^@\S+?:/ - para=para.gsub(/^@(\S+?):(\s+|$)/,"#{Mx[:meta_o]}\\1#{Mx[:meta_c]}\\2"). - gsub(/^@(\S+?):([+-])(\s+|$)/,"#{Mx[:meta_o]}\\1\\2#{Mx[:meta_c]}\\3") + para=para.gsub(/^@(\S+?):(\s+|$)/, + "#{Mx[:meta_o]}\\1#{Mx[:meta_c]}\\2"). + gsub(/^@(\S+?):([+-])(\s+|$)/, + "#{Mx[:meta_o]}\\1\\2#{Mx[:meta_c]}\\3") end para end @@ -79,7 +82,9 @@ module SiSU_AO_MiscArrangeText block_open,block_close,text=nil,nil,nil if para =~/\A```[ ]+(?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block|table).*?\n.+?\n```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*\Z/m @flag=:close - block_open,text,block_close=/\A(```[ ]+(?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block|table).*?)\n(.+?)\n(```([ ]+[~-][#]|\s+\~\{.+?\}\~)?)\s*\Z/m.match(para)[1..3] + block_open,text,block_close= + /\A(```[ ]+(?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block|table).*?)\n(.+?)\n(```([ ]+[~-][#]|\s+\~\{.+?\}\~)?)\s*\Z/m. + match(para)[1..3] ((para=~/^```[ ]+table(?:~h)?\s+/) \ and (para !~/^```[ ]+table(?:~h)?\s+c\d+/)) \ ? para @@ -96,7 +101,8 @@ module SiSU_AO_MiscArrangeText elsif para =~/\A.+?\n```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*\Z/m \ and @flag==:open @flag=:close - text,block_close=/\A(.+?)\n(```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?)\s*\Z/m.match(para)[1,2] + text,block_close= + /\A(.+?)\n(```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?)\s*\Z/m.match(para)[1,2] para=[] if not text.to_s.empty? para << text.to_s << block_close @@ -109,7 +115,8 @@ module SiSU_AO_MiscArrangeText end def ticks_remove(para) unless @md.opt.act[:quiet][:set] ==:on - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).mark("ticks not recognized, ticks removed from pargraph\n#{para}") + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). + mark("ticks not recognized, ticks removed from pargraph\n#{para}") end para=para.gsub(/```[ ]+\S+[ ]*/m,''). gsub(/```\s*/m,''). @@ -134,11 +141,15 @@ module SiSU_AO_MiscArrangeText def curly_braces(para) block_open,block_close,text=nil,nil,nil para=if para =~/\A(?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block|table)\{ .+?\n.+?\n\}(?:code|box|poem|alt|group|block|table)(?: [~-][#])?\s*\Z/m - block_open,text,block_close=/\A((?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block|table)\{ .+?)\n(.+?)\n(\}(?:code|box|poem|alt|group|block|table)(?: [~-][#])?)\s*\Z/m.match(para)[1..3] + block_open,text,block_close= + /\A((?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block|table)\{ .+?)\n(.+?)\n(\}(?:code|box|poem|alt|group|block|table)(?: [~-][#])?)\s*\Z/m. + match(para)[1..3] para=[] para << block_open << text << block_close elsif para =~/\A(?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block|table)\{ .+?\n.+?\Z/m - block_open,text=/\A((?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block|table)\{ .+?)\n(.+?)\Z/m.match(para)[1,2] + block_open,text= + /\A((?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block|table)\{ .+?)\n(.+?)\Z/m. + match(para)[1,2] para=[] if not text.to_s.empty? para << block_open << text @@ -146,7 +157,9 @@ module SiSU_AO_MiscArrangeText para << block_open end elsif para =~/\A.+?\n\}(?:code|box|poem|alt|group|block|table)(?: [~-][#])?\s*\Z/m - text,block_close=/\A(.+?)\n(\}(?:code|box|poem|alt|group|block|table)(?: [~-][#])?)\s*\Z/m.match(para)[1,2] + text,block_close= + /\A(.+?)\n(\}(?:code|box|poem|alt|group|block|table)(?: [~-][#])?)\s*\Z/m. + match(para)[1,2] para=[] if not text.to_s.empty? para << text.to_s << block_close diff --git a/lib/sisu/v5/ao_numbering.rb b/lib/sisu/v5/ao_numbering.rb index a143abeb..cd631796 100644 --- a/lib/sisu/v5/ao_numbering.rb +++ b/lib/sisu/v5/ao_numbering.rb @@ -121,7 +121,8 @@ module SiSU_AO_Numbering dob end def heading_tag_clean(heading_tag) - heading_tag=heading_tag.gsub(/[ ]+/,'_'). + heading_tag=heading_tag. + gsub(/[ ]+/,'_'). gsub(/["']/,''). gsub(/[\/]/,'-'). gsub(/#{Mx[:fa_bold_o]}|#{Mx[:fa_bold_c]}/,''). @@ -315,7 +316,8 @@ module SiSU_AO_Numbering if dob.name !~/^\S+/ \ and dob.obj =~/^\s*(?:\S+\s+)?([\d.,:-]+)/m #heading starts with a recognised numeric or word followed by a recognised numerical construct, use that as name possible_seg_name=$1 - possible_seg_name=possible_seg_name.gsub(/(?:[:,-]|\W)/,'.'). + possible_seg_name=possible_seg_name. + gsub(/(?:[:,-]|\W)/,'.'). gsub(/\.$/,'') if @md.seg_names.is_a?(Array) \ and not @md.seg_names.include?(possible_seg_name) @@ -363,11 +365,17 @@ module SiSU_AO_Numbering m=dob.ln.to_s dob_tmp=[] if @md.pagenew.inspect =~/#{m}/ - dob_tmp << SiSU_AO_DocumentStructure::ObjectLayout.new.break(Hx[:br_page_new]) << dob + dob_tmp << + SiSU_AO_DocumentStructure::ObjectLayout.new.break(Hx[:br_page_new]) << + dob elsif @md.pagebreak.inspect =~/#{m}/ - dob_tmp << SiSU_AO_DocumentStructure::ObjectLayout.new.break(Hx[:br_page]) << dob + dob_tmp << + SiSU_AO_DocumentStructure::ObjectLayout.new.break(Hx[:br_page]) << + dob elsif @md.pageline.inspect =~/#{m}/ - dob_tmp << SiSU_AO_DocumentStructure::ObjectLayout.new.break(Hx[:br_page_line]) << dob + dob_tmp << + SiSU_AO_DocumentStructure::ObjectLayout.new.break(Hx[:br_page_line]) << + dob end unless dob_tmp.length > 0; dob else dob_tmp @@ -381,11 +389,23 @@ module SiSU_AO_Numbering : @segname tags["#{dob.ocn}"]={ segname: @segname } ocn_html_seg[dob.ocn]=if (dob.is==:heading || dob.is==:heading_insert) - if dob.ln =~/[0-3]/ then { seg: nil, level: dob.ln } + if dob.ln =~/[0-3]/ + { + seg: nil, + level: dob.ln, + } #elsif dob.ln =~/[4-6]/ - else { seg: @seg, level: dob.ln } + else + { + seg: @seg, + level: dob.ln, + } end - else { seg: @seg, level: nil } + else + { + seg: @seg, + level: nil, + } end end dob.tags=dob.tags.uniq if defined? dob.tags @@ -434,7 +454,9 @@ module SiSU_AO_Numbering and defined? @md.title.full \ and defined? @md.creator \ and @md.creator - head=@md.title.main ? ([@lv='1',@obj=@md.title.main]) : ([@lv='1',@obj='[no title provided]']) + head=@md.title.main \ + ? ([@lv='1',@obj=@md.title.main]) + : ([@lv='1',@obj='[no title provided]']) @tuned_file << head end end @@ -479,7 +501,8 @@ module SiSU_AO_Numbering unless @md.set_header_title if t_o !~/^%{1,2}\s/m \ and t_o !~/\A\s*\Z/m - @tuned_file << "#{Mx[:meta_o]}title#{Mx[:meta_c]} #{@md.heading_seg_first}" + @tuned_file << + "#{Mx[:meta_o]}title#{Mx[:meta_c]} #{@md.heading_seg_first}" @md.title.main=@md.heading_seg_first @md.set_header_title=true end diff --git a/lib/sisu/v5/ao_syntax.rb b/lib/sisu/v5/ao_syntax.rb index 619c5ac0..99cb6ca0 100644 --- a/lib/sisu/v5/ao_syntax.rb +++ b/lib/sisu/v5/ao_syntax.rb @@ -143,7 +143,8 @@ module SiSU_AO_Syntax && dob.is !=:comment \ && dob.is !=:code \ && dob.is !=:table - dob.obj=dob.obj.gsub(/^-\\\\-\s*$/,"#{Mx[:br_page]}"). + dob.obj=dob.obj. + gsub(/^-\\\\-\s*$/,"#{Mx[:br_page]}"). gsub(/^=\\\\=\s*$/,"#{Mx[:br_page_new]}"). gsub(/ \\\\(?: |$)/,"#{Mx[:br_line]}"). gsub(/(?:<:?pb>)/,"#{Mx[:br_page]}"). # depreciated @@ -190,7 +191,8 @@ module SiSU_AO_Syntax dob end def embolden(given) - given=given.gsub(/^!_\s+((?:\{|#{Mx[:lnk_o]})(?:~^ )?.+?(?:\}|#{Mx[:lnk_o]})https?:\/\/\S+.*?)([#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}])/, + given=given. + gsub(/^!_\s+((?:\{|#{Mx[:lnk_o]})(?:~^ )?.+?(?:\}|#{Mx[:lnk_o]})https?:\/\/\S+.*?)([#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}])/, "#{Mx[:fa_bold_o]} \\1 #{Mx[:fa_bold_c]}\\2"). gsub(/^!_\s+((?:\{|#{Mx[:lnk_o]})(?:~^ )?.+?(?:\}|#{Mx[:lnk_o]})https?:\/\/\S+.*)/, "#{Mx[:fa_bold_o]} \\1 #{Mx[:fa_bold_c]}"). @@ -204,7 +206,8 @@ module SiSU_AO_Syntax "#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}") end def italicise(given) - given=given.gsub(/^\/_\s*(.+?)([#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}])/, + given=given. + gsub(/^\/_\s*(.+?)([#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}])/, "#{Mx[:fa_italics_o]}\\1#{Mx[:fa_italics_c]}\\2"). gsub(/^\/_\s*(.+?)\s+((?:[*]~\S+\s*)+)/, "#{Mx[:fa_italics_o]}\\1#{Mx[:fa_italics_c]}\\2"). @@ -282,11 +285,13 @@ module SiSU_AO_Syntax word.each do |w| unless /#{@manmkp_bold}|#{@http_m}/.match(w) if defined? @md.bold_match_list[:regx] \ - and @md.bold_match_list[:regx] #document header: @bold: [bold word list] - w=w.gsub(@md.bold_match_list[:regx],"#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}") + and @md.bold_match_list[:regx] #document header: @bold: [bold word list] + w=w.gsub(@md.bold_match_list[:regx], + "#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}") elsif defined? @vz.markup_make_bold \ and @vz.markup_make_bold #defaults adjusted bold word list - w=w.gsub(@vz.markup_make_bold,"#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}") + w=w.gsub(@vz.markup_make_bold, + "#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}") end else w=if w =~ /(?:^!_|^#{Mx[:lv_o]}[7-9]:\S*?#{Mx[:lv_c]})\s+/ @@ -324,7 +329,9 @@ module SiSU_AO_Syntax else '' end txt="#{lead_break}#{fce}\{" + txt.split(Mx[:br_nl]).join("\}#{fce}#{Mx[:br_nl]}#{fce}\{") + "\}#{fce}" - dob.obj=dob.obj.sub(/(?:^|#{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]}]|[\(\[\{]|\>)([*!\/_#])\{.+?\}\1/m,"#{lead}#{txt}") + dob.obj=dob.obj. + sub(/(?:^|#{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]}]|[\(\[\{]|\>)([*!\/_#])\{.+?\}\1/m, + "#{lead}#{txt}") dob else dob end @@ -336,7 +343,8 @@ module SiSU_AO_Syntax 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]}]|[\(\[\{]|[、。「‹«¿¡]|\>/ dob=fontface_lines(dob,leader) - dob.obj=dob.obj.gsub(/(#{leader})\*\{(.+?)\}\*/m, + dob.obj=dob.obj. + gsub(/(#{leader})\*\{(.+?)\}\*/m, "\\1#{@emph[:o]}\\2#{@emph[:c]}"). #emphasis gsub(/(#{leader})!\{(.+?)\}!/m, "\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}"). #bold @@ -399,18 +407,20 @@ module SiSU_AO_Syntax word=dob.obj.scan(/\S+|\n/) #unless line =~/^(?:#{Mx[:meta_o]}|%+\s)/ #visit if word word.each do |w| # _ - / # | : ! ^ ~ - unless w =~/~\{|\}~|~\[|\]~|^\^~|~\^|\*~\S+|~#|\{t?~|\{table|https?:\/\/\S+/ # do something earlier about table!! - w=w.gsub(/\\?~/,"#{Mx[:gl_o]}#126#{Mx[:gl_c]}") #escaped special character + unless w =~/~\{|\}~|~\[|\]~|^\^~|~\^|\*~\S+|~#|\{t?~|\{table|https?:\/\/\S+/ # do something earlier about table!! + w=w.gsub(/\\?~/,"#{Mx[:gl_o]}#126#{Mx[:gl_c]}") #escaped special character end - w=w.gsub(/^\<$/,"#{Mx[:gl_o]}#lt#{Mx[:gl_c]}").gsub(/^\>$/,"#{Mx[:gl_o]}#gt#{Mx[:gl_c]}") #escaped special character + w=w.gsub(/^\<$/, + "#{Mx[:gl_o]}#lt#{Mx[:gl_c]}").gsub(/^\>$/,"#{Mx[:gl_o]}#gt#{Mx[:gl_c]}") #escaped special character line_array << w end dob.obj=line_array.join(' ') dob.obj=dob.obj.strip end - dob.obj=dob.obj.gsub(/^([*#-.]{1,12})$/,'\1 ~#'). #ocn off for these paragraph separators + dob.obj=dob.obj. + gsub(/^([*#-.]{1,12})$/,'\1 ~#'). #ocn off for these paragraph separators gsub(/~\{(.+?)\}~/m,Mx[:en_a_o] + '\1' + Mx[:en_a_c]). - gsub(/~\[([^*+].+?)\]~/m,Mx[:en_b_o] + '* \1' + Mx[:en_b_c]). #default if markup does not specify + gsub(/~\[([^*+].+?)\]~/m,Mx[:en_b_o] + '* \1' + Mx[:en_b_c]). #default if markup does not specify gsub(/~\[(.+?)\]~/m,Mx[:en_b_o] + '\1' + Mx[:en_b_c]) if dob.is ==:heading \ and dob.ln ==0 @@ -431,12 +441,14 @@ module SiSU_AO_Syntax dob.obj=if dob.lv =~/[23]/ \ and defined? @md.creator.author \ and @md.creator.author - dob.obj.gsub(/^\s*(?:(by\s+)?(?:@creator|@author))\s*$/,"\\1#{@md.creator.author}") + dob.obj. + gsub(/^\s*(?:(by\s+)?(?:@creator|@author))\s*$/, + "\\1#{@md.creator.author}") else dob.obj.gsub(/^\s*(?:(by\s+)?(?:@creator|@author))\s*$/,'\1') end end end - dob.obj=dob.obj.gsub(/<(https?:\/\/\S+?)>/,'< \1 >'). #catch problem markup + dob.obj=dob.obj.gsub(/<(https?:\/\/\S+?)>/,'< \1 >'). #catch problem markup gsub(/<:=(\S+?)>/,'{ c_\1.png 14x14 }image'). gsub(//,'<:\1>'). #escaped special character gsub(/ /,"#{Mx[:nbsp]}"). #escaped special character @@ -463,15 +475,18 @@ module SiSU_AO_Syntax gsub(/\\\!/,"#{Mx[:gl_o]}#033#{Mx[:gl_c]}") #escaped special character if dob.obj=~/(?:https?:|ftp:|\{([^{}]+?)\}(?:#|:|[.]{1,2}\/))\S+/m if dob.obj=~/(?:^|[#{Mx[:gl_c]}#{Mx[:nbsp]} ])\{~\^ (?:.+?)\s*\}(?:(?:https?:|ftp:|:|[.]{1,2}\/)\S+?)\s*#{Mx[:en_a_o]}(.+?)#{Mx[:en_a_c]}/m - dob.obj=dob.obj.gsub(/(^|[#{Mx[:gl_c]}#{Mx[:nbsp]} ])\{~\^ ([^}]+?)\s*\}((?:https?:|ftp:|:|[.]{1,2}\/)\S+?)\s*#{Mx[:en_a_o]}(.+?)#{Mx[:en_a_c]}/m, - "\\1#{Mx[:lnk_o]}\\2#{Mx[:lnk_c]}\\3 #{Mx[:en_a_o]}\\3 \\4#{Mx[:en_a_c]}") # watch + dob.obj=dob.obj. + gsub(/(^|[#{Mx[:gl_c]}#{Mx[:nbsp]} ])\{~\^ ([^}]+?)\s*\}((?:https?:|ftp:|:|[.]{1,2}\/)\S+?)\s*#{Mx[:en_a_o]}(.+?)#{Mx[:en_a_c]}/m, + "\\1#{Mx[:lnk_o]}\\2#{Mx[:lnk_c]}\\3 #{Mx[:en_a_o]}\\3 \\4#{Mx[:en_a_c]}") # watch end if dob.obj=~/(?:^|[#{Mx[:gl_c]}#{Mx[:nbsp]} ])\{~\^ (?:.+?)\s*\}(?:(?:https?:|ftp:|:|[.]{1,2}\/)\S+?)([;,.]?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m - dob.obj=dob.obj.gsub(/(^|[#{Mx[:gl_c]}#{Mx[:nbsp]} ])\{~\^ (.+?)\s*\}((?:https?:|ftp:|:|[.]{1,2}\/)\S+?)([;,.]?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m, - "\\1#{Mx[:lnk_o]}\\2#{Mx[:lnk_c]}\\3\\4 #{Mx[:en_a_o]}\\3#{Mx[:en_a_c]} ") + dob.obj=dob.obj. + gsub(/(^|[#{Mx[:gl_c]}#{Mx[:nbsp]} ])\{~\^ (.+?)\s*\}((?:https?:|ftp:|:|[.]{1,2}\/)\S+?)([;,.]?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m, + "\\1#{Mx[:lnk_o]}\\2#{Mx[:lnk_c]}\\3\\4 #{Mx[:en_a_o]}\\3#{Mx[:en_a_c]} ") end - dob.obj=dob.obj.gsub(/(^|[^#])\{\s*([^{}]+?)\s*\}((?:https?:|:|[.]{2}\/|#)\S+?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}#{Mx[:en_a_o]}#{Mx[:en_b_o]}]|$)/, - "\\1#{Mx[:lnk_o]}\\2#{Mx[:lnk_c]}\\3"). #linked (text or image, however text cannot include modified face, e.g. bold, ital, underline) + dob.obj=dob.obj. + gsub(/(^|[^#])\{\s*([^{}]+?)\s*\}((?:https?:|:|[.]{2}\/|#)\S+?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}#{Mx[:en_a_o]}#{Mx[:en_b_o]}]|$)/, + "\\1#{Mx[:lnk_o]}\\2#{Mx[:lnk_c]}\\3"). #linked (text or image, however text cannot include modified face, e.g. bold, ital, underline) gsub(/(^|[#{Mx[:gl_c]}#{Mx[:lnk_c]}#{Mx[:en_a_o]}#{Mx[:en_b_o]}(\s])((?:https?|ftp):\/\/\S+?\.[^>< ]+?)([,.;'"]?)(?=[\s#{Mx[:en_a_c]}#{Mx[:en_b_c]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m, %{\\1#{Mx[:url_o]}\\2#{Mx[:url_c]}\\3}). gsub(/#{Mx[:lnk_c]}#(\S+?[^>< ]+?)([()\[\]]*[,.;:!?'"]{0,2})(?=[\s#{Mx[:en_a_c]}#{Mx[:en_b_c]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m, @@ -486,7 +501,8 @@ module SiSU_AO_Syntax %{\\1#{Mx[:url_o]}\\2#{Mx[:url_c]}\\3}) end dob=fontface(dob) - dob.obj=dob.obj.gsub(/<[:e]\s+(.+?)!?>/, + dob.obj=dob.obj. + gsub(/<[:e]\s+(.+?)!?>/, "#{Mx[:en_a_o]}\\1#{Mx[:en_a_c]}"). #not tested gsub(/(^|#{Mx[:br_nl]})\s*_\*\s*/, "\\1#{Mx[:gl_bullet]}"). #bullets, shortcut @@ -526,7 +542,8 @@ module SiSU_AO_Syntax elsif dob.is==:table dob=fontface(dob) elsif dob.is ==:code - dob.obj=dob.obj.gsub(/#{Mx[:meta_o]}(\S+?)#{Mx[:meta_c]}\s*/,'@\1: '). + dob.obj=dob.obj. + gsub(/#{Mx[:meta_o]}(\S+?)#{Mx[:meta_c]}\s*/,'@\1: '). gsub(/(^|#{Mx[:gl_c]}|\s)<(br(?: \/)?)>([\s,.]|$)/,'\1<\2>\3') #convert

back, clumsy if dob.number_ codeline=[] @@ -569,7 +586,8 @@ module SiSU_AO_Syntax # +2 puts 'tech' @data.each do |line| - line=line.gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)e\{(.+?)\}e/, + line=line. + gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)e\{(.+?)\}e/, "\\1#{@emph[:o]}\\2#{@emph[:c]}"). #emphasis gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)b\{(.+?)\}b/, "\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}"). #bold diff --git a/lib/sisu/v5/hub.rb b/lib/sisu/v5/hub.rb index f57274ad..d9359862 100644 --- a/lib/sisu/v5/hub.rb +++ b/lib/sisu/v5/hub.rb @@ -75,7 +75,8 @@ module SiSU begin require 'uri' rescue LoadError - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('uri NOT FOUND (LoadError)') + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). + error('uri NOT FOUND (LoadError)') end class HubMaster def initialize(argv) @@ -159,7 +160,11 @@ module SiSU end end if files_translated_idx.flatten.length > 1 - SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Manifest re-run on (currently generated) translated files',"").grey_title_hi unless @opt.act[:quiet][:set] ==:on + SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + 'Manifest re-run on (currently generated) translated files', + '' + ).grey_title_hi unless @opt.act[:quiet][:set] ==:on files_translated_idx.flatten.each do |i| @opt.fns=@opt.files[i] @opt.f_pth=@opt.f_pths[i] @@ -191,22 +196,26 @@ module SiSU @@n_do=0 end def remote_put_base_site_rsync # -CR - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__).mark(:cyan) if @opt.act[:maintenance][:set] ==:on + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__).mark(:cyan) \ + if @opt.act[:maintenance][:set] ==:on require_relative 'remote' # remote.rb SiSU_Remote::Put.new(@opt).rsync_base end def remote_put_base_site_rsync_match # -CCRZ - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__).mark(:cyan) if @opt.act[:maintenance][:set] ==:on + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__).mark(:cyan) \ + if @opt.act[:maintenance][:set] ==:on require_relative 'remote' # remote.rb SiSU_Remote::Put.new(@opt).rsync_base_sync end def remote_put_base_site # -Cr - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__).mark(:cyan) if @opt.act[:maintenance][:set] ==:on + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__).mark(:cyan) \ + if @opt.act[:maintenance][:set] ==:on require_relative 'remote' # remote.rb SiSU_Remote::Put.new(@opt).scp_base end def remote_put_base_site_all # -CCr - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__).mark(:cyan) if @opt.act[:maintenance][:set] ==:on + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__).mark(:cyan) \ + if @opt.act[:maintenance][:set] ==:on require_relative 'remote' # remote.rb SiSU_Remote::Put.new(@opt).scp_base_all end @@ -217,7 +226,10 @@ module SiSU def termsheet # -t system("sisu_termsheet #{@opt.cmd} #{@opt.fns}\n") @@n_do=@@n_do+1 - SiSU_Screen::Ansi.new(@opt.cmd,@@n_do,'Termsheet(s) processed').term_sheet_title unless @opt.act[:quiet][:set] ==:on + SiSU_Screen::Ansi.new( + @opt.cmd,@@n_do, + 'Termsheet(s) processed' + ).term_sheet_title unless @opt.act[:quiet][:set] ==:on end def webrick # -W prt=SiSU_Env::InfoEnv.new(@fns).port.webrick_port @@ -254,7 +266,8 @@ module SiSU require 'fileutils' include FileUtils rescue LoadError - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('fileutils NOT FOUND (LoadError)') + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). + error('fileutils NOT FOUND (LoadError)') end @@env=nil attr_accessor :op @@ -262,7 +275,9 @@ module SiSU @opt=opt @@env=@env=SiSU_Env::InfoEnv.new @msg,@msgs='',nil - @tell=lambda { SiSU_Screen::Ansi.new(@opt.cmd,@msg,"#{@msgs.inspect if @msgs}") } + @tell=lambda { + SiSU_Screen::Ansi.new(@opt.cmd,@msg,"#{@msgs.inspect if @msgs}") + } end def remove_skipped_files_if_any_from_processing_files_array if @remove_faulty_markup_files_array.length > 0 @@ -272,7 +287,8 @@ module SiSU 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(',') + STDERR.puts 'ERROR with file(s), did not process: ' + + @remove_faulty_markup_files_array.join(',') end end def do_loops @@ -288,7 +304,8 @@ module SiSU def do_each_file_loop_options @opt.files.each_with_index do |fno,i| @opt.fno=fno - @opt.fns=fno.gsub(/(?:https?|file):\/\/\S+\/(\S+)\.sst$/,'\1.-sst'). + @opt.fns=fno. + gsub(/(?:https?|file):\/\/\S+\/(\S+)\.sst$/,'\1.-sst'). gsub(/\.ssm$/,'.ssm.sst') @opt.f_pth=@opt.f_pths[i] if @opt.fns !~/\.-sst$/ @@ -492,7 +509,8 @@ module SiSU ensure path_pod=@env.processing_path.processing_sisupod(@opt).paths unless @opt.act[:maintenance][:set]==:on - FileUtils::rm_rf("#{path_pod[:sisupod]}/*") if FileTest.directory?(path_pod[:sisupod]) + FileUtils::rm_rf("#{path_pod[:sisupod]}/*") \ + if FileTest.directory?(path_pod[:sisupod]) end end end @@ -518,7 +536,7 @@ module SiSU case @opt.fns when /\.(termsheet.rb)$/ SiSU::Operations.new(@opt).termsheet - else #print "not processed --> ", fns, "\n" + else #print "not processed --> ", fns, "\n" end else SiSU::Operations.new(@opt).not_found end @@ -528,13 +546,13 @@ module SiSU if @opt.act[:psql][:set]==:on #% --pg, -D DB postgresql require_relative 'dbi' OptionLoopFiles.new(@opt).loop_files_on_given_option do - SiSU_DBI::SQL.new(@opt).connect # -D -d dbi.rb + SiSU_DBI::SQL.new(@opt).connect # -D -d dbi.rb end end if @opt.act[:sqlite][:set]==:on #% --sqlite, -d DB sqlite require_relative 'dbi' OptionLoopFiles.new(@opt).loop_files_on_given_option do - SiSU_DBI::SQL.new(@opt).connect # -D -d dbi.rb + SiSU_DBI::SQL.new(@opt).connect # -D -d dbi.rb end end if @opt.act[:manifest][:set]==:on #% --manifest, -y @@ -579,7 +597,10 @@ module SiSU if (@opt.act[:verbose][:set]==:on \ || @opt.act[:verbose_plus][:set]==:on \ || @opt.act[:maintenance][:set]==:on) - SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],' ' + File.dirname(__FILE__)).grey + SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + ' ' + File.dirname(__FILE__) + ).grey end end if @opt.act[:ao][:set]==:on \ @@ -676,7 +697,8 @@ module SiSU begin require 'profile' rescue LoadError - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('profile NOT FOUND (LoadError)') + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). + error('profile NOT FOUND (LoadError)') end end action_on_file_ =if @opt.act[:rsync][:set]==:on \ diff --git a/lib/sisu/v5/options.rb b/lib/sisu/v5/options.rb index 091f7665..591bb990 100644 --- a/lib/sisu/v5/options.rb +++ b/lib/sisu/v5/options.rb @@ -72,7 +72,22 @@ module SiSU_Commandline @@sisu_call_origin_path=nil class HeaderCommon def sisu_document_make_instructions - @pagenew=@pagebreak=@pageline=@toc=@lv1=@lv2=@lv3=@lv4=@lv5=@lv6=@num_top=@i18n=@man_section=@emphasis_set_to=@bold_match_list=@italics_match_list=@substitution_match_list=@footer_links=@home_button_links=@links=nil + @pagenew= + @pagebreak= + @pageline= + @toc= + @lv1=@lv2=@lv3=@lv4=@lv5=@lv6= + @num_top= + @i18n= + @man_section= + @emphasis_set_to= + @bold_match_list= + @italics_match_list= + @substitution_match_list= + @footer_links= + @home_button_links= + @links= + nil make_instruct_array=SiSU_Env::GetInit.new.sisu_document_make.makefile_read @makeset=false if make_instruct_array @@ -143,7 +158,8 @@ module SiSU_Commandline attr_accessor :cmd,:mod,:act,:dir_structure_by,:lingual,:f_pths,:files,:files_mod,:base_path,:base_stub,:sub_location,:paths,:lngs,:f_pth,:pth,:fno,:fns,:fnb,:fnc,:fng,:fncb,:lng,:lng_base,:what,:make_instructions,:make_instructions_pod @@act=nil def initialize(a) - @cmd,@f_pth,@pth,@fno,@fns,@fnb,@fnc,@fng,@fncb,@what,@lng,@lng_base,@base_path,@base_stub,@sub_location='','','','','','','','','','','','','','' + @cmd,@f_pth,@pth,@fno,@fns,@fnb,@fnc,@fng,@fncb,@what,@lng,@lng_base,@base_path,@base_stub,@sub_location= + '', '', '', '', '', '', '', '', '', '', '', '', '', '', '' @f_pths,@files,@files_mod,@paths,@mod,@act=Array.new(5){[]} @env=SiSU_Env::InfoEnv.new @lng_base=@env.language_default_set @@ -316,7 +332,8 @@ module SiSU_Commandline FileUtils::mkdir_p(pt.to_s) pod_make_path=fullname + '/sisupod/doc/_sisu' make_instruct_array=sisu_document_make_pod.makefile_read(pod_make_path) - @make_instructions_pod=HeaderCommon.new(make_instruct_array).sisu_document_make_instructions + @make_instructions_pod= + HeaderCommon.new(make_instruct_array).sisu_document_make_instructions Dir.chdir(pt.realpath) system(" chdir #{fullname} @@ -410,7 +427,7 @@ module SiSU_Commandline lng: lng_is, lng_is: lng_is, url_base: nil, - url: nil + url: nil, } else puts "file not found: #{x}" end @@ -422,7 +439,16 @@ module SiSU_Commandline puts "#{x} in #{a.join(' ')}?" end end - { cmd: c, mod: m, what: w, paths: pth, files: f, f_pths: f_pths, lng: lng_is, lngs: lngs } + { + cmd: c, + mod: m, + what: w, + paths: pth, + files: f, + f_pths: f_pths, + lng: lng_is, + lngs: lngs, + } end def expand_numeric_shortcuts(a) shortcut=SiSU_Env::InfoProcessingFlag.new diff --git a/lib/sisu/v5/param.rb b/lib/sisu/v5/param.rb index 9dcdfc26..d20a0129 100644 --- a/lib/sisu/v5/param.rb +++ b/lib/sisu/v5/param.rb @@ -65,15 +65,34 @@ module SiSU_Param require 'uri' require 'pstore' rescue LoadError - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('uri or pstore NOT FOUND (LoadError)') + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). + error('uri or pstore NOT FOUND (LoadError)') end require_relative 'sysenv' # sysenv.rb include SiSU_Env require_relative 'param_make' # param_make.rb require_relative 'param_identify_markup' # param_identify_markup.rb @@date=SiSU_Env::InfoDate.new - @@proc=@@filename_txt=@@filename_texinfo=@@filename_lout_portrait=@@filename_lout_landscape=@@filename_html_scroll=@@filename_html_index=@@filename_html_segtoc=@@filename_semantic=@@filename_rss=@@newfile=@@drr=nil - @doc={ initialise: nil, markup: '', lnks: '', stmp: '', req: {} } + @@proc= + @@filename_txt= + @@filename_texinfo= + @@filename_lout_portrait= + @@filename_lout_landscape= + @@filename_html_scroll= + @@filename_html_index= + @@filename_html_segtoc= + @@filename_semantic= + @@filename_rss= + @@newfile= + @@drr= + nil + @doc={ + initialise: nil, + markup: '', + lnks: '', + stmp: '', + req: {}, + } @@yaml=@@yamladdr=nil @@trigger=nil @@lv,@@flag={},{} @@ -99,7 +118,8 @@ module SiSU_Param # you may need to change Dir.pwd to @opt.f_pth[:pth] where the latter # has a path value that is different, however, f_pth is not always set! Dir.chdir(@opt.f_pth[:pth]) - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('-- bug alert --') + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). + error('-- bug alert --') p 'f_pth ' + @opt.f_pth[:pth] p 'pwd ' + Dir.pwd end @@ -186,7 +206,11 @@ module SiSU_Param STDERR.puts "#{n} is #{s.class}: programming error, String expected #{__FILE__}:#{__LINE__}" s else - SiSU_Screen::Ansi.new('v',"*WARN* #{n} length #{s.length} exceeds set db field length #{l}, metadata dropped",@opt.fns).warn unless @opt.act[:quiet][:set]==:on + SiSU_Screen::Ansi.new( + 'v', + "*WARN* #{n} length #{s.length} exceeds set db field length #{l}, metadata dropped", + @opt.fns + ).warn unless @opt.act[:quiet][:set]==:on nil end end @@ -504,7 +528,10 @@ module SiSU_Param 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 + SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + 'WARNING Document Copyright missing; provide @rights: :copyright:' + ).warn unless @opt.act[:quiet][:set]==:on '' end l,n=Db[:col_info_note],'rights.copyright.text' @@ -603,7 +630,10 @@ module SiSU_Param 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 + SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + 'WARNING Document Rights information missing; provide @rights: :copyright:' + ).warn unless @opt.act[:quiet][:set]==:on else l,n=Db[:col_info_note],'rights.all' validate_length(s,l,n) @@ -835,8 +865,10 @@ module SiSU_Param attr_accessor :make,:env,:path,:file,:fn,:fns,:fno,:fnb,:fnn,:fnt,:fnl,:flv,:fnz,:fnstex,:ocn,:sfx_src,:pdf,:file_type,:dir_out,:dir_tex,:dir_lout,:txt_path,:sisu,:sisu_version,:ruby_version,:title,:subtitle,:full_title,:html_title,:subtitle_tex,:creator,:classify,:author_home,:author,:author_title,:author_nationality,:authors,:authorship,:translator,:illustrator,:prepared_by,:digitized_by,:subject,:description,:publisher,:current_publisher,:contributor,:date,:date_created,:date_issued,:date_available,:date_valid,:date_modified,:date_translated,:date_added_to_site,:date_scheme,:date_created_scheme,:date_issued_scheme,:date_available_scheme,:date_valid_scheme,:date_modified_scheme,:type,:format,:identifier,:source,:language,:language_original,:relation,:coverage,:rights,:keywords,:comments,:abstract,:cls_loc,:cls_dewey,:cls_pg,:cls_isbn,:papersize,:papersize_array,:toc,:lv0,:lv1,:lv2,:lv3,:lv4,:lv5,:lv6,:lvs,:pagenew,:pagebreak,:pageline,:num_top,:bold_match_list,:italics_match_list,:substitution_match_list,:emphasis_set_to,:toc_lev_limit,:flag_endnotes,:flag_auto_endnotes,:flag_separate_endnotes,:flag_separate_endnotes_make,:markup,:markup_instruction,:flag_tables,:vocabulary,:doc_css,:yaml,:lnk,:links,:prefix_a,:prefix_b,:suffix,:information,:contact,:icon,:image,:ad_url,:ad_png,:ad_alt,:ad_began,:flag_promo,:promo,:ad_home,:stmp,:stmpd,:sc_filename,:sc_number,:sc_date,:sc_time,:sc_info,:yamladdr,:locale,:wc_lines,:wc_words,:wc_bytes,:file_encoding,:filesize,:user,:home,:hostname,:pwd,:firstseg,:programs,:author_copymark,:i18n,:lang,:lang_code_insert,:en,:notes,:dgst,:generated,:tags,:tag_array,:concord_make,:seg_names,:seg_autoname_safe,:set_header_title,:set_heading_top,:set_heading_seg,:heading_seg_first,:heading_seg_first_flag,:base_program,:ec,:opt,:sem_tag,:book_idx,:topic_register,:topic_register_array,:original,:writing_focus,:audio,:daisy,:home_button_image,:home_button_links,:footer_links,:cover_image,:man_section def initialize(fns_array,opt) @env=@path,@file=@fn=@fns=@fno=@fnb=@fnn=@fnt=@fnl=@flv=@fnz=@fnstex=@ocn=@sfx_src=@pdf=@file_type=@dir_out=@dir_tex=@dir_lout=@txt_path=@make=@flag_endnotes=@flag_auto_endnotes=@flag_separate_endnotes=@flag_separate_endnotes_make=@sisu=@sisu_version=@ruby_version=@title=@subtitle=@full_title=@html_title=@subtitle_tex=@creator=@classify=@author_home=@author=@author_title=@author_nationality=@translator=@illustrator=@prepared_by=@digitized_by=@subject=@description=@publisher=@current_publisher=@contributor=@date=@date_created=@date_issued=@date_available=@date_valid=@date_modified=@date_translated=@date_added_to_site=@date_scheme=@date_created_scheme=@date_issued_scheme=@date_available_scheme=@date_valid_scheme=@date_modified_scheme=@type=@format=@identifier=@source=@language=@language_original=@relation=@coverage=@rights=@keywords=@comments=@abstract=@cls_loc=@cls_dewey=@cls_pg=@cls_isbn=@papersize=@toc=@lv0=@lv1=@lv2=@lv3=@lv4=@lv5=@lv6=@pagenew=@pagebreak=@pageline=@num_top=@bold_match_list=@italics_match_list=@substitution_match_list=@emphasis_set_to=@toc_lev_limit=@flag_tables=@vocabulary=@doc_css=@yaml=@lnk=@links=@prefix_a=@prefix_b=@suffix=@information=@contact=@icon=@ad_url=@ad_png=@ad_alt=@ad_began=@promo=@ad_home=@stmp=@stmpd=@sc_filename=@sc_number=@sc_date=@sc_time=@sc_info=@yamladdr=@locale=@wc_lines=@wc_words=@wc_bytes=@file_encoding=@filesize=@firstseg=@programs=@author_copymark=@i18n=@lang=@lang_code_insert=@en=@notes=@dgst=@generated=@heading_seg_first=@base_program=@topic_register=@original=@writing_focus=@audio=@home_button_image=@home_button_links=@cover_image=@man_section=nil - @data,@path,@fns,@fno,@opt=fns_array,opt.pth,opt.fns,opt.fno,opt #@data used as data - @flag_tables,@set_header_title,@set_heading_top,@set_heading_seg,@heading_seg_first_flag,@flag_promo,@book_idx=false,false,false,false,false,false,false + @data, @path, @fns, @fno, @opt= + fns_array,opt.pth,opt.fns,opt.fno,opt #@data used as data + @flag_tables,@set_header_title,@set_heading_top,@set_heading_seg,@heading_seg_first_flag,@flag_promo,@book_idx= + false, false, false, false, false, false, false @seg_autoname_safe=true @daisy,@sem_tag=false,false @authorship,@markup_instruction,@image='','','','' #check which other values should be set to empty rather than nil @@ -1020,37 +1052,48 @@ module SiSU_Param @lv4=(makes[:lv4]) ? (makes[:lv4]) : @lv4 @lv5=(makes[:lv5]) ? (makes[:lv5]) : @lv5 @lv6=(makes[:lv6]) ? (makes[:lv6]) : @lv6 - @num_top=(makes[:num_top]) \ + @num_top= + (makes[:num_top]) \ ? (makes[:num_top]) \ : @num_top - @substitution_match_list=(makes[:substitution_match_list]) \ + @substitution_match_list= + (makes[:substitution_match_list]) \ ? (makes[:substitution_match_list]) \ : @substitution_match_list - @bold_match_list=(makes[:bold_match_list]) \ + @bold_match_list= + (makes[:bold_match_list]) \ ? (makes[:bold_match_list]) \ : @bold_match_list - @italics_match_list=(makes[:italics_match_list]) \ + @italics_match_list= + (makes[:italics_match_list]) \ ? (makes[:italics_match_list]) \ : @italics_match_list - @emphasis_set_to=(makes[:emphasis_set_to]) \ + @emphasis_set_to= + (makes[:emphasis_set_to]) \ ? (makes[:emphasis_set_to]) \ : @emphasis_set_to - @i18n=(makes[:i18n]) \ + @i18n= + (makes[:i18n]) \ ? (makes[:i18n]) \ : @i18n - @man_section=(makes[:man_section]) \ + @man_section= + (makes[:man_section]) \ ? (makes[:man_section]) \ : @man_section - @footer_links=(makes[:footer_links]) \ + @footer_links= + (makes[:footer_links]) \ ? (makes[:footer_links]) \ : @footer_links - @home_button_links=(makes[:home_button_links]) \ + @home_button_links= + (makes[:home_button_links]) \ ? (makes[:home_button_links]) \ : @home_button_links - @home_button_image=(makes[:home_button_image]) \ + @home_button_image= + (makes[:home_button_image]) \ ? (makes[:home_button_image]) \ : @home_button_image - @cover_image=(makes[:cover_image]) \ + @cover_image= + (makes[:cover_image]) \ ? (makes[:cover_image]) \ : @cover_image end @@ -1117,7 +1160,11 @@ module SiSU_Param : '' 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 + 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 \ and para =~/^=\{(.+?)\}\s*$/ @@ -1151,11 +1198,11 @@ module SiSU_Param elsif para =~/^1~\s+(.+)$/ t=$1 end - unless @heading_seg_first_flag # extract first segment name + unless @heading_seg_first_flag # extract first segment name @heading_seg_first=t @heading_seg_first_flag=true end - if m # list all segment names + if m # list all segment names @seg_names << m @set_heading_seg=true if m=~/^\d{1,3}/ \ @@ -1164,7 +1211,7 @@ module SiSU_Param end end end - para=para.gsub(/<:=(\S+?)>/,'{ c_\1.png 14x14 }image') # embedded symbol (image) + para=para.gsub(/<:=(\S+?)>/,'{ c_\1.png 14x14 }image') # embedded symbol (image) if para !~/^%+\s/ \ and para =~@rgx_image @ec[:image] << para.scan(@rgx_image).uniq @@ -1178,7 +1225,11 @@ module SiSU_Param unless @make if (@opt.act[:verbose_plus][:set]==:on \ || @opt.act[:maintenance][:set]==:on) - SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'@make:','header absent').warn + SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + '@make:', + 'header absent' + ).warn end @make=SiSU_Param::Parameters::MdMake.new('@make: ',@opt,@env).make end @@ -1318,15 +1369,25 @@ module SiSU_Param if @en[:note] > 0 \ and @en[:sum] > 0 if @en[:sum] > 0 - else SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'*WARN* both endnote styles used',"~{ #{@en[:sum]} }~ and ^~ #{@en[:mark]}").warn unless @opt.act[:quiet][:set]==:on + else + SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + '*WARN* both endnote styles used', + "~{ #{@en[:sum]} }~ and ^~ #{@en[:mark]}" + ).warn unless @opt.act[:quiet][:set]==:on end end if @en[:mark] != @en[:note] \ and @en[:note] > 0 @en[:mismatch]=@en[:note] - @en[:mark] - SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'*WARN* endnote number mismatch',"endnotes: #{@en[:note]} != endnote reference marks: #{@en[:mark]} (difference = #{@en[:mismatch]})").warn unless @opt.act[:quiet][:set]==:on + SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + '*WARN* endnote number mismatch', + "endnotes: #{@en[:note]} != endnote reference marks: #{@en[:mark]} (difference = #{@en[:mismatch]})" + ).warn unless @opt.act[:quiet][:set]==:on footnote_conversion_errors=File.new("#{Dir.pwd}/footnote_conversion_errors.txt",'a') - footnote_conversion_errors << "#{@fns}:\n\tendnotes: #{@en[:note]} != endnote reference marks: #{@en[:mark]} (difference = #{@en[:mismatch]})\n" + footnote_conversion_errors << + "#{@fns}:\n\tendnotes: #{@en[:note]} != endnote reference marks: #{@en[:mark]} (difference = #{@en[:mismatch]})\n" end if not @title \ or not defined? @title.main \ @@ -1335,7 +1396,11 @@ module SiSU_Param and @opt.inspect =~/P/ #@title=Md.new('Text Insert',@opt,@env).title else - SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'WARNING: Document Title missing','please provide @title:').warn unless @opt.act[:quiet][:set]==:on + SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + 'WARNING: Document Title missing', + 'please provide @title:' + ).warn unless @opt.act[:quiet][:set]==:on end end if @author !~/[\S]/ @@ -1343,7 +1408,11 @@ module SiSU_Param and @opt.inspect =~/P/ #@creator=SiSU_Param::Md.new('Text Insert',@opt,@env).creator else - SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'WARNING: Document Author missing','please provide @creator: :author:').warn unless @opt.act[:quiet][:set]==:on + SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + 'WARNING: Document Author missing', + 'please provide @creator: :author:' + ).warn unless @opt.act[:quiet][:set]==:on end end @struct={} @@ -1426,7 +1495,10 @@ module SiSU_Param File.unlink(pstorefile) if FileTest.file?(pstorefile) if (@md.opt.act[:verbose_plus][:set]==:on \ || @md.opt.act[:maintenance][:set]==:on) - SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],"PStore -> #{pstorefile}").txt_grey + SiSU_Screen::Ansi.new( + @md.opt.act[:color_state][:set], + "PStore -> #{pstorefile}" + ).txt_grey end store=PStore.new(pstorefile) store.transaction do @@ -1447,10 +1519,26 @@ module SiSU_Param class Instantiate def param_instantiate @@date=SiSU_Env::InfoDate.new - @@proc=@@filename_txt=@@filename_texinfo=@@filename_lout_portrait=@@filename_lout_landscape=@@filename_html_scroll=@@filename_html_index=@@filename_html_segtoc=@@filename_semantic=@@filename_rss=@@newfile=@@drr=nil + @@proc= + @@filename_txt= + @@filename_texinfo= + @@filename_lout_portrait= + @@filename_lout_landscape= + @@filename_html_scroll= + @@filename_html_index= + @@filename_html_segtoc= + @@filename_semantic= + @@filename_rss= + @@newfile= + @@drr= + nil @doc={ initialise: nil, - markup: '', lnks: '', stmp: '', prefix_a: '', prefix_b: '', + markup: '', + lnks: '', + stmp: '', + prefix_a: '', + prefix_b: '', req: {} } @@yaml=@@yamladdr=nil diff --git a/lib/sisu/v6/ao.rb b/lib/sisu/v6/ao.rb index 064436ae..370bb7e1 100644 --- a/lib/sisu/v6/ao.rb +++ b/lib/sisu/v6/ao.rb @@ -162,7 +162,9 @@ module SiSU_AO : @opt.fns @@idx_arr[:sst]=[] end - ao=(@@idx_arr[:sst].empty?) ? read_idx_sst : @@idx_arr[:sst].dup #check + ao=(@@idx_arr[:sst].empty?) \ + ? read_idx_sst + : @@idx_arr[:sst].dup #check rescue SiSU_Errors::Rescued.new($!,$@,@opt.cmd,@opt.fns).location do __LINE__.to_s + ':' + __FILE__ @@ -181,7 +183,9 @@ module SiSU_AO : @opt.fns @@idx_arr[:tex]=[] end - ao=(@@idx_arr[:tex].empty?) ? read_idx_raw : @@idx_arr[:tex].dup #check + ao=(@@idx_arr[:tex].empty?) \ + ? read_idx_raw + : @@idx_arr[:tex].dup #check rescue SiSU_Errors::Rescued.new($!,$@,@opt.cmd,@opt.fns).location do __LINE__.to_s + ':' + __FILE__ @@ -200,7 +204,9 @@ module SiSU_AO : @opt.fns @@idx_arr[:html]=[] end - ao=(@@idx_arr[:html].empty?) ? read_idx_html : @@idx_arr[:html].dup + ao=(@@idx_arr[:html].empty?) \ + ? read_idx_html + : @@idx_arr[:html].dup rescue SiSU_Errors::Rescued.new($!,$@,@opt.cmd,@opt.fns).location do __LINE__.to_s + ':' + __FILE__ @@ -219,7 +225,9 @@ module SiSU_AO : @opt.fns @@idx_arr[:xthml]=[] end - ao=(@@idx_arr[:xhtml].empty?) ? read_idx_xhtml : @@idx_arr[:xhtml].dup + ao=(@@idx_arr[:xhtml].empty?) \ + ? read_idx_xhtml + : @@idx_arr[:xhtml].dup rescue SiSU_Errors::Rescued.new($!,$@,@opt.cmd,@opt.fns).location do __LINE__.to_s + ':' + __FILE__ @@ -238,7 +246,9 @@ module SiSU_AO : @opt.fns @@map_arr[:nametags]=[] end - ao=(@@map_arr[:nametags].empty?) ? read_map_nametags : @@map_arr[:nametags].dup + ao=(@@map_arr[:nametags].empty?) \ + ? read_map_nametags + : @@map_arr[:nametags].dup rescue SiSU_Errors::Rescued.new($!,$@,@opt.cmd,@opt.fns).location do __LINE__.to_s + ':' + __FILE__ @@ -257,7 +267,9 @@ module SiSU_AO : @opt.fns @@map_arr[:ocn_htmlseg]=[] end - ao=(@@map_arr[:ocn_htmlseg].empty?) ? read_map_ocn_htmlseg : @@map_arr[:ocn_htmlseg].dup + ao=(@@map_arr[:ocn_htmlseg].empty?) \ + ? read_map_ocn_htmlseg + : @@map_arr[:ocn_htmlseg].dup rescue SiSU_Errors::Rescued.new($!,$@,@opt.cmd,@opt.fns).location do __LINE__.to_s + ':' + __FILE__ @@ -273,8 +285,14 @@ module SiSU_AO tell=(@opt.act[:verbose][:set]==:on \ || @opt.act[:verbose_plus][:set]==:on \ || @opt.act[:maintenance][:set]==:on) \ - ? SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Document Abstraction') - : SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Document Abstraction',"[#{@opt.f_pth[:lng_is]}] #{@opt.fno}") + ? SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + 'Document Abstraction' + ) + : SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + 'Document Abstraction',"[#{@opt.f_pth[:lng_is]}] #{@opt.fno}" + ) tell.blue_title_hi end fn=(@fnx && @fnx =~/\.ss[tmi]$/) \ @@ -293,9 +311,16 @@ module SiSU_AO cf=SiSU_Env::CreateFile.new(fn) if (@opt.act[:verbose][:set]==:on \ || @opt.act[:verbose_plus][:set]==:on) - SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],@opt.fns,"~meta/#{@opt.fns}.meta").output + SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + @opt.fns, + "~meta/#{@opt.fns}.meta" + ).output elsif @opt.act[:maintenance][:set]==:on - SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"ao -> #{cf.meta}").txt_grey + SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + "ao -> #{cf.meta}" + ).txt_grey end end ao.each {|s| ao_array << s} @@ -435,7 +460,8 @@ module SiSU_AO if defined? o.ocn case o.is when :heading - filename_debug.puts "#{o.is.to_s} #{o.lv}~#{o.name} odv=#{o.odv} osp=#{o.osp} [#{o.ocn}] -->\n\t#{o.obj}" + filename_debug.puts + "#{o.is.to_s} #{o.lv}~#{o.name} odv=#{o.odv} osp=#{o.osp} [#{o.ocn}] -->\n\t#{o.obj}" end end end @@ -507,23 +533,37 @@ module SiSU_AO reset data_txt=@data data_txt= - SiSU_AO_Insertions::Insertions.new(@md,data_txt).expand_insertions? # ao_expand_insertions.rb + SiSU_AO_Insertions::Insertions.new(@md,data_txt). # ao_expand_insertions.rb + expand_insertions? data_txt= - SiSU_AO_MiscArrangeText::SI.new(@md,data_txt).prepare_text # ao_misc_arrange.rb - data_obj,metadata= - SiSU_AO_DocumentStructureExtract::Build.new(@md,data_txt).identify_parts # ao_doc_str.rb + SiSU_AO_MiscArrangeText::SI.new(@md,data_txt). # ao_misc_arrange.rb + prepare_text + data_obj, + metadata= + SiSU_AO_DocumentStructureExtract::Build.new(@md,data_txt). # ao_doc_str.rb + identify_parts data_obj= - SiSU_AO_Syntax::Markup.new(@md,data_obj).songsheet # ao_syntax.rb - data_obj,endnote_array= - SiSU_AO_CharacterCheck::Check.new(data_obj).character_check_and_oldstyle_endnote_array # ao_character_check.rb + SiSU_AO_Syntax::Markup.new(@md,data_obj).songsheet # ao_syntax.rb + data_obj, + endnote_array= + SiSU_AO_CharacterCheck::Check.new(data_obj). # ao_character_check.rb + character_check_and_oldstyle_endnote_array data_obj= - SiSU_AO_Images::Images.new(@md,data_obj).images # ao_images.rb - data_obj,tags_map,ocn_html_seg_map= - SiSU_AO_Numbering::Numbering.new(@md,data_obj).numbering_song # ao_numbering.rb - data_obj,book_index_rel,book_index_rel_html_seg,html_idx,xhtml_idx= - SiSU_AO_BookIndex::BookIndex.new(@md,data_obj,@env).indexing_song if @md.book_idx # ao_idx.rb + SiSU_AO_Images::Images.new(@md,data_obj).images # ao_images.rb + data_obj, + tags_map, + ocn_html_seg_map= + SiSU_AO_Numbering::Numbering.new(@md,data_obj). # ao_numbering.rb + numbering_song + data_obj, + book_index_rel, + book_index_rel_html_seg, + html_idx,xhtml_idx= + SiSU_AO_BookIndex::BookIndex.new(@md,data_obj,@env). # ao_idx.rb + indexing_song if @md.book_idx data_obj= - SiSU_AO_Endnotes::Endnotes.new(@md,data_obj,endnote_array).endnotes # ao_endnotes.rb + SiSU_AO_Endnotes::Endnotes.new(@md,data_obj,endnote_array). # ao_endnotes.rb + endnotes outputdata=data_obj if (@md.opt.act[:ao][:set]==:on \ || @md.opt.act[:maintenance][:set]==:on) diff --git a/lib/sisu/v6/ao_character_check.rb b/lib/sisu/v6/ao_character_check.rb index 8774d7a8..22655797 100644 --- a/lib/sisu/v6/ao_character_check.rb +++ b/lib/sisu/v6/ao_character_check.rb @@ -80,9 +80,9 @@ module SiSU_AO_CharacterCheck gsub(/(#{Mx[:en_a_o]})\s*\s+/,'\1 '). gsub(/(~\{\s*)\s+/,'\1 '). gsub(/ \/\//,"#{Mx[:br_line]}"). - gsub(/
/,"#{Mx[:br_line]}"). #needed by xml, xhtml etc. + gsub(/
/,"#{Mx[:br_line]}"). #needed by xml, xhtml etc. gsub(/\t/,' '). - gsub(/\342\200\231/u,"'"). #if dob =~/’/ #Avoid #‘ ’ #“ ” + gsub(/\342\200\231/u,"'"). #if dob =~/’/ #Avoid #‘ ’ #“ ” gsub(/\\copy(?:right)?\b/,'©'). gsub(/\\trademark\b|\\tm\b/,'®') dob.obj=dob.obj + "\n" @@ -91,8 +91,9 @@ module SiSU_AO_CharacterCheck when /\^~/ #% Note must do this first (earlier loop) and then enter gathered data into ~^\d+ sub_dob=dob.obj.dup @endnote_array << sub_dob.gsub(/\n/,''). - gsub(/\^~\s+(.+)\s*/,%{#{Mx[:en_a_o]}#{endnote_no} \\1 #{Mx[:en_a_c]}}). - strip + gsub(/\^~\s+(.+)\s*/, + %{#{Mx[:en_a_o]}#{endnote_no} \\1 #{Mx[:en_a_c]}}). + strip endnote_no+=1 dob=nil if dob.obj =~/\^~ .+/ #watch, removes 'binary' endnote now in endnote array for later insertion end diff --git a/lib/sisu/v6/ao_composite.rb b/lib/sisu/v6/ao_composite.rb index f8c4b396..2f864228 100644 --- a/lib/sisu/v6/ao_composite.rb +++ b/lib/sisu/v6/ao_composite.rb @@ -74,7 +74,8 @@ module SiSU_Assemble end def download_images(images_info) path="#{@env.processing_path.processing}/external_document/image" - FileUtils::mkdir_p(path) unless FileTest.directory?(path) + FileUtils::mkdir_p(path) \ + unless FileTest.directory?(path) download_from=images_info.shift images_info.each do |i| image="#{path}/#{i}" @@ -85,7 +86,8 @@ module SiSU_Assemble imagefile.close end output_path="#{@env.path.webserv}/#{@env.path.stub_pwd}/_sisu/image_external" - FileUtils::mkdir_p(output_path) unless FileTest.directory?(output_path) + FileUtils::mkdir_p(output_path) \ + unless FileTest.directory?(output_path) SiSU_Env::SystemCall.new("#{path}/*",output_path,'q').rsync end end @@ -99,8 +101,8 @@ module SiSU_Assemble begin pwd=Dir.pwd Dir.chdir(@opt.f_pth[:pth]) - @fns_array=IO.readlines(@opt.fno,'') - assembled=insertions? + fns_array=IO.readlines(@opt.fno,'') + assembled=insertions?(fns_array) write(assembled) Dir.chdir(pwd) rescue @@ -141,7 +143,9 @@ module SiSU_Assemble end if not @code_flag \ and i !~/^%+\s/ - i=i.gsub(/^([123]|:?[ABCD])~\? /,'% [conditional heading:] \1~ ') #off conditional heading (consider syntax) + i=i. + gsub(/^([123]|:?[ABCD])~\? /, + '% [conditional heading:] \1~ ') #off conditional heading (consider syntax) if i =~/^@\S+?:/ i=i.gsub(/\n/m,"\n% "). gsub(/\n%\s+$/m,''). @@ -161,27 +165,36 @@ module SiSU_Assemble end file end - def insertions? - data=@fns_array + def insertions?(fns_array) 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| + 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 + fns_array.each do |para| if para =~/^<<\s+(\S+?\.ss[it])$/ loadfile=$1.strip - src_ssm=@opt.fns.sub(/\.ssm\.sst/,'.ssm') if (@opt.act[:verbose][:set]==:on \ || @opt.act[:verbose_plus][:set]==:on \ || @opt.act[:maintenance][:set]==:on) - SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'loading:',loadfile).txt_grey + SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + 'loading:', + loadfile, + ).txt_grey end - tuned_file << if loadfile =~ /(?:https?|file):\/\/\S+?\.ss[ti]$/ # and NetTest - imagedir = /((?:https?|file):\/\/\S+?)\/[^\/]+?\.ss[ti]$/.match(loadfile).captures.join + '/_sisu/image' #watch + tuned_file << if loadfile =~ /(?:https?|file):\/\/\S+?\.ss[it]$/ # and NetTest + imagedir = /((?:https?|file):\/\/\S+?)\/[^\/]+?\.ss[it]$/. + match(loadfile).captures.join + + '/_sisu/image' #watch begin require 'uri' require 'open-uri' require 'pp' rescue LoadError - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('uri, open-uri or pp NOT FOUND (LoadError)') + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). + error('uri, open-uri or pp NOT FOUND (LoadError)') end image_uri=URI.parse(imagedir) insert=open(loadfile) @@ -191,13 +204,12 @@ module SiSU_Assemble @@imager[image_uri] ||=[] @@imager[image_uri] << file[:images] file[:prepared] - elsif loadfile =~ /\.ss[ti]$/ \ + elsif loadfile =~ /\.ss[it]$/ \ and FileTest.file?(loadfile) insert_array=IO.readlines(loadfile,'') file=insertion(loadfile,insert_array) file[:prepared] else - cX=SiSU_Screen::Ansi.new(@opt.act[:color_state][:set]).cX 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 @@ -225,8 +237,8 @@ module SiSU_Assemble def read begin @opt.fns=@opt.fns.gsub(/\.ssm\.sst$/,'.ssm') #FIX earlier, hub - @fns_array=IO.readlines(@opt.fns,'') - insertions? + fns_array=IO.readlines(@opt.fns,'') + insertions?(fns_array) rescue SiSU_Errors::Rescued.new($!,$@,@opt.cmd,@opt.fns).location do __LINE__.to_s + ':' + __FILE__ @@ -234,26 +246,32 @@ module SiSU_Assemble ensure end end - def insertions? - data=@fns_array + def insertions?(fns_array) tuned_file=[] - SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Composite Document',@opt.fno).grey_title_hi unless @opt.act[:quiet][:set]==:on + SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + 'Composite Document', + @opt.fno + ).grey_title_hi unless @opt.act[:quiet][:set]==:on @ssm=[@opt.fns] - data.each do |para| + fns_array.each do |para| if para =~/^<<\s+(\S+?\.ss[it])$/ loadfile=$1.strip if (@opt.act[:verbose][:set]==:on \ || @opt.act[:verbose_plus][:set]==:on \ || @opt.act[:maintenance][:set]==:on) - SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'loading:',loadfile).txt_grey + SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + 'loading:', + loadfile, + ).txt_grey end - tuned_file << if loadfile =~ /(?:https?|file):\/\/\S+?\.ss[ti]$/ + tuned_file << if loadfile =~ /(?:https?|file):\/\/\S+?\.ss[it]$/ @ssm << loadfile - elsif loadfile =~ /\.ss[ti]$/ \ + elsif loadfile =~ /\.ss[it]$/ \ and FileTest.file?(loadfile) @ssm << loadfile else - cX=SiSU_Screen::Ansi.new(@opt.act[:color_state][:set]).cX 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 diff --git a/lib/sisu/v6/ao_doc_objects.rb b/lib/sisu/v6/ao_doc_objects.rb index ee229200..909bb600 100644 --- a/lib/sisu/v6/ao_doc_objects.rb +++ b/lib/sisu/v6/ao_doc_objects.rb @@ -74,10 +74,10 @@ module SiSU_AO_DocumentStructure @of=:meta end def metadata(tags) - of= @of #Symbol, classification - group - is= :meta #Symbol, classification - specific type - tags= tags || ((defined? o.tags) ? o.tags : {}) #String, metadata type/tag - obj= nil + of = @of #Symbol, classification - group + is = :meta #Symbol, classification - specific type + tags = tags || ((defined? o.tags) ? o.tags : {}) #String, metadata type/tag + obj = nil @of,@is,@tags,@obj=of,is,tags,obj self end @@ -89,12 +89,12 @@ module SiSU_AO_DocumentStructure @of=:meta end def metadata(h,o=nil) - of= @of #Symbol, classification - group - is= :meta #Symbol, classification - specific type - 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, sha512, sha256 or md5 + of = @of #Symbol, classification - group + is = :meta #Symbol, classification - specific type + 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, sha512, sha256 or md5 @of,@is,@tag,@obj,@digest,@tmp=of,is,tag,obj,digest,tmp self end @@ -142,44 +142,47 @@ module SiSU_AO_DocumentStructure and (h[:ln] and h[:ln].to_s=~/[0-9]/) h[:lv]=heading_lv(h[:ln]) end - of= @of #Symbol, classification - group - is= :heading #Symbol, classification - specific type - name= h[:name] || ((defined? o.name) ? o.name : nil) #String, named object? - tags= h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any - obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content - idx= h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? - ocn= h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects - odv= h[:odv] || ((defined? o.odv) ? o.odv : nil) - osp= h[:osp] || ((defined? o.osp) ? o.osp : nil) - node= h[:node] || ((defined? o.node) ? o.node : nil) #[Node relationship doc structure info] - parent= h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] - 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) - 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 - autonum_= if h[:autonum_].nil? then ((defined? o.autonum_) ? o.autonum_ : true) #Bool? auto-numbering if requested default on, false suppresses - 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, 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,@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 + of = @of #Symbol, classification - group + is = :heading #Symbol, classification - specific type + name = h[:name] || ((defined? o.name) ? o.name : nil) #String, named object? + tags = h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any + obj = h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content + idx = h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? + ocn = h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects + odv = h[:odv] || ((defined? o.odv) ? o.odv : nil) + osp = h[:osp] || ((defined? o.osp) ? o.osp : nil) + node = h[:node] || ((defined? o.node) ? o.node : nil) #[Node relationship doc structure info] + parent = h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] + 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) + 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? + ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider + else h[:ocn_] + end + autonum_ = if h[:autonum_].nil? + ((defined? o.autonum_) ? o.autonum_ : true) #Bool? auto-numbering if requested default on, false suppresses + 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, 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,@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) heading(h,o=nil) - @is= :heading_insert #String, classification - specific type + @is = :heading_insert #String, classification - specific type self end end @@ -191,52 +194,56 @@ module SiSU_AO_DocumentStructure @tags=[] end def paragraph(h,o=nil) - of= @of #Symbol, classification - group - is= :para #Symbol, classification - specific type - name= h[:name] || ((defined? o.name) ? o.name : nil) #String, named object? - tags= h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any - obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content - idx= h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? - ocn= h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects - odv= h[:odv] || ((defined? o.odv) ? o.odv : nil) - osp= h[:osp] || ((defined? o.osp) ? o.osp : nil) - parent= h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] - indent= h[:indent].to_s || ((defined? o.indent) ? o.indent.to_s : nil) #Integer, indent level - hang= h[:hang].to_s || ((defined? o.hang) ? o.hang.to_s : nil) #Integer, hanging indent level - bullet_=h[:bullet_] || ((defined? o.bullet_) ? o.bullet_ : false) #Bool, bulleted? - quote_= h[:quote_] || ((defined? o.quote_) ? o.quote_ : false) #Bool, quote (blockquote)? - note_= h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) - image_= h[:image_] || ((defined? o.image_) ? o.image_ : false) #Bool, images? (processing optimization) - 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_] + of = @of #Symbol, classification - group + is = :para #Symbol, classification - specific type + name = h[:name] || ((defined? o.name) ? o.name : nil) #String, named object? + tags = h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any + obj = h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content + idx = h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? + ocn = h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects + odv = h[:odv] || ((defined? o.odv) ? o.odv : nil) + osp = h[:osp] || ((defined? o.osp) ? o.osp : nil) + parent = h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] + indent = h[:indent].to_s || ((defined? o.indent) ? o.indent.to_s : nil) #Integer, indent level + hang = h[:hang].to_s || ((defined? o.hang) ? o.hang.to_s : nil) #Integer, hanging indent level + bullet_ = h[:bullet_] || ((defined? o.bullet_) ? o.bullet_ : false) #Bool, bulleted? + quote_ = h[:quote_] || ((defined? o.quote_) ? o.quote_ : false) #Bool, quote (blockquote)? + note_ = h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) + image_ = h[:image_] || ((defined? o.image_) ? o.image_ : false) #Bool, images? (processing optimization) + ocn_ = if h[:ocn_].nil? + ((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, 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_,@quote_,@idx,@ocn,@odv,@osp,@parent,@image_,@note_,@ocn_,@digest,@tmp=of,is,name,tags,obj,indent,hang,bullet_,quote_,idx,ocn,odv,osp,parent,image_,note_,ocn_,digest,tmp + 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_,@quote_,@idx,@ocn,@odv,@osp,@parent,@image_,@note_,@ocn_,@digest,@tmp= + of, is, name, tags, obj, indent, hang, bullet_, quote_, idx, ocn, odv, osp, parent, image_, note_, ocn_, digest, tmp self end def docinfo(h,o=nil) - of= @of #String, classification - group - is= :docinfo #String, classification - specific type - name= h[:name] || ((defined? o.name) ? o.name : nil) #String, named object? - tags= h[:tags] || ((defined? o.tags) ? o.tags : nil) #Array, associated object tags, names if any - obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content - idx= nil #String, book index provided? - ocn= nil #Integer, sequential on substantive-content objects - odv= h[:odv] || ((defined? o.odv) ? o.odv : nil) - osp= h[:osp] || ((defined? o.osp) ? o.osp : nil) - parent= h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] - indent= nil #Integer, indent level - hang= nil #Integer, indent level - bullet_=false #Bool, bulleted? - note_= false #Bool, endnotes/footnotes? (processing optimization) - image_= h[:image_] || ((defined? o.image_) ? o.image_ : false) #Bool, images? (processing optimization) - 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_] + of = @of #String, classification - group + is = :docinfo #String, classification - specific type + name = h[:name] || ((defined? o.name) ? o.name : nil) #String, named object? + tags = h[:tags] || ((defined? o.tags) ? o.tags : nil) #Array, associated object tags, names if any + obj = h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content + idx = nil #String, book index provided? + ocn = nil #Integer, sequential on substantive-content objects + odv = h[:odv] || ((defined? o.odv) ? o.odv : nil) + osp = h[:osp] || ((defined? o.osp) ? o.osp : nil) + parent = h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] + indent = nil #Integer, indent level + hang = nil #Integer, indent level + bullet_ = false #Bool, bulleted? + note_ = false #Bool, endnotes/footnotes? (processing optimization) + image_ = h[:image_] || ((defined? o.image_) ? o.image_ : false) #Bool, images? (processing optimization) + ocn_ = if h[:ocn_].nil? + ((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, 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 + 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 end end @@ -248,124 +255,136 @@ module SiSU_AO_DocumentStructure @tags=[] end def code(h,o=nil) - of= @of #Symbol, classification - group #alt 'code' - is= :code #Symbol, classification - specific type - tags= h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any - obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content - lngsyn= h[:lngsyn] || ((defined? o.lngsyn) ? o.lngsyn : :txt) #symbol, code lngsyn - idx= h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? - ocn= h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects - odv= h[:odv] || ((defined? o.odv) ? o.odv : nil) - osp= h[:osp] || ((defined? o.osp) ? o.osp : nil) - parent= h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] - number_= h[:number_] || ((defined? o.number_) ? o.number_ : false) #Bool, numbered or not? - note_= h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) - 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_] + of = @of #Symbol, classification - group #alt 'code' + is = :code #Symbol, classification - specific type + tags = h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any + obj = h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content + lngsyn = h[:lngsyn] || ((defined? o.lngsyn) ? o.lngsyn : :txt) #symbol, code lngsyn + idx = h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? + ocn = h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects + odv = h[:odv] || ((defined? o.odv) ? o.odv : nil) + osp = h[:osp] || ((defined? o.osp) ? o.osp : nil) + parent = h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] + number_ = h[:number_] || ((defined? o.number_) ? o.number_ : false) #Bool, numbered or not? + note_ = h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) + ocn_ = if h[:ocn_].nil? + ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider + else h[:ocn_] end - num= h[:num] || ((defined? o.num) ? o.num : nil) - digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, sha512, sha256 or md5 - tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use - @of,@is,@tags,@obj,@lngsyn,@idx,@ocn,@odv,@osp,@parent,@number_,@note_,@ocn_,@num,@digest,@tmp=of,is,tags,obj,lngsyn,idx,ocn,odv,osp,parent,number_,note_,ocn_,num,digest,tmp + num = h[:num] || ((defined? o.num) ? o.num : nil) + 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,@lngsyn,@idx,@ocn,@odv,@osp,@parent,@number_,@note_,@ocn_,@num,@digest,@tmp= + of, is, tags, obj, lngsyn, idx, ocn, odv, osp, parent, number_, note_, ocn_, num, digest, tmp self end def box(h,o=nil) - of= @of #Symbol, classification - group - is= :box #Symbol, classification - specific type - tags= h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any - obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content - idx= h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? - ocn= h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects - odv= h[:odv] || ((defined? o.odv) ? o.odv : nil) - osp= h[:osp] || ((defined? o.osp) ? o.osp : nil) - parent= h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] - note_= h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) - 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_] + of = @of #Symbol, classification - group + is = :box #Symbol, classification - specific type + tags = h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any + obj = h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content + idx = h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? + ocn = h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects + odv = h[:odv] || ((defined? o.odv) ? o.odv : nil) + osp = h[:osp] || ((defined? o.osp) ? o.osp : nil) + parent = h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] + note_ = h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) + ocn_ = if h[:ocn_].nil? + ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider + else h[:ocn_] end - num= h[:num] || ((defined? o.num) ? o.num : nil) - digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, 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 + num = h[:num] || ((defined? o.num) ? o.num : nil) + 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 end def block(h,o=nil) - of= @of #Symbol, classification - group - is= :block #Symbol, classification - specific type - tags= h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any - obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content - idx= h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? - ocn= h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects - odv= h[:odv] || ((defined? o.odv) ? o.odv : nil) - osp= h[:osp] || ((defined? o.osp) ? o.osp : nil) - parent= h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] - note_= h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) - 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_] + of = @of #Symbol, classification - group + is = :block #Symbol, classification - specific type + tags = h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any + obj = h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content + idx = h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? + ocn = h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects + odv = h[:odv] || ((defined? o.odv) ? o.odv : nil) + osp = h[:osp] || ((defined? o.osp) ? o.osp : nil) + parent = h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] + note_ = h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) + ocn_ = if h[:ocn_].nil? + ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider + else h[:ocn_] end - num= h[:num] || ((defined? o.num) ? o.num : nil) - digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, 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 + num = h[:num] || ((defined? o.num) ? o.num : nil) + 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 end def group(h,o=nil) - of= @of #Symbol, classification - group - is= :group #Symbol, classification - specific type - tags= h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any - obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content - idx= h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? - ocn= h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects - odv= h[:odv] || ((defined? o.odv) ? o.odv : nil) - osp= h[:osp] || ((defined? o.osp) ? o.osp : nil) - parent= h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] - note_= h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) - 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_] + of = @of #Symbol, classification - group + is = :group #Symbol, classification - specific type + tags = h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any + obj = h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content + idx = h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? + ocn = h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects + odv = h[:odv] || ((defined? o.odv) ? o.odv : nil) + osp = h[:osp] || ((defined? o.osp) ? o.osp : nil) + parent = h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] + note_ = h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) + ocn_ = if h[:ocn_].nil? + ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider + else h[:ocn_] end - num= h[:num] || ((defined? o.num) ? o.num : nil) - digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, 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 + num = h[:num] || ((defined? o.num) ? o.num : nil) + 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 end - def alt(h,o=nil) #see block - of= @of #Symbol, classification - group - is= :alt #Symbol, classification - specific type - tags= h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any - obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content - idx= h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? - ocn= h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects - odv= h[:odv] || ((defined? o.odv) ? o.odv : nil) - osp= h[:osp] || ((defined? o.osp) ? o.osp : nil) - parent= h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] - note_= h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) - 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_] + def alt(h,o=nil) #see block + of = @of #Symbol, classification - group + is = :alt #Symbol, classification - specific type + tags = h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any + obj = h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content + idx = h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? + ocn = h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects + odv = h[:odv] || ((defined? o.odv) ? o.odv : nil) + osp = h[:osp] || ((defined? o.osp) ? o.osp : nil) + parent = h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] + note_ = h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) + ocn_ = if h[:ocn_].nil? + ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider + else h[:ocn_] end - num= h[:num] || ((defined? o.num) ? o.num : nil) - digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, 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 + num = h[:num] || ((defined? o.num) ? o.num : nil) + 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 end - def verse(h,o=nil) #part of poem decide how you deal with this - of= @of #Symbol, classification - group - is= :verse #Symbol, classification - specific type - tags= h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any - obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content - idx= h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? - ocn= h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects - odv= h[:odv] || ((defined? o.odv) ? o.odv : nil) - osp= h[:osp] || ((defined? o.osp) ? o.osp : nil) - parent= h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] - 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_] + def verse(h,o=nil) #part of poem decide how you deal with this + of = @of #Symbol, classification - group + is = :verse #Symbol, classification - specific type + tags = h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any + obj = h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content + idx = h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? + ocn = h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects + odv = h[:odv] || ((defined? o.odv) ? o.odv : nil) + osp = h[:osp] || ((defined? o.osp) ? o.osp : nil) + parent = h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] + ocn_ = if h[:ocn_].nil? + ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider + else h[:ocn_] end - num= h[:num] || ((defined? o.num) ? o.num : nil) - digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, 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 + num = h[:num] || ((defined? o.num) ? o.num : nil) + 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 self end @@ -378,26 +397,28 @@ module SiSU_AO_DocumentStructure @tags=[] end def table(h,o=nil) - of= @of #Symbol, classification - group - is= :table #Symbol, classification - specific type - tags= h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any - cols= h[:cols] || ((defined? o.cols) ? o.cols : nil) - widths= h[:widths] || ((defined? o.widths) ? o.widths : nil) - obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content - idx= h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? - ocn= h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects - odv= h[:odv] || ((defined? o.odv) ? o.odv : nil) - osp= h[:osp] || ((defined? o.osp) ? o.osp : nil) - parent= h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] - head_= h[:head_] || ((defined? o.head_) ? o.head_ : false) - note_= h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) - 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_] + of = @of #Symbol, classification - group + is = :table #Symbol, classification - specific type + tags = h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any + cols = h[:cols] || ((defined? o.cols) ? o.cols : nil) + widths = h[:widths] || ((defined? o.widths) ? o.widths : nil) + obj = h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content + idx = h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? + ocn = h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects + odv = h[:odv] || ((defined? o.odv) ? o.odv : nil) + osp = h[:osp] || ((defined? o.osp) ? o.osp : nil) + parent = h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] + head_ = h[:head_] || ((defined? o.head_) ? o.head_ : false) + note_ = h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) + ocn_ = if h[:ocn_].nil? + ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider + else h[:ocn_] end - num= h[:num] || ((defined? o.num) ? o.num : nil) - digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, 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 + num = h[:num] || ((defined? o.num) ? o.num : nil) + 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 end end @@ -420,8 +441,9 @@ module SiSU_AO_DocumentStructure osp= h[:osp] || ((defined? o.osp) ? o.osp : nil) parent= h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] note_= h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) - 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_] + ocn_=if h[:ocn_].nil? + ((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, sha512, sha256 or md5 tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use @@ -507,7 +529,8 @@ module SiSU_AO_DocumentStructure attr= h[:attr] || ((defined? o.attr) ? o.attr : nil) #String, text content tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use num= h[:num] || ((defined? o.num) ? o.num : nil) - @of,@is,@obj,@sym,@attr,@tmp,@num=of,is,obj,sym,attr,tmp,num + @of,@is,@obj,@sym,@attr,@tmp,@num= + of, is, obj, sym, attr, tmp, num self end end diff --git a/lib/sisu/v6/ao_doc_str.rb b/lib/sisu/v6/ao_doc_str.rb index 7f2815d8..675bfc90 100644 --- a/lib/sisu/v6/ao_doc_str.rb +++ b/lib/sisu/v6/ao_doc_str.rb @@ -154,12 +154,18 @@ module SiSU_AO_DocumentStructureExtract [0,0] end obj=if str2 =~/^(.+?)\s+\\\\(?:\s+|\n)/ - str2.gsub(/^(.+?)(\s+\\\\(?:\s+|\n))/,"#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}\\2") + str2.gsub(/^(.+?)(\s+\\\\(?:\s+|\n))/, + "#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}\\2") else - str2.gsub(/^(.+?)\n/,"#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}\n") + str2.gsub(/^(.+?)\n/, + "#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}\n") end hang,indent=hang_indent[0],hang_indent[1] - [hang,indent,obj] + [ + hang, + indent, + obj, + ] end def endnote_test?(str) (str=~/~\{.+?\}~|~\[.+?\]~/) \ @@ -182,7 +188,10 @@ module SiSU_AO_DocumentStructureExtract t.gsub!(/[^a-z0-9._-]/,'') end end - [str,tags] + [ + str, + tags, + ] end def rgx_idx_ocn_seg @rgx_idx_ocn_seg=/(.+?)\s*[+](\d+)/ @@ -196,9 +205,13 @@ module SiSU_AO_DocumentStructureExtract idx_couplet_tmp=[] idx_couplet=idx.scan(/\s*[^:]+\s*/) if idx_couplet[1] =~/[|]/ - idx_couplet_tmp << idx_couplet[0] << idx_couplet[1].scan(/\s*[^|]+\s*/) + idx_couplet_tmp << + idx_couplet[0] << + idx_couplet[1].scan(/\s*[^|]+\s*/) else - idx_couplet_tmp << idx_couplet[0] << [idx_couplet[1]] + idx_couplet_tmp << + idx_couplet[0] << + [idx_couplet[1]] end idx_couplet=idx_couplet_tmp else [idx] @@ -207,14 +220,17 @@ module SiSU_AO_DocumentStructureExtract idx_lst.each do |term_node| case term_node when String - term_node=term_node[0].chr.capitalize + term_node[1,term_node.length] + term_node= + term_node[0].chr.capitalize + + term_node[1,term_node.length] term_node=(term_node =~/.+?[+]\d+/) \ ? term_node : (term_node + '+0') term_nodes << term_node use,plus=rgx_idx_ocn_seg.match(term_node)[1,2] @use=use.strip - idx_hash[@use]={ sub: [], plus: plus } unless idx_hash[@use] and defined? idx_hash[@use] + idx_hash[@use]= + { sub: [], plus: plus } unless idx_hash[@use] and defined? idx_hash[@use] when Array subterm_nodes=[] term_node.each do |subterm_node| @@ -223,15 +239,20 @@ module SiSU_AO_DocumentStructureExtract : (subterm_node + '+0') subterm_nodes << subterm_node sub,sub_plus=rgx_idx_ocn_seg.match(subterm_node)[1,2] - idx_hash[@use]={ sub: [], plus: 0 } unless idx_hash[@use] and defined? idx_hash[@use] - idx_hash[@use][:sub] << {sub.strip => { plus: sub_plus }} + idx_hash[@use]= + { sub: [], plus: 0 } unless idx_hash[@use] and defined? idx_hash[@use] + idx_hash[@use][:sub] << + { sub.strip => { plus: sub_plus } } end term_nodes << subterm_nodes end end idx_array << term_nodes end - { hash: idx_hash, array: idx_array } + { + hash: idx_hash, + array: idx_array, + } end def identify_parts tuned_file=[] @@ -252,16 +273,26 @@ module SiSU_AO_DocumentStructureExtract h=case $1 when /[+]/ @@flag[:ocn]=:on - {flag: :ocn_on} + { + flag: :ocn_on, + } when /[~]/ @@flag[:ocn]=:ocn_off_headings_keep - {flag: :ocn_off, mod: :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} + { + flag: :ocn_off, + mod: :headings_exclude, + } else @@flag[:ocn]=:on - {flag: :ocn_on} + { + flag: :ocn_on, + } end t_o=SiSU_AO_DocumentStructure::ObjectFlag.new.flag_ocn(h) next @@ -296,7 +327,7 @@ module SiSU_AO_DocumentStructureExtract t_o=nil when /^%+\s/ #comment t_o=if t_o=~/^%+\s+(.+)/ - h={obj: $1} + h={ obj: $1 } SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) else nil end @@ -319,7 +350,13 @@ module SiSU_AO_DocumentStructureExtract end end end - h={ lv: lv, ln: ln, obj: obj, idx: idx, tags: tags } + h={ + lv: lv, + ln: ln, + obj: obj, + idx: idx, + tags: tags, + } SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h) elsif t_o=~/^:?[A-D1-6]\~(\S+?)-\s+(.+)/m name,obj=$1,$2 @@ -337,7 +374,14 @@ module SiSU_AO_DocumentStructureExtract end end end - h={ lv: lv, name: name, obj: obj, idx: idx, autonum_: false, tags: tags} + h={ + lv: lv, + name: name, + obj: obj, + idx: idx, + autonum_: false, + tags: tags, + } SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h) elsif t_o=~/^:?[A-D1-6]\~(\S+)\s+(.+)/m name,obj=$1,$2 @@ -355,7 +399,13 @@ module SiSU_AO_DocumentStructureExtract end end end - h={ lv: lv, name: name, obj: obj, idx: idx, tags: tags } + h={ + lv: lv, + name: name, + obj: obj, + idx: idx, + tags: tags, + } SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h) else nil end @@ -378,7 +428,17 @@ module SiSU_AO_DocumentStructureExtract obj << ' ~#' end end - h={ bullet_: bullet, hang: hang, indent: indent, obj: obj, idx: idx, note_: note, image_: image, tags: tags, quote: quotes? } + h={ + bullet_: bullet, + hang: hang, + indent: indent, + obj: obj, + idx: idx, + note_: note, + image_: image, + tags: tags, + quote: quotes?, + } SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h) end else nil @@ -401,7 +461,16 @@ module SiSU_AO_DocumentStructureExtract obj << ' ~#' end end - h={ hang: hang, indent: indent, obj: obj, idx: idx, note_: note, image_: image, tags: tags, quote: quotes? } + h={ + hang: hang, + indent: indent, + obj: obj, + idx: idx, + note_: note, + image_: image, + tags: tags, + quote: quotes?, + } SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h) end else nil @@ -425,7 +494,17 @@ module SiSU_AO_DocumentStructureExtract end end unless obj=~/\A\s*\Z/m - h={ bullet_: false, indent: 0, hang: 0, obj: obj, idx: idx, note_: note, image_: image, tags: tags, quote: quotes? } + h={ + bullet_: false, + indent: 0, + hang: 0, + obj: obj, + idx: idx, + note_: note, + image_: image, + tags: tags, + quote: quotes?, + } SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h) end end @@ -447,9 +526,17 @@ module SiSU_AO_DocumentStructureExtract else :txt end @@counter=1 - @codeblock_numbered=(t_o =~/^(?:code(?:\.[a-z][0-9a-z_]+)?\{#|```[ ]+code(?:\.[a-z][0-9a-z_]+)?\s[#])/) ? true : false + @codeblock_numbered= + (t_o =~/^(?:code(?:\.[a-z][0-9a-z_]+)?\{#|```[ ]+code(?:\.[a-z][0-9a-z_]+)?\s[#])/) \ + ? true + : false @num_id[:code_block] +=1 - h={ obj: '', sym: :code_block_open, num: @num_id[:code_block], syntax: @@flag[:lngsyn] } + h={ + obj: '', + sym: :code_block_open, + num: @num_id[:code_block], + syntax: @@flag[:lngsyn], + } t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) elsif t_o =~/^(?:poem\{|```[ ]+poem)/ @@flag[:poem]=case t_o @@ -458,58 +545,86 @@ module SiSU_AO_DocumentStructureExtract else @@flag[:poem] #error end @num_id[:poem] +=1 - h={ obj: '', sym: :poem_open, num: @num_id[:poem] } + h={ + obj: '', + sym: :poem_open, + num: @num_id[:poem], + } t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) tuned_file << t_o elsif t_o =~/^(?:box(?:\.[a-z_]+)?\{|```[ ]+box(?:\.[a-z_]+)?)/ @@flag[:box]=case t_o when /^box\{/ then :curls when /^```[ ]+box/ then :tics - else @@flag[:box] #error + else @@flag[:box] #error end @num_id[:box] +=1 - h={ obj: '', sym: :box_open, num: @num_id[:box] } + h={ + obj: '', + sym: :box_open, + num: @num_id[:box], + } t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) tuned_file << t_o elsif t_o =~/^(?:group\{|```[ ]+group)/ @@flag[:group]=case t_o when /^group\{/ then :curls when /^```[ ]+group/ then :tics - else @@flag[:group] #error + else @@flag[:group] #error end @num_id[:group] +=1 - h={ obj: '', sym: :group_open, num: @num_id[:group] } + h={ + obj: '', + sym: :group_open, + num: @num_id[:group], + } t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) tuned_file << t_o elsif t_o =~/^(?:block\{|```[ ]+block)/ @@flag[:block]=case t_o when /^block\{/ then :curls when /^```[ ]+block/ then :tics - else @@flag[:block] #error + else @@flag[:block] #error end @num_id[:block] +=1 - h={ obj: '', sym: :block_open, num: @num_id[:block] } + h={ + obj: '', + sym: :block_open, + num: @num_id[:block], + } t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) tuned_file << t_o elsif t_o =~/^(?:alt\{|```[ ]+alt)/ @@flag[:alt]=case t_o when /^alt\{/ then :curls when /^```[ ]+alt/ then :tics - else @@flag[:alt] #error + else @@flag[:alt] #error end @num_id[:alt] +=1 - h={ obj: '', sym: :alt_open, num: @num_id[:alt] } + h={ + obj: '', + sym: :alt_open, + num: @num_id[:alt], + } t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) tuned_file << t_o elsif t_o =~/^`:quote_open`/ @@flag[:quote]=:open @num_id[:quote] +=1 - h={ obj: '', sym: :quote_open, num: @num_id[:quote] } + h={ + obj: '', + sym: :quote_open, + num: @num_id[:quote], + } t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) #tuned_file << t_o #% find second source, entered twice, should be once so closed off here elsif t_o =~/^(?:table\{|```[ ]+table|\{table)[ ~]/ @num_id[:table] +=1 - h={ obj: '', sym: :table_open, num: @num_id[:table] } + h={ + obj: '', + sym: :table_open, + num: @num_id[:table], + } ins_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) tuned_file << ins_o if t_o=~/^table\{(?:~h)?\s+/ @@ -525,7 +640,12 @@ module SiSU_AO_DocumentStructureExtract col=$2.scan(/\d+/) heading=false end - @h={ head_: heading, cols: cols, widths: col, idx: idx } + @h={ + head_: heading, + cols: cols, + widths: col, + idx: idx, + } elsif t_o=~/^```[ ]+table(?:~h)?\s+c\d+/ @@flag[:table]=:tics @rows='' @@ -539,7 +659,12 @@ module SiSU_AO_DocumentStructureExtract col=$2.scan(/\d+/) heading=false end - @h={ head_: heading, cols: cols, widths: col, idx: idx } + @h={ + head_: heading, + cols: cols, + widths: col, + idx: idx, + } elsif t_o=~/^\{table(?:~h)?(?:\s+\d+;?)?\}\n.+\Z/m m1,m2,hd=nil,nil,nil tbl=/^\{table(?:~h)?(?:\s+\d+;?)?\}\n(.+)\Z/m.match(t_o)[1] @@ -550,7 +675,7 @@ module SiSU_AO_DocumentStructureExtract cols=nil rws.each do |r| cols=(cols ? cols : (r.scan('|').length) +1) - r=r.gsub(/\s*\|\s*/m,"#{Mx[:tc_p]}") #r.gsub!(/\|/m,"#{Mx[:tc_p]}") + r=r.gsub(/\s*\|\s*/m,"#{Mx[:tc_p]}") #r.gsub!(/\|/m,"#{Mx[:tc_p]}") rows += r + Mx[:tc_c] end col=[] @@ -563,18 +688,30 @@ module SiSU_AO_DocumentStructureExtract width=100.00/cols cols.times { col << width } end - h={ head_: hd, cols: cols, widths: col, obj: rows, idx: idx, tags: tags, num: @num_id[:table] } + h={ + head_: hd, + cols: cols, + widths: col, + obj: rows, + idx: idx, + tags: tags, + num: @num_id[:table], + } t_o=SiSU_AO_DocumentStructure::ObjectTable.new.table(h) unless h.nil? tuned_file << t_o - h={ obj: '', sym: :table_close, num: @num_id[:table] } + h={ + obj: '', + sym: :table_close, + num: @num_id[:table], + } t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) t_o elsif t_o=~/^```[ ]+table(?:~h)?\s+/ m1,m2,hd=nil,nil,nil h=case t_o - when /^```[ ]+table~h\s+(.+?)\n(.+)\Z/m #two table representations should be consolidated as one + when /^```[ ]+table~h\s+(.+?)\n(.+)\Z/m #two table representations should be consolidated as one m1,tbl,hd=$1,$2,true - when /^```[ ]+table\s+(.+?)\n(.+)\Z/m #two table representations should be consolidated as one + when /^```[ ]+table\s+(.+?)\n(.+)\Z/m #two table representations should be consolidated as one m1,tbl,hd=$1,$2,false else nil end @@ -583,13 +720,25 @@ module SiSU_AO_DocumentStructureExtract rws=tbl.split(/\n/) rows='' rws.each do |r| - r=r.gsub(/\s*\|\s*/m,"#{Mx[:tc_p]}") #r.gsub!(/\|/m,"#{Mx[:tc_p]}") + r=r.gsub(/\s*\|\s*/m,"#{Mx[:tc_p]}") #r.gsub!(/\|/m,"#{Mx[:tc_p]}") rows += r + Mx[:tc_c] end - h={ head_: hd, cols: col.length, widths: col, obj: rows, idx: idx, tags: tags, num: @num_id[:table] } + h={ + head_: hd, + cols: col.length, + widths: col, + obj: rows, + idx: idx, + tags: tags, + num: @num_id[:table], + } t_o=SiSU_AO_DocumentStructure::ObjectTable.new.table(h) unless h.nil? tuned_file << t_o - h={ obj: '', sym: :table_close, num: @num_id[:table] } + h={ + obj: '', + sym: :table_close, + num: @num_id[:table], + } t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) t_o elsif t_o=~/^\{table(?:~h)?\s+/ @@ -606,13 +755,25 @@ module SiSU_AO_DocumentStructureExtract rws=tbl.split(/\n/) rows='' rws.each do |r| - r=r.gsub(/\s*\|\s*/m,"#{Mx[:tc_p]}") #r.gsub!(/\|/m,"#{Mx[:tc_p]}") + r=r.gsub(/\s*\|\s*/m,"#{Mx[:tc_p]}") #r.gsub!(/\|/m,"#{Mx[:tc_p]}") rows += r + Mx[:tc_c] end - h={ head_: hd, cols: col.length, widths: col, obj: rows, idx: idx, tags: tags, num: @num_id[:table] } + h={ + head_: hd, + cols: col.length, + widths: col, + obj: rows, + idx: idx, + tags: tags, + num: @num_id[:table], + } t_o=SiSU_AO_DocumentStructure::ObjectTable.new.table(h) unless h.nil? tuned_file << t_o - h={ obj: '', sym: :table_close, num: @num_id[:table] } + h={ + obj: '', + sym: :table_close, + num: @num_id[:table], + } t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) t_o end @@ -626,11 +787,21 @@ module SiSU_AO_DocumentStructureExtract and t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) @@flag[:table]=:off headings,columns,widths,idx=@h[:head_],@h[:cols],@h[:widths],@h[:idx] - @h={ head_: headings, cols: columns, widths: widths, idx: idx, obj: @rows } + @h={ + head_: headings, + cols: columns, + widths: widths, + idx: idx, + obj: @rows, + } t_o=SiSU_AO_DocumentStructure::ObjectTable.new.table(@h) tuned_file << t_o @h,@rows=nil,'' - h={ obj: '', sym: :table_close, num: @num_id[:table] } + h={ + obj: '', + sym: :table_close, + num: @num_id[:table], + } t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) t_o else @@ -650,12 +821,22 @@ module SiSU_AO_DocumentStructureExtract @tuned_code[-1].gsub!(/\s*(?:#{Mx[:br_line]}|#{Mx[:br_nl]})\s*\Z/m,'') obj=@tuned_code.join("\n") tags=[] - h={ obj: obj, syntax: @@flag[:lngsyn], tags: tags, num: @num_id[:code_block], number_: @codeblock_numbered } + h={ + obj: obj, + syntax: @@flag[:lngsyn], + tags: tags, + num: @num_id[:code_block], + number_: @codeblock_numbered, + } @@flag[:lngsyn]=:txt t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.code(h) @tuned_code=[] tuned_file << t_o - h={ obj: '', sym: :code_close, num: @num_id[:code_block] } + h={ + obj: '', + sym: :code_close, + num: @num_id[:code_block], + } t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) end if (@@flag[:code]==:curls or @@flag[:code]==:tics) \ @@ -676,55 +857,102 @@ module SiSU_AO_DocumentStructureExtract if (@@flag[:poem]==:curls and t_o =~/^\}poem/) \ or (@@flag[:poem]==:tics and t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) @@flag[:poem]=:off - h={ obj: '', sym: :poem_close, num: @num_id[:poem] } + h={ + obj: '', + sym: :poem_close, + num: @num_id[:poem], + } t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) elsif (@@flag[:box]==:curls and t_o =~/^\}box/) \ or (@@flag[:box]==:tics and t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) @@flag[:box]=:off obj,tags=extract_tags(@tuned_block.join("\n")) - h={ obj: obj, tags: tags, num: @num_id[:box] } + h={ + obj: obj, + tags: tags, + num: @num_id[:box], + } @tuned_block=[] t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.box(h) tuned_file << t_o - h={ obj: '', sym: :box_close, num: @num_id[:box] } + h={ + obj: '', + sym: :box_close, + num: @num_id[:box], + } t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) elsif (@@flag[:group]==:curls and t_o =~/^\}group/) \ or (@@flag[:group]==:tics and t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) @@flag[:group]=:off obj,tags=extract_tags(@tuned_block.join("\n")) - h={ obj: obj, tags: tags, num: @num_id[:group] } + h={ + obj: obj, + tags: tags, + num: @num_id[:group], + } @tuned_block=[] t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.group(h) tuned_file << t_o - h={ obj: '', sym: :group_close, num: @num_id[:group] } + h={ + obj: '', + sym: :group_close, + num: @num_id[:group], + } t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) elsif (@@flag[:block]==:curls and t_o =~/^\}block/) \ or (@@flag[:block]==:tics and t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) @@flag[:block]=:off obj,tags=extract_tags(@tuned_block.join("\n")) - h={ obj: obj, tags: tags, num: @num_id[:block] } + h={ + obj: obj, + tags: tags, + num: @num_id[:block], + } @tuned_block=[] t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.block(h) tuned_file << t_o - h={ obj: '', sym: :block_close, num: @num_id[:block] } + h={ obj: '', + sym: :block_close, + num: @num_id[:block], + } t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) elsif (@@flag[:alt]==:curls and t_o =~/^\}alt/) \ or (@@flag[:alt]==:tics and t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) @@flag[:alt]=:off obj,tags=extract_tags(@tuned_block.join("\n")) - h={ obj: obj, tags: tags, num: @num_id[:alt] } + h={ + obj: obj, + tags: tags, + num: @num_id[:alt], + } t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.alt(h) @tuned_block=[] tuned_file << t_o - h={ obj: '', sym: :alt_close, num: @num_id[:alt] } + h={ + obj: '', + sym: :alt_close, + num: @num_id[:alt], + } t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) elsif @@flag[:quote]==:open and t_o =~/`:quote_close`/m @@flag[:quote]=:off - h={ obj: '', sym: :quote_close, num: @num_id[:quote] } + h={ + obj: '', + sym: :quote_close, + num: @num_id[:quote], + } t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) elsif @@flag[:quote]==:open t_o,tags=extract_tags(t_o) - h={ indent: 1, obj: t_o, idx: idx, note_: note, image_: image, tags: tags, quote: quotes? } + h={ + indent: 1, + obj: t_o, + idx: idx, + note_: note, + image_: image, + tags: tags, + quote: quotes?, + } SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h) end if (@@flag[:poem]==:curls or @@flag[:poem]==:tics \ @@ -741,7 +969,11 @@ module SiSU_AO_DocumentStructureExtract poem.each do |v| v=v.gsub(/\n/m,"#{Mx[:br_nl]}\n") obj,tags=extract_tags(v) - h={ obj: obj, tags: tags, num: @num_id[:poem] } + h={ + obj: obj, + tags: tags, + num: @num_id[:poem], + } t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.verse(h) tuned_file << t_o end @@ -779,26 +1011,67 @@ module SiSU_AO_DocumentStructureExtract end if @md.flag_endnotes tuned_file << @pb - h={ ln: 1, lc: 1, obj: 'Endnotes', autonum_: false } + h={ + ln: 1, + lc: 1, + obj: 'Endnotes', + autonum_: false, + } tuned_file << SiSU_AO_DocumentStructure::ObjectHeading.new.heading_insert(h) - h={ ln: 4, lc: 2, obj: 'Endnotes', name: 'endnotes', autonum_: false } + h={ + ln: 4, + lc: 2, + obj: 'Endnotes', + name: 'endnotes', + autonum_: false, + } tuned_file << SiSU_AO_DocumentStructure::ObjectHeading.new.heading_insert(h) - h={ obj: 'Endnotes' } + h={ + obj: 'Endnotes' + } end if @md.book_idx tuned_file << @pb - h={ ln: 1, lc: 1, obj: 'Index', autonum_: false } + h={ + ln: 1, + lc: 1, + obj: 'Index', + autonum_: false, + } tuned_file << SiSU_AO_DocumentStructure::ObjectHeading.new.heading_insert(h) - h={ ln: 4, lc: 2, obj: 'Index', name: 'book_index', autonum_: false } + h={ + ln: 4, + lc: 2, + obj: 'Index', + name: 'book_index', + autonum_: false, + } tuned_file << SiSU_AO_DocumentStructure::ObjectHeading.new.heading_insert(h) - h={ obj: 'Index' } + h={ + obj: 'Index' + } end tuned_file << @pb - h={ ln: 1, lc: 1, obj: 'Metadata', autonum_: false, ocn_: false } + h={ + ln: 1, + lc: 1, + obj: 'Metadata', + autonum_: false, + ocn_: false, + } tuned_file << SiSU_AO_DocumentStructure::ObjectHeading.new.heading_insert(h) - h={ ln: 4, lc: 2, obj: 'SiSU Metadata, document information', name: 'metadata', autonum_: false, ocn_: false } + h={ + ln: 4, + lc: 2, + obj: 'SiSU Metadata, document information', + name: 'metadata', + autonum_: false, + ocn_: false, + } tuned_file << SiSU_AO_DocumentStructure::ObjectHeading.new.heading_insert(h) - h={ obj: 'eof' } + h={ + obj: 'eof', + } meta=SiSU_AO_DocumentStructure::ObjectMetadata.new.metadata(@metadata) [tuned_file,meta] end @@ -811,11 +1084,20 @@ module SiSU_AO_DocumentStructureExtract table end def meta_heading(h) - h={ lv: h[:lv], ln: h[:ln], name: h[:name], obj: h[:obj], ocn: '0' } + h={ + lv: h[:lv], + ln: h[:ln], + name: h[:name], + obj: h[:obj], + ocn: '0', + } SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h) end def meta_para(str) - h={ obj: str, ocn_: false } + h={ + obj: str, + ocn_: false, + } SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h) end def build_lines(type=:none) @@ -831,7 +1113,7 @@ module SiSU_AO_DocumentStructureExtract line=line.gsub(/^/,"#{Mx[:gr_o]}codeline#{Mx[:gr_c]}") if type==:code # REMOVE try sort for texpdf special case line=if line =~/(?:https?|file|ftp):\/\/\S+$/ line.gsub(/\s*$/," #{Mx[:br_nl]}") - else line.gsub(/\s*$/,"#{Mx[:br_nl]}") #unless type=='code' + else line.gsub(/\s*$/,"#{Mx[:br_nl]}") #unless type=='code' end elsif line =~/^\s*$/ line.gsub(/\s*$/,"#{Mx[:br_nl]}") @@ -857,25 +1139,46 @@ module SiSU_AO_DocumentStructureExtract and not @dob.bullet_ @dob=case @dob.obj when /^#{@md.lv0}/ - h={ lv: 'A', ln: 0 } + h={ + lv: 'A', + ln: 0, + } SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,@dob) when /^#{@md.lv1}/ - h={ lv: 'B', ln: 1 } + h={ + lv: 'B', + ln: 1, + } SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,@dob) when /^#{@md.lv2}/ - h={ lv: 'C', ln: 2 } + h={ + lv: 'C', + ln: 2, + } SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,@dob) when /^#{@md.lv3}/ - h={ lv: 'D', ln: 3 } + h={ + lv: 'D', + ln: 3, + } SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,@dob) when /^#{@md.lv4}/ - h={ lv: '1', ln: 4 } + h={ + lv: '1', + ln: 4, + } SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,@dob) when /^#{@md.lv5}/ - h={ lv: '2', ln: 5 } + h={ + lv: '2', + ln: 5, + } SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,@dob) when /^#{@md.lv6}/ - h={ lv: '3', ln: 6 } + h={ + lv: '3', + ln: 6, + } SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,@dob) else @dob end @@ -1269,7 +1572,8 @@ SKIPPED processing file: [#{@md.opt.lng}] "#{@md.fns}"} end if dob.is==:heading if ocn_flag==true - 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 + 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 heading_use=:ok @@ -1280,19 +1584,22 @@ SKIPPED processing file: [#{@md.opt.lng}] "#{@md.fns}"} 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 + 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 \ && dob.of !=:comment \ && dob.of !=:layout if ocn_flag == true - dob.ocn,dob.ocn_,dob.odv,dob.osp,dob.parent=ocn,ocn_flag,ocn_dv,ocn_sp,parent + dob.ocn,dob.ocn_,dob.odv,dob.osp,dob.parent= + ocn, ocn_flag,ocn_dv, ocn_sp, parent 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.ocn,dob.ocn_,dob.odv,dob.osp,dob.parent=nil,ocn_flag,ocn_dv,ocn_sp,parent + dob.ocn,dob.ocn_,dob.odv,dob.osp,dob.parent= + nil, ocn_flag,ocn_dv, ocn_sp, parent end end end @@ -1340,7 +1647,10 @@ SKIPPED processing file: [#{@md.opt.lng}] "#{@md.fns}"} data=@data tuned_file=[] hs=[0,false,false,false] - t={ lv: @s[0], status: :open } + t={ + lv: @s[0], + status: :open, + } tuned_file << tags(t) if @md.opt.act[:verbose_plus][:set]==:on puts "\nXML sisu structure outline --->\n" @@ -1432,7 +1742,13 @@ SKIPPED processing file: [#{@md.opt.lng}] "#{@md.fns}"} when '5' then 8 when '6' then 9 end - h={ tag: tag, node: o[:node], lv: o[:lv], ln: ln, status: o[:status] } + h={ + tag: tag, + node: o[:node], + lv: o[:lv], + ln: ln, + status: o[:status], + } SiSU_AO_DocumentStructure::ObjectStructure.new.xml_dom(h) #downstream code utilise else ignore like comments end def tag_open(o,tag) @@ -1445,121 +1761,205 @@ SKIPPED processing file: [#{@md.opt.lng}] "#{@md.fns}"} case hs[0] when 0 if (lev <= 0) and hs[0] - t={ lv: @s[0], status: :close } + t={ + lv: @s[0], + status: :close, + } ary << tags(t) end when 1 if (lev <= 1) and hs[1] - t={ lv: @s[1], status: :close } + t={ + lv: @s[1], + status: :close, + } ary << tags(t) end if (lev==0) - t={ lv: @s[0], status: :close } + t={ + lv: @s[0], + status: :close, + } ary << tags(t) end when 2 if (lev <= 2) and hs[2] - t={ lv: @s[2], status: :close } + t={ + lv: @s[2], + status: :close, + } ary << tags(t) end if (lev <= 1) and hs[1] - t={ lv: @s[1], status: :close } + t={ + lv: @s[1], + status: :close, + } ary << tags(t) end if (lev==0) - t={ lv: @s[0], status: :close } + t={ + lv: @s[0], + status: :close, + } ary << tags(t) end when 3 if (lev <= 3) and hs[3] - t={ lv: @s[3], status: :close } + t={ + lv: @s[3], + status: :close, + } ary << tags(t) end if (lev <= 2) and hs[2] - t={ lv: @s[2], status: :close } + t={ + lv: @s[2], + status: :close, + } ary << tags(t) end if (lev <= 1) and hs[1] - t={ lv: @s[1], status: :close } + t={ + lv: @s[1], + status: :close, + } ary << tags(t) end if (lev==0) - t={ lv: @s[0], status: :close } + t={ + lv: @s[0], + status: :close, + } ary << tags(t) end when 4 if (lev <= 4) - t={ lv: @s[4], status: :close } + t={ + lv: @s[4], + status: :close, + } ary << tags(t) end if (lev <= 3) and hs[3] - t={ lv: @s[3], status: :close } + t={ + lv: @s[3], + status: :close, + } ary << tags(t) end if (lev <= 2) and hs[2] - t={ lv: @s[2], status: :close } + t={ + lv: @s[2], + status: :close, + } ary << tags(t) end if (lev <= 1) and hs[1] - t={ lv: @s[1], status: :close } + t={ + lv: @s[1], + status: :close, + } ary << tags(t) end if (lev==0) - t={ lv: @s[0], status: :close } + t={ + lv: @s[0], + status: :close, + } ary << tags(t) end when 5 if (lev <= 5) - t={ lv: @s[5], status: :close } + t={ + lv: @s[5], + status: :close, + } ary << tags(t) end if (lev <= 4) - t={ lv: @s[4], status: :close } + t={ + lv: @s[4], + status: :close, + } ary << tags(t) end if (lev <= 3) and hs[3] - t={ lv: @s[3], status: :close } + t={ + lv: @s[3], + status: :close, + } ary << tags(t) end if (lev <= 2) and hs[2] - t={ lv: @s[2], status: :close } + t={ + lv: @s[2], + status: :close, + } ary << tags(t) end if (lev <= 1) and hs[1] - t={ lv: @s[1], status: :close } + t={ + lv: @s[1], + status: :close, + } ary << tags(t) end if (lev==0) - t={ lv: @s[0], status: :close } + t={ + lv: @s[0], + status: :close, + } ary << tags(t) end when 6 if (lev <= 6) - t={ lv: @s[6], status: :close } + t={ + lv: @s[6], + status: :close, + } ary << tags(t) end if (lev <= 5) - t={ lv: @s[5], status: :close } + t={ + lv: @s[5], + status: :close, + } ary << tags(t) end if (lev <= 4) - t={ lv: @s[4], status: :close } + t={ + lv: @s[4], + status: :close, + } ary << tags(t) end if (lev <= 3) and hs[3] - t={ lv: @s[3], status: :close } + t={ + lv: @s[3], + status: :close, + } ary << tags(t) end if (lev <= 2) and hs[2] - t={ lv: @s[2], status: :close } + t={ + lv: @s[2], + status: :close, + } ary << tags(t) end if (lev <= 1) and hs[1] - t={ lv: @s[1], status: :close } + t={ + lv: @s[1], + status: :close, + } ary << tags(t) end if (lev==0) - t={ lv: @s[0], status: :close } + t={ + lv: @s[0], + status: :close, + } ary << tags(t) end end diff --git a/lib/sisu/v6/ao_endnotes.rb b/lib/sisu/v6/ao_endnotes.rb index 21509098..dbc8b214 100644 --- a/lib/sisu/v6/ao_endnotes.rb +++ b/lib/sisu/v6/ao_endnotes.rb @@ -63,8 +63,12 @@ module SiSU_AO_Endnotes class Endnotes def initialize(md,data,endnote_array=nil) - @md,@data,@endnote_array=md,data,endnote_array - @endnote_counter,@endnote_counter_asterisk,@endnote_counter_dag=1,1,1 + @md,@data,@endnote_array= + md, data, endnote_array + @endnote_counter, + @endnote_counter_asterisk, + @endnote_counter_dag= + 1,1,1 end def endnotes data=@data @@ -73,17 +77,20 @@ module SiSU_AO_Endnotes data.each do |dob| # manually numbered endnotes --> if @md.opt.mod.inspect =~/--no-asterisk|--no-annotate/ - dob.obj=dob.obj.gsub(/#{Mx[:en_b_o]}\s.+?#{Mx[:en_b_c]}/,'') + dob.obj=dob.obj. + gsub(/#{Mx[:en_b_o]}\s.+?#{Mx[:en_b_c]}/,'') end if @md.opt.mod.inspect =~/--no-dagger|--no-annotate/ - dob.obj=dob.obj.gsub(/#{Mx[:en_b_o]}[+]\s.+?#{Mx[:en_b_c]}/,'') + dob.obj=dob.obj. + gsub(/#{Mx[:en_b_o]}[+]\s.+?#{Mx[:en_b_c]}/,'') end if (defined? dob.obj) \ && (defined? dob.is) \ && dob.is !=:code case dob.obj # auto-numbered endnotes --> when /#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}[*+]\s+.+?#{Mx[:en_b_c]}/ - dob.obj=dob.obj.gsub(/\s*(#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/,'\1') + dob.obj=dob.obj. + gsub(/\s*(#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/,'\1') word_mode=dob.obj.scan(/\S+/m) word_mode=endnote_call_number(word_mode) dob.obj=word_mode.join(' ') @@ -97,7 +104,10 @@ module SiSU_AO_Endnotes end @tuned_file << dob end - @endnote_counter,@endnote_counter_asterisk,@endnote_counter_dag=1,1,1 + @endnote_counter, + @endnote_counter_asterisk, + @endnote_counter_dag= + 1,1,1 @tuned_file=@tuned_file.flatten end def endnote_call_number(words) @@ -105,20 +115,24 @@ module SiSU_AO_Endnotes case word when /#{Mx[:en_a_o]}/ unless word =~/#{Mx[:en_a_o]}[*+]+/ - word.gsub!(/#{Mx[:en_a_o]}/,"#{Mx[:en_a_o]}#{@endnote_counter} ") + word.gsub!(/#{Mx[:en_a_o]}/, + "#{Mx[:en_a_o]}#{@endnote_counter} ") @endnote_counter+=1 end when /#{Mx[:en_b_o]}/ if word =~/#{Mx[:en_b_o]}[+]/ - word.gsub!(/#{Mx[:en_b_o]}[+]/,"#{Mx[:en_b_o]}\+#{@endnote_counter_dag} ") + word.gsub!(/#{Mx[:en_b_o]}[+]/, + "#{Mx[:en_b_o]}\+#{@endnote_counter_dag} ") @endnote_counter_dag+=1 else - word.gsub!(/#{Mx[:en_b_o]}[*]?/,"#{Mx[:en_b_o]}\*#{@endnote_counter_asterisk} ") + word.gsub!(/#{Mx[:en_b_o]}[*]?/, + "#{Mx[:en_b_o]}\*#{@endnote_counter_asterisk} ") @endnote_counter_asterisk+=1 end when /~\^|<:e>/ if @endnote_array - word.gsub!(/~\^|<:e>/,"#{@endnote_array[@endnote_counter-1]}") + word.gsub!(/~\^|<:e>/, + "#{@endnote_array[@endnote_counter-1]}") @endnote_counter+=1 end end diff --git a/lib/sisu/v6/ao_expand_insertions.rb b/lib/sisu/v6/ao_expand_insertions.rb index 22e3b1ea..eee89f3e 100644 --- a/lib/sisu/v6/ao_expand_insertions.rb +++ b/lib/sisu/v6/ao_expand_insertions.rb @@ -77,33 +77,53 @@ module SiSU_AO_Insertions end file_type_names={} file_type_names[:gen],file_type_names[:src]=[],[] - file_type_names[:gen] <<= if cmd_list =~ /y/ then "~^ { document manifest }#{lnk[:manifest]}" + file_type_names[:gen] <<= if cmd_list =~ /y/ + "~^ { document manifest }#{lnk[:manifest]}" end - file_type_names[:gen] <<= if cmd_list =~ /h/ then [" { html, segmented text }#{lnk[:html_toc]}"," { html, scroll, document in one }#{lnk[:html_doc]}"] + file_type_names[:gen] <<= if cmd_list =~ /h/ + [ + " { html, segmented text }#{lnk[:html_toc]}", + " { html, scroll, document in one }#{lnk[:html_doc]}", + ] end - file_type_names[:gen] <<= if cmd_list =~ /e/ then [" { epub }#{lnk[:epub]}"] + file_type_names[:gen] <<= if cmd_list =~ /e/ + [" { epub }#{lnk[:epub]}"] end - file_type_names[:gen] <<= if cmd_list =~ /p/ then [" { pdf, landscape }#{lnk[:pdf_landscape]}"," { pdf, portrait }#{lnk[:pdf_portrait]}"] + file_type_names[:gen] <<= if cmd_list =~ /p/ + [ + " { pdf, landscape }#{lnk[:pdf_landscape]}", + " { pdf, portrait }#{lnk[:pdf_portrait]}", + ] end - file_type_names[:gen] <<= if cmd_list =~ /o/ then " { odf:odt, open document text }#{lnk[:odt]}" + file_type_names[:gen] <<= if cmd_list =~ /o/ + " { odf:odt, open document text }#{lnk[:odt]}" end - file_type_names[:gen] <<= if cmd_list =~ /b/ then " { xhtml scroll }#{lnk[:xhtml]}" + file_type_names[:gen] <<= if cmd_list =~ /b/ + " { xhtml scroll }#{lnk[:xhtml]}" end - file_type_names[:gen] <<= if cmd_list =~ /x/ then " { xml, sax }#{lnk[:xml_sax]}" + file_type_names[:gen] <<= if cmd_list =~ /x/ + " { xml, sax }#{lnk[:xml_sax]}" end - file_type_names[:gen] <<= if cmd_list =~ /X/ then " { xml, dom }#{lnk[:xml_dom]}" + file_type_names[:gen] <<= if cmd_list =~ /X/ + " { xml, dom }#{lnk[:xml_dom]}" end - file_type_names[:gen] <<= if cmd_list =~ /a/ then " { plain text utf-8 }#{lnk[:txt]}" + file_type_names[:gen] <<= if cmd_list =~ /a/ + " { plain text utf-8 }#{lnk[:txt]}" end - file_type_names[:gen] <<= if cmd_list =~ /g/ then 'wiki.txt' + file_type_names[:gen] <<= if cmd_list =~ /g/ + 'wiki.txt' end - file_type_names[:gen] <<= if cmd_list =~ /w/ then " { concordance }#{lnk[:html_concordance]}" + file_type_names[:gen] <<= if cmd_list =~ /w/ + " { concordance }#{lnk[:html_concordance]}" end - file_type_names[:gen] <<= if cmd_list =~ /N/ then " { dcc, document content certificate (digests) }#{lnk[:digest]}" + file_type_names[:gen] <<= if cmd_list =~ /N/ + " { dcc, document content certificate (digests) }#{lnk[:digest]}" end - file_type_names[:src] <<= if source and cmd_shortcut =~ /s/ then " { markup source text }#{lnk[:source]}" + file_type_names[:src] <<= if source and cmd_shortcut =~ /s/ + " { markup source text }#{lnk[:source]}" end - file_type_names[:src] <<= if cmd_shortcut =~ /S/ then " { markup source (zipped) pod }#{lnk[:sisupod]}" + file_type_names[:src] <<= if cmd_shortcut =~ /S/ + " { markup source (zipped) pod }#{lnk[:sisupod]}" end file_type_names[:gen]=file_type_names[:gen].flatten file_type_names[:src]=file_type_names[:src].flatten diff --git a/lib/sisu/v6/ao_hash_digest.rb b/lib/sisu/v6/ao_hash_digest.rb index 257902f4..b5a6aaea 100644 --- a/lib/sisu/v6/ao_hash_digest.rb +++ b/lib/sisu/v6/ao_hash_digest.rb @@ -85,8 +85,8 @@ module SiSU_AO_Hash t_o.obj=t_o.obj.strip end if (t_o.of !=:structure \ - && t_o.of !=:comment \ - && t_o.of !=:layout) \ + && t_o.of !=:comment \ + && t_o.of !=:layout) \ && t_o.ocn.is_a?(Fixnum) case sha_ when :sha512 @@ -114,7 +114,9 @@ module SiSU_AO_Hash t_o_bit <<= case en_plus when /#{Mx[:en_a_o]}|#{Mx[:en_b_o]}/ 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] + 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=case @env.digest(@md.opt).type when :sha512 @@ -126,7 +128,13 @@ module SiSU_AO_Hash 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 + 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 end else en_plus @@ -143,8 +151,10 @@ module SiSU_AO_Hash case t_o.obj when /#{Mx[:en_a_o]}[\d*+]+\s+.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}[*+]\d+\s+.+?#{Mx[:en_b_c]}/m en_and_t_o_digest=[] - t_o.obj=t_o.obj.gsub(/\s*(#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/m,' \1') #watch - t_o_plus_en=t_o.obj.scan(/.*?#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|.*?#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]}/m) + t_o.obj=t_o.obj. + gsub(/\s*(#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/m,' \1') #watch + t_o_plus_en=t_o.obj. + scan(/.*?#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|.*?#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]}/m) t_o_tail=if t_o.obj =~/(?:.*?#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|.*?#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})+([\s\S]+)/m /(?:.*?#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|.*?#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})+.*/m.match(t_o.obj)[1] else '' diff --git a/lib/sisu/v6/ao_idx.rb b/lib/sisu/v6/ao_idx.rb index eaaf7a90..7a4b1f03 100644 --- a/lib/sisu/v6/ao_idx.rb +++ b/lib/sisu/v6/ao_idx.rb @@ -67,14 +67,26 @@ module SiSU_AO_BookIndex @rgx_idx=/#{Mx[:idx_o]}(?:.+?)#{Mx[:idx_c]}\s*/ @rgx_idx_ocn_seg=/(.+?)~(\d+)~(\S+)/ @rgx_idx_ocn=/(.+?)~(\d+)/ - @ocn_html_identifier=SiSU_Env::ProcessingSettings.new(@md).ocn_html_identifier + @ocn_html_identifier= + SiSU_Env::ProcessingSettings.new(@md).ocn_html_identifier @env ||=SiSU_Env::InfoEnv.new(@md.fns) end def indexing_song data=@data - data,sisu_markup_idx_rel,sisu_markup_idx_rel_html_seg,html_idx,xhtml_idx=extract_book_index(data) - data=clean_and_insert_index(data,sisu_markup_idx_rel_html_seg) - [data,sisu_markup_idx_rel,sisu_markup_idx_rel_html_seg,html_idx,xhtml_idx] + data, + sisu_markup_idx_rel, + sisu_markup_idx_rel_html_seg, + html_idx,xhtml_idx= + extract_book_index(data) + data= + clean_and_insert_index(data,sisu_markup_idx_rel_html_seg) + [ + data, + sisu_markup_idx_rel, + sisu_markup_idx_rel_html_seg, + html_idx, + xhtml_idx, + ] end def extract_book_index(data) tuned_file=[] @@ -93,13 +105,25 @@ module SiSU_AO_BookIndex end if idx_array.length > 0 the_idx=construct_book_index(idx_array) - sisu_markup_idx_rel,sisu_markup_idx_rel_html_seg,html_idx,xhtml_idx=nil,nil,nil,nil if @md.book_idx idx=index(the_idx) - sisu_markup_idx_rel,sisu_markup_idx_rel_html_seg,html_idx,xhtml_idx=idx[:sst_rel],idx[:sst_rel_html_seg],idx[:html],idx[:xhtml] + sisu_markup_idx_rel,sisu_markup_idx_rel_html_seg,html_idx, xhtml_idx= + idx[:sst_rel], idx[:sst_rel_html_seg], idx[:html],idx[:xhtml] + else + sisu_markup_idx_rel= + sisu_markup_idx_rel_html_seg= + html_idx= + xhtml_idx= + nil end end - [tuned_file,sisu_markup_idx_rel,sisu_markup_idx_rel_html_seg,html_idx,xhtml_idx] + [ + tuned_file, + sisu_markup_idx_rel, + sisu_markup_idx_rel_html_seg, + html_idx, + xhtml_idx, + ] end def construct_book_index(idx_array) the_idx={} @@ -108,8 +132,12 @@ module SiSU_AO_BookIndex location=(term_info[:plus].to_i > 0) \ ? (%{#{idx[:ocn]}-#{idx[:ocn].to_i + term_info[:plus].to_i}}) : idx[:ocn].to_s - the_idx[term]={} unless the_idx[term] and defined? the_idx[term] - the_idx[term]['node_0_terms']=[] unless the_idx[term]['node_0_terms'] and defined? the_idx[term]['node_0_terms'] + the_idx[term]={} \ + unless the_idx[term] \ + and defined? the_idx[term] + the_idx[term]['node_0_terms']=[] \ + unless the_idx[term]['node_0_terms'] \ + and defined? the_idx[term]['node_0_terms'] the_idx[term]['node_0_terms'] << { ocn: idx[:ocn], range: location, seg: idx[:seg] } if term_info[:sub].is_a?(Array) \ and term_info[:sub].length > 0 @@ -118,11 +146,20 @@ module SiSU_AO_BookIndex location=(subterm_info[:plus].to_i > 0) \ ? (%{#{idx[:ocn]}-#{idx[:ocn].to_i + subterm_info[:plus].to_i}}) : idx[:ocn].to_s - the_idx[term]={} unless the_idx[term] and defined? the_idx[term] - the_idx[term]['node_0_terms']=[] unless the_idx[term]['node_0_terms'] and defined? the_idx[term]['node_0_terms'] - the_idx[term]['node_1_subterms']={} unless the_idx[term]['node_1_subterms'] and defined? the_idx[term]['node_1_subterms'] - the_idx[term]['node_1_subterms'][subterm]=[] unless the_idx[term]['node_1_subterms'][subterm] and defined? the_idx[term]['node_1_subterms'][subterm] - the_idx[term]['node_1_subterms'][subterm] << { ocn: idx[:ocn], range: location, seg: idx[:seg] } + the_idx[term]={} \ + unless the_idx[term] \ + and defined? the_idx[term] + the_idx[term]['node_0_terms']=[] \ + unless the_idx[term]['node_0_terms']\ + and defined? the_idx[term]['node_0_terms'] + the_idx[term]['node_1_subterms']={} \ + unless the_idx[term]['node_1_subterms'] \ + and defined? the_idx[term]['node_1_subterms'] + the_idx[term]['node_1_subterms'][subterm]=[] \ + unless the_idx[term]['node_1_subterms'][subterm] \ + and defined? the_idx[term]['node_1_subterms'][subterm] + the_idx[term]['node_1_subterms'][subterm] << + { ocn: idx[:ocn], range: location, seg: idx[:seg] } end end end @@ -138,16 +175,27 @@ module SiSU_AO_BookIndex def index(the_idx) @x=1 idx={} - idx[:sst_rel_html_seg],idx[:sst_rel],idx[:html],idx[:xhtml]=[],[],[],[] - h={obj: Mx[:br_page]} + idx[:sst_rel_html_seg],idx[:sst_rel],idx[:html],idx[:xhtml]= + [], [], [], [] + h={ + obj: Mx[:br_page] + } o=SiSU_AO_DocumentStructure::ObjectLayout.new.break(h) idx[:sst_rel_html_seg] << o idx[:sst_rel] << o - h={lv: '1', name: 'index', obj: "Index"} + h={ + lv: '1', + name: 'index', + obj: "Index" + } o=SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h) idx[:sst_rel_html_seg] << o idx[:sst_rel] << o - h={lv: '4', name: 'idx', obj: " [Index] #{Mx[:pa_non_object_dummy_heading]}"} + h={ + lv: '4', + name: 'idx', + obj: " [Index] #{Mx[:pa_non_object_dummy_heading]}" + } o=SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h) idx[:sst_rel_html_seg] << o idx[:sst_rel] << o @@ -159,15 +207,19 @@ module SiSU_AO_BookIndex idx[:html] << '' idx[:xhtml] << '' else - idx[:html] << %{#{x},#{$ep[:hsp]}} - idx[:xhtml] << %{#{x},#{$ep[:hsp]}} + idx[:html] << + %{#{x},#{$ep[:hsp]}} + idx[:xhtml] << + %{#{x},#{$ep[:hsp]}} end end idx[:html] << '

' idx[:xhtml] << '

' letter=alph.shift - idx[:html] << %{\n

} - idx[:xhtml] << %{\n

0 - 9

} + idx[:html] << + %{\n

} + idx[:xhtml] << + %{\n

0 - 9

} the_idx.each do |i| i.each do |x| if x.is_a?(String) @@ -176,18 +228,24 @@ module SiSU_AO_BookIndex while letter < f if alph.length > 0 letter=alph.shift - idx[:html] << %{\n

#{letter}

} - idx[:xhtml] << %{\n

#{letter}

} + idx[:html] << + %{\n

#{letter}

} + idx[:xhtml] << + %{\n

#{letter}

} else break end end end - idx[:sst_rel_html_seg] << %{\n\n#{Mx[:fa_bold_o]}#{x},#{Mx[:fa_bold_c]} } - idx[:sst_rel] << %{\n\n#{Mx[:fa_bold_o]}#{x},#{Mx[:fa_bold_c]} } + idx[:sst_rel_html_seg] << + %{\n\n#{Mx[:fa_bold_o]}#{x},#{Mx[:fa_bold_c]} } + idx[:sst_rel] << + %{\n\n#{Mx[:fa_bold_o]}#{x},#{Mx[:fa_bold_c]} } aname=x.gsub(/\s+/,'_') - idx[:html] << %{\n

#{x}, } + idx[:html] << + %{\n

#{x}, } c=clean_xml(x.dup) - idx[:xhtml] << %{\n

#{c}, } + idx[:xhtml] << + %{\n

#{c}, } @o=idx[:sst_rel_html_seg].index(idx[:sst_rel_html_seg].last) @t=idx[:sst_rel].index(idx[:sst_rel].last) @q=idx[:html].index(idx[:html].last) @@ -200,16 +258,32 @@ module SiSU_AO_BookIndex if x['node_0_terms'].is_a?(Array) x['node_0_terms'].each do |a| if a[:range] - idx[:sst_rel_html_seg][@o]=idx[:sst_rel_html_seg][@o] + %{#{Mx[:lnk_o]}#{a[:range]}#{Mx[:lnk_c]}#{Mx[:rel_o]}/#{a[:seg]}.html##{@ocn_html_identifier}#{a[:ocn]}#{Mx[:rel_c]}, } - idx[:sst_rel][@t]=idx[:sst_rel][@t] + %{#{Mx[:lnk_o]}#{a[:range]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{a[:ocn]}#{Mx[:rel_c]}, } - idx[:html][@q]=idx[:html][@q] + %{#{a[:range]}, } - idx[:xhtml][@q]=idx[:xhtml][@q] + %{#{a[:range]}, } + idx[:sst_rel_html_seg][@o]= + idx[:sst_rel_html_seg][@o] + + %{#{Mx[:lnk_o]}#{a[:range]}#{Mx[:lnk_c]}#{Mx[:rel_o]}/#{a[:seg]}.html##{@ocn_html_identifier}#{a[:ocn]}#{Mx[:rel_c]}, } + idx[:sst_rel][@t]= + idx[:sst_rel][@t] + + %{#{Mx[:lnk_o]}#{a[:range]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{a[:ocn]}#{Mx[:rel_c]}, } + idx[:html][@q]= + idx[:html][@q] + + %{#{a[:range]}, } + idx[:xhtml][@q]= + idx[:xhtml][@q] + + %{#{a[:range]}, } print a[:range] + ', ' if @md.opt.act[:verbose_plus][:set]==:on elsif a[:ocn] - idx[:sst_rel_html_seg][@o]=idx[:sst_rel_html_seg][@o] + %{#{Mx[:lnk_o]}#{a[:ocn]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{a[:seg]}.html##{@ocn_html_identifier}#{a[:ocn]}#{Mx[:rel_c]}, } - idx[:sst_rel][@t]=idx[:sst_rel][@t] + %{#{Mx[:lnk_o]}#{a[:ocn]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{a[:ocn]}#{Mx[:rel_c]}, } - idx[:html][@q]=idx[:html][@q] + %{#{a[:ocn]}, } - idx[:xhtml][@q]=idx[:xhtml][@q] + %{#{a[:ocn]}, } + idx[:sst_rel_html_seg][@o]= + idx[:sst_rel_html_seg][@o] + + %{#{Mx[:lnk_o]}#{a[:ocn]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{a[:seg]}.html##{@ocn_html_identifier}#{a[:ocn]}#{Mx[:rel_c]}, } + idx[:sst_rel][@t]= + idx[:sst_rel][@t] + + %{#{Mx[:lnk_o]}#{a[:ocn]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{a[:ocn]}#{Mx[:rel_c]}, } + idx[:html][@q]= + idx[:html][@q] + + %{#{a[:ocn]}, } + idx[:xhtml][@q]= + idx[:xhtml][@q] + + %{#{a[:ocn]}, } print a[:ocn] + ', ' if @md.opt.act[:verbose_plus][:set]==:on else p 'error' end @@ -220,24 +294,48 @@ module SiSU_AO_BookIndex if x['node_1_subterms'] x['node_1_subterms'].sort.each do |k,y| if k !~/node_0_terms/ - idx[:sst_rel_html_seg][@o]=idx[:sst_rel_html_seg][@o] + %{#{k}, } - idx[:sst_rel][@t]=idx[:sst_rel][@t] + %{#{k}, } - idx[:html][@q]=idx[:html][@q] + %{\n

#{k}, } + idx[:sst_rel_html_seg][@o]= + idx[:sst_rel_html_seg][@o] + + %{#{k}, } + idx[:sst_rel][@t]= + idx[:sst_rel][@t] + + %{#{k}, } + idx[:html][@q]= + idx[:html][@q] + + %{\n

#{k}, } c=clean_xml(k.dup) - idx[:xhtml][@r]=idx[:xhtml][@r] + %{\n

#{c}, } + idx[:xhtml][@r]= + idx[:xhtml][@r] + + %{\n

#{c}, } print "\n\t" + k + ', ' if @md.opt.act[:verbose_plus][:set]==:on y.each do |z| if z[:range] - idx[:sst_rel_html_seg][@o]=idx[:sst_rel_html_seg][@o] + %{#{Mx[:lnk_o]}#{z[:range]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{z[:seg]}.html##{@ocn_html_identifier}#{z[:ocn]}#{Mx[:rel_c]}, } - idx[:sst_rel][@t]=idx[:sst_rel][@t] + %{#{Mx[:lnk_o]}#{z[:range]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{z[:ocn]}#{Mx[:rel_c]}, } - idx[:html][@q]=idx[:html][@q] + %{#{z[:range]}, } - idx[:xhtml][@q]=idx[:xhtml][@q] + %{#{z[:range]}, } + idx[:sst_rel_html_seg][@o]= + idx[:sst_rel_html_seg][@o] + + %{#{Mx[:lnk_o]}#{z[:range]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{z[:seg]}.html##{@ocn_html_identifier}#{z[:ocn]}#{Mx[:rel_c]}, } + idx[:sst_rel][@t]= + idx[:sst_rel][@t] + + %{#{Mx[:lnk_o]}#{z[:range]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{z[:ocn]}#{Mx[:rel_c]}, } + idx[:html][@q]= + idx[:html][@q] + + %{#{z[:range]}, } + idx[:xhtml][@q]= + idx[:xhtml][@q] + + %{#{z[:range]}, } print z[:range] + ', ' if @md.opt.act[:verbose_plus][:set]==:on elsif z[:ocn] - idx[:sst_rel_html_seg][@o]=idx[:sst_rel_html_seg][@o] + %{#{Mx[:lnk_o]}#{z[:ocn]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{z[:seg]}.html##{@ocn_html_identifier}#{z[:ocn]}#{Mx[:rel_c]}, } - idx[:sst_rel][@t]=idx[:sst_rel][@t] + %{#{Mx[:lnk_o]}#{z[:ocn]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{z[:ocn]}#{Mx[:rel_c]}, } - idx[:html][@q]=idx[:html][@q] + %{#{z[:ocn]}, } - idx[:xhtml][@q]=idx[:xhtml][@q] + %{#{z[:ocn]}, } + idx[:sst_rel_html_seg][@o]= + idx[:sst_rel_html_seg][@o] + + %{#{Mx[:lnk_o]}#{z[:ocn]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{z[:seg]}.html##{@ocn_html_identifier}#{z[:ocn]}#{Mx[:rel_c]}, } + idx[:sst_rel][@t]= + idx[:sst_rel][@t] + + %{#{Mx[:lnk_o]}#{z[:ocn]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{z[:ocn]}#{Mx[:rel_c]}, } + idx[:html][@q]= + idx[:html][@q] + + %{#{z[:ocn]}, } + idx[:xhtml][@q]= + idx[:xhtml][@q] + + %{#{z[:ocn]}, } print z[:ocn] + ', ' if @md.opt.act[:verbose_plus][:set]==:on else p 'error' end diff --git a/lib/sisu/v6/ao_images.rb b/lib/sisu/v6/ao_images.rb index 030dbd19..93ed4d84 100644 --- a/lib/sisu/v6/ao_images.rb +++ b/lib/sisu/v6/ao_images.rb @@ -85,7 +85,10 @@ module SiSU_AO_Images else 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 + SiSU_Screen::Ansi.new( + @md.opt.act[:color_state][:set], + '*WARN* use of RMagick is not enabled in sisurc.yml' + ).warn end end data.each do |dob| @@ -99,7 +102,11 @@ module SiSU_AO_Images img_col=img_row=nil images=imgs.each do |image| dir=SiSU_Env::InfoEnv.new(@md.fns) - path_image=[dir.path.image_source_include_local,dir.path.image_source_include_remote,dir.path.image_source_include] + path_image=[ + dir.path.image_source_include_local, + dir.path.image_source_include_remote, + dir.path.image_source_include + ] image_path=nil path_image.each do |img_pth| image_path=img_pth @@ -112,7 +119,10 @@ module SiSU_AO_Images else 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 + SiSU_Screen::Ansi.new( + @md.opt.act[:color_state][:set], + '*WARN* RMagick not present, will attempt to use imagemagick (identify) directly' + ).warn end imgk=SiSU_Env::SystemCall.new.imagemagick gmgk=SiSU_Env::SystemCall.new.graphicksmagick @@ -144,12 +154,18 @@ module SiSU_AO_Images end end dob.obj=dob.obj.gsub(/(#{image})/,"#{image} #{img_col}x#{img_row}") - else dob.obj=dob.obj.gsub(/#{Mx[:lnk_o]}\s*(\S+)\.(png|jpg|gif).+?#{Mx[:lnk_c]}(#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/,'[ \1 (\2 missing) ]') + else + dob.obj=dob.obj. + gsub(/#{Mx[:lnk_o]}\s*(\S+)\.(png|jpg|gif).+?#{Mx[:lnk_c]}(#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/, + '[ \1 (\2 missing) ]') end end else images=dob.obj.scan(m) do |image| - SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],'*WARN* where image dimensions have not been provided RMagick or imagemagick is required',image).warn unless @md.opt.act[:quiet][:set]==:on + SiSU_Screen::Ansi.new( + @md.opt.act[:color_state][:set], + '*WARN* where image dimensions have not been provided RMagick or imagemagick is required',image + ).warn unless @md.opt.act[:quiet][:set]==:on end end end diff --git a/lib/sisu/v6/ao_metadata.rb b/lib/sisu/v6/ao_metadata.rb index 3ca232f3..975d261d 100644 --- a/lib/sisu/v6/ao_metadata.rb +++ b/lib/sisu/v6/ao_metadata.rb @@ -69,11 +69,20 @@ module SiSU_AO_Metadata @tr=SiSU_Translate::Source.new(md,language) end def make_para(obj,ocn) - h={ obj: obj, ocn: 0 } + h={ + obj: obj, + ocn: 0 + } SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h) end def make_heading(obj,ocn,name,lv,ln) - h={ lv: lv, ln: ln, name: name, obj: obj, ocn: 0 } + h={ + lv: lv, + ln: ln, + name: name, + obj: obj, + ocn: 0 + } SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h) end def metadata diff --git a/lib/sisu/v6/ao_misc_arrange.rb b/lib/sisu/v6/ao_misc_arrange.rb index de32f560..387c14ca 100644 --- a/lib/sisu/v6/ao_misc_arrange.rb +++ b/lib/sisu/v6/ao_misc_arrange.rb @@ -67,10 +67,13 @@ module SiSU_AO_MiscArrangeText end def conditional_headings(para) para=para.gsub(/^(:?A~)\s*$/,'\1~ @title @author'). #conditional header - gsub(/^((?:[1-9]|:?[A-D])~\S*)\s*$/,'\1~ [Note: heading marker::required title missing]~#') #conditional header for incorporated document 2004w12 + gsub(/^((?:[1-9]|:?[A-D])~\S*)\s*$/, + '\1~ [Note: heading marker::required title missing]~#') #conditional header for incorporated document 2004w12 if para =~/^@\S+?:/ - para=para.gsub(/^@(\S+?):(\s+|$)/,"#{Mx[:meta_o]}\\1#{Mx[:meta_c]}\\2"). - gsub(/^@(\S+?):([+-])(\s+|$)/,"#{Mx[:meta_o]}\\1\\2#{Mx[:meta_c]}\\3") + para=para.gsub(/^@(\S+?):(\s+|$)/, + "#{Mx[:meta_o]}\\1#{Mx[:meta_c]}\\2"). + gsub(/^@(\S+?):([+-])(\s+|$)/, + "#{Mx[:meta_o]}\\1\\2#{Mx[:meta_c]}\\3") end para end @@ -79,7 +82,9 @@ module SiSU_AO_MiscArrangeText block_open,block_close,text=nil,nil,nil if para =~/\A```[ ]+(?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block|table).*?\n.+?\n```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*\Z/m @flag=:close - block_open,text,block_close=/\A(```[ ]+(?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block|table).*?)\n(.+?)\n(```([ ]+[~-][#]|\s+\~\{.+?\}\~)?)\s*\Z/m.match(para)[1..3] + block_open,text,block_close= + /\A(```[ ]+(?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block|table).*?)\n(.+?)\n(```([ ]+[~-][#]|\s+\~\{.+?\}\~)?)\s*\Z/m. + match(para)[1..3] ((para=~/^```[ ]+table(?:~h)?\s+/) \ and (para !~/^```[ ]+table(?:~h)?\s+c\d+/)) \ ? para @@ -96,7 +101,8 @@ module SiSU_AO_MiscArrangeText elsif para =~/\A.+?\n```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*\Z/m \ and @flag==:open @flag=:close - text,block_close=/\A(.+?)\n(```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?)\s*\Z/m.match(para)[1,2] + text,block_close= + /\A(.+?)\n(```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?)\s*\Z/m.match(para)[1,2] para=[] if not text.to_s.empty? para << text.to_s << block_close @@ -109,7 +115,8 @@ module SiSU_AO_MiscArrangeText end def ticks_remove(para) unless @md.opt.act[:quiet][:set] ==:on - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).mark("ticks not recognized, ticks removed from pargraph\n#{para}") + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). + mark("ticks not recognized, ticks removed from pargraph\n#{para}") end para=para.gsub(/```[ ]+\S+[ ]*/m,''). gsub(/```\s*/m,''). @@ -134,11 +141,15 @@ module SiSU_AO_MiscArrangeText def curly_braces(para) block_open,block_close,text=nil,nil,nil para=if para =~/\A(?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block|table)\{ .+?\n.+?\n\}(?:code|box|poem|alt|group|block|table)(?: [~-][#])?\s*\Z/m - block_open,text,block_close=/\A((?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block|table)\{ .+?)\n(.+?)\n(\}(?:code|box|poem|alt|group|block|table)(?: [~-][#])?)\s*\Z/m.match(para)[1..3] + block_open,text,block_close= + /\A((?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block|table)\{ .+?)\n(.+?)\n(\}(?:code|box|poem|alt|group|block|table)(?: [~-][#])?)\s*\Z/m. + match(para)[1..3] para=[] para << block_open << text << block_close elsif para =~/\A(?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block|table)\{ .+?\n.+?\Z/m - block_open,text=/\A((?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block|table)\{ .+?)\n(.+?)\Z/m.match(para)[1,2] + block_open,text= + /\A((?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block|table)\{ .+?)\n(.+?)\Z/m. + match(para)[1,2] para=[] if not text.to_s.empty? para << block_open << text @@ -146,7 +157,9 @@ module SiSU_AO_MiscArrangeText para << block_open end elsif para =~/\A.+?\n\}(?:code|box|poem|alt|group|block|table)(?: [~-][#])?\s*\Z/m - text,block_close=/\A(.+?)\n(\}(?:code|box|poem|alt|group|block|table)(?: [~-][#])?)\s*\Z/m.match(para)[1,2] + text,block_close= + /\A(.+?)\n(\}(?:code|box|poem|alt|group|block|table)(?: [~-][#])?)\s*\Z/m. + match(para)[1,2] para=[] if not text.to_s.empty? para << text.to_s << block_close diff --git a/lib/sisu/v6/ao_numbering.rb b/lib/sisu/v6/ao_numbering.rb index 0dbb1a71..791f5bfc 100644 --- a/lib/sisu/v6/ao_numbering.rb +++ b/lib/sisu/v6/ao_numbering.rb @@ -121,7 +121,8 @@ module SiSU_AO_Numbering dob end def heading_tag_clean(heading_tag) - heading_tag=heading_tag.gsub(/[ ]+/,'_'). + heading_tag=heading_tag. + gsub(/[ ]+/,'_'). gsub(/["']/,''). gsub(/[\/]/,'-'). gsub(/#{Mx[:fa_bold_o]}|#{Mx[:fa_bold_c]}/,''). @@ -315,7 +316,8 @@ module SiSU_AO_Numbering if dob.name !~/^\S+/ \ and dob.obj =~/^\s*(?:\S+\s+)?([\d.,:-]+)/m #heading starts with a recognised numeric or word followed by a recognised numerical construct, use that as name possible_seg_name=$1 - possible_seg_name=possible_seg_name.gsub(/(?:[:,-]|\W)/,'.'). + possible_seg_name=possible_seg_name. + gsub(/(?:[:,-]|\W)/,'.'). gsub(/\.$/,'') if @md.seg_names.is_a?(Array) \ and not @md.seg_names.include?(possible_seg_name) @@ -363,11 +365,17 @@ module SiSU_AO_Numbering m=dob.ln.to_s dob_tmp=[] if @md.pagenew.inspect =~/#{m}/ - dob_tmp << SiSU_AO_DocumentStructure::ObjectLayout.new.break(Hx[:br_page_new]) << dob + dob_tmp << + SiSU_AO_DocumentStructure::ObjectLayout.new.break(Hx[:br_page_new]) << + dob elsif @md.pagebreak.inspect =~/#{m}/ - dob_tmp << SiSU_AO_DocumentStructure::ObjectLayout.new.break(Hx[:br_page]) << dob + dob_tmp << + SiSU_AO_DocumentStructure::ObjectLayout.new.break(Hx[:br_page]) << + dob elsif @md.pageline.inspect =~/#{m}/ - dob_tmp << SiSU_AO_DocumentStructure::ObjectLayout.new.break(Hx[:br_page_line]) << dob + dob_tmp << + SiSU_AO_DocumentStructure::ObjectLayout.new.break(Hx[:br_page_line]) << + dob end unless dob_tmp.length > 0; dob else dob_tmp @@ -381,11 +389,23 @@ module SiSU_AO_Numbering : @segname tags["#{dob.ocn}"]={ segname: @segname } ocn_html_seg[dob.ocn]=if (dob.is==:heading || dob.is==:heading_insert) - if dob.ln =~/[0-3]/ then { seg: nil, level: dob.ln } + if dob.ln =~/[0-3]/ + { + seg: nil, + level: dob.ln, + } #elsif dob.ln =~/[4-6]/ - else { seg: @seg, level: dob.ln } + else + { + seg: @seg, + level: dob.ln, + } end - else { seg: @seg, level: nil } + else + { + seg: @seg, + level: nil, + } end end dob.tags=dob.tags.uniq if defined? dob.tags @@ -434,7 +454,9 @@ module SiSU_AO_Numbering and defined? @md.title.full \ and defined? @md.creator \ and @md.creator - head=@md.title.main ? ([@lv='1',@obj=@md.title.main]) : ([@lv='1',@obj='[no title provided]']) + head=@md.title.main \ + ? ([@lv='1',@obj=@md.title.main]) + : ([@lv='1',@obj='[no title provided]']) @tuned_file << head end end @@ -479,7 +501,8 @@ module SiSU_AO_Numbering unless @md.set_header_title if t_o !~/^%{1,2}\s/m \ and t_o !~/\A\s*\Z/m - @tuned_file << "#{Mx[:meta_o]}title#{Mx[:meta_c]} #{@md.heading_seg_first}" + @tuned_file << + "#{Mx[:meta_o]}title#{Mx[:meta_c]} #{@md.heading_seg_first}" @md.title.main=@md.heading_seg_first @md.set_header_title=true end diff --git a/lib/sisu/v6/ao_syntax.rb b/lib/sisu/v6/ao_syntax.rb index 68720aca..cdd4a389 100644 --- a/lib/sisu/v6/ao_syntax.rb +++ b/lib/sisu/v6/ao_syntax.rb @@ -143,7 +143,8 @@ module SiSU_AO_Syntax && dob.is !=:comment \ && dob.is !=:code \ && dob.is !=:table - dob.obj=dob.obj.gsub(/^-\\\\-\s*$/,"#{Mx[:br_page]}"). + dob.obj=dob.obj. + gsub(/^-\\\\-\s*$/,"#{Mx[:br_page]}"). gsub(/^=\\\\=\s*$/,"#{Mx[:br_page_new]}"). gsub(/ \\\\(?: |$)/,"#{Mx[:br_line]}"). gsub(/(?:<:?pb>)/,"#{Mx[:br_page]}"). # depreciated @@ -190,7 +191,8 @@ module SiSU_AO_Syntax dob end def embolden(given) - given=given.gsub(/^!_\s+((?:\{|#{Mx[:lnk_o]})(?:~^ )?.+?(?:\}|#{Mx[:lnk_o]})https?:\/\/\S+.*?)([#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}])/, + given=given. + gsub(/^!_\s+((?:\{|#{Mx[:lnk_o]})(?:~^ )?.+?(?:\}|#{Mx[:lnk_o]})https?:\/\/\S+.*?)([#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}])/, "#{Mx[:fa_bold_o]} \\1 #{Mx[:fa_bold_c]}\\2"). gsub(/^!_\s+((?:\{|#{Mx[:lnk_o]})(?:~^ )?.+?(?:\}|#{Mx[:lnk_o]})https?:\/\/\S+.*)/, "#{Mx[:fa_bold_o]} \\1 #{Mx[:fa_bold_c]}"). @@ -204,7 +206,8 @@ module SiSU_AO_Syntax "#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}") end def italicise(given) - given=given.gsub(/^\/_\s*(.+?)([#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}])/, + given=given. + gsub(/^\/_\s*(.+?)([#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}])/, "#{Mx[:fa_italics_o]}\\1#{Mx[:fa_italics_c]}\\2"). gsub(/^\/_\s*(.+?)\s+((?:[*]~\S+\s*)+)/, "#{Mx[:fa_italics_o]}\\1#{Mx[:fa_italics_c]}\\2"). @@ -282,11 +285,13 @@ module SiSU_AO_Syntax word.each do |w| unless /#{@manmkp_bold}|#{@http_m}/.match(w) if defined? @md.bold_match_list[:regx] \ - and @md.bold_match_list[:regx] #document header: @bold: [bold word list] - w=w.gsub(@md.bold_match_list[:regx],"#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}") + and @md.bold_match_list[:regx] #document header: @bold: [bold word list] + w=w.gsub(@md.bold_match_list[:regx], + "#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}") elsif defined? @vz.markup_make_bold \ and @vz.markup_make_bold #defaults adjusted bold word list - w=w.gsub(@vz.markup_make_bold,"#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}") + w=w.gsub(@vz.markup_make_bold, + "#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}") end else w=if w =~ /(?:^!_|^#{Mx[:lv_o]}[7-9]:\S*?#{Mx[:lv_c]})\s+/ @@ -324,7 +329,9 @@ module SiSU_AO_Syntax else '' end txt="#{lead_break}#{fce}\{" + txt.split(Mx[:br_nl]).join("\}#{fce}#{Mx[:br_nl]}#{fce}\{") + "\}#{fce}" - dob.obj=dob.obj.sub(/(?:^|#{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]}]|[\(\[\{]|\>)([*!\/_#])\{.+?\}\1/m,"#{lead}#{txt}") + dob.obj=dob.obj. + sub(/(?:^|#{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]}]|[\(\[\{]|\>)([*!\/_#])\{.+?\}\1/m, + "#{lead}#{txt}") dob else dob end @@ -336,7 +343,8 @@ module SiSU_AO_Syntax 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]}]|[\(\[\{]|[、。「‹«¿¡]|\>/ dob=fontface_lines(dob,leader) - dob.obj=dob.obj.gsub(/(#{leader})\*\{(.+?)\}\*/m, + dob.obj=dob.obj. + gsub(/(#{leader})\*\{(.+?)\}\*/m, "\\1#{@emph[:o]}\\2#{@emph[:c]}"). #emphasis gsub(/(#{leader})!\{(.+?)\}!/m, "\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}"). #bold @@ -399,18 +407,20 @@ module SiSU_AO_Syntax word=dob.obj.scan(/\S+|\n/) #unless line =~/^(?:#{Mx[:meta_o]}|%+\s)/ #visit if word word.each do |w| # _ - / # | : ! ^ ~ - unless w =~/~\{|\}~|~\[|\]~|^\^~|~\^|\*~\S+|~#|\{t?~|\{table|https?:\/\/\S+/ # do something earlier about table!! - w=w.gsub(/\\?~/,"#{Mx[:gl_o]}#126#{Mx[:gl_c]}") #escaped special character + unless w =~/~\{|\}~|~\[|\]~|^\^~|~\^|\*~\S+|~#|\{t?~|\{table|https?:\/\/\S+/ # do something earlier about table!! + w=w.gsub(/\\?~/,"#{Mx[:gl_o]}#126#{Mx[:gl_c]}") #escaped special character end - w=w.gsub(/^\<$/,"#{Mx[:gl_o]}#lt#{Mx[:gl_c]}").gsub(/^\>$/,"#{Mx[:gl_o]}#gt#{Mx[:gl_c]}") #escaped special character + w=w.gsub(/^\<$/, + "#{Mx[:gl_o]}#lt#{Mx[:gl_c]}").gsub(/^\>$/,"#{Mx[:gl_o]}#gt#{Mx[:gl_c]}") #escaped special character line_array << w end dob.obj=line_array.join(' ') dob.obj=dob.obj.strip end - dob.obj=dob.obj.gsub(/^([*#-.]{1,12})$/,'\1 ~#'). #ocn off for these paragraph separators + dob.obj=dob.obj. + gsub(/^([*#-.]{1,12})$/,'\1 ~#'). #ocn off for these paragraph separators gsub(/~\{(.+?)\}~/m,Mx[:en_a_o] + '\1' + Mx[:en_a_c]). - gsub(/~\[([^*+].+?)\]~/m,Mx[:en_b_o] + '* \1' + Mx[:en_b_c]). #default if markup does not specify + gsub(/~\[([^*+].+?)\]~/m,Mx[:en_b_o] + '* \1' + Mx[:en_b_c]). #default if markup does not specify gsub(/~\[(.+?)\]~/m,Mx[:en_b_o] + '\1' + Mx[:en_b_c]) if dob.is ==:heading \ and dob.ln ==0 @@ -431,12 +441,14 @@ module SiSU_AO_Syntax dob.obj=if dob.lv =~/[23]/ \ and defined? @md.creator.author \ and @md.creator.author - dob.obj.gsub(/^\s*(?:(by\s+)?(?:@creator|@author))\s*$/,"\\1#{@md.creator.author}") + dob.obj. + gsub(/^\s*(?:(by\s+)?(?:@creator|@author))\s*$/, + "\\1#{@md.creator.author}") else dob.obj.gsub(/^\s*(?:(by\s+)?(?:@creator|@author))\s*$/,'\1') end end end - dob.obj=dob.obj.gsub(/<(https?:\/\/\S+?)>/,'< \1 >'). #catch problem markup + dob.obj=dob.obj.gsub(/<(https?:\/\/\S+?)>/,'< \1 >'). #catch problem markup gsub(/<:=(\S+?)>/,'{ c_\1.png 14x14 }image'). gsub(//,'<:\1>'). #escaped special character gsub(/ /,"#{Mx[:nbsp]}"). #escaped special character @@ -463,15 +475,18 @@ module SiSU_AO_Syntax gsub(/\\\!/,"#{Mx[:gl_o]}#033#{Mx[:gl_c]}") #escaped special character if dob.obj=~/(?:https?:|ftp:|\{([^{}]+?)\}(?:#|:|[.]{1,2}\/))\S+/m if dob.obj=~/(?:^|[#{Mx[:gl_c]}#{Mx[:nbsp]} ])\{~\^ (?:.+?)\s*\}(?:(?:https?:|ftp:|:|[.]{1,2}\/)\S+?)\s*#{Mx[:en_a_o]}(.+?)#{Mx[:en_a_c]}/m - dob.obj=dob.obj.gsub(/(^|[#{Mx[:gl_c]}#{Mx[:nbsp]} ])\{~\^ ([^}]+?)\s*\}((?:https?:|ftp:|:|[.]{1,2}\/)\S+?)\s*#{Mx[:en_a_o]}(.+?)#{Mx[:en_a_c]}/m, - "\\1#{Mx[:lnk_o]}\\2#{Mx[:lnk_c]}\\3 #{Mx[:en_a_o]}\\3 \\4#{Mx[:en_a_c]}") # watch + dob.obj=dob.obj. + gsub(/(^|[#{Mx[:gl_c]}#{Mx[:nbsp]} ])\{~\^ ([^}]+?)\s*\}((?:https?:|ftp:|:|[.]{1,2}\/)\S+?)\s*#{Mx[:en_a_o]}(.+?)#{Mx[:en_a_c]}/m, + "\\1#{Mx[:lnk_o]}\\2#{Mx[:lnk_c]}\\3 #{Mx[:en_a_o]}\\3 \\4#{Mx[:en_a_c]}") # watch end if dob.obj=~/(?:^|[#{Mx[:gl_c]}#{Mx[:nbsp]} ])\{~\^ (?:.+?)\s*\}(?:(?:https?:|ftp:|:|[.]{1,2}\/)\S+?)([;,.]?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m - dob.obj=dob.obj.gsub(/(^|[#{Mx[:gl_c]}#{Mx[:nbsp]} ])\{~\^ (.+?)\s*\}((?:https?:|ftp:|:|[.]{1,2}\/)\S+?)([;,.]?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m, - "\\1#{Mx[:lnk_o]}\\2#{Mx[:lnk_c]}\\3\\4 #{Mx[:en_a_o]}\\3#{Mx[:en_a_c]} ") + dob.obj=dob.obj. + gsub(/(^|[#{Mx[:gl_c]}#{Mx[:nbsp]} ])\{~\^ (.+?)\s*\}((?:https?:|ftp:|:|[.]{1,2}\/)\S+?)([;,.]?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m, + "\\1#{Mx[:lnk_o]}\\2#{Mx[:lnk_c]}\\3\\4 #{Mx[:en_a_o]}\\3#{Mx[:en_a_c]} ") end - dob.obj=dob.obj.gsub(/(^|[^#])\{\s*([^{}]+?)\s*\}((?:https?:|:|[.]{2}\/|#)\S+?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}#{Mx[:en_a_o]}#{Mx[:en_b_o]}]|$)/, - "\\1#{Mx[:lnk_o]}\\2#{Mx[:lnk_c]}\\3"). #linked (text or image, however text cannot include modified face, e.g. bold, ital, underline) + dob.obj=dob.obj. + gsub(/(^|[^#])\{\s*([^{}]+?)\s*\}((?:https?:|:|[.]{2}\/|#)\S+?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}#{Mx[:en_a_o]}#{Mx[:en_b_o]}]|$)/, + "\\1#{Mx[:lnk_o]}\\2#{Mx[:lnk_c]}\\3"). #linked (text or image, however text cannot include modified face, e.g. bold, ital, underline) gsub(/(^|[#{Mx[:gl_c]}#{Mx[:lnk_c]}#{Mx[:en_a_o]}#{Mx[:en_b_o]}(\s])((?:https?|ftp):\/\/\S+?\.[^>< ]+?)([,.;'"]?)(?=[\s#{Mx[:en_a_c]}#{Mx[:en_b_c]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m, %{\\1#{Mx[:url_o]}\\2#{Mx[:url_c]}\\3}). gsub(/#{Mx[:lnk_c]}#(\S+?[^>< ]+?)([()\[\]]*[,.;:!?'"]{0,2})(?=[\s#{Mx[:en_a_c]}#{Mx[:en_b_c]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m, @@ -486,7 +501,8 @@ module SiSU_AO_Syntax %{\\1#{Mx[:url_o]}\\2#{Mx[:url_c]}\\3}) end dob=fontface(dob) - dob.obj=dob.obj.gsub(/<[:e]\s+(.+?)!?>/, + dob.obj=dob.obj. + gsub(/<[:e]\s+(.+?)!?>/, "#{Mx[:en_a_o]}\\1#{Mx[:en_a_c]}"). #not tested gsub(/(^|#{Mx[:br_nl]})\s*_\*\s*/, "\\1#{Mx[:gl_bullet]}"). #bullets, shortcut @@ -526,7 +542,8 @@ module SiSU_AO_Syntax elsif dob.is==:table dob=fontface(dob) elsif dob.is ==:code - dob.obj=dob.obj.gsub(/#{Mx[:meta_o]}(\S+?)#{Mx[:meta_c]}\s*/,'@\1: '). + dob.obj=dob.obj. + gsub(/#{Mx[:meta_o]}(\S+?)#{Mx[:meta_c]}\s*/,'@\1: '). gsub(/(^|#{Mx[:gl_c]}|\s)<(br(?: \/)?)>([\s,.]|$)/,'\1<\2>\3') #convert

back, clumsy if dob.number_ codeline=[] @@ -569,7 +586,8 @@ module SiSU_AO_Syntax # +2 puts 'tech' @data.each do |line| - line=line.gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)e\{(.+?)\}e/, + line=line. + gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)e\{(.+?)\}e/, "\\1#{@emph[:o]}\\2#{@emph[:c]}"). #emphasis gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)b\{(.+?)\}b/, "\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}"). #bold diff --git a/lib/sisu/v6/hub.rb b/lib/sisu/v6/hub.rb index bfe0cbe2..94d0eb8e 100644 --- a/lib/sisu/v6/hub.rb +++ b/lib/sisu/v6/hub.rb @@ -75,7 +75,8 @@ module SiSU begin require 'uri' rescue LoadError - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('uri NOT FOUND (LoadError)') + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). + error('uri NOT FOUND (LoadError)') end class HubMaster def initialize(argv) @@ -159,7 +160,11 @@ module SiSU end end if files_translated_idx.flatten.length > 1 - SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Manifest re-run on (currently generated) translated files',"").grey_title_hi unless @opt.act[:quiet][:set] ==:on + SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + 'Manifest re-run on (currently generated) translated files', + '' + ).grey_title_hi unless @opt.act[:quiet][:set] ==:on files_translated_idx.flatten.each do |i| @opt.fns=@opt.files[i] @opt.f_pth=@opt.f_pths[i] @@ -191,22 +196,26 @@ module SiSU @@n_do=0 end def remote_put_base_site_rsync # -CR - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__).mark(:cyan) if @opt.act[:maintenance][:set] ==:on + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__).mark(:cyan) \ + if @opt.act[:maintenance][:set] ==:on require_relative 'remote' # remote.rb SiSU_Remote::Put.new(@opt).rsync_base end def remote_put_base_site_rsync_match # -CCRZ - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__).mark(:cyan) if @opt.act[:maintenance][:set] ==:on + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__).mark(:cyan) \ + if @opt.act[:maintenance][:set] ==:on require_relative 'remote' # remote.rb SiSU_Remote::Put.new(@opt).rsync_base_sync end def remote_put_base_site # -Cr - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__).mark(:cyan) if @opt.act[:maintenance][:set] ==:on + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__).mark(:cyan) \ + if @opt.act[:maintenance][:set] ==:on require_relative 'remote' # remote.rb SiSU_Remote::Put.new(@opt).scp_base end def remote_put_base_site_all # -CCr - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__).mark(:cyan) if @opt.act[:maintenance][:set] ==:on + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__).mark(:cyan) \ + if @opt.act[:maintenance][:set] ==:on require_relative 'remote' # remote.rb SiSU_Remote::Put.new(@opt).scp_base_all end @@ -217,7 +226,10 @@ module SiSU def termsheet # -t system("sisu_termsheet #{@opt.cmd} #{@opt.fns}\n") @@n_do=@@n_do+1 - SiSU_Screen::Ansi.new(@opt.cmd,@@n_do,'Termsheet(s) processed').term_sheet_title unless @opt.act[:quiet][:set] ==:on + SiSU_Screen::Ansi.new( + @opt.cmd,@@n_do, + 'Termsheet(s) processed' + ).term_sheet_title unless @opt.act[:quiet][:set] ==:on end def webrick # -W prt=SiSU_Env::InfoEnv.new(@fns).port.webrick_port @@ -254,7 +266,8 @@ module SiSU require 'fileutils' include FileUtils rescue LoadError - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('fileutils NOT FOUND (LoadError)') + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). + error('fileutils NOT FOUND (LoadError)') end @@env=nil attr_accessor :op @@ -262,7 +275,9 @@ module SiSU @opt=opt @@env=@env=SiSU_Env::InfoEnv.new @msg,@msgs='',nil - @tell=lambda { SiSU_Screen::Ansi.new(@opt.cmd,@msg,"#{@msgs.inspect if @msgs}") } + @tell=lambda { + SiSU_Screen::Ansi.new(@opt.cmd,@msg,"#{@msgs.inspect if @msgs}") + } end def remove_skipped_files_if_any_from_processing_files_array if @remove_faulty_markup_files_array.length > 0 @@ -272,7 +287,8 @@ module SiSU 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(',') + STDERR.puts 'ERROR with file(s), did not process: ' + + @remove_faulty_markup_files_array.join(',') end end def do_loops @@ -288,7 +304,8 @@ module SiSU def do_each_file_loop_options @opt.files.each_with_index do |fno,i| @opt.fno=fno - @opt.fns=fno.gsub(/(?:https?|file):\/\/\S+\/(\S+)\.sst$/,'\1.-sst'). + @opt.fns=fno. + gsub(/(?:https?|file):\/\/\S+\/(\S+)\.sst$/,'\1.-sst'). gsub(/\.ssm$/,'.ssm.sst') @opt.f_pth=@opt.f_pths[i] if @opt.fns !~/\.-sst$/ @@ -492,7 +509,8 @@ module SiSU ensure path_pod=@env.processing_path.processing_sisupod(@opt).paths unless @opt.act[:maintenance][:set]==:on - FileUtils::rm_rf("#{path_pod[:sisupod]}/*") if FileTest.directory?(path_pod[:sisupod]) + FileUtils::rm_rf("#{path_pod[:sisupod]}/*") \ + if FileTest.directory?(path_pod[:sisupod]) end end end @@ -518,7 +536,7 @@ module SiSU case @opt.fns when /\.(termsheet.rb)$/ SiSU::Operations.new(@opt).termsheet - else #print "not processed --> ", fns, "\n" + else #print "not processed --> ", fns, "\n" end else SiSU::Operations.new(@opt).not_found end @@ -528,13 +546,13 @@ module SiSU if @opt.act[:psql][:set]==:on #% --pg, -D DB postgresql require_relative 'dbi' OptionLoopFiles.new(@opt).loop_files_on_given_option do - SiSU_DBI::SQL.new(@opt).connect # -D -d dbi.rb + SiSU_DBI::SQL.new(@opt).connect # -D -d dbi.rb end end if @opt.act[:sqlite][:set]==:on #% --sqlite, -d DB sqlite require_relative 'dbi' OptionLoopFiles.new(@opt).loop_files_on_given_option do - SiSU_DBI::SQL.new(@opt).connect # -D -d dbi.rb + SiSU_DBI::SQL.new(@opt).connect # -D -d dbi.rb end end if @opt.act[:manifest][:set]==:on #% --manifest, -y @@ -579,7 +597,10 @@ module SiSU if (@opt.act[:verbose][:set]==:on \ || @opt.act[:verbose_plus][:set]==:on \ || @opt.act[:maintenance][:set]==:on) - SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],' ' + File.dirname(__FILE__)).grey + SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + ' ' + File.dirname(__FILE__) + ).grey end end if @opt.act[:ao][:set]==:on \ @@ -676,7 +697,8 @@ module SiSU begin require 'profile' rescue LoadError - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('profile NOT FOUND (LoadError)') + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). + error('profile NOT FOUND (LoadError)') end end action_on_file_ =if @opt.act[:rsync][:set]==:on \ diff --git a/lib/sisu/v6/options.rb b/lib/sisu/v6/options.rb index d7719ea4..e181ee8e 100644 --- a/lib/sisu/v6/options.rb +++ b/lib/sisu/v6/options.rb @@ -72,7 +72,22 @@ module SiSU_Commandline @@sisu_call_origin_path=nil class HeaderCommon def sisu_document_make_instructions - @pagenew=@pagebreak=@pageline=@toc=@lv1=@lv2=@lv3=@lv4=@lv5=@lv6=@num_top=@i18n=@man_section=@emphasis_set_to=@bold_match_list=@italics_match_list=@substitution_match_list=@footer_links=@home_button_links=@links=nil + @pagenew= + @pagebreak= + @pageline= + @toc= + @lv1=@lv2=@lv3=@lv4=@lv5=@lv6= + @num_top= + @i18n= + @man_section= + @emphasis_set_to= + @bold_match_list= + @italics_match_list= + @substitution_match_list= + @footer_links= + @home_button_links= + @links= + nil make_instruct_array=SiSU_Env::GetInit.new.sisu_document_make.makefile_read @makeset=false if make_instruct_array @@ -143,7 +158,8 @@ module SiSU_Commandline attr_accessor :cmd,:mod,:act,:dir_structure_by,:lingual,:f_pths,:files,:files_mod,:base_path,:base_stub,:sub_location,:paths,:lngs,:f_pth,:pth,:fno,:fns,:fnb,:fnc,:fng,:fncb,:lng,:lng_base,:what,:make_instructions,:make_instructions_pod @@act=nil def initialize(a) - @cmd,@f_pth,@pth,@fno,@fns,@fnb,@fnc,@fng,@fncb,@what,@lng,@lng_base,@base_path,@base_stub,@sub_location='','','','','','','','','','','','','','' + @cmd,@f_pth,@pth,@fno,@fns,@fnb,@fnc,@fng,@fncb,@what,@lng,@lng_base,@base_path,@base_stub,@sub_location= + '', '', '', '', '', '', '', '', '', '', '', '', '', '', '' @f_pths,@files,@files_mod,@paths,@mod,@act=Array.new(5){[]} @env=SiSU_Env::InfoEnv.new @lng_base=@env.language_default_set @@ -316,7 +332,8 @@ module SiSU_Commandline FileUtils::mkdir_p(pt.to_s) pod_make_path=fullname + '/sisupod/doc/_sisu' make_instruct_array=sisu_document_make_pod.makefile_read(pod_make_path) - @make_instructions_pod=HeaderCommon.new(make_instruct_array).sisu_document_make_instructions + @make_instructions_pod= + HeaderCommon.new(make_instruct_array).sisu_document_make_instructions Dir.chdir(pt.realpath) system(" chdir #{fullname} @@ -410,7 +427,7 @@ module SiSU_Commandline lng: lng_is, lng_is: lng_is, url_base: nil, - url: nil + url: nil, } else puts "file not found: #{x}" end @@ -422,7 +439,16 @@ module SiSU_Commandline puts "#{x} in #{a.join(' ')}?" end end - { cmd: c, mod: m, what: w, paths: pth, files: f, f_pths: f_pths, lng: lng_is, lngs: lngs } + { + cmd: c, + mod: m, + what: w, + paths: pth, + files: f, + f_pths: f_pths, + lng: lng_is, + lngs: lngs, + } end def expand_numeric_shortcuts(a) shortcut=SiSU_Env::InfoProcessingFlag.new diff --git a/lib/sisu/v6/param.rb b/lib/sisu/v6/param.rb index 19769027..1e7ea9de 100644 --- a/lib/sisu/v6/param.rb +++ b/lib/sisu/v6/param.rb @@ -65,15 +65,34 @@ module SiSU_Param require 'uri' require 'pstore' rescue LoadError - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('uri or pstore NOT FOUND (LoadError)') + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). + error('uri or pstore NOT FOUND (LoadError)') end require_relative 'sysenv' # sysenv.rb include SiSU_Env require_relative 'param_make' # param_make.rb require_relative 'param_identify_markup' # param_identify_markup.rb @@date=SiSU_Env::InfoDate.new - @@proc=@@filename_txt=@@filename_texinfo=@@filename_lout_portrait=@@filename_lout_landscape=@@filename_html_scroll=@@filename_html_index=@@filename_html_segtoc=@@filename_semantic=@@filename_rss=@@newfile=@@drr=nil - @doc={ initialise: nil, markup: '', lnks: '', stmp: '', req: {} } + @@proc= + @@filename_txt= + @@filename_texinfo= + @@filename_lout_portrait= + @@filename_lout_landscape= + @@filename_html_scroll= + @@filename_html_index= + @@filename_html_segtoc= + @@filename_semantic= + @@filename_rss= + @@newfile= + @@drr= + nil + @doc={ + initialise: nil, + markup: '', + lnks: '', + stmp: '', + req: {}, + } @@yaml=@@yamladdr=nil @@trigger=nil @@lv,@@flag={},{} @@ -99,7 +118,8 @@ module SiSU_Param # you may need to change Dir.pwd to @opt.f_pth[:pth] where the latter # has a path value that is different, however, f_pth is not always set! Dir.chdir(@opt.f_pth[:pth]) - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('-- bug alert --') + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). + error('-- bug alert --') p 'f_pth ' + @opt.f_pth[:pth] p 'pwd ' + Dir.pwd end @@ -186,7 +206,11 @@ module SiSU_Param STDERR.puts "#{n} is #{s.class}: programming error, String expected #{__FILE__}:#{__LINE__}" s else - SiSU_Screen::Ansi.new('v',"*WARN* #{n} length #{s.length} exceeds set db field length #{l}, metadata dropped",@opt.fns).warn unless @opt.act[:quiet][:set]==:on + SiSU_Screen::Ansi.new( + 'v', + "*WARN* #{n} length #{s.length} exceeds set db field length #{l}, metadata dropped", + @opt.fns + ).warn unless @opt.act[:quiet][:set]==:on nil end end @@ -504,7 +528,10 @@ module SiSU_Param 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 + SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + 'WARNING Document Copyright missing; provide @rights: :copyright:' + ).warn unless @opt.act[:quiet][:set]==:on '' end l,n=Db[:col_info_note],'rights.copyright.text' @@ -603,7 +630,10 @@ module SiSU_Param 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 + SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + 'WARNING Document Rights information missing; provide @rights: :copyright:' + ).warn unless @opt.act[:quiet][:set]==:on else l,n=Db[:col_info_note],'rights.all' validate_length(s,l,n) @@ -835,8 +865,10 @@ module SiSU_Param attr_accessor :make,:env,:path,:file,:fn,:fns,:fno,:fnb,:fnn,:fnt,:fnl,:flv,:fnz,:fnstex,:ocn,:sfx_src,:pdf,:file_type,:dir_out,:dir_tex,:dir_lout,:txt_path,:sisu,:sisu_version,:ruby_version,:title,:subtitle,:full_title,:html_title,:subtitle_tex,:creator,:classify,:author_home,:author,:author_title,:author_nationality,:authors,:authorship,:translator,:illustrator,:prepared_by,:digitized_by,:subject,:description,:publisher,:current_publisher,:contributor,:date,:date_created,:date_issued,:date_available,:date_valid,:date_modified,:date_translated,:date_added_to_site,:date_scheme,:date_created_scheme,:date_issued_scheme,:date_available_scheme,:date_valid_scheme,:date_modified_scheme,:type,:format,:identifier,:source,:language,:language_original,:relation,:coverage,:rights,:keywords,:comments,:abstract,:cls_loc,:cls_dewey,:cls_pg,:cls_isbn,:papersize,:papersize_array,:toc,:lv0,:lv1,:lv2,:lv3,:lv4,:lv5,:lv6,:lvs,:pagenew,:pagebreak,:pageline,:num_top,:bold_match_list,:italics_match_list,:substitution_match_list,:emphasis_set_to,:toc_lev_limit,:flag_endnotes,:flag_auto_endnotes,:flag_separate_endnotes,:flag_separate_endnotes_make,:markup,:markup_instruction,:flag_tables,:vocabulary,:doc_css,:yaml,:lnk,:links,:prefix_a,:prefix_b,:suffix,:information,:contact,:icon,:image,:ad_url,:ad_png,:ad_alt,:ad_began,:flag_promo,:promo,:ad_home,:stmp,:stmpd,:sc_filename,:sc_number,:sc_date,:sc_time,:sc_info,:yamladdr,:locale,:wc_lines,:wc_words,:wc_bytes,:file_encoding,:filesize,:user,:home,:hostname,:pwd,:firstseg,:programs,:author_copymark,:i18n,:lang,:lang_code_insert,:en,:notes,:dgst,:generated,:tags,:tag_array,:concord_make,:seg_names,:seg_autoname_safe,:set_header_title,:set_heading_top,:set_heading_seg,:heading_seg_first,:heading_seg_first_flag,:base_program,:ec,:opt,:sem_tag,:book_idx,:topic_register,:topic_register_array,:original,:writing_focus,:audio,:daisy,:home_button_image,:home_button_links,:footer_links,:cover_image,:man_section def initialize(fns_array,opt) @env=@path,@file=@fn=@fns=@fno=@fnb=@fnn=@fnt=@fnl=@flv=@fnz=@fnstex=@ocn=@sfx_src=@pdf=@file_type=@dir_out=@dir_tex=@dir_lout=@txt_path=@make=@flag_endnotes=@flag_auto_endnotes=@flag_separate_endnotes=@flag_separate_endnotes_make=@sisu=@sisu_version=@ruby_version=@title=@subtitle=@full_title=@html_title=@subtitle_tex=@creator=@classify=@author_home=@author=@author_title=@author_nationality=@translator=@illustrator=@prepared_by=@digitized_by=@subject=@description=@publisher=@current_publisher=@contributor=@date=@date_created=@date_issued=@date_available=@date_valid=@date_modified=@date_translated=@date_added_to_site=@date_scheme=@date_created_scheme=@date_issued_scheme=@date_available_scheme=@date_valid_scheme=@date_modified_scheme=@type=@format=@identifier=@source=@language=@language_original=@relation=@coverage=@rights=@keywords=@comments=@abstract=@cls_loc=@cls_dewey=@cls_pg=@cls_isbn=@papersize=@toc=@lv0=@lv1=@lv2=@lv3=@lv4=@lv5=@lv6=@pagenew=@pagebreak=@pageline=@num_top=@bold_match_list=@italics_match_list=@substitution_match_list=@emphasis_set_to=@toc_lev_limit=@flag_tables=@vocabulary=@doc_css=@yaml=@lnk=@links=@prefix_a=@prefix_b=@suffix=@information=@contact=@icon=@ad_url=@ad_png=@ad_alt=@ad_began=@promo=@ad_home=@stmp=@stmpd=@sc_filename=@sc_number=@sc_date=@sc_time=@sc_info=@yamladdr=@locale=@wc_lines=@wc_words=@wc_bytes=@file_encoding=@filesize=@firstseg=@programs=@author_copymark=@i18n=@lang=@lang_code_insert=@en=@notes=@dgst=@generated=@heading_seg_first=@base_program=@topic_register=@original=@writing_focus=@audio=@home_button_image=@home_button_links=@cover_image=@man_section=nil - @data,@path,@fns,@fno,@opt=fns_array,opt.pth,opt.fns,opt.fno,opt #@data used as data - @flag_tables,@set_header_title,@set_heading_top,@set_heading_seg,@heading_seg_first_flag,@flag_promo,@book_idx=false,false,false,false,false,false,false + @data, @path, @fns, @fno, @opt= + fns_array,opt.pth,opt.fns,opt.fno,opt #@data used as data + @flag_tables,@set_header_title,@set_heading_top,@set_heading_seg,@heading_seg_first_flag,@flag_promo,@book_idx= + false, false, false, false, false, false, false @seg_autoname_safe=true @daisy,@sem_tag=false,false @authorship,@markup_instruction,@image='','','','' #check which other values should be set to empty rather than nil @@ -1020,37 +1052,48 @@ module SiSU_Param @lv4=(makes[:lv4]) ? (makes[:lv4]) : @lv4 @lv5=(makes[:lv5]) ? (makes[:lv5]) : @lv5 @lv6=(makes[:lv6]) ? (makes[:lv6]) : @lv6 - @num_top=(makes[:num_top]) \ + @num_top= + (makes[:num_top]) \ ? (makes[:num_top]) \ : @num_top - @substitution_match_list=(makes[:substitution_match_list]) \ + @substitution_match_list= + (makes[:substitution_match_list]) \ ? (makes[:substitution_match_list]) \ : @substitution_match_list - @bold_match_list=(makes[:bold_match_list]) \ + @bold_match_list= + (makes[:bold_match_list]) \ ? (makes[:bold_match_list]) \ : @bold_match_list - @italics_match_list=(makes[:italics_match_list]) \ + @italics_match_list= + (makes[:italics_match_list]) \ ? (makes[:italics_match_list]) \ : @italics_match_list - @emphasis_set_to=(makes[:emphasis_set_to]) \ + @emphasis_set_to= + (makes[:emphasis_set_to]) \ ? (makes[:emphasis_set_to]) \ : @emphasis_set_to - @i18n=(makes[:i18n]) \ + @i18n= + (makes[:i18n]) \ ? (makes[:i18n]) \ : @i18n - @man_section=(makes[:man_section]) \ + @man_section= + (makes[:man_section]) \ ? (makes[:man_section]) \ : @man_section - @footer_links=(makes[:footer_links]) \ + @footer_links= + (makes[:footer_links]) \ ? (makes[:footer_links]) \ : @footer_links - @home_button_links=(makes[:home_button_links]) \ + @home_button_links= + (makes[:home_button_links]) \ ? (makes[:home_button_links]) \ : @home_button_links - @home_button_image=(makes[:home_button_image]) \ + @home_button_image= + (makes[:home_button_image]) \ ? (makes[:home_button_image]) \ : @home_button_image - @cover_image=(makes[:cover_image]) \ + @cover_image= + (makes[:cover_image]) \ ? (makes[:cover_image]) \ : @cover_image end @@ -1117,7 +1160,11 @@ module SiSU_Param : '' 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 + 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 \ and para =~/^=\{(.+?)\}\s*$/ @@ -1151,11 +1198,11 @@ module SiSU_Param elsif para =~/^1~\s+(.+)$/ t=$1 end - unless @heading_seg_first_flag # extract first segment name + unless @heading_seg_first_flag # extract first segment name @heading_seg_first=t @heading_seg_first_flag=true end - if m # list all segment names + if m # list all segment names @seg_names << m @set_heading_seg=true if m=~/^\d{1,3}/ \ @@ -1164,7 +1211,7 @@ module SiSU_Param end end end - para=para.gsub(/<:=(\S+?)>/,'{ c_\1.png 14x14 }image') # embedded symbol (image) + para=para.gsub(/<:=(\S+?)>/,'{ c_\1.png 14x14 }image') # embedded symbol (image) if para !~/^%+\s/ \ and para =~@rgx_image @ec[:image] << para.scan(@rgx_image).uniq @@ -1178,7 +1225,11 @@ module SiSU_Param unless @make if (@opt.act[:verbose_plus][:set]==:on \ || @opt.act[:maintenance][:set]==:on) - SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'@make:','header absent').warn + SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + '@make:', + 'header absent' + ).warn end @make=SiSU_Param::Parameters::MdMake.new('@make: ',@opt,@env).make end @@ -1318,15 +1369,25 @@ module SiSU_Param if @en[:note] > 0 \ and @en[:sum] > 0 if @en[:sum] > 0 - else SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'*WARN* both endnote styles used',"~{ #{@en[:sum]} }~ and ^~ #{@en[:mark]}").warn unless @opt.act[:quiet][:set]==:on + else + SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + '*WARN* both endnote styles used', + "~{ #{@en[:sum]} }~ and ^~ #{@en[:mark]}" + ).warn unless @opt.act[:quiet][:set]==:on end end if @en[:mark] != @en[:note] \ and @en[:note] > 0 @en[:mismatch]=@en[:note] - @en[:mark] - SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'*WARN* endnote number mismatch',"endnotes: #{@en[:note]} != endnote reference marks: #{@en[:mark]} (difference = #{@en[:mismatch]})").warn unless @opt.act[:quiet][:set]==:on + SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + '*WARN* endnote number mismatch', + "endnotes: #{@en[:note]} != endnote reference marks: #{@en[:mark]} (difference = #{@en[:mismatch]})" + ).warn unless @opt.act[:quiet][:set]==:on footnote_conversion_errors=File.new("#{Dir.pwd}/footnote_conversion_errors.txt",'a') - footnote_conversion_errors << "#{@fns}:\n\tendnotes: #{@en[:note]} != endnote reference marks: #{@en[:mark]} (difference = #{@en[:mismatch]})\n" + footnote_conversion_errors << + "#{@fns}:\n\tendnotes: #{@en[:note]} != endnote reference marks: #{@en[:mark]} (difference = #{@en[:mismatch]})\n" end if not @title \ or not defined? @title.main \ @@ -1335,7 +1396,11 @@ module SiSU_Param and @opt.inspect =~/P/ #@title=Md.new('Text Insert',@opt,@env).title else - SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'WARNING: Document Title missing','please provide @title:').warn unless @opt.act[:quiet][:set]==:on + SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + 'WARNING: Document Title missing', + 'please provide @title:' + ).warn unless @opt.act[:quiet][:set]==:on end end if @author !~/[\S]/ @@ -1343,7 +1408,11 @@ module SiSU_Param and @opt.inspect =~/P/ #@creator=SiSU_Param::Md.new('Text Insert',@opt,@env).creator else - SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'WARNING: Document Author missing','please provide @creator: :author:').warn unless @opt.act[:quiet][:set]==:on + SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + 'WARNING: Document Author missing', + 'please provide @creator: :author:' + ).warn unless @opt.act[:quiet][:set]==:on end end @struct={} @@ -1426,7 +1495,10 @@ module SiSU_Param File.unlink(pstorefile) if FileTest.file?(pstorefile) if (@md.opt.act[:verbose_plus][:set]==:on \ || @md.opt.act[:maintenance][:set]==:on) - SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],"PStore -> #{pstorefile}").txt_grey + SiSU_Screen::Ansi.new( + @md.opt.act[:color_state][:set], + "PStore -> #{pstorefile}" + ).txt_grey end store=PStore.new(pstorefile) store.transaction do @@ -1447,10 +1519,26 @@ module SiSU_Param class Instantiate def param_instantiate @@date=SiSU_Env::InfoDate.new - @@proc=@@filename_txt=@@filename_texinfo=@@filename_lout_portrait=@@filename_lout_landscape=@@filename_html_scroll=@@filename_html_index=@@filename_html_segtoc=@@filename_semantic=@@filename_rss=@@newfile=@@drr=nil + @@proc= + @@filename_txt= + @@filename_texinfo= + @@filename_lout_portrait= + @@filename_lout_landscape= + @@filename_html_scroll= + @@filename_html_index= + @@filename_html_segtoc= + @@filename_semantic= + @@filename_rss= + @@newfile= + @@drr= + nil @doc={ initialise: nil, - markup: '', lnks: '', stmp: '', prefix_a: '', prefix_b: '', + markup: '', + lnks: '', + stmp: '', + prefix_a: '', + prefix_b: '', req: {} } @@yaml=@@yamladdr=nil -- cgit v1.2.3 From 844f9270e3190ec55666d787cfc8c482997cfc06 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Tue, 1 Jul 2014 00:47:13 -0400 Subject: v5 v6: ao, (param), book index, strip white spaces around terms * fix uppercase first character where spaces used --- data/doc/sisu/CHANGELOG_v5 | 2 ++ data/doc/sisu/CHANGELOG_v6 | 2 ++ lib/sisu/v5/ao_doc_str.rb | 7 ++++--- lib/sisu/v5/param.rb | 2 +- lib/sisu/v6/ao_doc_str.rb | 7 ++++--- lib/sisu/v6/param.rb | 2 +- 6 files changed, 14 insertions(+), 8 deletions(-) diff --git a/data/doc/sisu/CHANGELOG_v5 b/data/doc/sisu/CHANGELOG_v5 index f4c824f5..7acd5140 100644 --- a/data/doc/sisu/CHANGELOG_v5 +++ b/data/doc/sisu/CHANGELOG_v5 @@ -40,6 +40,8 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_5.4.3.orig.tar.xz * ao, * code cosmetic rearrangement + * book index, strip white spaces around terms + (fix uppercase first character where spaces used) * code cosmetic rearrangement * ao*, param, hub, options, composite diff --git a/data/doc/sisu/CHANGELOG_v6 b/data/doc/sisu/CHANGELOG_v6 index 81420f21..beada6ad 100644 --- a/data/doc/sisu/CHANGELOG_v6 +++ b/data/doc/sisu/CHANGELOG_v6 @@ -30,6 +30,8 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_6.0.9.orig.tar.xz * ao, * code cosmetic rearrangement + * book index, strip white spaces around terms + (fix uppercase first character where spaces used) * code cosmetic rearrangement * ao*, param, hub, options, composite diff --git a/lib/sisu/v5/ao_doc_str.rb b/lib/sisu/v5/ao_doc_str.rb index 9743f794..c3b65ee1 100644 --- a/lib/sisu/v5/ao_doc_str.rb +++ b/lib/sisu/v5/ao_doc_str.rb @@ -200,6 +200,7 @@ module SiSU_AO_DocumentStructureExtract idx_array_raw=idxraw.scan(/[^;]+/) idx_hash,idx_array,idx_lst={},[],[] idx_array_raw.each do |idx| + idx=idx.strip idx_lst=case idx when /\S+?\s*:/ idx_couplet_tmp=[] @@ -308,11 +309,11 @@ module SiSU_AO_DocumentStructureExtract and @@flag[:box]==:off \ and @@flag[:table]==:off unless t_o =~/^(?:@\S+?:|%+)\s/ # extract book index for paragraph if any - idx=if t_o=~/^=\{(.+)\}\s*$\Z/m; m=$1 - m=m.split(/\n/).join(' '). + idx=if t_o=~/^=\{\s*(.+)\s*\}\s*$\Z/m; m=$1 + m=m.split(/[ ]*\n/).join(' '). gsub(/\s+([|:;])\s+/,'\1'). gsub(/\s+([+]\d+)\s+/,'\1') - t_o=t_o.gsub(/\n=\{.+\}\s*$\Z/m,'') + t_o=t_o.gsub(/\n=\{.+?\}\s*$/m,'') idx_array_and_hash=construct_idx_array_and_hash(m) idx_array_and_hash[:hash] else nil diff --git a/lib/sisu/v5/param.rb b/lib/sisu/v5/param.rb index d20a0129..b2e50d41 100644 --- a/lib/sisu/v5/param.rb +++ b/lib/sisu/v5/param.rb @@ -1167,7 +1167,7 @@ module SiSU_Param ).txt_grey if @opt.act[:verbose][:set]==:on end if not @book_idx \ - and para =~/^=\{(.+?)\}\s*$/ + and para =~/^=\{(.+?)\}[\s`]*\Z/m @book_idx=true end unless @code_flag diff --git a/lib/sisu/v6/ao_doc_str.rb b/lib/sisu/v6/ao_doc_str.rb index 675bfc90..001b2aef 100644 --- a/lib/sisu/v6/ao_doc_str.rb +++ b/lib/sisu/v6/ao_doc_str.rb @@ -200,6 +200,7 @@ module SiSU_AO_DocumentStructureExtract idx_array_raw=idxraw.scan(/[^;]+/) idx_hash,idx_array,idx_lst={},[],[] idx_array_raw.each do |idx| + idx=idx.strip idx_lst=case idx when /\S+?\s*:/ idx_couplet_tmp=[] @@ -308,11 +309,11 @@ module SiSU_AO_DocumentStructureExtract and @@flag[:box]==:off \ and @@flag[:table]==:off unless t_o =~/^(?:@\S+?:|%+)\s/ # extract book index for paragraph if any - idx=if t_o=~/^=\{(.+)\}\s*$\Z/m; m=$1 - m=m.split(/\n/).join(' '). + idx=if t_o=~/^=\{\s*(.+)\s*\}\s*$\Z/m; m=$1 + m=m.split(/[ ]*\n/).join(' '). gsub(/\s+([|:;])\s+/,'\1'). gsub(/\s+([+]\d+)\s+/,'\1') - t_o=t_o.gsub(/\n=\{.+\}\s*$\Z/m,'') + t_o=t_o.gsub(/\n=\{.+?\}\s*$/m,'') idx_array_and_hash=construct_idx_array_and_hash(m) idx_array_and_hash[:hash] else nil diff --git a/lib/sisu/v6/param.rb b/lib/sisu/v6/param.rb index 1e7ea9de..bacee802 100644 --- a/lib/sisu/v6/param.rb +++ b/lib/sisu/v6/param.rb @@ -1167,7 +1167,7 @@ module SiSU_Param ).txt_grey if @opt.act[:verbose][:set]==:on end if not @book_idx \ - and para =~/^=\{(.+?)\}\s*$/ + and para =~/^=\{(.+?)\}[\s`]*\Z/m @book_idx=true end unless @code_flag -- cgit v1.2.3 From 60411adb8256b06545ea6db3cd2b4d2e7f58d03a Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Tue, 1 Jul 2014 00:49:09 -0400 Subject: v5 v6: ao, quote block, insert text indent markup (book index markup unchanged) --- data/doc/sisu/CHANGELOG_v5 | 1 + data/doc/sisu/CHANGELOG_v6 | 1 + lib/sisu/v5/ao_misc_arrange.rb | 9 +++++++-- lib/sisu/v6/ao_misc_arrange.rb | 9 +++++++-- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/data/doc/sisu/CHANGELOG_v5 b/data/doc/sisu/CHANGELOG_v5 index 7acd5140..6605fc8e 100644 --- a/data/doc/sisu/CHANGELOG_v5 +++ b/data/doc/sisu/CHANGELOG_v5 @@ -42,6 +42,7 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_5.4.3.orig.tar.xz * code cosmetic rearrangement * book index, strip white spaces around terms (fix uppercase first character where spaces used) + * quote block, insert text indent markup, exclude book index * code cosmetic rearrangement * ao*, param, hub, options, composite diff --git a/data/doc/sisu/CHANGELOG_v6 b/data/doc/sisu/CHANGELOG_v6 index beada6ad..266f1219 100644 --- a/data/doc/sisu/CHANGELOG_v6 +++ b/data/doc/sisu/CHANGELOG_v6 @@ -32,6 +32,7 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_6.0.9.orig.tar.xz * code cosmetic rearrangement * book index, strip white spaces around terms (fix uppercase first character where spaces used) + * quote block, insert text indent markup, exclude book index * code cosmetic rearrangement * ao*, param, hub, options, composite diff --git a/lib/sisu/v5/ao_misc_arrange.rb b/lib/sisu/v5/ao_misc_arrange.rb index a053f37e..09842fcc 100644 --- a/lib/sisu/v5/ao_misc_arrange.rb +++ b/lib/sisu/v5/ao_misc_arrange.rb @@ -66,7 +66,7 @@ module SiSU_AO_MiscArrangeText @md,@data=md,data end def conditional_headings(para) - para=para.gsub(/^(:?A~)\s*$/,'\1~ @title @author'). #conditional header + para=para.gsub(/^(:?A~)\s*$/,'\1~ @title @author'). #conditional header gsub(/^((?:[1-9]|:?[A-D])~\S*)\s*$/, '\1~ [Note: heading marker::required title missing]~#') #conditional header for incorporated document 2004w12 if para =~/^@\S+?:/ @@ -130,7 +130,12 @@ module SiSU_AO_MiscArrangeText para << '`:quote_open`' text=text.gsub(/```[ ]+quote/m,'') end - text=text.gsub(/(?:\n|\A)([^`=\n]+)/m,'_1 \1') #not a perfect match for book index \n={ + text=if text =~/(?:\n|\A)=\{.+?\}/m #exclude book index from indent markup + txt,bkidx,tail=/(.+?)((?:\n|\A)=\{.+?\}$)(.*)/m.match(text).captures + txt=txt.gsub(/(?:\n|\A)([^`\n]+)/m,'_1 \1') + txt + bkidx + tail + else text.gsub(/(?:\n|\A)([^`\n]+)/m,'_1 \1') + end para << text.gsub(/```/m,'') if text =~/```/m @flag=:quote_close diff --git a/lib/sisu/v6/ao_misc_arrange.rb b/lib/sisu/v6/ao_misc_arrange.rb index 387c14ca..8adebfd5 100644 --- a/lib/sisu/v6/ao_misc_arrange.rb +++ b/lib/sisu/v6/ao_misc_arrange.rb @@ -66,7 +66,7 @@ module SiSU_AO_MiscArrangeText @md,@data=md,data end def conditional_headings(para) - para=para.gsub(/^(:?A~)\s*$/,'\1~ @title @author'). #conditional header + para=para.gsub(/^(:?A~)\s*$/,'\1~ @title @author'). #conditional header gsub(/^((?:[1-9]|:?[A-D])~\S*)\s*$/, '\1~ [Note: heading marker::required title missing]~#') #conditional header for incorporated document 2004w12 if para =~/^@\S+?:/ @@ -130,7 +130,12 @@ module SiSU_AO_MiscArrangeText para << '`:quote_open`' text=text.gsub(/```[ ]+quote/m,'') end - text=text.gsub(/(?:\n|\A)([^`=\n]+)/m,'_1 \1') #not a perfect match for book index \n={ + text=if text =~/(?:\n|\A)=\{.+?\}/m #exclude book index from indent markup + txt,bkidx,tail=/(.+?)((?:\n|\A)=\{.+?\}$)(.*)/m.match(text).captures + txt=txt.gsub(/(?:\n|\A)([^`\n]+)/m,'_1 \1') + txt + bkidx + tail + else text.gsub(/(?:\n|\A)([^`\n]+)/m,'_1 \1') + end para << text.gsub(/```/m,'') if text =~/```/m @flag=:quote_close -- cgit v1.2.3 From e881dffcbeae1fcdebdc07ec4ce262564c49db86 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Tue, 1 Jul 2014 00:52:27 -0400 Subject: v5 v6: ao, doc objects, layout group open & close, identify, is_for --- data/doc/sisu/CHANGELOG_v5 | 1 + data/doc/sisu/CHANGELOG_v6 | 1 + lib/sisu/v5/ao_doc_objects.rb | 9 +++++---- lib/sisu/v5/ao_doc_str.rb | 22 +++++++++++++++++++++- lib/sisu/v6/ao_doc_objects.rb | 9 +++++---- lib/sisu/v6/ao_doc_str.rb | 22 +++++++++++++++++++++- 6 files changed, 54 insertions(+), 10 deletions(-) diff --git a/data/doc/sisu/CHANGELOG_v5 b/data/doc/sisu/CHANGELOG_v5 index 6605fc8e..9d14921a 100644 --- a/data/doc/sisu/CHANGELOG_v5 +++ b/data/doc/sisu/CHANGELOG_v5 @@ -43,6 +43,7 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_5.4.3.orig.tar.xz * book index, strip white spaces around terms (fix uppercase first character where spaces used) * quote block, insert text indent markup, exclude book index + * doc objects, layout group open & close identify is_for * code cosmetic rearrangement * ao*, param, hub, options, composite diff --git a/data/doc/sisu/CHANGELOG_v6 b/data/doc/sisu/CHANGELOG_v6 index 266f1219..72369d35 100644 --- a/data/doc/sisu/CHANGELOG_v6 +++ b/data/doc/sisu/CHANGELOG_v6 @@ -33,6 +33,7 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_6.0.9.orig.tar.xz * book index, strip white spaces around terms (fix uppercase first character where spaces used) * quote block, insert text indent markup, exclude book index + * doc objects, layout group open & close identify is_for * code cosmetic rearrangement * ao*, param, hub, options, composite diff --git a/lib/sisu/v5/ao_doc_objects.rb b/lib/sisu/v5/ao_doc_objects.rb index 1357ee90..b372da4c 100644 --- a/lib/sisu/v5/ao_doc_objects.rb +++ b/lib/sisu/v5/ao_doc_objects.rb @@ -499,10 +499,10 @@ module SiSU_AO_DocumentStructure end end class ObjectLayout - attr_accessor :obj,:sym,:attr,:is,:of,:from,:tmp,:num + attr_accessor :obj,:sym,:attr,:is,:is_for,:of,:from,:tmp,:num def initialize @of=:layout - @is=@obj=@from=@tmp=@num=nil + @is=@is_for=@obj=@from=@tmp=@num=nil end def break(h,f=nil) #decide how to deal with of= @of #Symbol, classification - group @@ -524,13 +524,14 @@ module SiSU_AO_DocumentStructure def open_close(h,o=nil) #useful for poem & quote of= @of #Symbol, classification - group is= :open_close_tags #Symbol, classification - specific type + is_for= h[:is_for] || ((defined? o.is_for) ? o.is_for : nil) #String, text content obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content sym= h[:sym] || ((defined? o.sym) ? o.sym : nil) #Symbol tag_open, tag_close attr= h[:attr] || ((defined? o.attr) ? o.attr : nil) #String, text content tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use num= h[:num] || ((defined? o.num) ? o.num : nil) - @of,@is,@obj,@sym,@attr,@tmp,@num= - of, is, obj, sym, attr, tmp, num + @of,@is,@is_for,@obj,@sym,@attr,@tmp,@num= + of, is, is_for, obj, sym, attr, tmp, num self end end diff --git a/lib/sisu/v5/ao_doc_str.rb b/lib/sisu/v5/ao_doc_str.rb index c3b65ee1..5b93819e 100644 --- a/lib/sisu/v5/ao_doc_str.rb +++ b/lib/sisu/v5/ao_doc_str.rb @@ -533,6 +533,7 @@ module SiSU_AO_DocumentStructureExtract : false @num_id[:code_block] +=1 h={ + is_for: :code, obj: '', sym: :code_block_open, num: @num_id[:code_block], @@ -547,6 +548,7 @@ module SiSU_AO_DocumentStructureExtract end @num_id[:poem] +=1 h={ + is_for: :poem, obj: '', sym: :poem_open, num: @num_id[:poem], @@ -561,6 +563,7 @@ module SiSU_AO_DocumentStructureExtract end @num_id[:box] +=1 h={ + is_for: :box, obj: '', sym: :box_open, num: @num_id[:box], @@ -575,6 +578,7 @@ module SiSU_AO_DocumentStructureExtract end @num_id[:group] +=1 h={ + is_for: :group, obj: '', sym: :group_open, num: @num_id[:group], @@ -589,6 +593,7 @@ module SiSU_AO_DocumentStructureExtract end @num_id[:block] +=1 h={ + is_for: :block, obj: '', sym: :block_open, num: @num_id[:block], @@ -603,6 +608,7 @@ module SiSU_AO_DocumentStructureExtract end @num_id[:alt] +=1 h={ + is_for: :alt, obj: '', sym: :alt_open, num: @num_id[:alt], @@ -613,6 +619,7 @@ module SiSU_AO_DocumentStructureExtract @@flag[:quote]=:open @num_id[:quote] +=1 h={ + is_for: :quote, obj: '', sym: :quote_open, num: @num_id[:quote], @@ -622,6 +629,7 @@ module SiSU_AO_DocumentStructureExtract elsif t_o =~/^(?:table\{|```[ ]+table|\{table)[ ~]/ @num_id[:table] +=1 h={ + is_for: :table, obj: '', sym: :table_open, num: @num_id[:table], @@ -701,6 +709,7 @@ module SiSU_AO_DocumentStructureExtract t_o=SiSU_AO_DocumentStructure::ObjectTable.new.table(h) unless h.nil? tuned_file << t_o h={ + is_for: :table, obj: '', sym: :table_close, num: @num_id[:table], @@ -736,6 +745,7 @@ module SiSU_AO_DocumentStructureExtract t_o=SiSU_AO_DocumentStructure::ObjectTable.new.table(h) unless h.nil? tuned_file << t_o h={ + is_for: :table, obj: '', sym: :table_close, num: @num_id[:table], @@ -771,6 +781,7 @@ module SiSU_AO_DocumentStructureExtract t_o=SiSU_AO_DocumentStructure::ObjectTable.new.table(h) unless h.nil? tuned_file << t_o h={ + is_for: :table, obj: '', sym: :table_close, num: @num_id[:table], @@ -799,6 +810,7 @@ module SiSU_AO_DocumentStructureExtract tuned_file << t_o @h,@rows=nil,'' h={ + is_for: :table, obj: '', sym: :table_close, num: @num_id[:table], @@ -834,6 +846,7 @@ module SiSU_AO_DocumentStructureExtract @tuned_code=[] tuned_file << t_o h={ + is_for: :code, obj: '', sym: :code_close, num: @num_id[:code_block], @@ -859,6 +872,7 @@ module SiSU_AO_DocumentStructureExtract or (@@flag[:poem]==:tics and t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) @@flag[:poem]=:off h={ + is_for: :poem, obj: '', sym: :poem_close, num: @num_id[:poem], @@ -877,6 +891,7 @@ module SiSU_AO_DocumentStructureExtract t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.box(h) tuned_file << t_o h={ + is_for: :box, obj: '', sym: :box_close, num: @num_id[:box], @@ -895,6 +910,7 @@ module SiSU_AO_DocumentStructureExtract t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.group(h) tuned_file << t_o h={ + is_for: :group, obj: '', sym: :group_close, num: @num_id[:group], @@ -912,7 +928,9 @@ module SiSU_AO_DocumentStructureExtract @tuned_block=[] t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.block(h) tuned_file << t_o - h={ obj: '', + h={ + is_for: :block, + obj: '', sym: :block_close, num: @num_id[:block], } @@ -930,6 +948,7 @@ module SiSU_AO_DocumentStructureExtract @tuned_block=[] tuned_file << t_o h={ + is_for: :alt, obj: '', sym: :alt_close, num: @num_id[:alt], @@ -938,6 +957,7 @@ module SiSU_AO_DocumentStructureExtract elsif @@flag[:quote]==:open and t_o =~/`:quote_close`/m @@flag[:quote]=:off h={ + is_for: :quote, obj: '', sym: :quote_close, num: @num_id[:quote], diff --git a/lib/sisu/v6/ao_doc_objects.rb b/lib/sisu/v6/ao_doc_objects.rb index 909bb600..44660469 100644 --- a/lib/sisu/v6/ao_doc_objects.rb +++ b/lib/sisu/v6/ao_doc_objects.rb @@ -499,10 +499,10 @@ module SiSU_AO_DocumentStructure end end class ObjectLayout - attr_accessor :obj,:sym,:attr,:is,:of,:from,:tmp,:num + attr_accessor :obj,:sym,:attr,:is,:is_for,:of,:from,:tmp,:num def initialize @of=:layout - @is=@obj=@from=@tmp=@num=nil + @is=@is_for=@obj=@from=@tmp=@num=nil end def break(h,f=nil) #decide how to deal with of= @of #Symbol, classification - group @@ -524,13 +524,14 @@ module SiSU_AO_DocumentStructure def open_close(h,o=nil) #useful for poem & quote of= @of #Symbol, classification - group is= :open_close_tags #Symbol, classification - specific type + is_for= h[:is_for] || ((defined? o.is_for) ? o.is_for : nil) #String, text content obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content sym= h[:sym] || ((defined? o.sym) ? o.sym : nil) #Symbol tag_open, tag_close attr= h[:attr] || ((defined? o.attr) ? o.attr : nil) #String, text content tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use num= h[:num] || ((defined? o.num) ? o.num : nil) - @of,@is,@obj,@sym,@attr,@tmp,@num= - of, is, obj, sym, attr, tmp, num + @of,@is,@is_for,@obj,@sym,@attr,@tmp,@num= + of, is, is_for, obj, sym, attr, tmp, num self end end diff --git a/lib/sisu/v6/ao_doc_str.rb b/lib/sisu/v6/ao_doc_str.rb index 001b2aef..0c07eee7 100644 --- a/lib/sisu/v6/ao_doc_str.rb +++ b/lib/sisu/v6/ao_doc_str.rb @@ -533,6 +533,7 @@ module SiSU_AO_DocumentStructureExtract : false @num_id[:code_block] +=1 h={ + is_for: :code, obj: '', sym: :code_block_open, num: @num_id[:code_block], @@ -547,6 +548,7 @@ module SiSU_AO_DocumentStructureExtract end @num_id[:poem] +=1 h={ + is_for: :poem, obj: '', sym: :poem_open, num: @num_id[:poem], @@ -561,6 +563,7 @@ module SiSU_AO_DocumentStructureExtract end @num_id[:box] +=1 h={ + is_for: :box, obj: '', sym: :box_open, num: @num_id[:box], @@ -575,6 +578,7 @@ module SiSU_AO_DocumentStructureExtract end @num_id[:group] +=1 h={ + is_for: :group, obj: '', sym: :group_open, num: @num_id[:group], @@ -589,6 +593,7 @@ module SiSU_AO_DocumentStructureExtract end @num_id[:block] +=1 h={ + is_for: :block, obj: '', sym: :block_open, num: @num_id[:block], @@ -603,6 +608,7 @@ module SiSU_AO_DocumentStructureExtract end @num_id[:alt] +=1 h={ + is_for: :alt, obj: '', sym: :alt_open, num: @num_id[:alt], @@ -613,6 +619,7 @@ module SiSU_AO_DocumentStructureExtract @@flag[:quote]=:open @num_id[:quote] +=1 h={ + is_for: :quote, obj: '', sym: :quote_open, num: @num_id[:quote], @@ -622,6 +629,7 @@ module SiSU_AO_DocumentStructureExtract elsif t_o =~/^(?:table\{|```[ ]+table|\{table)[ ~]/ @num_id[:table] +=1 h={ + is_for: :table, obj: '', sym: :table_open, num: @num_id[:table], @@ -701,6 +709,7 @@ module SiSU_AO_DocumentStructureExtract t_o=SiSU_AO_DocumentStructure::ObjectTable.new.table(h) unless h.nil? tuned_file << t_o h={ + is_for: :table, obj: '', sym: :table_close, num: @num_id[:table], @@ -736,6 +745,7 @@ module SiSU_AO_DocumentStructureExtract t_o=SiSU_AO_DocumentStructure::ObjectTable.new.table(h) unless h.nil? tuned_file << t_o h={ + is_for: :table, obj: '', sym: :table_close, num: @num_id[:table], @@ -771,6 +781,7 @@ module SiSU_AO_DocumentStructureExtract t_o=SiSU_AO_DocumentStructure::ObjectTable.new.table(h) unless h.nil? tuned_file << t_o h={ + is_for: :table, obj: '', sym: :table_close, num: @num_id[:table], @@ -799,6 +810,7 @@ module SiSU_AO_DocumentStructureExtract tuned_file << t_o @h,@rows=nil,'' h={ + is_for: :table, obj: '', sym: :table_close, num: @num_id[:table], @@ -834,6 +846,7 @@ module SiSU_AO_DocumentStructureExtract @tuned_code=[] tuned_file << t_o h={ + is_for: :code, obj: '', sym: :code_close, num: @num_id[:code_block], @@ -859,6 +872,7 @@ module SiSU_AO_DocumentStructureExtract or (@@flag[:poem]==:tics and t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) @@flag[:poem]=:off h={ + is_for: :poem, obj: '', sym: :poem_close, num: @num_id[:poem], @@ -877,6 +891,7 @@ module SiSU_AO_DocumentStructureExtract t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.box(h) tuned_file << t_o h={ + is_for: :box, obj: '', sym: :box_close, num: @num_id[:box], @@ -895,6 +910,7 @@ module SiSU_AO_DocumentStructureExtract t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.group(h) tuned_file << t_o h={ + is_for: :group, obj: '', sym: :group_close, num: @num_id[:group], @@ -912,7 +928,9 @@ module SiSU_AO_DocumentStructureExtract @tuned_block=[] t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.block(h) tuned_file << t_o - h={ obj: '', + h={ + is_for: :block, + obj: '', sym: :block_close, num: @num_id[:block], } @@ -930,6 +948,7 @@ module SiSU_AO_DocumentStructureExtract @tuned_block=[] tuned_file << t_o h={ + is_for: :alt, obj: '', sym: :alt_close, num: @num_id[:alt], @@ -938,6 +957,7 @@ module SiSU_AO_DocumentStructureExtract elsif @@flag[:quote]==:open and t_o =~/`:quote_close`/m @@flag[:quote]=:off h={ + is_for: :quote, obj: '', sym: :quote_close, num: @num_id[:quote], -- cgit v1.2.3 From f74de438d030629eec66eeb1f7275ed62bc5c370 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Tue, 1 Jul 2014 00:54:37 -0400 Subject: v5 v6: ao, segment numbering, fixed width, leading zeros * alphanumeric sorting --- data/doc/sisu/CHANGELOG_v5 | 1 + data/doc/sisu/CHANGELOG_v6 | 1 + lib/sisu/v5/ao_doc_str.rb | 53 +++++++++++++++++++++++++------------------ lib/sisu/v5/ao_numbering.rb | 55 +++++++++++++++++++++++++++++++++++++++------ lib/sisu/v5/constants.rb | 1 + lib/sisu/v6/ao_doc_str.rb | 53 +++++++++++++++++++++++++------------------ lib/sisu/v6/ao_numbering.rb | 55 +++++++++++++++++++++++++++++++++++++++------ lib/sisu/v6/constants.rb | 1 + 8 files changed, 162 insertions(+), 58 deletions(-) diff --git a/data/doc/sisu/CHANGELOG_v5 b/data/doc/sisu/CHANGELOG_v5 index 9d14921a..45d9587f 100644 --- a/data/doc/sisu/CHANGELOG_v5 +++ b/data/doc/sisu/CHANGELOG_v5 @@ -44,6 +44,7 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_5.4.3.orig.tar.xz (fix uppercase first character where spaces used) * quote block, insert text indent markup, exclude book index * doc objects, layout group open & close identify is_for + * segment numbering, fixed width, leading zeros (for alphanumeric sorting) * code cosmetic rearrangement * ao*, param, hub, options, composite diff --git a/data/doc/sisu/CHANGELOG_v6 b/data/doc/sisu/CHANGELOG_v6 index 72369d35..732d0d99 100644 --- a/data/doc/sisu/CHANGELOG_v6 +++ b/data/doc/sisu/CHANGELOG_v6 @@ -34,6 +34,7 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_6.0.9.orig.tar.xz (fix uppercase first character where spaces used) * quote block, insert text indent markup, exclude book index * doc objects, layout group open & close identify is_for + * segment numbering, fixed width, leading zeros (for alphanumeric sorting) * code cosmetic rearrangement * ao*, param, hub, options, composite diff --git a/lib/sisu/v5/ao_doc_str.rb b/lib/sisu/v5/ao_doc_str.rb index 5b93819e..931e51d3 100644 --- a/lib/sisu/v5/ao_doc_str.rb +++ b/lib/sisu/v5/ao_doc_str.rb @@ -506,8 +506,9 @@ module SiSU_AO_DocumentStructureExtract tags: tags, quote: quotes?, } - SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h) + t_o=SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h) end + t_o=SiSU_AO_DocumentStructureExtract::Structure.new(@md).structure_markup(t_o) #must happen earlier, node info etc. require end elsif @@flag[:code]==:off if t_o =~/^(?:code(?:\.[a-z][0-9a-z_]+)?\{|```[ ]+code(?:\.[a-z][0-9a-z_]+)?)/ @@ -1146,66 +1147,74 @@ module SiSU_AO_DocumentStructureExtract end end class Structure # this must happen early - def initialize(md,dob) - @md,@dob=md,dob + def initialize(md) + @md=md end - def structure - structure_markup - @dob + def structure(data) + data.compact.each do |dob| + structure_markup(dob) + end end - def structure_markup #build structure where structure provided only in meta header - @dob=if @dob.is==:para \ - && (((@dob.hang !~/[1-9]/) && (@dob.indent !~/[1-9]/)) \ - || (@dob.hang != @dob.indent)) \ - and not @dob.bullet_ - @dob=case @dob.obj + def structure_markup(dob) #build structure where structure provided only in meta header + dob=if dob.is==:para \ + && (((dob.hang !~/[1-9]/) && (dob.indent !~/[1-9]/)) \ + || (dob.hang != dob.indent)) \ + and not dob.bullet_ + dob=case dob.obj when /^#{@md.lv0}/ h={ + is: :heading, lv: 'A', ln: 0, } - SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,@dob) + SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,dob) when /^#{@md.lv1}/ h={ + is: :heading, lv: 'B', ln: 1, } - SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,@dob) + SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,dob) when /^#{@md.lv2}/ h={ + is: :heading, lv: 'C', ln: 2, } - SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,@dob) + SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,dob) when /^#{@md.lv3}/ h={ + is: :heading, lv: 'D', ln: 3, } - SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,@dob) + SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,dob) when /^#{@md.lv4}/ h={ + is: :heading, lv: '1', ln: 4, } - SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,@dob) + SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,dob) when /^#{@md.lv5}/ h={ + is: :heading, lv: '2', ln: 5, } - SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,@dob) + SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,dob) when /^#{@md.lv6}/ h={ + is: :heading, lv: '3', ln: 6, } - SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,@dob) - else @dob + SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,dob) + else dob end - else @dob + else dob end - @dob + dob end end class OCN diff --git a/lib/sisu/v5/ao_numbering.rb b/lib/sisu/v5/ao_numbering.rb index cd631796..c4b6558f 100644 --- a/lib/sisu/v5/ao_numbering.rb +++ b/lib/sisu/v5/ao_numbering.rb @@ -63,10 +63,23 @@ module SiSU_AO_Numbering class Numbering attr_accessor :obj,:osp,:ocn,:lv,:name,:index,:comment + @@segments_count=0 def initialize(md,data) @md,@data=md,data @obj=@type=@ocn=@lv=@name=@index=@comment=nil end + def number_of_segments? + if @@segments_count==0 + @data.each do |dob| + if dob.is == :heading \ + and dob.lv == '1' + @@segments_count += 1 + end + end + @@segments_count + else @@segments_count + end + end def numbering_song data=@data data=number_plaintext_para(data) @@ -152,7 +165,6 @@ module SiSU_AO_Numbering data=data.compact data.each do |dob| #@md.seg_names << [additions to segment names] title_no=nil - dob=SiSU_AO_DocumentStructureExtract::Structure.new(@md,dob).structure_markup #must happen earlier, node info etc. require if dob.is ==:heading \ && dob.autonum_ \ and defined? @md.make.num_top \ @@ -280,6 +292,33 @@ module SiSU_AO_Numbering end @tuned_file=@tuned_file.flatten end + def leading_zeros_fixed_width_number(possible_seg_name) + if possible_seg_name =~/^([\d]+?\.|[\d]+)$/m #!~/[.,:-]+/ + possible_seg_name=possible_seg_name. + gsub(/\.$/,'') + nl=possible_seg_name.to_s.length + zero='0' + zeros_fixed_width=number_of_segments?.to_s.length + zero_width=(zeros_fixed_width - nl) + zero_width == 0 \ + ? Mx[:auto_seg_prefix] + + possible_seg_name.to_s + : Mx[:auto_seg_prefix] + + zero*zero_width + + possible_seg_name.to_s + end + end + def auto_seg_name(possible_seg_name) + if possible_seg_name =~/^([\d]+?\.|[\d]+)$/m #!~/[.,:-]+/ + leading_zeros_fixed_width_number(possible_seg_name) + elsif possible_seg_name =~/^[\d.,:-]+$/m + possible_seg_name=possible_seg_name. + gsub(/(?:[:,-]|\W)/,'.'). + gsub(/\.$/,'') + #Mx[:auto_seg_prefix] + possible_seg_name + else possible_seg_name + end + end def name_para_seg_filename(data) #segment naming, remaining # paragraph name/numbering rules # manual naming overrides, manual naming may be @@ -314,8 +353,10 @@ module SiSU_AO_Numbering @md.set_heading_seg=true end if dob.name !~/^\S+/ \ - and dob.obj =~/^\s*(?:\S+\s+)?([\d.,:-]+)/m #heading starts with a recognised numeric or word followed by a recognised numerical construct, use that as name + and dob.obj =~/^\s*(?:\S+\s+)?([\d.,:-]+)/m #heading starts with a recognised numeric or word followed by a recognised numeric construct, use that as name possible_seg_name=$1 + possible_seg_name= + auto_seg_name(possible_seg_name) possible_seg_name=possible_seg_name. gsub(/(?:[:,-]|\W)/,'.'). gsub(/\.$/,'') @@ -339,13 +380,13 @@ module SiSU_AO_Numbering end if dob.ln==4 \ and not dob.name #if still no segment name, provide a numerical one - pf='_' #pg='' #may use e.g. '' or '~' or '_' - segn_auto="#{pf}#{art_filename_auto.to_s}" + possible_seg_name= + auto_seg_name(art_filename_auto) if @md.seg_names.is_a?(Array) \ - and not @md.seg_names.include?(segn_auto) - dob.name=segn_auto + and not @md.seg_names.include?(possible_seg_name) + dob.name=possible_seg_name dob.tags=set_tags(dob.tags,dob.name) - @md.seg_names << segn_auto + @md.seg_names << possible_seg_name else puts 'segment name (numbering) error' end art_filename_auto+=1 diff --git a/lib/sisu/v5/constants.rb b/lib/sisu/v5/constants.rb index 42ab53a3..6b44ec68 100644 --- a/lib/sisu/v5/constants.rb +++ b/lib/sisu/v5/constants.rb @@ -104,6 +104,7 @@ Xx={ html_relative1: '※', } Mx={ + auto_seg_prefix: 's', ocn_id_char: 'o', note: 'note_', note_ref: 'noteref_', diff --git a/lib/sisu/v6/ao_doc_str.rb b/lib/sisu/v6/ao_doc_str.rb index 0c07eee7..2a96abb7 100644 --- a/lib/sisu/v6/ao_doc_str.rb +++ b/lib/sisu/v6/ao_doc_str.rb @@ -506,8 +506,9 @@ module SiSU_AO_DocumentStructureExtract tags: tags, quote: quotes?, } - SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h) + t_o=SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h) end + t_o=SiSU_AO_DocumentStructureExtract::Structure.new(@md).structure_markup(t_o) #must happen earlier, node info etc. require end elsif @@flag[:code]==:off if t_o =~/^(?:code(?:\.[a-z][0-9a-z_]+)?\{|```[ ]+code(?:\.[a-z][0-9a-z_]+)?)/ @@ -1146,66 +1147,74 @@ module SiSU_AO_DocumentStructureExtract end end class Structure # this must happen early - def initialize(md,dob) - @md,@dob=md,dob + def initialize(md) + @md=md end - def structure - structure_markup - @dob + def structure(data) + data.compact.each do |dob| + structure_markup(dob) + end end - def structure_markup #build structure where structure provided only in meta header - @dob=if @dob.is==:para \ - && (((@dob.hang !~/[1-9]/) && (@dob.indent !~/[1-9]/)) \ - || (@dob.hang != @dob.indent)) \ - and not @dob.bullet_ - @dob=case @dob.obj + def structure_markup(dob) #build structure where structure provided only in meta header + dob=if dob.is==:para \ + && (((dob.hang !~/[1-9]/) && (dob.indent !~/[1-9]/)) \ + || (dob.hang != dob.indent)) \ + and not dob.bullet_ + dob=case dob.obj when /^#{@md.lv0}/ h={ + is: :heading, lv: 'A', ln: 0, } - SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,@dob) + SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,dob) when /^#{@md.lv1}/ h={ + is: :heading, lv: 'B', ln: 1, } - SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,@dob) + SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,dob) when /^#{@md.lv2}/ h={ + is: :heading, lv: 'C', ln: 2, } - SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,@dob) + SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,dob) when /^#{@md.lv3}/ h={ + is: :heading, lv: 'D', ln: 3, } - SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,@dob) + SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,dob) when /^#{@md.lv4}/ h={ + is: :heading, lv: '1', ln: 4, } - SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,@dob) + SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,dob) when /^#{@md.lv5}/ h={ + is: :heading, lv: '2', ln: 5, } - SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,@dob) + SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,dob) when /^#{@md.lv6}/ h={ + is: :heading, lv: '3', ln: 6, } - SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,@dob) - else @dob + SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,dob) + else dob end - else @dob + else dob end - @dob + dob end end class OCN diff --git a/lib/sisu/v6/ao_numbering.rb b/lib/sisu/v6/ao_numbering.rb index 791f5bfc..d6faf3a6 100644 --- a/lib/sisu/v6/ao_numbering.rb +++ b/lib/sisu/v6/ao_numbering.rb @@ -63,10 +63,23 @@ module SiSU_AO_Numbering class Numbering attr_accessor :obj,:osp,:ocn,:lv,:name,:index,:comment + @@segments_count=0 def initialize(md,data) @md,@data=md,data @obj=@type=@ocn=@lv=@name=@index=@comment=nil end + def number_of_segments? + if @@segments_count==0 + @data.each do |dob| + if dob.is == :heading \ + and dob.lv == '1' + @@segments_count += 1 + end + end + @@segments_count + else @@segments_count + end + end def numbering_song data=@data data=number_plaintext_para(data) @@ -152,7 +165,6 @@ module SiSU_AO_Numbering data=data.compact data.each do |dob| #@md.seg_names << [additions to segment names] title_no=nil - dob=SiSU_AO_DocumentStructureExtract::Structure.new(@md,dob).structure_markup #must happen earlier, node info etc. require if dob.is ==:heading \ && dob.autonum_ \ and defined? @md.make.num_top \ @@ -280,6 +292,33 @@ module SiSU_AO_Numbering end @tuned_file=@tuned_file.flatten end + def leading_zeros_fixed_width_number(possible_seg_name) + if possible_seg_name =~/^([\d]+?\.|[\d]+)$/m #!~/[.,:-]+/ + possible_seg_name=possible_seg_name. + gsub(/\.$/,'') + nl=possible_seg_name.to_s.length + zero='0' + zeros_fixed_width=number_of_segments?.to_s.length + zero_width=(zeros_fixed_width - nl) + zero_width == 0 \ + ? Mx[:auto_seg_prefix] + + possible_seg_name.to_s + : Mx[:auto_seg_prefix] + + zero*zero_width + + possible_seg_name.to_s + end + end + def auto_seg_name(possible_seg_name) + if possible_seg_name =~/^([\d]+?\.|[\d]+)$/m #!~/[.,:-]+/ + leading_zeros_fixed_width_number(possible_seg_name) + elsif possible_seg_name =~/^[\d.,:-]+$/m + possible_seg_name=possible_seg_name. + gsub(/(?:[:,-]|\W)/,'.'). + gsub(/\.$/,'') + #Mx[:auto_seg_prefix] + possible_seg_name + else possible_seg_name + end + end def name_para_seg_filename(data) #segment naming, remaining # paragraph name/numbering rules # manual naming overrides, manual naming may be @@ -314,8 +353,10 @@ module SiSU_AO_Numbering @md.set_heading_seg=true end if dob.name !~/^\S+/ \ - and dob.obj =~/^\s*(?:\S+\s+)?([\d.,:-]+)/m #heading starts with a recognised numeric or word followed by a recognised numerical construct, use that as name + and dob.obj =~/^\s*(?:\S+\s+)?([\d.,:-]+)/m #heading starts with a recognised numeric or word followed by a recognised numeric construct, use that as name possible_seg_name=$1 + possible_seg_name= + auto_seg_name(possible_seg_name) possible_seg_name=possible_seg_name. gsub(/(?:[:,-]|\W)/,'.'). gsub(/\.$/,'') @@ -339,13 +380,13 @@ module SiSU_AO_Numbering end if dob.ln==4 \ and not dob.name #if still no segment name, provide a numerical one - pf='_' #pg='' #may use e.g. '' or '~' or '_' - segn_auto="#{pf}#{art_filename_auto.to_s}" + possible_seg_name= + auto_seg_name(art_filename_auto) if @md.seg_names.is_a?(Array) \ - and not @md.seg_names.include?(segn_auto) - dob.name=segn_auto + and not @md.seg_names.include?(possible_seg_name) + dob.name=possible_seg_name dob.tags=set_tags(dob.tags,dob.name) - @md.seg_names << segn_auto + @md.seg_names << possible_seg_name else puts 'segment name (numbering) error' end art_filename_auto+=1 diff --git a/lib/sisu/v6/constants.rb b/lib/sisu/v6/constants.rb index 43fff554..487d96a0 100644 --- a/lib/sisu/v6/constants.rb +++ b/lib/sisu/v6/constants.rb @@ -104,6 +104,7 @@ Xx={ html_relative1: '※', } Mx={ + auto_seg_prefix: 's', ocn_id_char: 'o', note: 'note_', note_ref: 'noteref_', -- cgit v1.2.3 From 1b3d9ac3643bee5c51e37c2b6d27886fe0f721df Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Tue, 1 Jul 2014 00:56:27 -0400 Subject: v5 v6: epub, a fix, double check --- data/doc/sisu/CHANGELOG_v5 | 2 ++ data/doc/sisu/CHANGELOG_v6 | 2 ++ lib/sisu/v5/xhtml_epub2_segments.rb | 1 + lib/sisu/v6/xhtml_epub2_segments.rb | 1 + 4 files changed, 6 insertions(+) diff --git a/data/doc/sisu/CHANGELOG_v5 b/data/doc/sisu/CHANGELOG_v5 index 45d9587f..f3ac82cd 100644 --- a/data/doc/sisu/CHANGELOG_v5 +++ b/data/doc/sisu/CHANGELOG_v5 @@ -66,6 +66,8 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_5.4.3.orig.tar.xz * box block * quote block +* epub, a fix, double check + %% 5.4.2.orig.tar.xz (2014-06-22:24/7) http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/sisu_5.4.2 http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/debian/sisu_5.4.2-1 diff --git a/data/doc/sisu/CHANGELOG_v6 b/data/doc/sisu/CHANGELOG_v6 index 732d0d99..2d8474e3 100644 --- a/data/doc/sisu/CHANGELOG_v6 +++ b/data/doc/sisu/CHANGELOG_v6 @@ -39,6 +39,8 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_6.0.9.orig.tar.xz * code cosmetic rearrangement * ao*, param, hub, options, composite +* epub, a fix, double check + %% 6.0.8.orig.tar.xz (2014-06-19:24/4) http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/sisu_6.0.8 http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/debian/sisu_6.0.8-1 diff --git a/lib/sisu/v5/xhtml_epub2_segments.rb b/lib/sisu/v5/xhtml_epub2_segments.rb index 8612696f..3c3b3263 100644 --- a/lib/sisu/v5/xhtml_epub2_segments.rb +++ b/lib/sisu/v5/xhtml_epub2_segments.rb @@ -80,6 +80,7 @@ module SiSU_XHTML_EPUB2_Seg filename_seg << @seg[:heading_endnotes] << @seg[:headings] << %{\n

\n} << @seg[:endnote_all] << '
' elsif @type=='idx' @seg[:headings]=[] + txt_obj={ txt: 'Index', ocn_display: ''} format_seg=SiSU_XHTML_EPUB2_Format::FormatSeg.new(@md,txt_obj) @seg[:headings] << format_seg.title_heading1 filename_seg << @seg[:heading_idx] << @seg[:headings] << %{\n
\n} << @seg[:idx] << '
' diff --git a/lib/sisu/v6/xhtml_epub2_segments.rb b/lib/sisu/v6/xhtml_epub2_segments.rb index d249b0ff..8b9254d4 100644 --- a/lib/sisu/v6/xhtml_epub2_segments.rb +++ b/lib/sisu/v6/xhtml_epub2_segments.rb @@ -80,6 +80,7 @@ module SiSU_XHTML_EPUB2_Seg filename_seg << @seg[:heading_endnotes] << @seg[:headings] << %{\n
\n} << @seg[:endnote_all] << '
' elsif @type=='idx' @seg[:headings]=[] + txt_obj={ txt: 'Index', ocn_display: ''} format_seg=SiSU_XHTML_EPUB2_Format::FormatSeg.new(@md,txt_obj) @seg[:headings] << format_seg.title_heading1 filename_seg << @seg[:heading_idx] << @seg[:headings] << %{\n
\n} << @seg[:idx] << '
' -- cgit v1.2.3 From d850e670c1163dd1dba5f958d0cfd62f2a431112 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Tue, 1 Jul 2014 00:58:09 -0400 Subject: v5 v6: sysenv, developer _CONSTRUCTION_ZONE warning setup modified --- data/doc/sisu/CHANGELOG_v5 | 2 ++ data/doc/sisu/CHANGELOG_v6 | 2 ++ lib/sisu/v5/constants.rb | 1 + lib/sisu/v5/sysenv.rb | 16 ++++++++-------- lib/sisu/v6/constants.rb | 1 + lib/sisu/v6/sysenv.rb | 16 ++++++++-------- 6 files changed, 22 insertions(+), 16 deletions(-) diff --git a/data/doc/sisu/CHANGELOG_v5 b/data/doc/sisu/CHANGELOG_v5 index f3ac82cd..ec8eb24f 100644 --- a/data/doc/sisu/CHANGELOG_v5 +++ b/data/doc/sisu/CHANGELOG_v5 @@ -49,6 +49,8 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_5.4.3.orig.tar.xz * code cosmetic rearrangement * ao*, param, hub, options, composite +* sysenv, developer _CONSTRUCTION_ZONE warning modified + * merge what was sisu_6.0.8 into v5 * ao, * syntax, able optionally to indicate the language syntax of a code block diff --git a/data/doc/sisu/CHANGELOG_v6 b/data/doc/sisu/CHANGELOG_v6 index 2d8474e3..ada19da7 100644 --- a/data/doc/sisu/CHANGELOG_v6 +++ b/data/doc/sisu/CHANGELOG_v6 @@ -39,6 +39,8 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_6.0.9.orig.tar.xz * code cosmetic rearrangement * ao*, param, hub, options, composite +* sysenv, developer _CONSTRUCTION_ZONE warning modified + * epub, a fix, double check %% 6.0.8.orig.tar.xz (2014-06-19:24/4) diff --git a/lib/sisu/v5/constants.rb b/lib/sisu/v5/constants.rb index 6b44ec68..eb252fda 100644 --- a/lib/sisu/v5/constants.rb +++ b/lib/sisu/v5/constants.rb @@ -334,6 +334,7 @@ DISABLE={ } DEVELOPER={ maintenance: :false, + under_construction: '_CONSTRUCTION_ZONE', } __END__ utils.rb diff --git a/lib/sisu/v5/sysenv.rb b/lib/sisu/v5/sysenv.rb index cfd40460..7358ff40 100644 --- a/lib/sisu/v5/sysenv.rb +++ b/lib/sisu/v5/sysenv.rb @@ -6032,7 +6032,7 @@ WOK end def textile def ft - 'textile_CONSTRUCTION_ZONE' + 'textile' + DEVELOPER[:under_construction] end def dir set_path(ft).dir.abc @@ -6053,7 +6053,7 @@ WOK end def asciidoc def ft - 'asciidoc_CONSTRUCTION_ZONE' + 'asciidoc' + DEVELOPER[:under_construction] end def dir set_path(ft).dir.abc @@ -6074,7 +6074,7 @@ WOK end def markdown def ft - 'markdown_CONSTRUCTION_ZONE' + 'markdown' + DEVELOPER[:under_construction] end def dir set_path(ft).dir.abc @@ -6095,7 +6095,7 @@ WOK end def rst def ft - 'rst_CONSTRUCTION_ZONE' + 'rst' + DEVELOPER[:under_construction] end def dir set_path(ft).dir.abc @@ -6315,7 +6315,7 @@ WOK end def xml_docbook def ft - 'docbook_CONSTRUCTION_ZONE' + 'docbook' + DEVELOPER[:under_construction] end def dir set_path(ft).dir.abc @@ -6339,7 +6339,7 @@ WOK end def xml_docbook_article def ft - 'docbook' + 'docbook' + DEVELOPER[:under_construction] end def dir set_path(ft).dir.abc @@ -6363,7 +6363,7 @@ WOK end def xml_docbook_book def ft - 'docbook_CONSTRUCTION_ZONE' + 'docbook' + DEVELOPER[:under_construction] end def dir set_path(ft).dir.abc @@ -6387,7 +6387,7 @@ WOK end def xml_fictionbook def ft - 'fictionbook_CONSTRUCTION_ZONE' + 'fictionbook' + DEVELOPER[:under_construction] end def dir set_path(ft).dir.abc diff --git a/lib/sisu/v6/constants.rb b/lib/sisu/v6/constants.rb index 487d96a0..d25478d1 100644 --- a/lib/sisu/v6/constants.rb +++ b/lib/sisu/v6/constants.rb @@ -334,6 +334,7 @@ DISABLE={ } DEVELOPER={ maintenance: :false, + under_construction: '_CONSTRUCTION_ZONE', } __END__ utils.rb diff --git a/lib/sisu/v6/sysenv.rb b/lib/sisu/v6/sysenv.rb index 2c2a8c10..3c774c46 100644 --- a/lib/sisu/v6/sysenv.rb +++ b/lib/sisu/v6/sysenv.rb @@ -6032,7 +6032,7 @@ WOK end def textile def ft - 'textile_CONSTRUCTION_ZONE' + 'textile' + DEVELOPER[:under_construction] end def dir set_path(ft).dir.abc @@ -6053,7 +6053,7 @@ WOK end def asciidoc def ft - 'asciidoc_CONSTRUCTION_ZONE' + 'asciidoc' + DEVELOPER[:under_construction] end def dir set_path(ft).dir.abc @@ -6074,7 +6074,7 @@ WOK end def markdown def ft - 'markdown_CONSTRUCTION_ZONE' + 'markdown' + DEVELOPER[:under_construction] end def dir set_path(ft).dir.abc @@ -6095,7 +6095,7 @@ WOK end def rst def ft - 'rst_CONSTRUCTION_ZONE' + 'rst' + DEVELOPER[:under_construction] end def dir set_path(ft).dir.abc @@ -6315,7 +6315,7 @@ WOK end def xml_docbook def ft - 'docbook_CONSTRUCTION_ZONE' + 'docbook' + DEVELOPER[:under_construction] end def dir set_path(ft).dir.abc @@ -6339,7 +6339,7 @@ WOK end def xml_docbook_article def ft - 'docbook' + 'docbook' + DEVELOPER[:under_construction] end def dir set_path(ft).dir.abc @@ -6363,7 +6363,7 @@ WOK end def xml_docbook_book def ft - 'docbook_CONSTRUCTION_ZONE' + 'docbook' + DEVELOPER[:under_construction] end def dir set_path(ft).dir.abc @@ -6387,7 +6387,7 @@ WOK end def xml_fictionbook def ft - 'fictionbook_CONSTRUCTION_ZONE' + 'fictionbook' + DEVELOPER[:under_construction] end def dir set_path(ft).dir.abc -- cgit v1.2.3