diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/sisu/v6/ao_doc_objects.rb | 16 | ||||
-rw-r--r-- | lib/sisu/v6/ao_doc_str.rb | 80 | ||||
-rw-r--r-- | lib/sisu/v6/ao_numbering.rb | 2 | ||||
-rw-r--r-- | lib/sisu/v6/texpdf_format.rb | 22 | ||||
-rw-r--r-- | lib/sisu/v6/txt_plain.rb | 5 | ||||
-rw-r--r-- | lib/sisu/v6/xml_odf_odt.rb | 7 |
6 files changed, 74 insertions, 58 deletions
diff --git a/lib/sisu/v6/ao_doc_objects.rb b/lib/sisu/v6/ao_doc_objects.rb index 8dbdedc3..9555ab5e 100644 --- a/lib/sisu/v6/ao_doc_objects.rb +++ b/lib/sisu/v6/ao_doc_objects.rb @@ -100,10 +100,10 @@ module SiSU_AO_DocumentStructure end end class ObjectHeading - attr_accessor :obj,:is,:tags,:of,:lv,:ln,:lc,:toc_,:name,:idx,:ocn,:odv,:osp,:node,:parent,:ocn_,:note_,:autonum_,:digest,:tmp + attr_accessor :obj,:is,:tags,:of,:lv,:ln,:lc,:use_,:name,:idx,:ocn,:odv,:osp,:node,:parent,:ocn_,:note_,:autonum_,:digest,:tmp def initialize @of=:para - @is=@obj=@lv=@ln=@lc=@toc_=@name=@idx=@size=@ocn=@odv=@osp=@node=@parent=@ocn_=@note_=@autonum_=@digest=@tmp=nil + @is=@obj=@lv=@ln=@lc=@use_=@name=@idx=@size=@ocn=@odv=@osp=@node=@parent=@ocn_=@note_=@autonum_=@digest=@tmp=nil @tags=[] end def heading_ln(lv) @@ -156,7 +156,15 @@ module SiSU_AO_DocumentStructure lv= h[:lv] || ((defined? o.lv) ? o.lv : nil) #Alpha-numeric, document structure as used in markup, A-D then 1-6 ln= h[:ln] || ((defined? o.ln) ? o.ln : nil) #Integer, document structure level, for convenience in processing 1-9 lc= h[:lc] || ((defined? o.lc) ? o.lc : nil) #Integer, document structure collapsed level, convenience (collapse sisu's dual level document structure for markup with simple linear structure) - toc_= h[:toc_] || ((defined? o.toc_) ? o.toc_ : false) #Bool, do not include in toc, (relevant to headings) + use_=if lv \ + and lv == '1' + h[:use_] || ((defined? o.use_) ? o.use_ : :ok) + elsif not lv.empty? \ + and lv =~ /[A-D2-3]/ + :ok + else + h[:use_] || ((defined? o.use_) ? o.use_ : :ok) + end ocn_=if h[:ocn_].nil? then ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider else h[:ocn_] end @@ -166,7 +174,7 @@ module SiSU_AO_DocumentStructure note_= h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, sha512, sha256 or md5 tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use - @of,@is,@lv,@ln,@lc,@name,@tags,@obj,@idx,@ocn,@odv,@osp,@node,@parent,@toc_,@ocn_,@note_,@autonum_,@digest,@tmp=of,is,lv,ln,lc,name,tags,obj,idx,ocn,odv,osp,node,parent,toc_,ocn_,note_,autonum_,digest,tmp + @of,@is,@lv,@ln,@lc,@name,@tags,@obj,@idx,@ocn,@odv,@osp,@node,@parent,@use_,@ocn_,@note_,@autonum_,@digest,@tmp=of,is,lv,ln,lc,name,tags,obj,idx,ocn,odv,osp,node,parent,use_,ocn_,note_,autonum_,digest,tmp self end def heading_insert(h,o=nil) diff --git a/lib/sisu/v6/ao_doc_str.rb b/lib/sisu/v6/ao_doc_str.rb index 3eb4a804..d060d89c 100644 --- a/lib/sisu/v6/ao_doc_str.rb +++ b/lib/sisu/v6/ao_doc_str.rb @@ -234,10 +234,10 @@ module SiSU_AO_DocumentStructureExtract @@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]=:ocn_off_headings_keep + {flag: :ocn_off, mod: :headings_keep} + when /[-]/ #of particular relevance with level 1~ which is required to precede substantive text & used e.g. in html segmented text + @@flag[:ocn]=:ocn_off_headings_dummy_lev1 {flag: :ocn_off, mod: :headings_exclude} else @@flag[:ocn]=:on @@ -286,12 +286,14 @@ module SiSU_AO_DocumentStructureExtract obj=$1 note=endnote_test?(obj) obj,tags=extract_tags(obj) - if @@flag[:ocn]==:off_headings_exclude \ - or @@flag[:ocn]==:off_headings_substantive + if @@flag[:ocn]==:ocn_off_headings_dummy_lev1 \ + or @@flag[:ocn]==:ocn_off_headings_keep unless obj =~ /[~-][#]\s*$/ - if @@flag[:ocn]==:off_headings_exclude + if @@flag[:ocn]==:ocn_off_headings_dummy_lev1 \ + and t_o =~/^1\~\S*\s+/m obj << ' -#' - elsif @@flag[:ocn]==:off_headings_substantive + elsif @@flag[:ocn]==:ocn_off_headings_dummy_lev1 \ + or @@flag[:ocn]==:ocn_off_headings_keep obj << ' ~#' end end @@ -302,12 +304,14 @@ module SiSU_AO_DocumentStructureExtract 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 + if @@flag[:ocn]==:ocn_off_headings_dummy_lev1 \ + or @@flag[:ocn]==:ocn_off_headings_keep unless obj =~ /[~-][#]\s*$/ - if @@flag[:ocn]==:off_headings_exclude + if @@flag[:ocn]==:ocn_off_headings_dummy_lev1 \ + and t_o =~/^1\~\S*\s+/m obj << ' -#' - elsif @@flag[:ocn]==:off_headings_substantive + elsif @@flag[:ocn]==:ocn_off_headings_dummy_lev1 \ + or @@flag[:ocn]==:ocn_off_headings_keep obj << ' ~#' end end @@ -318,12 +322,14 @@ module SiSU_AO_DocumentStructureExtract 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 + if @@flag[:ocn]==:ocn_off_headings_dummy_lev1 \ + or @@flag[:ocn]==:ocn_off_headings_keep unless obj =~ /[~-][#]\s*$/ - if @@flag[:ocn]==:off_headings_exclude + if @@flag[:ocn]==:ocn_off_headings_dummy_lev1 \ + and t_o =~/^1\~\S*\s+/m obj << ' -#' - elsif @@flag[:ocn]==:off_headings_substantive + elsif @@flag[:ocn]==:ocn_off_headings_dummy_lev1 \ + or @@flag[:ocn]==:ocn_off_headings_keep obj << ' ~#' end end @@ -345,8 +351,8 @@ module SiSU_AO_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 + if @@flag[:ocn]==:ocn_off_headings_dummy_lev1 \ + or @@flag[:ocn]==:ocn_off_headings_keep unless obj =~ /[~-][#]\s*$/ obj << ' ~#' end @@ -368,8 +374,8 @@ module SiSU_AO_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 + if @@flag[:ocn]==:ocn_off_headings_dummy_lev1 \ + or @@flag[:ocn]==:ocn_off_headings_keep unless obj =~ /[~-][#]\s*$/ obj << ' ~#' end @@ -391,8 +397,8 @@ module SiSU_AO_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 + if @@flag[:ocn]==:ocn_off_headings_dummy_lev1 \ + or @@flag[:ocn]==:ocn_off_headings_keep unless obj =~ /[~-][#]\s*$/ obj << ' ~#' end @@ -1193,9 +1199,15 @@ SKIPPED processing file: [#{@md.opt.lng}] "#{@md.fns}"} dob.ln,dob.node,dob.ocn,dob.ocn_,dob.odv,dob.osp,dob.parent,dob.lc=ln,node,ocn,ocn_flag,ocn_dv,ocn_sp,parent,collapsed_level else ocnu+=1 - dob.obj=dob.obj.gsub(/#{Mx[:fa_o]}[~-]##{Mx[:fa_c]}/,'') if dob.obj - ocn_dv,ocn_sp="u#{ocnu}","u#{ocnu}" - dob.ln,dob.node,dob.ocn,dob.ocn_,dob.odv,dob.osp,dob.parent,dob.lc=ln,node,nil,ocn_flag,ocn_dv,ocn_sp,parent,collapsed_level + heading_use=:ok + if dob.obj=~/#{Mx[:pa_non_object_no_heading]}/ + dob.obj=dob.obj.gsub(/#{Mx[:pa_non_object_no_heading]}/,'') + heading_use=:ok + elsif dob.obj=~/#{Mx[:pa_non_object_dummy_heading]}/ + dob.obj=dob.obj.gsub(/#{Mx[:pa_non_object_dummy_heading]}/,'') + heading_use=:dummy + end + dob.ln,dob.node,dob.ocn,dob.ocn_,dob.use_,dob.odv,dob.osp,dob.parent,dob.lc=ln,node,nil,ocn_flag,heading_use,ocn_dv,ocn_sp,parent,collapsed_level end else if dob.of !=:meta \ @@ -1212,24 +1224,6 @@ SKIPPED processing file: [#{@md.opt.lng}] "#{@md.fns}"} end end h - elsif dob.obj=~/#{Mx[:pa_non_object_no_heading]}/ - dob.obj=dob.obj.gsub(/#{Mx[:pa_non_object_no_heading]}/,'') - if dob.is==:para - h={ obj: dob.obj, ocn_: false, ocn: nil, hang: dob.hang, indent: dob.indent, bullet_: dob.bullet_, tags: dob.tags, parent: dob.parent } - dob=SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h,dob) - elsif dob.is==:heading - h={ obj: dob.obj, ocn_: false, ocn: nil, toc_: true, parent: dob.parent } - dob=SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,dob) - end - elsif dob.obj=~/#{Mx[:pa_non_object_dummy_heading]}/ - dob.obj=dob.obj.gsub(/#{Mx[:pa_non_object_dummy_heading]}/,'') - if dob.is==:para - h={ obj: dob.obj, ocn_: false, ocn: nil, hang: dob.hang, indent: dob.indent, bullet_: dob.bullet_, tags: dob.tags, parent: dob.parent } - dob=SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h,dob) - elsif dob.is==:heading - h={ obj: dob.obj, ocn_: false, ocn: nil, toc_: false, parent: dob.parent } - dob=SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,dob) - end else dob end if dob.is==:code \ diff --git a/lib/sisu/v6/ao_numbering.rb b/lib/sisu/v6/ao_numbering.rb index acb2351a..e04befb0 100644 --- a/lib/sisu/v6/ao_numbering.rb +++ b/lib/sisu/v6/ao_numbering.rb @@ -167,7 +167,7 @@ module SiSU_AO_Numbering @subnumber=0 if dob.ln==no1 end if dob.ln.to_s =~/^[0-6]/ \ - and not dob.toc_ \ + and not dob.use_ ==:dummy \ and dob.obj !~/#{Mx[:fa_o]}(?:~#|-#)#{Mx[:fa_c]}/ # <-- fix if dob.ln==no1 t_no1+=1; t_no2=0; t_no3=0 diff --git a/lib/sisu/v6/texpdf_format.rb b/lib/sisu/v6/texpdf_format.rb index e680bc00..ce027718 100644 --- a/lib/sisu/v6/texpdf_format.rb +++ b/lib/sisu/v6/texpdf_format.rb @@ -258,20 +258,24 @@ module SiSU_TeX_Pdf \\markboth{#{@md.title.full}}\n") dob end - def heading_sublevels(dob,sublev) - if sublev==:lev1 + def heading_dev_null(dob) + dob.tmp,dob.obj='','' + dob + end + def heading_sublevels(dob) + if dob.lv=='1' sect='section' tocadd=%{\\addcontentsline{toc}{section}} pre='' post='' headadd=%{\n\\markright{#{@md.title.full}}} - elsif sublev==:lev2 + elsif dob.lv=='2' sect='subsection' tocadd=%{\\addcontentsline{toc}{subsection}} pre='' post=" \\\\\n" headadd='' - elsif sublev==:lev3 + elsif dob.lv=='3' sect='subsubsection' tocadd=%{\\addcontentsline{toc}{subsubsection}} pre='' #pre='~~~~' @@ -307,13 +311,17 @@ module SiSU_TeX_Pdf section_heading_level(@dob) end def heading_level_1 - heading_sublevels(@dob,:lev1) + if not @dob.use_ == :dummy + heading_sublevels(@dob) + else + heading_dev_null(@dob) + end end def heading_level_2 - heading_sublevels(@dob,:lev2) + heading_sublevels(@dob) end def heading_level_3 - heading_sublevels(@dob,:lev3) + heading_sublevels(@dob) end def hang case @dob.indent diff --git a/lib/sisu/v6/txt_plain.rb b/lib/sisu/v6/txt_plain.rb index 1aa08f0e..a56f5ac9 100644 --- a/lib/sisu/v6/txt_plain.rb +++ b/lib/sisu/v6/txt_plain.rb @@ -384,7 +384,10 @@ WOK when 1 then wrapped.upcase << break_line << decorate.heading_underscore.l1*times + p_num << break_line*2 when 2 then wrapped.upcase << break_line << decorate.heading_underscore.l2*times + p_num << break_line*2 when 3 then wrapped.upcase << break_line << decorate.heading_underscore.l3*times + p_num << break_line*2 - when 4 then wrapped.upcase << break_line << decorate.heading_underscore.l4*times + p_num << break_line*2 + when 4 + unless dob.use_ == :dummy + wrapped.upcase << break_line << decorate.heading_underscore.l4*times + p_num << break_line*2 + end when 5 then wrapped.upcase << break_line << decorate.heading_underscore.l5*times + p_num << break_line*2 when 6 then wrapped.upcase << break_line << decorate.heading_underscore.l6*times + p_num << break_line*2 end diff --git a/lib/sisu/v6/xml_odf_odt.rb b/lib/sisu/v6/xml_odf_odt.rb index 0457ad7d..0fe880c0 100644 --- a/lib/sisu/v6/xml_odf_odt.rb +++ b/lib/sisu/v6/xml_odf_odt.rb @@ -209,8 +209,11 @@ module SiSU_XML_ODF_ODT end end @@docstart=false - dob.tmp=dob.obj - dob.obj=%{#{breakpage}<text:h text:style-name="H_#{dob.ln}" text:outline-level="#{dob.ln}">#{p_num[:set_ref]}#{set_bookmark_tag(dob)}#{dob.obj}#{p_num[:display]}</text:h>} + if dob.use_ != :dummy + dob.tmp=dob.obj + dob.obj=%{#{breakpage}<text:h text:style-name="H_#{dob.ln}" text:outline-level="#{dob.ln}">#{p_num[:set_ref]}#{set_bookmark_tag(dob)}#{dob.obj}#{p_num[:display]}</text:h>} + else dob.tmp,dob.obj='','' + end dob end def toc(dob,p_num) |