aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v5/dal_doc_str.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sisu/v5/dal_doc_str.rb')
-rw-r--r--lib/sisu/v5/dal_doc_str.rb65
1 files changed, 32 insertions, 33 deletions
diff --git a/lib/sisu/v5/dal_doc_str.rb b/lib/sisu/v5/dal_doc_str.rb
index ebde930a..d3f65bff 100644
--- a/lib/sisu/v5/dal_doc_str.rb
+++ b/lib/sisu/v5/dal_doc_str.rb
@@ -72,7 +72,6 @@ module SiSU_DAL_DocumentStructureExtract
table_to: :off,
}
def initialize
- @@flag[:table_to]=:off
@@counter=@@column=@@columns=0
@@line_mode=''
end
@@ -195,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 !~/^```\s+(?:code|poem|alt|group|block)|^```(?:\s*[~-][#])?\s*$/ \
+ and t_o !~/^[`]{3}\s+(?:code|poem|alt|group|block)|^[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/ \
and @@flag[:code]==:off \
and @@flag[:poem]==:off \
and @@flag[:group]==:off \
@@ -346,48 +345,48 @@ module SiSU_DAL_DocumentStructureExtract
end
end
elsif @@flag[:code]==:off
- if t_o =~/^(?:code\{|```\s+code)/
+ if t_o =~/^(?:code\{|[`]{3}\s+code)/
@@flag[:code]=case t_o
- when /^code\{/; :curls
- when /^```\s+code/; :tics
- else @@flag[:code] #error
+ when /^code\{/; :curls
+ when /^[`]{3}\s+code/; :tics
+ else @@flag[:code] #error
end
@@counter=1
- @codeblock_numbered=(t_o =~/^(?:code\{#|```\s+code\s[#])/) ? true : false
+ @codeblock_numbered=(t_o =~/^(?:code\{#|[`]{3}\s+code\s[#])/) ? true : false
h={ obj: 'code block start' } #introduce a counter
t_o=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h)
- elsif t_o =~/^(?:poem\{|```\s+poem)/
+ elsif t_o =~/^(?:poem\{|[`]{3}\s+poem)/
@@flag[:poem]=case t_o
- when /^poem\{/; :curls
- when /^```\s+poem/; :tics
- else @@flag[:poem] #error
+ when /^poem\{/; :curls
+ when /^[`]{3}\s+poem/; :tics
+ else @@flag[:poem] #error
end
h={ obj: 'poem start' } #introduce a counter
t_o=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h)
tuned_file << t_o
- elsif t_o =~/^(?:group\{|```\s+group)/
+ elsif t_o =~/^(?:group\{|[`]{3}\s+group)/
@@flag[:group]=case t_o
- when /^group\{/; :curls
- when /^```\s+group/; :tics
- else @@flag[:group] #error
+ when /^group\{/; :curls
+ when /^[`]{3}\s+group/; :tics
+ else @@flag[:group] #error
end
h={ obj: 'group text start' } #introduce a counter
t_o=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h)
tuned_file << t_o
- elsif t_o =~/^(?:block\{|```\s+block)/
+ elsif t_o =~/^(?:block\{|[`]{3}\s+block)/
@@flag[:block]=case t_o
- when /^block\{/; :curls
- when /^```\s+block/; :tics
- else @@flag[:block] #error
+ when /^block\{/; :curls
+ when /^[`]{3}\s+block/; :tics
+ else @@flag[:block] #error
end
h={ obj: 'block text start' } #introduce a counter
t_o=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h)
tuned_file << t_o
- elsif t_o =~/^(?:alt\{|```\s+alt)/
+ elsif t_o =~/^(?:alt\{|[`]{3}\s+alt)/
@@flag[:alt]=case t_o
- when /^alt\{/; :curls
- when /^```\s+alt/; :tics
- else @@flag[:alt] #error
+ when /^alt\{/; :curls
+ when /^[`]{3}\s+alt/; :tics
+ else @@flag[:alt] #error
end
h={ obj: 'alt text start' } #introduce a counter
t_o=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h)
@@ -410,7 +409,7 @@ module SiSU_DAL_DocumentStructureExtract
heading=false
end
@h={ head_: heading, cols: cols, widths: col, idx: idx }
- elsif t_o=~/^```\s+table(?:~h)?\s+/
+ elsif t_o=~/^[`]{3}\s+table(?:~h)?\s+/
@@flag[:table]=:tics
@rows=''
case t_o
@@ -484,7 +483,7 @@ module SiSU_DAL_DocumentStructureExtract
if (@@flag[:table]==:curls \
and t_o =~/^\}table/) \
or (@@flag[:table]==:tics \
- and t_o =~/^```(?:\s*[~-][#])?\s*$/)
+ and t_o =~/^[`]{3}(?:\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 }
@@ -496,7 +495,7 @@ module SiSU_DAL_DocumentStructureExtract
t_o
else
if t_o.is_a?(String) \
- and t_o !~/^(?:table\{|```\s+table)/
+ and t_o !~/^(?:table\{|[`]{3}\s+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]
@@ -506,7 +505,7 @@ module SiSU_DAL_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 =~/^```(?:\s*[~-][#])?\s*$/)
+ or (@@flag[:code]==:tics and t_o =~/^[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/)
@@flag[:code]=:off
obj=@tuned_code.join("\n")
tags=[]
@@ -531,12 +530,12 @@ module SiSU_DAL_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 =~/^```(?:\s*[~-][#])?\s*$/)
+ or (@@flag[:poem]==:tics and t_o =~/^[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/)
@@flag[:poem]=:off
h={ obj: 'poem end' } #introduce a counter
t_o=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h)
elsif (@@flag[:group]==:curls and t_o =~/^\}group/) \
- or (@@flag[:group]==:tics and t_o =~/^```(?:\s*[~-][#])?\s*$/)
+ or (@@flag[:group]==:tics and t_o =~/^[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/)
@@flag[:group]=:off
obj,tags=extract_tags(@tuned_block.join("\n"))
h={ obj: obj, tags: tags }
@@ -546,7 +545,7 @@ module SiSU_DAL_DocumentStructureExtract
h={ obj: 'group text end' } #introduce a counter
t_o=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h)
elsif (@@flag[:block]==:curls and t_o =~/^\}block/) \
- or (@@flag[:block]==:tics and t_o =~/^```(?:\s*[~-][#])?\s*$/)
+ or (@@flag[:block]==:tics and t_o =~/^[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/)
@@flag[:block]=:off
obj,tags=extract_tags(@tuned_block.join("\n"))
h={ obj: obj, tags: tags }
@@ -556,7 +555,7 @@ module SiSU_DAL_DocumentStructureExtract
h={ obj: 'block text end' } #introduce a counter
t_o=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h)
elsif (@@flag[:alt]==:curls and t_o =~/^\}alt/) \
- or (@@flag[:alt]==:tics and t_o =~/^```(?:\s*[~-][#])?\s*$/)
+ or (@@flag[:alt]==:tics and t_o =~/^[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/)
@@flag[:alt]=:off
obj,tags=extract_tags(@tuned_block.join("\n"))
h={ obj: obj, tags: tags }
@@ -571,7 +570,7 @@ module SiSU_DAL_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 !~/^```\s+(?:code|poem|alt|group|block)|^```(?:\s*[~-][#])?\s*$/ # fix logic
+ and t_o !~/^[`]{3}\s+(?:code|poem|alt|group|block)|^[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/ # fix logic
sub_array=t_o.dup
@line_mode=sub_array.scan(/.+/)
type=if @@flag[:poem]==:curls or @@flag[:poem]==:tics
@@ -659,7 +658,7 @@ module SiSU_DAL_DocumentStructureExtract
lines.each do |line|
line=if line =~/\S/ \
and line !~/^(?:code\{|\}code)/ \
- and line !~/^(?:```\s+code|```(?:\s*[~-][#])?\s*$)/ \
+ and line !~/^(?:[`]{3}\s+code|[`]{3}(?:\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}").