From d4d5086099c5bcd08f6f011b4ca7c9ee336c56cf Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Thu, 19 Jun 2014 19:06:39 -0400 Subject: v5 v6: version & changelog (& rakefile) --- data/doc/sisu/CHANGELOG_v5 | 54 ++++++++++++++++++++++++++++++++++++++++++++++ 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, 69 insertions(+), 8 deletions(-) diff --git a/data/doc/sisu/CHANGELOG_v5 b/data/doc/sisu/CHANGELOG_v5 index fe2834c2..292d0c21 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.1.orig.tar.xz (2014-06-19:24/4) +http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/sisu_5.4.1 +http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/debian/sisu_5.4.1-1 +http://www.jus.uio.no/sisu/pkg/src/sisu_5.4.1.orig.tar.xz + sisu_5.4.1.orig.tar.xz + sisu_5.4.1-1.dsc + %% 5.4.0.orig.tar.xz (2014-05-25:20/7) http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/sisu_5.4.0 http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/debian/sisu_5.4.0-1 @@ -38,6 +45,53 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_5.4.0.orig.tar.xz sisu_5.4.0.orig.tar.xz sisu_5.4.0-1.dsc +* v5: merge v6 to v5, version bump to 5.4.*, reason adds structure check + * ao, document structure check, stop processing on major error + (with error message & text at location of failure) + [reason for version bump the addition of structure check] + * utils, add ok code marker + * ao, heading with no ocn, distinguish ~# from -# + * ~# is general & means no ocn (for any object to which it is applied) + * -# is relevant only for 1~ dummy headings & instructs that they should be + removed from output where possible + * applied so far to pdf, odt & plaintext + * ao_images, reduce warnings when ruby RMagic absent as program used directly + * reduced dependency on ruby RMagic library (as some time way back had + issues) + * ao, document markup structure check, skip processing file on major error + * with error message & text at location of failure + * texpdf, urls in creator cause breakage + * texpdf, mailto markup links set for normal text objects + * texpdf, '&' in heading breaks toc (now removed from toc (not heading)), bug + * revisit, bug + * texpdf, for urls switch to sans serif (small fontsize) + * instead of typewriter, latex default + * texpdf, pdf colored hyperlinks configurable + * --pdf-hyperlinks-color + --pdf-hyperlinks-no-color or --pdf-hyperlinks-monochrome + * ['default']['pdf_hyperlinks']='color' + (other options switch hyperlink color off 'no-color' 'color-off' + 'monochrome') + * texpdf, pdf default font size configurable (cli & sisurc.yml) (no fractions) + * --pdf-fontsize-12 --pdf-fontsize-8 + * default: + texpdf_fontsize: 12 + * texpdf, headings and table of contents representation + * fixes 1~ and 2~ result in the same formatting + 1~ 2~ & 3~ now differentiated, see discussion in sisu.org under #744383 + * fixes :A smaller formatted than :B + A~ B~ C~ now the same size, see discussion in sisu.org under #744383 + * :B and :C result in the same formatting, issue explained see sisu.org + * texpdf, (internal coding) fontface, rename texpdf_font texpdf_fontface + * texpdf, (internal coding) use symbols to identify page orientation + * param, metadata rights, line-breaks instead of semicolons separating rights + * fixes remove trailing semicolon after :copyright: + * digests sha512 option implemented + * options sha512 sha256 md5 + * command line --sha512 + * rcconf.yml ['defsault']['digest'] = sha512 + * xml object citation numbering (docbook fictionbook) + %% 5.3.6.orig.tar.xz (2014-05-18:19/7) http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/sisu_5.3.6 http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/debian/sisu_5.3.6-1 diff --git a/data/doc/sisu/CHANGELOG_v6 b/data/doc/sisu/CHANGELOG_v6 index d58762a9..eef26941 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.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 +http://www.jus.uio.no/sisu/pkg/src/sisu_6.0.8.orig.tar.xz + sisu_6.0.8.orig.tar.xz + sisu_6.0.8-1.dsc + %% 6.0.7.orig.tar.xz (2014-05-25:20/7) http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/sisu_6.0.7 http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/debian/sisu_6.0.7-1 diff --git a/data/sisu/v5/v/version.yml b/data/sisu/v5/v/version.yml index 959947ba..ec9d1cde 100644 --- a/data/sisu/v5/v/version.yml +++ b/data/sisu/v5/v/version.yml @@ -1,5 +1,5 @@ --- :project: SiSU -:version: 5.4.0 -:date_stamp: 2014w20/7 -:date: "2014-05-25" +:version: 5.4.1 +:date_stamp: 2014w24/4 +:date: "2014-06-19" diff --git a/data/sisu/v6/v/version.yml b/data/sisu/v6/v/version.yml index 098c97b5..563a9713 100644 --- a/data/sisu/v6/v/version.yml +++ b/data/sisu/v6/v/version.yml @@ -1,5 +1,5 @@ --- :project: SiSU -:version: 6.0.7 -:date_stamp: 2014w20/7 -:date: "2014-05-25" +:version: 6.0.8 +:date_stamp: 2014w24/4 +:date: "2014-06-19" diff --git a/rbuild b/rbuild index 9ee18775..a5beb760 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.0' -SiSU_version_next_unstable = '6.0.7' +SiSU_version_next_stable = '5.4.1' +SiSU_version_next_unstable = '6.0.8' #% rake file SiSU_version_generic_next_stable = '5.4.x' SiSU_version_generic_next_unstable = '6.0.x' -- cgit v1.2.3 From 66b72eae1710087a38e41df6b9168acfe723cae9 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Thu, 19 Jun 2014 19:11:16 -0400 Subject: v5 v6: ao, misc, mostly minor cleaning --- data/doc/sisu/CHANGELOG_v5 | 2 + data/doc/sisu/CHANGELOG_v6 | 2 + lib/sisu/v5/ao.rb | 31 ++++++++----- lib/sisu/v5/ao_doc_objects.rb | 102 +++++++++++++++++++++--------------------- lib/sisu/v5/ao_doc_str.rb | 98 +++++++++++++++++++--------------------- lib/sisu/v5/ao_numbering.rb | 15 +++---- lib/sisu/v5/constants.rb | 5 ++- lib/sisu/v6/ao.rb | 31 ++++++++----- lib/sisu/v6/ao_doc_objects.rb | 102 +++++++++++++++++++++--------------------- lib/sisu/v6/ao_doc_str.rb | 98 +++++++++++++++++++--------------------- lib/sisu/v6/ao_numbering.rb | 15 +++---- lib/sisu/v6/constants.rb | 5 ++- 12 files changed, 260 insertions(+), 246 deletions(-) diff --git a/data/doc/sisu/CHANGELOG_v5 b/data/doc/sisu/CHANGELOG_v5 index 292d0c21..99f59534 100644 --- a/data/doc/sisu/CHANGELOG_v5 +++ b/data/doc/sisu/CHANGELOG_v5 @@ -38,6 +38,8 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_5.4.1.orig.tar.xz sisu_5.4.1.orig.tar.xz sisu_5.4.1-1.dsc +* ao, misc, minorish + %% 5.4.0.orig.tar.xz (2014-05-25:20/7) http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/sisu_5.4.0 http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/debian/sisu_5.4.0-1 diff --git a/data/doc/sisu/CHANGELOG_v6 b/data/doc/sisu/CHANGELOG_v6 index eef26941..645d482d 100644 --- a/data/doc/sisu/CHANGELOG_v6 +++ b/data/doc/sisu/CHANGELOG_v6 @@ -28,6 +28,8 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_6.0.8.orig.tar.xz sisu_6.0.8.orig.tar.xz sisu_6.0.8-1.dsc +* ao, misc, minorish + %% 6.0.7.orig.tar.xz (2014-05-25:20/7) http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/sisu_6.0.7 http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/debian/sisu_6.0.7-1 diff --git a/lib/sisu/v5/ao.rb b/lib/sisu/v5/ao.rb index 2a02ad63..c69e3be9 100644 --- a/lib/sisu/v5/ao.rb +++ b/lib/sisu/v5/ao.rb @@ -505,17 +505,26 @@ module SiSU_AO end def song reset - data=@data - data=SiSU_AO_Insertions::Insertions.new(@md,data).expand_insertions? # ao_expand_insertions.rb - data=SiSU_AO_MiscArrangeText::SI.new(@md,data).prepare_text # ao_misc_arrange.rb - data,metadata=SiSU_AO_DocumentStructureExtract::Build.new(@md,data).identify_parts # ao_doc_str.rb - data=SiSU_AO_Syntax::Markup.new(@md,data).songsheet # ao_syntax.rb - data,endnote_array=SiSU_AO_CharacterCheck::Check.new(data).character_check_and_oldstyle_endnote_array # ao_character_check.rb - data=SiSU_AO_Images::Images.new(@md,data).images # ao_images.rb - data,tags_map,ocn_html_seg_map=SiSU_AO_Numbering::Numbering.new(@md,data).numbering_song # ao_numbering.rb - data,book_index_rel,book_index_rel_html_seg,html_idx,xhtml_idx=SiSU_AO_BookIndex::BookIndex.new(@md,data,@env).indexing_song if @md.book_idx # ao_idx.rb - data=SiSU_AO_Endnotes::Endnotes.new(@md,data,endnote_array).endnotes # ao_endnotes.rb - outputdata=data + data_txt=@data + data_txt= + SiSU_AO_Insertions::Insertions.new(@md,data_txt).expand_insertions? # ao_expand_insertions.rb + 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 + 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 + 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 + data_obj= + SiSU_AO_Endnotes::Endnotes.new(@md,data_obj,endnote_array).endnotes # ao_endnotes.rb + outputdata=data_obj if (@md.opt.act[:ao][:set]==:on \ || @md.opt.act[:maintenance][:set]==:on) SiSU_AO::Output.new(@fn,@md,outputdata).hard_output diff --git a/lib/sisu/v5/ao_doc_objects.rb b/lib/sisu/v5/ao_doc_objects.rb index 216349c1..cd0d196c 100644 --- a/lib/sisu/v5/ao_doc_objects.rb +++ b/lib/sisu/v5/ao_doc_objects.rb @@ -74,8 +74,8 @@ module SiSU_AO_DocumentStructure @of=:meta end def metadata(tags) - of= @of #String, classification - group - is= :meta #String, classification - specific type + 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 @@ -89,8 +89,8 @@ module SiSU_AO_DocumentStructure @of=:meta end def metadata(h,o=nil) - of= @of #String, classification - group - is= :meta #String, classification - specific type + 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 @@ -142,8 +142,8 @@ module SiSU_AO_DocumentStructure and (h[:ln] and h[:ln].to_s=~/[0-9]/) h[:lv]=heading_lv(h[:ln]) end - of= @of #String, classification - group - is= :heading #String, classification - specific type + 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 @@ -191,8 +191,8 @@ module SiSU_AO_DocumentStructure @tags=[] end def paragraph(h,o=nil) - of= @of #String, classification - group - is= :para #String, classification - specific type + 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 @@ -247,8 +247,8 @@ module SiSU_AO_DocumentStructure @tags=[] end def code(h,o=nil) - of= @of #String, classification - group #alt 'code' - is= :code #String, classification - specific type + 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 idx= h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? @@ -268,8 +268,8 @@ module SiSU_AO_DocumentStructure self end def block(h,o=nil) - of= @of #String, classification - group - is= :block #String, classification - specific type + 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? @@ -288,8 +288,8 @@ module SiSU_AO_DocumentStructure self end def group(h,o=nil) - of= @of #String, classification - group - is= :group #String, classification - specific type + 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? @@ -308,8 +308,8 @@ module SiSU_AO_DocumentStructure self end def alt(h,o=nil) #see block - of= @of #String, classification - group - is= :alt #String, classification - specific type + 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? @@ -328,8 +328,8 @@ module SiSU_AO_DocumentStructure self end def verse(h,o=nil) #part of poem decide how you deal with this - of= @of #String, classification - group - is= :verse #String, classification - specific type + 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? @@ -349,15 +349,15 @@ module SiSU_AO_DocumentStructure end end class ObjectTable - attr_accessor :obj,:is,:of,:lv,:tags,:name,:idx,:indent,:hang,:size,:ocn,:number,:head_,:cols,:widths,:odv,:osp,:parent,:note_,:ocn_,:digest,:tmp + attr_accessor :obj,:is,:of,:lv,:tags,:name,:idx,:indent,:hang,:size,:ocn,:num,:head_,:cols,:widths,:odv,:osp,:parent,:note_,:ocn_,:digest,:tmp def initialize @of=:block - @is=@obj=@lv=@name=@idx=@indent=@hang=@size=@ocn,@number,@head_,@cols,@widths=@odv=@osp=@parent=@note_=@ocn_=@num=@digest=@tmp=nil + @is=@obj=@lv=@name=@idx=@indent=@hang=@size=@ocn,@num,@head_,@cols,@widths=@odv=@osp=@parent=@note_=@ocn_=@num=@digest=@tmp=nil @tags=[] end def table(h,o=nil) - of= @of #String, classification - group - is= :table #String, classification - specific type + 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) @@ -370,9 +370,9 @@ module SiSU_AO_DocumentStructure 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_] + else h[:ocn_] end - num= h[:num] || ((defined? o.num) ? o.num : nil) + 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 @@ -387,8 +387,8 @@ module SiSU_AO_DocumentStructure @tags=[] end def image(h,o=nil) #not yet used, and what of a paragraph containing several images, consider - of= @of #String, classification - group - is= :image #String, classification - specific type + of= @of #Symbol, classification - group + is= :image #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 size= h[:size] || ((defined? o.size) ? o.size : nil) @@ -414,8 +414,8 @@ module SiSU_AO_DocumentStructure @is=@obj=@node=@lv=@ln=@lc=@status=@tmp=nil end def xml_dom(h,o=nil) - of= @of #String, classification - group - is= :xml_dom #String, classification - specific type + of= @of #Symbol, classification - group + is= :xml_dom #Symbol, classification - specific type obj= h[:obj] || ((defined? o.obj) ? o.obj : '') #String, text content 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 @@ -427,21 +427,6 @@ module SiSU_AO_DocumentStructure self end end - class ObjectComment - attr_accessor :obj,:is,:of,:tmp - def initialize - @of=:comment - @is=@obj=@tmp=nil - end - def comment(h,o=nil) - of= @of #String, classification - group - is= :comment #String, classification - specific type - 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 - @of,@is,@obj,@tmp=of,is,obj,tmp - self - end - end class ObjectFlag attr_accessor :obj,:is,:of,:flag,:mod,:tmp def initialize @@ -449,8 +434,8 @@ module SiSU_AO_DocumentStructure @is=@obj=@flag=@mod=@tmp=nil end def flag(h,o=nil) - of= @of #String, classification - group - is= :flag #String, classification - specific type + of= @of #Symbol, classification - group + is= :flag #Symbol, classification - specific type obj= nil #String, text content flag= h[:flag] || ((defined? o.flag) ? o.flag : nil) #String, text content mod= h[:mod] || ((defined? o.mod) ? o.mod : nil) #String, text content @@ -459,8 +444,8 @@ module SiSU_AO_DocumentStructure self end def flag_ocn(h,o=nil) - of= @of #String, classification - group - is= :flag_ocn #String, classification - specific type + of= @of #Symbol, classification - group + is= :flag_ocn #Symbol, classification - specific type obj= nil #String, text content flag= h[:flag] || ((defined? o.flag) ? o.flag : nil) #String, text content mod= h[:mod] || ((defined? o.mod) ? o.mod : nil) #String, text content @@ -476,8 +461,8 @@ module SiSU_AO_DocumentStructure @is=@obj=@from=@tmp=nil end def break(h,f=nil) #decide how to deal with - of= @of #String, classification - group - is= :break #String, classification - specific type + of= @of #Symbol, classification - group + is= :break #Symbol, classification - specific type obj= h[:obj] #String, text content from= f tmp= h[:tmp] #available for processing, empty after use @@ -485,8 +470,23 @@ module SiSU_AO_DocumentStructure self end def insert(h,o=nil) #decide how to deal with, could mimic paragraph? - of= @of #String, classification - group - is= :insert #String, classification - specific type + of= @of #Symbol, classification - group + is= :insert #Symbol, classification - specific type + 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 + @of,@is,@obj,@tmp=of,is,obj,tmp + self + end + end + class ObjectComment + attr_accessor :obj,:is,:of,:tmp + def initialize + @of=:comment + @is=@obj=@tmp=nil + end + def comment(h,o=nil) + of= @of #Symbol, classification - group + is= :comment #Symbol, classification - specific type 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 @of,@is,@obj,@tmp=of,is,obj,tmp diff --git a/lib/sisu/v5/ao_doc_str.rb b/lib/sisu/v5/ao_doc_str.rb index b66f01d1..15d4aa9e 100644 --- a/lib/sisu/v5/ao_doc_str.rb +++ b/lib/sisu/v5/ao_doc_str.rb @@ -63,14 +63,14 @@ module SiSU_AO_DocumentStructureExtract class Instantiate < SiSU_Param::Parameters::Instructions @@flag={ - ocn: :on, - code: :off, - poem: :off, - block: :off, - group: :off, - alt: :off, - table: :off, - table_to: :off, + ocn: :on, + code: :off, + poem: :off, + block: :off, + group: :off, + alt: :off, + table: :off, + table_to: :off, } def initialize @@counter=@@column=@@columns=0 @@ -79,14 +79,14 @@ module SiSU_AO_DocumentStructureExtract end class Build @@flag={ - ocn: :on, - code: :off, - poem: :off, - block: :off, - group: :off, - alt: :off, - table: :off, - table_to: :off, + ocn: :on, + code: :off, + poem: :off, + block: :off, + group: :off, + alt: :off, + table: :off, + table_to: :off, } def initialize(md,data) @md,@data=md,data @@ -516,7 +516,7 @@ 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_table } + h={ head_: hd, cols: cols, widths: col, obj: rows, idx: idx, tags: tags, num: @num_table } t_o=SiSU_AO_DocumentStructure::ObjectTable.new.table(h) unless h.nil? tuned_file << t_o h={ obj: "table end #{@num_table}" } @@ -539,7 +539,7 @@ module SiSU_AO_DocumentStructureExtract r=r.gsub(/\s*\|\s*/m,"#{Mx[:tc_p]}") #r.gsub!(/\|/m,"#{Mx[:tc_p]}") rows += r + Mx[:tc_c] end - h={ head_: hd, cols: col.length, widths: col, obj: rows, idx: idx, tags: tags, num: @num_table } + h={ head_: hd, cols: col.length, widths: col, obj: rows, idx: idx, tags: tags, num: @num_table } t_o=SiSU_AO_DocumentStructure::ObjectTable.new.table(h) unless h.nil? tuned_file << t_o h={ obj: "table end #{@num_table}" } @@ -1231,7 +1231,7 @@ SKIPPED processing file: [#{@md.opt.lng}] "#{@md.fns}"} || dob.is==:alt \ || dob.is==:group \ || dob.is==:block - dob.obj=dob.obj.gsub(/\n\n/,"\n") #newlines taken out + dob.obj=dob.obj.gsub(/\n+/,"\n") #newlines taken out end @o_array << dob end @@ -1255,19 +1255,13 @@ SKIPPED processing file: [#{@md.opt.lng}] "#{@md.fns}"} @data,@md=data,md end def dom - @s=[ - 'A', - 'B', - 'C', - 'D', - '1', - '2', - '3' - ] - @sp=' ' + @s=[ 'A', 'B', 'C', 'D', '1', '2', '3' ] tuned_file=structure_build tuned_file end + def spaces + Ax[:spaces] + end def structure_build data=@data tuned_file=[] @@ -1498,45 +1492,45 @@ SKIPPED processing file: [#{@md.opt.lng}] "#{@md.fns}"} ary end def puts_tag_open(o,tag) - puts %{#{@sp*o.ln}<#{tag[o.ln]} id="#{o.node}">} + puts %{#{spaces*o.ln}<#{tag[o.ln]} id="#{o.node}">} end def puts_tag_close(lev,hs) case hs[0] when 0 - #puts "#{@sp*0}" if (lev <= 0) and hs[0] + #puts "#{spaces*0}" if (lev <= 0) and hs[0] puts "" if (lev==0) when 1 - puts "#{@sp*1}" if (lev <= 1) and hs[1] + puts "#{spaces*1}" if (lev <= 1) and hs[1] puts "" if (lev==0) when 2 - puts "#{@sp*2}" if (lev <= 2) and hs[2] - puts "#{@sp*1}" if (lev <= 1) and hs[1] + puts "#{spaces*2}" if (lev <= 2) and hs[2] + puts "#{spaces*1}" if (lev <= 1) and hs[1] puts "" if (lev==0) when 3 - puts "#{@sp*3}" if (lev <= 3) and hs[3] - puts "#{@sp*2}" if (lev <= 2) and hs[2] - puts "#{@sp*1}" if (lev <= 1) and hs[1] + puts "#{spaces*3}" if (lev <= 3) and hs[3] + puts "#{spaces*2}" if (lev <= 2) and hs[2] + puts "#{spaces*1}" if (lev <= 1) and hs[1] puts "" if (lev==0) when 4 - puts "#{@sp*4}" if (lev <= 4) - puts "#{@sp*3}" if (lev <= 3) and hs[3] - puts "#{@sp*2}" if (lev <= 2) and hs[2] - puts "#{@sp*1}" if (lev <= 1) and hs[1] + puts "#{spaces*4}" if (lev <= 4) + puts "#{spaces*3}" if (lev <= 3) and hs[3] + puts "#{spaces*2}" if (lev <= 2) and hs[2] + puts "#{spaces*1}" if (lev <= 1) and hs[1] puts "" if (lev==0) when 5 - puts "#{@sp*5}" if (lev <= 5) - puts "#{@sp*4}" if (lev <= 4) - puts "#{@sp*3}" if (lev <= 3) and hs[3] - puts "#{@sp*2}" if (lev <= 2) and hs[2] - puts "#{@sp*1}" if (lev <= 1) and hs[1] + puts "#{spaces*5}" if (lev <= 5) + puts "#{spaces*4}" if (lev <= 4) + puts "#{spaces*3}" if (lev <= 3) and hs[3] + puts "#{spaces*2}" if (lev <= 2) and hs[2] + puts "#{spaces*1}" if (lev <= 1) and hs[1] puts "" if (lev==0) when 6 - puts "#{@sp*6}" if (lev <= 6) - puts "#{@sp*5}" if (lev <= 5) - puts "#{@sp*4}" if (lev <= 4) - puts "#{@sp*3}" if (lev <= 3) and hs[3] - puts "#{@sp*2}" if (lev <= 2) and hs[2] - puts "#{@sp*1}" if (lev <= 1) and hs[1] + puts "#{spaces*6}" if (lev <= 6) + puts "#{spaces*5}" if (lev <= 5) + puts "#{spaces*4}" if (lev <= 4) + puts "#{spaces*3}" if (lev <= 3) and hs[3] + puts "#{spaces*2}" if (lev <= 2) and hs[2] + puts "#{spaces*1}" if (lev <= 1) and hs[1] puts "" if (lev==0) end end diff --git a/lib/sisu/v5/ao_numbering.rb b/lib/sisu/v5/ao_numbering.rb index 7affbe93..a143abeb 100644 --- a/lib/sisu/v5/ao_numbering.rb +++ b/lib/sisu/v5/ao_numbering.rb @@ -286,7 +286,7 @@ module SiSU_AO_Numbering # numeric only (a number), if # all segments have been named, # the numbers used are over 1000 or - # it is not minded that auto-numbering uses a funny scheme for naming segments (not yet implemented) + # it is not minded that auto-numbering uses a funny scheme for naming segments (not yet implemented) # [for now a warning is printed for such documents on use of maintenance or very-verbose flag] # auto-naming takes the form of giving numbers to segments # the rules for which are as follows @@ -381,13 +381,11 @@ 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]/ - { seg: nil, level: dob.ln } - else #elsif dob.ln =~/[4-6]/ - { seg: @seg, level: dob.ln } + if dob.ln =~/[0-3]/ then { seg: nil, level: dob.ln } + #elsif dob.ln =~/[4-6]/ + 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 @@ -406,7 +404,8 @@ module SiSU_AO_Numbering if ocn \ and ocn[:level].to_s=~/[1-3]/ (1..4).each do |x| - if ocn_html_seg[i+x] and ocn_html_seg[i+x][:level]==4 + if ocn_html_seg[i+x] \ + and ocn_html_seg[i+x][:level]==4 ocn[:seg]=ocn_html_seg[i+x][:seg] end end diff --git a/lib/sisu/v5/constants.rb b/lib/sisu/v5/constants.rb index 748051b6..42ab53a3 100644 --- a/lib/sisu/v5/constants.rb +++ b/lib/sisu/v5/constants.rb @@ -92,9 +92,12 @@ Sfx={ } Ax={ tab: "\t", + comment: '%', + spaces: ' ', } Xx={ protect: '☞', + split: '✠', segment: 'Ф', relative_path: '☼', html_relative2: '※※', @@ -348,7 +351,7 @@ check:  · ¤ - #˝ " λ Ω β α π Ѫ Ж Я Ѳ ѳ Ф ㈣ + #˝ " λ Ω β α π Ѫ Ж Я Ѳ ѳ Ф ✠ ㈣ Ѳ ѳ Ф ♩ ♭  ✠  ▭ ▬ ▪ 【】〖〗◢ ◣ ◀ ▶ ◘ ◙ diff --git a/lib/sisu/v6/ao.rb b/lib/sisu/v6/ao.rb index 6f7b1ac8..064436ae 100644 --- a/lib/sisu/v6/ao.rb +++ b/lib/sisu/v6/ao.rb @@ -505,17 +505,26 @@ module SiSU_AO end def song reset - data=@data - data=SiSU_AO_Insertions::Insertions.new(@md,data).expand_insertions? # ao_expand_insertions.rb - data=SiSU_AO_MiscArrangeText::SI.new(@md,data).prepare_text # ao_misc_arrange.rb - data,metadata=SiSU_AO_DocumentStructureExtract::Build.new(@md,data).identify_parts # ao_doc_str.rb - data=SiSU_AO_Syntax::Markup.new(@md,data).songsheet # ao_syntax.rb - data,endnote_array=SiSU_AO_CharacterCheck::Check.new(data).character_check_and_oldstyle_endnote_array # ao_character_check.rb - data=SiSU_AO_Images::Images.new(@md,data).images # ao_images.rb - data,tags_map,ocn_html_seg_map=SiSU_AO_Numbering::Numbering.new(@md,data).numbering_song # ao_numbering.rb - data,book_index_rel,book_index_rel_html_seg,html_idx,xhtml_idx=SiSU_AO_BookIndex::BookIndex.new(@md,data,@env).indexing_song if @md.book_idx # ao_idx.rb - data=SiSU_AO_Endnotes::Endnotes.new(@md,data,endnote_array).endnotes # ao_endnotes.rb - outputdata=data + data_txt=@data + data_txt= + SiSU_AO_Insertions::Insertions.new(@md,data_txt).expand_insertions? # ao_expand_insertions.rb + 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 + 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 + 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 + data_obj= + SiSU_AO_Endnotes::Endnotes.new(@md,data_obj,endnote_array).endnotes # ao_endnotes.rb + outputdata=data_obj if (@md.opt.act[:ao][:set]==:on \ || @md.opt.act[:maintenance][:set]==:on) SiSU_AO::Output.new(@fn,@md,outputdata).hard_output diff --git a/lib/sisu/v6/ao_doc_objects.rb b/lib/sisu/v6/ao_doc_objects.rb index 9555ab5e..972a8392 100644 --- a/lib/sisu/v6/ao_doc_objects.rb +++ b/lib/sisu/v6/ao_doc_objects.rb @@ -74,8 +74,8 @@ module SiSU_AO_DocumentStructure @of=:meta end def metadata(tags) - of= @of #String, classification - group - is= :meta #String, classification - specific type + 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 @@ -89,8 +89,8 @@ module SiSU_AO_DocumentStructure @of=:meta end def metadata(h,o=nil) - of= @of #String, classification - group - is= :meta #String, classification - specific type + 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 @@ -142,8 +142,8 @@ module SiSU_AO_DocumentStructure and (h[:ln] and h[:ln].to_s=~/[0-9]/) h[:lv]=heading_lv(h[:ln]) end - of= @of #String, classification - group - is= :heading #String, classification - specific type + 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 @@ -191,8 +191,8 @@ module SiSU_AO_DocumentStructure @tags=[] end def paragraph(h,o=nil) - of= @of #String, classification - group - is= :para #String, classification - specific type + 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 @@ -247,8 +247,8 @@ module SiSU_AO_DocumentStructure @tags=[] end def code(h,o=nil) - of= @of #String, classification - group #alt 'code' - is= :code #String, classification - specific type + 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 idx= h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? @@ -268,8 +268,8 @@ module SiSU_AO_DocumentStructure self end def block(h,o=nil) - of= @of #String, classification - group - is= :block #String, classification - specific type + 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? @@ -288,8 +288,8 @@ module SiSU_AO_DocumentStructure self end def group(h,o=nil) - of= @of #String, classification - group - is= :group #String, classification - specific type + 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? @@ -308,8 +308,8 @@ module SiSU_AO_DocumentStructure self end def alt(h,o=nil) #see block - of= @of #String, classification - group - is= :alt #String, classification - specific type + 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? @@ -328,8 +328,8 @@ module SiSU_AO_DocumentStructure self end def verse(h,o=nil) #part of poem decide how you deal with this - of= @of #String, classification - group - is= :verse #String, classification - specific type + 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? @@ -349,15 +349,15 @@ module SiSU_AO_DocumentStructure end end class ObjectTable - attr_accessor :obj,:is,:of,:lv,:tags,:name,:idx,:indent,:hang,:size,:ocn,:number,:head_,:cols,:widths,:odv,:osp,:parent,:note_,:ocn_,:digest,:tmp + attr_accessor :obj,:is,:of,:lv,:tags,:name,:idx,:indent,:hang,:size,:ocn,:num,:head_,:cols,:widths,:odv,:osp,:parent,:note_,:ocn_,:digest,:tmp def initialize @of=:block - @is=@obj=@lv=@name=@idx=@indent=@hang=@size=@ocn,@number,@head_,@cols,@widths=@odv=@osp=@parent=@note_=@ocn_=@num=@digest=@tmp=nil + @is=@obj=@lv=@name=@idx=@indent=@hang=@size=@ocn,@num,@head_,@cols,@widths=@odv=@osp=@parent=@note_=@ocn_=@num=@digest=@tmp=nil @tags=[] end def table(h,o=nil) - of= @of #String, classification - group - is= :table #String, classification - specific type + 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) @@ -370,9 +370,9 @@ module SiSU_AO_DocumentStructure 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_] + else h[:ocn_] end - num= h[:num] || ((defined? o.num) ? o.num : nil) + 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 @@ -387,8 +387,8 @@ module SiSU_AO_DocumentStructure @tags=[] end def image(h,o=nil) #not yet used, and what of a paragraph containing several images, consider - of= @of #String, classification - group - is= :image #String, classification - specific type + of= @of #Symbol, classification - group + is= :image #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 size= h[:size] || ((defined? o.size) ? o.size : nil) @@ -414,8 +414,8 @@ module SiSU_AO_DocumentStructure @is=@obj=@node=@lv=@ln=@lc=@status=@tmp=nil end def xml_dom(h,o=nil) - of= @of #String, classification - group - is= :xml_dom #String, classification - specific type + of= @of #Symbol, classification - group + is= :xml_dom #Symbol, classification - specific type obj= h[:obj] || ((defined? o.obj) ? o.obj : '') #String, text content 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 @@ -427,21 +427,6 @@ module SiSU_AO_DocumentStructure self end end - class ObjectComment - attr_accessor :obj,:is,:of,:tmp - def initialize - @of=:comment - @is=@obj=@tmp=nil - end - def comment(h,o=nil) - of= @of #String, classification - group - is= :comment #String, classification - specific type - 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 - @of,@is,@obj,@tmp=of,is,obj,tmp - self - end - end class ObjectFlag attr_accessor :obj,:is,:of,:flag,:mod,:tmp def initialize @@ -449,8 +434,8 @@ module SiSU_AO_DocumentStructure @is=@obj=@flag=@mod=@tmp=nil end def flag(h,o=nil) - of= @of #String, classification - group - is= :flag #String, classification - specific type + of= @of #Symbol, classification - group + is= :flag #Symbol, classification - specific type obj= nil #String, text content flag= h[:flag] || ((defined? o.flag) ? o.flag : nil) #String, text content mod= h[:mod] || ((defined? o.mod) ? o.mod : nil) #String, text content @@ -459,8 +444,8 @@ module SiSU_AO_DocumentStructure self end def flag_ocn(h,o=nil) - of= @of #String, classification - group - is= :flag_ocn #String, classification - specific type + of= @of #Symbol, classification - group + is= :flag_ocn #Symbol, classification - specific type obj= nil #String, text content flag= h[:flag] || ((defined? o.flag) ? o.flag : nil) #String, text content mod= h[:mod] || ((defined? o.mod) ? o.mod : nil) #String, text content @@ -476,8 +461,8 @@ module SiSU_AO_DocumentStructure @is=@obj=@from=@tmp=nil end def break(h,f=nil) #decide how to deal with - of= @of #String, classification - group - is= :break #String, classification - specific type + of= @of #Symbol, classification - group + is= :break #Symbol, classification - specific type obj= h[:obj] #String, text content from= f tmp= h[:tmp] #available for processing, empty after use @@ -485,8 +470,23 @@ module SiSU_AO_DocumentStructure self end def insert(h,o=nil) #decide how to deal with, could mimic paragraph? - of= @of #String, classification - group - is= :insert #String, classification - specific type + of= @of #Symbol, classification - group + is= :insert #Symbol, classification - specific type + 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 + @of,@is,@obj,@tmp=of,is,obj,tmp + self + end + end + class ObjectComment + attr_accessor :obj,:is,:of,:tmp + def initialize + @of=:comment + @is=@obj=@tmp=nil + end + def comment(h,o=nil) + of= @of #Symbol, classification - group + is= :comment #Symbol, classification - specific type 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 @of,@is,@obj,@tmp=of,is,obj,tmp diff --git a/lib/sisu/v6/ao_doc_str.rb b/lib/sisu/v6/ao_doc_str.rb index d060d89c..846a7027 100644 --- a/lib/sisu/v6/ao_doc_str.rb +++ b/lib/sisu/v6/ao_doc_str.rb @@ -63,14 +63,14 @@ module SiSU_AO_DocumentStructureExtract class Instantiate < SiSU_Param::Parameters::Instructions @@flag={ - ocn: :on, - code: :off, - poem: :off, - block: :off, - group: :off, - alt: :off, - table: :off, - table_to: :off, + ocn: :on, + code: :off, + poem: :off, + block: :off, + group: :off, + alt: :off, + table: :off, + table_to: :off, } def initialize @@counter=@@column=@@columns=0 @@ -79,14 +79,14 @@ module SiSU_AO_DocumentStructureExtract end class Build @@flag={ - ocn: :on, - code: :off, - poem: :off, - block: :off, - group: :off, - alt: :off, - table: :off, - table_to: :off, + ocn: :on, + code: :off, + poem: :off, + block: :off, + group: :off, + alt: :off, + table: :off, + table_to: :off, } def initialize(md,data) @md,@data=md,data @@ -516,7 +516,7 @@ 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_table } + h={ head_: hd, cols: cols, widths: col, obj: rows, idx: idx, tags: tags, num: @num_table } t_o=SiSU_AO_DocumentStructure::ObjectTable.new.table(h) unless h.nil? tuned_file << t_o h={ obj: "table end #{@num_table}" } @@ -539,7 +539,7 @@ module SiSU_AO_DocumentStructureExtract r=r.gsub(/\s*\|\s*/m,"#{Mx[:tc_p]}") #r.gsub!(/\|/m,"#{Mx[:tc_p]}") rows += r + Mx[:tc_c] end - h={ head_: hd, cols: col.length, widths: col, obj: rows, idx: idx, tags: tags, num: @num_table } + h={ head_: hd, cols: col.length, widths: col, obj: rows, idx: idx, tags: tags, num: @num_table } t_o=SiSU_AO_DocumentStructure::ObjectTable.new.table(h) unless h.nil? tuned_file << t_o h={ obj: "table end #{@num_table}" } @@ -1231,7 +1231,7 @@ SKIPPED processing file: [#{@md.opt.lng}] "#{@md.fns}"} || dob.is==:alt \ || dob.is==:group \ || dob.is==:block - dob.obj=dob.obj.gsub(/\n\n/,"\n") #newlines taken out + dob.obj=dob.obj.gsub(/\n+/,"\n") #newlines taken out end @o_array << dob end @@ -1255,19 +1255,13 @@ SKIPPED processing file: [#{@md.opt.lng}] "#{@md.fns}"} @data,@md=data,md end def dom - @s=[ - 'A', - 'B', - 'C', - 'D', - '1', - '2', - '3' - ] - @sp=' ' + @s=[ 'A', 'B', 'C', 'D', '1', '2', '3' ] tuned_file=structure_build tuned_file end + def spaces + Ax[:spaces] + end def structure_build data=@data tuned_file=[] @@ -1498,45 +1492,45 @@ SKIPPED processing file: [#{@md.opt.lng}] "#{@md.fns}"} ary end def puts_tag_open(o,tag) - puts %{#{@sp*o.ln}<#{tag[o.ln]} id="#{o.node}">} + puts %{#{spaces*o.ln}<#{tag[o.ln]} id="#{o.node}">} end def puts_tag_close(lev,hs) case hs[0] when 0 - #puts "#{@sp*0}" if (lev <= 0) and hs[0] + #puts "#{spaces*0}" if (lev <= 0) and hs[0] puts "" if (lev==0) when 1 - puts "#{@sp*1}" if (lev <= 1) and hs[1] + puts "#{spaces*1}" if (lev <= 1) and hs[1] puts "" if (lev==0) when 2 - puts "#{@sp*2}" if (lev <= 2) and hs[2] - puts "#{@sp*1}" if (lev <= 1) and hs[1] + puts "#{spaces*2}" if (lev <= 2) and hs[2] + puts "#{spaces*1}" if (lev <= 1) and hs[1] puts "" if (lev==0) when 3 - puts "#{@sp*3}" if (lev <= 3) and hs[3] - puts "#{@sp*2}" if (lev <= 2) and hs[2] - puts "#{@sp*1}" if (lev <= 1) and hs[1] + puts "#{spaces*3}" if (lev <= 3) and hs[3] + puts "#{spaces*2}" if (lev <= 2) and hs[2] + puts "#{spaces*1}" if (lev <= 1) and hs[1] puts "" if (lev==0) when 4 - puts "#{@sp*4}" if (lev <= 4) - puts "#{@sp*3}" if (lev <= 3) and hs[3] - puts "#{@sp*2}" if (lev <= 2) and hs[2] - puts "#{@sp*1}" if (lev <= 1) and hs[1] + puts "#{spaces*4}" if (lev <= 4) + puts "#{spaces*3}" if (lev <= 3) and hs[3] + puts "#{spaces*2}" if (lev <= 2) and hs[2] + puts "#{spaces*1}" if (lev <= 1) and hs[1] puts "" if (lev==0) when 5 - puts "#{@sp*5}" if (lev <= 5) - puts "#{@sp*4}" if (lev <= 4) - puts "#{@sp*3}" if (lev <= 3) and hs[3] - puts "#{@sp*2}" if (lev <= 2) and hs[2] - puts "#{@sp*1}" if (lev <= 1) and hs[1] + puts "#{spaces*5}" if (lev <= 5) + puts "#{spaces*4}" if (lev <= 4) + puts "#{spaces*3}" if (lev <= 3) and hs[3] + puts "#{spaces*2}" if (lev <= 2) and hs[2] + puts "#{spaces*1}" if (lev <= 1) and hs[1] puts "" if (lev==0) when 6 - puts "#{@sp*6}" if (lev <= 6) - puts "#{@sp*5}" if (lev <= 5) - puts "#{@sp*4}" if (lev <= 4) - puts "#{@sp*3}" if (lev <= 3) and hs[3] - puts "#{@sp*2}" if (lev <= 2) and hs[2] - puts "#{@sp*1}" if (lev <= 1) and hs[1] + puts "#{spaces*6}" if (lev <= 6) + puts "#{spaces*5}" if (lev <= 5) + puts "#{spaces*4}" if (lev <= 4) + puts "#{spaces*3}" if (lev <= 3) and hs[3] + puts "#{spaces*2}" if (lev <= 2) and hs[2] + puts "#{spaces*1}" if (lev <= 1) and hs[1] puts "" if (lev==0) end end diff --git a/lib/sisu/v6/ao_numbering.rb b/lib/sisu/v6/ao_numbering.rb index e04befb0..0dbb1a71 100644 --- a/lib/sisu/v6/ao_numbering.rb +++ b/lib/sisu/v6/ao_numbering.rb @@ -286,7 +286,7 @@ module SiSU_AO_Numbering # numeric only (a number), if # all segments have been named, # the numbers used are over 1000 or - # it is not minded that auto-numbering uses a funny scheme for naming segments (not yet implemented) + # it is not minded that auto-numbering uses a funny scheme for naming segments (not yet implemented) # [for now a warning is printed for such documents on use of maintenance or very-verbose flag] # auto-naming takes the form of giving numbers to segments # the rules for which are as follows @@ -381,13 +381,11 @@ 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]/ - { seg: nil, level: dob.ln } - else #elsif dob.ln =~/[4-6]/ - { seg: @seg, level: dob.ln } + if dob.ln =~/[0-3]/ then { seg: nil, level: dob.ln } + #elsif dob.ln =~/[4-6]/ + 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 @@ -406,7 +404,8 @@ module SiSU_AO_Numbering if ocn \ and ocn[:level].to_s=~/[1-3]/ (1..4).each do |x| - if ocn_html_seg[i+x] and ocn_html_seg[i+x][:level]==4 + if ocn_html_seg[i+x] \ + and ocn_html_seg[i+x][:level]==4 ocn[:seg]=ocn_html_seg[i+x][:seg] end end diff --git a/lib/sisu/v6/constants.rb b/lib/sisu/v6/constants.rb index be60431e..43fff554 100644 --- a/lib/sisu/v6/constants.rb +++ b/lib/sisu/v6/constants.rb @@ -92,9 +92,12 @@ Sfx={ } Ax={ tab: "\t", + comment: '%', + spaces: ' ', } Xx={ protect: '☞', + split: '✠', segment: 'Ф', relative_path: '☼', html_relative2: '※※', @@ -348,7 +351,7 @@ check:  · ¤ - #˝ " λ Ω β α π Ѫ Ж Я Ѳ ѳ Ф ㈣ + #˝ " λ Ω β α π Ѫ Ж Я Ѳ ѳ Ф ✠ ㈣ Ѳ ѳ Ф ♩ ♭  ✠  ▭ ▬ ▪ 【】〖〗◢ ◣ ◀ ▶ ◘ ◙ -- cgit v1.2.3 From 83137da0f259e8366eba7f626319b5a5b9b27d6d Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Thu, 19 Jun 2014 19:17:23 -0400 Subject: v5 v6: indent spaces, minor --- lib/sisu/v5/digests.rb | 17 +++--- lib/sisu/v5/harvest_topics.rb | 77 +++++++++++++------------ lib/sisu/v5/qrcode.rb | 8 ++- lib/sisu/v5/xml_docbook5.rb | 74 ++++++++++++------------ lib/sisu/v5/xml_fictionbook2.rb | 68 +++++++++++----------- lib/sisu/v5/xml_scaffold_structure_collapsed.rb | 53 ++++++++--------- lib/sisu/v5/xml_scaffold_structure_sisu.rb | 55 +++++++++--------- lib/sisu/v6/digests.rb | 17 +++--- lib/sisu/v6/harvest_topics.rb | 77 +++++++++++++------------ lib/sisu/v6/qrcode.rb | 8 ++- lib/sisu/v6/xml_docbook5.rb | 74 ++++++++++++------------ lib/sisu/v6/xml_fictionbook2.rb | 68 +++++++++++----------- lib/sisu/v6/xml_scaffold_structure_collapsed.rb | 53 ++++++++--------- lib/sisu/v6/xml_scaffold_structure_sisu.rb | 55 +++++++++--------- 14 files changed, 364 insertions(+), 340 deletions(-) diff --git a/lib/sisu/v5/digests.rb b/lib/sisu/v5/digests.rb index 6cea7c3e..06851739 100644 --- a/lib/sisu/v5/digests.rb +++ b/lib/sisu/v5/digests.rb @@ -134,6 +134,9 @@ module SiSU_DigestView supplementary output end + def spaces + Ax[:spaces] + end def description(f,e='') puts f + e.to_s if @md.opt.act[:verbose_plus][:set]==:on @@description << f << e @@ -234,19 +237,19 @@ module SiSU_DigestView if t_o.is==:heading x=case t_o.ln when 0 then l[0] +=1 - ' '*0 << ':A' + spaces*0 << ':A' when 1 then l[1] +=1 - ' '*1 << ':B' + spaces*1 << ':B' when 2 then l[2] +=1 - ' '*2 << ':C' + spaces*2 << ':C' when 3 then l[3] +=1 - ' '*3 << ':D' + spaces*3 << ':D' when 4 then l[4] +=1 - ' '*4 << '1' + spaces*4 << '1' when 5 then l[5] +=1 - ' '*5 << '2' + spaces*5 << '2' when 6 then l[6] +=1 - ' '*6 << '3' + spaces*6 << '3' else nil end end diff --git a/lib/sisu/v5/harvest_topics.rb b/lib/sisu/v5/harvest_topics.rb index aeca5246..09739200 100644 --- a/lib/sisu/v5/harvest_topics.rb +++ b/lib/sisu/v5/harvest_topics.rb @@ -97,6 +97,11 @@ module SiSU_HarvestTopics SiSU_HarvestTopics::OutputIndex.new(@opt,the_hash).html_print.html_songsheet end end + class Mix + def spaces + Ax[:spaces] + end + end class Harvest def initialize(opt,env,data,filename,name,idx_array,lang) @opt,@env,@data,@filename,@name,@idx_array,@lang=opt,env,data,filename,name,idx_array,lang @@ -160,7 +165,7 @@ module SiSU_HarvestTopics idx_array end end - class Index + class Index < Mix def initialize(opt,env,idx_array,the_idx) @opt,@env,@idx_array,@the_idx=opt,env,idx_array,the_idx @@the_idx_topics=@the_idx @@ -313,7 +318,7 @@ module SiSU_HarvestTopics else @the_h[x0] ||={} end - #puts ' '*0 + x0 + #puts spaces*0 + x0 if extract >= 1 y0.each_pair do |x1,y1| if extract == 1 @@ -322,7 +327,7 @@ module SiSU_HarvestTopics else @the_h[x0][x1] ||={} end - #puts ' '*1 + x1 + #puts spaces*1 + x1 if extract >= 2 y1.each_pair do |x2,y2| if extract == 2 @@ -331,7 +336,7 @@ module SiSU_HarvestTopics else @the_h[x0][x1][x2] ||={} end - #puts ' '*2 + x2 + #puts spaces*2 + x2 if extract >= 3 y2.each_pair do |x3,y3| if extract == 3 @@ -340,7 +345,7 @@ module SiSU_HarvestTopics else @the_h[x0][x1][x2][x3] ||={} end - #puts ' '*3 + x3 + #puts spaces*3 + x3 if extract == 4 y3.each_pair do |x4,y4| if extract == 4 @@ -349,14 +354,14 @@ module SiSU_HarvestTopics else @the_h[x0][x1][x2][x3][x4] ||={} end - #puts ' '*4 + x4 + #puts spaces*4 + x4 if extract == 5 y4.each_pair do |x5,y5| if extract == 5 @the_h[x0][x1][x2][x3][x4][x5] ||={ md: [] } @the_h[x0][x1][x2][x3][x4][x5][:md] << y5 end - #puts ' '*5 + x5 + #puts spaces*5 + x5 end end end @@ -375,22 +380,22 @@ module SiSU_HarvestTopics end def traverse_base @the_h.each_pair do |x0,y0| - puts ' '*0 + x0 if x0.is_a?(String) + puts spaces*0 + x0 if x0.is_a?(String) if y0.is_a?(Hash) y0.each_pair do |x1,y1| - puts ' '*1 + x1 if x1.is_a?(String) + puts spaces*1 + x1 if x1.is_a?(String) if y1.is_a?(Hash) y1.each_pair do |x2,y2| - puts ' '*2 + x2 if x2.is_a?(String) + puts spaces*2 + x2 if x2.is_a?(String) if y2.is_a?(Hash) y2.each_pair do |x3,y3| - puts ' '*3 + x3 if x3.is_a?(String) + puts spaces*3 + x3 if x3.is_a?(String) if y3.is_a?(Hash) y3.each_pair do |x4,y4| - puts ' '*4 + x4 if x4.is_a?(String) + puts spaces*4 + x4 if x4.is_a?(String) if y4.is_a?(Hash) y4.each_pair do |x5,y5| - puts ' '*5 + x5 if x5.is_a?(String) + puts spaces*5 + x5 if x5.is_a?(String) end end end @@ -405,37 +410,37 @@ module SiSU_HarvestTopics end def traverse @the_h.each_pair do |x0,y0| - puts ' '*0 + x0 if x0.is_a?(String) + puts spaces*0 + x0 if x0.is_a?(String) if y0.is_a?(Hash) if y0.has_key?(:md) - y0[:md].each { |x| puts ' '*5 + x[:title] } + y0[:md].each { |x| puts spaces*5 + x[:title] } end y0.each_pair do |x1,y1| - puts ' '*1 + x1 if x1.is_a?(String) + puts spaces*1 + x1 if x1.is_a?(String) if y1.is_a?(Hash) if y1.has_key?(:md) - y1[:md].each { |x| puts ' '*5 + x[:title] } + y1[:md].each { |x| puts spaces*5 + x[:title] } end y1.each_pair do |x2,y2| - puts ' '*2 + x2 if x2.is_a?(String) + puts spaces*2 + x2 if x2.is_a?(String) if y2.is_a?(Hash) if y2.has_key?(:md) - y2[:md].each { |x| puts ' '*5 + x[:title] } + y2[:md].each { |x| puts spaces*5 + x[:title] } end y2.each_pair do |x3,y3| - puts ' '*3 + x3 if x3.is_a?(String) + puts spaces*3 + x3 if x3.is_a?(String) if y3.is_a?(Hash) if y3.has_key?(:md) - y3[:md].each { |x| puts ' '*5 + x[:title] } + y3[:md].each { |x| puts spaces*5 + x[:title] } end y3.each_pair do |x4,y4| - puts ' '*4 + x4 if x4.is_a?(String) + puts spaces*4 + x4 if x4.is_a?(String) if y4.is_a?(Hash) if y4.has_key?(:md) - y4[:md].each { |x| puts ' '*5 + x[:title] } + y4[:md].each { |x| puts spaces*5 + x[:title] } end y4.each_pair do |x5,y5| - puts ' '*5 + x4 if x4.is_a?(String) + puts spaces*5 + x4 if x4.is_a?(String) end end end @@ -449,7 +454,7 @@ module SiSU_HarvestTopics end end end - class OutputIndex + class OutputIndex < Mix require_relative 'i18n' # i18n.rb def initialize(opt,the_idx) @opt,@the_idx=opt,the_idx @@ -509,67 +514,67 @@ module SiSU_HarvestTopics lng=x0 if x0.is_a?(String) #do_string_name(lng,'lev0',x0) - #puts ' '*0 + x0 + #puts spaces*0 + x0 end if y0.is_a?(Hash) if y0.has_key?(:md) y0[:md].each do |x| #do_hash(lng,attrib,x) #lv==0 ? - #puts ' '*5 + x[:title] + #puts spaces*5 + x[:title] end end y0.each_pair do |x1,y1| if x1.is_a?(String) do_string_name(lng,'lev0',x1) - #puts ' '*1 + x1 + #puts spaces*1 + x1 end if y1.is_a?(Hash) if y1.has_key?(:md) y1[:md].each do |x| do_hash(lng,0,x) - #puts ' '*5 + x[:title] + #puts spaces*5 + x[:title] end end y1.each_pair do |x2,y2| if x2.is_a?(String) do_string(lng,'lev1',x2) - #puts ' '*2 + x2 + #puts spaces*2 + x2 end if y2.is_a?(Hash) if y2.has_key?(:md) y2[:md].each do |x| do_hash(lng,1,x) - #puts ' '*5 + x[:title] + #puts spaces*5 + x[:title] end end y2.each_pair do |x3,y3| if x3.is_a?(String) do_string(lng,'lev2',x3) - #puts ' '*3 + x3 + #puts spaces*3 + x3 end if y3.is_a?(Hash) if y3.has_key?(:md) y3[:md].each do |x| do_hash(lng,2,x) - #puts ' '*5 + x[:title] + #puts spaces*5 + x[:title] end end y3.each_pair do |x4,y4| if x4.is_a?(String) do_string(lng,'lev3',x4) - #puts ' '*4 + x4 + #puts spaces*4 + x4 end if y4.is_a?(Hash) if y4.has_key?(:md) y4[:md].each do |x| do_hash(lng,3,x) - #puts ' '*5 + x[:title] + #puts spaces*5 + x[:title] end end y4.each_pair do |x5,y5| if x5.is_a?(String) do_string(lng,'lev4',x5) - #puts ' '*5 + x5 + #puts spaces*5 + x5 end end end diff --git a/lib/sisu/v5/qrcode.rb b/lib/sisu/v5/qrcode.rb index 66584198..e17b1d86 100644 --- a/lib/sisu/v5/qrcode.rb +++ b/lib/sisu/v5/qrcode.rb @@ -124,6 +124,9 @@ module SiSU_QRcode @brace_url=SiSU_Viz::Defaults.new.url_decoration @f.make_path(@f.output_path.qrcode.dir) end + def spaces + Ax[:spaces] + end def output_metadata fn=@f.base_filename.manifest_txt mn='' @@ -666,14 +669,13 @@ WOK if defined? @md.topic_register_array \ and @md.topic_register_array.length > 0 @manifest[:txt] << %{#{@translate.topic_register}:\n} -@sp=' ' @md.topic_register_array.each do |t| t.each_with_index do |st,i| if st.is_a?(Array) st.each do |v| - @manifest[:txt] << %{#{@sp*i}#{v}\n} + @manifest[:txt] << %{#{spaces*i}#{v}\n} end - else @manifest[:txt] << %{#{@sp*i}#{st}\n} + else @manifest[:txt] << %{#{spaces*i}#{st}\n} end end end diff --git a/lib/sisu/v5/xml_docbook5.rb b/lib/sisu/v5/xml_docbook5.rb index 45e6f0cf..98450520 100644 --- a/lib/sisu/v5/xml_docbook5.rb +++ b/lib/sisu/v5/xml_docbook5.rb @@ -127,8 +127,8 @@ module SiSU_XML_Docbook_Book structure_build_collapsed(data) #tail end - def space - ' ' + def spaces + Ax[:spaces] end def tags # collapsed --> @@ -176,7 +176,7 @@ module SiSU_XML_Docbook_Book end def output(o,comment='') puts o.lc == (0..6) \ - ? "#{space*o.lc}<#{o.lc}>[#{o.ocn}] #{o.ln} #{o.obj}#{comment}" + ? "#{spaces*o.lc}<#{o.lc}>[#{o.ocn}] #{o.ln} #{o.obj}#{comment}" : "<#{o.lc}>[#{o.ocn}] #{o.ln} #{o.obj}#{comment}" end def structure_collapsed(data) @@ -213,21 +213,21 @@ module SiSU_XML_Docbook_Book @splv=o.lc tag_id=o.tags[0] ? %{ id="#{o.tags[0]}" } : '' if doc_position ==:head - filename_docbook.puts %{#{space*o.lc}} + filename_docbook.puts %{#{spaces*o.lc}} doc_position=:body_and_tail else filename_docbook.puts structure_build_tag_close(o.lc,h) - filename_docbook.puts %{#{space*(o.lc)}<#{tags.docbook(o.lc,chlv)}#{tag_id}> -#{space*o.lc} + filename_docbook.puts %{#{spaces*(o.lc)}<#{tags.docbook(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 - filename_docbook.puts %{#{space*o.lc}} + filename_docbook.puts %{#{spaces*o.lc}} h=o.lc elsif (o.of ==:para or o.of ==:block) - filename_docbook.puts "#{space*(@splv)}" + filename_docbook.puts "#{spaces*(@splv)}" filename_docbook.puts SiSU_TextUtils::Wrap.new(o.obj + ocn,80,(@splv*2+2)).line_wrap - filename_docbook.puts "#{space*(@splv)}" + filename_docbook.puts "#{spaces*(@splv)}" end end filename_docbook.puts structure_build_tag_close(0,h) @@ -237,40 +237,40 @@ module SiSU_XML_Docbook_Book x=[] case h when 0 - x << "#{space*0}" if (lc <= 0) + x << "#{spaces*0}" if (lc <= 0) when 1 - x << "#{space*1}" if (lc <= 1) - x << "#{space*0}" if (lc <= 0) + x << "#{spaces*1}" if (lc <= 1) + x << "#{spaces*0}" if (lc <= 0) when 2 - x << "#{space*2}" if (lc <= 2) - x << "#{space*1}" if (lc <= 1) - x << "#{space*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 << "#{space*3}" if (lc <= 3) - x << "#{space*2}" if (lc <= 2) - x << "#{space*1}" if (lc <= 1) - x << "#{space*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 << "#{space*4}" if (lc <= 4) - x << "#{space*3}" if (lc <= 3) - x << "#{space*2}" if (lc <= 2) - x << "#{space*1}" if (lc <= 1) - x << "#{space*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 << "#{space*5}" if (lc <= 5) - x << "#{space*4}" if (lc <= 4) - x << "#{space*5}" if (lc <= 3) - x << "#{space*2}" if (lc <= 2) - x << "#{space*1}" if (lc <= 1) - x << "#{space*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 << "#{space*6}" if (lc <= 6) - x << "#{space*5}" if (lc <= 5) - x << "#{space*4}" if (lc <= 4) - x << "#{space*3}" if (lc <= 3) - x << "#{space*2}" if (lc <= 2) - x << "#{space*1}" if (lc <= 1) - x << "#{space*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_fictionbook2.rb b/lib/sisu/v5/xml_fictionbook2.rb index 32a7bc76..f890b329 100644 --- a/lib/sisu/v5/xml_fictionbook2.rb +++ b/lib/sisu/v5/xml_fictionbook2.rb @@ -126,8 +126,8 @@ module SiSU_XML_Fictionbook data=markup_text(data) structure_build_collapsed(data,endnotes,images_base64) end - def space - ' ' + def spaces + Ax[:spaces] end def tags # collapsed --> @@ -278,7 +278,7 @@ module SiSU_XML_Fictionbook end def output(o,comment='') puts o.lc == (0..6) \ - ? "#{space*o.lc}<#{o.lc}>[#{o.ocn}] #{o.ln} #{o.obj}#{comment}" + ? "#{spaces*o.lc}<#{o.lc}>[#{o.ocn}] #{o.ln} #{o.obj}#{comment}" : "<#{o.lc}>[#{o.ocn}] #{o.ln} #{o.obj}#{comment}" end def structure_collapsed(data) @@ -315,11 +315,11 @@ module SiSU_XML_Fictionbook filename_fictionbook.puts structure_build_tag_close(o.lc,h) end doc_position=:body_and_tail - filename_fictionbook.puts %{#{space*o.lc}<#{tags.fictionbook[o.lc]}> -#{space*o.lc} + filename_fictionbook.puts %{#{spaces*o.lc}<#{tags.fictionbook[o.lc]}> +#{spaces*o.lc}<title> } filename_fictionbook.puts SiSU_TextUtils::Wrap.new("<p>#{o.obj}#{ocn}</p>",80,(o.lc*2+2)).line_wrap - filename_fictionbook.puts %{#{space*o.lc}} + filename_fictionbook.puts %{#{spaces*o.lc}} h=o.lc elsif o.is ==:heading_insert \ and o.obj =~/Endnotes/ \ @@ -338,40 +338,40 @@ module SiSU_XML_Fictionbook x=[] case h when 0 - x << "#{space*0}" if (lc <= 0) + x << "#{spaces*0}" if (lc <= 0) when 1 - x << "#{space*1}" if (lc <= 1) - x << "#{space*0}" if (lc <= 0) + x << "#{spaces*1}" if (lc <= 1) + x << "#{spaces*0}" if (lc <= 0) when 2 - x << "#{space*2}" if (lc <= 2) - x << "#{space*1}" if (lc <= 1) - x << "#{space*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 << "#{space*3}" if (lc <= 3) - x << "#{space*2}" if (lc <= 2) - x << "#{space*1}" if (lc <= 1) - x << "#{space*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 << "#{space*4}" if (lc <= 4) - x << "#{space*3}" if (lc <= 3) - x << "#{space*2}" if (lc <= 2) - x << "#{space*1}" if (lc <= 1) - x << "#{space*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 << "#{space*5}" if (lc <= 5) - x << "#{space*4}" if (lc <= 4) - x << "#{space*3}" if (lc <= 3) - x << "#{space*2}" if (lc <= 2) - x << "#{space*1}" if (lc <= 1) - x << "#{space*0}" if (lc <= 0) + 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) when 6 - x << "#{space*6}" if (lc <= 6) - x << "#{space*5}" if (lc <= 5) - x << "#{space*4}" if (lc <= 4) - x << "#{space*3}" if (lc <= 3) - x << "#{space*2}" if (lc <= 2) - x << "#{space*1}" if (lc <= 1) - x << "#{space*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_scaffold_structure_collapsed.rb b/lib/sisu/v5/xml_scaffold_structure_collapsed.rb index b6430159..0395d090 100644 --- a/lib/sisu/v5/xml_scaffold_structure_collapsed.rb +++ b/lib/sisu/v5/xml_scaffold_structure_collapsed.rb @@ -70,7 +70,9 @@ module SiSU_XML_Scaffold_Structure_Collapse def initialize(opt) @opt=opt @particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt) - @sp=' ' + end + def spaces + Ax[:spaces] end def read begin @@ -87,7 +89,6 @@ module SiSU_XML_Scaffold_Structure_Collapse class Scroll [#{o.ocn}] #{o.ln} #{o.obj}#{comment}" + puts lev == (0..6) \ + ? "#{spaces*lev}<#{lev}>[#{o.ocn}] #{o.ln} #{o.obj}#{comment}" : "<#{lev}>[#{o.ocn}] #{o.ln} #{o.obj}#{comment}" end def structure_collapsed(data) @@ -137,7 +138,7 @@ module SiSU_XML_Scaffold_Structure_Collapse if (o.is ==:heading || o.is ==:heading_insert) lev=o.lc structure_build_tag_close(lev,h) - puts "#{@sp*lev}<#{@s[lev]}>\n#{@sp*lev} [#{o.ocn}] #{lev} {#{o.node}}" + puts "#{spaces*lev}<#{@s[lev]}>\n#{spaces*lev} [#{o.ocn}] #{lev} {#{o.node}}" h[0]=lev end end @@ -146,37 +147,37 @@ module SiSU_XML_Scaffold_Structure_Collapse def structure_build_tag_close(lev,h) case h[0] when 1 - puts "#{@sp*1}" if (lev <= 1) + puts "#{spaces*1}" if (lev <= 1) puts "" if (lev==0) when 2 - puts "#{@sp*2}" if (lev <= 2) - puts "#{@sp*1}" if (lev <= 1) + puts "#{spaces*2}" if (lev <= 2) + puts "#{spaces*1}" if (lev <= 1) puts "" if (lev==0) when 3 - puts "#{@sp*3}" if (lev <= 3) - puts "#{@sp*2}" if (lev <= 2) - puts "#{@sp*1}" if (lev <= 1) + puts "#{spaces*3}" if (lev <= 3) + puts "#{spaces*2}" if (lev <= 2) + puts "#{spaces*1}" if (lev <= 1) puts "" if (lev==0) when 4 - puts "#{@sp*4}" if (lev <= 4) - puts "#{@sp*3}" if (lev <= 3) - puts "#{@sp*2}" if (lev <= 2) - puts "#{@sp*1}" if (lev <= 1) + puts "#{spaces*4}" if (lev <= 4) + puts "#{spaces*3}" if (lev <= 3) + puts "#{spaces*2}" if (lev <= 2) + puts "#{spaces*1}" if (lev <= 1) puts "" if (lev==0) when 5 - puts "#{@sp*5}" if (lev <= 5) - puts "#{@sp*4}" if (lev <= 4) - puts "#{@sp*3}" if (lev <= 3) - puts "#{@sp*2}" if (lev <= 2) - puts "#{@sp*1}" if (lev <= 1) + puts "#{spaces*5}" if (lev <= 5) + puts "#{spaces*4}" if (lev <= 4) + puts "#{spaces*3}" if (lev <= 3) + puts "#{spaces*2}" if (lev <= 2) + puts "#{spaces*1}" if (lev <= 1) puts "" if (lev==0) when 6 - puts "#{@sp*6}" if (lev <= 6) - puts "#{@sp*5}" if (lev <= 5) - puts "#{@sp*4}" if (lev <= 4) - puts "#{@sp*3}" if (lev <= 3) - puts "#{@sp*2}" if (lev <= 2) - puts "#{@sp*1}" if (lev <= 1) + puts "#{spaces*6}" if (lev <= 6) + puts "#{spaces*5}" if (lev <= 5) + puts "#{spaces*4}" if (lev <= 4) + puts "#{spaces*3}" if (lev <= 3) + puts "#{spaces*2}" if (lev <= 2) + puts "#{spaces*1}" if (lev <= 1) puts "" if (lev==0) end end diff --git a/lib/sisu/v5/xml_scaffold_structure_sisu.rb b/lib/sisu/v5/xml_scaffold_structure_sisu.rb index 5e2afa4d..39ca1e6a 100644 --- a/lib/sisu/v5/xml_scaffold_structure_sisu.rb +++ b/lib/sisu/v5/xml_scaffold_structure_sisu.rb @@ -70,7 +70,9 @@ module SiSU_XML_Scaffold_Structure_Sisu def initialize(opt) @opt=opt @particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt) - @sp=' ' + end + def spaces + Ax[:spaces] end def read begin @@ -87,7 +89,6 @@ module SiSU_XML_Scaffold_Structure_Sisu class Scroll \n\n" data.each_with_index do |o,i| if (o.is ==:heading || o.is ==:heading_insert) - puts "#{@sp*o.ln}<#{tags.sisu[o.ln]}>[#{o.ocn}] #{o.ln} #{o.obj}" + puts "#{spaces*o.ln}<#{tags.sisu[o.ln]}>[#{o.ocn}] #{o.ln} #{o.obj}" end end end def output(o,lev=nil,comment='') - puts lev == 0..6 \ - ? "#{@sp*lev}<#{lev}>[#{o.ocn}] #{o.ln} #{o.obj}#{comment}" + puts lev == (0..6) \ + ? "#{spaces*lev}<#{lev}>[#{o.ocn}] #{o.ln} #{o.obj}#{comment}" : "<#{lev}>[#{o.ocn}] #{o.ln} #{o.obj}#{comment}" end def structure_build_sisu(data) @@ -131,7 +132,7 @@ module SiSU_XML_Scaffold_Structure_Sisu data.each_with_index do |o,i| if (o.is ==:heading || o.is ==:heading_insert) structure_build_tag_close(o.ln,h) - puts "#{@sp*o.ln}<#{@s[o.ln]}>\n#{@sp*o.ln} [#{o.ocn}] #{o.ln} {#{o.node}}" + puts "#{spaces*o.ln}<#{@s[o.ln]}>\n#{spaces*o.ln} [#{o.ocn}] #{o.ln} {#{o.node}}" case o.ln when 1 h=[o.ln,true,false,false] @@ -149,37 +150,37 @@ module SiSU_XML_Scaffold_Structure_Sisu def structure_build_tag_close(lev,h) case h[0] when 1 - puts "#{@sp*1}" if (lev <= 1) && h[1] + puts "#{spaces*1}" if (lev <= 1) && h[1] puts "" if (lev==0) when 2 - puts "#{@sp*2}" if (lev <= 2) && h[2] - puts "#{@sp*1}" if (lev <= 1) && h[1] + puts "#{spaces*2}" if (lev <= 2) && h[2] + puts "#{spaces*1}" if (lev <= 1) && h[1] puts "" if (lev==0) when 3 - puts "#{@sp*3}" if (lev <= 3) && h[3] - puts "#{@sp*2}" if (lev <= 2) && h[2] - puts "#{@sp*1}" if (lev <= 1) && h[1] + puts "#{spaces*3}" if (lev <= 3) && h[3] + puts "#{spaces*2}" if (lev <= 2) && h[2] + puts "#{spaces*1}" if (lev <= 1) && h[1] puts "" if (lev==0) when 4 - puts "#{@sp*4}" if (lev <= 4) - puts "#{@sp*3}" if (lev <= 3) && h[3] - puts "#{@sp*2}" if (lev <= 2) && h[2] - puts "#{@sp*1}" if (lev <= 1) && h[1] + puts "#{spaces*4}" if (lev <= 4) + puts "#{spaces*3}" if (lev <= 3) && h[3] + puts "#{spaces*2}" if (lev <= 2) && h[2] + puts "#{spaces*1}" if (lev <= 1) && h[1] puts "" if (lev==0) when 5 - puts "#{@sp*5}" if (lev <= 5) - puts "#{@sp*4}" if (lev <= 4) - puts "#{@sp*3}" if (lev <= 3) && h[3] - puts "#{@sp*2}" if (lev <= 2) && h[2] - puts "#{@sp*1}" if (lev <= 1) && h[1] + puts "#{spaces*5}" if (lev <= 5) + puts "#{spaces*4}" if (lev <= 4) + puts "#{spaces*3}" if (lev <= 3) && h[3] + puts "#{spaces*2}" if (lev <= 2) && h[2] + puts "#{spaces*1}" if (lev <= 1) && h[1] puts "" if (lev==0) when 6 - puts "#{@sp*6}" if (lev <= 6) - puts "#{@sp*5}" if (lev <= 5) - puts "#{@sp*4}" if (lev <= 4) - puts "#{@sp*3}" if (lev <= 3) && h[3] - puts "#{@sp*2}" if (lev <= 2) && h[2] - puts "#{@sp*1}" if (lev <= 1) && h[1] + puts "#{spaces*6}" if (lev <= 6) + puts "#{spaces*5}" if (lev <= 5) + puts "#{spaces*4}" if (lev <= 4) + puts "#{spaces*3}" if (lev <= 3) && h[3] + puts "#{spaces*2}" if (lev <= 2) && h[2] + puts "#{spaces*1}" if (lev <= 1) && h[1] puts "" if (lev==0) end end diff --git a/lib/sisu/v6/digests.rb b/lib/sisu/v6/digests.rb index 24ddc32e..7e5e42ab 100644 --- a/lib/sisu/v6/digests.rb +++ b/lib/sisu/v6/digests.rb @@ -134,6 +134,9 @@ module SiSU_DigestView supplementary output end + def spaces + Ax[:spaces] + end def description(f,e='') puts f + e.to_s if @md.opt.act[:verbose_plus][:set]==:on @@description << f << e @@ -234,19 +237,19 @@ module SiSU_DigestView if t_o.is==:heading x=case t_o.ln when 0 then l[0] +=1 - ' '*0 << ':A' + spaces*0 << ':A' when 1 then l[1] +=1 - ' '*1 << ':B' + spaces*1 << ':B' when 2 then l[2] +=1 - ' '*2 << ':C' + spaces*2 << ':C' when 3 then l[3] +=1 - ' '*3 << ':D' + spaces*3 << ':D' when 4 then l[4] +=1 - ' '*4 << '1' + spaces*4 << '1' when 5 then l[5] +=1 - ' '*5 << '2' + spaces*5 << '2' when 6 then l[6] +=1 - ' '*6 << '3' + spaces*6 << '3' else nil end end diff --git a/lib/sisu/v6/harvest_topics.rb b/lib/sisu/v6/harvest_topics.rb index ce6e13c2..c682bd37 100644 --- a/lib/sisu/v6/harvest_topics.rb +++ b/lib/sisu/v6/harvest_topics.rb @@ -97,6 +97,11 @@ module SiSU_HarvestTopics SiSU_HarvestTopics::OutputIndex.new(@opt,the_hash).html_print.html_songsheet end end + class Mix + def spaces + Ax[:spaces] + end + end class Harvest def initialize(opt,env,data,filename,name,idx_array,lang) @opt,@env,@data,@filename,@name,@idx_array,@lang=opt,env,data,filename,name,idx_array,lang @@ -160,7 +165,7 @@ module SiSU_HarvestTopics idx_array end end - class Index + class Index < Mix def initialize(opt,env,idx_array,the_idx) @opt,@env,@idx_array,@the_idx=opt,env,idx_array,the_idx @@the_idx_topics=@the_idx @@ -313,7 +318,7 @@ module SiSU_HarvestTopics else @the_h[x0] ||={} end - #puts ' '*0 + x0 + #puts spaces*0 + x0 if extract >= 1 y0.each_pair do |x1,y1| if extract == 1 @@ -322,7 +327,7 @@ module SiSU_HarvestTopics else @the_h[x0][x1] ||={} end - #puts ' '*1 + x1 + #puts spaces*1 + x1 if extract >= 2 y1.each_pair do |x2,y2| if extract == 2 @@ -331,7 +336,7 @@ module SiSU_HarvestTopics else @the_h[x0][x1][x2] ||={} end - #puts ' '*2 + x2 + #puts spaces*2 + x2 if extract >= 3 y2.each_pair do |x3,y3| if extract == 3 @@ -340,7 +345,7 @@ module SiSU_HarvestTopics else @the_h[x0][x1][x2][x3] ||={} end - #puts ' '*3 + x3 + #puts spaces*3 + x3 if extract == 4 y3.each_pair do |x4,y4| if extract == 4 @@ -349,14 +354,14 @@ module SiSU_HarvestTopics else @the_h[x0][x1][x2][x3][x4] ||={} end - #puts ' '*4 + x4 + #puts spaces*4 + x4 if extract == 5 y4.each_pair do |x5,y5| if extract == 5 @the_h[x0][x1][x2][x3][x4][x5] ||={ md: [] } @the_h[x0][x1][x2][x3][x4][x5][:md] << y5 end - #puts ' '*5 + x5 + #puts spaces*5 + x5 end end end @@ -375,22 +380,22 @@ module SiSU_HarvestTopics end def traverse_base @the_h.each_pair do |x0,y0| - puts ' '*0 + x0 if x0.is_a?(String) + puts spaces*0 + x0 if x0.is_a?(String) if y0.is_a?(Hash) y0.each_pair do |x1,y1| - puts ' '*1 + x1 if x1.is_a?(String) + puts spaces*1 + x1 if x1.is_a?(String) if y1.is_a?(Hash) y1.each_pair do |x2,y2| - puts ' '*2 + x2 if x2.is_a?(String) + puts spaces*2 + x2 if x2.is_a?(String) if y2.is_a?(Hash) y2.each_pair do |x3,y3| - puts ' '*3 + x3 if x3.is_a?(String) + puts spaces*3 + x3 if x3.is_a?(String) if y3.is_a?(Hash) y3.each_pair do |x4,y4| - puts ' '*4 + x4 if x4.is_a?(String) + puts spaces*4 + x4 if x4.is_a?(String) if y4.is_a?(Hash) y4.each_pair do |x5,y5| - puts ' '*5 + x5 if x5.is_a?(String) + puts spaces*5 + x5 if x5.is_a?(String) end end end @@ -405,37 +410,37 @@ module SiSU_HarvestTopics end def traverse @the_h.each_pair do |x0,y0| - puts ' '*0 + x0 if x0.is_a?(String) + puts spaces*0 + x0 if x0.is_a?(String) if y0.is_a?(Hash) if y0.has_key?(:md) - y0[:md].each { |x| puts ' '*5 + x[:title] } + y0[:md].each { |x| puts spaces*5 + x[:title] } end y0.each_pair do |x1,y1| - puts ' '*1 + x1 if x1.is_a?(String) + puts spaces*1 + x1 if x1.is_a?(String) if y1.is_a?(Hash) if y1.has_key?(:md) - y1[:md].each { |x| puts ' '*5 + x[:title] } + y1[:md].each { |x| puts spaces*5 + x[:title] } end y1.each_pair do |x2,y2| - puts ' '*2 + x2 if x2.is_a?(String) + puts spaces*2 + x2 if x2.is_a?(String) if y2.is_a?(Hash) if y2.has_key?(:md) - y2[:md].each { |x| puts ' '*5 + x[:title] } + y2[:md].each { |x| puts spaces*5 + x[:title] } end y2.each_pair do |x3,y3| - puts ' '*3 + x3 if x3.is_a?(String) + puts spaces*3 + x3 if x3.is_a?(String) if y3.is_a?(Hash) if y3.has_key?(:md) - y3[:md].each { |x| puts ' '*5 + x[:title] } + y3[:md].each { |x| puts spaces*5 + x[:title] } end y3.each_pair do |x4,y4| - puts ' '*4 + x4 if x4.is_a?(String) + puts spaces*4 + x4 if x4.is_a?(String) if y4.is_a?(Hash) if y4.has_key?(:md) - y4[:md].each { |x| puts ' '*5 + x[:title] } + y4[:md].each { |x| puts spaces*5 + x[:title] } end y4.each_pair do |x5,y5| - puts ' '*5 + x4 if x4.is_a?(String) + puts spaces*5 + x4 if x4.is_a?(String) end end end @@ -449,7 +454,7 @@ module SiSU_HarvestTopics end end end - class OutputIndex + class OutputIndex < Mix require_relative 'i18n' # i18n.rb def initialize(opt,the_idx) @opt,@the_idx=opt,the_idx @@ -509,67 +514,67 @@ module SiSU_HarvestTopics lng=x0 if x0.is_a?(String) #do_string_name(lng,'lev0',x0) - #puts ' '*0 + x0 + #puts spaces*0 + x0 end if y0.is_a?(Hash) if y0.has_key?(:md) y0[:md].each do |x| #do_hash(lng,attrib,x) #lv==0 ? - #puts ' '*5 + x[:title] + #puts spaces*5 + x[:title] end end y0.each_pair do |x1,y1| if x1.is_a?(String) do_string_name(lng,'lev0',x1) - #puts ' '*1 + x1 + #puts spaces*1 + x1 end if y1.is_a?(Hash) if y1.has_key?(:md) y1[:md].each do |x| do_hash(lng,0,x) - #puts ' '*5 + x[:title] + #puts spaces*5 + x[:title] end end y1.each_pair do |x2,y2| if x2.is_a?(String) do_string(lng,'lev1',x2) - #puts ' '*2 + x2 + #puts spaces*2 + x2 end if y2.is_a?(Hash) if y2.has_key?(:md) y2[:md].each do |x| do_hash(lng,1,x) - #puts ' '*5 + x[:title] + #puts spaces*5 + x[:title] end end y2.each_pair do |x3,y3| if x3.is_a?(String) do_string(lng,'lev2',x3) - #puts ' '*3 + x3 + #puts spaces*3 + x3 end if y3.is_a?(Hash) if y3.has_key?(:md) y3[:md].each do |x| do_hash(lng,2,x) - #puts ' '*5 + x[:title] + #puts spaces*5 + x[:title] end end y3.each_pair do |x4,y4| if x4.is_a?(String) do_string(lng,'lev3',x4) - #puts ' '*4 + x4 + #puts spaces*4 + x4 end if y4.is_a?(Hash) if y4.has_key?(:md) y4[:md].each do |x| do_hash(lng,3,x) - #puts ' '*5 + x[:title] + #puts spaces*5 + x[:title] end end y4.each_pair do |x5,y5| if x5.is_a?(String) do_string(lng,'lev4',x5) - #puts ' '*5 + x5 + #puts spaces*5 + x5 end end end diff --git a/lib/sisu/v6/qrcode.rb b/lib/sisu/v6/qrcode.rb index 73feaf3f..a8d27ad2 100644 --- a/lib/sisu/v6/qrcode.rb +++ b/lib/sisu/v6/qrcode.rb @@ -124,6 +124,9 @@ module SiSU_QRcode @brace_url=SiSU_Viz::Defaults.new.url_decoration @f.make_path(@f.output_path.qrcode.dir) end + def spaces + Ax[:spaces] + end def output_metadata fn=@f.base_filename.manifest_txt mn='' @@ -666,14 +669,13 @@ WOK if defined? @md.topic_register_array \ and @md.topic_register_array.length > 0 @manifest[:txt] << %{#{@translate.topic_register}:\n} -@sp=' ' @md.topic_register_array.each do |t| t.each_with_index do |st,i| if st.is_a?(Array) st.each do |v| - @manifest[:txt] << %{#{@sp*i}#{v}\n} + @manifest[:txt] << %{#{spaces*i}#{v}\n} end - else @manifest[:txt] << %{#{@sp*i}#{st}\n} + else @manifest[:txt] << %{#{spaces*i}#{st}\n} end end end diff --git a/lib/sisu/v6/xml_docbook5.rb b/lib/sisu/v6/xml_docbook5.rb index f5dba87a..bc4ad233 100644 --- a/lib/sisu/v6/xml_docbook5.rb +++ b/lib/sisu/v6/xml_docbook5.rb @@ -127,8 +127,8 @@ module SiSU_XML_Docbook_Book structure_build_collapsed(data) #tail end - def space - ' ' + def spaces + Ax[:spaces] end def tags # collapsed --> @@ -176,7 +176,7 @@ module SiSU_XML_Docbook_Book end def output(o,comment='') puts o.lc == (0..6) \ - ? "#{space*o.lc}<#{o.lc}>[#{o.ocn}] #{o.ln} #{o.obj}#{comment}" + ? "#{spaces*o.lc}<#{o.lc}>[#{o.ocn}] #{o.ln} #{o.obj}#{comment}" : "<#{o.lc}>[#{o.ocn}] #{o.ln} #{o.obj}#{comment}" end def structure_collapsed(data) @@ -213,21 +213,21 @@ module SiSU_XML_Docbook_Book @splv=o.lc tag_id=o.tags[0] ? %{ id="#{o.tags[0]}" } : '' if doc_position ==:head - filename_docbook.puts %{#{space*o.lc}} + filename_docbook.puts %{#{spaces*o.lc}} doc_position=:body_and_tail else filename_docbook.puts structure_build_tag_close(o.lc,h) - filename_docbook.puts %{#{space*(o.lc)}<#{tags.docbook(o.lc,chlv)}#{tag_id}> -#{space*o.lc} + filename_docbook.puts %{#{spaces*(o.lc)}<#{tags.docbook(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 - filename_docbook.puts %{#{space*o.lc}} + filename_docbook.puts %{#{spaces*o.lc}} h=o.lc elsif (o.of ==:para or o.of ==:block) - filename_docbook.puts "#{space*(@splv)}" + filename_docbook.puts "#{spaces*(@splv)}" filename_docbook.puts SiSU_TextUtils::Wrap.new(o.obj + ocn,80,(@splv*2+2)).line_wrap - filename_docbook.puts "#{space*(@splv)}" + filename_docbook.puts "#{spaces*(@splv)}" end end filename_docbook.puts structure_build_tag_close(0,h) @@ -237,40 +237,40 @@ module SiSU_XML_Docbook_Book x=[] case h when 0 - x << "#{space*0}" if (lc <= 0) + x << "#{spaces*0}" if (lc <= 0) when 1 - x << "#{space*1}" if (lc <= 1) - x << "#{space*0}" if (lc <= 0) + x << "#{spaces*1}" if (lc <= 1) + x << "#{spaces*0}" if (lc <= 0) when 2 - x << "#{space*2}" if (lc <= 2) - x << "#{space*1}" if (lc <= 1) - x << "#{space*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 << "#{space*3}" if (lc <= 3) - x << "#{space*2}" if (lc <= 2) - x << "#{space*1}" if (lc <= 1) - x << "#{space*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 << "#{space*4}" if (lc <= 4) - x << "#{space*3}" if (lc <= 3) - x << "#{space*2}" if (lc <= 2) - x << "#{space*1}" if (lc <= 1) - x << "#{space*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 << "#{space*5}" if (lc <= 5) - x << "#{space*4}" if (lc <= 4) - x << "#{space*5}" if (lc <= 3) - x << "#{space*2}" if (lc <= 2) - x << "#{space*1}" if (lc <= 1) - x << "#{space*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 << "#{space*6}" if (lc <= 6) - x << "#{space*5}" if (lc <= 5) - x << "#{space*4}" if (lc <= 4) - x << "#{space*3}" if (lc <= 3) - x << "#{space*2}" if (lc <= 2) - x << "#{space*1}" if (lc <= 1) - x << "#{space*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/v6/xml_fictionbook2.rb b/lib/sisu/v6/xml_fictionbook2.rb index d0ad4a7f..4e580b84 100644 --- a/lib/sisu/v6/xml_fictionbook2.rb +++ b/lib/sisu/v6/xml_fictionbook2.rb @@ -126,8 +126,8 @@ module SiSU_XML_Fictionbook data=markup_text(data) structure_build_collapsed(data,endnotes,images_base64) end - def space - ' ' + def spaces + Ax[:spaces] end def tags # collapsed --> @@ -278,7 +278,7 @@ module SiSU_XML_Fictionbook end def output(o,comment='') puts o.lc == (0..6) \ - ? "#{space*o.lc}<#{o.lc}>[#{o.ocn}] #{o.ln} #{o.obj}#{comment}" + ? "#{spaces*o.lc}<#{o.lc}>[#{o.ocn}] #{o.ln} #{o.obj}#{comment}" : "<#{o.lc}>[#{o.ocn}] #{o.ln} #{o.obj}#{comment}" end def structure_collapsed(data) @@ -315,11 +315,11 @@ module SiSU_XML_Fictionbook filename_fictionbook.puts structure_build_tag_close(o.lc,h) end doc_position=:body_and_tail - filename_fictionbook.puts %{#{space*o.lc}<#{tags.fictionbook[o.lc]}> -#{space*o.lc} + filename_fictionbook.puts %{#{spaces*o.lc}<#{tags.fictionbook[o.lc]}> +#{spaces*o.lc}<title> } filename_fictionbook.puts SiSU_TextUtils::Wrap.new("<p>#{o.obj}#{ocn}</p>",80,(o.lc*2+2)).line_wrap - filename_fictionbook.puts %{#{space*o.lc}} + filename_fictionbook.puts %{#{spaces*o.lc}} h=o.lc elsif o.is ==:heading_insert \ and o.obj =~/Endnotes/ \ @@ -338,40 +338,40 @@ module SiSU_XML_Fictionbook x=[] case h when 0 - x << "#{space*0}" if (lc <= 0) + x << "#{spaces*0}" if (lc <= 0) when 1 - x << "#{space*1}" if (lc <= 1) - x << "#{space*0}" if (lc <= 0) + x << "#{spaces*1}" if (lc <= 1) + x << "#{spaces*0}" if (lc <= 0) when 2 - x << "#{space*2}" if (lc <= 2) - x << "#{space*1}" if (lc <= 1) - x << "#{space*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 << "#{space*3}" if (lc <= 3) - x << "#{space*2}" if (lc <= 2) - x << "#{space*1}" if (lc <= 1) - x << "#{space*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 << "#{space*4}" if (lc <= 4) - x << "#{space*3}" if (lc <= 3) - x << "#{space*2}" if (lc <= 2) - x << "#{space*1}" if (lc <= 1) - x << "#{space*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 << "#{space*5}" if (lc <= 5) - x << "#{space*4}" if (lc <= 4) - x << "#{space*3}" if (lc <= 3) - x << "#{space*2}" if (lc <= 2) - x << "#{space*1}" if (lc <= 1) - x << "#{space*0}" if (lc <= 0) + 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) when 6 - x << "#{space*6}" if (lc <= 6) - x << "#{space*5}" if (lc <= 5) - x << "#{space*4}" if (lc <= 4) - x << "#{space*3}" if (lc <= 3) - x << "#{space*2}" if (lc <= 2) - x << "#{space*1}" if (lc <= 1) - x << "#{space*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/v6/xml_scaffold_structure_collapsed.rb b/lib/sisu/v6/xml_scaffold_structure_collapsed.rb index 23bc4f4c..9fece3bf 100644 --- a/lib/sisu/v6/xml_scaffold_structure_collapsed.rb +++ b/lib/sisu/v6/xml_scaffold_structure_collapsed.rb @@ -70,7 +70,9 @@ module SiSU_XML_Scaffold_Structure_Collapse def initialize(opt) @opt=opt @particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt) - @sp=' ' + end + def spaces + Ax[:spaces] end def read begin @@ -87,7 +89,6 @@ module SiSU_XML_Scaffold_Structure_Collapse class Scroll [#{o.ocn}] #{o.ln} #{o.obj}#{comment}" + puts lev == (0..6) \ + ? "#{spaces*lev}<#{lev}>[#{o.ocn}] #{o.ln} #{o.obj}#{comment}" : "<#{lev}>[#{o.ocn}] #{o.ln} #{o.obj}#{comment}" end def structure_collapsed(data) @@ -137,7 +138,7 @@ module SiSU_XML_Scaffold_Structure_Collapse if (o.is ==:heading || o.is ==:heading_insert) lev=o.lc structure_build_tag_close(lev,h) - puts "#{@sp*lev}<#{@s[lev]}>\n#{@sp*lev} [#{o.ocn}] #{lev} {#{o.node}}" + puts "#{spaces*lev}<#{@s[lev]}>\n#{spaces*lev} [#{o.ocn}] #{lev} {#{o.node}}" h[0]=lev end end @@ -146,37 +147,37 @@ module SiSU_XML_Scaffold_Structure_Collapse def structure_build_tag_close(lev,h) case h[0] when 1 - puts "#{@sp*1}" if (lev <= 1) + puts "#{spaces*1}" if (lev <= 1) puts "" if (lev==0) when 2 - puts "#{@sp*2}" if (lev <= 2) - puts "#{@sp*1}" if (lev <= 1) + puts "#{spaces*2}" if (lev <= 2) + puts "#{spaces*1}" if (lev <= 1) puts "" if (lev==0) when 3 - puts "#{@sp*3}" if (lev <= 3) - puts "#{@sp*2}" if (lev <= 2) - puts "#{@sp*1}" if (lev <= 1) + puts "#{spaces*3}" if (lev <= 3) + puts "#{spaces*2}" if (lev <= 2) + puts "#{spaces*1}" if (lev <= 1) puts "" if (lev==0) when 4 - puts "#{@sp*4}" if (lev <= 4) - puts "#{@sp*3}" if (lev <= 3) - puts "#{@sp*2}" if (lev <= 2) - puts "#{@sp*1}" if (lev <= 1) + puts "#{spaces*4}" if (lev <= 4) + puts "#{spaces*3}" if (lev <= 3) + puts "#{spaces*2}" if (lev <= 2) + puts "#{spaces*1}" if (lev <= 1) puts "" if (lev==0) when 5 - puts "#{@sp*5}" if (lev <= 5) - puts "#{@sp*4}" if (lev <= 4) - puts "#{@sp*3}" if (lev <= 3) - puts "#{@sp*2}" if (lev <= 2) - puts "#{@sp*1}" if (lev <= 1) + puts "#{spaces*5}" if (lev <= 5) + puts "#{spaces*4}" if (lev <= 4) + puts "#{spaces*3}" if (lev <= 3) + puts "#{spaces*2}" if (lev <= 2) + puts "#{spaces*1}" if (lev <= 1) puts "" if (lev==0) when 6 - puts "#{@sp*6}" if (lev <= 6) - puts "#{@sp*5}" if (lev <= 5) - puts "#{@sp*4}" if (lev <= 4) - puts "#{@sp*3}" if (lev <= 3) - puts "#{@sp*2}" if (lev <= 2) - puts "#{@sp*1}" if (lev <= 1) + puts "#{spaces*6}" if (lev <= 6) + puts "#{spaces*5}" if (lev <= 5) + puts "#{spaces*4}" if (lev <= 4) + puts "#{spaces*3}" if (lev <= 3) + puts "#{spaces*2}" if (lev <= 2) + puts "#{spaces*1}" if (lev <= 1) puts "" if (lev==0) end end diff --git a/lib/sisu/v6/xml_scaffold_structure_sisu.rb b/lib/sisu/v6/xml_scaffold_structure_sisu.rb index 075a00ee..a21f8347 100644 --- a/lib/sisu/v6/xml_scaffold_structure_sisu.rb +++ b/lib/sisu/v6/xml_scaffold_structure_sisu.rb @@ -70,7 +70,9 @@ module SiSU_XML_Scaffold_Structure_Sisu def initialize(opt) @opt=opt @particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt) - @sp=' ' + end + def spaces + Ax[:spaces] end def read begin @@ -87,7 +89,6 @@ module SiSU_XML_Scaffold_Structure_Sisu class Scroll \n\n" data.each_with_index do |o,i| if (o.is ==:heading || o.is ==:heading_insert) - puts "#{@sp*o.ln}<#{tags.sisu[o.ln]}>[#{o.ocn}] #{o.ln} #{o.obj}" + puts "#{spaces*o.ln}<#{tags.sisu[o.ln]}>[#{o.ocn}] #{o.ln} #{o.obj}" end end end def output(o,lev=nil,comment='') - puts lev == 0..6 \ - ? "#{@sp*lev}<#{lev}>[#{o.ocn}] #{o.ln} #{o.obj}#{comment}" + puts lev == (0..6) \ + ? "#{spaces*lev}<#{lev}>[#{o.ocn}] #{o.ln} #{o.obj}#{comment}" : "<#{lev}>[#{o.ocn}] #{o.ln} #{o.obj}#{comment}" end def structure_build_sisu(data) @@ -131,7 +132,7 @@ module SiSU_XML_Scaffold_Structure_Sisu data.each_with_index do |o,i| if (o.is ==:heading || o.is ==:heading_insert) structure_build_tag_close(o.ln,h) - puts "#{@sp*o.ln}<#{@s[o.ln]}>\n#{@sp*o.ln} [#{o.ocn}] #{o.ln} {#{o.node}}" + puts "#{spaces*o.ln}<#{@s[o.ln]}>\n#{spaces*o.ln} [#{o.ocn}] #{o.ln} {#{o.node}}" case o.ln when 1 h=[o.ln,true,false,false] @@ -149,37 +150,37 @@ module SiSU_XML_Scaffold_Structure_Sisu def structure_build_tag_close(lev,h) case h[0] when 1 - puts "#{@sp*1}" if (lev <= 1) && h[1] + puts "#{spaces*1}" if (lev <= 1) && h[1] puts "" if (lev==0) when 2 - puts "#{@sp*2}" if (lev <= 2) && h[2] - puts "#{@sp*1}" if (lev <= 1) && h[1] + puts "#{spaces*2}" if (lev <= 2) && h[2] + puts "#{spaces*1}" if (lev <= 1) && h[1] puts "" if (lev==0) when 3 - puts "#{@sp*3}" if (lev <= 3) && h[3] - puts "#{@sp*2}" if (lev <= 2) && h[2] - puts "#{@sp*1}" if (lev <= 1) && h[1] + puts "#{spaces*3}" if (lev <= 3) && h[3] + puts "#{spaces*2}" if (lev <= 2) && h[2] + puts "#{spaces*1}" if (lev <= 1) && h[1] puts "" if (lev==0) when 4 - puts "#{@sp*4}" if (lev <= 4) - puts "#{@sp*3}" if (lev <= 3) && h[3] - puts "#{@sp*2}" if (lev <= 2) && h[2] - puts "#{@sp*1}" if (lev <= 1) && h[1] + puts "#{spaces*4}" if (lev <= 4) + puts "#{spaces*3}" if (lev <= 3) && h[3] + puts "#{spaces*2}" if (lev <= 2) && h[2] + puts "#{spaces*1}" if (lev <= 1) && h[1] puts "" if (lev==0) when 5 - puts "#{@sp*5}" if (lev <= 5) - puts "#{@sp*4}" if (lev <= 4) - puts "#{@sp*3}" if (lev <= 3) && h[3] - puts "#{@sp*2}" if (lev <= 2) && h[2] - puts "#{@sp*1}" if (lev <= 1) && h[1] + puts "#{spaces*5}" if (lev <= 5) + puts "#{spaces*4}" if (lev <= 4) + puts "#{spaces*3}" if (lev <= 3) && h[3] + puts "#{spaces*2}" if (lev <= 2) && h[2] + puts "#{spaces*1}" if (lev <= 1) && h[1] puts "" if (lev==0) when 6 - puts "#{@sp*6}" if (lev <= 6) - puts "#{@sp*5}" if (lev <= 5) - puts "#{@sp*4}" if (lev <= 4) - puts "#{@sp*3}" if (lev <= 3) && h[3] - puts "#{@sp*2}" if (lev <= 2) && h[2] - puts "#{@sp*1}" if (lev <= 1) && h[1] + puts "#{spaces*6}" if (lev <= 6) + puts "#{spaces*5}" if (lev <= 5) + puts "#{spaces*4}" if (lev <= 4) + puts "#{spaces*3}" if (lev <= 3) && h[3] + puts "#{spaces*2}" if (lev <= 2) && h[2] + puts "#{spaces*1}" if (lev <= 1) && h[1] puts "" if (lev==0) end end -- cgit v1.2.3 From 5d168b3061ae8fbe3c2373827edce8de1bce4cfd Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Thu, 19 Jun 2014 19:18:47 -0400 Subject: v5 v6: ao, code blocks, clean trailing newlines --- data/doc/sisu/CHANGELOG_v5 | 4 +++- data/doc/sisu/CHANGELOG_v6 | 4 +++- lib/sisu/v5/ao_doc_str.rb | 1 + lib/sisu/v6/ao_doc_str.rb | 1 + 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/data/doc/sisu/CHANGELOG_v5 b/data/doc/sisu/CHANGELOG_v5 index 99f59534..c20bbef3 100644 --- a/data/doc/sisu/CHANGELOG_v5 +++ b/data/doc/sisu/CHANGELOG_v5 @@ -38,7 +38,9 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_5.4.1.orig.tar.xz sisu_5.4.1.orig.tar.xz sisu_5.4.1-1.dsc -* ao, misc, minorish +* ao, + * code blocks, clean trailing newlines + * misc, minorish %% 5.4.0.orig.tar.xz (2014-05-25:20/7) http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/sisu_5.4.0 diff --git a/data/doc/sisu/CHANGELOG_v6 b/data/doc/sisu/CHANGELOG_v6 index 645d482d..55804b1c 100644 --- a/data/doc/sisu/CHANGELOG_v6 +++ b/data/doc/sisu/CHANGELOG_v6 @@ -28,7 +28,9 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_6.0.8.orig.tar.xz sisu_6.0.8.orig.tar.xz sisu_6.0.8-1.dsc -* ao, misc, minorish +* ao, + * code blocks, clean trailing newlines + * misc, minorish %% 6.0.7.orig.tar.xz (2014-05-25:20/7) http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/sisu_6.0.7 diff --git a/lib/sisu/v5/ao_doc_str.rb b/lib/sisu/v5/ao_doc_str.rb index 15d4aa9e..59361cc8 100644 --- a/lib/sisu/v5/ao_doc_str.rb +++ b/lib/sisu/v5/ao_doc_str.rb @@ -600,6 +600,7 @@ module SiSU_AO_DocumentStructureExtract if (@@flag[:code]==:curls and t_o =~/^\}code/) \ or (@@flag[:code]==:tics and t_o =~/^[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) @@flag[:code]=:off + @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_code_block, number_: @codeblock_numbered } diff --git a/lib/sisu/v6/ao_doc_str.rb b/lib/sisu/v6/ao_doc_str.rb index 846a7027..db340aa3 100644 --- a/lib/sisu/v6/ao_doc_str.rb +++ b/lib/sisu/v6/ao_doc_str.rb @@ -600,6 +600,7 @@ module SiSU_AO_DocumentStructureExtract if (@@flag[:code]==:curls and t_o =~/^\}code/) \ or (@@flag[:code]==:tics and t_o =~/^[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) @@flag[:code]=:off + @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_code_block, number_: @codeblock_numbered } -- cgit v1.2.3 From de1c383871c4a6e401cab30351d2af805445d5a9 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Thu, 19 Jun 2014 19:21:12 -0400 Subject: v5 v6: ao, turn id numbers (for tags) into a hash --- data/doc/sisu/CHANGELOG_v5 | 1 + data/doc/sisu/CHANGELOG_v6 | 1 + lib/sisu/v5/ao_doc_str.rb | 67 +++++++++++++++++++++++++--------------------- lib/sisu/v6/ao_doc_str.rb | 67 +++++++++++++++++++++++++--------------------- 4 files changed, 76 insertions(+), 60 deletions(-) diff --git a/data/doc/sisu/CHANGELOG_v5 b/data/doc/sisu/CHANGELOG_v5 index c20bbef3..0b449409 100644 --- a/data/doc/sisu/CHANGELOG_v5 +++ b/data/doc/sisu/CHANGELOG_v5 @@ -40,6 +40,7 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_5.4.1.orig.tar.xz * ao, * code blocks, clean trailing newlines + * turn id numbers (for tags) into a hash * misc, minorish %% 5.4.0.orig.tar.xz (2014-05-25:20/7) diff --git a/data/doc/sisu/CHANGELOG_v6 b/data/doc/sisu/CHANGELOG_v6 index 55804b1c..d082de3f 100644 --- a/data/doc/sisu/CHANGELOG_v6 +++ b/data/doc/sisu/CHANGELOG_v6 @@ -30,6 +30,7 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_6.0.8.orig.tar.xz * ao, * code blocks, clean trailing newlines + * turn id numbers (for tags) into a hash * misc, minorish %% 6.0.7.orig.tar.xz (2014-05-25:20/7) diff --git a/lib/sisu/v5/ao_doc_str.rb b/lib/sisu/v5/ao_doc_str.rb index 59361cc8..8f708803 100644 --- a/lib/sisu/v5/ao_doc_str.rb +++ b/lib/sisu/v5/ao_doc_str.rb @@ -225,7 +225,14 @@ module SiSU_AO_DocumentStructureExtract def identify_parts tuned_file=[] @tuned_block,@tuned_code=[],[] - @@counter,@verse_count,@num_code_block,@num_poem,@num_group,@num_block,@num_alt,@num_table=0,0,0,0,0,0,0,0 + @@counter,@verse_count=0,0 + @num_id={ + code_block: 0, + poem: 0, + group: 0, + alt: 0, + table: 0, + } @metadata={} @data.each do |t_o| if t_o =~/^--([+~-])[#]$/ @@ -417,8 +424,8 @@ module SiSU_AO_DocumentStructureExtract end @@counter=1 @codeblock_numbered=(t_o =~/^(?:code\{#|[`]{3}\s+code\s[#])/) ? true : false - @num_code_block +=1 - h={ obj: "code block start #{@num_code_block}" } + @num_id[:code_block] +=1 + h={ obj: "code block start #{@num_id[:code_block]}" } t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) elsif t_o =~/^(?:poem\{|[`]{3}\s+poem)/ @@flag[:poem]=case t_o @@ -426,8 +433,8 @@ module SiSU_AO_DocumentStructureExtract when /^[`]{3}\s+poem/ then :tics else @@flag[:poem] #error end - @num_poem +=1 - h={ obj: "poem start #{@num_poem}" } + @num_id[:poem] +=1 + h={ obj: "poem start #{@num_id[:poem]}" } t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) tuned_file << t_o elsif t_o =~/^(?:group\{|[`]{3}\s+group)/ @@ -436,8 +443,8 @@ module SiSU_AO_DocumentStructureExtract when /^[`]{3}\s+group/ then :tics else @@flag[:group] #error end - @num_group +=1 - h={ obj: "group text start #{@num_group}" } + @num_id[:group] +=1 + h={ obj: "group text start #{@num_id[:group]}" } t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) tuned_file << t_o elsif t_o =~/^(?:block\{|[`]{3}\s+block)/ @@ -446,8 +453,8 @@ module SiSU_AO_DocumentStructureExtract when /^[`]{3}\s+block/ then :tics else @@flag[:block] #error end - @num_block +=1 - h={ obj: "block text start #{@num_block}" } + @num_id[:block] +=1 + h={ obj: "block text start #{@num_id[:block]}" } t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) tuned_file << t_o elsif t_o =~/^(?:alt\{|[`]{3}\s+alt)/ @@ -456,13 +463,13 @@ module SiSU_AO_DocumentStructureExtract when /^[`]{3}\s+alt/ then :tics else @@flag[:alt] #error end - @num_alt +=1 - h={ obj: "alt text start #{@num_alt}" } + @num_id[:alt] +=1 + h={ obj: "alt text start #{@num_id[:alt]}" } t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) tuned_file << t_o elsif t_o =~/^(?:table\{|[`]{3}\s+table|\{table)[ ~]/ - @num_table +=1 - h={ obj: "table start #{@num_table}" } + @num_id[:table] +=1 + h={ obj: "table start #{@num_id[:table]}" } ins=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) tuned_file << ins if t_o=~/^table\{(?:~h)?\s+/ @@ -516,10 +523,10 @@ module SiSU_AO_DocumentStructureExtract width=100.00/cols cols.times { col << width } end - h={ head_: hd, cols: cols, widths: col, obj: rows, idx: idx, tags: tags, num: @num_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: "table end #{@num_table}" } + h={ obj: "table end #{@num_id[:table]}" } t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) t_o elsif t_o=~/^[`]{3}\s+table(?:~h)?\s+/ @@ -539,10 +546,10 @@ module SiSU_AO_DocumentStructureExtract r=r.gsub(/\s*\|\s*/m,"#{Mx[:tc_p]}") #r.gsub!(/\|/m,"#{Mx[:tc_p]}") rows += r + Mx[:tc_c] end - h={ head_: hd, cols: col.length, widths: col, obj: rows, idx: idx, tags: tags, num: @num_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: "table end #{@num_table}" } + h={ obj: "table end #{@num_id[:table]}" } t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) t_o elsif t_o=~/^\{table(?:~h)?\s+/ @@ -562,10 +569,10 @@ module SiSU_AO_DocumentStructureExtract r=r.gsub(/\s*\|\s*/m,"#{Mx[:tc_p]}") #r.gsub!(/\|/m,"#{Mx[:tc_p]}") rows += r + Mx[:tc_c] end - h={ head_: hd, cols: col.length, widths: col, obj: rows, idx: idx, tags: tags, num: @num_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: "table end #{@num_table}" } + h={ obj: "table end #{@num_id[:table]}" } t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) t_o end @@ -583,7 +590,7 @@ module SiSU_AO_DocumentStructureExtract t_o=SiSU_AO_DocumentStructure::ObjectTable.new.table(@h) tuned_file << t_o @h,@rows=nil,'' - h={ obj: "table end #{@num_table}" } + h={ obj: "table end #{@num_id[:table]}" } t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) t_o else @@ -603,11 +610,11 @@ 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_code_block, number_: @codeblock_numbered } + h={ obj: obj, tags: tags, num: @num_id[:code_block], number_: @codeblock_numbered } t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.code(h) @tuned_code=[] tuned_file << t_o - h={ obj: "code block end #{@num_code_block}" } + h={ obj: "code block end #{@num_id[:code_block]}" } t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) end if (@@flag[:code]==:curls or @@flag[:code]==:tics) \ @@ -626,37 +633,37 @@ module SiSU_AO_DocumentStructureExtract if (@@flag[:poem]==:curls and t_o =~/^\}poem/) \ or (@@flag[:poem]==:tics and t_o =~/^[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) @@flag[:poem]=:off - h={ obj: "poem end #{@num_poem}" } + h={ obj: "poem end #{@num_id[:poem]}" } t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) elsif (@@flag[:group]==:curls and t_o =~/^\}group/) \ or (@@flag[:group]==:tics and t_o =~/^[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) @@flag[:group]=:off obj,tags=extract_tags(@tuned_block.join("\n")) - h={ obj: obj, tags: tags, num: @num_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: "group text end #{@num_group}" } + h={ obj: "group text end #{@num_id[:group]}" } t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) elsif (@@flag[:block]==:curls and t_o =~/^\}block/) \ or (@@flag[:block]==:tics and t_o =~/^[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) @@flag[:block]=:off obj,tags=extract_tags(@tuned_block.join("\n")) - h={ obj: obj, tags: tags, num: @num_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: "block text end #{@num_block}" } + h={ obj: "block text end #{@num_id[:block]}" } t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) elsif (@@flag[:alt]==:curls and t_o =~/^\}alt/) \ or (@@flag[:alt]==:tics and t_o =~/^[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) @@flag[:alt]=:off obj,tags=extract_tags(@tuned_block.join("\n")) - h={ obj: obj, tags: tags, num: @num_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: "alt text end #{@num_alt}" } + h={ obj: "alt text end #{@num_id[:alt]}" } t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) end if (@@flag[:poem]==:curls or @@flag[:poem]==:tics \ @@ -673,7 +680,7 @@ module SiSU_AO_DocumentStructureExtract poem.each do |v| v=v.gsub(/\n/m,"#{Mx[:br_nl]}\n") obj,tags=extract_tags(v) - h={ obj: obj, tags: tags, num: @num_poem } + h={ obj: obj, tags: tags, num: @num_id[:poem] } t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.verse(h) tuned_file << t_o end diff --git a/lib/sisu/v6/ao_doc_str.rb b/lib/sisu/v6/ao_doc_str.rb index db340aa3..ebee81aa 100644 --- a/lib/sisu/v6/ao_doc_str.rb +++ b/lib/sisu/v6/ao_doc_str.rb @@ -225,7 +225,14 @@ module SiSU_AO_DocumentStructureExtract def identify_parts tuned_file=[] @tuned_block,@tuned_code=[],[] - @@counter,@verse_count,@num_code_block,@num_poem,@num_group,@num_block,@num_alt,@num_table=0,0,0,0,0,0,0,0 + @@counter,@verse_count=0,0 + @num_id={ + code_block: 0, + poem: 0, + group: 0, + alt: 0, + table: 0, + } @metadata={} @data.each do |t_o| if t_o =~/^--([+~-])[#]$/ @@ -417,8 +424,8 @@ module SiSU_AO_DocumentStructureExtract end @@counter=1 @codeblock_numbered=(t_o =~/^(?:code\{#|[`]{3}\s+code\s[#])/) ? true : false - @num_code_block +=1 - h={ obj: "code block start #{@num_code_block}" } + @num_id[:code_block] +=1 + h={ obj: "code block start #{@num_id[:code_block]}" } t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) elsif t_o =~/^(?:poem\{|[`]{3}\s+poem)/ @@flag[:poem]=case t_o @@ -426,8 +433,8 @@ module SiSU_AO_DocumentStructureExtract when /^[`]{3}\s+poem/ then :tics else @@flag[:poem] #error end - @num_poem +=1 - h={ obj: "poem start #{@num_poem}" } + @num_id[:poem] +=1 + h={ obj: "poem start #{@num_id[:poem]}" } t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) tuned_file << t_o elsif t_o =~/^(?:group\{|[`]{3}\s+group)/ @@ -436,8 +443,8 @@ module SiSU_AO_DocumentStructureExtract when /^[`]{3}\s+group/ then :tics else @@flag[:group] #error end - @num_group +=1 - h={ obj: "group text start #{@num_group}" } + @num_id[:group] +=1 + h={ obj: "group text start #{@num_id[:group]}" } t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) tuned_file << t_o elsif t_o =~/^(?:block\{|[`]{3}\s+block)/ @@ -446,8 +453,8 @@ module SiSU_AO_DocumentStructureExtract when /^[`]{3}\s+block/ then :tics else @@flag[:block] #error end - @num_block +=1 - h={ obj: "block text start #{@num_block}" } + @num_id[:block] +=1 + h={ obj: "block text start #{@num_id[:block]}" } t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) tuned_file << t_o elsif t_o =~/^(?:alt\{|[`]{3}\s+alt)/ @@ -456,13 +463,13 @@ module SiSU_AO_DocumentStructureExtract when /^[`]{3}\s+alt/ then :tics else @@flag[:alt] #error end - @num_alt +=1 - h={ obj: "alt text start #{@num_alt}" } + @num_id[:alt] +=1 + h={ obj: "alt text start #{@num_id[:alt]}" } t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) tuned_file << t_o elsif t_o =~/^(?:table\{|[`]{3}\s+table|\{table)[ ~]/ - @num_table +=1 - h={ obj: "table start #{@num_table}" } + @num_id[:table] +=1 + h={ obj: "table start #{@num_id[:table]}" } ins=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) tuned_file << ins if t_o=~/^table\{(?:~h)?\s+/ @@ -516,10 +523,10 @@ module SiSU_AO_DocumentStructureExtract width=100.00/cols cols.times { col << width } end - h={ head_: hd, cols: cols, widths: col, obj: rows, idx: idx, tags: tags, num: @num_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: "table end #{@num_table}" } + h={ obj: "table end #{@num_id[:table]}" } t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) t_o elsif t_o=~/^[`]{3}\s+table(?:~h)?\s+/ @@ -539,10 +546,10 @@ module SiSU_AO_DocumentStructureExtract r=r.gsub(/\s*\|\s*/m,"#{Mx[:tc_p]}") #r.gsub!(/\|/m,"#{Mx[:tc_p]}") rows += r + Mx[:tc_c] end - h={ head_: hd, cols: col.length, widths: col, obj: rows, idx: idx, tags: tags, num: @num_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: "table end #{@num_table}" } + h={ obj: "table end #{@num_id[:table]}" } t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) t_o elsif t_o=~/^\{table(?:~h)?\s+/ @@ -562,10 +569,10 @@ module SiSU_AO_DocumentStructureExtract r=r.gsub(/\s*\|\s*/m,"#{Mx[:tc_p]}") #r.gsub!(/\|/m,"#{Mx[:tc_p]}") rows += r + Mx[:tc_c] end - h={ head_: hd, cols: col.length, widths: col, obj: rows, idx: idx, tags: tags, num: @num_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: "table end #{@num_table}" } + h={ obj: "table end #{@num_id[:table]}" } t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) t_o end @@ -583,7 +590,7 @@ module SiSU_AO_DocumentStructureExtract t_o=SiSU_AO_DocumentStructure::ObjectTable.new.table(@h) tuned_file << t_o @h,@rows=nil,'' - h={ obj: "table end #{@num_table}" } + h={ obj: "table end #{@num_id[:table]}" } t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) t_o else @@ -603,11 +610,11 @@ 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_code_block, number_: @codeblock_numbered } + h={ obj: obj, tags: tags, num: @num_id[:code_block], number_: @codeblock_numbered } t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.code(h) @tuned_code=[] tuned_file << t_o - h={ obj: "code block end #{@num_code_block}" } + h={ obj: "code block end #{@num_id[:code_block]}" } t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) end if (@@flag[:code]==:curls or @@flag[:code]==:tics) \ @@ -626,37 +633,37 @@ module SiSU_AO_DocumentStructureExtract if (@@flag[:poem]==:curls and t_o =~/^\}poem/) \ or (@@flag[:poem]==:tics and t_o =~/^[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) @@flag[:poem]=:off - h={ obj: "poem end #{@num_poem}" } + h={ obj: "poem end #{@num_id[:poem]}" } t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) elsif (@@flag[:group]==:curls and t_o =~/^\}group/) \ or (@@flag[:group]==:tics and t_o =~/^[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) @@flag[:group]=:off obj,tags=extract_tags(@tuned_block.join("\n")) - h={ obj: obj, tags: tags, num: @num_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: "group text end #{@num_group}" } + h={ obj: "group text end #{@num_id[:group]}" } t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) elsif (@@flag[:block]==:curls and t_o =~/^\}block/) \ or (@@flag[:block]==:tics and t_o =~/^[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) @@flag[:block]=:off obj,tags=extract_tags(@tuned_block.join("\n")) - h={ obj: obj, tags: tags, num: @num_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: "block text end #{@num_block}" } + h={ obj: "block text end #{@num_id[:block]}" } t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) elsif (@@flag[:alt]==:curls and t_o =~/^\}alt/) \ or (@@flag[:alt]==:tics and t_o =~/^[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) @@flag[:alt]=:off obj,tags=extract_tags(@tuned_block.join("\n")) - h={ obj: obj, tags: tags, num: @num_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: "alt text end #{@num_alt}" } + h={ obj: "alt text end #{@num_id[:alt]}" } t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) end if (@@flag[:poem]==:curls or @@flag[:poem]==:tics \ @@ -673,7 +680,7 @@ module SiSU_AO_DocumentStructureExtract poem.each do |v| v=v.gsub(/\n/m,"#{Mx[:br_nl]}\n") obj,tags=extract_tags(v) - h={ obj: obj, tags: tags, num: @num_poem } + h={ obj: obj, tags: tags, num: @num_id[:poem] } t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.verse(h) tuned_file << t_o end -- cgit v1.2.3 From afdedc96a518a59a1ab9959e68f4342415ff873d Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Thu, 19 Jun 2014 19:24:15 -0400 Subject: v5 v6: ao, regex match for tics "```" followed by space tweaked --- data/doc/sisu/CHANGELOG_v5 | 3 +- data/doc/sisu/CHANGELOG_v6 | 3 +- lib/sisu/v5/ao_doc_str.rb | 68 ++++++++++++++++++------------------- lib/sisu/v5/ao_expand_insertions.rb | 4 +-- lib/sisu/v5/ao_misc_arrange.rb | 16 ++++----- lib/sisu/v6/ao_doc_str.rb | 68 ++++++++++++++++++------------------- lib/sisu/v6/ao_expand_insertions.rb | 4 +-- lib/sisu/v6/ao_misc_arrange.rb | 16 ++++----- 8 files changed, 92 insertions(+), 90 deletions(-) diff --git a/data/doc/sisu/CHANGELOG_v5 b/data/doc/sisu/CHANGELOG_v5 index 0b449409..61971a6c 100644 --- a/data/doc/sisu/CHANGELOG_v5 +++ b/data/doc/sisu/CHANGELOG_v5 @@ -39,8 +39,9 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_5.4.1.orig.tar.xz sisu_5.4.1-1.dsc * ao, - * code blocks, clean trailing newlines + * regex match for tics "```" followed by space tweaked * turn id numbers (for tags) into a hash + * code blocks, clean trailing newlines * misc, minorish %% 5.4.0.orig.tar.xz (2014-05-25:20/7) diff --git a/data/doc/sisu/CHANGELOG_v6 b/data/doc/sisu/CHANGELOG_v6 index d082de3f..8f374569 100644 --- a/data/doc/sisu/CHANGELOG_v6 +++ b/data/doc/sisu/CHANGELOG_v6 @@ -29,8 +29,9 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_6.0.8.orig.tar.xz sisu_6.0.8-1.dsc * ao, - * code blocks, clean trailing newlines + * regex match for tics "```" followed by space tweaked * turn id numbers (for tags) into a hash + * code blocks, clean trailing newlines * misc, minorish %% 6.0.7.orig.tar.xz (2014-05-25:20/7) diff --git a/lib/sisu/v5/ao_doc_str.rb b/lib/sisu/v5/ao_doc_str.rb index 8f708803..ec925018 100644 --- a/lib/sisu/v5/ao_doc_str.rb +++ b/lib/sisu/v5/ao_doc_str.rb @@ -255,7 +255,7 @@ module SiSU_AO_DocumentStructureExtract 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 !~/^[`]{3}\s+(?:code|poem|alt|group|block|table)|^[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/ \ + and t_o !~/^```[ ]+(?:code|poem|alt|group|block|table)|^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/ \ and @@flag[:code]==:off \ and @@flag[:poem]==:off \ and @@flag[:group]==:off \ @@ -416,58 +416,58 @@ module SiSU_AO_DocumentStructureExtract end end elsif @@flag[:code]==:off - if t_o =~/^(?:code\{|[`]{3}\s+code)/ + if t_o =~/^(?:code\{|```[ ]+code)/ @@flag[:code]=case t_o when /^code\{/ then :curls - when /^[`]{3}\s+code/ then :tics + when /^```[ ]+code/ then :tics else @@flag[:code] #error end @@counter=1 - @codeblock_numbered=(t_o =~/^(?:code\{#|[`]{3}\s+code\s[#])/) ? true : false + @codeblock_numbered=(t_o =~/^(?:code\{#|```[ ]+code\s[#])/) ? true : false @num_id[:code_block] +=1 h={ obj: "code block start #{@num_id[:code_block]}" } t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) - elsif t_o =~/^(?:poem\{|[`]{3}\s+poem)/ + elsif t_o =~/^(?:poem\{|```[ ]+poem)/ @@flag[:poem]=case t_o - when /^poem\{/ then :curls - when /^[`]{3}\s+poem/ then :tics - else @@flag[:poem] #error + when /^poem\{/ then :curls + when /^```[ ]+poem/ then :tics + 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) tuned_file << t_o - elsif t_o =~/^(?:group\{|[`]{3}\s+group)/ + elsif t_o =~/^(?:group\{|```[ ]+group)/ @@flag[:group]=case t_o - when /^group\{/ then :curls - when /^[`]{3}\s+group/ then :tics - else @@flag[:group] #error + when /^group\{/ then :curls + when /^```[ ]+group/ then :tics + 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) tuned_file << t_o - elsif t_o =~/^(?:block\{|[`]{3}\s+block)/ + elsif t_o =~/^(?:block\{|```[ ]+block)/ @@flag[:block]=case t_o - when /^block\{/ then :curls - when /^[`]{3}\s+block/ then :tics - else @@flag[:block] #error + when /^block\{/ then :curls + when /^```[ ]+block/ then :tics + 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) tuned_file << t_o - elsif t_o =~/^(?:alt\{|[`]{3}\s+alt)/ + elsif t_o =~/^(?:alt\{|```[ ]+alt)/ @@flag[:alt]=case t_o when /^alt\{/ then :curls - when /^[`]{3}\s+alt/ then :tics + when /^```[ ]+alt/ then :tics 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) tuned_file << t_o - elsif t_o =~/^(?:table\{|[`]{3}\s+table|\{table)[ ~]/ + 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) @@ -486,15 +486,15 @@ module SiSU_AO_DocumentStructureExtract heading=false end @h={ head_: heading, cols: cols, widths: col, idx: idx } - elsif t_o=~/^[`]{3}\s+table(?:~h)?\s+c\d+/ + elsif t_o=~/^```[ ]+table(?:~h)?\s+c\d+/ @@flag[:table]=:tics @rows='' case t_o - when /^[`]{3}\s+table~h\s+c(\d+);\s+(.+)/ + when /^```[ ]+table~h\s+c(\d+);\s+(.+)/ cols=$1 col=$2.scan(/\d+/) heading=true - when /^[`]{3}\s+table\s+c(\d+);\s+(.+)/ + when /^```[ ]+table\s+c(\d+);\s+(.+)/ cols=$1 col=$2.scan(/\d+/) heading=false @@ -529,12 +529,12 @@ module SiSU_AO_DocumentStructureExtract h={ obj: "table end #{@num_id[:table]}" } t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) t_o - elsif t_o=~/^[`]{3}\s+table(?:~h)?\s+/ + elsif t_o=~/^```[ ]+table(?:~h)?\s+/ m1,m2,hd=nil,nil,nil h=case t_o - when /^[`]{3}\s+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 /^[`]{3}\s+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,7 +583,7 @@ module SiSU_AO_DocumentStructureExtract if (@@flag[:table]==:curls \ and t_o =~/^\}table/) \ or (@@flag[:table]==:tics \ - and t_o =~/^[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) + 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 } @@ -595,7 +595,7 @@ module SiSU_AO_DocumentStructureExtract t_o else if t_o.is_a?(String) \ - and t_o !~/^(?:table\{|[`]{3}\s+table)/ + 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) gsub(/\n+/m,"#{Mx[:tc_p]}") @rows += t_o + Mx[:tc_c] @@ -605,7 +605,7 @@ module SiSU_AO_DocumentStructureExtract end if @@flag[:code]==:curls or @@flag[:code]==:tics if (@@flag[:code]==:curls and t_o =~/^\}code/) \ - or (@@flag[:code]==:tics and t_o =~/^[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) + or (@@flag[:code]==:tics and t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) @@flag[:code]=:off @tuned_code[-1].gsub!(/\s*(?:#{Mx[:br_line]}|#{Mx[:br_nl]})\s*\Z/m,'') obj=@tuned_code.join("\n") @@ -631,12 +631,12 @@ module SiSU_AO_DocumentStructureExtract or (@@flag[:block]==:curls or @@flag[:block]==:tics) \ or (@@flag[:alt]==:curls or @@flag[:alt]==:tics) if (@@flag[:poem]==:curls and t_o =~/^\}poem/) \ - or (@@flag[:poem]==:tics and t_o =~/^[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) + 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) elsif (@@flag[:group]==:curls and t_o =~/^\}group/) \ - or (@@flag[:group]==:tics and t_o =~/^[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) + 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] } @@ -646,7 +646,7 @@ module SiSU_AO_DocumentStructureExtract h={ obj: "group text end #{@num_id[:group]}" } t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) elsif (@@flag[:block]==:curls and t_o =~/^\}block/) \ - or (@@flag[:block]==:tics and t_o =~/^[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) + 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] } @@ -656,7 +656,7 @@ module SiSU_AO_DocumentStructureExtract h={ obj: "block text end #{@num_id[:block]}" } t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) elsif (@@flag[:alt]==:curls and t_o =~/^\}alt/) \ - or (@@flag[:alt]==:tics and t_o =~/^[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) + 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] } @@ -671,7 +671,7 @@ module SiSU_AO_DocumentStructureExtract 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 !~/^[`]{3}\s+(?:code|poem|alt|group|block)|^[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/ # fix logic + and t_o !~/^```[ ]+(?:code|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 @@ -759,7 +759,7 @@ module SiSU_AO_DocumentStructureExtract lines.each do |line| line=if line =~/\S/ \ and line !~/^(?:code\{|\}code)/ \ - and line !~/^(?:[`]{3}\s+code|[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$)/ \ + and line !~/^(?:```[ ]+code|```(?:\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}"). diff --git a/lib/sisu/v5/ao_expand_insertions.rb b/lib/sisu/v5/ao_expand_insertions.rb index 60117e1d..ea499119 100644 --- a/lib/sisu/v5/ao_expand_insertions.rb +++ b/lib/sisu/v5/ao_expand_insertions.rb @@ -333,9 +333,9 @@ module SiSU_AO_Insertions tuned_file,tuned_file_tmp=[],[] codeblock_=false data.each do |para| - codeblock_=if para =~/^(?:code\{|[`]{3}\s+code)/ + codeblock_=if para =~/^(?:code\{|```[ ]+code)/ true - elsif para =~/^(?:\}code|[`]{3}(?:\s|$))/m + elsif para =~/^(?:\}code|```(?:\s|$))/m false else codeblock_ end diff --git a/lib/sisu/v5/ao_misc_arrange.rb b/lib/sisu/v5/ao_misc_arrange.rb index caf3326c..03d1e735 100644 --- a/lib/sisu/v5/ao_misc_arrange.rb +++ b/lib/sisu/v5/ao_misc_arrange.rb @@ -77,22 +77,22 @@ module SiSU_AO_MiscArrangeText def code_blocks(para) def ticks(para) block_open,block_close,text=nil,nil,nil - if para =~/\A[`]{3}\s+.+?\n.+?\n[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*\Z/m - block_open,text,block_close=/\A([`]{3}\s+.+?)\n(.+?)\n([`]{3}(\s+[~-][#]|\s+\~\{.+?\}\~)?)\s*\Z/m.match(para)[1..3] - ((para=~/^[`]{3}\s+table(?:~h)?\s+/) \ - and (para !~/^[`]{3}\s+table(?:~h)?\s+c\d+/)) \ + if para =~/\A```[ ]+.+?\n.+?\n```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*\Z/m + block_open,text,block_close=/\A(```[ ]+.+?)\n(.+?)\n(```(\s+[~-][#]|\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[`]{3}\s+.+?\n.*?\Z/m #look at, study - block_open,text=/\A([`]{3}(?:\s+.+?))\n(.*?)\Z/m.match(para)[1,2] + elsif para =~/\A```[ ]+.+?\n.*?\Z/m #look at, study + block_open,text=/\A(```(?:\s+.+?))\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[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*\Z/m - text,block_close=/\A(.+?)\n([`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?)\s*\Z/m.match(para)[1,2] + elsif para =~/\A.+?\n```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*\Z/m + 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 diff --git a/lib/sisu/v6/ao_doc_str.rb b/lib/sisu/v6/ao_doc_str.rb index ebee81aa..6ddc706a 100644 --- a/lib/sisu/v6/ao_doc_str.rb +++ b/lib/sisu/v6/ao_doc_str.rb @@ -255,7 +255,7 @@ module SiSU_AO_DocumentStructureExtract 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 !~/^[`]{3}\s+(?:code|poem|alt|group|block|table)|^[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/ \ + and t_o !~/^```[ ]+(?:code|poem|alt|group|block|table)|^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/ \ and @@flag[:code]==:off \ and @@flag[:poem]==:off \ and @@flag[:group]==:off \ @@ -416,58 +416,58 @@ module SiSU_AO_DocumentStructureExtract end end elsif @@flag[:code]==:off - if t_o =~/^(?:code\{|[`]{3}\s+code)/ + if t_o =~/^(?:code\{|```[ ]+code)/ @@flag[:code]=case t_o when /^code\{/ then :curls - when /^[`]{3}\s+code/ then :tics + when /^```[ ]+code/ then :tics else @@flag[:code] #error end @@counter=1 - @codeblock_numbered=(t_o =~/^(?:code\{#|[`]{3}\s+code\s[#])/) ? true : false + @codeblock_numbered=(t_o =~/^(?:code\{#|```[ ]+code\s[#])/) ? true : false @num_id[:code_block] +=1 h={ obj: "code block start #{@num_id[:code_block]}" } t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) - elsif t_o =~/^(?:poem\{|[`]{3}\s+poem)/ + elsif t_o =~/^(?:poem\{|```[ ]+poem)/ @@flag[:poem]=case t_o - when /^poem\{/ then :curls - when /^[`]{3}\s+poem/ then :tics - else @@flag[:poem] #error + when /^poem\{/ then :curls + when /^```[ ]+poem/ then :tics + 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) tuned_file << t_o - elsif t_o =~/^(?:group\{|[`]{3}\s+group)/ + elsif t_o =~/^(?:group\{|```[ ]+group)/ @@flag[:group]=case t_o - when /^group\{/ then :curls - when /^[`]{3}\s+group/ then :tics - else @@flag[:group] #error + when /^group\{/ then :curls + when /^```[ ]+group/ then :tics + 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) tuned_file << t_o - elsif t_o =~/^(?:block\{|[`]{3}\s+block)/ + elsif t_o =~/^(?:block\{|```[ ]+block)/ @@flag[:block]=case t_o - when /^block\{/ then :curls - when /^[`]{3}\s+block/ then :tics - else @@flag[:block] #error + when /^block\{/ then :curls + when /^```[ ]+block/ then :tics + 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) tuned_file << t_o - elsif t_o =~/^(?:alt\{|[`]{3}\s+alt)/ + elsif t_o =~/^(?:alt\{|```[ ]+alt)/ @@flag[:alt]=case t_o when /^alt\{/ then :curls - when /^[`]{3}\s+alt/ then :tics + when /^```[ ]+alt/ then :tics 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) tuned_file << t_o - elsif t_o =~/^(?:table\{|[`]{3}\s+table|\{table)[ ~]/ + 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) @@ -486,15 +486,15 @@ module SiSU_AO_DocumentStructureExtract heading=false end @h={ head_: heading, cols: cols, widths: col, idx: idx } - elsif t_o=~/^[`]{3}\s+table(?:~h)?\s+c\d+/ + elsif t_o=~/^```[ ]+table(?:~h)?\s+c\d+/ @@flag[:table]=:tics @rows='' case t_o - when /^[`]{3}\s+table~h\s+c(\d+);\s+(.+)/ + when /^```[ ]+table~h\s+c(\d+);\s+(.+)/ cols=$1 col=$2.scan(/\d+/) heading=true - when /^[`]{3}\s+table\s+c(\d+);\s+(.+)/ + when /^```[ ]+table\s+c(\d+);\s+(.+)/ cols=$1 col=$2.scan(/\d+/) heading=false @@ -529,12 +529,12 @@ module SiSU_AO_DocumentStructureExtract h={ obj: "table end #{@num_id[:table]}" } t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) t_o - elsif t_o=~/^[`]{3}\s+table(?:~h)?\s+/ + elsif t_o=~/^```[ ]+table(?:~h)?\s+/ m1,m2,hd=nil,nil,nil h=case t_o - when /^[`]{3}\s+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 /^[`]{3}\s+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,7 +583,7 @@ module SiSU_AO_DocumentStructureExtract if (@@flag[:table]==:curls \ and t_o =~/^\}table/) \ or (@@flag[:table]==:tics \ - and t_o =~/^[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) + 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 } @@ -595,7 +595,7 @@ module SiSU_AO_DocumentStructureExtract t_o else if t_o.is_a?(String) \ - and t_o !~/^(?:table\{|[`]{3}\s+table)/ + 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) gsub(/\n+/m,"#{Mx[:tc_p]}") @rows += t_o + Mx[:tc_c] @@ -605,7 +605,7 @@ module SiSU_AO_DocumentStructureExtract end if @@flag[:code]==:curls or @@flag[:code]==:tics if (@@flag[:code]==:curls and t_o =~/^\}code/) \ - or (@@flag[:code]==:tics and t_o =~/^[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) + or (@@flag[:code]==:tics and t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) @@flag[:code]=:off @tuned_code[-1].gsub!(/\s*(?:#{Mx[:br_line]}|#{Mx[:br_nl]})\s*\Z/m,'') obj=@tuned_code.join("\n") @@ -631,12 +631,12 @@ module SiSU_AO_DocumentStructureExtract or (@@flag[:block]==:curls or @@flag[:block]==:tics) \ or (@@flag[:alt]==:curls or @@flag[:alt]==:tics) if (@@flag[:poem]==:curls and t_o =~/^\}poem/) \ - or (@@flag[:poem]==:tics and t_o =~/^[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) + 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) elsif (@@flag[:group]==:curls and t_o =~/^\}group/) \ - or (@@flag[:group]==:tics and t_o =~/^[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) + 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] } @@ -646,7 +646,7 @@ module SiSU_AO_DocumentStructureExtract h={ obj: "group text end #{@num_id[:group]}" } t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) elsif (@@flag[:block]==:curls and t_o =~/^\}block/) \ - or (@@flag[:block]==:tics and t_o =~/^[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) + 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] } @@ -656,7 +656,7 @@ module SiSU_AO_DocumentStructureExtract h={ obj: "block text end #{@num_id[:block]}" } t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) elsif (@@flag[:alt]==:curls and t_o =~/^\}alt/) \ - or (@@flag[:alt]==:tics and t_o =~/^[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) + 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] } @@ -671,7 +671,7 @@ module SiSU_AO_DocumentStructureExtract 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 !~/^[`]{3}\s+(?:code|poem|alt|group|block)|^[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/ # fix logic + and t_o !~/^```[ ]+(?:code|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 @@ -759,7 +759,7 @@ module SiSU_AO_DocumentStructureExtract lines.each do |line| line=if line =~/\S/ \ and line !~/^(?:code\{|\}code)/ \ - and line !~/^(?:[`]{3}\s+code|[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$)/ \ + and line !~/^(?:```[ ]+code|```(?:\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}"). diff --git a/lib/sisu/v6/ao_expand_insertions.rb b/lib/sisu/v6/ao_expand_insertions.rb index 65386c48..6b1e642d 100644 --- a/lib/sisu/v6/ao_expand_insertions.rb +++ b/lib/sisu/v6/ao_expand_insertions.rb @@ -333,9 +333,9 @@ module SiSU_AO_Insertions tuned_file,tuned_file_tmp=[],[] codeblock_=false data.each do |para| - codeblock_=if para =~/^(?:code\{|[`]{3}\s+code)/ + codeblock_=if para =~/^(?:code\{|```[ ]+code)/ true - elsif para =~/^(?:\}code|[`]{3}(?:\s|$))/m + elsif para =~/^(?:\}code|```(?:\s|$))/m false else codeblock_ end diff --git a/lib/sisu/v6/ao_misc_arrange.rb b/lib/sisu/v6/ao_misc_arrange.rb index a2cbb6c1..d30176bf 100644 --- a/lib/sisu/v6/ao_misc_arrange.rb +++ b/lib/sisu/v6/ao_misc_arrange.rb @@ -77,22 +77,22 @@ module SiSU_AO_MiscArrangeText def code_blocks(para) def ticks(para) block_open,block_close,text=nil,nil,nil - if para =~/\A[`]{3}\s+.+?\n.+?\n[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*\Z/m - block_open,text,block_close=/\A([`]{3}\s+.+?)\n(.+?)\n([`]{3}(\s+[~-][#]|\s+\~\{.+?\}\~)?)\s*\Z/m.match(para)[1..3] - ((para=~/^[`]{3}\s+table(?:~h)?\s+/) \ - and (para !~/^[`]{3}\s+table(?:~h)?\s+c\d+/)) \ + if para =~/\A```[ ]+.+?\n.+?\n```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*\Z/m + block_open,text,block_close=/\A(```[ ]+.+?)\n(.+?)\n(```(\s+[~-][#]|\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[`]{3}\s+.+?\n.*?\Z/m #look at, study - block_open,text=/\A([`]{3}(?:\s+.+?))\n(.*?)\Z/m.match(para)[1,2] + elsif para =~/\A```[ ]+.+?\n.*?\Z/m #look at, study + block_open,text=/\A(```(?:\s+.+?))\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[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*\Z/m - text,block_close=/\A(.+?)\n([`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?)\s*\Z/m.match(para)[1,2] + elsif para =~/\A.+?\n```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*\Z/m + 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 -- cgit v1.2.3 From 46410b13582eaadee20eac8e26b3d7f19966c57e Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Thu, 19 Jun 2014 19:27:29 -0400 Subject: v5 v6: ao, Symbol to match grouped text open & close (instead of String) --- data/doc/sisu/CHANGELOG_v5 | 1 + data/doc/sisu/CHANGELOG_v6 | 1 + lib/sisu/v5/ao_doc_objects.rb | 2 +- lib/sisu/v5/ao_doc_str.rb | 66 +++++++++++++++++++++---------------------- lib/sisu/v6/ao_doc_objects.rb | 2 +- lib/sisu/v6/ao_doc_str.rb | 66 +++++++++++++++++++++---------------------- 6 files changed, 70 insertions(+), 68 deletions(-) diff --git a/data/doc/sisu/CHANGELOG_v5 b/data/doc/sisu/CHANGELOG_v5 index 61971a6c..010b9189 100644 --- a/data/doc/sisu/CHANGELOG_v5 +++ b/data/doc/sisu/CHANGELOG_v5 @@ -40,6 +40,7 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_5.4.1.orig.tar.xz * ao, * regex match for tics "```" followed by space tweaked + * Symbol to match grouped text open & close (instead of String) * turn id numbers (for tags) into a hash * code blocks, clean trailing newlines * misc, minorish diff --git a/data/doc/sisu/CHANGELOG_v6 b/data/doc/sisu/CHANGELOG_v6 index 8f374569..ed9bac41 100644 --- a/data/doc/sisu/CHANGELOG_v6 +++ b/data/doc/sisu/CHANGELOG_v6 @@ -30,6 +30,7 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_6.0.8.orig.tar.xz * ao, * regex match for tics "```" followed by space tweaked + * Symbol to match grouped text open & close (instead of String) * turn id numbers (for tags) into a hash * code blocks, clean trailing newlines * misc, minorish diff --git a/lib/sisu/v5/ao_doc_objects.rb b/lib/sisu/v5/ao_doc_objects.rb index cd0d196c..c53c60d6 100644 --- a/lib/sisu/v5/ao_doc_objects.rb +++ b/lib/sisu/v5/ao_doc_objects.rb @@ -421,7 +421,7 @@ module SiSU_AO_DocumentStructure 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) node= h[:node] || ((defined? o.node) ? o.node : nil) #[Node relationship doc structure info] - status= h[:status] || ((defined? o.status) ? o.status : nil) #tag status open or close + status= h[:status] || ((defined? o.status) ? o.status : nil) #tag status Symbol :open or :close tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use @of,@is,@obj,@status,@node,@lv,@ln,@lc,@tmp=of,is,obj,status,node,lv,ln,lc,tmp self diff --git a/lib/sisu/v5/ao_doc_str.rb b/lib/sisu/v5/ao_doc_str.rb index ec925018..43fa8e5e 100644 --- a/lib/sisu/v5/ao_doc_str.rb +++ b/lib/sisu/v5/ao_doc_str.rb @@ -425,8 +425,8 @@ module SiSU_AO_DocumentStructureExtract @@counter=1 @codeblock_numbered=(t_o =~/^(?:code\{#|```[ ]+code\s[#])/) ? true : false @num_id[:code_block] +=1 - h={ obj: "code block 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] } + t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) elsif t_o =~/^(?:poem\{|```[ ]+poem)/ @@flag[:poem]=case t_o when /^poem\{/ then :curls @@ -1274,7 +1274,7 @@ 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" @@ -1351,7 +1351,7 @@ SKIPPED processing file: [#{@md.opt.lng}] "#{@md.fns}"} tuned_file=tuned_file.flatten end def tags(o) - tag=(o[:status]=='open') \ + tag=(o[:status]==:open) \ ? %{<#{o[:lv]} id="#{o[:node]}">} : "" ln=case o[:lv] @@ -1370,7 +1370,7 @@ SKIPPED processing file: [#{@md.opt.lng}] "#{@md.fns}"} SiSU_AO_DocumentStructure::ObjectStructure.new.xml_dom(h) #downstream code utilise else ignore like comments end def tag_open(o,tag) - t={ lv: tag[o.ln], node: o.node, status: 'open' } + t={ lv: tag[o.ln], node: o.node, status: :open } t_o=tags(t) t_o end @@ -1379,121 +1379,121 @@ 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_doc_objects.rb b/lib/sisu/v6/ao_doc_objects.rb index 972a8392..1d95e2c9 100644 --- a/lib/sisu/v6/ao_doc_objects.rb +++ b/lib/sisu/v6/ao_doc_objects.rb @@ -421,7 +421,7 @@ module SiSU_AO_DocumentStructure 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) node= h[:node] || ((defined? o.node) ? o.node : nil) #[Node relationship doc structure info] - status= h[:status] || ((defined? o.status) ? o.status : nil) #tag status open or close + status= h[:status] || ((defined? o.status) ? o.status : nil) #tag status Symbol :open or :close tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use @of,@is,@obj,@status,@node,@lv,@ln,@lc,@tmp=of,is,obj,status,node,lv,ln,lc,tmp self diff --git a/lib/sisu/v6/ao_doc_str.rb b/lib/sisu/v6/ao_doc_str.rb index 6ddc706a..2b2a86fc 100644 --- a/lib/sisu/v6/ao_doc_str.rb +++ b/lib/sisu/v6/ao_doc_str.rb @@ -425,8 +425,8 @@ module SiSU_AO_DocumentStructureExtract @@counter=1 @codeblock_numbered=(t_o =~/^(?:code\{#|```[ ]+code\s[#])/) ? true : false @num_id[:code_block] +=1 - h={ obj: "code block 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] } + t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) elsif t_o =~/^(?:poem\{|```[ ]+poem)/ @@flag[:poem]=case t_o when /^poem\{/ then :curls @@ -1274,7 +1274,7 @@ 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" @@ -1351,7 +1351,7 @@ SKIPPED processing file: [#{@md.opt.lng}] "#{@md.fns}"} tuned_file=tuned_file.flatten end def tags(o) - tag=(o[:status]=='open') \ + tag=(o[:status]==:open) \ ? %{<#{o[:lv]} id="#{o[:node]}">} : "" ln=case o[:lv] @@ -1370,7 +1370,7 @@ SKIPPED processing file: [#{@md.opt.lng}] "#{@md.fns}"} SiSU_AO_DocumentStructure::ObjectStructure.new.xml_dom(h) #downstream code utilise else ignore like comments end def tag_open(o,tag) - t={ lv: tag[o.ln], node: o.node, status: 'open' } + t={ lv: tag[o.ln], node: o.node, status: :open } t_o=tags(t) t_o end @@ -1379,121 +1379,121 @@ 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 -- cgit v1.2.3 From 64d8e1b14101d973d4412bf50b24be8cfb425627 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Thu, 19 Jun 2014 19:28:58 -0400 Subject: v5 v6: ao, introduce way of removing unrecognized tic markers * this is to provide some forward compatibility with new markup (unrecognized new tic marks are removed) * noisy, reports to screen on tics that are to be removed, unless quiet is on * review --- data/doc/sisu/CHANGELOG_v5 | 1 + data/doc/sisu/CHANGELOG_v6 | 1 + lib/sisu/v5/ao_misc_arrange.rb | 37 +++++++++++++++++++++++++++---------- lib/sisu/v6/ao_misc_arrange.rb | 37 +++++++++++++++++++++++++++---------- 4 files changed, 56 insertions(+), 20 deletions(-) diff --git a/data/doc/sisu/CHANGELOG_v5 b/data/doc/sisu/CHANGELOG_v5 index 010b9189..74dd197e 100644 --- a/data/doc/sisu/CHANGELOG_v5 +++ b/data/doc/sisu/CHANGELOG_v5 @@ -41,6 +41,7 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_5.4.1.orig.tar.xz * ao, * regex match for tics "```" followed by space tweaked * Symbol to match grouped text open & close (instead of String) + * introduce way of removing unrecognized tic markers * turn id numbers (for tags) into a hash * code blocks, clean trailing newlines * misc, minorish diff --git a/data/doc/sisu/CHANGELOG_v6 b/data/doc/sisu/CHANGELOG_v6 index ed9bac41..ce7b2e89 100644 --- a/data/doc/sisu/CHANGELOG_v6 +++ b/data/doc/sisu/CHANGELOG_v6 @@ -31,6 +31,7 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_6.0.8.orig.tar.xz * ao, * regex match for tics "```" followed by space tweaked * Symbol to match grouped text open & close (instead of String) + * introduce way of removing unrecognized tic markers * turn id numbers (for tags) into a hash * code blocks, clean trailing newlines * misc, minorish diff --git a/lib/sisu/v5/ao_misc_arrange.rb b/lib/sisu/v5/ao_misc_arrange.rb index 03d1e735..419241e1 100644 --- a/lib/sisu/v5/ao_misc_arrange.rb +++ b/lib/sisu/v5/ao_misc_arrange.rb @@ -74,24 +74,28 @@ module SiSU_AO_MiscArrangeText end para end - def code_blocks(para) + def markup_blocks(para) def ticks(para) block_open,block_close,text=nil,nil,nil - if para =~/\A```[ ]+.+?\n.+?\n```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*\Z/m - block_open,text,block_close=/\A(```[ ]+.+?)\n(.+?)\n(```(\s+[~-][#]|\s+\~\{.+?\}\~)?)\s*\Z/m.match(para)[1..3] + if para =~/\A```[ ]+(?:code|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] ((para=~/^```[ ]+table(?:~h)?\s+/) \ and (para !~/^```[ ]+table(?:~h)?\s+c\d+/)) \ ? para : (para=[]; para << block_open << text << block_close) - elsif para =~/\A```[ ]+.+?\n.*?\Z/m #look at, study - block_open,text=/\A(```(?:\s+.+?))\n(.*?)\Z/m.match(para)[1,2] + elsif para =~/\A```[ ]+(?:code|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=[] if not text.to_s.empty? para << block_open << text else para << block_open end - elsif para =~/\A.+?\n```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*\Z/m + 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] para=[] if not text.to_s.empty? @@ -103,6 +107,14 @@ module SiSU_AO_MiscArrangeText end para 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}") + end + para=para.gsub(/```[ ]+\S+[ ]*/m,''). + gsub(/```\s*/m,''). + strip + 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 @@ -129,9 +141,14 @@ module SiSU_AO_MiscArrangeText end para end - para=para =~/^```/m \ - ? ticks(para) - : para + para=if para =~/\A```[ ]+(?:code|poem|alt|group|block|table).*?\n.*?\Z/m \ + or @flag==:open + ticks(para) + elsif para =~/```/m + ticks_remove(para) + else + para + end para=(para =~/^(?:code|poem|alt|group|block|table)\{|^\}(?:code|poem|alt|group|block|table)/m) \ ? curly_braces(para) : para @@ -149,7 +166,7 @@ module SiSU_AO_MiscArrangeText end data.each do |para| para=conditional_headings(para) - data_new << code_blocks(para) + data_new << markup_blocks(para) end data_new=data_new.flatten end diff --git a/lib/sisu/v6/ao_misc_arrange.rb b/lib/sisu/v6/ao_misc_arrange.rb index d30176bf..e58ce72a 100644 --- a/lib/sisu/v6/ao_misc_arrange.rb +++ b/lib/sisu/v6/ao_misc_arrange.rb @@ -74,24 +74,28 @@ module SiSU_AO_MiscArrangeText end para end - def code_blocks(para) + def markup_blocks(para) def ticks(para) block_open,block_close,text=nil,nil,nil - if para =~/\A```[ ]+.+?\n.+?\n```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*\Z/m - block_open,text,block_close=/\A(```[ ]+.+?)\n(.+?)\n(```(\s+[~-][#]|\s+\~\{.+?\}\~)?)\s*\Z/m.match(para)[1..3] + if para =~/\A```[ ]+(?:code|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] ((para=~/^```[ ]+table(?:~h)?\s+/) \ and (para !~/^```[ ]+table(?:~h)?\s+c\d+/)) \ ? para : (para=[]; para << block_open << text << block_close) - elsif para =~/\A```[ ]+.+?\n.*?\Z/m #look at, study - block_open,text=/\A(```(?:\s+.+?))\n(.*?)\Z/m.match(para)[1,2] + elsif para =~/\A```[ ]+(?:code|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=[] if not text.to_s.empty? para << block_open << text else para << block_open end - elsif para =~/\A.+?\n```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*\Z/m + 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] para=[] if not text.to_s.empty? @@ -103,6 +107,14 @@ module SiSU_AO_MiscArrangeText end para 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}") + end + para=para.gsub(/```[ ]+\S+[ ]*/m,''). + gsub(/```\s*/m,''). + strip + 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 @@ -129,9 +141,14 @@ module SiSU_AO_MiscArrangeText end para end - para=para =~/^```/m \ - ? ticks(para) - : para + para=if para =~/\A```[ ]+(?:code|poem|alt|group|block|table).*?\n.*?\Z/m \ + or @flag==:open + ticks(para) + elsif para =~/```/m + ticks_remove(para) + else + para + end para=(para =~/^(?:code|poem|alt|group|block|table)\{|^\}(?:code|poem|alt|group|block|table)/m) \ ? curly_braces(para) : para @@ -149,7 +166,7 @@ module SiSU_AO_MiscArrangeText end data.each do |para| para=conditional_headings(para) - data_new << code_blocks(para) + data_new << markup_blocks(para) end data_new=data_new.flatten end -- cgit v1.2.3 From fa8a138532c5d7ac63094d23e3df335ad08a8206 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Thu, 19 Jun 2014 19:32:00 -0400 Subject: v6: ao, syntax, able optionally to indicate the language syntax of a code block --- data/doc/sisu/CHANGELOG_v6 | 1 + lib/sisu/v6/ao_doc_objects.rb | 7 ++++--- lib/sisu/v6/ao_doc_str.rb | 39 ++++++++++++++++++++++++------------- lib/sisu/v6/ao_expand_insertions.rb | 2 +- lib/sisu/v6/ao_misc_arrange.rb | 18 ++++++++--------- lib/sisu/v6/ao_syntax.rb | 2 +- 6 files changed, 42 insertions(+), 27 deletions(-) diff --git a/data/doc/sisu/CHANGELOG_v6 b/data/doc/sisu/CHANGELOG_v6 index ce7b2e89..3f8f6e29 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.8.orig.tar.xz * regex match for tics "```" followed by space tweaked * Symbol to match grouped text open & close (instead of String) * introduce way of removing unrecognized tic markers + * syntax, able optionally to indicate the language syntax of a code block * turn id numbers (for tags) into a hash * code blocks, clean trailing newlines * misc, minorish diff --git a/lib/sisu/v6/ao_doc_objects.rb b/lib/sisu/v6/ao_doc_objects.rb index 1d95e2c9..9356321c 100644 --- a/lib/sisu/v6/ao_doc_objects.rb +++ b/lib/sisu/v6/ao_doc_objects.rb @@ -240,10 +240,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 +251,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 +265,7 @@ 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 block(h,o=nil) diff --git a/lib/sisu/v6/ao_doc_str.rb b/lib/sisu/v6/ao_doc_str.rb index 2b2a86fc..0d9d7576 100644 --- a/lib/sisu/v6/ao_doc_str.rb +++ b/lib/sisu/v6/ao_doc_str.rb @@ -65,6 +65,7 @@ module SiSU_AO_DocumentStructureExtract @@flag={ ocn: :on, code: :off, + lngsyn: :txt, poem: :off, block: :off, group: :off, @@ -81,6 +82,7 @@ module SiSU_AO_DocumentStructureExtract @@flag={ ocn: :on, code: :off, + lngsyn: :txt, poem: :off, block: :off, group: :off, @@ -254,8 +256,8 @@ 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_]+)?|poem|alt|group|block)\{|^\}(?:code|poem|alt|group|block)|^(?:table\{|\{table)[ ~]/ \ + and t_o !~/^```[ ]+(?:code(?:\.[a-z][0-9a-z_]+)?|poem|alt|group|block|table)|^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/ \ and @@flag[:code]==:off \ and @@flag[:poem]==:off \ and @@flag[:group]==:off \ @@ -416,16 +418,26 @@ module SiSU_AO_DocumentStructureExtract 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: '', sym: :code_block_open, num: @num_id[:code_block] } + 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 @@ -610,7 +622,8 @@ 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 @@ -670,8 +683,8 @@ module SiSU_AO_DocumentStructureExtract 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|alt|group|block)|(?:verse|code(?:\.[a-z][0-9a-z_]+)?|alt|group|block)\{)/ \ + and t_o !~/^```[ ]+(?:code(?:\.[a-z][0-9a-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 @@ -758,8 +771,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}"). diff --git a/lib/sisu/v6/ao_expand_insertions.rb b/lib/sisu/v6/ao_expand_insertions.rb index 6b1e642d..22e3b1ea 100644 --- a/lib/sisu/v6/ao_expand_insertions.rb +++ b/lib/sisu/v6/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/v6/ao_misc_arrange.rb b/lib/sisu/v6/ao_misc_arrange.rb index e58ce72a..a6b3a73d 100644 --- a/lib/sisu/v6/ao_misc_arrange.rb +++ b/lib/sisu/v6/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_]+)?|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_]+)?|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_]+)?|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=[] @@ -117,12 +117,12 @@ module SiSU_AO_MiscArrangeText 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_]+)?|poem|alt|group|block|table)\{ .+?\n.+?\n\}(?:code|poem|alt|group|block|table)(?: [~-][#])?\s*\Z/m + block_open,text,block_close=/\A((?:code(?:\.[a-z][0-9a-z_]+)?|poem|alt|group|block|table)\{ .+?)\n(.+?)\n(\}(?:code|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_]+)?|poem|alt|group|block|table)\{ .+?\n.+?\Z/m + block_open,text=/\A((?:code(?:\.[a-z][0-9a-z_]+)?|poem|alt|group|block|table)\{ .+?)\n(.+?)\Z/m.match(para)[1,2] para=[] if not text.to_s.empty? para << block_open << text @@ -141,7 +141,7 @@ module SiSU_AO_MiscArrangeText end para end - para=if para =~/\A```[ ]+(?:code|poem|alt|group|block|table).*?\n.*?\Z/m \ + para=if para =~/\A```[ ]+(?:code(?:\.[a-z][0-9a-z_]+)?|poem|alt|group|block|table).*?\n.*?\Z/m \ or @flag==:open ticks(para) elsif para =~/```/m @@ -149,7 +149,7 @@ module SiSU_AO_MiscArrangeText else para end - para=(para =~/^(?:code|poem|alt|group|block|table)\{|^\}(?:code|poem|alt|group|block|table)/m) \ + para=(para =~/^(?:code(?:\.[a-z][0-9a-z_]+)?|poem|alt|group|block|table)\{|^\}(?:code|poem|alt|group|block|table)/m) \ ? curly_braces(para) : para end diff --git a/lib/sisu/v6/ao_syntax.rb b/lib/sisu/v6/ao_syntax.rb index 8a13e406..fb3508b9 100644 --- a/lib/sisu/v6/ao_syntax.rb +++ b/lib/sisu/v6/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_]+)?|block|group|alt|verse)(?:-end)?#{Mx[:gr_c]}|#{Mx[:fa_o]}:br#{Mx[:fa_c]}} @manmkp_ital=emph_italics \ ? '[i/*]\\{.+?\\}[i/*]' : '[i/]\\{.+?\\}[i/]' -- cgit v1.2.3 From dffa2293ca33039bc9a625c23842644104fcf401 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Thu, 19 Jun 2014 19:33:41 -0400 Subject: v6: ao, syntax, introduce box text block/group --- data/doc/sisu/CHANGELOG_v6 | 1 + lib/sisu/v6/ao_doc_objects.rb | 20 ++++++++++++++++++++ lib/sisu/v6/ao_doc_str.rb | 37 +++++++++++++++++++++++++++++++++---- lib/sisu/v6/ao_misc_arrange.rb | 22 +++++++++++----------- lib/sisu/v6/ao_syntax.rb | 2 +- 5 files changed, 66 insertions(+), 16 deletions(-) diff --git a/data/doc/sisu/CHANGELOG_v6 b/data/doc/sisu/CHANGELOG_v6 index 3f8f6e29..04248097 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.8.orig.tar.xz * Symbol to match grouped text open & close (instead of String) * introduce way of removing unrecognized tic markers * syntax, able optionally to indicate the language syntax of a code block + * syntax, introduce box text block/group * turn id numbers (for tags) into a hash * code blocks, clean trailing newlines * misc, minorish diff --git a/lib/sisu/v6/ao_doc_objects.rb b/lib/sisu/v6/ao_doc_objects.rb index 9356321c..e1a14da1 100644 --- a/lib/sisu/v6/ao_doc_objects.rb +++ b/lib/sisu/v6/ao_doc_objects.rb @@ -268,6 +268,26 @@ module SiSU_AO_DocumentStructure @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) of= @of #Symbol, classification - group is= :block #Symbol, classification - specific type diff --git a/lib/sisu/v6/ao_doc_str.rb b/lib/sisu/v6/ao_doc_str.rb index 0d9d7576..cd4f62e8 100644 --- a/lib/sisu/v6/ao_doc_str.rb +++ b/lib/sisu/v6/ao_doc_str.rb @@ -68,6 +68,7 @@ module SiSU_AO_DocumentStructureExtract lngsyn: :txt, poem: :off, block: :off, + box: :off, group: :off, alt: :off, table: :off, @@ -85,6 +86,7 @@ module SiSU_AO_DocumentStructureExtract lngsyn: :txt, poem: :off, block: :off, + box: :off, group: :off, alt: :off, table: :off, @@ -231,6 +233,7 @@ module SiSU_AO_DocumentStructureExtract @num_id={ code_block: 0, poem: 0, + box: 0, group: 0, alt: 0, table: 0, @@ -256,13 +259,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(?:\.[a-z][0-9a-z_]+)?|poem|alt|group|block)\{|^\}(?:code|poem|alt|group|block)|^(?:table\{|\{table)[ ~]/ \ - and t_o !~/^```[ ]+(?:code(?:\.[a-z][0-9a-z_]+)?|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*$/ \ 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 @@ -449,6 +453,16 @@ module SiSU_AO_DocumentStructureExtract h={ obj: "poem start #{@num_id[:poem]}" } t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(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: "box text start #{@num_id[:box]}" } + t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) + tuned_file << t_o elsif t_o =~/^(?:group\{|```[ ]+group)/ @@flag[:group]=case t_o when /^group\{/ then :curls @@ -640,6 +654,7 @@ 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) @@ -648,6 +663,16 @@ module SiSU_AO_DocumentStructureExtract @@flag[:poem]=:off h={ obj: "poem end #{@num_id[:poem]}" } t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(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: "box text end #{@num_id[:box]}" } + t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) elsif (@@flag[:group]==:curls and t_o =~/^\}group/) \ or (@@flag[:group]==:tics and t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) @@flag[:group]=:off @@ -683,8 +708,8 @@ module SiSU_AO_DocumentStructureExtract 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(?:\.[a-z][0-9a-z_]+)?|alt|group|block)\{)/ \ - and t_o !~/^```[ ]+(?:code(?:\.[a-z][0-9a-z_]+)?|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 @@ -705,6 +730,7 @@ 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 if t_o.is_a?(String) @@ -715,6 +741,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}"). @@ -1203,6 +1230,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 @@ -1250,6 +1278,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/v6/ao_misc_arrange.rb b/lib/sisu/v6/ao_misc_arrange.rb index a6b3a73d..9279f888 100644 --- a/lib/sisu/v6/ao_misc_arrange.rb +++ b/lib/sisu/v6/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(?:\.[a-z][0-9a-z_]+)?|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(?:\.[a-z][0-9a-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 : (para=[]; para << block_open << text << block_close) - elsif para =~/\A```[ ]+(?:code(?:\.[a-z][0-9a-z_]+)?|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=[] @@ -117,20 +117,20 @@ module SiSU_AO_MiscArrangeText end def curly_braces(para) block_open,block_close,text=nil,nil,nil - para=if para =~/\A(?:code(?:\.[a-z][0-9a-z_]+)?|poem|alt|group|block|table)\{ .+?\n.+?\n\}(?:code|poem|alt|group|block|table)(?: [~-][#])?\s*\Z/m - block_open,text,block_close=/\A((?:code(?:\.[a-z][0-9a-z_]+)?|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(?:\.[a-z][0-9a-z_]+)?|poem|alt|group|block|table)\{ .+?\n.+?\Z/m - block_open,text=/\A((?:code(?:\.[a-z][0-9a-z_]+)?|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 +141,7 @@ module SiSU_AO_MiscArrangeText end para end - para=if para =~/\A```[ ]+(?:code(?:\.[a-z][0-9a-z_]+)?|poem|alt|group|block|table).*?\n.*?\Z/m \ + para=if 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,7 +149,7 @@ module SiSU_AO_MiscArrangeText else para end - para=(para =~/^(?:code(?:\.[a-z][0-9a-z_]+)?|poem|alt|group|block|table)\{|^\}(?:code|poem|alt|group|block|table)/m) \ + para=(para =~/^(?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block|table)\{|^\}(?:code|poem|alt|group|block|table)/m) \ ? curly_braces(para) : para end diff --git a/lib/sisu/v6/ao_syntax.rb b/lib/sisu/v6/ao_syntax.rb index fb3508b9..b30847a8 100644 --- a/lib/sisu/v6/ao_syntax.rb +++ b/lib/sisu/v6/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(?:\.[a-z][0-9a-z_]+)?|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/]' -- cgit v1.2.3 From ac654580ff2d245402eb2bca3d8685a97dd5d1fb Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Thu, 19 Jun 2014 19:36:14 -0400 Subject: v6: ao, syntax, introduce tics quotes markup (blockquote equivalent) --- data/doc/sisu/CHANGELOG_v6 | 1 + data/doc/sisu/sisu.org | 4 ++ lib/sisu/v6/ao_doc_objects.rb | 22 +++++++-- lib/sisu/v6/ao_doc_str.rb | 104 +++++++++++++++++++++++++---------------- lib/sisu/v6/ao_misc_arrange.rb | 30 ++++++++++-- lib/sisu/v6/ao_syntax.rb | 1 + 6 files changed, 113 insertions(+), 49 deletions(-) diff --git a/data/doc/sisu/CHANGELOG_v6 b/data/doc/sisu/CHANGELOG_v6 index 04248097..96ed1f24 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.8.orig.tar.xz * introduce way of removing unrecognized tic markers * 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) * turn id numbers (for tags) into a hash * code blocks, clean trailing newlines * misc, minorish diff --git a/data/doc/sisu/sisu.org b/data/doc/sisu/sisu.org index f8817e68..341cdd52 100644 --- a/data/doc/sisu/sisu.org +++ b/data/doc/sisu/sisu.org @@ -271,6 +271,10 @@ The package is divided into the following components: ``` box:red:"Warn" (select color and lead text of box, else instead select color box & use regular single line bold markup ^!_ Warn$) +*** TODO [#D] blockquotes implement? :feature:ponder: + ``` quote + not sure how best to represent + *** TODO [#D] bibliography :feature:ponder: *** TODO speaker, as e.g. play (irc?) :feature:ponder: diff --git a/lib/sisu/v6/ao_doc_objects.rb b/lib/sisu/v6/ao_doc_objects.rb index e1a14da1..ee229200 100644 --- a/lib/sisu/v6/ao_doc_objects.rb +++ b/lib/sisu/v6/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) @@ -476,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 @@ -498,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/v6/ao_doc_str.rb b/lib/sisu/v6/ao_doc_str.rb index cd4f62e8..7f2815d8 100644 --- a/lib/sisu/v6/ao_doc_str.rb +++ b/lib/sisu/v6/ao_doc_str.rb @@ -71,6 +71,7 @@ module SiSU_AO_DocumentStructureExtract box: :off, group: :off, alt: :off, + quote: :off, table: :off, table_to: :off, } @@ -89,6 +90,7 @@ module SiSU_AO_DocumentStructureExtract box: :off, group: :off, alt: :off, + quote: :off, table: :off, table_to: :off, } @@ -123,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] @@ -236,6 +243,7 @@ module SiSU_AO_DocumentStructureExtract box: 0, group: 0, alt: 0, + quote: 0, table: 0, } @metadata={} @@ -260,7 +268,7 @@ module SiSU_AO_DocumentStructureExtract end t_o=t_o.gsub(/(?:\n\s*\n)+/m,"\n") if @@flag[:code]==:off 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*$/ \ + 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 \ @@ -370,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 @@ -393,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 @@ -417,7 +425,7 @@ 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 @@ -450,8 +458,8 @@ 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 @@ -460,8 +468,8 @@ module SiSU_AO_DocumentStructureExtract else @@flag[:box] #error end @num_id[:box] +=1 - h={ obj: "box text start #{@num_id[:box]}" } - t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) + 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 @@ -470,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 @@ -480,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 @@ -490,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='' @@ -552,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 @@ -575,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 @@ -598,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 @@ -616,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 @@ -641,8 +655,8 @@ module SiSU_AO_DocumentStructureExtract 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) @@ -657,12 +671,13 @@ module SiSU_AO_DocumentStructureExtract 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 @@ -671,8 +686,8 @@ module SiSU_AO_DocumentStructureExtract @tuned_block=[] t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.box(h) tuned_file << t_o - h={ obj: "box text end #{@num_id[:box]}" } - t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) + 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 @@ -681,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 @@ -691,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 @@ -701,8 +716,16 @@ 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 \ @@ -732,7 +755,8 @@ module SiSU_AO_DocumentStructureExtract 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}"). diff --git a/lib/sisu/v6/ao_misc_arrange.rb b/lib/sisu/v6/ao_misc_arrange.rb index 9279f888..de32f560 100644 --- a/lib/sisu/v6/ao_misc_arrange.rb +++ b/lib/sisu/v6/ao_misc_arrange.rb @@ -115,6 +115,22 @@ 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(?:\.[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 @@ -141,7 +157,11 @@ module SiSU_AO_MiscArrangeText end para end - para=if para =~/\A```[ ]+(?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|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(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|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/v6/ao_syntax.rb b/lib/sisu/v6/ao_syntax.rb index b30847a8..68720aca 100644 --- a/lib/sisu/v6/ao_syntax.rb +++ b/lib/sisu/v6/ao_syntax.rb @@ -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 -- cgit v1.2.3 From 4f5b055e9eb95cc4078cc776398d8239fe65c8ba Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Thu, 19 Jun 2014 19:38:14 -0400 Subject: v6: docbook, tags (name touch) --- lib/sisu/v6/xml_docbook5.rb | 60 ++++++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/lib/sisu/v6/xml_docbook5.rb b/lib/sisu/v6/xml_docbook5.rb index bc4ad233..a835288a 100644 --- a/lib/sisu/v6/xml_docbook5.rb +++ b/lib/sisu/v6/xml_docbook5.rb @@ -135,7 +135,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' @@ -217,7 +217,7 @@ 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 @@ -237,40 +237,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 -- cgit v1.2.3 From e0c38cb8d044e0b3dc449e10d1aa14ef3b6900ad Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Thu, 19 Jun 2014 21:13:06 -0400 Subject: v6: docbook, ocn & footnote numbers (as xml comments) --- data/doc/sisu/CHANGELOG_v6 | 3 +++ lib/sisu/v6/txt_shared.rb | 9 ++++++--- lib/sisu/v6/xml_docbook5.rb | 4 ++-- lib/sisu/v6/xml_shared.rb | 3 ++- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/data/doc/sisu/CHANGELOG_v6 b/data/doc/sisu/CHANGELOG_v6 index 96ed1f24..820995f8 100644 --- a/data/doc/sisu/CHANGELOG_v6 +++ b/data/doc/sisu/CHANGELOG_v6 @@ -39,6 +39,9 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_6.0.8.orig.tar.xz * code blocks, clean trailing newlines * misc, minorish +* docbook, + * ocn & footnote numbers (as xml comments) + %% 6.0.7.orig.tar.xz (2014-05-25:20/7) http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/sisu_6.0.7 http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/debian/sisu_6.0.7-1 diff --git a/lib/sisu/v6/txt_shared.rb b/lib/sisu/v6/txt_shared.rb index 8d2a09b7..3159844f 100644 --- a/lib/sisu/v6/txt_shared.rb +++ b/lib/sisu/v6/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/v6/xml_docbook5.rb b/lib/sisu/v6/xml_docbook5.rb index a835288a..3f5333b2 100644 --- a/lib/sisu/v6/xml_docbook5.rb +++ b/lib/sisu/v6/xml_docbook5.rb @@ -200,7 +200,7 @@ module SiSU_XML_Docbook_Book data.each_with_index do |o,i| if (defined? o.ocn and not o.ocn.nil?) ocn=(@make.build.ocn?) \ - ? "\n#{Dx[:ocn_o]}#{o.ocn}#{Dx[:ocn_c]}" + ? "" : '' id=%{ id="o#{o.ocn}" } else @@ -221,7 +221,7 @@ module SiSU_XML_Docbook_Book #{spaces*o.lc} } end - filename_docbook.puts SiSU_TextUtils::Wrap.new(o.obj + ocn,80,(@splv*2+2)).line_wrap + filename_docbook.puts SiSU_TextUtils::Wrap.new(o.obj,80,(@splv*2+2),nil,ocn).line_wrap filename_docbook.puts %{#{spaces*o.lc}} h=o.lc elsif (o.of ==:para or o.of ==:block) diff --git a/lib/sisu/v6/xml_shared.rb b/lib/sisu/v6/xml_shared.rb index 033659f0..aeb73f22 100644 --- a/lib/sisu/v6/xml_shared.rb +++ b/lib/sisu/v6/xml_shared.rb @@ -460,7 +460,8 @@ 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'). + 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 -- cgit v1.2.3 From beb28d69dcf076b73dda47096353fd7404565fa8 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Thu, 19 Jun 2014 21:14:34 -0400 Subject: v6: docbook, metadata header (docinfo) --- data/doc/sisu/CHANGELOG_v6 | 1 + lib/sisu/v6/shared_metadata.rb | 66 ++++++++++++++++++++++++++++++++++++++++++ lib/sisu/v6/xml_docbook5.rb | 9 ++++++ 3 files changed, 76 insertions(+) diff --git a/data/doc/sisu/CHANGELOG_v6 b/data/doc/sisu/CHANGELOG_v6 index 820995f8..bfa4d5e7 100644 --- a/data/doc/sisu/CHANGELOG_v6 +++ b/data/doc/sisu/CHANGELOG_v6 @@ -41,6 +41,7 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_6.0.8.orig.tar.xz * docbook, * ocn & footnote numbers (as xml comments) + * metadata header (docinfo) %% 6.0.7.orig.tar.xz (2014-05-25:20/7) http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/sisu_6.0.7 diff --git a/lib/sisu/v6/shared_metadata.rb b/lib/sisu/v6/shared_metadata.rb index 1fa57fa7..dae28c6c 100644 --- a/lib/sisu/v6/shared_metadata.rb +++ b/lib/sisu/v6/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/v6/xml_docbook5.rb b/lib/sisu/v6/xml_docbook5.rb index 3f5333b2..75764043 100644 --- a/lib/sisu/v6/xml_docbook5.rb +++ b/lib/sisu/v6/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 @@ -189,6 +190,13 @@ module SiSU_XML_Docbook_Book end #def chapterlevel #end + def xml_head + [ + '', + SiSU_Metadata::Summary.new(@md).xml_docbook.metadata, + '' + ].flatten + end def structure_build_collapsed(data) #output_file=@md.file.output_path.xml_docbook_book.dir + '/' + @md.file.base_filename.xml_docbook_book file=SiSU_Env::FileOp.new(@md) @@ -197,6 +205,7 @@ module SiSU_XML_Docbook_Book @chlv=chlv=0 doc_position=:head filename_docbook.puts head + filename_docbook.puts xml_head data.each_with_index do |o,i| if (defined? o.ocn and not o.ocn.nil?) ocn=(@make.build.ocn?) \ -- cgit v1.2.3 From 16380ed1aa129cb3059b0f5eb23bc1a3f20bf08c Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Thu, 19 Jun 2014 21:15:36 -0400 Subject: v6: docbook, quotes (blockquote) --- data/doc/sisu/CHANGELOG_v6 | 1 + lib/sisu/v6/xml_docbook5.rb | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/data/doc/sisu/CHANGELOG_v6 b/data/doc/sisu/CHANGELOG_v6 index bfa4d5e7..f1c54994 100644 --- a/data/doc/sisu/CHANGELOG_v6 +++ b/data/doc/sisu/CHANGELOG_v6 @@ -42,6 +42,7 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_6.0.8.orig.tar.xz * docbook, * ocn & footnote numbers (as xml comments) * metadata header (docinfo) + * quotes (blockquote) %% 6.0.7.orig.tar.xz (2014-05-25:20/7) http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/sisu_6.0.7 diff --git a/lib/sisu/v6/xml_docbook5.rb b/lib/sisu/v6/xml_docbook5.rb index 75764043..28b7fc4a 100644 --- a/lib/sisu/v6/xml_docbook5.rb +++ b/lib/sisu/v6/xml_docbook5.rb @@ -163,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 @@ -233,6 +233,16 @@ module SiSU_XML_Docbook_Book filename_docbook.puts SiSU_TextUtils::Wrap.new(o.obj,80,(@splv*2+2),nil,ocn).line_wrap filename_docbook.puts %{#{spaces*o.lc}} h=o.lc + 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 ==:para or o.of ==:block) filename_docbook.puts "#{spaces*(@splv)}" filename_docbook.puts SiSU_TextUtils::Wrap.new(o.obj + ocn,80,(@splv*2+2)).line_wrap -- cgit v1.2.3 From 8ed75b2bfd615c863e14b9c540ec15c429c06e98 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Thu, 19 Jun 2014 21:16:33 -0400 Subject: v6: docbook, tables --- data/doc/sisu/CHANGELOG_v6 | 1 + lib/sisu/v6/xml_docbook5.rb | 10 +++++++- lib/sisu/v6/xml_tables.rb | 58 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+), 1 deletion(-) diff --git a/data/doc/sisu/CHANGELOG_v6 b/data/doc/sisu/CHANGELOG_v6 index f1c54994..29f5be22 100644 --- a/data/doc/sisu/CHANGELOG_v6 +++ b/data/doc/sisu/CHANGELOG_v6 @@ -43,6 +43,7 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_6.0.8.orig.tar.xz * ocn & footnote numbers (as xml comments) * metadata header (docinfo) * quotes (blockquote) + * tables %% 6.0.7.orig.tar.xz (2014-05-25:20/7) http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/sisu_6.0.7 diff --git a/lib/sisu/v6/xml_docbook5.rb b/lib/sisu/v6/xml_docbook5.rb index 28b7fc4a..db6e7eb0 100644 --- a/lib/sisu/v6/xml_docbook5.rb +++ b/lib/sisu/v6/xml_docbook5.rb @@ -243,7 +243,15 @@ module SiSU_XML_Docbook_Book unless xml_tag.empty? filename_docbook.puts "#{spaces*(@splv)}#{xml_tag}" end - elsif (o.of ==:para or o.of ==:block) + elsif o.of ==:block + if o.is ==:table + filename_docbook.puts SiSU_Tables::TableXMLdocbook.new(o,id).table.obj + else + filename_docbook.puts "#{spaces*(@splv)}" + filename_docbook.puts SiSU_TextUtils::Wrap.new(o.obj + ocn,80,(@splv*2+2)).line_wrap + 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 filename_docbook.puts "#{spaces*(@splv)}" diff --git a/lib/sisu/v6/xml_tables.rb b/lib/sisu/v6/xml_tables.rb index a994e402..6967bb86 100644 --- a/lib/sisu/v6/xml_tables.rb +++ b/lib/sisu/v6/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: Thu, 19 Jun 2014 21:18:05 -0400 Subject: v6: docbook, images --- data/doc/sisu/CHANGELOG_v6 | 1 + lib/sisu/v6/xml_docbook5.rb | 28 +++++++++++++++++++++++++--- lib/sisu/v6/xml_shared.rb | 3 ++- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/data/doc/sisu/CHANGELOG_v6 b/data/doc/sisu/CHANGELOG_v6 index 29f5be22..9152019a 100644 --- a/data/doc/sisu/CHANGELOG_v6 +++ b/data/doc/sisu/CHANGELOG_v6 @@ -44,6 +44,7 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_6.0.8.orig.tar.xz * metadata header (docinfo) * quotes (blockquote) * tables + * images %% 6.0.7.orig.tar.xz (2014-05-25:20/7) http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/sisu_6.0.7 diff --git a/lib/sisu/v6/xml_docbook5.rb b/lib/sisu/v6/xml_docbook5.rb index db6e7eb0..28fa25ed 100644 --- a/lib/sisu/v6/xml_docbook5.rb +++ b/lib/sisu/v6/xml_docbook5.rb @@ -197,6 +197,28 @@ module SiSU_XML_Docbook_Book '' ].flatten 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 =~/
} end - filename_docbook.puts SiSU_TextUtils::Wrap.new(o.obj,80,(@splv*2+2),nil,ocn).line_wrap + adjust_output(o,ocn,filename_docbook,@splv) filename_docbook.puts %{#{spaces*o.lc}} h=o.lc elsif o.of ==:layout \ @@ -248,12 +270,12 @@ module SiSU_XML_Docbook_Book filename_docbook.puts SiSU_Tables::TableXMLdocbook.new(o,id).table.obj else 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 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 diff --git a/lib/sisu/v6/xml_shared.rb b/lib/sisu/v6/xml_shared.rb index aeb73f22..b1ebc95f 100644 --- a/lib/sisu/v6/xml_shared.rb +++ b/lib/sisu/v6/xml_shared.rb @@ -476,7 +476,8 @@ module SiSU_XML_Munge 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[: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 -- cgit v1.2.3 From e7ce3d1c446e63853068380e7d025ba991817146 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Thu, 19 Jun 2014 21:19:17 -0400 Subject: v6: docbook, code block --- data/doc/sisu/CHANGELOG_v6 | 1 + lib/sisu/v6/xml_docbook5.rb | 9 ++++++++ lib/sisu/v6/xml_shared.rb | 51 ++++++++++++++++++++++++--------------------- 3 files changed, 37 insertions(+), 24 deletions(-) diff --git a/data/doc/sisu/CHANGELOG_v6 b/data/doc/sisu/CHANGELOG_v6 index 9152019a..4945c147 100644 --- a/data/doc/sisu/CHANGELOG_v6 +++ b/data/doc/sisu/CHANGELOG_v6 @@ -45,6 +45,7 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_6.0.8.orig.tar.xz * quotes (blockquote) * tables * images + * code block %% 6.0.7.orig.tar.xz (2014-05-25:20/7) http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/sisu_6.0.7 diff --git a/lib/sisu/v6/xml_docbook5.rb b/lib/sisu/v6/xml_docbook5.rb index 28fa25ed..b3e9e035 100644 --- a/lib/sisu/v6/xml_docbook5.rb +++ b/lib/sisu/v6/xml_docbook5.rb @@ -197,6 +197,9 @@ module SiSU_XML_Docbook_Book '' ].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]}/) @@ -268,6 +271,12 @@ module SiSU_XML_Docbook_Book 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) diff --git a/lib/sisu/v6/xml_shared.rb b/lib/sisu/v6/xml_shared.rb index b1ebc95f..3e8ddf50 100644 --- a/lib/sisu/v6/xml_shared.rb +++ b/lib/sisu/v6/xml_shared.rb @@ -460,30 +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]}(\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) + 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='') -- cgit v1.2.3 From e6ba0168903a66375171344ebbd4209acdb07f14 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Thu, 19 Jun 2014 22:33:06 -0400 Subject: vim syntax, code block, language syntax; box group; quote --- data/doc/sisu/CHANGELOG_v6 | 5 +++++ data/sisu/conf/editor-syntax-etc/vim/syntax/sisu.vim | 15 ++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/data/doc/sisu/CHANGELOG_v6 b/data/doc/sisu/CHANGELOG_v6 index 4945c147..4d324faa 100644 --- a/data/doc/sisu/CHANGELOG_v6 +++ b/data/doc/sisu/CHANGELOG_v6 @@ -47,6 +47,11 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_6.0.8.orig.tar.xz * images * code block +* vim syntax, add + * code block, language syntax, optional + * box block + * quote block + %% 6.0.7.orig.tar.xz (2014-05-25:20/7) http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/sisu_6.0.7 http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/debian/sisu_6.0.7-1 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 d88720f4..03e1766f 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-5.2.0) -" Last Change: 2014-01-06 +" SiSU Markup: SiSU (sisu-6.0.8) +" Last Change: 2014-06-19 " URL: "(originally looked at Ruby Vim by Mirko Nasato) @@ -103,11 +103,16 @@ syn region sisu_content_alt contains=sisu_strikeout,sisu_number,sisu_bold,sisu_c syn region sisu_content_alt contains=sisu_strikeout,sisu_number,sisu_bold,sisu_control,sisu_identifier,sisu_error matchgroup=sisu_contain start="^```\s\+table" end="^```\(\s\|$\)" syn region sisu_content_alt contains=sisu_strikeout,sisu_number,sisu_bold,sisu_control,sisu_identifier,sisu_error matchgroup=sisu_contain start="^{\(t\|table\)\(\~h\)\?\(\sc[0-9]\+;\)\?[0-9; ]*}" end="\n$" " block, group, poem, alt -syn region sisu_content_alt contains=sisu_mark_endnote,sisu_content_endnote,sisu_link,sisu_mark,sisu_strikeout,sisu_number,sisu_control,sisu_identifier,sisu_error matchgroup=sisu_contain start="^\(block\|group\|poem\|alt\){" end="^}\(block\|group\|poem\|alt\)" +syn region sisu_content_alt contains=sisu_mark_endnote,sisu_content_endnote,sisu_link,sisu_mark,sisu_strikeout,sisu_number,sisu_control,sisu_identifier,sisu_error matchgroup=sisu_contain start="^\(block\|group\|poem\|alt\){" end="^}\1" syn region sisu_content_alt contains=sisu_mark_endnote,sisu_content_endnote,sisu_link,sisu_mark,sisu_strikeout,sisu_number,sisu_control,sisu_identifier,sisu_error matchgroup=sisu_contain start="^```\s\+\(block\|group\|poem\|alt\)" end="^```\(\s\|$\)" +" box +syn region sisu_content_alt contains=sisu_mark_endnote,sisu_content_endnote,sisu_link,sisu_mark,sisu_strikeout,sisu_number,sisu_control,sisu_identifier,sisu_error matchgroup=sisu_contain start="^box\(\.[a-z]\+\)\?{" end="^}box" +syn region sisu_content_alt contains=sisu_mark_endnote,sisu_content_endnote,sisu_link,sisu_mark,sisu_strikeout,sisu_number,sisu_control,sisu_identifier,sisu_error matchgroup=sisu_contain start="^```\s\+\box\(\.[a-z]\+\)\?" end="^```\(\s\|$\)" " code -syn region sisu_content_alt contains=sisu_error matchgroup=sisu_contain start="^code{" end="^}code" -syn region sisu_content_alt contains=sisu_error matchgroup=sisu_contain start="^```\s\+code" end="^```\(\s\|$\)" +syn region sisu_content_alt contains=sisu_error,@NoSpell matchgroup=sisu_contain start="^code\(\.[a-z][0-9a-z_]\+\)\?{" end="^}code" +syn region sisu_content_alt contains=sisu_error,@NoSpell matchgroup=sisu_contain start="^```\s\+code\(\.[a-z][0-9a-z_]\+\)\?" end="^```\(\s\|$\)" +" quote +syn region sisu_normal contains=sisu_fontface,sisu_bold,sisu_control,sisu_identifier,sisu_content_endnote,sisu_mark_endnote,sisu_link,sisu_sem_block,sisu_sem_content,sisu_sem_marker_block,sisu_sem_marker,sisu_sem_ex_marker_block,sisu_sem_ex_marker,sisu_linked,sisu_error,sisu_error_wspace matchgroup=sisu_contain start="^```\s\+quote" end="^```\(\s\|$\)" "% "Endnotes: " regular endnote or asterisk or plus sign endnote -- cgit v1.2.3