aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/develop/ao_doc_str.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sisu/develop/ao_doc_str.rb')
-rw-r--r--lib/sisu/develop/ao_doc_str.rb153
1 files changed, 136 insertions, 17 deletions
diff --git a/lib/sisu/develop/ao_doc_str.rb b/lib/sisu/develop/ao_doc_str.rb
index c5f39ed4..353469ec 100644
--- a/lib/sisu/develop/ao_doc_str.rb
+++ b/lib/sisu/develop/ao_doc_str.rb
@@ -231,21 +231,8 @@ 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 /[+]/
@@ -274,6 +261,29 @@ module SiSU_AO_DocumentStructureExtract
t_o=SiSU_AO_DocumentStructure::ObjectFlag.new.flag_ocn(h)
next
end
+ 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
@@ -1046,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={
@@ -1065,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
@@ -1110,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=[]