aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--data/doc/sisu/CHANGELOG_v53
-rw-r--r--lib/sisu/v5/dal_doc_str.rb65
-rw-r--r--lib/sisu/v5/dal_expand_insertions.rb4
-rw-r--r--lib/sisu/v5/dal_misc_arrange.rb12
4 files changed, 43 insertions, 41 deletions
diff --git a/data/doc/sisu/CHANGELOG_v5 b/data/doc/sisu/CHANGELOG_v5
index 940b9435..90cfb85a 100644
--- a/data/doc/sisu/CHANGELOG_v5
+++ b/data/doc/sisu/CHANGELOG_v5
@@ -30,6 +30,9 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_5.0.13.orig.tar.xz
sisu_5.0.13.orig.tar.xz
sisu_5.0.13-1.dsc
+* dal, refine grouped text open and close using tics "```"
+ [note use of "~~" considered but more problematic, (tics not used elsewhere)]
+
* css, html, epub, adjust paragraph spacing, (increase, whitespace aesthetic,
review further)
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}").
diff --git a/lib/sisu/v5/dal_expand_insertions.rb b/lib/sisu/v5/dal_expand_insertions.rb
index eb4f8363..e43dd3af 100644
--- a/lib/sisu/v5/dal_expand_insertions.rb
+++ b/lib/sisu/v5/dal_expand_insertions.rb
@@ -332,9 +332,9 @@ module SiSU_DAL_Insertions
tuned_file,tuned_file_tmp=[],[]
codeblock_=false
data.each do |para|
- codeblock_=if para =~/^(?:code\{|```\s+code)/
+ codeblock_=if para =~/^(?:code\{|[`]{3}\s+code)/
true
- elsif para =~/^(?:\}code|```)/m
+ elsif para =~/^(?:\}code|[`]{3}(?:\s|$))/m
false
else codeblock_
end
diff --git a/lib/sisu/v5/dal_misc_arrange.rb b/lib/sisu/v5/dal_misc_arrange.rb
index c1751360..ab4f3ea4 100644
--- a/lib/sisu/v5/dal_misc_arrange.rb
+++ b/lib/sisu/v5/dal_misc_arrange.rb
@@ -76,20 +76,20 @@ module SiSU_DAL_MiscArrangeText
def code_blocks(para)
def ticks(para)
block_open,block_close,text=nil,nil,nil
- if para =~/\A(``` .+?)\n(.+?)\n(```(?: [~-][#])?)\s*\Z/m
- block_open,text,block_close=/\A(``` .+?)\n(.+?)\n(```(?: [~-][#])?)\s*\Z/m.match(para)[1..3]
+ 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
- elsif para =~/\A(``` .+?)\n(.*?)\Z/m #look at, study
- block_open,text=/\A(```(?: .+?))\n(.*?)\Z/m.match(para)[1,2]
+ 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=[]
if not text.to_s.empty?
para << block_open << text
else
para << block_open
end
- elsif para =~/\A(.+?)\n(```(?:\s*[~-][#])?)\s*\Z/m
- text,block_close=/\A(.+?)\n(```(?: [~-][#])?)\s*\Z/m.match(para)[1,2]
+ 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]
para=[]
if not text.to_s.empty?
para << text.to_s << block_close