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 --- lib/sisu/v6/ao_doc_str.rb | 98 ++++++++++++++++++++++------------------------- 1 file changed, 46 insertions(+), 52 deletions(-) (limited to 'lib/sisu/v6/ao_doc_str.rb') 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 -- 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 --- lib/sisu/v6/ao_doc_str.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/sisu/v6/ao_doc_str.rb') 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 --- lib/sisu/v6/ao_doc_str.rb | 67 ++++++++++++++++++++++++++--------------------- 1 file changed, 37 insertions(+), 30 deletions(-) (limited to 'lib/sisu/v6/ao_doc_str.rb') 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 --- lib/sisu/v6/ao_doc_str.rb | 68 +++++++++++++++++++++++------------------------ 1 file changed, 34 insertions(+), 34 deletions(-) (limited to 'lib/sisu/v6/ao_doc_str.rb') 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}"). -- 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) --- lib/sisu/v6/ao_doc_str.rb | 66 +++++++++++++++++++++++------------------------ 1 file changed, 33 insertions(+), 33 deletions(-) (limited to 'lib/sisu/v6/ao_doc_str.rb') 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 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 --- lib/sisu/v6/ao_doc_str.rb | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) (limited to 'lib/sisu/v6/ao_doc_str.rb') 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}"). -- 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 --- lib/sisu/v6/ao_doc_str.rb | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) (limited to 'lib/sisu/v6/ao_doc_str.rb') 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 -- 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) --- lib/sisu/v6/ao_doc_str.rb | 104 ++++++++++++++++++++++++++++------------------ 1 file changed, 64 insertions(+), 40 deletions(-) (limited to 'lib/sisu/v6/ao_doc_str.rb') 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}"). -- cgit v1.2.3