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/v4/dal_doc_str.rb | |
parent | v4 v5: odf:odt, footnotes, fix (diff) |
v4 v5: dal, text blocks, tuning
Diffstat (limited to 'lib/sisu/v4/dal_doc_str.rb')
-rw-r--r-- | lib/sisu/v4/dal_doc_str.rb | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/lib/sisu/v4/dal_doc_str.rb b/lib/sisu/v4/dal_doc_str.rb index 6c588a8a..e7d9917b 100644 --- a/lib/sisu/v4/dal_doc_str.rb +++ b/lib/sisu/v4/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 |