aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v6/ao_doc_str.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sisu/v6/ao_doc_str.rb')
-rw-r--r--lib/sisu/v6/ao_doc_str.rb412
1 files changed, 240 insertions, 172 deletions
diff --git a/lib/sisu/v6/ao_doc_str.rb b/lib/sisu/v6/ao_doc_str.rb
index d060d89c..7f2815d8 100644
--- a/lib/sisu/v6/ao_doc_str.rb
+++ b/lib/sisu/v6/ao_doc_str.rb
@@ -63,14 +63,17 @@
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,
+ lngsyn: :txt,
+ poem: :off,
+ block: :off,
+ box: :off,
+ group: :off,
+ alt: :off,
+ quote: :off,
+ table: :off,
+ table_to: :off,
}
def initialize
@@counter=@@column=@@columns=0
@@ -79,14 +82,17 @@ 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,
+ lngsyn: :txt,
+ poem: :off,
+ block: :off,
+ box: :off,
+ group: :off,
+ alt: :off,
+ quote: :off,
+ table: :off,
+ table_to: :off,
}
def initialize(md,data)
@md,@data=md,data
@@ -119,6 +125,11 @@ module SiSU_AO_DocumentStructureExtract
? true
: false
end
+ def quotes?
+ @@flag[:quote]==:open \
+ ? true
+ : false
+ end
def hang_and_indent_test(str)
hang_indent=if str=~/^_([1-9])[^_]/
[$1,$1]
@@ -225,7 +236,16 @@ 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,
+ box: 0,
+ group: 0,
+ alt: 0,
+ quote: 0,
+ table: 0,
+ }
@metadata={}
@data.each do |t_o|
if t_o =~/^--([+~-])[#]$/
@@ -247,13 +267,14 @@ module SiSU_AO_DocumentStructureExtract
next
end
t_o=t_o.gsub(/(?:\n\s*\n)+/m,"\n") if @@flag[:code]==:off
- if t_o !~/^(?:code|poem|alt|group|block)\{|^\}(?:code|poem|alt|group|block)|^(?:table\{|\{table)[ ~]/ \
- and t_o !~/^[`]{3}\s+(?:code|poem|alt|group|block|table)|^[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/ \
+ if t_o !~/^(?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block)\{|^\}(?:code|poem|alt|group|block)|^(?:table\{|\{table)[ ~]/ \
+ and t_o !~/^```[ ]+(?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block|table)|^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$|^`:quote_(?:open|close)`/ \
and @@flag[:code]==:off \
and @@flag[:poem]==:off \
and @@flag[:group]==:off \
and @@flag[:block]==:off \
and @@flag[:alt]==:off \
+ and @@flag[:box]==:off \
and @@flag[:table]==:off
unless t_o =~/^(?:@\S+?:|%+)\s/ # extract book index for paragraph if any
idx=if t_o=~/^=\{(.+)\}\s*$\Z/m; m=$1
@@ -357,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
@@ -380,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
@@ -404,67 +425,93 @@ module SiSU_AO_DocumentStructureExtract
end
end
unless obj=~/\A\s*\Z/m
- h={ bullet_: false, indent: 0, hang: 0, obj: obj, idx: idx, note_: note, image_: image, tags: tags }
+ h={ bullet_: false, indent: 0, hang: 0, obj: obj, idx: idx, note_: note, image_: image, tags: tags, quote: quotes? }
SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h)
end
end
elsif @@flag[:code]==:off
- if t_o =~/^(?:code\{|[`]{3}\s+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 /^[`]{3}\s+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\{#|[`]{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(?:\.[a-z][0-9a-z_]+)?\{#|```[ ]+code(?:\.[a-z][0-9a-z_]+)?\s[#])/) ? true : false
+ @num_id[:code_block] +=1
+ h={ obj: '', sym: :code_block_open, num: @num_id[:code_block], syntax: @@flag[:lngsyn] }
+ 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}" }
- t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h)
+ @num_id[:poem] +=1
+ 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 =~/^(?:group\{|[`]{3}\s+group)/
+ elsif t_o =~/^(?:box(?:\.[a-z_]+)?\{|```[ ]+box(?:\.[a-z_]+)?)/
+ @@flag[:box]=case t_o
+ when /^box\{/ then :curls
+ when /^```[ ]+box/ then :tics
+ else @@flag[:box] #error
+ end
+ @num_id[:box] +=1
+ h={ obj: '', sym: :box_open, num: @num_id[:box] }
+ t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h)
+ tuned_file << t_o
+ elsif t_o =~/^(?:group\{|```[ ]+group)/
@@flag[:group]=case t_o
- 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}" }
- t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h)
+ @num_id[:group] +=1
+ 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\{|[`]{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}" }
- t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h)
+ @num_id[:block] +=1
+ 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\{|[`]{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}" }
- t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h)
+ @num_id[:alt] +=1
+ 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 =~/^(?:table\{|[`]{3}\s+table|\{table)[ ~]/
- @num_table +=1
- h={ obj: "table start #{@num_table}" }
- ins=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h)
- tuned_file << ins
+ 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: '', 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=''
@@ -479,15 +526,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 +563,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}" }
- 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=~/^[`]{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,11 +586,11 @@ 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}" }
- 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
@@ -562,11 +609,11 @@ 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}" }
- 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
@@ -576,20 +623,20 @@ 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}" }
- 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\{|[`]{3}\s+table)/
- t_o=t_o.gsub(/^\n+/m,''). #check added for ruby 1.9.2 not needed in 1.8 series (tested in v2)
+ and t_o !~/^(?:table\{|```[ ]+table)/
+ t_o=t_o.gsub(/^\n+/m,'').
gsub(/\n+/m,"#{Mx[:tc_p]}")
@rows += t_o + Mx[:tc_c]
end
@@ -598,16 +645,18 @@ 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, syntax: @@flag[:lngsyn], tags: tags, num: @num_id[:code_block], number_: @codeblock_numbered }
+ @@flag[:lngsyn]=:txt
t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.code(h)
@tuned_code=[]
tuned_file << t_o
- h={ obj: "code block end #{@num_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)
@@ -619,51 +668,71 @@ module SiSU_AO_DocumentStructureExtract
t_o=nil
end
elsif (@@flag[:poem]==:curls or @@flag[:poem]==:tics) \
+ or (@@flag[:box]==:curls or @@flag[:box]==:tics) \
or (@@flag[:group]==:curls or @@flag[:group]==:tics) \
or (@@flag[:block]==:curls or @@flag[:block]==:tics) \
- or (@@flag[:alt]==:curls or @@flag[:alt]==:tics)
+ or (@@flag[:alt]==:curls or @@flag[:alt]==:tics) \
+ or (@@flag[:quote]==:open and t_o =~/`:quote_close`/m) #not
if (@@flag[:poem]==:curls and t_o =~/^\}poem/) \
- or (@@flag[:poem]==:tics and t_o =~/^[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/)
+ or (@@flag[:poem]==:tics and t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/)
@@flag[:poem]=:off
- h={ obj: "poem end #{@num_poem}" }
- t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h)
+ h={ obj: '', sym: :poem_close, num: @num_id[:poem] }
+ t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h)
+ elsif (@@flag[:box]==:curls and t_o =~/^\}box/) \
+ or (@@flag[:box]==:tics and t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/)
+ @@flag[:box]=:off
+ obj,tags=extract_tags(@tuned_block.join("\n"))
+ h={ obj: obj, tags: tags, num: @num_id[:box] }
+ @tuned_block=[]
+ t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.box(h)
+ tuned_file << t_o
+ h={ obj: '', sym: :box_close, num: @num_id[:box] }
+ t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h)
elsif (@@flag[:group]==:curls and t_o =~/^\}group/) \
- or (@@flag[:group]==:tics and t_o =~/^[`]{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}" }
- 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 =~/^[`]{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}" }
- 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 =~/^[`]{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}" }
- t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h)
+ h={ obj: '', sym: :alt_close, num: @num_id[:alt] }
+ t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h)
+ elsif @@flag[:quote]==:open and t_o =~/`:quote_close`/m
+ @@flag[:quote]=:off
+ h={ obj: '', sym: :quote_close, num: @num_id[:quote] }
+ t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h)
+ elsif @@flag[:quote]==:open
+ t_o,tags=extract_tags(t_o)
+ h={ indent: 1, obj: t_o, idx: idx, note_: note, image_: image, tags: tags, quote: quotes? }
+ SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h)
end
if (@@flag[:poem]==:curls or @@flag[:poem]==:tics \
or @@flag[:group]==:curls or @@flag[:group]==:tics \
or @@flag[:alt]==:curls or @@flag[:alt]==:tics) \
and t_o =~/\S/ \
- and t_o !~/^(?:\}(?:verse|code|alt|group|block)|(?:verse|code|alt|group|block)\{)/ \
- and t_o !~/^[`]{3}\s+(?:code|poem|alt|group|block)|^[`]{3}(?:\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
@@ -672,7 +741,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
@@ -684,8 +753,10 @@ module SiSU_AO_DocumentStructureExtract
end
if @@flag[:code]==:off
if @@flag[:poem]==:curls or @@flag[:poem]==:tics \
+ or @@flag[:box]==:curls or @@flag[:box]==:tics \
or @@flag[:group]==:curls or @@flag[:group]==:tics \
- or @@flag[:alt]==:curls or @@flag[:alt]==:tics
+ or @@flag[:alt]==:curls or @@flag[:alt]==:tics \
+ or (@@flag[:quote]==:open and t_o =~/`:quote_close`/m)
if t_o.is_a?(String)
t_o=t_o.gsub(/\n/m,"#{Mx[:br_nl]}").
gsub(/[ ][ ]/m,"#{Mx[:nbsp]*2}").
@@ -694,6 +765,7 @@ module SiSU_AO_DocumentStructureExtract
elsif t_o.is==:group \
|| t_o.is==:block \
|| t_o.is==:alt \
+ || t_o.is==:box \
|| t_o.is==:verse
t_o.obj=t_o.obj.gsub(/\n/m,"#{Mx[:br_nl]}").
gsub(/[ ][ ]/m,"#{Mx[:nbsp]*2}").
@@ -750,8 +822,8 @@ module SiSU_AO_DocumentStructureExtract
lines,lines_new=@data,[]
lines.each do |line|
line=if line =~/\S/ \
- and line !~/^(?:code\{|\}code)/ \
- and line !~/^(?:[`]{3}\s+code|[`]{3}(?:\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}").
@@ -1182,6 +1254,7 @@ SKIPPED processing file: [#{@md.opt.lng}] "#{@md.fns}"}
ocnc+=1
ocn_sp,parent="c#{ocnc}",node
elsif dob.is==:group \
+ || dob.is==:box \
|| dob.is==:block \
|| dob.is==:alt \
|| dob.is==:verse
@@ -1229,9 +1302,10 @@ 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/,"\n") #newlines taken out
+ dob.obj=dob.obj.gsub(/\n+/,"\n") #newlines taken out
end
@o_array << dob
end
@@ -1255,24 +1329,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 +1417,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 +1436,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 +1445,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