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.rb714
1 files changed, 572 insertions, 142 deletions
diff --git a/lib/sisu/v6/ao_doc_str.rb b/lib/sisu/v6/ao_doc_str.rb
index 7f2815d8..2a96abb7 100644
--- a/lib/sisu/v6/ao_doc_str.rb
+++ b/lib/sisu/v6/ao_doc_str.rb
@@ -154,12 +154,18 @@ module SiSU_AO_DocumentStructureExtract
[0,0]
end
obj=if str2 =~/^(.+?)\s+\\\\(?:\s+|\n)/
- str2.gsub(/^(.+?)(\s+\\\\(?:\s+|\n))/,"#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}\\2")
+ str2.gsub(/^(.+?)(\s+\\\\(?:\s+|\n))/,
+ "#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}\\2")
else
- str2.gsub(/^(.+?)\n/,"#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}\n")
+ str2.gsub(/^(.+?)\n/,
+ "#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}\n")
end
hang,indent=hang_indent[0],hang_indent[1]
- [hang,indent,obj]
+ [
+ hang,
+ indent,
+ obj,
+ ]
end
def endnote_test?(str)
(str=~/~\{.+?\}~|~\[.+?\]~/) \
@@ -182,7 +188,10 @@ module SiSU_AO_DocumentStructureExtract
t.gsub!(/[^a-z0-9._-]/,'')
end
end
- [str,tags]
+ [
+ str,
+ tags,
+ ]
end
def rgx_idx_ocn_seg
@rgx_idx_ocn_seg=/(.+?)\s*[+](\d+)/
@@ -191,14 +200,19 @@ module SiSU_AO_DocumentStructureExtract
idx_array_raw=idxraw.scan(/[^;]+/)
idx_hash,idx_array,idx_lst={},[],[]
idx_array_raw.each do |idx|
+ idx=idx.strip
idx_lst=case idx
when /\S+?\s*:/
idx_couplet_tmp=[]
idx_couplet=idx.scan(/\s*[^:]+\s*/)
if idx_couplet[1] =~/[|]/
- idx_couplet_tmp << idx_couplet[0] << idx_couplet[1].scan(/\s*[^|]+\s*/)
+ idx_couplet_tmp <<
+ idx_couplet[0] <<
+ idx_couplet[1].scan(/\s*[^|]+\s*/)
else
- idx_couplet_tmp << idx_couplet[0] << [idx_couplet[1]]
+ idx_couplet_tmp <<
+ idx_couplet[0] <<
+ [idx_couplet[1]]
end
idx_couplet=idx_couplet_tmp
else [idx]
@@ -207,14 +221,17 @@ module SiSU_AO_DocumentStructureExtract
idx_lst.each do |term_node|
case term_node
when String
- term_node=term_node[0].chr.capitalize + term_node[1,term_node.length]
+ term_node=
+ term_node[0].chr.capitalize +
+ term_node[1,term_node.length]
term_node=(term_node =~/.+?[+]\d+/) \
? term_node
: (term_node + '+0')
term_nodes << term_node
use,plus=rgx_idx_ocn_seg.match(term_node)[1,2]
@use=use.strip
- idx_hash[@use]={ sub: [], plus: plus } unless idx_hash[@use] and defined? idx_hash[@use]
+ idx_hash[@use]=
+ { sub: [], plus: plus } unless idx_hash[@use] and defined? idx_hash[@use]
when Array
subterm_nodes=[]
term_node.each do |subterm_node|
@@ -223,15 +240,20 @@ module SiSU_AO_DocumentStructureExtract
: (subterm_node + '+0')
subterm_nodes << subterm_node
sub,sub_plus=rgx_idx_ocn_seg.match(subterm_node)[1,2]
- idx_hash[@use]={ sub: [], plus: 0 } unless idx_hash[@use] and defined? idx_hash[@use]
- idx_hash[@use][:sub] << {sub.strip => { plus: sub_plus }}
+ idx_hash[@use]=
+ { sub: [], plus: 0 } unless idx_hash[@use] and defined? idx_hash[@use]
+ idx_hash[@use][:sub] <<
+ { sub.strip => { plus: sub_plus } }
end
term_nodes << subterm_nodes
end
end
idx_array << term_nodes
end
- { hash: idx_hash, array: idx_array }
+ {
+ hash: idx_hash,
+ array: idx_array,
+ }
end
def identify_parts
tuned_file=[]
@@ -252,16 +274,26 @@ module SiSU_AO_DocumentStructureExtract
h=case $1
when /[+]/
@@flag[:ocn]=:on
- {flag: :ocn_on}
+ {
+ flag: :ocn_on,
+ }
when /[~]/
@@flag[:ocn]=:ocn_off_headings_keep
- {flag: :ocn_off, mod: :headings_keep}
+ {
+ flag: :ocn_off,
+ mod: :headings_keep,
+ }
when /[-]/ #of particular relevance with level 1~ which is required to precede substantive text & used e.g. in html segmented text
@@flag[:ocn]=:ocn_off_headings_dummy_lev1
- {flag: :ocn_off, mod: :headings_exclude}
+ {
+ flag: :ocn_off,
+ mod: :headings_exclude,
+ }
else
@@flag[:ocn]=:on
- {flag: :ocn_on}
+ {
+ flag: :ocn_on,
+ }
end
t_o=SiSU_AO_DocumentStructure::ObjectFlag.new.flag_ocn(h)
next
@@ -277,11 +309,11 @@ module SiSU_AO_DocumentStructureExtract
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
- m=m.split(/\n/).join(' ').
+ idx=if t_o=~/^=\{\s*(.+)\s*\}\s*$\Z/m; m=$1
+ m=m.split(/[ ]*\n/).join(' ').
gsub(/\s+([|:;])\s+/,'\1').
gsub(/\s+([+]\d+)\s+/,'\1')
- t_o=t_o.gsub(/\n=\{.+\}\s*$\Z/m,'')
+ t_o=t_o.gsub(/\n=\{.+?\}\s*$/m,'')
idx_array_and_hash=construct_idx_array_and_hash(m)
idx_array_and_hash[:hash]
else nil
@@ -296,7 +328,7 @@ module SiSU_AO_DocumentStructureExtract
t_o=nil
when /^%+\s/ #comment
t_o=if t_o=~/^%+\s+(.+)/
- h={obj: $1}
+ h={ obj: $1 }
SiSU_AO_DocumentStructure::ObjectComment.new.comment(h)
else nil
end
@@ -319,7 +351,13 @@ module SiSU_AO_DocumentStructureExtract
end
end
end
- h={ lv: lv, ln: ln, obj: obj, idx: idx, tags: tags }
+ h={
+ lv: lv,
+ ln: ln,
+ obj: obj,
+ idx: idx,
+ tags: tags,
+ }
SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h)
elsif t_o=~/^:?[A-D1-6]\~(\S+?)-\s+(.+)/m
name,obj=$1,$2
@@ -337,7 +375,14 @@ module SiSU_AO_DocumentStructureExtract
end
end
end
- h={ lv: lv, name: name, obj: obj, idx: idx, autonum_: false, tags: tags}
+ h={
+ lv: lv,
+ name: name,
+ obj: obj,
+ idx: idx,
+ autonum_: false,
+ tags: tags,
+ }
SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h)
elsif t_o=~/^:?[A-D1-6]\~(\S+)\s+(.+)/m
name,obj=$1,$2
@@ -355,7 +400,13 @@ module SiSU_AO_DocumentStructureExtract
end
end
end
- h={ lv: lv, name: name, obj: obj, idx: idx, tags: tags }
+ h={
+ lv: lv,
+ name: name,
+ obj: obj,
+ idx: idx,
+ tags: tags,
+ }
SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h)
else nil
end
@@ -378,7 +429,17 @@ module SiSU_AO_DocumentStructureExtract
obj << ' ~#'
end
end
- h={ bullet_: bullet, hang: hang, indent: indent, obj: obj, idx: idx, note_: note, image_: image, tags: tags, quote: quotes? }
+ 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
@@ -401,7 +462,16 @@ module SiSU_AO_DocumentStructureExtract
obj << ' ~#'
end
end
- h={ hang: hang, indent: indent, obj: obj, idx: idx, note_: note, image_: image, tags: tags, quote: quotes? }
+ 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
@@ -425,9 +495,20 @@ 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, quote: quotes? }
- SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h)
+ h={
+ bullet_: false,
+ indent: 0,
+ hang: 0,
+ obj: obj,
+ idx: idx,
+ note_: note,
+ image_: image,
+ tags: tags,
+ quote: quotes?,
+ }
+ t_o=SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h)
end
+ t_o=SiSU_AO_DocumentStructureExtract::Structure.new(@md).structure_markup(t_o) #must happen earlier, node info etc. require
end
elsif @@flag[:code]==:off
if t_o =~/^(?:code(?:\.[a-z][0-9a-z_]+)?\{|```[ ]+code(?:\.[a-z][0-9a-z_]+)?)/
@@ -447,9 +528,18 @@ module SiSU_AO_DocumentStructureExtract
else :txt
end
@@counter=1
- @codeblock_numbered=(t_o =~/^(?:code(?:\.[a-z][0-9a-z_]+)?\{#|```[ ]+code(?:\.[a-z][0-9a-z_]+)?\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], syntax: @@flag[:lngsyn] }
+ h={
+ is_for: :code,
+ 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
@@ -458,58 +548,93 @@ module SiSU_AO_DocumentStructureExtract
else @@flag[:poem] #error
end
@num_id[:poem] +=1
- h={ obj: '', sym: :poem_open, num: @num_id[:poem] }
+ h={
+ is_for: :poem,
+ 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
when /^box\{/ then :curls
when /^```[ ]+box/ then :tics
- else @@flag[:box] #error
+ else @@flag[:box] #error
end
@num_id[:box] +=1
- h={ obj: '', sym: :box_open, num: @num_id[:box] }
+ h={
+ is_for: :box,
+ 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 /^```[ ]+group/ then :tics
- else @@flag[:group] #error
+ else @@flag[:group] #error
end
@num_id[:group] +=1
- h={ obj: '', sym: :group_open, num: @num_id[:group] }
+ h={
+ is_for: :group,
+ 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
when /^block\{/ then :curls
when /^```[ ]+block/ then :tics
- else @@flag[:block] #error
+ else @@flag[:block] #error
end
@num_id[:block] +=1
- h={ obj: '', sym: :block_open, num: @num_id[:block] }
+ h={
+ is_for: :block,
+ 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
when /^alt\{/ then :curls
when /^```[ ]+alt/ then :tics
- else @@flag[:alt] #error
+ else @@flag[:alt] #error
end
@num_id[:alt] +=1
- h={ obj: '', sym: :alt_open, num: @num_id[:alt] }
+ h={
+ is_for: :alt,
+ 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] }
+ h={
+ is_for: :quote,
+ 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] }
+ h={
+ is_for: :table,
+ 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+/
@@ -525,7 +650,12 @@ module SiSU_AO_DocumentStructureExtract
col=$2.scan(/\d+/)
heading=false
end
- @h={ head_: heading, cols: cols, widths: col, idx: idx }
+ @h={
+ head_: heading,
+ cols: cols,
+ widths: col,
+ idx: idx,
+ }
elsif t_o=~/^```[ ]+table(?:~h)?\s+c\d+/
@@flag[:table]=:tics
@rows=''
@@ -539,7 +669,12 @@ module SiSU_AO_DocumentStructureExtract
col=$2.scan(/\d+/)
heading=false
end
- @h={ head_: heading, cols: cols, widths: col, idx: idx }
+ @h={
+ head_: heading,
+ cols: cols,
+ widths: col,
+ idx: idx,
+ }
elsif t_o=~/^\{table(?:~h)?(?:\s+\d+;?)?\}\n.+\Z/m
m1,m2,hd=nil,nil,nil
tbl=/^\{table(?:~h)?(?:\s+\d+;?)?\}\n(.+)\Z/m.match(t_o)[1]
@@ -550,7 +685,7 @@ module SiSU_AO_DocumentStructureExtract
cols=nil
rws.each do |r|
cols=(cols ? cols : (r.scan('|').length) +1)
- r=r.gsub(/\s*\|\s*/m,"#{Mx[:tc_p]}") #r.gsub!(/\|/m,"#{Mx[:tc_p]}")
+ r=r.gsub(/\s*\|\s*/m,"#{Mx[:tc_p]}") #r.gsub!(/\|/m,"#{Mx[:tc_p]}")
rows += r + Mx[:tc_c]
end
col=[]
@@ -563,18 +698,31 @@ 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_id[: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: '', sym: :table_close, num: @num_id[:table] }
+ h={
+ is_for: :table,
+ 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
h=case t_o
- when /^```[ ]+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 /^```[ ]+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,13 +731,26 @@ module SiSU_AO_DocumentStructureExtract
rws=tbl.split(/\n/)
rows=''
rws.each do |r|
- r=r.gsub(/\s*\|\s*/m,"#{Mx[:tc_p]}") #r.gsub!(/\|/m,"#{Mx[:tc_p]}")
+ 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_id[: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: '', sym: :table_close, num: @num_id[:table] }
+ h={
+ is_for: :table,
+ 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+/
@@ -606,13 +767,26 @@ module SiSU_AO_DocumentStructureExtract
rws=tbl.split(/\n/)
rows=''
rws.each do |r|
- r=r.gsub(/\s*\|\s*/m,"#{Mx[:tc_p]}") #r.gsub!(/\|/m,"#{Mx[:tc_p]}")
+ 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_id[: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: '', sym: :table_close, num: @num_id[:table] }
+ h={
+ is_for: :table,
+ obj: '',
+ sym: :table_close,
+ num: @num_id[:table],
+ }
t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h)
t_o
end
@@ -626,11 +800,22 @@ module SiSU_AO_DocumentStructureExtract
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 }
+ @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: '', sym: :table_close, num: @num_id[:table] }
+ h={
+ is_for: :table,
+ obj: '',
+ sym: :table_close,
+ num: @num_id[:table],
+ }
t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h)
t_o
else
@@ -650,12 +835,23 @@ 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, syntax: @@flag[:lngsyn], 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
- h={ obj: '', sym: :code_close, num: @num_id[:code_block] }
+ h={
+ is_for: :code,
+ 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) \
@@ -676,55 +872,109 @@ module SiSU_AO_DocumentStructureExtract
if (@@flag[:poem]==:curls and t_o =~/^\}poem/) \
or (@@flag[:poem]==:tics and t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/)
@@flag[:poem]=:off
- h={ obj: '', sym: :poem_close, num: @num_id[:poem] }
+ h={
+ is_for: :poem,
+ 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] }
+ 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] }
+ h={
+ is_for: :box,
+ 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
obj,tags=extract_tags(@tuned_block.join("\n"))
- h={ obj: obj, tags: tags, num: @num_id[: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: '', sym: :group_close, num: @num_id[:group] }
+ h={
+ is_for: :group,
+ 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
obj,tags=extract_tags(@tuned_block.join("\n"))
- h={ obj: obj, tags: tags, num: @num_id[: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: '', sym: :block_close, num: @num_id[:block] }
+ h={
+ is_for: :block,
+ 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
obj,tags=extract_tags(@tuned_block.join("\n"))
- h={ obj: obj, tags: tags, num: @num_id[: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: '', sym: :alt_close, num: @num_id[:alt] }
+ h={
+ is_for: :alt,
+ 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] }
+ h={
+ is_for: :quote,
+ 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? }
+ 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 \
@@ -741,7 +991,11 @@ 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_id[:poem] }
+ h={
+ obj: obj,
+ tags: tags,
+ num: @num_id[:poem],
+ }
t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.verse(h)
tuned_file << t_o
end
@@ -779,26 +1033,67 @@ module SiSU_AO_DocumentStructureExtract
end
if @md.flag_endnotes
tuned_file << @pb
- h={ ln: 1, lc: 1, obj: 'Endnotes', autonum_: false }
+ h={
+ ln: 1,
+ lc: 1,
+ obj: 'Endnotes',
+ autonum_: false,
+ }
tuned_file << SiSU_AO_DocumentStructure::ObjectHeading.new.heading_insert(h)
- h={ ln: 4, lc: 2, obj: 'Endnotes', name: 'endnotes', autonum_: false }
+ h={
+ ln: 4,
+ lc: 2,
+ obj: 'Endnotes',
+ name: 'endnotes',
+ autonum_: false,
+ }
tuned_file << SiSU_AO_DocumentStructure::ObjectHeading.new.heading_insert(h)
- h={ obj: 'Endnotes' }
+ h={
+ obj: 'Endnotes'
+ }
end
if @md.book_idx
tuned_file << @pb
- h={ ln: 1, lc: 1, obj: 'Index', autonum_: false }
+ h={
+ ln: 1,
+ lc: 1,
+ obj: 'Index',
+ autonum_: false,
+ }
tuned_file << SiSU_AO_DocumentStructure::ObjectHeading.new.heading_insert(h)
- h={ ln: 4, lc: 2, obj: 'Index', name: 'book_index', autonum_: false }
+ h={
+ ln: 4,
+ lc: 2,
+ obj: 'Index',
+ name: 'book_index',
+ autonum_: false,
+ }
tuned_file << SiSU_AO_DocumentStructure::ObjectHeading.new.heading_insert(h)
- h={ obj: 'Index' }
+ h={
+ obj: 'Index'
+ }
end
tuned_file << @pb
- h={ ln: 1, lc: 1, obj: 'Metadata', autonum_: false, ocn_: false }
+ h={
+ ln: 1,
+ lc: 1,
+ obj: 'Metadata',
+ autonum_: false,
+ ocn_: false,
+ }
tuned_file << SiSU_AO_DocumentStructure::ObjectHeading.new.heading_insert(h)
- h={ ln: 4, lc: 2, obj: 'SiSU Metadata, document information', name: 'metadata', autonum_: false, ocn_: false }
+ h={
+ ln: 4,
+ lc: 2,
+ obj: 'SiSU Metadata, document information',
+ name: 'metadata',
+ autonum_: false,
+ ocn_: false,
+ }
tuned_file << SiSU_AO_DocumentStructure::ObjectHeading.new.heading_insert(h)
- h={ obj: 'eof' }
+ h={
+ obj: 'eof',
+ }
meta=SiSU_AO_DocumentStructure::ObjectMetadata.new.metadata(@metadata)
[tuned_file,meta]
end
@@ -811,11 +1106,20 @@ module SiSU_AO_DocumentStructureExtract
table
end
def meta_heading(h)
- h={ lv: h[:lv], ln: h[:ln], name: h[:name], obj: h[:obj], ocn: '0' }
+ h={
+ lv: h[:lv],
+ ln: h[:ln],
+ name: h[:name],
+ obj: h[:obj],
+ ocn: '0',
+ }
SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h)
end
def meta_para(str)
- h={ obj: str, ocn_: false }
+ h={
+ obj: str,
+ ocn_: false,
+ }
SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h)
end
def build_lines(type=:none)
@@ -831,7 +1135,7 @@ module SiSU_AO_DocumentStructureExtract
line=line.gsub(/^/,"#{Mx[:gr_o]}codeline#{Mx[:gr_c]}") if type==:code # REMOVE try sort for texpdf special case
line=if line =~/(?:https?|file|ftp):\/\/\S+$/
line.gsub(/\s*$/," #{Mx[:br_nl]}")
- else line.gsub(/\s*$/,"#{Mx[:br_nl]}") #unless type=='code'
+ else line.gsub(/\s*$/,"#{Mx[:br_nl]}") #unless type=='code'
end
elsif line =~/^\s*$/
line.gsub(/\s*$/,"#{Mx[:br_nl]}")
@@ -843,45 +1147,74 @@ module SiSU_AO_DocumentStructureExtract
end
end
class Structure # this must happen early
- def initialize(md,dob)
- @md,@dob=md,dob
+ def initialize(md)
+ @md=md
end
- def structure
- structure_markup
- @dob
+ def structure(data)
+ data.compact.each do |dob|
+ structure_markup(dob)
+ end
end
- def structure_markup #build structure where structure provided only in meta header
- @dob=if @dob.is==:para \
- && (((@dob.hang !~/[1-9]/) && (@dob.indent !~/[1-9]/)) \
- || (@dob.hang != @dob.indent)) \
- and not @dob.bullet_
- @dob=case @dob.obj
+ def structure_markup(dob) #build structure where structure provided only in meta header
+ dob=if dob.is==:para \
+ && (((dob.hang !~/[1-9]/) && (dob.indent !~/[1-9]/)) \
+ || (dob.hang != dob.indent)) \
+ and not dob.bullet_
+ dob=case dob.obj
when /^#{@md.lv0}/
- h={ lv: 'A', ln: 0 }
- SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,@dob)
+ h={
+ is: :heading,
+ lv: 'A',
+ ln: 0,
+ }
+ SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,dob)
when /^#{@md.lv1}/
- h={ lv: 'B', ln: 1 }
- SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,@dob)
+ h={
+ is: :heading,
+ lv: 'B',
+ ln: 1,
+ }
+ SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,dob)
when /^#{@md.lv2}/
- h={ lv: 'C', ln: 2 }
- SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,@dob)
+ h={
+ is: :heading,
+ lv: 'C',
+ ln: 2,
+ }
+ SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,dob)
when /^#{@md.lv3}/
- h={ lv: 'D', ln: 3 }
- SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,@dob)
+ h={
+ is: :heading,
+ lv: 'D',
+ ln: 3,
+ }
+ SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,dob)
when /^#{@md.lv4}/
- h={ lv: '1', ln: 4 }
- SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,@dob)
+ h={
+ is: :heading,
+ lv: '1',
+ ln: 4,
+ }
+ SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,dob)
when /^#{@md.lv5}/
- h={ lv: '2', ln: 5 }
- SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,@dob)
+ h={
+ is: :heading,
+ lv: '2',
+ ln: 5,
+ }
+ SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,dob)
when /^#{@md.lv6}/
- h={ lv: '3', ln: 6 }
- SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,@dob)
- else @dob
+ h={
+ is: :heading,
+ lv: '3',
+ ln: 6,
+ }
+ SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,dob)
+ else dob
end
- else @dob
+ else dob
end
- @dob
+ dob
end
end
class OCN
@@ -1269,7 +1602,8 @@ SKIPPED processing file: [#{@md.opt.lng}] "#{@md.fns}"}
end
if dob.is==:heading
if ocn_flag==true
- dob.ln,dob.node,dob.ocn,dob.ocn_,dob.odv,dob.osp,dob.parent,dob.lc=ln,node,ocn,ocn_flag,ocn_dv,ocn_sp,parent,collapsed_level
+ dob.ln,dob.node,dob.ocn,dob.ocn_,dob.odv,dob.osp,dob.parent,dob.lc=
+ ln, node, ocn, ocn_flag, ocn_dv,ocn_sp, parent, collapsed_level
else
ocnu+=1
heading_use=:ok
@@ -1280,19 +1614,22 @@ SKIPPED processing file: [#{@md.opt.lng}] "#{@md.fns}"}
dob.obj=dob.obj.gsub(/#{Mx[:pa_non_object_dummy_heading]}/,'')
heading_use=:dummy
end
- dob.ln,dob.node,dob.ocn,dob.ocn_,dob.use_,dob.odv,dob.osp,dob.parent,dob.lc=ln,node,nil,ocn_flag,heading_use,ocn_dv,ocn_sp,parent,collapsed_level
+ dob.ln,dob.node,dob.ocn,dob.ocn_,dob.use_, dob.odv,dob.osp,dob.parent,dob.lc=
+ ln, node, nil, ocn_flag,heading_use,ocn_dv, ocn_sp, parent, collapsed_level
end
else
if dob.of !=:meta \
&& dob.of !=:comment \
&& dob.of !=:layout
if ocn_flag == true
- dob.ocn,dob.ocn_,dob.odv,dob.osp,dob.parent=ocn,ocn_flag,ocn_dv,ocn_sp,parent
+ dob.ocn,dob.ocn_,dob.odv,dob.osp,dob.parent=
+ ocn, ocn_flag,ocn_dv, ocn_sp, parent
else
ocnu+=1
dob.obj=dob.obj.gsub(/#{Mx[:fa_o]}[~-]##{Mx[:fa_c]}/,'') if dob.obj
ocn_dv,ocn_sp="u#{ocnu}","u#{ocnu}"
- dob.ocn,dob.ocn_,dob.odv,dob.osp,dob.parent=nil,ocn_flag,ocn_dv,ocn_sp,parent
+ dob.ocn,dob.ocn_,dob.odv,dob.osp,dob.parent=
+ nil, ocn_flag,ocn_dv, ocn_sp, parent
end
end
end
@@ -1340,7 +1677,10 @@ 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"
@@ -1432,7 +1772,13 @@ SKIPPED processing file: [#{@md.opt.lng}] "#{@md.fns}"}
when '5' then 8
when '6' then 9
end
- h={ tag: tag, node: o[:node], lv: o[:lv], ln: ln, status: o[:status] }
+ h={
+ tag: tag,
+ node: o[:node],
+ lv: o[:lv],
+ ln: ln,
+ status: o[:status],
+ }
SiSU_AO_DocumentStructure::ObjectStructure.new.xml_dom(h) #downstream code utilise else ignore like comments
end
def tag_open(o,tag)
@@ -1445,121 +1791,205 @@ 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