aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2014-07-01 00:52:27 -0400
committerRalph Amissah <ralph@amissah.com>2014-07-01 00:52:37 -0400
commite881dffcbeae1fcdebdc07ec4ce262564c49db86 (patch)
tree7ff0af81450fefad67606b9d240d3d66b8852a11 /lib
parentv5 v6: ao, quote block, insert text indent markup (book index markup unchanged) (diff)
v5 v6: ao, doc objects, layout group open & close, identify, is_for
Diffstat (limited to 'lib')
-rw-r--r--lib/sisu/v5/ao_doc_objects.rb9
-rw-r--r--lib/sisu/v5/ao_doc_str.rb22
-rw-r--r--lib/sisu/v6/ao_doc_objects.rb9
-rw-r--r--lib/sisu/v6/ao_doc_str.rb22
4 files changed, 52 insertions, 10 deletions
diff --git a/lib/sisu/v5/ao_doc_objects.rb b/lib/sisu/v5/ao_doc_objects.rb
index 1357ee90..b372da4c 100644
--- a/lib/sisu/v5/ao_doc_objects.rb
+++ b/lib/sisu/v5/ao_doc_objects.rb
@@ -499,10 +499,10 @@ module SiSU_AO_DocumentStructure
end
end
class ObjectLayout
- attr_accessor :obj,:sym,:attr,:is,:of,:from,:tmp,:num
+ attr_accessor :obj,:sym,:attr,:is,:is_for,:of,:from,:tmp,:num
def initialize
@of=:layout
- @is=@obj=@from=@tmp=@num=nil
+ @is=@is_for=@obj=@from=@tmp=@num=nil
end
def break(h,f=nil) #decide how to deal with
of= @of #Symbol, classification - group
@@ -524,13 +524,14 @@ module SiSU_AO_DocumentStructure
def open_close(h,o=nil) #useful for poem & quote
of= @of #Symbol, classification - group
is= :open_close_tags #Symbol, classification - specific type
+ is_for= h[:is_for] || ((defined? o.is_for) ? o.is_for : nil) #String, text content
obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content
sym= h[:sym] || ((defined? o.sym) ? o.sym : nil) #Symbol tag_open, tag_close
attr= h[:attr] || ((defined? o.attr) ? o.attr : nil) #String, text content
tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use
num= h[:num] || ((defined? o.num) ? o.num : nil)
- @of,@is,@obj,@sym,@attr,@tmp,@num=
- of, is, obj, sym, attr, tmp, num
+ @of,@is,@is_for,@obj,@sym,@attr,@tmp,@num=
+ of, is, is_for, obj, sym, attr, tmp, num
self
end
end
diff --git a/lib/sisu/v5/ao_doc_str.rb b/lib/sisu/v5/ao_doc_str.rb
index c3b65ee1..5b93819e 100644
--- a/lib/sisu/v5/ao_doc_str.rb
+++ b/lib/sisu/v5/ao_doc_str.rb
@@ -533,6 +533,7 @@ module SiSU_AO_DocumentStructureExtract
: false
@num_id[:code_block] +=1
h={
+ is_for: :code,
obj: '',
sym: :code_block_open,
num: @num_id[:code_block],
@@ -547,6 +548,7 @@ module SiSU_AO_DocumentStructureExtract
end
@num_id[:poem] +=1
h={
+ is_for: :poem,
obj: '',
sym: :poem_open,
num: @num_id[:poem],
@@ -561,6 +563,7 @@ module SiSU_AO_DocumentStructureExtract
end
@num_id[:box] +=1
h={
+ is_for: :box,
obj: '',
sym: :box_open,
num: @num_id[:box],
@@ -575,6 +578,7 @@ module SiSU_AO_DocumentStructureExtract
end
@num_id[:group] +=1
h={
+ is_for: :group,
obj: '',
sym: :group_open,
num: @num_id[:group],
@@ -589,6 +593,7 @@ module SiSU_AO_DocumentStructureExtract
end
@num_id[:block] +=1
h={
+ is_for: :block,
obj: '',
sym: :block_open,
num: @num_id[:block],
@@ -603,6 +608,7 @@ module SiSU_AO_DocumentStructureExtract
end
@num_id[:alt] +=1
h={
+ is_for: :alt,
obj: '',
sym: :alt_open,
num: @num_id[:alt],
@@ -613,6 +619,7 @@ module SiSU_AO_DocumentStructureExtract
@@flag[:quote]=:open
@num_id[:quote] +=1
h={
+ is_for: :quote,
obj: '',
sym: :quote_open,
num: @num_id[:quote],
@@ -622,6 +629,7 @@ module SiSU_AO_DocumentStructureExtract
elsif t_o =~/^(?:table\{|```[ ]+table|\{table)[ ~]/
@num_id[:table] +=1
h={
+ is_for: :table,
obj: '',
sym: :table_open,
num: @num_id[:table],
@@ -701,6 +709,7 @@ module SiSU_AO_DocumentStructureExtract
t_o=SiSU_AO_DocumentStructure::ObjectTable.new.table(h) unless h.nil?
tuned_file << t_o
h={
+ is_for: :table,
obj: '',
sym: :table_close,
num: @num_id[:table],
@@ -736,6 +745,7 @@ module SiSU_AO_DocumentStructureExtract
t_o=SiSU_AO_DocumentStructure::ObjectTable.new.table(h) unless h.nil?
tuned_file << t_o
h={
+ is_for: :table,
obj: '',
sym: :table_close,
num: @num_id[:table],
@@ -771,6 +781,7 @@ module SiSU_AO_DocumentStructureExtract
t_o=SiSU_AO_DocumentStructure::ObjectTable.new.table(h) unless h.nil?
tuned_file << t_o
h={
+ is_for: :table,
obj: '',
sym: :table_close,
num: @num_id[:table],
@@ -799,6 +810,7 @@ module SiSU_AO_DocumentStructureExtract
tuned_file << t_o
@h,@rows=nil,''
h={
+ is_for: :table,
obj: '',
sym: :table_close,
num: @num_id[:table],
@@ -834,6 +846,7 @@ module SiSU_AO_DocumentStructureExtract
@tuned_code=[]
tuned_file << t_o
h={
+ is_for: :code,
obj: '',
sym: :code_close,
num: @num_id[:code_block],
@@ -859,6 +872,7 @@ module SiSU_AO_DocumentStructureExtract
or (@@flag[:poem]==:tics and t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/)
@@flag[:poem]=:off
h={
+ is_for: :poem,
obj: '',
sym: :poem_close,
num: @num_id[:poem],
@@ -877,6 +891,7 @@ module SiSU_AO_DocumentStructureExtract
t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.box(h)
tuned_file << t_o
h={
+ is_for: :box,
obj: '',
sym: :box_close,
num: @num_id[:box],
@@ -895,6 +910,7 @@ module SiSU_AO_DocumentStructureExtract
t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.group(h)
tuned_file << t_o
h={
+ is_for: :group,
obj: '',
sym: :group_close,
num: @num_id[:group],
@@ -912,7 +928,9 @@ module SiSU_AO_DocumentStructureExtract
@tuned_block=[]
t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.block(h)
tuned_file << t_o
- h={ obj: '',
+ h={
+ is_for: :block,
+ obj: '',
sym: :block_close,
num: @num_id[:block],
}
@@ -930,6 +948,7 @@ module SiSU_AO_DocumentStructureExtract
@tuned_block=[]
tuned_file << t_o
h={
+ is_for: :alt,
obj: '',
sym: :alt_close,
num: @num_id[:alt],
@@ -938,6 +957,7 @@ module SiSU_AO_DocumentStructureExtract
elsif @@flag[:quote]==:open and t_o =~/`:quote_close`/m
@@flag[:quote]=:off
h={
+ is_for: :quote,
obj: '',
sym: :quote_close,
num: @num_id[:quote],
diff --git a/lib/sisu/v6/ao_doc_objects.rb b/lib/sisu/v6/ao_doc_objects.rb
index 909bb600..44660469 100644
--- a/lib/sisu/v6/ao_doc_objects.rb
+++ b/lib/sisu/v6/ao_doc_objects.rb
@@ -499,10 +499,10 @@ module SiSU_AO_DocumentStructure
end
end
class ObjectLayout
- attr_accessor :obj,:sym,:attr,:is,:of,:from,:tmp,:num
+ attr_accessor :obj,:sym,:attr,:is,:is_for,:of,:from,:tmp,:num
def initialize
@of=:layout
- @is=@obj=@from=@tmp=@num=nil
+ @is=@is_for=@obj=@from=@tmp=@num=nil
end
def break(h,f=nil) #decide how to deal with
of= @of #Symbol, classification - group
@@ -524,13 +524,14 @@ module SiSU_AO_DocumentStructure
def open_close(h,o=nil) #useful for poem & quote
of= @of #Symbol, classification - group
is= :open_close_tags #Symbol, classification - specific type
+ is_for= h[:is_for] || ((defined? o.is_for) ? o.is_for : nil) #String, text content
obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content
sym= h[:sym] || ((defined? o.sym) ? o.sym : nil) #Symbol tag_open, tag_close
attr= h[:attr] || ((defined? o.attr) ? o.attr : nil) #String, text content
tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use
num= h[:num] || ((defined? o.num) ? o.num : nil)
- @of,@is,@obj,@sym,@attr,@tmp,@num=
- of, is, obj, sym, attr, tmp, num
+ @of,@is,@is_for,@obj,@sym,@attr,@tmp,@num=
+ of, is, is_for, obj, sym, attr, tmp, num
self
end
end
diff --git a/lib/sisu/v6/ao_doc_str.rb b/lib/sisu/v6/ao_doc_str.rb
index 001b2aef..0c07eee7 100644
--- a/lib/sisu/v6/ao_doc_str.rb
+++ b/lib/sisu/v6/ao_doc_str.rb
@@ -533,6 +533,7 @@ module SiSU_AO_DocumentStructureExtract
: false
@num_id[:code_block] +=1
h={
+ is_for: :code,
obj: '',
sym: :code_block_open,
num: @num_id[:code_block],
@@ -547,6 +548,7 @@ module SiSU_AO_DocumentStructureExtract
end
@num_id[:poem] +=1
h={
+ is_for: :poem,
obj: '',
sym: :poem_open,
num: @num_id[:poem],
@@ -561,6 +563,7 @@ module SiSU_AO_DocumentStructureExtract
end
@num_id[:box] +=1
h={
+ is_for: :box,
obj: '',
sym: :box_open,
num: @num_id[:box],
@@ -575,6 +578,7 @@ module SiSU_AO_DocumentStructureExtract
end
@num_id[:group] +=1
h={
+ is_for: :group,
obj: '',
sym: :group_open,
num: @num_id[:group],
@@ -589,6 +593,7 @@ module SiSU_AO_DocumentStructureExtract
end
@num_id[:block] +=1
h={
+ is_for: :block,
obj: '',
sym: :block_open,
num: @num_id[:block],
@@ -603,6 +608,7 @@ module SiSU_AO_DocumentStructureExtract
end
@num_id[:alt] +=1
h={
+ is_for: :alt,
obj: '',
sym: :alt_open,
num: @num_id[:alt],
@@ -613,6 +619,7 @@ module SiSU_AO_DocumentStructureExtract
@@flag[:quote]=:open
@num_id[:quote] +=1
h={
+ is_for: :quote,
obj: '',
sym: :quote_open,
num: @num_id[:quote],
@@ -622,6 +629,7 @@ module SiSU_AO_DocumentStructureExtract
elsif t_o =~/^(?:table\{|```[ ]+table|\{table)[ ~]/
@num_id[:table] +=1
h={
+ is_for: :table,
obj: '',
sym: :table_open,
num: @num_id[:table],
@@ -701,6 +709,7 @@ module SiSU_AO_DocumentStructureExtract
t_o=SiSU_AO_DocumentStructure::ObjectTable.new.table(h) unless h.nil?
tuned_file << t_o
h={
+ is_for: :table,
obj: '',
sym: :table_close,
num: @num_id[:table],
@@ -736,6 +745,7 @@ module SiSU_AO_DocumentStructureExtract
t_o=SiSU_AO_DocumentStructure::ObjectTable.new.table(h) unless h.nil?
tuned_file << t_o
h={
+ is_for: :table,
obj: '',
sym: :table_close,
num: @num_id[:table],
@@ -771,6 +781,7 @@ module SiSU_AO_DocumentStructureExtract
t_o=SiSU_AO_DocumentStructure::ObjectTable.new.table(h) unless h.nil?
tuned_file << t_o
h={
+ is_for: :table,
obj: '',
sym: :table_close,
num: @num_id[:table],
@@ -799,6 +810,7 @@ module SiSU_AO_DocumentStructureExtract
tuned_file << t_o
@h,@rows=nil,''
h={
+ is_for: :table,
obj: '',
sym: :table_close,
num: @num_id[:table],
@@ -834,6 +846,7 @@ module SiSU_AO_DocumentStructureExtract
@tuned_code=[]
tuned_file << t_o
h={
+ is_for: :code,
obj: '',
sym: :code_close,
num: @num_id[:code_block],
@@ -859,6 +872,7 @@ module SiSU_AO_DocumentStructureExtract
or (@@flag[:poem]==:tics and t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/)
@@flag[:poem]=:off
h={
+ is_for: :poem,
obj: '',
sym: :poem_close,
num: @num_id[:poem],
@@ -877,6 +891,7 @@ module SiSU_AO_DocumentStructureExtract
t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.box(h)
tuned_file << t_o
h={
+ is_for: :box,
obj: '',
sym: :box_close,
num: @num_id[:box],
@@ -895,6 +910,7 @@ module SiSU_AO_DocumentStructureExtract
t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.group(h)
tuned_file << t_o
h={
+ is_for: :group,
obj: '',
sym: :group_close,
num: @num_id[:group],
@@ -912,7 +928,9 @@ module SiSU_AO_DocumentStructureExtract
@tuned_block=[]
t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.block(h)
tuned_file << t_o
- h={ obj: '',
+ h={
+ is_for: :block,
+ obj: '',
sym: :block_close,
num: @num_id[:block],
}
@@ -930,6 +948,7 @@ module SiSU_AO_DocumentStructureExtract
@tuned_block=[]
tuned_file << t_o
h={
+ is_for: :alt,
obj: '',
sym: :alt_close,
num: @num_id[:alt],
@@ -938,6 +957,7 @@ module SiSU_AO_DocumentStructureExtract
elsif @@flag[:quote]==:open and t_o =~/`:quote_close`/m
@@flag[:quote]=:off
h={
+ is_for: :quote,
obj: '',
sym: :quote_close,
num: @num_id[:quote],