From 9347018753e818b49980651df3b77352c5f3792f Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Tue, 1 Jul 2014 00:45:40 -0400 Subject: v5 v6: ao, code cosmetic rearrangement --- lib/sisu/v6/ao_doc_str.rb | 634 +++++++++++++++++++++++++++++++++++++--------- 1 file changed, 517 insertions(+), 117 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 7f2815d8..675bfc90 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+)/ @@ -196,9 +205,13 @@ module SiSU_AO_DocumentStructureExtract 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 +220,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 +239,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 +273,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 @@ -296,7 +327,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 +350,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 +374,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 +399,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 +428,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 +461,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,7 +494,17 @@ 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? } + 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 @@ -447,9 +526,17 @@ 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={ + 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 +545,86 @@ module SiSU_AO_DocumentStructureExtract else @@flag[:poem] #error end @num_id[:poem] +=1 - h={ obj: '', sym: :poem_open, num: @num_id[:poem] } + 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 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={ + 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={ + 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={ + 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={ + 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={ + 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={ + 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 +640,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 +659,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 +675,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 +688,30 @@ 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={ + 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 +720,25 @@ 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={ + 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 +755,25 @@ 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={ + obj: '', + sym: :table_close, + num: @num_id[:table], + } t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) t_o end @@ -626,11 +787,21 @@ 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={ + obj: '', + sym: :table_close, + num: @num_id[:table], + } t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) t_o else @@ -650,12 +821,22 @@ 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={ + 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 +857,102 @@ 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={ + 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={ + 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={ + 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={ 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={ + 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={ + 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 +969,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 +1011,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 +1084,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 +1113,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]}") @@ -857,25 +1139,46 @@ module SiSU_AO_DocumentStructureExtract and not @dob.bullet_ @dob=case @dob.obj when /^#{@md.lv0}/ - h={ lv: 'A', ln: 0 } + h={ + lv: 'A', + ln: 0, + } SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,@dob) when /^#{@md.lv1}/ - h={ lv: 'B', ln: 1 } + h={ + lv: 'B', + ln: 1, + } SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,@dob) when /^#{@md.lv2}/ - h={ lv: 'C', ln: 2 } + h={ + lv: 'C', + ln: 2, + } SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,@dob) when /^#{@md.lv3}/ - h={ lv: 'D', ln: 3 } + h={ + lv: 'D', + ln: 3, + } SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,@dob) when /^#{@md.lv4}/ - h={ lv: '1', ln: 4 } + h={ + lv: '1', + ln: 4, + } SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,@dob) when /^#{@md.lv5}/ - h={ lv: '2', ln: 5 } + h={ + lv: '2', + ln: 5, + } SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,@dob) when /^#{@md.lv6}/ - h={ lv: '3', ln: 6 } + h={ + lv: '3', + ln: 6, + } SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,@dob) else @dob end @@ -1269,7 +1572,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 +1584,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 +1647,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 +1742,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 +1761,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 -- cgit v1.2.3