diff options
author | Ralph Amissah <ralph@amissah.com> | 2013-08-28 18:17:23 -0400 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2013-08-28 18:17:23 -0400 |
commit | 349169b7fb76b63431080552d02bff5e3d29d9ea (patch) | |
tree | 3722c6129b18bff8caee31906a7d154568ebe386 /lib/sisu/v5 | |
parent | v4 v5: odf:odt, footnotes, fix (diff) |
v4 v5: dal, text blocks, tuning
Diffstat (limited to 'lib/sisu/v5')
-rw-r--r-- | lib/sisu/v5/dal_doc_str.rb | 35 | ||||
-rw-r--r-- | lib/sisu/v5/dal_misc_arrange.rb | 6 |
2 files changed, 33 insertions, 8 deletions
diff --git a/lib/sisu/v5/dal_doc_str.rb b/lib/sisu/v5/dal_doc_str.rb index d3f65bff..612d2905 100644 --- a/lib/sisu/v5/dal_doc_str.rb +++ b/lib/sisu/v5/dal_doc_str.rb @@ -194,7 +194,7 @@ module SiSU_DAL_DocumentStructureExtract end t_o=t_o.gsub(/(?:\n\s*\n)+/m,"\n") if @@flag[:code]==:off if t_o !~/^(?:code|poem|alt|group|block)\{|^\}(?:code|poem|alt|group|block)|^(?:table\{|\{table)[ ~]/ \ - and t_o !~/^[`]{3}\s+(?:code|poem|alt|group|block)|^[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/ \ + and t_o !~/^[`]{3}\s+(?:code|poem|alt|group|block|table)|^[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/ \ and @@flag[:code]==:off \ and @@flag[:poem]==:off \ and @@flag[:group]==:off \ @@ -391,7 +391,7 @@ module SiSU_DAL_DocumentStructureExtract h={ obj: 'alt text start' } #introduce a counter t_o=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h) tuned_file << t_o - elsif t_o =~/^(?:table\{|\{table)[ ~]/ + elsif t_o =~/^(?:table\{|[`]{3}\s+table|\{table)[ ~]/ h={ obj: 'table start' } #introduce a counter ins=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h) tuned_file << ins @@ -409,15 +409,15 @@ module SiSU_DAL_DocumentStructureExtract heading=false end @h={ head_: heading, cols: cols, widths: col, idx: idx } - elsif t_o=~/^[`]{3}\s+table(?:~h)?\s+/ + elsif t_o=~/^[`]{3}\s+table(?:~h)?\s+c\d+/ @@flag[:table]=:tics @rows='' case t_o - when /table\{~h\s+c(\d+);\s+(.+)/ + when /^[`]{3}\s+table~h\s+c(\d+);\s+(.+)/ cols=$1 col=$2.scan(/\d+/) heading=true - when /table\{\s+c(\d+);\s+(.+)/ + when /^[`]{3}\s+table\s+c(\d+);\s+(.+)/ cols=$1 col=$2.scan(/\d+/) heading=false @@ -425,7 +425,7 @@ module SiSU_DAL_DocumentStructureExtract @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] #two table representations should be consolidated as one + tbl=/^\{table(?:~h)?(?:\s+\d+;?)?\}\n(.+)\Z/m.match(t_o)[1] hd=((t_o =~/^\{table~h/) ? true : false) tbl,tags=extract_tags(tbl) rws=tbl.split(/\n/) @@ -452,6 +452,29 @@ module SiSU_DAL_DocumentStructureExtract h={ obj: 'table end' } #introduce a counter t_o=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h) t_o + elsif t_o=~/^[`]{3}\s+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 + m1,tbl,hd=$1,$2,true + when /^[`]{3}\s+table\s+(.+?)\n(.+)\Z/m #two table representations should be consolidated as one + m1,tbl,hd=$1,$2,false + else nil + end + tbl,tags=extract_tags(tbl) + col=m1.scan(/\d+/) + rws=tbl.split(/\n/) + rows='' + rws.each do |r| + 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 } + t_o=SiSU_DAL_DocumentStructure::ObjectTable.new.table(h) unless h.nil? + tuned_file << t_o + h={ obj: 'table end' } #introduce a counter + t_o=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h) + t_o elsif t_o=~/^\{table(?:~h)?\s+/ m1,m2,hd=nil,nil,nil h=case t_o diff --git a/lib/sisu/v5/dal_misc_arrange.rb b/lib/sisu/v5/dal_misc_arrange.rb index ab4f3ea4..e6cc72db 100644 --- a/lib/sisu/v5/dal_misc_arrange.rb +++ b/lib/sisu/v5/dal_misc_arrange.rb @@ -78,8 +78,10 @@ module SiSU_DAL_MiscArrangeText block_open,block_close,text=nil,nil,nil if para =~/\A[`]{3}\s+.+?\n.+?\n[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*\Z/m block_open,text,block_close=/\A([`]{3}\s+.+?)\n(.+?)\n([`]{3}(\s+[~-][#]|\s+\~\{.+?\}\~)?)\s*\Z/m.match(para)[1..3] - para=[] - para << block_open << text << block_close + ((para=~/^[`]{3}\s+table(?:~h)?\s+/) \ + and (para !~/^[`]{3}\s+table(?:~h)?\s+c\d+/)) \ + ? para + : (para=[]; para << block_open << text << block_close) elsif para =~/\A[`]{3}\s+.+?\n.*?\Z/m #look at, study block_open,text=/\A([`]{3}(?:\s+.+?))\n(.*?)\Z/m.match(para)[1,2] para=[] |