diff options
author | Ralph Amissah <ralph@amissah.com> | 2014-06-19 22:36:38 -0400 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2014-06-19 22:36:38 -0400 |
commit | ea5affb331624b72a7a5a7ac5614e2d19f347c4d (patch) | |
tree | 2db6a88dc15f0019741254a2a3ea5f78236ef2ff /lib/sisu/v5 | |
parent | debian/changelog (5.4.0-1) (diff) | |
parent | vim syntax, code block, language syntax; box group; quote (diff) |
Merge tag 'sisu_5.4.1' into debian/sid
SiSU 5.4.1
Diffstat (limited to 'lib/sisu/v5')
-rw-r--r-- | lib/sisu/v5/ao.rb | 31 | ||||
-rw-r--r-- | lib/sisu/v5/ao_doc_objects.rb | 104 | ||||
-rw-r--r-- | lib/sisu/v5/ao_doc_str.rb | 294 | ||||
-rw-r--r-- | lib/sisu/v5/ao_expand_insertions.rb | 4 | ||||
-rw-r--r-- | lib/sisu/v5/ao_misc_arrange.rb | 43 | ||||
-rw-r--r-- | lib/sisu/v5/ao_numbering.rb | 15 | ||||
-rw-r--r-- | lib/sisu/v5/constants.rb | 5 | ||||
-rw-r--r-- | lib/sisu/v5/digests.rb | 17 | ||||
-rw-r--r-- | lib/sisu/v5/harvest_topics.rb | 77 | ||||
-rw-r--r-- | lib/sisu/v5/qrcode.rb | 8 | ||||
-rw-r--r-- | lib/sisu/v5/xml_docbook5.rb | 74 | ||||
-rw-r--r-- | lib/sisu/v5/xml_fictionbook2.rb | 68 | ||||
-rw-r--r-- | lib/sisu/v5/xml_scaffold_structure_collapsed.rb | 53 | ||||
-rw-r--r-- | lib/sisu/v5/xml_scaffold_structure_sisu.rb | 55 |
14 files changed, 445 insertions, 403 deletions
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..c53c60d6 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,34 +414,19 @@ 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 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 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..43fa8e5e 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 @@ -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 =~/^--([+~-])[#]$/ @@ -248,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 \ @@ -409,60 +416,60 @@ 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 - @num_code_block +=1 - h={ obj: "code block start #{@num_code_block}" } - t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) - elsif t_o =~/^(?:poem\{|[`]{3}\s+poem)/ + @codeblock_numbered=(t_o =~/^(?:code\{#|```[ ]+code\s[#])/) ? true : false + @num_id[:code_block] +=1 + 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 - when /^[`]{3}\s+poem/ then :tics - else @@flag[:poem] #error + when /^poem\{/ then :curls + when /^```[ ]+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)/ + 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_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)/ + 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_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)/ + 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_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}" } + 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 if t_o=~/^table\{(?:~h)?\s+/ @@ -479,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 @@ -516,18 +523,18 @@ 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+/ + 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 @@ -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 @@ -576,19 +583,19 @@ 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 } 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 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] @@ -598,15 +605,16 @@ 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") 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) \ @@ -623,39 +631,39 @@ 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_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*$/) + 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_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*$/) + 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_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*$/) + 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_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 \ @@ -663,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 @@ -672,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 @@ -751,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}"). @@ -1231,7 +1239,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,24 +1263,18 @@ 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=[] 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" @@ -1349,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]}">} : "</#{o[:lv]}>" ln=case o[:lv] @@ -1368,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 @@ -1377,166 +1379,166 @@ 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 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}</#{@s[0]}>" if (lev <= 0) and hs[0] + #puts "#{spaces*0}</#{@s[0]}>" if (lev <= 0) and hs[0] puts "</#{@s[0]}>" if (lev==0) when 1 - puts "#{@sp*1}</#{@s[1]}>" if (lev <= 1) and hs[1] + puts "#{spaces*1}</#{@s[1]}>" if (lev <= 1) and hs[1] puts "</#{@s[0]}>" if (lev==0) when 2 - puts "#{@sp*2}</#{@s[2]}>" if (lev <= 2) and hs[2] - puts "#{@sp*1}</#{@s[1]}>" if (lev <= 1) and hs[1] + puts "#{spaces*2}</#{@s[2]}>" if (lev <= 2) and hs[2] + puts "#{spaces*1}</#{@s[1]}>" if (lev <= 1) and hs[1] puts "</#{@s[0]}>" if (lev==0) when 3 - puts "#{@sp*3}</#{@s[3]}>" if (lev <= 3) and hs[3] - puts "#{@sp*2}</#{@s[2]}>" if (lev <= 2) and hs[2] - puts "#{@sp*1}</#{@s[1]}>" if (lev <= 1) and hs[1] + puts "#{spaces*3}</#{@s[3]}>" if (lev <= 3) and hs[3] + puts "#{spaces*2}</#{@s[2]}>" if (lev <= 2) and hs[2] + puts "#{spaces*1}</#{@s[1]}>" if (lev <= 1) and hs[1] puts "</#{@s[0]}>" if (lev==0) when 4 - puts "#{@sp*4}</#{@s[4]}>" if (lev <= 4) - puts "#{@sp*3}</#{@s[3]}>" if (lev <= 3) and hs[3] - puts "#{@sp*2}</#{@s[2]}>" if (lev <= 2) and hs[2] - puts "#{@sp*1}</#{@s[1]}>" if (lev <= 1) and hs[1] + puts "#{spaces*4}</#{@s[4]}>" if (lev <= 4) + puts "#{spaces*3}</#{@s[3]}>" if (lev <= 3) and hs[3] + puts "#{spaces*2}</#{@s[2]}>" if (lev <= 2) and hs[2] + puts "#{spaces*1}</#{@s[1]}>" if (lev <= 1) and hs[1] puts "</#{@s[0]}>" if (lev==0) when 5 - puts "#{@sp*5}</#{@s[5]}>" if (lev <= 5) - puts "#{@sp*4}</#{@s[4]}>" if (lev <= 4) - puts "#{@sp*3}</#{@s[3]}>" if (lev <= 3) and hs[3] - puts "#{@sp*2}</#{@s[2]}>" if (lev <= 2) and hs[2] - puts "#{@sp*1}</#{@s[1]}>" if (lev <= 1) and hs[1] + puts "#{spaces*5}</#{@s[5]}>" if (lev <= 5) + puts "#{spaces*4}</#{@s[4]}>" if (lev <= 4) + puts "#{spaces*3}</#{@s[3]}>" if (lev <= 3) and hs[3] + puts "#{spaces*2}</#{@s[2]}>" if (lev <= 2) and hs[2] + puts "#{spaces*1}</#{@s[1]}>" if (lev <= 1) and hs[1] puts "</#{@s[0]}>" if (lev==0) when 6 - puts "#{@sp*6}</#{@s[6]}>" if (lev <= 6) - puts "#{@sp*5}</#{@s[5]}>" if (lev <= 5) - puts "#{@sp*4}</#{@s[4]}>" if (lev <= 4) - puts "#{@sp*3}</#{@s[3]}>" if (lev <= 3) and hs[3] - puts "#{@sp*2}</#{@s[2]}>" if (lev <= 2) and hs[2] - puts "#{@sp*1}</#{@s[1]}>" if (lev <= 1) and hs[1] + puts "#{spaces*6}</#{@s[6]}>" if (lev <= 6) + puts "#{spaces*5}</#{@s[5]}>" if (lev <= 5) + puts "#{spaces*4}</#{@s[4]}>" if (lev <= 4) + puts "#{spaces*3}</#{@s[3]}>" if (lev <= 3) and hs[3] + puts "#{spaces*2}</#{@s[2]}>" if (lev <= 2) and hs[2] + puts "#{spaces*1}</#{@s[1]}>" if (lev <= 1) and hs[1] puts "</#{@s[0]}>" if (lev==0) end end 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..419241e1 100644 --- a/lib/sisu/v5/ao_misc_arrange.rb +++ b/lib/sisu/v5/ao_misc_arrange.rb @@ -74,25 +74,29 @@ 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[`]{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```[ ]+(?: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[`]{3}\s+.+?\n.*?\Z/m #look at, study - block_open,text=/\A([`]{3}(?:\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[`]{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 \ + 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? para << text.to_s << block_close @@ -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/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/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}</#{o.lc}>#{comment}" + ? "#{spaces*o.lc}<#{o.lc}>[#{o.ocn}] #{o.ln} #{o.obj}</#{o.lc}>#{comment}" : "<#{o.lc}>[#{o.ocn}] #{o.ln} #{o.obj}</#{o.lc}>#{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}<title#{id}>} + filename_docbook.puts %{#{spaces*o.lc}<title#{id}>} 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}<title#{id}> + filename_docbook.puts %{#{spaces*(o.lc)}<#{tags.docbook(o.lc,chlv)}#{tag_id}> +#{spaces*o.lc}<title#{id}> } end filename_docbook.puts SiSU_TextUtils::Wrap.new(o.obj + ocn,80,(@splv*2+2)).line_wrap - filename_docbook.puts %{#{space*o.lc}</title>} + filename_docbook.puts %{#{spaces*o.lc}</title>} h=o.lc elsif (o.of ==:para or o.of ==:block) - filename_docbook.puts "#{space*(@splv)}<para#{id}>" + filename_docbook.puts "#{spaces*(@splv)}<para#{id}>" filename_docbook.puts SiSU_TextUtils::Wrap.new(o.obj + ocn,80,(@splv*2+2)).line_wrap - filename_docbook.puts "#{space*(@splv)}</para>" + filename_docbook.puts "#{spaces*(@splv)}</para>" 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}</#{tags.docbook(0)}>" if (lc <= 0) + x << "#{spaces*0}</#{tags.docbook(0)}>" if (lc <= 0) when 1 - x << "#{space*1}</#{tags.docbook(1,@chlv)}>" if (lc <= 1) - x << "#{space*0}</#{tags.docbook(0)}>" if (lc <= 0) + x << "#{spaces*1}</#{tags.docbook(1,@chlv)}>" if (lc <= 1) + x << "#{spaces*0}</#{tags.docbook(0)}>" if (lc <= 0) when 2 - x << "#{space*2}</#{tags.docbook(2,@chlv)}>" if (lc <= 2) - x << "#{space*1}</#{tags.docbook(1,@chlv)}>" if (lc <= 1) - x << "#{space*0}</#{tags.docbook(0)}>" if (lc <= 0) + x << "#{spaces*2}</#{tags.docbook(2,@chlv)}>" if (lc <= 2) + x << "#{spaces*1}</#{tags.docbook(1,@chlv)}>" if (lc <= 1) + x << "#{spaces*0}</#{tags.docbook(0)}>" if (lc <= 0) when 3 - x << "#{space*3}</#{tags.docbook(3,@chlv)}>" if (lc <= 3) - x << "#{space*2}</#{tags.docbook(2,@chlv)}>" if (lc <= 2) - x << "#{space*1}</#{tags.docbook(1,@chlv)}>" if (lc <= 1) - x << "#{space*0}</#{tags.docbook(0)}>" if (lc <= 0) + x << "#{spaces*3}</#{tags.docbook(3,@chlv)}>" if (lc <= 3) + x << "#{spaces*2}</#{tags.docbook(2,@chlv)}>" if (lc <= 2) + x << "#{spaces*1}</#{tags.docbook(1,@chlv)}>" if (lc <= 1) + x << "#{spaces*0}</#{tags.docbook(0)}>" if (lc <= 0) when 4 - x << "#{space*4}</#{tags.docbook(4,@chlv)}>" if (lc <= 4) - x << "#{space*3}</#{tags.docbook(3,@chlv)}>" if (lc <= 3) - x << "#{space*2}</#{tags.docbook(2,@chlv)}>" if (lc <= 2) - x << "#{space*1}</#{tags.docbook(1,@chlv)}>" if (lc <= 1) - x << "#{space*0}</#{tags.docbook(0)}>" if (lc <= 0) + x << "#{spaces*4}</#{tags.docbook(4,@chlv)}>" if (lc <= 4) + x << "#{spaces*3}</#{tags.docbook(3,@chlv)}>" if (lc <= 3) + x << "#{spaces*2}</#{tags.docbook(2,@chlv)}>" if (lc <= 2) + x << "#{spaces*1}</#{tags.docbook(1,@chlv)}>" if (lc <= 1) + x << "#{spaces*0}</#{tags.docbook(0)}>" if (lc <= 0) when 5 - x << "#{space*5}</#{tags.docbook(5)}>" if (lc <= 5) - x << "#{space*4}</#{tags.docbook(4,@chlv)}>" if (lc <= 4) - x << "#{space*5}</#{tags.docbook(3,@chlv)}>" if (lc <= 3) - x << "#{space*2}</#{tags.docbook(2,@chlv)}>" if (lc <= 2) - x << "#{space*1}</#{tags.docbook(1,@chlv)}>" if (lc <= 1) - x << "#{space*0}</#{tags.docbook(0)}>" if (lc <= 0) + x << "#{spaces*5}</#{tags.docbook(5)}>" if (lc <= 5) + x << "#{spaces*4}</#{tags.docbook(4,@chlv)}>" if (lc <= 4) + x << "#{spaces*5}</#{tags.docbook(3,@chlv)}>" if (lc <= 3) + x << "#{spaces*2}</#{tags.docbook(2,@chlv)}>" if (lc <= 2) + x << "#{spaces*1}</#{tags.docbook(1,@chlv)}>" if (lc <= 1) + x << "#{spaces*0}</#{tags.docbook(0)}>" if (lc <= 0) when 6 - x << "#{space*6}</#{tags.docbook(6)}>" if (lc <= 6) - x << "#{space*5}</#{tags.docbook(5)}>" if (lc <= 5) - x << "#{space*4}</#{tags.docbook(4,@chlv)}>" if (lc <= 4) - x << "#{space*3}</#{tags.docbook(3,@chlv)}>" if (lc <= 3) - x << "#{space*2}</#{tags.docbook(2,@chlv)}>" if (lc <= 2) - x << "#{space*1}</#{tags.docbook(1,@chlv)}>" if (lc <= 1) - x << "#{space*0}</#{tags.docbook(0)}>" if (lc <= 0) + x << "#{spaces*6}</#{tags.docbook(6)}>" if (lc <= 6) + x << "#{spaces*5}</#{tags.docbook(5)}>" if (lc <= 5) + x << "#{spaces*4}</#{tags.docbook(4,@chlv)}>" if (lc <= 4) + x << "#{spaces*3}</#{tags.docbook(3,@chlv)}>" if (lc <= 3) + x << "#{spaces*2}</#{tags.docbook(2,@chlv)}>" if (lc <= 2) + x << "#{spaces*1}</#{tags.docbook(1,@chlv)}>" if (lc <= 1) + x << "#{spaces*0}</#{tags.docbook(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}</#{o.lc}>#{comment}" + ? "#{spaces*o.lc}<#{o.lc}>[#{o.ocn}] #{o.ln} #{o.obj}</#{o.lc}>#{comment}" : "<#{o.lc}>[#{o.ocn}] #{o.ln} #{o.obj}</#{o.lc}>#{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}<title> + 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}</title>} + filename_fictionbook.puts %{#{spaces*o.lc}</title>} 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}</#{tags.fictionbook[0]}>" if (lc <= 0) + x << "#{spaces*0}</#{tags.fictionbook[0]}>" if (lc <= 0) when 1 - x << "#{space*1}</#{tags.fictionbook[1]}>" if (lc <= 1) - x << "#{space*0}</#{tags.fictionbook[0]}>" if (lc <= 0) + x << "#{spaces*1}</#{tags.fictionbook[1]}>" if (lc <= 1) + x << "#{spaces*0}</#{tags.fictionbook[0]}>" if (lc <= 0) when 2 - x << "#{space*2}</#{tags.fictionbook[2]}>" if (lc <= 2) - x << "#{space*1}</#{tags.fictionbook[1]}>" if (lc <= 1) - x << "#{space*0}</#{tags.fictionbook[0]}>" if (lc <= 0) + x << "#{spaces*2}</#{tags.fictionbook[2]}>" if (lc <= 2) + x << "#{spaces*1}</#{tags.fictionbook[1]}>" if (lc <= 1) + x << "#{spaces*0}</#{tags.fictionbook[0]}>" if (lc <= 0) when 3 - x << "#{space*3}</#{tags.fictionbook[3]}>" if (lc <= 3) - x << "#{space*2}</#{tags.fictionbook[2]}>" if (lc <= 2) - x << "#{space*1}</#{tags.fictionbook[1]}>" if (lc <= 1) - x << "#{space*0}</#{tags.fictionbook[0]}>" if (lc <= 0) + x << "#{spaces*3}</#{tags.fictionbook[3]}>" if (lc <= 3) + x << "#{spaces*2}</#{tags.fictionbook[2]}>" if (lc <= 2) + x << "#{spaces*1}</#{tags.fictionbook[1]}>" if (lc <= 1) + x << "#{spaces*0}</#{tags.fictionbook[0]}>" if (lc <= 0) when 4 - x << "#{space*4}</#{tags.fictionbook[4]}>" if (lc <= 4) - x << "#{space*3}</#{tags.fictionbook[3]}>" if (lc <= 3) - x << "#{space*2}</#{tags.fictionbook[2]}>" if (lc <= 2) - x << "#{space*1}</#{tags.fictionbook[1]}>" if (lc <= 1) - x << "#{space*0}</#{tags.fictionbook[0]}>" if (lc <= 0) + x << "#{spaces*4}</#{tags.fictionbook[4]}>" if (lc <= 4) + x << "#{spaces*3}</#{tags.fictionbook[3]}>" if (lc <= 3) + x << "#{spaces*2}</#{tags.fictionbook[2]}>" if (lc <= 2) + x << "#{spaces*1}</#{tags.fictionbook[1]}>" if (lc <= 1) + x << "#{spaces*0}</#{tags.fictionbook[0]}>" if (lc <= 0) when 5 - x << "#{space*5}</#{tags.fictionbook[5]}>" if (lc <= 5) - x << "#{space*4}</#{tags.fictionbook[4]}>" if (lc <= 4) - x << "#{space*3}</#{tags.fictionbook[3]}>" if (lc <= 3) - x << "#{space*2}</#{tags.fictionbook[2]}>" if (lc <= 2) - x << "#{space*1}</#{tags.fictionbook[1]}>" if (lc <= 1) - x << "#{space*0}</#{tags.fictionbook[0]}>" if (lc <= 0) + x << "#{spaces*5}</#{tags.fictionbook[5]}>" if (lc <= 5) + x << "#{spaces*4}</#{tags.fictionbook[4]}>" if (lc <= 4) + x << "#{spaces*3}</#{tags.fictionbook[3]}>" if (lc <= 3) + x << "#{spaces*2}</#{tags.fictionbook[2]}>" if (lc <= 2) + x << "#{spaces*1}</#{tags.fictionbook[1]}>" if (lc <= 1) + x << "#{spaces*0}</#{tags.fictionbook[0]}>" if (lc <= 0) when 6 - x << "#{space*6}</#{tags.fictionbook[6]}>" if (lc <= 6) - x << "#{space*5}</#{tags.fictionbook[5]}>" if (lc <= 5) - x << "#{space*4}</#{tags.fictionbook[4]}>" if (lc <= 4) - x << "#{space*3}</#{tags.fictionbook[3]}>" if (lc <= 3) - x << "#{space*2}</#{tags.fictionbook[2]}>" if (lc <= 2) - x << "#{space*1}</#{tags.fictionbook[1]}>" if (lc <= 1) - x << "#{space*0}</#{tags.fictionbook[0]}>" if (lc <= 0) + x << "#{spaces*6}</#{tags.fictionbook[6]}>" if (lc <= 6) + x << "#{spaces*5}</#{tags.fictionbook[5]}>" if (lc <= 5) + x << "#{spaces*4}</#{tags.fictionbook[4]}>" if (lc <= 4) + x << "#{spaces*3}</#{tags.fictionbook[3]}>" if (lc <= 3) + x << "#{spaces*2}</#{tags.fictionbook[2]}>" if (lc <= 2) + x << "#{spaces*1}</#{tags.fictionbook[1]}>" if (lc <= 1) + x << "#{spaces*0}</#{tags.fictionbook[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 <Source def initialize(data='',md='') @data,@md=data,md - @sp=' ' end def songsheet @t='sisu' @@ -116,8 +117,8 @@ module SiSU_XML_Scaffold_Structure_Collapse self end def output(o,lev=nil,comment='') - puts lev == 0..6 \ - ? "#{@sp*lev}<#{lev}>[#{o.ocn}] #{o.ln} #{o.obj}</#{lev}>#{comment}" + puts lev == (0..6) \ + ? "#{spaces*lev}<#{lev}>[#{o.ocn}] #{o.ln} #{o.obj}</#{lev}>#{comment}" : "<#{lev}>[#{o.ocn}] #{o.ln} #{o.obj}</#{lev}>#{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}</#{@s[1]}>" if (lev <= 1) + puts "#{spaces*1}</#{@s[1]}>" if (lev <= 1) puts "</#{@s[0]}>" if (lev==0) when 2 - puts "#{@sp*2}</#{@s[2]}>" if (lev <= 2) - puts "#{@sp*1}</#{@s[1]}>" if (lev <= 1) + puts "#{spaces*2}</#{@s[2]}>" if (lev <= 2) + puts "#{spaces*1}</#{@s[1]}>" if (lev <= 1) puts "</#{@s[0]}>" if (lev==0) when 3 - puts "#{@sp*3}</#{@s[3]}>" if (lev <= 3) - puts "#{@sp*2}</#{@s[2]}>" if (lev <= 2) - puts "#{@sp*1}</#{@s[1]}>" if (lev <= 1) + puts "#{spaces*3}</#{@s[3]}>" if (lev <= 3) + puts "#{spaces*2}</#{@s[2]}>" if (lev <= 2) + puts "#{spaces*1}</#{@s[1]}>" if (lev <= 1) puts "</#{@s[0]}>" if (lev==0) when 4 - puts "#{@sp*4}</#{@s[4]}>" if (lev <= 4) - puts "#{@sp*3}</#{@s[3]}>" if (lev <= 3) - puts "#{@sp*2}</#{@s[2]}>" if (lev <= 2) - puts "#{@sp*1}</#{@s[1]}>" if (lev <= 1) + puts "#{spaces*4}</#{@s[4]}>" if (lev <= 4) + puts "#{spaces*3}</#{@s[3]}>" if (lev <= 3) + puts "#{spaces*2}</#{@s[2]}>" if (lev <= 2) + puts "#{spaces*1}</#{@s[1]}>" if (lev <= 1) puts "</#{@s[0]}>" if (lev==0) when 5 - puts "#{@sp*5}</#{@s[5]}>" if (lev <= 5) - puts "#{@sp*4}</#{@s[4]}>" if (lev <= 4) - puts "#{@sp*3}</#{@s[3]}>" if (lev <= 3) - puts "#{@sp*2}</#{@s[2]}>" if (lev <= 2) - puts "#{@sp*1}</#{@s[1]}>" if (lev <= 1) + puts "#{spaces*5}</#{@s[5]}>" if (lev <= 5) + puts "#{spaces*4}</#{@s[4]}>" if (lev <= 4) + puts "#{spaces*3}</#{@s[3]}>" if (lev <= 3) + puts "#{spaces*2}</#{@s[2]}>" if (lev <= 2) + puts "#{spaces*1}</#{@s[1]}>" if (lev <= 1) puts "</#{@s[0]}>" if (lev==0) when 6 - puts "#{@sp*6}</#{@s[6]}>" if (lev <= 6) - puts "#{@sp*5}</#{@s[5]}>" if (lev <= 5) - puts "#{@sp*4}</#{@s[4]}>" if (lev <= 4) - puts "#{@sp*3}</#{@s[3]}>" if (lev <= 3) - puts "#{@sp*2}</#{@s[2]}>" if (lev <= 2) - puts "#{@sp*1}</#{@s[1]}>" if (lev <= 1) + puts "#{spaces*6}</#{@s[6]}>" if (lev <= 6) + puts "#{spaces*5}</#{@s[5]}>" if (lev <= 5) + puts "#{spaces*4}</#{@s[4]}>" if (lev <= 4) + puts "#{spaces*3}</#{@s[3]}>" if (lev <= 3) + puts "#{spaces*2}</#{@s[2]}>" if (lev <= 2) + puts "#{spaces*1}</#{@s[1]}>" if (lev <= 1) puts "</#{@s[0]}>" 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 <Source def initialize(data='',md='') @data,@md=data,md - @sp=' ' end def songsheet @t='sisu' @@ -114,13 +115,13 @@ module SiSU_XML_Scaffold_Structure_Sisu puts "\nsisu structure, heading outline --->\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}</#{tags.sisu[o.ln]}>" + puts "#{spaces*o.ln}<#{tags.sisu[o.ln]}>[#{o.ocn}] #{o.ln} #{o.obj}</#{tags.sisu[o.ln]}>" end end end def output(o,lev=nil,comment='') - puts lev == 0..6 \ - ? "#{@sp*lev}<#{lev}>[#{o.ocn}] #{o.ln} #{o.obj}</#{lev}>#{comment}" + puts lev == (0..6) \ + ? "#{spaces*lev}<#{lev}>[#{o.ocn}] #{o.ln} #{o.obj}</#{lev}>#{comment}" : "<#{lev}>[#{o.ocn}] #{o.ln} #{o.obj}</#{lev}>#{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}</#{@s[1]}>" if (lev <= 1) && h[1] + puts "#{spaces*1}</#{@s[1]}>" if (lev <= 1) && h[1] puts "</#{@s[0]}>" if (lev==0) when 2 - puts "#{@sp*2}</#{@s[2]}>" if (lev <= 2) && h[2] - puts "#{@sp*1}</#{@s[1]}>" if (lev <= 1) && h[1] + puts "#{spaces*2}</#{@s[2]}>" if (lev <= 2) && h[2] + puts "#{spaces*1}</#{@s[1]}>" if (lev <= 1) && h[1] puts "</#{@s[0]}>" if (lev==0) when 3 - puts "#{@sp*3}</#{@s[3]}>" if (lev <= 3) && h[3] - puts "#{@sp*2}</#{@s[2]}>" if (lev <= 2) && h[2] - puts "#{@sp*1}</#{@s[1]}>" if (lev <= 1) && h[1] + puts "#{spaces*3}</#{@s[3]}>" if (lev <= 3) && h[3] + puts "#{spaces*2}</#{@s[2]}>" if (lev <= 2) && h[2] + puts "#{spaces*1}</#{@s[1]}>" if (lev <= 1) && h[1] puts "</#{@s[0]}>" if (lev==0) when 4 - puts "#{@sp*4}</#{@s[4]}>" if (lev <= 4) - puts "#{@sp*3}</#{@s[3]}>" if (lev <= 3) && h[3] - puts "#{@sp*2}</#{@s[2]}>" if (lev <= 2) && h[2] - puts "#{@sp*1}</#{@s[1]}>" if (lev <= 1) && h[1] + puts "#{spaces*4}</#{@s[4]}>" if (lev <= 4) + puts "#{spaces*3}</#{@s[3]}>" if (lev <= 3) && h[3] + puts "#{spaces*2}</#{@s[2]}>" if (lev <= 2) && h[2] + puts "#{spaces*1}</#{@s[1]}>" if (lev <= 1) && h[1] puts "</#{@s[0]}>" if (lev==0) when 5 - puts "#{@sp*5}</#{@s[5]}>" if (lev <= 5) - puts "#{@sp*4}</#{@s[4]}>" if (lev <= 4) - puts "#{@sp*3}</#{@s[3]}>" if (lev <= 3) && h[3] - puts "#{@sp*2}</#{@s[2]}>" if (lev <= 2) && h[2] - puts "#{@sp*1}</#{@s[1]}>" if (lev <= 1) && h[1] + puts "#{spaces*5}</#{@s[5]}>" if (lev <= 5) + puts "#{spaces*4}</#{@s[4]}>" if (lev <= 4) + puts "#{spaces*3}</#{@s[3]}>" if (lev <= 3) && h[3] + puts "#{spaces*2}</#{@s[2]}>" if (lev <= 2) && h[2] + puts "#{spaces*1}</#{@s[1]}>" if (lev <= 1) && h[1] puts "</#{@s[0]}>" if (lev==0) when 6 - puts "#{@sp*6}</#{@s[6]}>" if (lev <= 6) - puts "#{@sp*5}</#{@s[5]}>" if (lev <= 5) - puts "#{@sp*4}</#{@s[4]}>" if (lev <= 4) - puts "#{@sp*3}</#{@s[3]}>" if (lev <= 3) && h[3] - puts "#{@sp*2}</#{@s[2]}>" if (lev <= 2) && h[2] - puts "#{@sp*1}</#{@s[1]}>" if (lev <= 1) && h[1] + puts "#{spaces*6}</#{@s[6]}>" if (lev <= 6) + puts "#{spaces*5}</#{@s[5]}>" if (lev <= 5) + puts "#{spaces*4}</#{@s[4]}>" if (lev <= 4) + puts "#{spaces*3}</#{@s[3]}>" if (lev <= 3) && h[3] + puts "#{spaces*2}</#{@s[2]}>" if (lev <= 2) && h[2] + puts "#{spaces*1}</#{@s[1]}>" if (lev <= 1) && h[1] puts "</#{@s[0]}>" if (lev==0) end end |