aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2014-06-19 19:24:15 -0400
committerRalph Amissah <ralph@amissah.com>2014-06-19 19:24:15 -0400
commitafdedc96a518a59a1ab9959e68f4342415ff873d (patch)
treeb650a791c1a2f4609c3b319a66da33020a0c4ff2 /lib
parentv5 v6: ao, turn id numbers (for tags) into a hash (diff)
v5 v6: ao, regex match for tics "```" followed by space tweaked
Diffstat (limited to 'lib')
-rw-r--r--lib/sisu/v5/ao_doc_str.rb68
-rw-r--r--lib/sisu/v5/ao_expand_insertions.rb4
-rw-r--r--lib/sisu/v5/ao_misc_arrange.rb16
-rw-r--r--lib/sisu/v6/ao_doc_str.rb68
-rw-r--r--lib/sisu/v6/ao_expand_insertions.rb4
-rw-r--r--lib/sisu/v6/ao_misc_arrange.rb16
6 files changed, 88 insertions, 88 deletions
diff --git a/lib/sisu/v5/ao_doc_str.rb b/lib/sisu/v5/ao_doc_str.rb
index 8f708803..ec925018 100644
--- a/lib/sisu/v5/ao_doc_str.rb
+++ b/lib/sisu/v5/ao_doc_str.rb
@@ -255,7 +255,7 @@ module SiSU_AO_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|table)|^[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/ \
+ and t_o !~/^```[ ]+(?:code|poem|alt|group|block|table)|^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/ \
and @@flag[:code]==:off \
and @@flag[:poem]==:off \
and @@flag[:group]==:off \
@@ -416,58 +416,58 @@ module SiSU_AO_DocumentStructureExtract
end
end
elsif @@flag[:code]==:off
- if t_o =~/^(?:code\{|[`]{3}\s+code)/
+ if t_o =~/^(?:code\{|```[ ]+code)/
@@flag[:code]=case t_o
when /^code\{/ then :curls
- when /^[`]{3}\s+code/ then :tics
+ when /^```[ ]+code/ then :tics
else @@flag[:code] #error
end
@@counter=1
- @codeblock_numbered=(t_o =~/^(?:code\{#|[`]{3}\s+code\s[#])/) ? true : false
+ @codeblock_numbered=(t_o =~/^(?:code\{#|```[ ]+code\s[#])/) ? true : false
@num_id[:code_block] +=1
h={ obj: "code block start #{@num_id[:code_block]}" }
t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h)
- elsif t_o =~/^(?:poem\{|[`]{3}\s+poem)/
+ elsif t_o =~/^(?:poem\{|```[ ]+poem)/
@@flag[:poem]=case t_o
- when /^poem\{/ then :curls
- when /^[`]{3}\s+poem/ then :tics
- else @@flag[:poem] #error
+ when /^poem\{/ then :curls
+ when /^```[ ]+poem/ then :tics
+ else @@flag[:poem] #error
end
@num_id[:poem] +=1
h={ obj: "poem start #{@num_id[:poem]}" }
t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h)
tuned_file << t_o
- elsif t_o =~/^(?:group\{|[`]{3}\s+group)/
+ elsif t_o =~/^(?:group\{|```[ ]+group)/
@@flag[:group]=case t_o
- when /^group\{/ then :curls
- when /^[`]{3}\s+group/ then :tics
- else @@flag[:group] #error
+ when /^group\{/ then :curls
+ when /^```[ ]+group/ then :tics
+ else @@flag[:group] #error
end
@num_id[:group] +=1
h={ obj: "group text start #{@num_id[:group]}" }
t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h)
tuned_file << t_o
- elsif t_o =~/^(?:block\{|[`]{3}\s+block)/
+ elsif t_o =~/^(?:block\{|```[ ]+block)/
@@flag[:block]=case t_o
- when /^block\{/ then :curls
- when /^[`]{3}\s+block/ then :tics
- else @@flag[:block] #error
+ when /^block\{/ then :curls
+ when /^```[ ]+block/ then :tics
+ else @@flag[:block] #error
end
@num_id[:block] +=1
h={ obj: "block text start #{@num_id[:block]}" }
t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h)
tuned_file << t_o
- elsif t_o =~/^(?:alt\{|[`]{3}\s+alt)/
+ elsif t_o =~/^(?:alt\{|```[ ]+alt)/
@@flag[:alt]=case t_o
when /^alt\{/ then :curls
- when /^[`]{3}\s+alt/ then :tics
+ when /^```[ ]+alt/ then :tics
else @@flag[:alt] #error
end
@num_id[:alt] +=1
h={ obj: "alt text start #{@num_id[:alt]}" }
t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h)
tuned_file << t_o
- elsif t_o =~/^(?:table\{|[`]{3}\s+table|\{table)[ ~]/
+ elsif t_o =~/^(?:table\{|```[ ]+table|\{table)[ ~]/
@num_id[:table] +=1
h={ obj: "table start #{@num_id[:table]}" }
ins=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h)
@@ -486,15 +486,15 @@ module SiSU_AO_DocumentStructureExtract
heading=false
end
@h={ head_: heading, cols: cols, widths: col, idx: idx }
- elsif t_o=~/^[`]{3}\s+table(?:~h)?\s+c\d+/
+ elsif t_o=~/^```[ ]+table(?:~h)?\s+c\d+/
@@flag[:table]=:tics
@rows=''
case t_o
- when /^[`]{3}\s+table~h\s+c(\d+);\s+(.+)/
+ when /^```[ ]+table~h\s+c(\d+);\s+(.+)/
cols=$1
col=$2.scan(/\d+/)
heading=true
- when /^[`]{3}\s+table\s+c(\d+);\s+(.+)/
+ when /^```[ ]+table\s+c(\d+);\s+(.+)/
cols=$1
col=$2.scan(/\d+/)
heading=false
@@ -529,12 +529,12 @@ module SiSU_AO_DocumentStructureExtract
h={ obj: "table end #{@num_id[:table]}" }
t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h)
t_o
- elsif t_o=~/^[`]{3}\s+table(?:~h)?\s+/
+ elsif t_o=~/^```[ ]+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
+ when /^```[ ]+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
+ when /^```[ ]+table\s+(.+?)\n(.+)\Z/m #two table representations should be consolidated as one
m1,tbl,hd=$1,$2,false
else nil
end
@@ -583,7 +583,7 @@ module SiSU_AO_DocumentStructureExtract
if (@@flag[:table]==:curls \
and t_o =~/^\}table/) \
or (@@flag[:table]==:tics \
- and t_o =~/^[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/)
+ 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 }
@@ -595,7 +595,7 @@ module SiSU_AO_DocumentStructureExtract
t_o
else
if t_o.is_a?(String) \
- and t_o !~/^(?:table\{|[`]{3}\s+table)/
+ and t_o !~/^(?:table\{|```[ ]+table)/
t_o=t_o.gsub(/^\n+/m,''). #check added for ruby 1.9.2 not needed in 1.8 series (tested in v2)
gsub(/\n+/m,"#{Mx[:tc_p]}")
@rows += t_o + Mx[:tc_c]
@@ -605,7 +605,7 @@ module SiSU_AO_DocumentStructureExtract
end
if @@flag[:code]==:curls or @@flag[:code]==:tics
if (@@flag[:code]==:curls and t_o =~/^\}code/) \
- or (@@flag[:code]==:tics and t_o =~/^[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/)
+ or (@@flag[:code]==:tics and t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/)
@@flag[:code]=:off
@tuned_code[-1].gsub!(/\s*(?:#{Mx[:br_line]}|#{Mx[:br_nl]})\s*\Z/m,'')
obj=@tuned_code.join("\n")
@@ -631,12 +631,12 @@ module SiSU_AO_DocumentStructureExtract
or (@@flag[:block]==:curls or @@flag[:block]==:tics) \
or (@@flag[:alt]==:curls or @@flag[:alt]==:tics)
if (@@flag[:poem]==:curls and t_o =~/^\}poem/) \
- or (@@flag[:poem]==:tics and t_o =~/^[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/)
+ or (@@flag[:poem]==:tics and t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/)
@@flag[:poem]=:off
h={ obj: "poem end #{@num_id[:poem]}" }
t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h)
elsif (@@flag[:group]==:curls and t_o =~/^\}group/) \
- or (@@flag[:group]==:tics and t_o =~/^[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/)
+ 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] }
@@ -646,7 +646,7 @@ module SiSU_AO_DocumentStructureExtract
h={ obj: "group text end #{@num_id[:group]}" }
t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h)
elsif (@@flag[:block]==:curls and t_o =~/^\}block/) \
- or (@@flag[:block]==:tics and t_o =~/^[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/)
+ 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] }
@@ -656,7 +656,7 @@ module SiSU_AO_DocumentStructureExtract
h={ obj: "block text end #{@num_id[:block]}" }
t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h)
elsif (@@flag[:alt]==:curls and t_o =~/^\}alt/) \
- or (@@flag[:alt]==:tics and t_o =~/^[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/)
+ 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] }
@@ -671,7 +671,7 @@ module SiSU_AO_DocumentStructureExtract
or @@flag[:alt]==:curls or @@flag[:alt]==:tics) \
and t_o =~/\S/ \
and t_o !~/^(?:\}(?:verse|code|alt|group|block)|(?:verse|code|alt|group|block)\{)/ \
- and t_o !~/^[`]{3}\s+(?:code|poem|alt|group|block)|^[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/ # fix logic
+ and t_o !~/^```[ ]+(?:code|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
@@ -759,7 +759,7 @@ module SiSU_AO_DocumentStructureExtract
lines.each do |line|
line=if line =~/\S/ \
and line !~/^(?:code\{|\}code)/ \
- and line !~/^(?:[`]{3}\s+code|[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$)/ \
+ and line !~/^(?:```[ ]+code|```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$)/ \
and not line.is_a?(Hash) #watch
@@counter+=1 if @@flag[:code]==:curls or @@flag[:code]==:tics
line=line.gsub(/\s\s/,"#{Mx[:nbsp]*2}").
diff --git a/lib/sisu/v5/ao_expand_insertions.rb b/lib/sisu/v5/ao_expand_insertions.rb
index 60117e1d..ea499119 100644
--- a/lib/sisu/v5/ao_expand_insertions.rb
+++ b/lib/sisu/v5/ao_expand_insertions.rb
@@ -333,9 +333,9 @@ module SiSU_AO_Insertions
tuned_file,tuned_file_tmp=[],[]
codeblock_=false
data.each do |para|
- codeblock_=if para =~/^(?:code\{|[`]{3}\s+code)/
+ codeblock_=if para =~/^(?:code\{|```[ ]+code)/
true
- elsif para =~/^(?:\}code|[`]{3}(?:\s|$))/m
+ elsif para =~/^(?:\}code|```(?:\s|$))/m
false
else codeblock_
end
diff --git a/lib/sisu/v5/ao_misc_arrange.rb b/lib/sisu/v5/ao_misc_arrange.rb
index caf3326c..03d1e735 100644
--- a/lib/sisu/v5/ao_misc_arrange.rb
+++ b/lib/sisu/v5/ao_misc_arrange.rb
@@ -77,22 +77,22 @@ module SiSU_AO_MiscArrangeText
def code_blocks(para)
def ticks(para)
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=~/^[`]{3}\s+table(?:~h)?\s+/) \
- and (para !~/^[`]{3}\s+table(?:~h)?\s+c\d+/)) \
+ if para =~/\A```[ ]+.+?\n.+?\n```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*\Z/m
+ block_open,text,block_close=/\A(```[ ]+.+?)\n(.+?)\n(```(\s+[~-][#]|\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[`]{3}\s+.+?\n.*?\Z/m #look at, study
- block_open,text=/\A([`]{3}(?:\s+.+?))\n(.*?)\Z/m.match(para)[1,2]
+ elsif para =~/\A```[ ]+.+?\n.*?\Z/m #look at, study
+ block_open,text=/\A(```(?:\s+.+?))\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[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*\Z/m
- text,block_close=/\A(.+?)\n([`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?)\s*\Z/m.match(para)[1,2]
+ elsif para =~/\A.+?\n```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*\Z/m
+ text,block_close=/\A(.+?)\n(```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?)\s*\Z/m.match(para)[1,2]
para=[]
if not text.to_s.empty?
para << text.to_s << block_close
diff --git a/lib/sisu/v6/ao_doc_str.rb b/lib/sisu/v6/ao_doc_str.rb
index ebee81aa..6ddc706a 100644
--- a/lib/sisu/v6/ao_doc_str.rb
+++ b/lib/sisu/v6/ao_doc_str.rb
@@ -255,7 +255,7 @@ module SiSU_AO_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|table)|^[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/ \
+ and t_o !~/^```[ ]+(?:code|poem|alt|group|block|table)|^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/ \
and @@flag[:code]==:off \
and @@flag[:poem]==:off \
and @@flag[:group]==:off \
@@ -416,58 +416,58 @@ module SiSU_AO_DocumentStructureExtract
end
end
elsif @@flag[:code]==:off
- if t_o =~/^(?:code\{|[`]{3}\s+code)/
+ if t_o =~/^(?:code\{|```[ ]+code)/
@@flag[:code]=case t_o
when /^code\{/ then :curls
- when /^[`]{3}\s+code/ then :tics
+ when /^```[ ]+code/ then :tics
else @@flag[:code] #error
end
@@counter=1
- @codeblock_numbered=(t_o =~/^(?:code\{#|[`]{3}\s+code\s[#])/) ? true : false
+ @codeblock_numbered=(t_o =~/^(?:code\{#|```[ ]+code\s[#])/) ? true : false
@num_id[:code_block] +=1
h={ obj: "code block start #{@num_id[:code_block]}" }
t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h)
- elsif t_o =~/^(?:poem\{|[`]{3}\s+poem)/
+ elsif t_o =~/^(?:poem\{|```[ ]+poem)/
@@flag[:poem]=case t_o
- when /^poem\{/ then :curls
- when /^[`]{3}\s+poem/ then :tics
- else @@flag[:poem] #error
+ when /^poem\{/ then :curls
+ when /^```[ ]+poem/ then :tics
+ else @@flag[:poem] #error
end
@num_id[:poem] +=1
h={ obj: "poem start #{@num_id[:poem]}" }
t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h)
tuned_file << t_o
- elsif t_o =~/^(?:group\{|[`]{3}\s+group)/
+ elsif t_o =~/^(?:group\{|```[ ]+group)/
@@flag[:group]=case t_o
- when /^group\{/ then :curls
- when /^[`]{3}\s+group/ then :tics
- else @@flag[:group] #error
+ when /^group\{/ then :curls
+ when /^```[ ]+group/ then :tics
+ else @@flag[:group] #error
end
@num_id[:group] +=1
h={ obj: "group text start #{@num_id[:group]}" }
t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h)
tuned_file << t_o
- elsif t_o =~/^(?:block\{|[`]{3}\s+block)/
+ elsif t_o =~/^(?:block\{|```[ ]+block)/
@@flag[:block]=case t_o
- when /^block\{/ then :curls
- when /^[`]{3}\s+block/ then :tics
- else @@flag[:block] #error
+ when /^block\{/ then :curls
+ when /^```[ ]+block/ then :tics
+ else @@flag[:block] #error
end
@num_id[:block] +=1
h={ obj: "block text start #{@num_id[:block]}" }
t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h)
tuned_file << t_o
- elsif t_o =~/^(?:alt\{|[`]{3}\s+alt)/
+ elsif t_o =~/^(?:alt\{|```[ ]+alt)/
@@flag[:alt]=case t_o
when /^alt\{/ then :curls
- when /^[`]{3}\s+alt/ then :tics
+ when /^```[ ]+alt/ then :tics
else @@flag[:alt] #error
end
@num_id[:alt] +=1
h={ obj: "alt text start #{@num_id[:alt]}" }
t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h)
tuned_file << t_o
- elsif t_o =~/^(?:table\{|[`]{3}\s+table|\{table)[ ~]/
+ elsif t_o =~/^(?:table\{|```[ ]+table|\{table)[ ~]/
@num_id[:table] +=1
h={ obj: "table start #{@num_id[:table]}" }
ins=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h)
@@ -486,15 +486,15 @@ module SiSU_AO_DocumentStructureExtract
heading=false
end
@h={ head_: heading, cols: cols, widths: col, idx: idx }
- elsif t_o=~/^[`]{3}\s+table(?:~h)?\s+c\d+/
+ elsif t_o=~/^```[ ]+table(?:~h)?\s+c\d+/
@@flag[:table]=:tics
@rows=''
case t_o
- when /^[`]{3}\s+table~h\s+c(\d+);\s+(.+)/
+ when /^```[ ]+table~h\s+c(\d+);\s+(.+)/
cols=$1
col=$2.scan(/\d+/)
heading=true
- when /^[`]{3}\s+table\s+c(\d+);\s+(.+)/
+ when /^```[ ]+table\s+c(\d+);\s+(.+)/
cols=$1
col=$2.scan(/\d+/)
heading=false
@@ -529,12 +529,12 @@ module SiSU_AO_DocumentStructureExtract
h={ obj: "table end #{@num_id[:table]}" }
t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h)
t_o
- elsif t_o=~/^[`]{3}\s+table(?:~h)?\s+/
+ elsif t_o=~/^```[ ]+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
+ when /^```[ ]+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
+ when /^```[ ]+table\s+(.+?)\n(.+)\Z/m #two table representations should be consolidated as one
m1,tbl,hd=$1,$2,false
else nil
end
@@ -583,7 +583,7 @@ module SiSU_AO_DocumentStructureExtract
if (@@flag[:table]==:curls \
and t_o =~/^\}table/) \
or (@@flag[:table]==:tics \
- and t_o =~/^[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/)
+ 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 }
@@ -595,7 +595,7 @@ module SiSU_AO_DocumentStructureExtract
t_o
else
if t_o.is_a?(String) \
- and t_o !~/^(?:table\{|[`]{3}\s+table)/
+ and t_o !~/^(?:table\{|```[ ]+table)/
t_o=t_o.gsub(/^\n+/m,''). #check added for ruby 1.9.2 not needed in 1.8 series (tested in v2)
gsub(/\n+/m,"#{Mx[:tc_p]}")
@rows += t_o + Mx[:tc_c]
@@ -605,7 +605,7 @@ module SiSU_AO_DocumentStructureExtract
end
if @@flag[:code]==:curls or @@flag[:code]==:tics
if (@@flag[:code]==:curls and t_o =~/^\}code/) \
- or (@@flag[:code]==:tics and t_o =~/^[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/)
+ or (@@flag[:code]==:tics and t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/)
@@flag[:code]=:off
@tuned_code[-1].gsub!(/\s*(?:#{Mx[:br_line]}|#{Mx[:br_nl]})\s*\Z/m,'')
obj=@tuned_code.join("\n")
@@ -631,12 +631,12 @@ module SiSU_AO_DocumentStructureExtract
or (@@flag[:block]==:curls or @@flag[:block]==:tics) \
or (@@flag[:alt]==:curls or @@flag[:alt]==:tics)
if (@@flag[:poem]==:curls and t_o =~/^\}poem/) \
- or (@@flag[:poem]==:tics and t_o =~/^[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/)
+ or (@@flag[:poem]==:tics and t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/)
@@flag[:poem]=:off
h={ obj: "poem end #{@num_id[:poem]}" }
t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h)
elsif (@@flag[:group]==:curls and t_o =~/^\}group/) \
- or (@@flag[:group]==:tics and t_o =~/^[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/)
+ 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] }
@@ -646,7 +646,7 @@ module SiSU_AO_DocumentStructureExtract
h={ obj: "group text end #{@num_id[:group]}" }
t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h)
elsif (@@flag[:block]==:curls and t_o =~/^\}block/) \
- or (@@flag[:block]==:tics and t_o =~/^[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/)
+ 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] }
@@ -656,7 +656,7 @@ module SiSU_AO_DocumentStructureExtract
h={ obj: "block text end #{@num_id[:block]}" }
t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h)
elsif (@@flag[:alt]==:curls and t_o =~/^\}alt/) \
- or (@@flag[:alt]==:tics and t_o =~/^[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/)
+ 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] }
@@ -671,7 +671,7 @@ module SiSU_AO_DocumentStructureExtract
or @@flag[:alt]==:curls or @@flag[:alt]==:tics) \
and t_o =~/\S/ \
and t_o !~/^(?:\}(?:verse|code|alt|group|block)|(?:verse|code|alt|group|block)\{)/ \
- and t_o !~/^[`]{3}\s+(?:code|poem|alt|group|block)|^[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/ # fix logic
+ and t_o !~/^```[ ]+(?:code|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
@@ -759,7 +759,7 @@ module SiSU_AO_DocumentStructureExtract
lines.each do |line|
line=if line =~/\S/ \
and line !~/^(?:code\{|\}code)/ \
- and line !~/^(?:[`]{3}\s+code|[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$)/ \
+ and line !~/^(?:```[ ]+code|```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$)/ \
and not line.is_a?(Hash) #watch
@@counter+=1 if @@flag[:code]==:curls or @@flag[:code]==:tics
line=line.gsub(/\s\s/,"#{Mx[:nbsp]*2}").
diff --git a/lib/sisu/v6/ao_expand_insertions.rb b/lib/sisu/v6/ao_expand_insertions.rb
index 65386c48..6b1e642d 100644
--- a/lib/sisu/v6/ao_expand_insertions.rb
+++ b/lib/sisu/v6/ao_expand_insertions.rb
@@ -333,9 +333,9 @@ module SiSU_AO_Insertions
tuned_file,tuned_file_tmp=[],[]
codeblock_=false
data.each do |para|
- codeblock_=if para =~/^(?:code\{|[`]{3}\s+code)/
+ codeblock_=if para =~/^(?:code\{|```[ ]+code)/
true
- elsif para =~/^(?:\}code|[`]{3}(?:\s|$))/m
+ elsif para =~/^(?:\}code|```(?:\s|$))/m
false
else codeblock_
end
diff --git a/lib/sisu/v6/ao_misc_arrange.rb b/lib/sisu/v6/ao_misc_arrange.rb
index a2cbb6c1..d30176bf 100644
--- a/lib/sisu/v6/ao_misc_arrange.rb
+++ b/lib/sisu/v6/ao_misc_arrange.rb
@@ -77,22 +77,22 @@ module SiSU_AO_MiscArrangeText
def code_blocks(para)
def ticks(para)
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=~/^[`]{3}\s+table(?:~h)?\s+/) \
- and (para !~/^[`]{3}\s+table(?:~h)?\s+c\d+/)) \
+ if para =~/\A```[ ]+.+?\n.+?\n```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*\Z/m
+ block_open,text,block_close=/\A(```[ ]+.+?)\n(.+?)\n(```(\s+[~-][#]|\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[`]{3}\s+.+?\n.*?\Z/m #look at, study
- block_open,text=/\A([`]{3}(?:\s+.+?))\n(.*?)\Z/m.match(para)[1,2]
+ elsif para =~/\A```[ ]+.+?\n.*?\Z/m #look at, study
+ block_open,text=/\A(```(?:\s+.+?))\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[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*\Z/m
- text,block_close=/\A(.+?)\n([`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?)\s*\Z/m.match(para)[1,2]
+ elsif para =~/\A.+?\n```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*\Z/m
+ text,block_close=/\A(.+?)\n(```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?)\s*\Z/m.match(para)[1,2]
para=[]
if not text.to_s.empty?
para << text.to_s << block_close