aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v6/ao_doc_str.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sisu/v6/ao_doc_str.rb')
-rw-r--r--lib/sisu/v6/ao_doc_str.rb37
1 files changed, 33 insertions, 4 deletions
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