diff options
author | Ralph Amissah <ralph@amissah.com> | 2014-06-19 19:33:41 -0400 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2014-06-19 19:33:41 -0400 |
commit | dffa2293ca33039bc9a625c23842644104fcf401 (patch) | |
tree | 1679f52825636a7b38e5472334ffd0de84e36820 | |
parent | v6: ao, syntax, able optionally to indicate the language syntax of a code block (diff) |
v6: ao, syntax, introduce box text block/group
-rw-r--r-- | data/doc/sisu/CHANGELOG_v6 | 1 | ||||
-rw-r--r-- | lib/sisu/v6/ao_doc_objects.rb | 20 | ||||
-rw-r--r-- | lib/sisu/v6/ao_doc_str.rb | 37 | ||||
-rw-r--r-- | lib/sisu/v6/ao_misc_arrange.rb | 22 | ||||
-rw-r--r-- | lib/sisu/v6/ao_syntax.rb | 2 |
5 files changed, 66 insertions, 16 deletions
diff --git a/data/doc/sisu/CHANGELOG_v6 b/data/doc/sisu/CHANGELOG_v6 index 3f8f6e29..04248097 100644 --- a/data/doc/sisu/CHANGELOG_v6 +++ b/data/doc/sisu/CHANGELOG_v6 @@ -33,6 +33,7 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_6.0.8.orig.tar.xz * Symbol to match grouped text open & close (instead of String) * introduce way of removing unrecognized tic markers * syntax, able optionally to indicate the language syntax of a code block + * syntax, introduce box text block/group * turn id numbers (for tags) into a hash * code blocks, clean trailing newlines * misc, minorish diff --git a/lib/sisu/v6/ao_doc_objects.rb b/lib/sisu/v6/ao_doc_objects.rb index 9356321c..e1a14da1 100644 --- a/lib/sisu/v6/ao_doc_objects.rb +++ b/lib/sisu/v6/ao_doc_objects.rb @@ -268,6 +268,26 @@ module SiSU_AO_DocumentStructure @of,@is,@tags,@obj,@lngsyn,@idx,@ocn,@odv,@osp,@parent,@number_,@note_,@ocn_,@num,@digest,@tmp=of,is,tags,obj,lngsyn,idx,ocn,odv,osp,parent,number_,note_,ocn_,num,digest,tmp self end + def box(h,o=nil) + of= @of #Symbol, classification - group + is= :box #Symbol, classification - specific type + tags= h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any + obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content + idx= h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? + ocn= h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects + odv= h[:odv] || ((defined? o.odv) ? o.odv : nil) + osp= h[:osp] || ((defined? o.osp) ? o.osp : nil) + parent= h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] + note_= h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) + ocn_= if h[:ocn_].nil? then ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider + else h[:ocn_] + end + num= h[:num] || ((defined? o.num) ? o.num : nil) + digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, sha512, sha256 or md5 + tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use + @of,@is,@tags,@obj,@idx,@ocn,@odv,@osp,@parent,@note_,@ocn_,@num,@digest,@tmp=of,is,tags,obj,idx,ocn,odv,osp,parent,note_,ocn_,num,digest,tmp + self + end def block(h,o=nil) of= @of #Symbol, classification - group is= :block #Symbol, classification - specific type diff --git a/lib/sisu/v6/ao_doc_str.rb b/lib/sisu/v6/ao_doc_str.rb index 0d9d7576..cd4f62e8 100644 --- a/lib/sisu/v6/ao_doc_str.rb +++ b/lib/sisu/v6/ao_doc_str.rb @@ -68,6 +68,7 @@ module SiSU_AO_DocumentStructureExtract lngsyn: :txt, poem: :off, block: :off, + box: :off, group: :off, alt: :off, table: :off, @@ -85,6 +86,7 @@ module SiSU_AO_DocumentStructureExtract lngsyn: :txt, poem: :off, block: :off, + box: :off, group: :off, alt: :off, table: :off, @@ -231,6 +233,7 @@ module SiSU_AO_DocumentStructureExtract @num_id={ code_block: 0, poem: 0, + box: 0, group: 0, alt: 0, table: 0, @@ -256,13 +259,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(?:\.[a-z][0-9a-z_]+)?|poem|alt|group|block)\{|^\}(?:code|poem|alt|group|block)|^(?:table\{|\{table)[ ~]/ \ - and t_o !~/^```[ ]+(?:code(?:\.[a-z][0-9a-z_]+)?|poem|alt|group|block|table)|^```(?:\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*$/ \ 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 @@ -449,6 +453,16 @@ module SiSU_AO_DocumentStructureExtract h={ obj: "poem start #{@num_id[:poem]}" } t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(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 + end + @num_id[:box] +=1 + h={ obj: "box text start #{@num_id[:box]}" } + t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) + tuned_file << t_o elsif t_o =~/^(?:group\{|```[ ]+group)/ @@flag[:group]=case t_o when /^group\{/ then :curls @@ -640,6 +654,7 @@ 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) @@ -648,6 +663,16 @@ module SiSU_AO_DocumentStructureExtract @@flag[:poem]=:off h={ obj: "poem end #{@num_id[:poem]}" } t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(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: "box text end #{@num_id[:box]}" } + t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) elsif (@@flag[:group]==:curls and t_o =~/^\}group/) \ or (@@flag[:group]==:tics and t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) @@flag[:group]=:off @@ -683,8 +708,8 @@ module SiSU_AO_DocumentStructureExtract 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(?:\.[a-z][0-9a-z_]+)?|alt|group|block)\{)/ \ - and t_o !~/^```[ ]+(?:code(?:\.[a-z][0-9a-z_]+)?|poem|alt|group|block)|^```(?:\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 @@ -705,6 +730,7 @@ 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 if t_o.is_a?(String) @@ -715,6 +741,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}"). @@ -1203,6 +1230,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 @@ -1250,6 +1278,7 @@ 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") #newlines taken out diff --git a/lib/sisu/v6/ao_misc_arrange.rb b/lib/sisu/v6/ao_misc_arrange.rb index a6b3a73d..9279f888 100644 --- a/lib/sisu/v6/ao_misc_arrange.rb +++ b/lib/sisu/v6/ao_misc_arrange.rb @@ -77,14 +77,14 @@ module SiSU_AO_MiscArrangeText def markup_blocks(para) def ticks(para) block_open,block_close,text=nil,nil,nil - if para =~/\A```[ ]+(?:code(?:\.[a-z][0-9a-z_]+)?|poem|alt|group|block|table).*?\n.+?\n```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*\Z/m + if para =~/\A```[ ]+(?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block|table).*?\n.+?\n```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*\Z/m @flag=:close - block_open,text,block_close=/\A(```[ ]+(?:code(?:\.[a-z][0-9a-z_]+)?|poem|alt|group|block|table).*?)\n(.+?)\n(```([ ]+[~-][#]|\s+\~\{.+?\}\~)?)\s*\Z/m.match(para)[1..3] + block_open,text,block_close=/\A(```[ ]+(?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block|table).*?)\n(.+?)\n(```([ ]+[~-][#]|\s+\~\{.+?\}\~)?)\s*\Z/m.match(para)[1..3] ((para=~/^```[ ]+table(?:~h)?\s+/) \ and (para !~/^```[ ]+table(?:~h)?\s+c\d+/)) \ ? para : (para=[]; para << block_open << text << block_close) - elsif para =~/\A```[ ]+(?:code(?:\.[a-z][0-9a-z_]+)?|poem|alt|group|block|table).*?\n.*?\Z/m #look at, study + elsif para =~/\A```[ ]+(?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block|table).*?\n.*?\Z/m #look at, study @flag=:open block_open,text=/\A(```(?:[ ]+.+?))\n(.*?)\Z/m.match(para)[1,2] para=[] @@ -117,20 +117,20 @@ module SiSU_AO_MiscArrangeText end def curly_braces(para) block_open,block_close,text=nil,nil,nil - para=if para =~/\A(?:code(?:\.[a-z][0-9a-z_]+)?|poem|alt|group|block|table)\{ .+?\n.+?\n\}(?:code|poem|alt|group|block|table)(?: [~-][#])?\s*\Z/m - block_open,text,block_close=/\A((?:code(?:\.[a-z][0-9a-z_]+)?|poem|alt|group|block|table)\{ .+?)\n(.+?)\n(\}(?:code|poem|alt|group|block|table)(?: [~-][#])?)\s*\Z/m.match(para)[1..3] + para=if para =~/\A(?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block|table)\{ .+?\n.+?\n\}(?:code|box|poem|alt|group|block|table)(?: [~-][#])?\s*\Z/m + block_open,text,block_close=/\A((?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block|table)\{ .+?)\n(.+?)\n(\}(?:code|box|poem|alt|group|block|table)(?: [~-][#])?)\s*\Z/m.match(para)[1..3] para=[] para << block_open << text << block_close - elsif para =~/\A(?:code(?:\.[a-z][0-9a-z_]+)?|poem|alt|group|block|table)\{ .+?\n.+?\Z/m - block_open,text=/\A((?:code(?:\.[a-z][0-9a-z_]+)?|poem|alt|group|block|table)\{ .+?)\n(.+?)\Z/m.match(para)[1,2] + elsif para =~/\A(?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block|table)\{ .+?\n.+?\Z/m + block_open,text=/\A((?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block|table)\{ .+?)\n(.+?)\Z/m.match(para)[1,2] para=[] if not text.to_s.empty? para << block_open << text else para << block_open end - elsif para =~/\A.+?\n\}(?:code|poem|alt|group|block|table)(?: [~-][#])?\s*\Z/m - text,block_close=/\A(.+?)\n(\}(?:code|poem|alt|group|block|table)(?: [~-][#])?)\s*\Z/m.match(para)[1,2] + elsif para =~/\A.+?\n\}(?:code|box|poem|alt|group|block|table)(?: [~-][#])?\s*\Z/m + text,block_close=/\A(.+?)\n(\}(?:code|box|poem|alt|group|block|table)(?: [~-][#])?)\s*\Z/m.match(para)[1,2] para=[] if not text.to_s.empty? para << text.to_s << block_close @@ -141,7 +141,7 @@ module SiSU_AO_MiscArrangeText end para end - para=if para =~/\A```[ ]+(?:code(?:\.[a-z][0-9a-z_]+)?|poem|alt|group|block|table).*?\n.*?\Z/m \ + para=if para =~/\A```[ ]+(?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block|table).*?\n.*?\Z/m \ or @flag==:open ticks(para) elsif para =~/```/m @@ -149,7 +149,7 @@ module SiSU_AO_MiscArrangeText else para end - para=(para =~/^(?:code(?:\.[a-z][0-9a-z_]+)?|poem|alt|group|block|table)\{|^\}(?:code|poem|alt|group|block|table)/m) \ + para=(para =~/^(?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block|table)\{|^\}(?:code|poem|alt|group|block|table)/m) \ ? curly_braces(para) : para end diff --git a/lib/sisu/v6/ao_syntax.rb b/lib/sisu/v6/ao_syntax.rb index fb3508b9..b30847a8 100644 --- a/lib/sisu/v6/ao_syntax.rb +++ b/lib/sisu/v6/ao_syntax.rb @@ -91,7 +91,7 @@ module SiSU_AO_Syntax { o: Mx[:fa_underscore_o], c: Mx[:fa_underscore_c] } else p __LINE__.to_s + '::' + __FILE__ end - @http_m=%r{\{.+?\}https?://\S+|https?:\S+|:\S+|\.\.\/\S+|#\S+|\S+?\.png\b|[*]~\S+|^#{Mx[:meta_o]}.+|#{Mx[:gr_o]}(?:code(?:\.[a-z][0-9a-z_]+)?|block|group|alt|verse)(?:-end)?#{Mx[:gr_c]}|#{Mx[:fa_o]}:br#{Mx[:fa_c]}} + @http_m=%r{\{.+?\}https?://\S+|https?:\S+|:\S+|\.\.\/\S+|#\S+|\S+?\.png\b|[*]~\S+|^#{Mx[:meta_o]}.+|#{Mx[:gr_o]}(?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|block|group|alt|verse)(?:-end)?#{Mx[:gr_c]}|#{Mx[:fa_o]}:br#{Mx[:fa_c]}} @manmkp_ital=emph_italics \ ? '[i/*]\\{.+?\\}[i/*]' : '[i/]\\{.+?\\}[i/]' |