aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2014-08-20 18:49:24 -0400
committerRalph Amissah <ralph@amissah.com>2014-08-20 18:52:45 -0400
commite1b6e755686e40a0133fa4fa75e66d257de9ba0c (patch)
treea3bd0366a815aef1f6dce06be9e7aeeb7d81a99d /lib
parentv5 v6: ao_expand_insertions, blocked text match, adjust (diff)
v5 v6: ao, book index related
Diffstat (limited to 'lib')
-rw-r--r--lib/sisu/v5/ao_doc_str.rb39
-rw-r--r--lib/sisu/v5/ao_misc_arrange.rb4
-rw-r--r--lib/sisu/v6/ao_doc_str.rb39
-rw-r--r--lib/sisu/v6/ao_misc_arrange.rb4
4 files changed, 54 insertions, 32 deletions
diff --git a/lib/sisu/v5/ao_doc_str.rb b/lib/sisu/v5/ao_doc_str.rb
index d9a7c9f2..e10cc4ef 100644
--- a/lib/sisu/v5/ao_doc_str.rb
+++ b/lib/sisu/v5/ao_doc_str.rb
@@ -305,6 +305,18 @@ module SiSU_AO_DocumentStructureExtract
next
end
t_o=t_o.gsub(/(?:\n\s*\n)+/m,"\n") if @@flag[:code]==:off
+ unless t_o =~/^(?:@\S+?:|%+)\s/ # extract book index for paragraph if any
+ idx=if t_o=~/^=\{\s*(.+)\s*\}\s*$\Z/m
+ m=$1
+ m=m.split(/[ ]*\n/).join(' ').
+ gsub(/\s+([|:;])\s+/,'\1').
+ gsub(/\s+([+]\d+)\s+/,'\1')
+ t_o=t_o.gsub(/\n=\{.+?\}\s*$/m,'')
+ idx_array_and_hash=construct_idx_array_and_hash(m)
+ idx_array_and_hash[:hash]
+ else nil
+ end
+ end
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*$|^`:quote_(?:open|close)`/ \
and @@flag[:code]==:off \
@@ -314,17 +326,6 @@ module SiSU_AO_DocumentStructureExtract
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*(.+)\s*\}\s*$\Z/m; m=$1
- m=m.split(/[ ]*\n/).join(' ').
- gsub(/\s+([|:;])\s+/,'\1').
- gsub(/\s+([+]\d+)\s+/,'\1')
- t_o=t_o.gsub(/\n=\{.+?\}\s*$/m,'')
- idx_array_and_hash=construct_idx_array_and_hash(m)
- idx_array_and_hash[:hash]
- else nil
- end
- end
t_o=case t_o
when /^#{Mx[:meta_o]}\S+?#{Mx[:meta_c]}/ #metadata, header
if t_o=~/^#{Mx[:meta_o]}(\S+?)#{Mx[:meta_c]}\s*(.+)/m
@@ -842,14 +843,17 @@ module SiSU_AO_DocumentStructureExtract
if (@@flag[:code]==:curls \
&& t_o =~/^\}code/) \
or (@@flag[:code]==:tics \
- && t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/)
+ && t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/m)
@@flag[:code]=:off
- @tuned_code[-1].
- gsub!(/\s*(?:#{Mx[:br_line]}|#{Mx[:br_nl]})\s*\Z/m,'')
+ if @tuned_code[-1]
+ @tuned_code[-1].
+ gsub!(/\s*(?:#{Mx[:br_line]}|#{Mx[:br_nl]})\s*\Z/m,'')
+ end
obj=@tuned_code.join("\n")
tags=[]
h={
obj: obj,
+ idx: idx,
syntax: @@flag[:lngsyn],
tags: tags,
num: @num_id[:code_block],
@@ -897,6 +901,7 @@ module SiSU_AO_DocumentStructureExtract
h={
is_for: :poem,
obj: '',
+ idx: idx,
sym: :poem_close,
num: @num_id[:poem],
}
@@ -909,6 +914,7 @@ module SiSU_AO_DocumentStructureExtract
obj,tags=extract_tags(@tuned_block.join("\n"))
h={
obj: obj,
+ idx: idx,
tags: tags,
num: @num_id[:box],
}
@@ -918,6 +924,7 @@ module SiSU_AO_DocumentStructureExtract
h={
is_for: :box,
obj: '',
+ idx: idx,
sym: :box_close,
num: @num_id[:box],
}
@@ -930,6 +937,7 @@ module SiSU_AO_DocumentStructureExtract
obj,tags=extract_tags(@tuned_block.join("\n"))
h={
obj: obj,
+ idx: idx,
tags: tags,
num: @num_id[:group],
}
@@ -951,6 +959,7 @@ module SiSU_AO_DocumentStructureExtract
obj,tags=extract_tags(@tuned_block.join("\n"))
h={
obj: obj,
+ idx: idx,
tags: tags,
num: @num_id[:block],
}
@@ -972,6 +981,7 @@ module SiSU_AO_DocumentStructureExtract
obj,tags=extract_tags(@tuned_block.join("\n"))
h={
obj: obj,
+ idx: idx,
tags: tags,
num: @num_id[:alt],
}
@@ -990,6 +1000,7 @@ module SiSU_AO_DocumentStructureExtract
@@flag[:quote]=:off
h={
is_for: :quote,
+ idx: idx,
obj: '',
sym: :quote_close,
num: @num_id[:quote],
diff --git a/lib/sisu/v5/ao_misc_arrange.rb b/lib/sisu/v5/ao_misc_arrange.rb
index 09842fcc..ab61671c 100644
--- a/lib/sisu/v5/ao_misc_arrange.rb
+++ b/lib/sisu/v5/ao_misc_arrange.rb
@@ -98,11 +98,11 @@ module SiSU_AO_MiscArrangeText
else
para << block_open
end
- elsif para =~/\A.+?\n```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*\Z/m \
+ elsif para =~/\A.+?\n```(?:\s+\~\{.+?\}\~)?(?:\s+[~-][#])?(\s*=\{.+?\})?\s*\Z/m \
and @flag==:open
@flag=:close
text,block_close=
- /\A(.+?)\n(```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?)\s*\Z/m.match(para)[1,2]
+ /\A(.+?)\n(```(?:\s+\~\{.+?\}\~)?(?:\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 25735de7..6e7a103f 100644
--- a/lib/sisu/v6/ao_doc_str.rb
+++ b/lib/sisu/v6/ao_doc_str.rb
@@ -305,6 +305,18 @@ module SiSU_AO_DocumentStructureExtract
next
end
t_o=t_o.gsub(/(?:\n\s*\n)+/m,"\n") if @@flag[:code]==:off
+ unless t_o =~/^(?:@\S+?:|%+)\s/ # extract book index for paragraph if any
+ idx=if t_o=~/^=\{\s*(.+)\s*\}\s*$\Z/m
+ m=$1
+ m=m.split(/[ ]*\n/).join(' ').
+ gsub(/\s+([|:;])\s+/,'\1').
+ gsub(/\s+([+]\d+)\s+/,'\1')
+ t_o=t_o.gsub(/\n=\{.+?\}\s*$/m,'')
+ idx_array_and_hash=construct_idx_array_and_hash(m)
+ idx_array_and_hash[:hash]
+ else nil
+ end
+ end
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*$|^`:quote_(?:open|close)`/ \
and @@flag[:code]==:off \
@@ -314,17 +326,6 @@ module SiSU_AO_DocumentStructureExtract
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*(.+)\s*\}\s*$\Z/m; m=$1
- m=m.split(/[ ]*\n/).join(' ').
- gsub(/\s+([|:;])\s+/,'\1').
- gsub(/\s+([+]\d+)\s+/,'\1')
- t_o=t_o.gsub(/\n=\{.+?\}\s*$/m,'')
- idx_array_and_hash=construct_idx_array_and_hash(m)
- idx_array_and_hash[:hash]
- else nil
- end
- end
t_o=case t_o
when /^#{Mx[:meta_o]}\S+?#{Mx[:meta_c]}/ #metadata, header
if t_o=~/^#{Mx[:meta_o]}(\S+?)#{Mx[:meta_c]}\s*(.+)/m
@@ -842,14 +843,17 @@ module SiSU_AO_DocumentStructureExtract
if (@@flag[:code]==:curls \
&& t_o =~/^\}code/) \
or (@@flag[:code]==:tics \
- && t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/)
+ && t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/m)
@@flag[:code]=:off
- @tuned_code[-1].
- gsub!(/\s*(?:#{Mx[:br_line]}|#{Mx[:br_nl]})\s*\Z/m,'')
+ if @tuned_code[-1]
+ @tuned_code[-1].
+ gsub!(/\s*(?:#{Mx[:br_line]}|#{Mx[:br_nl]})\s*\Z/m,'')
+ end
obj=@tuned_code.join("\n")
tags=[]
h={
obj: obj,
+ idx: idx,
syntax: @@flag[:lngsyn],
tags: tags,
num: @num_id[:code_block],
@@ -897,6 +901,7 @@ module SiSU_AO_DocumentStructureExtract
h={
is_for: :poem,
obj: '',
+ idx: idx,
sym: :poem_close,
num: @num_id[:poem],
}
@@ -909,6 +914,7 @@ module SiSU_AO_DocumentStructureExtract
obj,tags=extract_tags(@tuned_block.join("\n"))
h={
obj: obj,
+ idx: idx,
tags: tags,
num: @num_id[:box],
}
@@ -918,6 +924,7 @@ module SiSU_AO_DocumentStructureExtract
h={
is_for: :box,
obj: '',
+ idx: idx,
sym: :box_close,
num: @num_id[:box],
}
@@ -930,6 +937,7 @@ module SiSU_AO_DocumentStructureExtract
obj,tags=extract_tags(@tuned_block.join("\n"))
h={
obj: obj,
+ idx: idx,
tags: tags,
num: @num_id[:group],
}
@@ -951,6 +959,7 @@ module SiSU_AO_DocumentStructureExtract
obj,tags=extract_tags(@tuned_block.join("\n"))
h={
obj: obj,
+ idx: idx,
tags: tags,
num: @num_id[:block],
}
@@ -972,6 +981,7 @@ module SiSU_AO_DocumentStructureExtract
obj,tags=extract_tags(@tuned_block.join("\n"))
h={
obj: obj,
+ idx: idx,
tags: tags,
num: @num_id[:alt],
}
@@ -990,6 +1000,7 @@ module SiSU_AO_DocumentStructureExtract
@@flag[:quote]=:off
h={
is_for: :quote,
+ idx: idx,
obj: '',
sym: :quote_close,
num: @num_id[:quote],
diff --git a/lib/sisu/v6/ao_misc_arrange.rb b/lib/sisu/v6/ao_misc_arrange.rb
index 8adebfd5..f1aa1e02 100644
--- a/lib/sisu/v6/ao_misc_arrange.rb
+++ b/lib/sisu/v6/ao_misc_arrange.rb
@@ -98,11 +98,11 @@ module SiSU_AO_MiscArrangeText
else
para << block_open
end
- elsif para =~/\A.+?\n```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*\Z/m \
+ elsif para =~/\A.+?\n```(?:\s+\~\{.+?\}\~)?(?:\s+[~-][#])?(\s*=\{.+?\})?\s*\Z/m \
and @flag==:open
@flag=:close
text,block_close=
- /\A(.+?)\n(```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?)\s*\Z/m.match(para)[1,2]
+ /\A(.+?)\n(```(?:\s+\~\{.+?\}\~)?(?:\s+[~-][#])?(?:\s+=\{.+?\})?)\s*\Z/m.match(para)[1,2]
para=[]
if not text.to_s.empty?
para << text.to_s << block_close