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.rb104
1 files changed, 64 insertions, 40 deletions
diff --git a/lib/sisu/v6/ao_doc_str.rb b/lib/sisu/v6/ao_doc_str.rb
index cd4f62e8..7f2815d8 100644
--- a/lib/sisu/v6/ao_doc_str.rb
+++ b/lib/sisu/v6/ao_doc_str.rb
@@ -71,6 +71,7 @@ module SiSU_AO_DocumentStructureExtract
box: :off,
group: :off,
alt: :off,
+ quote: :off,
table: :off,
table_to: :off,
}
@@ -89,6 +90,7 @@ module SiSU_AO_DocumentStructureExtract
box: :off,
group: :off,
alt: :off,
+ quote: :off,
table: :off,
table_to: :off,
}
@@ -123,6 +125,11 @@ module SiSU_AO_DocumentStructureExtract
? true
: false
end
+ def quotes?
+ @@flag[:quote]==:open \
+ ? true
+ : false
+ end
def hang_and_indent_test(str)
hang_indent=if str=~/^_([1-9])[^_]/
[$1,$1]
@@ -236,6 +243,7 @@ module SiSU_AO_DocumentStructureExtract
box: 0,
group: 0,
alt: 0,
+ quote: 0,
table: 0,
}
@metadata={}
@@ -260,7 +268,7 @@ module SiSU_AO_DocumentStructureExtract
end
t_o=t_o.gsub(/(?:\n\s*\n)+/m,"\n") if @@flag[:code]==:off
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 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 \
and @@flag[:poem]==:off \
and @@flag[:group]==:off \
@@ -370,7 +378,7 @@ module SiSU_AO_DocumentStructureExtract
obj << ' ~#'
end
end
- h={ bullet_: bullet, hang: hang, indent: indent, obj: obj, idx: idx, note_: note, image_: image, tags: tags }
+ h={ bullet_: bullet, hang: hang, indent: indent, obj: obj, idx: idx, note_: note, image_: image, tags: tags, quote: quotes? }
SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h)
end
else nil
@@ -393,7 +401,7 @@ module SiSU_AO_DocumentStructureExtract
obj << ' ~#'
end
end
- h={ hang: hang, indent: indent, obj: obj, idx: idx, note_: note, image_: image, tags: tags }
+ h={ hang: hang, indent: indent, obj: obj, idx: idx, note_: note, image_: image, tags: tags, quote: quotes? }
SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h)
end
else nil
@@ -417,7 +425,7 @@ module SiSU_AO_DocumentStructureExtract
end
end
unless obj=~/\A\s*\Z/m
- h={ bullet_: false, indent: 0, hang: 0, obj: obj, idx: idx, note_: note, image_: image, tags: tags }
+ h={ bullet_: false, indent: 0, hang: 0, obj: obj, idx: idx, note_: note, image_: image, tags: tags, quote: quotes? }
SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h)
end
end
@@ -450,8 +458,8 @@ module SiSU_AO_DocumentStructureExtract
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)
+ h={ obj: '', sym: :poem_open, num: @num_id[:poem] }
+ t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h)
tuned_file << t_o
elsif t_o =~/^(?:box(?:\.[a-z_]+)?\{|```[ ]+box(?:\.[a-z_]+)?)/
@@flag[:box]=case t_o
@@ -460,8 +468,8 @@ module SiSU_AO_DocumentStructureExtract
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)
+ h={ obj: '', sym: :box_open, num: @num_id[:box] }
+ t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h)
tuned_file << t_o
elsif t_o =~/^(?:group\{|```[ ]+group)/
@@flag[:group]=case t_o
@@ -470,8 +478,8 @@ module SiSU_AO_DocumentStructureExtract
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)
+ h={ obj: '', sym: :group_open, num: @num_id[:group] }
+ t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h)
tuned_file << t_o
elsif t_o =~/^(?:block\{|```[ ]+block)/
@@flag[:block]=case t_o
@@ -480,8 +488,8 @@ module SiSU_AO_DocumentStructureExtract
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)
+ h={ obj: '', sym: :block_open, num: @num_id[:block] }
+ t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h)
tuned_file << t_o
elsif t_o =~/^(?:alt\{|```[ ]+alt)/
@@flag[:alt]=case t_o
@@ -490,14 +498,20 @@ module SiSU_AO_DocumentStructureExtract
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)
+ h={ obj: '', sym: :alt_open, num: @num_id[:alt] }
+ t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h)
tuned_file << t_o
+ elsif t_o =~/^`:quote_open`/
+ @@flag[:quote]=:open
+ @num_id[:quote] +=1
+ h={ obj: '', sym: :quote_open, num: @num_id[:quote] }
+ t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h)
+ #tuned_file << t_o #% find second source, entered twice, should be once so closed off here
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)
- tuned_file << ins
+ h={ obj: '', sym: :table_open, num: @num_id[:table] }
+ ins_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h)
+ tuned_file << ins_o
if t_o=~/^table\{(?:~h)?\s+/
@@flag[:table]=:curls
@rows=''
@@ -552,8 +566,8 @@ module SiSU_AO_DocumentStructureExtract
h={ head_: hd, cols: cols, widths: col, obj: rows, idx: idx, tags: tags, num: @num_id[:table] }
t_o=SiSU_AO_DocumentStructure::ObjectTable.new.table(h) unless h.nil?
tuned_file << t_o
- h={ obj: "table end #{@num_id[:table]}" }
- t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h)
+ h={ obj: '', sym: :table_close, num: @num_id[:table] }
+ t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h)
t_o
elsif t_o=~/^```[ ]+table(?:~h)?\s+/
m1,m2,hd=nil,nil,nil
@@ -575,8 +589,8 @@ module SiSU_AO_DocumentStructureExtract
h={ head_: hd, cols: col.length, widths: col, obj: rows, idx: idx, tags: tags, num: @num_id[:table] }
t_o=SiSU_AO_DocumentStructure::ObjectTable.new.table(h) unless h.nil?
tuned_file << t_o
- h={ obj: "table end #{@num_id[:table]}" }
- t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h)
+ h={ obj: '', sym: :table_close, num: @num_id[:table] }
+ t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h)
t_o
elsif t_o=~/^\{table(?:~h)?\s+/
m1,m2,hd=nil,nil,nil
@@ -598,8 +612,8 @@ module SiSU_AO_DocumentStructureExtract
h={ head_: hd, cols: col.length, widths: col, obj: rows, idx: idx, tags: tags, num: @num_id[:table] }
t_o=SiSU_AO_DocumentStructure::ObjectTable.new.table(h) unless h.nil?
tuned_file << t_o
- h={ obj: "table end #{@num_id[:table]}" }
- t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h)
+ h={ obj: '', sym: :table_close, num: @num_id[:table] }
+ t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h)
t_o
end
end
@@ -616,13 +630,13 @@ module SiSU_AO_DocumentStructureExtract
t_o=SiSU_AO_DocumentStructure::ObjectTable.new.table(@h)
tuned_file << t_o
@h,@rows=nil,''
- h={ obj: "table end #{@num_id[:table]}" }
- t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h)
+ h={ obj: '', sym: :table_close, num: @num_id[:table] }
+ t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h)
t_o
else
if t_o.is_a?(String) \
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)
+ t_o=t_o.gsub(/^\n+/m,'').
gsub(/\n+/m,"#{Mx[:tc_p]}")
@rows += t_o + Mx[:tc_c]
end
@@ -641,8 +655,8 @@ module SiSU_AO_DocumentStructureExtract
t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.code(h)
@tuned_code=[]
tuned_file << t_o
- h={ obj: "code block end #{@num_id[:code_block]}" }
- t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h)
+ h={ obj: '', sym: :code_close, num: @num_id[:code_block] }
+ t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h)
end
if (@@flag[:code]==:curls or @@flag[:code]==:tics) \
and t_o.is_a?(String)
@@ -657,12 +671,13 @@ module SiSU_AO_DocumentStructureExtract
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)
+ or (@@flag[:alt]==:curls or @@flag[:alt]==:tics) \
+ or (@@flag[:quote]==:open and t_o =~/`:quote_close`/m) #not
if (@@flag[:poem]==:curls and t_o =~/^\}poem/) \
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)
+ h={ obj: '', sym: :poem_close, num: @num_id[:poem] }
+ t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h)
elsif (@@flag[:box]==:curls and t_o =~/^\}box/) \
or (@@flag[:box]==:tics and t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/)
@@flag[:box]=:off
@@ -671,8 +686,8 @@ module SiSU_AO_DocumentStructureExtract
@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)
+ h={ obj: '', sym: :box_close, num: @num_id[:box] }
+ t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h)
elsif (@@flag[:group]==:curls and t_o =~/^\}group/) \
or (@@flag[:group]==:tics and t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/)
@@flag[:group]=:off
@@ -681,8 +696,8 @@ module SiSU_AO_DocumentStructureExtract
@tuned_block=[]
t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.group(h)
tuned_file << t_o
- h={ obj: "group text end #{@num_id[:group]}" }
- t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h)
+ h={ obj: '', sym: :group_close, num: @num_id[:group] }
+ t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h)
elsif (@@flag[:block]==:curls and t_o =~/^\}block/) \
or (@@flag[:block]==:tics and t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/)
@@flag[:block]=:off
@@ -691,8 +706,8 @@ module SiSU_AO_DocumentStructureExtract
@tuned_block=[]
t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.block(h)
tuned_file << t_o
- h={ obj: "block text end #{@num_id[:block]}" }
- t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h)
+ h={ obj: '', sym: :block_close, num: @num_id[:block] }
+ t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h)
elsif (@@flag[:alt]==:curls and t_o =~/^\}alt/) \
or (@@flag[:alt]==:tics and t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/)
@@flag[:alt]=:off
@@ -701,8 +716,16 @@ module SiSU_AO_DocumentStructureExtract
t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.alt(h)
@tuned_block=[]
tuned_file << t_o
- h={ obj: "alt text end #{@num_id[:alt]}" }
- t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h)
+ h={ obj: '', sym: :alt_close, num: @num_id[:alt] }
+ t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h)
+ elsif @@flag[:quote]==:open and t_o =~/`:quote_close`/m
+ @@flag[:quote]=:off
+ h={ obj: '', sym: :quote_close, num: @num_id[:quote] }
+ t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h)
+ elsif @@flag[:quote]==:open
+ t_o,tags=extract_tags(t_o)
+ h={ indent: 1, obj: t_o, idx: idx, note_: note, image_: image, tags: tags, quote: quotes? }
+ SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h)
end
if (@@flag[:poem]==:curls or @@flag[:poem]==:tics \
or @@flag[:group]==:curls or @@flag[:group]==:tics \
@@ -732,7 +755,8 @@ module SiSU_AO_DocumentStructureExtract
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
+ or @@flag[:alt]==:curls or @@flag[:alt]==:tics \
+ or (@@flag[:quote]==:open and t_o =~/`:quote_close`/m)
if t_o.is_a?(String)
t_o=t_o.gsub(/\n/m,"#{Mx[:br_nl]}").
gsub(/[ ][ ]/m,"#{Mx[:nbsp]*2}").