aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v5/ao_doc_str.rb
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2014-01-12 21:21:25 -0500
committerRalph Amissah <ralph@amissah.com>2014-01-12 21:21:25 -0500
commit81108043bb80beeb47214014b07993f0e2a48c9f (patch)
tree74a53542f66a88a466803dbeb22066b9aa5ba438 /lib/sisu/v5/ao_doc_str.rb
parentv4 v5: texpdf, report to screen on pdf output, link to a generated file-size (diff)
v5: ao, counter for various grouped / blocked texts & tables
* of particular use for poems which are broken into verse
Diffstat (limited to 'lib/sisu/v5/ao_doc_str.rb')
-rw-r--r--lib/sisu/v5/ao_doc_str.rb54
1 files changed, 30 insertions, 24 deletions
diff --git a/lib/sisu/v5/ao_doc_str.rb b/lib/sisu/v5/ao_doc_str.rb
index 31479252..f7168c26 100644
--- a/lib/sisu/v5/ao_doc_str.rb
+++ b/lib/sisu/v5/ao_doc_str.rb
@@ -222,7 +222,7 @@ module SiSU_AO_DocumentStructureExtract
def identify_parts
tuned_file=[]
@tuned_block,@tuned_code=[],[]
- @@counter,@verse_count=0,0
+ @@counter,@verse_count,@num_code_block,@num_poem,@num_group,@num_block,@num_alt,@num_table=0,0,0,0,0,0,0,0
@metadata={}
@data.each do |t_o|
if t_o =~/^--([+~-])[#]$/
@@ -408,7 +408,8 @@ module SiSU_AO_DocumentStructureExtract
end
@@counter=1
@codeblock_numbered=(t_o =~/^(?:code\{#|[`]{3}\s+code\s[#])/) ? true : false
- h={ obj: 'code block start' } #introduce a counter
+ @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)/
@@flag[:poem]=case t_o
@@ -416,7 +417,8 @@ module SiSU_AO_DocumentStructureExtract
when /^[`]{3}\s+poem/ then :tics
else @@flag[:poem] #error
end
- h={ obj: 'poem start' } #introduce a counter
+ @num_poem +=1
+ h={ obj: "poem start #{@num_poem}" }
t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h)
tuned_file << t_o
elsif t_o =~/^(?:group\{|[`]{3}\s+group)/
@@ -425,7 +427,8 @@ module SiSU_AO_DocumentStructureExtract
when /^[`]{3}\s+group/ then :tics
else @@flag[:group] #error
end
- h={ obj: 'group text start' } #introduce a counter
+ @num_group +=1
+ h={ obj: "group text start #{@num_group}" }
t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h)
tuned_file << t_o
elsif t_o =~/^(?:block\{|[`]{3}\s+block)/
@@ -434,7 +437,8 @@ module SiSU_AO_DocumentStructureExtract
when /^[`]{3}\s+block/ then :tics
else @@flag[:block] #error
end
- h={ obj: 'block text start' } #introduce a counter
+ @num_block +=1
+ h={ obj: "block text start #{@num_block}" }
t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h)
tuned_file << t_o
elsif t_o =~/^(?:alt\{|[`]{3}\s+alt)/
@@ -443,11 +447,13 @@ module SiSU_AO_DocumentStructureExtract
when /^[`]{3}\s+alt/ then :tics
else @@flag[:alt] #error
end
- h={ obj: 'alt text start' } #introduce a counter
+ @num_alt +=1
+ h={ obj: "alt text start #{@num_alt}" }
t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h)
tuned_file << t_o
elsif t_o =~/^(?:table\{|[`]{3}\s+table|\{table)[ ~]/
- h={ obj: 'table start' } #introduce a counter
+ @num_table +=1
+ h={ obj: "table start #{@num_table}" }
ins=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h)
tuned_file << ins
if t_o=~/^table\{(?:~h)?\s+/
@@ -501,10 +507,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 }
+ 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' } #introduce a counter
+ h={ obj: "table end #{@num_table}" }
t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h)
t_o
elsif t_o=~/^[`]{3}\s+table(?:~h)?\s+/
@@ -524,10 +530,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 }
+ 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' } #introduce a counter
+ h={ obj: "table end #{@num_table}" }
t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h)
t_o
elsif t_o=~/^\{table(?:~h)?\s+/
@@ -547,10 +553,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 }
+ 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' } #introduce a counter
+ h={ obj: "table end #{@num_table}" }
t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h)
t_o
end
@@ -568,7 +574,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' } #introduce a counter
+ h={ obj: "table end #{@num_table}" }
t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h)
t_o
else
@@ -587,11 +593,11 @@ module SiSU_AO_DocumentStructureExtract
@@flag[:code]=:off
obj=@tuned_code.join("\n")
tags=[]
- h={ obj: obj, tags: tags, number_: @codeblock_numbered }
+ h={ obj: obj, tags: tags, num: @num_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' } #introduce a counter
+ h={ obj: "code block end #{@num_code_block}" }
t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h)
end
if (@@flag[:code]==:curls or @@flag[:code]==:tics) \
@@ -610,37 +616,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' } #introduce a counter
+ h={ obj: "poem end #{@num_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 }
+ h={ obj: obj, tags: tags, num: @num_group }
@tuned_block=[]
t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.group(h)
tuned_file << t_o
- h={ obj: 'group text end' } #introduce a counter
+ h={ obj: "group text end #{@num_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 }
+ h={ obj: obj, tags: tags, num: @num_block }
@tuned_block=[]
t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.block(h)
tuned_file << t_o
- h={ obj: 'block text end' } #introduce a counter
+ h={ obj: "block text end #{@num_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 }
+ h={ obj: obj, tags: tags, num: @num_alt }
t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.alt(h)
@tuned_block=[]
tuned_file << t_o
- h={ obj: 'alt text end' } #introduce a counter
+ h={ obj: "alt text end #{@num_alt}" }
t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h)
end
if (@@flag[:poem]==:curls or @@flag[:poem]==:tics \
@@ -657,7 +663,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 }
+ h={ obj: obj, tags: tags, num: @num_poem }
t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.verse(h)
tuned_file << t_o
end