aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2013-08-21 23:14:21 -0400
committerRalph Amissah <ralph@amissah.com>2013-08-21 23:14:23 -0400
commit386233f07b668554d0057c405c661a95d588b43a (patch)
tree3edcab4efd3ba8c69f7db5c15e9345ae831d33f1 /lib
parentv4 v5: terminal message, code marker (diff)
v5: markup syntax add: switch ocn (object numbering) off & on for content block
* switch ocn off & on for a block of content, line containing only off: "--~#" (omit headings where possible) "---#" on: "--+#"
Diffstat (limited to 'lib')
-rw-r--r--lib/sisu/v5/dal_doc_objects.rb27
-rw-r--r--lib/sisu/v5/dal_doc_str.rb66
2 files changed, 93 insertions, 0 deletions
diff --git a/lib/sisu/v5/dal_doc_objects.rb b/lib/sisu/v5/dal_doc_objects.rb
index 64ddbfb1..b2be6105 100644
--- a/lib/sisu/v5/dal_doc_objects.rb
+++ b/lib/sisu/v5/dal_doc_objects.rb
@@ -423,6 +423,33 @@ module SiSU_DAL_DocumentStructure
self
end
end
+ class ObjectFlag
+ attr_accessor :obj,:is,:of,:flag,:mod,:tmp
+ def initialize
+ @of=:flag
+ @is=@obj=@flag=@mod=@tmp=nil
+ end
+ def flag(h,o=nil)
+ of= @of #String, classification - group
+ is= :flag #String, classification - specific type
+ obj= nil #String, text content
+ flag= h[:flag] || ((defined? o.flag) ? o.flag : nil) #String, text content
+ mod= h[:mod] || ((defined? o.mod) ? o.mod : nil) #String, text content
+ tmp= h[:flag] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use
+ @of,@is,@obj,@flag,@mod,@tmp=of,is,obj,flag,mod,tmp
+ self
+ end
+ def flag_ocn(h,o=nil)
+ of= @of #String, classification - group
+ is= :flag_ocn #String, classification - specific type
+ obj= nil #String, text content
+ flag= h[:flag] || ((defined? o.flag) ? o.flag : nil) #String, text content
+ mod= h[:mod] || ((defined? o.mod) ? o.mod : nil) #String, text content
+ tmp= h[:flag] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use
+ @of,@is,@obj,@flag,@mod,@tmp=of,is,obj,flag,mod,tmp
+ self
+ end
+ end
class ObjectLayout
attr_accessor :obj,:is,:of,:from,:tmp
def initialize
diff --git a/lib/sisu/v5/dal_doc_str.rb b/lib/sisu/v5/dal_doc_str.rb
index 70c2e61f..c8174323 100644
--- a/lib/sisu/v5/dal_doc_str.rb
+++ b/lib/sisu/v5/dal_doc_str.rb
@@ -157,6 +157,24 @@ module SiSU_DAL_DocumentStructureExtract
@@counter,@verse_count=0,0
@metadata={}
@data.each do |t_o|
+ if t_o =~/^--([+~-])[#]$/
+ h=case $1
+ when /[+]/
+ @@flag[:ocn]=:on
+ {flag: :ocn_on}
+ when /[~]/
+ @@flag[:ocn]=:off_headings_substantive
+ {flag: :ocn_off, mod: :headings_substantive}
+ when /[-]/
+ @@flag[:ocn]=:off_headings_exclude
+ {flag: :ocn_off, mod: :headings_exclude}
+ else
+ @@flag[:ocn]=:on
+ {flag: :ocn_on}
+ end
+ t_o=SiSU_DAL_DocumentStructure::ObjectFlag.new.flag_ocn(h)
+ next
+ end
t_o=t_o.gsub(/(?:\n\s*\n)+/m,"\n") unless @@flag['code']
if t_o !~/^(?:code|poem|alt|group|block)\{|^\}(?:code|poem|alt|group|block)|^(?:table\{|\{table)[ ~]/ \
and not @@flag['code'] \
@@ -192,18 +210,48 @@ module SiSU_DAL_DocumentStructureExtract
obj=$1
note=endnote_test?(obj)
obj,tags=extract_tags(obj)
+ if @@flag[:ocn]==:off_headings_exclude \
+ or @@flag[:ocn]==:off_headings_substantive
+ unless obj =~ /[~-][#]\s*$/
+ if @@flag[:ocn]==:off_headings_exclude
+ obj << ' -#'
+ elsif @@flag[:ocn]==:off_headings_substantive
+ obj << ' ~#'
+ end
+ end
+ end
h={ lv: lv, ln: ln, obj: obj, idx: idx, tags: tags }
SiSU_DAL_DocumentStructure::ObjectHeading.new.heading(h)
elsif t_o=~/^:?[A-C1-6]\~(\S+?)-\s+(.+)/m
name,obj=$1,$2
note=endnote_test?(obj)
obj,tags=extract_tags(obj)
+ if @@flag[:ocn]==:off_headings_exclude \
+ or @@flag[:ocn]==:off_headings_substantive
+ unless obj =~ /[~-][#]\s*$/
+ if @@flag[:ocn]==:off_headings_exclude
+ obj << ' -#'
+ elsif @@flag[:ocn]==:off_headings_substantive
+ obj << ' ~#'
+ end
+ end
+ end
h={ lv: lv, name: name, obj: obj, idx: idx, autonum_: false, tags: tags}
SiSU_DAL_DocumentStructure::ObjectHeading.new.heading(h)
elsif t_o=~/^:?[A-C1-6]\~(\S+)\s+(.+)/m
name,obj=$1,$2
note=endnote_test?(obj)
obj,tags=extract_tags(obj,name)
+ if @@flag[:ocn]==:off_headings_exclude \
+ or @@flag[:ocn]==:off_headings_substantive
+ unless obj =~ /[~-][#]\s*$/
+ if @@flag[:ocn]==:off_headings_exclude
+ obj << ' -#'
+ elsif @@flag[:ocn]==:off_headings_substantive
+ obj << ' ~#'
+ end
+ end
+ end
h={ lv: lv, name: name, obj: obj, idx: idx, tags: tags }
SiSU_DAL_DocumentStructure::ObjectHeading.new.heading(h)
else nil
@@ -221,6 +269,12 @@ module SiSU_DAL_DocumentStructureExtract
note=endnote_test?(obj)
obj,tags=extract_tags(obj)
unless obj=~/\A\s*\Z/m
+ if @@flag[:ocn]==:off_headings_exclude \
+ or @@flag[:ocn]==:off_headings_substantive
+ unless obj =~ /[~-][#]\s*$/
+ obj << ' ~#'
+ end
+ end
h={ bullet_: bullet, hang: hang, indent: indent, obj: obj, idx: idx, note_: note, image_: image, tags: tags }
SiSU_DAL_DocumentStructure::ObjectPara.new.paragraph(h)
end
@@ -238,6 +292,12 @@ module SiSU_DAL_DocumentStructureExtract
note=endnote_test?(obj)
obj,tags=extract_tags(obj)
unless obj=~/\A\s*\Z/m
+ if @@flag[:ocn]==:off_headings_exclude \
+ or @@flag[:ocn]==:off_headings_substantive
+ unless obj =~ /[~-][#]\s*$/
+ obj << ' ~#'
+ end
+ end
h={ hang: hang, indent: indent, obj: obj, idx: idx, note_: note, image_: image, tags: tags }
SiSU_DAL_DocumentStructure::ObjectPara.new.paragraph(h)
end
@@ -255,6 +315,12 @@ module SiSU_DAL_DocumentStructureExtract
image=image_test(t_o)
note=endnote_test?(t_o)
obj,tags=extract_tags(t_o)
+ if @@flag[:ocn]==:off_headings_exclude \
+ or @@flag[:ocn]==:off_headings_substantive
+ unless obj =~ /[~-][#]\s*$/
+ obj << ' ~#'
+ 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 }
SiSU_DAL_DocumentStructure::ObjectPara.new.paragraph(h)