aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/current/ao_doc_str.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sisu/current/ao_doc_str.rb')
-rw-r--r--lib/sisu/current/ao_doc_str.rb406
1 files changed, 250 insertions, 156 deletions
diff --git a/lib/sisu/current/ao_doc_str.rb b/lib/sisu/current/ao_doc_str.rb
index 50916d10..fba1724e 100644
--- a/lib/sisu/current/ao_doc_str.rb
+++ b/lib/sisu/current/ao_doc_str.rb
@@ -55,45 +55,21 @@
=end
module SiSU_AO_DocumentStructureExtract
+ require_relative 'ao_persist' # ao_persist.rb
class Instantiate < SiSU_Param::Parameters::Instructions
- @@flag={
- ocn: :on,
- code: :off,
- lngsyn: :txt,
- poem: :off,
- block: :off,
- box: :off,
- group: :off,
- alt: :off,
- quote: :off,
- table: :off,
- table_to: :off,
- }
def initialize
@@counter=@@column=@@columns=0
@@line_mode=''
end
end
class Build
- @@flag={
- ocn: :on,
- code: :off,
- lngsyn: :txt,
- poem: :off,
- block: :off,
- box: :off,
- group: :off,
- alt: :off,
- quote: :off,
- table: :off,
- table_to: :off,
- }
def initialize(md,data)
@md,@data=md,data
SiSU_AO_DocumentStructureExtract::Instantiate.new
@pb=SiSU_AO_DocumentStructure::ObjectLayout.new.break(Hx[:br_page])
@pbn=SiSU_AO_DocumentStructure::ObjectLayout.new.break(Hx[:br_page_new])
@pbl=SiSU_AO_DocumentStructure::ObjectLayout.new.break(Hx[:br_page_line])
+ @per=SiSU_AO_Persist::PersistDocStructExt.new
end
def ln_get(lv)
case lv
@@ -120,7 +96,7 @@ module SiSU_AO_DocumentStructureExtract
: false
end
def quotes?
- @@flag[:quote]==:open \
+ @per.quote==:open \
? true
: false
end
@@ -255,42 +231,29 @@ module SiSU_AO_DocumentStructureExtract
array: idx_array,
}
end
- def identify_parts
- tuned_file=[]
- @tuned_block,@tuned_code=[],[]
- @@counter,@verse_count=0,0
- @num_id={
- code_block: 0,
- poem: 0,
- box: 0,
- group: 0,
- alt: 0,
- quote: 0,
- table: 0,
- }
- @metadata={}
- @data.each do |t_o|
+ def extract_structure_loop(data,tuned_file)
+ data.each do |t_o|
if t_o =~/^--([+~-])[#]$/
h=case $1
when /[+]/
- @@flag[:ocn]=:on
+ @per.ocn=:on
{
flag: :ocn_on,
}
when /[~]/
- @@flag[:ocn]=:ocn_off_headings_keep
+ @per.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
+ @per.ocn=:ocn_off_headings_dummy_lev1
{
flag: :ocn_off,
mod: :headings_exclude,
}
else
- @@flag[:ocn]=:on
+ @per.ocn=:on
{
flag: :ocn_on,
}
@@ -298,7 +261,30 @@ module SiSU_AO_DocumentStructureExtract
t_o=SiSU_AO_DocumentStructure::ObjectFlag.new.flag_ocn(h)
next
end
- t_o=t_o.gsub(/(?:\n\s*\n)+/m,"\n") if @@flag[:code]==:off
+ if t_o =~/^:[~](#{SiSU_is.language_list_regex?}|-)$/ # work with for identifying language of objects
+ lng=$1
+ h=case lng
+ when /(?:#{SiSU_is.language_list_regex?})/
+ @per.lng=:on
+ @per.lng_is=lng.to_sym
+ {
+ flag: :lng_on,
+ act: lng.to_sym,
+ }
+ else # ^:~-
+ if @per.lng==:on
+ @per.lng=:off
+ @per.lng_is=:doc_default
+ {
+ flag: :lng_off,
+ act: :doc_default,
+ }
+ end
+ end
+ t_o=SiSU_AO_DocumentStructure::ObjectFlag.new.flag_lng(h)
+ next
+ end
+ t_o=t_o.gsub(/(?:\n\s*\n)+/m,"\n") if @per.code==:off
unless t_o =~/^(?:@\S+?:|%+)\s/ # extract book index for paragraph if any
idx=if t_o=~/^=\{\s*(.+)\s*\}\s*$\Z/m
m=$1
@@ -313,13 +299,13 @@ module SiSU_AO_DocumentStructureExtract
end
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*$|^`:quote_(?:open|close)`/ \
- 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
+ and @per.code==:off \
+ and @per.poem==:off \
+ and @per.group==:off \
+ and @per.block==:off \
+ and @per.alt==:off \
+ and @per.box==:off \
+ and @per.table==:off
t_o=case t_o
when /^#{Mx[:meta_o]}\S+?#{Mx[:meta_c]}/ #metadata, header
if t_o=~/^#{Mx[:meta_o]}(\S+?)#{Mx[:meta_c]}\s*(.+)/m
@@ -340,14 +326,14 @@ module SiSU_AO_DocumentStructureExtract
obj=$1
note=endnote_test?(obj)
obj,tags=extract_tags(obj)
- if @@flag[:ocn]==:ocn_off_headings_dummy_lev1 \
- or @@flag[:ocn]==:ocn_off_headings_keep
+ if @per.ocn==:ocn_off_headings_dummy_lev1 \
+ or @per.ocn==:ocn_off_headings_keep
unless obj =~ /[~-][#]\s*$/
- if @@flag[:ocn]==:ocn_off_headings_dummy_lev1 \
+ if @per.ocn==:ocn_off_headings_dummy_lev1 \
and t_o =~/^1\~\S*\s+/m
obj << ' -#'
- elsif @@flag[:ocn]==:ocn_off_headings_dummy_lev1 \
- or @@flag[:ocn]==:ocn_off_headings_keep
+ elsif @per.ocn==:ocn_off_headings_dummy_lev1 \
+ or @per.ocn==:ocn_off_headings_keep
obj << ' ~#'
end
end
@@ -364,14 +350,14 @@ module SiSU_AO_DocumentStructureExtract
name,obj=$1,$2
note=endnote_test?(obj)
obj,tags=extract_tags(obj)
- if @@flag[:ocn]==:ocn_off_headings_dummy_lev1 \
- or @@flag[:ocn]==:ocn_off_headings_keep
+ if @per.ocn==:ocn_off_headings_dummy_lev1 \
+ or @per.ocn==:ocn_off_headings_keep
unless obj =~ /[~-][#]\s*$/
- if @@flag[:ocn]==:ocn_off_headings_dummy_lev1 \
+ if @per.ocn==:ocn_off_headings_dummy_lev1 \
and t_o =~/^1\~\S*\s+/m
obj << ' -#'
- elsif @@flag[:ocn]==:ocn_off_headings_dummy_lev1 \
- or @@flag[:ocn]==:ocn_off_headings_keep
+ elsif @per.ocn==:ocn_off_headings_dummy_lev1 \
+ or @per.ocn==:ocn_off_headings_keep
obj << ' ~#'
end
end
@@ -389,14 +375,14 @@ module SiSU_AO_DocumentStructureExtract
name,obj=$1,$2
note=endnote_test?(obj)
obj,tags=extract_tags(obj,name)
- if @@flag[:ocn]==:ocn_off_headings_dummy_lev1 \
- or @@flag[:ocn]==:ocn_off_headings_keep
+ if @per.ocn==:ocn_off_headings_dummy_lev1 \
+ or @per.ocn==:ocn_off_headings_keep
unless obj =~ /[~-][#]\s*$/
- if @@flag[:ocn]==:ocn_off_headings_dummy_lev1 \
+ if @per.ocn==:ocn_off_headings_dummy_lev1 \
and t_o =~/^1\~\S*\s+/m
obj << ' -#'
- elsif @@flag[:ocn]==:ocn_off_headings_dummy_lev1 \
- or @@flag[:ocn]==:ocn_off_headings_keep
+ elsif @per.ocn==:ocn_off_headings_dummy_lev1 \
+ or @per.ocn==:ocn_off_headings_keep
obj << ' ~#'
end
end
@@ -424,8 +410,8 @@ module SiSU_AO_DocumentStructureExtract
note=endnote_test?(obj)
obj,tags=extract_tags(obj)
unless obj=~/\A\s*\Z/m
- if @@flag[:ocn]==:ocn_off_headings_dummy_lev1 \
- or @@flag[:ocn]==:ocn_off_headings_keep
+ if @per.ocn==:ocn_off_headings_dummy_lev1 \
+ or @per.ocn==:ocn_off_headings_keep
unless obj =~ /[~-][#]\s*$/
obj << ' ~#'
end
@@ -457,8 +443,8 @@ module SiSU_AO_DocumentStructureExtract
note=endnote_test?(obj)
obj,tags=extract_tags(obj)
unless obj=~/\A\s*\Z/m
- if @@flag[:ocn]==:ocn_off_headings_dummy_lev1 \
- or @@flag[:ocn]==:ocn_off_headings_keep
+ if @per.ocn==:ocn_off_headings_dummy_lev1 \
+ or @per.ocn==:ocn_off_headings_keep
unless obj =~ /[~-][#]\s*$/
obj << ' ~#'
end
@@ -489,8 +475,8 @@ module SiSU_AO_DocumentStructureExtract
image=image_test(t_o)
note=endnote_test?(t_o)
obj,tags=extract_tags(t_o)
- if @@flag[:ocn]==:ocn_off_headings_dummy_lev1 \
- or @@flag[:ocn]==:ocn_off_headings_keep
+ if @per.ocn==:ocn_off_headings_dummy_lev1 \
+ or @per.ocn==:ocn_off_headings_keep
unless obj =~ /[~-][#]\s*$/
obj << ' ~#'
end
@@ -511,14 +497,14 @@ module SiSU_AO_DocumentStructureExtract
end
t_o=SiSU_AO_DocumentStructureExtract::Structure.new(@md).structure_markup(t_o) #must happen earlier, node info etc. require
end
- elsif @@flag[:code]==:off
+ elsif @per.code==:off
if t_o =~/^(?:code(?:\.[a-z][0-9a-z_]+)?\{|```[ ]+code(?:\.[a-z][0-9a-z_]+)?)/
- @@flag[:code]=case t_o
+ @per.code=case t_o
when /^code(?:\.[a-z][0-9a-z_]+)?\{/ then :curls
when /^```[ ]+code/ then :tics
- else @@flag[:code] #error
+ else @per.code #error
end
- @@flag[:lngsyn]=if t_o =~/^(?:code\.[a-z][0-9a-z_]+\{|```[ ]+code\.[a-z_]+)/
+ @per.lngsyn=if t_o =~/^(?:code\.[a-z][0-9a-z_]+\{|```[ ]+code\.[a-z_]+)/
case t_o
when /^code\.([a-z][0-9a-z_]+)\{/
:"#{$1}"
@@ -539,14 +525,14 @@ module SiSU_AO_DocumentStructureExtract
obj: '',
sym: :code_block_open,
num: @num_id[:code_block],
- syntax: @@flag[:lngsyn],
+ syntax: @per.lngsyn,
}
t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h)
elsif t_o =~/^(?:poem\{|```[ ]+poem)/
- @@flag[:poem]=case t_o
+ @per.poem=case t_o
when /^poem\{/ then :curls
when /^```[ ]+poem/ then :tics
- else @@flag[:poem] #error
+ else @per.poem #error
end
@num_id[:poem] +=1
h={
@@ -558,10 +544,10 @@ module SiSU_AO_DocumentStructureExtract
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
+ @per.box=case t_o
when /^box\{/ then :curls
when /^```[ ]+box/ then :tics
- else @@flag[:box] #error
+ else @per.box #error
end
@num_id[:box] +=1
h={
@@ -573,10 +559,10 @@ module SiSU_AO_DocumentStructureExtract
t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h)
tuned_file << t_o
elsif t_o =~/^(?:group\{|```[ ]+group)/
- @@flag[:group]=case t_o
+ @per.group=case t_o
when /^group\{/ then :curls
when /^```[ ]+group/ then :tics
- else @@flag[:group] #error
+ else @per.group #error
end
@num_id[:group] +=1
h={
@@ -588,10 +574,10 @@ module SiSU_AO_DocumentStructureExtract
t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h)
tuned_file << t_o
elsif t_o =~/^(?:block\{|```[ ]+block)/
- @@flag[:block]=case t_o
+ @per.block=case t_o
when /^block\{/ then :curls
when /^```[ ]+block/ then :tics
- else @@flag[:block] #error
+ else @per.block #error
end
@num_id[:block] +=1
h={
@@ -603,10 +589,10 @@ module SiSU_AO_DocumentStructureExtract
t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h)
tuned_file << t_o
elsif t_o =~/^(?:alt\{|```[ ]+alt)/
- @@flag[:alt]=case t_o
+ @per.alt=case t_o
when /^alt\{/ then :curls
when /^```[ ]+alt/ then :tics
- else @@flag[:alt] #error
+ else @per.alt #error
end
@num_id[:alt] +=1
h={
@@ -618,7 +604,7 @@ module SiSU_AO_DocumentStructureExtract
t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h)
tuned_file << t_o
elsif t_o =~/^`:quote_open`/
- @@flag[:quote]=:open
+ @per.quote=:open
@num_id[:quote] +=1
h={
is_for: :quote,
@@ -639,7 +625,7 @@ module SiSU_AO_DocumentStructureExtract
ins_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h)
tuned_file << ins_o
if t_o=~/^table\{(?:~h)?\s+/
- @@flag[:table]=:curls
+ @per.table=:curls
@rows=''
case t_o
when /table\{~h\s+c(\d+);\s+(.+)/
@@ -658,7 +644,7 @@ module SiSU_AO_DocumentStructureExtract
idx: idx,
}
elsif t_o=~/^```[ ]+table(?:~h)?\s+c\d+/
- @@flag[:table]=:tics
+ @per.table=:tics
@rows=''
case t_o
when /^```[ ]+table~h\s+c(\d+);\s+(.+)/
@@ -797,12 +783,12 @@ module SiSU_AO_DocumentStructureExtract
end
t_o
end
- if @@flag[:table]==:curls or @@flag[:table]==:tics
- if (@@flag[:table]==:curls \
+ if @per.table==:curls or @per.table==:tics
+ if (@per.table==:curls \
and t_o =~/^\}table/) \
- or (@@flag[:table]==:tics \
+ or (@per.table==:tics \
and t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/)
- @@flag[:table]=:off
+ @per.table=:off
headings,columns,widths,idx=@h[:head_],@h[:cols],@h[:widths],@h[:idx]
@h={
head_: headings,
@@ -832,13 +818,13 @@ module SiSU_AO_DocumentStructureExtract
t_o=nil
end
end
- if @@flag[:code]==:curls \
- or @@flag[:code]==:tics
- if (@@flag[:code]==:curls \
+ if @per.code==:curls \
+ or @per.code==:tics
+ if (@per.code==:curls \
&& t_o =~/^\}code/) \
- or (@@flag[:code]==:tics \
+ or (@per.code==:tics \
&& t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/m)
- @@flag[:code]=:off
+ @per.code=:off
if @tuned_code[-1]
@tuned_code[-1].
gsub!(/\s*(?:#{Mx[:br_line]}|#{Mx[:br_nl]})\s*\Z/m,'')
@@ -848,12 +834,12 @@ module SiSU_AO_DocumentStructureExtract
h={
obj: obj,
idx: idx,
- syntax: @@flag[:lngsyn],
+ syntax: @per.lngsyn,
tags: tags,
num: @num_id[:code_block],
number_: @codeblock_numbered,
}
- @@flag[:lngsyn]=:txt
+ @per.lngsyn=:txt
t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.code(h)
@tuned_code=[]
tuned_file << t_o
@@ -865,8 +851,8 @@ module SiSU_AO_DocumentStructureExtract
}
t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h)
end
- if (@@flag[:code]==:curls \
- || @@flag[:code]==:tics) \
+ if (@per.code==:curls \
+ || @per.code==:tics) \
and t_o.is_a?(String)
sub_array=t_o.dup + "#{Mx[:br_nl]}"
@line_mode=[]
@@ -875,23 +861,23 @@ module SiSU_AO_DocumentStructureExtract
@tuned_code << t_o
t_o=nil
end
- elsif (@@flag[:poem]==:curls \
- || @@flag[:poem]==:tics) \
- or (@@flag[:box]==:curls \
- || @@flag[:box]==:tics) \
- or (@@flag[:group]==:curls \
- || @@flag[:group]==:tics) \
- or (@@flag[:block]==:curls \
- || @@flag[:block]==:tics) \
- or (@@flag[:alt]==:curls \
- || @@flag[:alt]==:tics) \
- or (@@flag[:quote]==:open \
+ elsif (@per.poem==:curls \
+ || @per.poem==:tics) \
+ or (@per.box==:curls \
+ || @per.box==:tics) \
+ or (@per.group==:curls \
+ || @per.group==:tics) \
+ or (@per.block==:curls \
+ || @per.block==:tics) \
+ or (@per.alt==:curls \
+ || @per.alt==:tics) \
+ or (@per.quote==:open \
&& t_o =~/`:quote_close`/m) #not
- if (@@flag[:poem]==:curls \
+ if (@per.poem==:curls \
&& t_o =~/^\}poem$/m) \
- or (@@flag[:poem]==:tics \
+ or (@per.poem==:tics \
&& t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/)
- @@flag[:poem]=:off
+ @per.poem=:off
h={
is_for: :poem,
obj: '',
@@ -900,11 +886,11 @@ module SiSU_AO_DocumentStructureExtract
num: @num_id[:poem],
}
t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h)
- elsif (@@flag[:box]==:curls \
+ elsif (@per.box==:curls \
&& t_o =~/^\}box/) \
- or (@@flag[:box]==:tics \
+ or (@per.box==:tics \
&& t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/)
- @@flag[:box]=:off
+ @per.box=:off
obj,tags=extract_tags(@tuned_block.join("\n"))
h={
obj: obj,
@@ -923,11 +909,11 @@ module SiSU_AO_DocumentStructureExtract
num: @num_id[:box],
}
t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h)
- elsif (@@flag[:group]==:curls \
+ elsif (@per.group==:curls \
&& t_o =~/^\}group/) \
- or (@@flag[:group]==:tics \
+ or (@per.group==:tics \
&& t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/)
- @@flag[:group]=:off
+ @per.group=:off
obj,tags=extract_tags(@tuned_block.join("\n"))
h={
obj: obj,
@@ -945,11 +931,11 @@ module SiSU_AO_DocumentStructureExtract
num: @num_id[:group],
}
t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h)
- elsif (@@flag[:block]==:curls \
+ elsif (@per.block==:curls \
&& t_o =~/^\}block/) \
- or (@@flag[:block]==:tics \
+ or (@per.block==:tics \
&& t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/)
- @@flag[:block]=:off
+ @per.block=:off
obj,tags=extract_tags(@tuned_block.join("\n"))
h={
obj: obj,
@@ -967,11 +953,11 @@ module SiSU_AO_DocumentStructureExtract
num: @num_id[:block],
}
t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h)
- elsif (@@flag[:alt]==:curls \
+ elsif (@per.alt==:curls \
&& t_o =~/^\}alt/) \
- or (@@flag[:alt]==:tics \
+ or (@per.alt==:tics \
&& t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/)
- @@flag[:alt]=:off
+ @per.alt=:off
obj,tags=extract_tags(@tuned_block.join("\n"))
h={
obj: obj,
@@ -989,9 +975,9 @@ module SiSU_AO_DocumentStructureExtract
num: @num_id[:alt],
}
t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h)
- elsif @@flag[:quote]==:open \
+ elsif @per.quote==:open \
and t_o =~/`:quote_close`/m
- @@flag[:quote]=:off
+ @per.quote=:off
h={
is_for: :quote,
idx: idx,
@@ -1000,7 +986,7 @@ module SiSU_AO_DocumentStructureExtract
num: @num_id[:quote],
}
t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h)
- elsif @@flag[:quote]==:open
+ elsif @per.quote==:open
t_o,tags=extract_tags(t_o)
h={
indent: 1,
@@ -1013,18 +999,18 @@ module SiSU_AO_DocumentStructureExtract
}
SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h)
end
- if (@@flag[:poem]==:curls \
- || @@flag[:poem]==:tics) \
- or (@@flag[:group]==:curls \
- || @@flag[:group]==:tics) \
- or (@@flag[:alt]==:curls \
- || @@flag[:alt]==:tics) \
+ if (@per.poem==:curls \
+ || @per.poem==:tics) \
+ or (@per.group==:curls \
+ || @per.group==:tics) \
+ or (@per.alt==:curls \
+ || @per.alt==:tics) \
and t_o =~/\S/ \
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
+ type=if @per.poem==:curls or @per.poem==:tics
t_o=SiSU_AO_DocumentStructureExtract::Build.new(@md,@line_mode).build_lines(type).join
poem=t_o.split(/\n\n/)
poem.each do |v|
@@ -1042,14 +1028,14 @@ module SiSU_AO_DocumentStructureExtract
else :group
end
end
- @verse_count+=1 if @@flag[:poem]==:curls or @@flag[:poem]==:tics
+ @verse_count+=1 if @per.poem==:curls or @per.poem==:tics
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 \
- or (@@flag[:quote]==:open and t_o =~/`:quote_close`/m)
+ if @per.code==:off
+ if @per.poem==:curls or @per.poem==:tics \
+ or @per.box==:curls or @per.box==:tics \
+ or @per.group==:curls or @per.group==:tics \
+ or @per.alt==:curls or @per.alt==:tics \
+ or (@per.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}").
@@ -1070,6 +1056,24 @@ module SiSU_AO_DocumentStructureExtract
else tuned_file << t_o
end
end
+ tuned_file
+ end
+ def identify_parts
+ tuned_file=[]
+ @tuned_block,@tuned_code=[],[]
+ @@counter,@verse_count=0,0
+ @num_id={
+ code_block: 0,
+ poem: 0,
+ box: 0,
+ group: 0,
+ alt: 0,
+ quote: 0,
+ table: 0,
+ }
+ @metadata={}
+ @data,bibliography=SiSU_AO_References::Bibliography.new(@md,@data).biblio_extraction
+ tuned_file=extract_structure_loop(@data,tuned_file)
if @md.flag_endnotes
tuned_file << @pb
h={
@@ -1089,7 +1093,98 @@ module SiSU_AO_DocumentStructureExtract
tuned_file << SiSU_AO_DocumentStructure::ObjectHeading.new.heading_insert(h)
h={
obj: 'Endnotes'
- }
+ }
+ end
+ if @md.flag_auto_biblio
+ tuned_file << @pb
+ h={
+ ln: 1,
+ lc: 1,
+ obj: 'References',
+ autonum_: false,
+ }
+ tuned_file << SiSU_AO_DocumentStructure::ObjectHeading.new.heading_insert(h)
+ h={
+ ln: 4,
+ lc: 2,
+ obj: 'Bibliography',
+ name: 'biblio',
+ autonum_: false,
+ }
+ tuned_file << SiSU_AO_DocumentStructure::ObjectHeading.new.heading_insert(h)
+ h={
+ obj: 'Bibliography'
+ }
+ citenumber=0
+ bibliography.each do |c|
+ citenumber +=1 if c.is_a?(Hash)
+ if c[:is]==:book
+ h={
+ obj: %{[#{citenumber}] *{#{c[:author]}}* /{"#{c[:fulltitle]}"}/ #{c[:publisher]} (#{c[:year]}) #{c[:url]}},
+ tags: [c[:id]],
+ hang: 0,
+ indent: 2,
+ ocn_: false,
+ }
+ tuned_file << SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h)
+ elsif c[:is]==:article
+ h={
+ obj: %{[#{citenumber}] *{#{c[:author]}}* /{"#{c[:title]}"}/ #{c[:journal]} #{c[:volume]} (#{c[:year]}) #{c[:url]}},
+ tags: [c[:id]],
+ hang: 0,
+ indent: 2,
+ ocn_: false,
+ }
+ tuned_file << SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h)
+ end
+ end
+ elsif @md.flag_biblio
+ tuned_file << @pb
+ h={
+ ln: 1,
+ lc: 1,
+ obj: 'References',
+ autonum_: false,
+ }
+ tuned_file << SiSU_AO_DocumentStructure::ObjectHeading.new.heading_insert(h)
+ h={
+ ln: 4,
+ lc: 2,
+ obj: 'Bibliography',
+ name: 'biblio',
+ autonum_: false,
+ }
+ tuned_file << SiSU_AO_DocumentStructure::ObjectHeading.new.heading_insert(h)
+ h={
+ obj: 'Bibliography'
+ }
+ if bibliography.length > 0
+ tuned_file=extract_structure_loop(bibliography,tuned_file)
+ else
+ tuned_file, citations =
+ SiSU_AO_References::Citations.new(@md,tuned_file).songsheet # ao_references.rb
+ citenumber=0
+ citations.compact.each do |c|
+ citenumber +=1 if c.is_a?(Hash)
+ if c[:is]==:book
+ h={
+ obj: %{[#{citenumber}] *{#{c[:author]}}* /{#{c[:publication]}}/ (#{c[:year]})},
+ hang: 0,
+ indent: 2,
+ ocn_: false,
+ }
+ tuned_file << SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h)
+ elsif c[:is]==:article
+ h={
+ obj: %{[#{citenumber}] *{#{c[:author]}}* /{"#{c[:title]}"}/ #{c[:publication]} editor #{c[:editor]} (#{c[:year]})},
+ hang: 0,
+ indent: 2,
+ ocn_: false,
+ }
+ tuned_file << SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h)
+ end
+ end
+ end
end
if @md.book_idx
tuned_file << @pb
@@ -1134,7 +1229,7 @@ module SiSU_AO_DocumentStructureExtract
obj: 'eof',
}
meta=SiSU_AO_DocumentStructure::ObjectMetadata.new.metadata(@metadata)
- [tuned_file,meta]
+ [tuned_file,meta,bibliography]
end
def table_rows_and_columns_array(table_str)
table=[]
@@ -1162,13 +1257,13 @@ module SiSU_AO_DocumentStructureExtract
SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h)
end
def build_lines(type=:none)
- lines,lines_new=@data,[]
- lines.each do |line|
+ lines=@data
+ lines.each.map do |line|
line=if line =~/\S/ \
and line !~/^(?:code(?:\.[a-z][0-9a-z_]+)?\{|\}code)/ \
and line !~/^(?:```[ ]+code(?:\.[a-z][0-9a-z_]+)?|```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$)/ \
and not line.is_a?(Hash) #watch
- @@counter+=1 if @@flag[:code]==:curls or @@flag[:code]==:tics
+ @@counter+=1 if @per.code==:curls or @per.code==:tics
line=line.gsub(/\s\s/,"#{Mx[:nbsp]*2}").
gsub(/#{Mx[:nbsp]}\s/,"#{Mx[:nbsp]*2}")
line=line.gsub(/^/,"#{Mx[:gr_o]}codeline#{Mx[:gr_c]}") if type==:code # REMOVE try sort for texpdf special case
@@ -1180,9 +1275,8 @@ module SiSU_AO_DocumentStructureExtract
line.gsub(/\s*$/,"#{Mx[:br_nl]}")
else line
end
- lines_new << line
+ line
end
- lines_new
end
end
class Structure # this must happen early