summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2015-04-19 18:44:38 +0000
committerRalph Amissah <ralph@amissah.com>2015-05-01 22:49:40 +0000
commit1323f18af45ea0d3aaef5cd9ead0efb5de8b9729 (patch)
treee1abd6d04547c269666f276d8bdb24afa9d7dfee /lib
parentsetup.rb s/Config/RbConfig/ (diff)
downloadsisu-1323f18af45ea0d3aaef5cd9ead0efb5de8b9729.zip
sisu-1323f18af45ea0d3aaef5cd9ead0efb5de8b9729.tar.xz
c<-d: sync, roll develop into current dir branch (5==6)
* two dir branches, same library contents (v5 synced & updated with v6)
Diffstat (limited to 'lib')
-rw-r--r--lib/sisu/current/ao.rb106
-rw-r--r--lib/sisu/current/ao_character_check.rb9
-rw-r--r--lib/sisu/current/ao_composite.rb30
-rw-r--r--lib/sisu/current/ao_doc_objects.rb12
-rw-r--r--lib/sisu/current/ao_doc_str.rb406
-rw-r--r--lib/sisu/current/ao_endnotes.rb15
-rw-r--r--lib/sisu/current/ao_expand_insertions.rb16
-rw-r--r--lib/sisu/current/ao_hash_digest.rb8
-rw-r--r--lib/sisu/current/ao_idx.rb25
-rw-r--r--lib/sisu/current/ao_images.rb6
-rw-r--r--lib/sisu/current/ao_misc_arrange.rb8
-rw-r--r--lib/sisu/current/ao_numbering.rb16
-rw-r--r--lib/sisu/current/ao_persist.rb194
-rw-r--r--lib/sisu/current/ao_references.rb502
-rw-r--r--lib/sisu/current/ao_syntax.rb22
-rw-r--r--lib/sisu/current/cgi_sql_common.rb20
-rw-r--r--lib/sisu/current/constants.rb33
-rw-r--r--lib/sisu/current/db_drop.rb8
-rw-r--r--lib/sisu/current/db_sqltxt.rb24
-rw-r--r--lib/sisu/current/dp.rb49
-rw-r--r--lib/sisu/current/git.rb72
-rw-r--r--lib/sisu/current/html.rb19
-rw-r--r--lib/sisu/current/html_format.rb50
-rw-r--r--lib/sisu/current/html_harvest_authors.rb2
-rw-r--r--lib/sisu/current/html_harvest_topics.rb8
-rw-r--r--lib/sisu/current/html_lite_shared.rb3
-rw-r--r--lib/sisu/current/html_manifest.rb381
-rw-r--r--lib/sisu/current/html_minitoc.rb5
-rw-r--r--lib/sisu/current/html_parts.rb10
-rw-r--r--lib/sisu/current/html_persist.rb237
-rw-r--r--lib/sisu/current/html_segments.rb356
-rw-r--r--lib/sisu/current/html_tune.rb15
-rw-r--r--lib/sisu/current/hub.rb6
-rw-r--r--lib/sisu/current/hub_actions.rb192
-rw-r--r--lib/sisu/current/hub_loop_markup_files.rb3
-rw-r--r--lib/sisu/current/hub_options.rb81
-rw-r--r--lib/sisu/current/manpage.rb103
-rw-r--r--lib/sisu/current/object_munge.rb307
-rw-r--r--lib/sisu/current/se_clear.rb1
-rw-r--r--lib/sisu/current/se_file_op.rb116
-rw-r--r--lib/sisu/current/se_filemap.rb6
-rw-r--r--lib/sisu/current/se_get_init.rb44
-rw-r--r--lib/sisu/current/se_info_env.rb14
-rw-r--r--lib/sisu/current/se_programs.rb10
-rw-r--r--lib/sisu/current/se_version.rb54
-rw-r--r--lib/sisu/current/shared_markup_alt.rb3
-rw-r--r--lib/sisu/current/shared_metadata.rb40
-rw-r--r--lib/sisu/current/src_po4a_share.rb309
-rw-r--r--lib/sisu/current/src_po4a_shelf.rb (renamed from lib/sisu/current/po4a.rb)947
-rw-r--r--lib/sisu/current/src_po4a_shelf_set.rb (renamed from lib/sisu/current/po4a_set.rb)10
-rw-r--r--lib/sisu/current/src_po4a_sst_ao_sst.rb893
-rw-r--r--lib/sisu/current/src_po4a_sst_ao_sst_set.rb284
-rw-r--r--lib/sisu/current/src_po4a_sstm.rb135
-rw-r--r--lib/sisu/current/src_shared.rb102
-rw-r--r--lib/sisu/current/src_sisupod_sstm.rb (renamed from lib/sisu/current/src_share.rb)4
-rw-r--r--lib/sisu/current/sst_convert_markup.rb5
-rw-r--r--lib/sisu/current/sst_from_xml.rb2
-rw-r--r--lib/sisu/current/sst_to_s_xml_sax.rb2
-rw-r--r--lib/sisu/current/texinfo_format.rb2
-rw-r--r--lib/sisu/current/texpdf_format.rb8
-rw-r--r--lib/sisu/current/txt_asciidoc.rb239
-rw-r--r--lib/sisu/current/txt_asciidoc_decorate.rb207
-rw-r--r--lib/sisu/current/txt_markdown.rb242
-rw-r--r--lib/sisu/current/txt_markdown_decorate.rb207
-rw-r--r--lib/sisu/current/txt_orgmode.rb376
-rw-r--r--lib/sisu/current/txt_orgmode_decorate.rb186
-rw-r--r--lib/sisu/current/txt_output.rb86
-rw-r--r--lib/sisu/current/txt_plain.rb243
-rw-r--r--lib/sisu/current/txt_plain_decorate.rb189
-rw-r--r--lib/sisu/current/txt_read.rb109
-rw-r--r--lib/sisu/current/txt_rst.rb218
-rw-r--r--lib/sisu/current/txt_rst_decorate.rb186
-rw-r--r--lib/sisu/current/txt_textile.rb240
-rw-r--r--lib/sisu/current/txt_textile_decorate.rb186
-rw-r--r--lib/sisu/current/urls.rb31
-rw-r--r--lib/sisu/current/utils_composite.rb115
-rw-r--r--lib/sisu/current/utils_response.rb25
-rw-r--r--lib/sisu/current/wikispeak.rb4
-rw-r--r--lib/sisu/current/xhtml.rb120
-rw-r--r--lib/sisu/current/xhtml_epub2.rb478
-rw-r--r--lib/sisu/current/xhtml_epub2_format.rb7
-rw-r--r--lib/sisu/current/xhtml_epub2_persist.rb278
-rw-r--r--lib/sisu/current/xhtml_epub2_segments.rb351
-rw-r--r--lib/sisu/current/xhtml_parts.rb2
-rw-r--r--lib/sisu/current/xhtml_table.rb1
-rw-r--r--lib/sisu/current/xml_dom.rb134
-rw-r--r--lib/sisu/current/xml_fictionbook2.rb4
-rw-r--r--lib/sisu/current/xml_odf_odt.rb48
-rw-r--r--lib/sisu/current/xml_odf_odt_format.rb4
-rw-r--r--lib/sisu/current/xml_persist.rb126
-rw-r--r--lib/sisu/current/xml_sax.rb145
-rw-r--r--lib/sisu/current/xml_shared.rb2
92 files changed, 7978 insertions, 3161 deletions
diff --git a/lib/sisu/current/ao.rb b/lib/sisu/current/ao.rb
index 3467c4c..b7878db 100644
--- a/lib/sisu/current/ao.rb
+++ b/lib/sisu/current/ao.rb
@@ -64,6 +64,7 @@ module SiSU_AO
require_relative 'ao_syntax' # ao_syntax.rb
include SiSU_AO_Syntax
require_relative 'ao_doc_str' # ao_doc_str.rb
+ require_relative 'ao_references' # ao_references.rb
require_relative 'ao_idx' # ao_idx.rb
require_relative 'ao_numbering' # ao_numbering.rb
require_relative 'ao_hash_digest' # ao_hash_digest.rb
@@ -73,6 +74,7 @@ module SiSU_AO
require_relative 'ao_character_check' # ao_character_check.rb
require_relative 'ao_misc_arrange' # ao_misc_arrange.rb
require_relative 'ao_expand_insertions' # ao_expand_insertions.rb
+ require_relative 'ao_persist' # ao_persist.rb
require_relative 'prog_text_translation' # prog_text_translation.rb
require_relative 'shared_sem' # shared_sem.rb
class Instantiate < SiSU_Param::Parameters::Instructions
@@ -82,13 +84,10 @@ module SiSU_AO
end
end
class Source <Instantiate
- @@ao_array=[]
- @@idx_arr={ sst: [], tex: [], html: [], xhtml: [] }
- @@map_arr={ nametags: [], ocn_htmlseg: [] }
- @@fns=nil
def initialize(opt,fnx=nil,process=:complete)
@opt,@fnx,@process=opt,fnx,process
- @@fns ||=opt.fns
+ @per ||=SiSU_AO_Persist::Persist.new.persist_init
+ @per.fns ||=opt.fns
fn_use=if fnx \
and fnx =~/\.ss[tmi]$/
fnx
@@ -110,32 +109,34 @@ module SiSU_AO
end
def read #creates ao
begin
- @@ao_array=[]
- @@fns=(@fnx && @fnx =~/\.ss[tmi]$/) \
+ @per=SiSU_AO_Persist::Persist.new
+ @per.ao_arr=[]
+ @per.fns=(@fnx && @fnx =~/\.ss[tmi]$/) \
? @fnx
: @opt.fns
create_ao
rescue
- SiSU_Errors::Rescued.new($!,$@,@opt.selections,@@fns).location do
+ SiSU_Errors::Rescued.new($!,$@,@opt.selections,@per.fns).location do
__LINE__.to_s + ':' + __FILE__
end
ensure
+ SiSU_AO_Persist::Persist.new.persist_init
SiSU_AO::Instantiate.new
end
end
def get #reads ao, unless does not exist then creates first
begin
ao=[]
- unless @@fns==@opt.fns \
- or @@fns==@fnx
- @@fns=(@fnx && @fnx =~/\.ss[tmi]$/) \
+ unless @per.fns==@opt.fns \
+ or @per.fns==@fnx
+ @per.fns=(@fnx && @fnx =~/\.ss[tmi]$/) \
? @fnx
: @opt.fns
- @@ao_array=[]
+ @per.ao_arr=[]
end
- ao=(@@ao_array.empty?) \
+ ao=(@per.ao_arr.empty?) \
? read_fnc
- : @@ao_array.dup
+ : @per.ao_arr.dup
rescue
SiSU_Errors::Rescued.new($!,$@,@opt.selections,@opt.fns).location do
__LINE__.to_s + ':' + __FILE__
@@ -147,16 +148,16 @@ module SiSU_AO
def get_idx_sst #reads ao idx.sst, #unless does not exist then creates first
begin
ao=[]
- unless @@fns==@opt.fns \
- or @@fns==@fnx
- @@fns=(@fnx && @fnx =~/\.ss[tmi]$/) \
+ unless @per.fns==@opt.fns \
+ or @per.fns==@fnx
+ @per.fns=(@fnx && @fnx =~/\.ss[tmi]$/) \
? @fnx
: @opt.fns
- @@idx_arr[:sst]=[]
+ @per.idx_arr_sst=[]
end
- ao=(@@idx_arr[:sst].empty?) \
+ ao=(@per.idx_arr_sst.empty?) \
? read_idx_sst
- : @@idx_arr[:sst].dup #check
+ : @per.idx_arr_sst.dup #check
rescue
SiSU_Errors::Rescued.new($!,$@,@opt.selections,@opt.fns).location do
__LINE__.to_s + ':' + __FILE__
@@ -168,16 +169,16 @@ module SiSU_AO
def get_idx_raw
begin
ao=[]
- unless @@fns==@opt.fns \
- or @@fns==@fnx
- @@fns=(@fnx && @fnx =~/\.ss[tmi]$/) \
+ unless @per.fns==@opt.fns \
+ or @per.fns==@fnx
+ @per.fns=(@fnx && @fnx =~/\.ss[tmi]$/) \
? @fnx
: @opt.fns
- @@idx_arr[:tex]=[]
+ @per.idx_arr_tex=[]
end
- ao=(@@idx_arr[:tex].empty?) \
+ ao=(@per.idx_arr_tex.empty?) \
? read_idx_raw
- : @@idx_arr[:tex].dup #check
+ : @per.idx_arr_tex.dup #check
rescue
SiSU_Errors::Rescued.new($!,$@,@opt.selections,@opt.fns).location do
__LINE__.to_s + ':' + __FILE__
@@ -189,16 +190,16 @@ module SiSU_AO
def get_idx_html #reads ao idx.html, #unless does not exist then creates first
begin
ao=[]
- unless @@fns==@opt.fns \
- or @@fns==@fnx
- @@fns=(@fnx && @fnx =~/\.ss[tmi]$/) \
+ unless @per.fns==@opt.fns \
+ or @per.fns==@fnx
+ @per.fns=(@fnx && @fnx =~/\.ss[tmi]$/) \
? @fnx
: @opt.fns
- @@idx_arr[:html]=[]
+ @per.idx_arr_html=[]
end
- ao=(@@idx_arr[:html].empty?) \
+ ao=(@per.idx_arr_html.empty?) \
? read_idx_html
- : @@idx_arr[:html].dup
+ : @per.idx_arr_html.dup
rescue
SiSU_Errors::Rescued.new($!,$@,@opt.selections,@opt.fns).location do
__LINE__.to_s + ':' + __FILE__
@@ -210,16 +211,16 @@ module SiSU_AO
def get_idx_xhtml #reads ao idx.xhtml, #unless does not exist then creates first
begin
ao=[]
- unless @@fns==@opt.fns \
- or @@fns==@fnx
- @@fns=(@fnx && @fnx =~/\.ss[tmi]$/) \
+ unless @per.fns==@opt.fns \
+ or @per.fns==@fnx
+ @per.fns=(@fnx && @fnx =~/\.ss[tmi]$/) \
? @fnx
: @opt.fns
- @@idx_arr[:xthml]=[]
+ @per.idx_arr_xhtml=[] #...
end
- ao=(@@idx_arr[:xhtml].empty?) \
+ ao=(@per.idx_arr_xhtml.empty?) \
? read_idx_xhtml
- : @@idx_arr[:xhtml].dup
+ : @per.idx_arr_xhtml.dup
rescue
SiSU_Errors::Rescued.new($!,$@,@opt.selections,@opt.fns).location do
__LINE__.to_s + ':' + __FILE__
@@ -231,16 +232,16 @@ module SiSU_AO
def get_map_nametags #reads ao map.nametags, #unless does not exist then creates first
begin
ao=[]
- unless @@fns==@opt.fns \
- or @@fns==@fnx
- @@fns=(@fnx && @fnx =~/\.ss[tmi]$/) \
+ unless @per.fns==@opt.fns \
+ or @per.fns==@fnx
+ @per.fns=(@fnx && @fnx =~/\.ss[tmi]$/) \
? @fnx
: @opt.fns
- @@map_arr[:nametags]=[]
+ @per.map_arr_nametags=[]
end
- ao=(@@map_arr[:nametags].empty?) \
+ ao=(@per.map_arr_nametags.empty?) \
? read_map_nametags
- : @@map_arr[:nametags].dup
+ : @per.map_arr_nametags.dup
rescue
SiSU_Errors::Rescued.new($!,$@,@opt.selections,@opt.fns).location do
__LINE__.to_s + ':' + __FILE__
@@ -252,16 +253,16 @@ module SiSU_AO
def get_map_ocn_htmlseg #reads ao map.ocn_htmlseg, #unless does not exist then creates first
begin
ao=[]
- unless @@fns==@opt.fns \
- or @@fns==@fnx
- @@fns=(@fnx && @fnx =~/\.ss[tmi]$/) \
+ unless @per.fns==@opt.fns \
+ or @per.fns==@fnx
+ @per.fns=(@fnx && @fnx =~/\.ss[tmi]$/) \
? @fnx
: @opt.fns
- @@map_arr[:ocn_htmlseg]=[]
+ @per.map_arr_ocn_htmlseg=[]
end
- ao=(@@map_arr[:ocn_htmlseg].empty?) \
+ ao=(@per.map_arr_ocn_htmlseg.empty?) \
? read_map_ocn_htmlseg
- : @@map_arr[:ocn_htmlseg].dup
+ : @per.map_arr_ocn_htmlseg.dup
rescue
SiSU_Errors::Rescued.new($!,$@,@opt.selections,@opt.fns).location do
__LINE__.to_s + ':' + __FILE__
@@ -539,11 +540,12 @@ module SiSU_AO
SiSU_AO_MiscArrangeText::SI.new(@md,data_txt). # ao_misc_arrange.rb
prepare_text
data_obj,
- metadata=
+ metadata,
+ bibliography=
SiSU_AO_DocumentStructureExtract::Build.new(@md,data_txt). # ao_doc_str.rb
identify_parts
data_obj=
- SiSU_AO_Syntax::Markup.new(@md,data_obj).songsheet # ao_syntax.rb
+ SiSU_AO_Syntax::Markup.new(@md,data_obj,bibliography).songsheet # ao_syntax.rb
data_obj,
endnote_array=
SiSU_AO_CharacterCheck::Check.new(data_obj). # ao_character_check.rb
diff --git a/lib/sisu/current/ao_character_check.rb b/lib/sisu/current/ao_character_check.rb
index faee592..9d91baa 100644
--- a/lib/sisu/current/ao_character_check.rb
+++ b/lib/sisu/current/ao_character_check.rb
@@ -63,9 +63,9 @@ module SiSU_AO_CharacterCheck
end
def character_check_and_oldstyle_endnote_array
data=@data
- @tuned_file,@endnote_array=[],[]
+ @endnote_array=[]
endnote_no=1
- data.each do |dob|
+ @tuned_file=data.select do |dob|
unless dob.is ==:table
dob.obj=dob.obj.strip.
gsub(/^[{~}]\s*$/,'').
@@ -93,9 +93,8 @@ module SiSU_AO_CharacterCheck
end
end
end
- @tuned_file << dob if dob.is_a?(Object)
- end
- @tuned_file=@tuned_file.flatten.compact
+ dob if dob.is_a?(Object)
+ end.flatten.compact
[@tuned_file,@endnote_array]
end
end
diff --git a/lib/sisu/current/ao_composite.rb b/lib/sisu/current/ao_composite.rb
index 611dd70..24683cb 100644
--- a/lib/sisu/current/ao_composite.rb
+++ b/lib/sisu/current/ao_composite.rb
@@ -57,6 +57,7 @@
=end
module SiSU_Assemble
require_relative 'se' # se.rb
+ require_relative 'utils_composite' # utils_composite.rb
class RemoteImage
def initialize
@env=SiSU_Env::InfoEnv.new
@@ -86,7 +87,7 @@ module SiSU_Assemble
end
end
class Composite
- @@imager={}
+ include SiSU_Composite_Doc_Utils # composite doc, .ssm, extract all related insert files, array of filenames test
def initialize(opt)
@opt=opt
@env=SiSU_Env::InfoEnv.new
@@ -101,14 +102,14 @@ module SiSU_Assemble
'Composite Document',
"[#{@opt.f_pth[:lng_is]}] #{@opt.fno}",
).grey_title_hi unless @opt.act[:quiet][:set]==:on
+ composite_and_imported_filenames_array(@opt.fno) # composite doc, .ssm, extract all related insert files, array of filenames test
assembled=loadfile(@opt.fno)
- #assembled=insertions?(fns_array)
- write(assembled)
write(assembled)
end
Dir.chdir(pwd)
rescue
- SiSU_Errors::Rescued.new($!,$@,@opt.selections.str,@opt.fns).location do
+ SiSU_Errors::Rescued.new($!,$@,@opt.selections.str,@opt.fns).
+ location do
__LINE__.to_s + ':' + __FILE__
end
ensure
@@ -126,7 +127,6 @@ module SiSU_Assemble
end
end
def loadfile(loadfilename)
- tuned_file=[]
begin
if FileTest.file?(loadfilename)
insert_array=IO.readlines(loadfilename,'')
@@ -140,18 +140,17 @@ module SiSU_Assemble
loadfilename,
).txt_grey
end
- if loadfilename =~/\S+?\.ss[im]$/
- insert_array.each do |para|
- tuned_file << insert?(para)
+ tuned_file=if loadfilename =~/\S+?\.ss[im]$/
+ insert_array.each.map do |para|
+ insert?(para)
end
elsif loadfilename =~/\S+?\.sst$/
- insert_array.each do |para|
- tuned_file << para
+ insert_array.each.map do |para|
+ para
end
- end
+ end.flatten.compact
end
end
- tuned_file=tuned_file.flatten.compact
rescue
SiSU_Errors::Rescued.new($!,$@,@opt.selections.str,@opt.fns).location do
__LINE__.to_s + ':' + __FILE__
@@ -162,9 +161,6 @@ module SiSU_Assemble
def url(loadfilename)
if loadfilename =~ /((?:https?|file):\/\/\S+?\.ss[it])$/ # and NetTest
loadfilename=$1
- imagedir = /((?:https?|file):\/\/\S+?)\/[^\/]+?\.ss[it]$/.
- match(loadfilename).captures.join +
- '/_sisu/image' #watch
begin
require 'uri'
require 'open-uri'
@@ -173,13 +169,10 @@ module SiSU_Assemble
SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).
error('uri, open-uri or pp NOT FOUND (LoadError)')
end
- image_uri=URI.parse(imagedir)
insert=open(loadfilename)
insert_array=insert.dup
insert.close
file=insertion(loadfilename,insert_array)
- @@imager[image_uri] ||=[]
- @@imager[image_uri] << file[:images]
file[:prepared]
end
end
@@ -238,7 +231,6 @@ module SiSU_Assemble
end
end
class CompositeFileList
- @@imager={}
def initialize(opt)
@opt=opt
@env=SiSU_Env::InfoEnv.new
diff --git a/lib/sisu/current/ao_doc_objects.rb b/lib/sisu/current/ao_doc_objects.rb
index ac528b9..a4b2fa8 100644
--- a/lib/sisu/current/ao_doc_objects.rb
+++ b/lib/sisu/current/ao_doc_objects.rb
@@ -495,6 +495,18 @@ module SiSU_AO_DocumentStructure
of,is, obj, flag, act, selections,tmp
self
end
+ def flag_lng(h,o=nil)
+ of= @of #Symbol, classification - group
+ is= :flag_lng
+ obj= nil #String, text content
+ flag= h[:flag] || ((defined? o.flag) ? o.flag : nil) #Symbol, :lng_on or :lng_off
+ act= h[:act] || ((defined? o.act) ? o.act : nil) #Symbol, language set to :en etc.
+ selections= h[:selections] || ((defined? o.selections) ? o.selections : nil) #String, text content
+ tmp= h[:act] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use
+ @of, @is,@obj,@flag,@act,@selections,@tmp=
+ of,is, obj, flag, act, selections,tmp
+ self
+ end
end
class ObjectLayout
attr_accessor :obj,:sym,:attr,:is,:is_for,:of,:from,:tmp,:num
diff --git a/lib/sisu/current/ao_doc_str.rb b/lib/sisu/current/ao_doc_str.rb
index 50916d1..fba1724 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
diff --git a/lib/sisu/current/ao_endnotes.rb b/lib/sisu/current/ao_endnotes.rb
index 7c9ae06..508d798 100644
--- a/lib/sisu/current/ao_endnotes.rb
+++ b/lib/sisu/current/ao_endnotes.rb
@@ -66,9 +66,8 @@ module SiSU_AO_Endnotes
end
def endnotes
data=@data
- @tuned_file=[]
endnote_ref=1
- data.each do |dob|
+ @tuned_file=data.each.map do |dob|
# manually numbered endnotes <!e(\d)!> <!e_(\d)!> -->
if @md.opt.selections.str =~/--no-asterisk|--no-annotate/
dob.obj=dob.obj.
@@ -89,20 +88,20 @@ module SiSU_AO_Endnotes
word_mode=endnote_call_number(word_mode)
dob.obj=word_mode.join(' ')
endnote_ref+=1
- when /~\^(?:\s|$)|<:e>/ #%note inserts endnotes previously gathered from /^(<!e[:_]!>|[-~]\{{3})/ (in earlier loop)
+ when /~\^(?:\s|$)/ #%note inserts endnotes previously gathered from /^(<!e[:_]!>|[-~]\{{3})/ (in earlier loop)
word_mode=dob.obj.scan(/\S+/m)
word_mode=endnote_call_number(word_mode)
dob.obj=word_mode.join(' ')
endnote_ref+=1
end
end
- @tuned_file << dob
- end
+ dob
+ end.flatten
@endnote_counter,
@endnote_counter_asterisk,
@endnote_counter_dag=
1,1,1
- @tuned_file=@tuned_file.flatten
+ @tuned_file
end
def endnote_call_number(words)
words.each do |word|
@@ -123,9 +122,9 @@ module SiSU_AO_Endnotes
"#{Mx[:en_b_o]}\*#{@endnote_counter_asterisk} ")
@endnote_counter_asterisk+=1
end
- when /~\^|<:e>/
+ when /~\^/
if @endnote_array
- word.gsub!(/~\^|<:e>/,
+ word.gsub!(/~\^/,
"#{@endnote_array[@endnote_counter-1]}")
@endnote_counter+=1
end
diff --git a/lib/sisu/current/ao_expand_insertions.rb b/lib/sisu/current/ao_expand_insertions.rb
index 3a749df..3d4ea8c 100644
--- a/lib/sisu/current/ao_expand_insertions.rb
+++ b/lib/sisu/current/ao_expand_insertions.rb
@@ -484,21 +484,19 @@ module SiSU_AO_Insertions
linked_title="#{m_pre}{#{m_txt} }#{lnk[:manifest]}#{m_note}\n\n"
tuned_file_tmp << linked_title
output_filetypes=output_filetypes_in_cmd(m_cmd,lnk)
- output_filetypes[:gen].each do |o_f|
- describe = o_f
- if describe
- tuned_file_tmp << if @u.remote #to double space <:br> at beginning of entry
- "#{Mx[:nbsp]*4} #{describe} "
+ output_filetypes[:gen].each do |desc|
+ if desc
+ tuned_file_tmp << if @u.remote
+ "#{Mx[:nbsp]*4} #{desc} "
else # remove ...
"[provide document placement host location]"
end
end
end
- output_filetypes[:src].each do |o_f|
- describe = o_f
- if describe
+ output_filetypes[:src].each do |desc|
+ if desc
tuned_file_tmp << if @u.remote
- "#{Mx[:nbsp]*4} #{describe} "
+ "#{Mx[:nbsp]*4} #{desc} "
else
"[provide document placement host location]"
end
diff --git a/lib/sisu/current/ao_hash_digest.rb b/lib/sisu/current/ao_hash_digest.rb
index bc86a48..0864989 100644
--- a/lib/sisu/current/ao_hash_digest.rb
+++ b/lib/sisu/current/ao_hash_digest.rb
@@ -103,9 +103,8 @@ module SiSU_AO_Hash
#use md5 or to create hash of each ao object including ocn, & add into to each ao object
end
def endnote_digest(data)
- t_o_bit=[]
- data.each do |en_plus|
- t_o_bit <<= case en_plus
+ data.each.map do |en_plus|
+ case en_plus
when /#{Mx[:en_a_o]}|#{Mx[:en_b_o]}/
if en_plus =~/#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]}/
t_o_txt,en_open,en_txt,en_close=
@@ -133,8 +132,7 @@ module SiSU_AO_Hash
end
else en_plus
end
- end
- t_o_bit.join
+ end.join
end
def stamped(t_o,hash_class) #decide what hash information is most useful, is compromise necessary?
t_o.obj=SiSU_TextRepresentation::Alter.new(t_o).strip_clean_of_extra_spaces
diff --git a/lib/sisu/current/ao_idx.rb b/lib/sisu/current/ao_idx.rb
index 0c9c8a4..defad2c 100644
--- a/lib/sisu/current/ao_idx.rb
+++ b/lib/sisu/current/ao_idx.rb
@@ -61,8 +61,6 @@ module SiSU_AO_BookIndex
@rgx_idx=/#{Mx[:idx_o]}(?:.+?)#{Mx[:idx_c]}\s*/
@rgx_idx_ocn_seg=/(.+?)~(\d+)~(\S+)/
@rgx_idx_ocn=/(.+?)~(\d+)/
- @ocn_html_identifier=
- SiSU_Env::ProcessingSettings.new(@md).ocn_html_identifier
@env ||=SiSU_Env::InfoEnv.new(@md.fns)
end
def indexing_song
@@ -261,13 +259,13 @@ module SiSU_AO_BookIndex
if a[:range]
idx[:sst_rel_html_seg][@o]=
idx[:sst_rel_html_seg][@o] +
- %{#{Mx[:lnk_o]}#{a[:range]}#{Mx[:lnk_c]}#{Mx[:rel_o]}/#{a[:seg]}.html##{@ocn_html_identifier}#{a[:ocn]}#{Mx[:rel_c]}, }
+ %{#{Mx[:lnk_o]}#{a[:range]}#{Mx[:lnk_c]}#{Mx[:rel_o]}/#{a[:seg]}.html##{a[:ocn]}#{Mx[:rel_c]}, }
idx[:sst_rel][@t]=
idx[:sst_rel][@t] +
%{#{Mx[:lnk_o]}#{a[:range]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{a[:ocn]}#{Mx[:rel_c]}, }
idx[:html][@q]=
idx[:html][@q] +
- %{<a href="#{a[:seg]}.html##{@ocn_html_identifier}#{a[:ocn]}">#{a[:range]}</a>, }
+ %{<a href="#{a[:seg]}.html##{a[:ocn]}">#{a[:range]}</a>, }
idx[:xhtml][@q]=
idx[:xhtml][@q] +
%{<a href="#{a[:seg]}.xhtml#o#{a[:ocn]}">#{a[:range]}</a>, }
@@ -275,13 +273,13 @@ module SiSU_AO_BookIndex
elsif a[:ocn]
idx[:sst_rel_html_seg][@o]=
idx[:sst_rel_html_seg][@o] +
- %{#{Mx[:lnk_o]}#{a[:ocn]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{a[:seg]}.html##{@ocn_html_identifier}#{a[:ocn]}#{Mx[:rel_c]}, }
+ %{#{Mx[:lnk_o]}#{a[:ocn]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{a[:seg]}.html##{a[:ocn]}#{Mx[:rel_c]}, }
idx[:sst_rel][@t]=
idx[:sst_rel][@t] +
%{#{Mx[:lnk_o]}#{a[:ocn]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{a[:ocn]}#{Mx[:rel_c]}, }
idx[:html][@q]=
idx[:html][@q] +
- %{<a href="#{a[:seg]}.html##{@ocn_html_identifier}#{a[:ocn]}">#{a[:ocn]}</a>, }
+ %{<a href="#{a[:seg]}.html##{a[:ocn]}">#{a[:ocn]}</a>, }
idx[:xhtml][@q]=
idx[:xhtml][@q] +
%{<a href="#{a[:seg]}.xhtml#o#{a[:ocn]}">#{a[:ocn]}</a>, }
@@ -313,13 +311,13 @@ module SiSU_AO_BookIndex
if z[:range]
idx[:sst_rel_html_seg][@o]=
idx[:sst_rel_html_seg][@o] +
- %{#{Mx[:lnk_o]}#{z[:range]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{z[:seg]}.html##{@ocn_html_identifier}#{z[:ocn]}#{Mx[:rel_c]}, }
+ %{#{Mx[:lnk_o]}#{z[:range]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{z[:seg]}.html##{z[:ocn]}#{Mx[:rel_c]}, }
idx[:sst_rel][@t]=
idx[:sst_rel][@t] +
%{#{Mx[:lnk_o]}#{z[:range]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{z[:ocn]}#{Mx[:rel_c]}, }
idx[:html][@q]=
idx[:html][@q] +
- %{<a href="#{z[:seg]}.html##{@ocn_html_identifier}#{z[:ocn]}">#{z[:range]}</a>, }
+ %{<a href="#{z[:seg]}.html##{z[:ocn]}">#{z[:range]}</a>, }
idx[:xhtml][@q]=
idx[:xhtml][@q] +
%{<a href="#{z[:seg]}.xhtml#o#{z[:ocn]}">#{z[:range]}</a>, }
@@ -327,13 +325,13 @@ module SiSU_AO_BookIndex
elsif z[:ocn]
idx[:sst_rel_html_seg][@o]=
idx[:sst_rel_html_seg][@o] +
- %{#{Mx[:lnk_o]}#{z[:ocn]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{z[:seg]}.html##{@ocn_html_identifier}#{z[:ocn]}#{Mx[:rel_c]}, }
+ %{#{Mx[:lnk_o]}#{z[:ocn]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{z[:seg]}.html##{z[:ocn]}#{Mx[:rel_c]}, }
idx[:sst_rel][@t]=
idx[:sst_rel][@t] +
%{#{Mx[:lnk_o]}#{z[:ocn]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{z[:ocn]}#{Mx[:rel_c]}, }
idx[:html][@q]=
idx[:html][@q] +
- %{<a href="#{z[:seg]}.html##{@ocn_html_identifier}#{z[:ocn]}">#{z[:ocn]}</a>, }
+ %{<a href="#{z[:seg]}.html##{z[:ocn]}">#{z[:ocn]}</a>, }
idx[:xhtml][@q]=
idx[:xhtml][@q] +
%{<a href="#{z[:seg]}.xhtml#o#{z[:ocn]}">#{z[:ocn]}</a>, }
@@ -415,12 +413,9 @@ module SiSU_AO_BookIndex
tuned_file
end
def clean_index(data) #check on use of dob
- tuned_file=[]
- data.each do |para|
- para=para.gsub(/\n*#{@rgx_idx}/m,'')
- tuned_file << para
+ data.each.map do |para|
+ para.gsub(/\n*#{@rgx_idx}/m,'')
end
- tuned_file
end
end
end
diff --git a/lib/sisu/current/ao_images.rb b/lib/sisu/current/ao_images.rb
index c0c4571..38fde81 100644
--- a/lib/sisu/current/ao_images.rb
+++ b/lib/sisu/current/ao_images.rb
@@ -67,7 +67,6 @@ module SiSU_AO_Images
end
def images
data=@data
- tuned_file=[]
@rmgk=false
imagemagick_=true #imagemagick_=SiSU_Env::InfoSettings.new.program?('rmagick')
if imagemagick_
@@ -85,7 +84,7 @@ module SiSU_AO_Images
).warn
end
end
- data.each do |dob|
+ data.select do |dob|
unless dob.is ==:table
dob.obj=dob.obj.strip
if dob.obj =~/#{Mx[:lnk_o]}\s*\S+\.(?:png|jpg|gif)(?:\s*|\s+.+)?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/
@@ -179,9 +178,8 @@ module SiSU_AO_Images
dob.obj=dob.obj.gsub(/(#{Mx[:lnk_o]})\s*(\S+\.(?:png|jpg|gif))\s+/i,'\1\2 ')
end
end
- tuned_file << dob unless dob.nil?
+ dob unless dob.nil?
end
- tuned_file
end
end
end
diff --git a/lib/sisu/current/ao_misc_arrange.rb b/lib/sisu/current/ao_misc_arrange.rb
index e010eac..d023c44 100644
--- a/lib/sisu/current/ao_misc_arrange.rb
+++ b/lib/sisu/current/ao_misc_arrange.rb
@@ -189,7 +189,6 @@ module SiSU_AO_MiscArrangeText
end
def prepare_text
data=@data
- data_new=[],[]
if data[0] =~ /^#!\s*(?:\/usr\/bin\/env sisu|\/usr\/bin\/sisu)/ # remove bang from top #! (however file is stripped, so will be removed provided no content precedes it)
data[0]=data[0].gsub(/^#!\s*\/usr\/bin\/sisu/,'').
gsub(/^#!\s*\/usr\/bin\/env sisu/,'')
@@ -198,11 +197,10 @@ module SiSU_AO_MiscArrangeText
data[0]=data[0].gsub(/^(SiSU\s*[\d.]*)$/,'% \1').
gsub(/^(sisu-[\d.]+)$/,'% \1')
end
- data.each do |para|
+ data.each.map do |para|
para=conditional_headings(para)
- data_new << markup_blocks(para)
- end
- data_new=data_new.flatten
+ markup_blocks(para)
+ end.flatten
end
end
end
diff --git a/lib/sisu/current/ao_numbering.rb b/lib/sisu/current/ao_numbering.rb
index 31986a8..861bbf0 100644
--- a/lib/sisu/current/ao_numbering.rb
+++ b/lib/sisu/current/ao_numbering.rb
@@ -172,7 +172,6 @@ module SiSU_AO_Numbering
gsub(/#{Mx[:gl_bullet]}/,'')
end
def auto_number_heading_ie_title(data) #also does some segment naming
- @tuned_file=[]
if defined? @md.make.num_top \
and @md.make.num_top \
and @md.make.num_top !~/^$/
@@ -185,7 +184,7 @@ module SiSU_AO_Numbering
end
chapter_number_counter=0
data=data.compact
- data.each do |dob| #@md.seg_names << [additions to segment names]
+ @tuned_file=data.each.map do |dob| #@md.seg_names << [additions to segment names]
title_no=nil
if dob.is ==:heading \
&& dob.autonum_ \
@@ -274,9 +273,8 @@ module SiSU_AO_Numbering
dob.tags=set_tags(dob.tags,dob.name)
end
dob.tags=dob.tags.uniq if defined? dob.tags
- @tuned_file << dob
- end
- @tuned_file=@tuned_file.flatten
+ dob
+ end.flatten
end
def ocn(data) #and auto segment numbering increment
@tuned_file=SiSU_AO_DocumentStructureExtract::OCN.new(@md,data,@fnx,@process).ocn
@@ -287,10 +285,9 @@ module SiSU_AO_Numbering
@tuned_file
end
def minor_numbering(data) #and auto segment numbering increment
- @tuned_file=[]
number_small,letter_small=0,0
letter=%w( a b c d e f g h i j k l m n o p q r s t u v w x y z )
- data.each do |dob|
+ @tuned_file=data.each.map do |dob|
if dob.of ==:heading \
|| dob.of ==:heading_insert \
|| dob.of ==:para \
@@ -313,9 +310,8 @@ module SiSU_AO_Numbering
end
end
end
- @tuned_file << dob
- end
- @tuned_file=@tuned_file.flatten
+ dob
+ end.flatten
end
def leading_zeros_fixed_width_number(possible_seg_name)
if possible_seg_name.to_s =~/^([0-9]+?\.|[0-9]+)$/m #!~/[.,:-]+/
diff --git a/lib/sisu/current/ao_persist.rb b/lib/sisu/current/ao_persist.rb
new file mode 100644
index 0000000..72126c9
--- /dev/null
+++ b/lib/sisu/current/ao_persist.rb
@@ -0,0 +1,194 @@
+# encoding: utf-8
+=begin
+
+* Name: SiSU
+
+** Description: documents, structuring, processing, publishing, search
+*** document abstraction
+
+** Author: Ralph Amissah
+ <ralph@amissah.com>
+ <ralph.amissah@gmail.com>
+
+** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
+ 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah,
+ All Rights Reserved.
+
+** License: GPL 3 or later:
+
+ SiSU, a framework for document structuring, publishing and search
+
+ Copyright (C) Ralph Amissah
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the Free
+ Software Foundation, either version 3 of the License, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ more details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program. If not, see <http://www.gnu.org/licenses/>.
+
+ If you have Internet connection, the latest version of the GPL should be
+ available at these locations:
+ <http://www.fsf.org/licensing/licenses/gpl.html>
+ <http://www.gnu.org/licenses/gpl.html>
+
+ <http://www.sisudoc.org/sisu/en/manifest/gpl.fsf.html>
+
+** SiSU uses:
+ * Standard SiSU markup syntax,
+ * Standard SiSU meta-markup syntax, and the
+ * Standard SiSU object citation numbering and system
+
+** Hompages:
+ <http://www.jus.uio.no/sisu>
+ <http://www.sisudoc.org>
+
+** Git
+ <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=summary>
+ <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=blob;f=lib/sisu/current/ao_persist.rb;hb=HEAD>
+
+=end
+module SiSU_AO_Persist
+ class Persist
+ @@persistance=nil
+ attr_accessor :fns, :ao_arr, :idx_arr_sst, :idx_arr_tex, :idx_arr_html, :idx_arr_xhtml, :map_arr_nametags, :map_arr_ocn_htmlseg
+ def initialize(args=nil)
+ @@persistance=args=(args ? args : (@@persistance || persist_init_hash_values))
+ @fns=args[:fns]
+ @ao_arr=args[:ao_arr]
+ @idx_arr_sst=args[:idx_arr_sst]
+ @idx_arr_tex=args[:idx_arr_tex]
+ @idx_arr_html=args[:idx_arr_html]
+ @idx_arr_xhtml=args[:idx_arr_xhtml]
+ @map_arr_nametags=args[:map_arr_nametags]
+ @map_arr_ocn_htmlseg=args[:map_arr_ocn_htmlseg]
+ end
+ def fns
+ @fns
+ end
+ def ao_arr
+ @ao_arr
+ end
+ def idx_arr_sst
+ @idx_arr_sst
+ end
+ def idx_arr_tex
+ @idx_arr_tex
+ end
+ def idx_arr_html
+ @idx_arr_html
+ end
+ def idx_arr_xhtml
+ @idx_arr_xhtml
+ end
+ def map_arr_nametags
+ @map_arr_nametags
+ end
+ def map_arr_ocn_htmlseg
+ @map_arr_ocn_htmlseg
+ end
+ def persist_init_hash_values
+ {
+ fns: nil,
+ ao_arr: [],
+ idx_arr_sst: [],
+ idx_arr_tex: [],
+ idx_arr_html: [],
+ idx_arr_xhtml: [],
+ map_arr_nametags: [],
+ map_arr_ocn_htmlseg: [],
+ }
+ end
+ def persist_init
+ @@persistance=nil
+ Persist.new(persist_init_hash_values)
+ end
+ end
+ class PersistDocStructExt
+ @@persist=nil
+ attr_accessor :ocn, :lng, :lng_is, :code, :lngsyn, :poem, :block, :box, :group, :alt, :quote, :table, :table_to
+ def initialize(args=nil)
+ @@persist=args=(args ? args : (@@persist || persist_init_hash_values))
+ @ocn=args[:ocn]
+ @lng=args[:lng]
+ @lng_is=args[:lng_is]
+ @code=args[:code]
+ @lngsyn=args[:lngsyn]
+ @poem=args[:poem]
+ @block=args[:block]
+ @box=args[:box]
+ @group=args[:group]
+ @alt=args[:alt]
+ @quote=args[:quote]
+ @table=args[:table]
+ @table_to=args[:table_to]
+ end
+ def ocn
+ @ocn
+ end
+ def lng
+ @lng
+ end
+ def lng_is
+ @lng_is
+ end
+ def code
+ @code
+ end
+ def lngsyn
+ @lngsyn
+ end
+ def poem
+ @poem
+ end
+ def block
+ @block
+ end
+ def box
+ @box
+ end
+ def group
+ @group
+ end
+ def alt
+ @alt
+ end
+ def quote
+ @quote
+ end
+ def table
+ @table
+ end
+ def table_to
+ @table_to
+ end
+ def persist_init_hash_values
+ {
+ ocn: :on,
+ lng: :off,
+ lng_is: :doc_default,
+ code: :off,
+ lngsyn: :txt,
+ poem: :off,
+ block: :off,
+ box: :off,
+ group: :off,
+ alt: :off,
+ quote: :off,
+ table: :off,
+ table_to: :off,
+ }
+ end
+ def persist_init
+ @@persist=nil
+ PersistDocStructExt.new(persist_init_hash_values)
+ end
+ end
+end
+__END__
diff --git a/lib/sisu/current/ao_references.rb b/lib/sisu/current/ao_references.rb
new file mode 100644
index 0000000..9a5e195
--- /dev/null
+++ b/lib/sisu/current/ao_references.rb
@@ -0,0 +1,502 @@
+# encoding: utf-8
+=begin
+
+* Name: SiSU
+
+** Description: documents, structuring, processing, publishing, search
+*** system environment, resource control and configuration details
+
+** Author: Ralph Amissah
+ <ralph@amissah.com>
+ <ralph.amissah@gmail.com>
+
+** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
+ 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah,
+ All Rights Reserved.
+
+** License: GPL 3 or later:
+
+ SiSU, a framework for document structuring, publishing and search
+
+ Copyright (C) Ralph Amissah
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the Free
+ Software Foundation, either version 3 of the License, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ more details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program. If not, see <http://www.gnu.org/licenses/>.
+
+ If you have Internet connection, the latest version of the GPL should be
+ available at these locations:
+ <http://www.fsf.org/licensing/licenses/gpl.html>
+ <http://www.gnu.org/licenses/gpl.html>
+
+ <http://www.sisudoc.org/sisu/en/manifest/gpl.fsf.html>
+
+** SiSU uses:
+ * Standard SiSU markup syntax,
+ * Standard SiSU meta-markup syntax, and the
+ * Standard SiSU object citation numbering and system
+
+** Hompages:
+ <http://www.jus.uio.no/sisu>
+ <http://www.sisudoc.org>
+
+** Git
+ <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=summary>
+ <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=blob;f=lib/sisu/current/ao_references.rb;hb=HEAD>
+
+=end
+module SiSU_AO_References
+ class Bibliography
+ def initialize(md,data)
+ @md,@data=md,data
+ end
+ def sort_bibliography_array_by_author_year_title(bib)
+ if bib
+ bib.compact.sort_by do |c|
+ [c[:author_arr][0],c[:year],c[:title]]
+ end
+ end
+ end
+ def citation_in_prepared_bibliography(cite)
+ @cite=cite
+ def article
+ {
+ is: :article,
+ author_raw: nil,
+ author: nil,
+ author_arr: nil,
+ title: nil,
+ language: nil,
+ journal: nil,
+ volume: nil,
+ editor: nil,
+ year: nil,
+ where: nil,
+ url: nil,
+ note: nil,
+ short_name: nil,
+ id: nil,
+ }
+ end
+ def book
+ {
+ is: :book,
+ author_raw: nil,
+ author: nil,
+ author_arr: nil,
+ #editor: nil,
+ title: nil,
+ subtitle: nil,
+ fulltitle: nil,
+ language: nil,
+ publisher: nil,
+ edition: nil,
+ year: nil,
+ where: nil,
+ url: nil,
+ note: nil,
+ short_name: nil,
+ id: nil,
+ }
+ end
+ def citation_metadata
+ type=if @cite =~/^jo: \S+/m
+ :article
+ elsif @cite =~/^au: \S+/m
+ :book
+ end
+ if type
+ citeblock=@cite.split("\n")
+ if type == :article
+ citation=article
+ citeblock.select do |meta|
+ case meta
+ when /^((?:au|author):\s+)\S+/ #req
+ citation[:author_raw]=/^#{$1}(.+)/.match(meta)[1]
+ when /^((?:ti|title):\s+)\S+/ #req
+ citation[:title]=/^#{$1}(.+)/.match(meta)[1]
+ when /^((?:lng|language):\s+)\S+/
+ citation[:language]=/^#{$1}(.+)/.match(meta)[1]
+ when /^((?:jo|journal):\s+)\S+/ #req?
+ citation[:journal]=/^#{$1}(.+)/.match(meta)[1]
+ when /^((?:vo|volume):\s+)\S+/
+ citation[:volume]=/^#{$1}(.+)/.match(meta)[1]
+ when /^((?:edr|editor):\s+)\S+/
+ citation[:editor]=/^#{$1}(.+)/.match(meta)[1]
+ when /^((?:yr|year):\s+)\S+/ #req?
+ citation[:year]=/^#{$1}(.+)/.match(meta)[1]
+ when /^((?:pst|publisher_state):\s+)\S+/
+ citation[:where]=/^#{$1}(.+)/.match(meta)[1]
+ when /^(url:\s+)\S+/
+ citation[:url]=/^#{$1}(.+)/.match(meta)[1]
+ when /^(note:\s+)\S+/
+ citation[:note]=/^#{$1}(.+)/.match(meta)[1]
+ when /^((?:sn|shortname):\s+)\S+/
+ citation[:short_name]=/^#{$1}(.+)/.match(meta)[1]
+ when /^(id:\s+)\S+/
+ citation[:id]=/^#{$1}(.+)/.match(meta)[1]
+ end
+ end
+ end
+ if type == :book
+ citation=book
+ citeblock.select do |meta|
+ case meta
+ when /^((?:au|author):\s+)\S+/ #req
+ citation[:author_raw]=/^#{$1}(.+)/.match(meta)[1]
+ when /^((?:ti|title):\s+)\S+/ #req
+ citation[:title]=/^#{$1}(.+)/.match(meta)[1]
+ when /^((?:st|subtitle):\s+)\S+/
+ citation[:subtitle]=/^#{$1}(.+)/.match(meta)[1]
+ when /^((?:lng|language):\s+)\S+/
+ citation[:language]=/^#{$1}(.+)/.match(meta)[1]
+ when /^((?:pb|publisher):\s+)\S+/
+ citation[:publisher]=/^#{$1}(.+)/.match(meta)[1]
+ when /^((?:edn|edition):\s+)\S+/
+ citation[:edition]=/^#{$1}(.+)/.match(meta)[1]
+ when /^((?:yr|year):\s+)\S+/ #req?
+ citation[:year]=/^#{$1}(.+)/.match(meta)[1]
+ when /^((?:pst|publisher_state):\s+)\S+/
+ citation[:where]=/^#{$1}(.+)/.match(meta)[1]
+ when /^(url:\s+)\S+/
+ citation[:url]=/^#{$1}(.+)/.match(meta)[1]
+ when /^(note:\s+)\S+/
+ citation[:note]=/^#{$1}(.+)/.match(meta)[1]
+ when /^((?:sn|shortname):\s+)\S+/
+ citation[:short_name]=/^#{$1}(.+)/.match(meta)[1]
+ when /^(id:\s+)\S+/
+ citation[:id]=/^#{$1}(.+)/.match(meta)[1]
+ end
+ end
+ end
+ if citation[:is]==:book
+ if citation[:subtitle]
+ citation[:fulltitle] = citation[:title] \
+ + ' - ' \
+ + citation[:subtitle]
+ else
+ citation[:fulltitle] = citation[:title]
+ end
+ end
+ citation[:author_arr]=citation[:author_raw].split(/;\s*/)
+ citation[:author]=citation[:author_arr].map do |author|
+ author.gsub(/(.+?),\s+(.+)/,'\2 \1').strip
+ end.join(', ').strip
+ unless citation[:short_name]
+ citation[:short_name]=%{#{c[:author]}, "#{c[:short_name]}" (#{c[:date]})}
+ end
+ end
+ citation
+ end
+ self
+ end
+ def biblio_extraction
+ bibliography=[]
+ biblioflag=false
+ code_flag=false
+ flag_code_curly=:not_code_curly
+ flag_code_tics=:not_code_tics
+ @data=@data.select do |t_o|
+ if t_o =~/^code\{/
+ flag_code_curly=:code_curly
+ elsif t_o =~/^\}code/
+ flag_code_curly=:not_code_curly
+ elsif t_o =~/^``` code/
+ flag_code_tics=:code_tics
+ elsif flag_code_tics ==:code_tics \
+ and t_o =~/^```/
+ flag_code_tics=:not_code_tics
+ end
+ code_flag=if flag_code_curly==:code_curly \
+ or flag_code_tics==:code_tics
+ true
+ else false
+ end
+ unless code_flag
+ if @md.flag_auto_biblio
+ if t_o =~/^1~biblio(?:graphy)?/
+ biblioflag = true
+ t_o
+ elsif t_o =~/^:?[B-D1]~/
+ biblioflag = false
+ t_o
+ elsif biblioflag
+ if t_o !~/\A%+ /
+ bibliography << citation_in_prepared_bibliography(t_o).citation_metadata
+ next
+ else
+ t_o
+ end
+ else t_o
+ end
+ elsif @md.flag_biblio
+ if t_o =~/^1~biblio(?:graphy)?/
+ biblioflag = true
+ next
+ elsif t_o =~/^:?[B-D]~/
+ next
+ elsif t_o =~/^:?[B-D1]~/
+ biblioflag = false
+ t_o
+ elsif biblioflag
+ if t_o !~/\A%+ /
+ bibliography << t_o
+ next
+ else
+ t_o
+ end
+ else t_o
+ end
+ else t_o
+ end
+ else t_o
+ end
+ end.compact
+ if @md.flag_auto_biblio \
+ and bibliography.length > 0
+ data_new=[]
+ bibliography=sort_bibliography_array_by_author_year_title(bibliography)
+ @data.select do |t_o|
+ if t_o =~/^1~biblio(?:graphy)?/
+ bibliography.each do |c|
+ if c[:is]==:book
+ <<-WOK
+
+!_ #{c[:author]}
+/{"#{c[:fulltitle]}"}/ #{c[:publisher]} (#{c[:year]})
+ WOK
+ elsif c[:is]==:article
+ <<-WOK
+
+!_ #{c[:author]}
+/{"#{c[:title]}"}/ #{c[:journal]} (#{c[:year]})
+ WOK
+ end
+ end
+ else data_new << t_o
+ end
+ end
+ @data=data_new
+ end
+ [@data,bibliography]
+ end
+ end
+ class Citations
+ def initialize(md='',data='')
+ @md,@data=md,data
+ #@biblio=[]
+ end
+ def songsheet
+ tuned_file,citations=citations_scan(@data)
+ [tuned_file,citations]
+ end
+ def sort_bibliography_array_by_author_year(bib)
+ bib.sort_by do |c|
+ [c[:author_raw],c[:year]]
+ #[c[:author_arr][0],c[:year],c[:title]]
+ end
+ end
+ def citations_regex
+ def pages_pattern
+ %r{(?:[,.:]?\s+(?:p{1,2}\.?\s+)?(?:\d+--?\d+)[,.]?\s+)?}
+ end
+ def editor_pattern
+ %r{(?<editor>(?:editor|edited by)\s+.+?)}
+ end
+ def year_pattern
+ %r{[(\[]?(?<year>\d{4})[\])]?[.,]?}
+ end
+ def authors_year_title_publication_editor_pages
+ /(?<authors>.+?)\s+#{year_pattern}\s+"(?<title>.+?)"\s+(?:#{Mx[:fa_italics_o]}|#{Mx[:srcrgx_italics_o]})(?<publication>.+?)(?:#{Mx[:fa_italics_c]}|#{Mx[:srcrgx_italics_c]})\s+#{editor_pattern}#{pages_pattern}/m # note ed. is usually edition rather than editor
+ end
+ def authors_title_publication_year_editor_pages
+ /(?<authors>.+?)\s+"(?<title>.+?)"\s+(?:#{Mx[:fa_italics_o]}|#{Mx[:srcrgx_italics_o]})(?<publication>.+?)(?:#{Mx[:fa_italics_c]}|#{Mx[:srcrgx_italics_c]})\s+#{year_pattern}\s+#{editor_pattern}#{pages_pattern}/m # note ed. is usually edition rather than editor
+ end
+ def authors_title_publication_editor_year_pages ###
+ /(?<authors>.+?)\s+"(?<title>.+?)"\s+(?:#{Mx[:fa_italics_o]}|#{Mx[:srcrgx_italics_o]})(?<publication>.+?)(?:#{Mx[:fa_italics_c]}|#{Mx[:srcrgx_italics_c]})\s+ed.\s+#{editor_pattern}#{year_pattern}#{pages_pattern}/m
+ # note ed. is usually edition rather than editor
+ end
+ def authors_title_publication_editor_pages_year ###
+ /(?<authors>.+?)\s+"(?<title>.+?)"\s+(?:#{Mx[:fa_italics_o]}|#{Mx[:srcrgx_italics_o]})(?<publication>.+?)(?:#{Mx[:fa_italics_c]}|#{Mx[:srcrgx_italics_c]})\s+#{editor_pattern}#{pages_pattern}#{year_pattern}/m # note ed. is usually edition rather than editor
+ end
+ def authors_year_title_publication_pages
+ /(?<authors>.+?)\s+#{year_pattern}\s+"(?<title>.+?)"\s+(?:#{Mx[:fa_italics_o]}|#{Mx[:srcrgx_italics_o]})(?<publication>.+?)(?:#{Mx[:fa_italics_c]}|#{Mx[:srcrgx_italics_c]})[,.;]?#{pages_pattern}/m
+ end
+ def authors_title_publication_year_pages
+ /(?<authors>.+?)\s+"(?<title>.+?)"\s+(?:#{Mx[:fa_italics_o]}|#{Mx[:srcrgx_italics_o]})(?<publication>.+?)(?:#{Mx[:fa_italics_c]}|#{Mx[:srcrgx_italics_c]})\s+#{year_pattern}\s+#{pages_pattern}/m
+ end
+ def authors_title_publication_pages_year ###
+ /(?<authors>.+?)\s+"(?<title>.+?)"\s+(?:#{Mx[:fa_italics_o]}|#{Mx[:srcrgx_italics_o]})(?<publication>.+?)(?:#{Mx[:fa_italics_c]}|#{Mx[:srcrgx_italics_c]})#{pages_pattern}#{year_pattern}/m
+ end
+ def authors_year_publication_pages
+ /(?<authors>.+?)\s+#{year_pattern}\s+(?:#{Mx[:fa_italics_o]}|#{Mx[:srcrgx_italics_o]})(?<publication>.+?)(?:#{Mx[:fa_italics_c]}|#{Mx[:srcrgx_italics_c]})#{pages_pattern}/m
+ end
+ def authors_publication_year_pages
+ /(?<authors>.+?)\s+(?:#{Mx[:fa_italics_o]}|#{Mx[:srcrgx_italics_o]})(?<publication>.+?)(?:#{Mx[:fa_italics_c]}|#{Mx[:srcrgx_italics_c]})[,.;]?\s+(?<publisher>.+?)?#{year_pattern}#{pages_pattern}[.;]?/m
+ end
+ self
+ end
+ def authors?(citations)
+ citations.each.map do |b|
+ if b =~ /^.+\s+::.+?:$/
+ c=/^(?<citation>.+?)\s+::(?<shortref>.+?):$/.match(b)
+ {
+ citation: c[:citation],
+ shortref: c[:shortref],
+ c[:shortref].to_s => c[:citation]
+ }
+ else { citation: b }
+ end
+ end
+ end
+ def long_and_short_ref?(citations) #could be useful, keep ... ectract shortref
+ citations.each.map do |b|
+ if b =~ /^.+\s+::.+?:$/
+ c=/^(?<citation>.+?)\s+::(?<shortref>.+?):$/.match(b)
+ {
+ citation: c[:citation],
+ shortref: c[:shortref],
+ c[:shortref].to_s => c[:citation]
+ }
+ else { citation: b }
+ end
+ end
+ end
+ def citation_detail(citations) #could be useful, keep ... extract shortref
+ bibahash=[]
+ number=0
+ missed=0
+ citations.select do |b|
+ z=if b =~citations_regex.authors_year_title_publication_editor_pages
+ c=citations_regex.authors_year_title_publication_editor_pages.match(b)
+ {
+ is: :article,
+ author_raw: c[:authors],
+ year: c[:year],
+ title: c[:title],
+ publication: c[:publication],
+ editor: c[:editor],
+ }
+ elsif b =~citations_regex.authors_title_publication_year_editor_pages
+ c=citations_regex.authors_title_publication_year_editor_pages.match(b)
+ {
+ is: :article,
+ author_raw: c[:authors],
+ year: c[:year],
+ title: c[:title],
+ publication: c[:publication],
+ editor: c[:editor],
+ }
+ elsif b =~citations_regex.authors_title_publication_editor_year_pages
+ c=citations_regex.authors_title_publication_editor_year_pages.match(b)
+ {
+ is: :article,
+ author_raw: c[:authors],
+ year: c[:year],
+ title: c[:title],
+ publication: c[:publication],
+ editor: c[:editor],
+ }
+ elsif b =~citations_regex.authors_title_publication_editor_pages_year
+ c=citations_regex.authors_title_publication_editor_pages_year.match(b)
+ {
+ is: :article,
+ author_raw: c[:authors],
+ year: c[:year],
+ title: c[:title],
+ publication: c[:publication],
+ editor: c[:editor],
+ }
+ elsif b =~citations_regex.authors_year_title_publication_pages
+ c=citations_regex.authors_year_title_publication_pages.match(b)
+ {
+ is: :article,
+ author_raw: c[:authors],
+ year: c[:year],
+ title: c[:title],
+ publication: c[:publication],
+ }
+ elsif b =~citations_regex.authors_title_publication_year_pages
+ c=citations_regex.authors_title_publication_year_pages.match(b)
+ {
+ is: :article,
+ author_raw: c[:authors],
+ year: c[:year],
+ title: c[:title],
+ publication: c[:publication],
+ }
+ elsif b =~citations_regex.authors_year_publication_pages
+ c=citations_regex.authors_year_publication_pages.match(b)
+ {
+ is: :book,
+ author_raw: c[:authors],
+ year: c[:year],
+ publication: c[:publication],
+ }
+ elsif b =~citations_regex.authors_publication_year_pages
+ c=citations_regex.authors_publication_year_pages.match(b)
+ {
+ is: :book,
+ author_raw: c[:authors],
+ year: c[:year],
+ publication: c[:publication],
+ }
+ else b
+ end
+ if not z.is_a?(NilClass) \
+ and z.is_a?(Hash) \
+ and z[:author_raw].length > 0
+ z[:author_arr]=z[:author_raw].split(/;\s*/)
+ z[:author]=z[:author_arr].map do |author|
+ author.gsub(/(.+?),\s+(.+)/,'\2 \1').strip
+ end.join(', ').strip
+ if @md.opt.act[:verbose_plus][:set]==:on \
+ || @md.opt.act[:maintenance][:set]==:on
+ number +=1 if z.is_a?(Hash)
+ missed +=1 if z.is_a?(String)
+ (z.is_a?(Hash)) \
+ ? (p '[' + number.to_s + '] ' + z.to_s)
+ : (p '<' + missed.to_s + '> ' + z.to_s)
+ end
+ end
+ bibahash << z if z.is_a?(Hash)
+ end
+ bibahash=sort_bibliography_array_by_author_year(bibahash.compact)
+ bibahash
+ end
+ def citations_scan(data)
+ citations=[]
+ #short_ref=[]
+ tuned_file = data.compact.select do |dob|
+ if dob.is !=:meta \
+ && dob.is !=:comment \
+ && dob.is !=:code \
+ && dob.is !=:table
+ if dob.obj =~/\.:.+?:\./
+ citations << dob.obj.scan(/\.:\s*(.+?)\s*:\./m)
+ #short_ref << dob.obj.scan(/\.:\s+(.+?)\s+::([^:]+)::\./m) #look at later
+ ##short_ref << dob.obj.scan(/\.:\s+(.+?)\s+::(.+?)::\./m) #look at later
+ #short_ref << dob.obj.scan(/\.:\s*(.+?)\s*(::(.+?):)?:\./m) #look at later
+ citations=citations.flatten.compact
+ dob.obj=dob.obj. #remove citations delimiter & helpers from text
+ gsub(/\.:|:\./,'')
+ end
+ end
+ dob if dob.is_a?(Object)
+ end
+ #bib=long_and_short_ref?(citations) #could be useful, keep ... extract shortref
+ citations=citation_detail(citations)
+ [tuned_file,citations]
+ end
+ end
+end
+__END__
diff --git a/lib/sisu/current/ao_syntax.rb b/lib/sisu/current/ao_syntax.rb
index 554daae..c310866 100644
--- a/lib/sisu/current/ao_syntax.rb
+++ b/lib/sisu/current/ao_syntax.rb
@@ -61,8 +61,8 @@ module SiSU_AO_Syntax
end
end
class Markup
- def initialize(md='',data='')
- @md,@data=md,data
+ def initialize(md='',data='',biblio=[])
+ @md,@data,@bibliography=md,data,biblio
@data_new=[]
url_and_stub=SiSU_Env::InfoEnv.new.url
@output_url="#{url_and_stub.remote}"
@@ -221,6 +221,24 @@ module SiSU_AO_Syntax
end
def substitutions(dob)
dob=dob.dup
+ dob=if @md.flag_auto_biblio \
+ and @bibliography.length > 0
+ dob=if dob.is !=:meta \
+ && dob.is !=:heading_insert \
+ && dob.is !=:code \
+ && dob.is !=:comment \
+ && dob.is !=:table
+ @bibliography.each do |c|
+ if c[:id] and not c[:id].nil? and not c[:id].empty?
+ dob.obj=dob.obj.gsub(/#{c[:id]}/mi,c[:short_name])
+ end
+ end
+ dob
+ else dob
+ end
+ dob
+ else dob
+ end
dob=if defined? @md.substitution_match_list[:match_and_replace] \
and @md.substitution_match_list[:match_and_replace].is_a?(Array)
dob=if dob.is !=:meta \
diff --git a/lib/sisu/current/cgi_sql_common.rb b/lib/sisu/current/cgi_sql_common.rb
index 94f6126..62bec04 100644
--- a/lib/sisu/current/cgi_sql_common.rb
+++ b/lib/sisu/current/cgi_sql_common.rb
@@ -537,14 +537,14 @@ module SiSU_CGI_SQL
<!-- SiSU Rights -->
<p class="tiny_left"><font color="#666666" size="2">
Generated by
- #{v[:project]} #{v[:version]} #{v[:date]} (#{v[:date_stamp]})
+ #{v.project} #{v.version} #{v.date} (#{v.date_stamp})
<br>
<a href="http://www.sisudoc.org" >
- <b>#{v[:project]}</b></a> <sup>&copy;</sup> Ralph Amissah
+ <b>#{v.project}</b></a> <sup>&copy;</sup> Ralph Amissah
1993, current 2014.
All Rights Reserved.
<br>
- #{v[:project]} is software for document structuring, publishing and search,
+ #{v.project} is software for document structuring, publishing and search,
<br>
<a href="http://www.jus.uio.no/sisu" >
www.jus.uio.no/sisu
@@ -574,7 +574,7 @@ module SiSU_CGI_SQL
</font></p>
</td><td valign="top" width="45%">
<p class="tiny_left"><font color="#666666" size="2">
- #{v[:project]} using:
+ #{v.project} using:
<br>Standard SiSU markup syntax,
<br>Standard SiSU meta-markup syntax, and the
<br>Standard SiSU <u>object citation numbering</u> and system, (object/text identifying/locating system)
@@ -601,7 +601,7 @@ module SiSU_CGI_SQL
</font></p>
</td><td valign="top" width="45%">
<p class="tiny_left"><font color="#666666" size="2">
- #{v[:project]}, developed using
+ #{v.project}, developed using
<a href="http://www.ruby-lang.org/en/">
Ruby
</a>
@@ -908,13 +908,11 @@ module SiSU_CGI_SQL
else nil
end
@search_regx=if unescaped_search #check
- search_regex=[]
- build=unescaped_search.scan(/\S+/).each do |g|
+ search_regex=unescaped_search.scan(/\S+/).each.map do |g|
(g.to_s =~/(AND|OR)/) \
- ? (search_regex << '|')
- : (search_regex << %{#{g.to_s}})
- end
- search_regex=search_regex.join(' ')
+ ? ('|')
+ : (%{#{g.to_s}})
+ end.join(' ')
search_regex=search_regex.gsub(/\s*\|\s*/,'|')
Regexp.new(search_regex, Regexp::IGNORECASE)
else nil
diff --git a/lib/sisu/current/constants.rb b/lib/sisu/current/constants.rb
index 7a23027..175c2e7 100644
--- a/lib/sisu/current/constants.rb
+++ b/lib/sisu/current/constants.rb
@@ -62,6 +62,7 @@ Sfx={
txt_asciidoc: '.ad',
txt_markdown: '.md',
txt_rst: '.rst',
+ txt_orgmode: '.org',
html: '.html',
xhtml: '.xhtml',
xml: '.xml',
@@ -146,6 +147,26 @@ Mx={
sm_set_o: '◢', sm_set_c: '◣',
sm_subset_o: '◢', sm_subset_c: '◣',
vline: '┆', # ¦ |
+ src_bold_o: '!{', src_bold_c: '}!',
+ src_italics_o: '/{', src_italics_c: '}/',
+ src_underscore_o: '_{', src_underscore_c: '}_',
+ src_cite_o: '"{', src_cite_c: '}"',
+ src_insert_o: '+{', src_insert_c: '}+',
+ src_strike_o: '-{', src_strike_c: '}-',
+ src_superscript_o: '^{', src_superscript_c: '}^',
+ src_subscript_o: ',{', src_subscript_c: '}',
+ src_hilite_o: '*{', src_hilite_c: '}*',
+ src_monospace_o: '#{', src_monospace_c: '}#',
+ srcrgx_bold_o: '\!\{', srcrgx_bold_c: '\}\!',
+ srcrgx_italics_o: '\/\{', srcrgx_italics_c: '\}\/',
+ srcrgx_underscore_o: '_\{', srcrgx_underscore_c: '\}_',
+ srcrgx_cite_o: '"\{', srcrgx_cite_c: '\}"',
+ srcrgx_insert_o: '\+\{', srcrgx_insert_c: '\}\+',
+ srcrgx_strike_o: '\-\{', srcrgx_strike_c: '\}\-',
+ srcrgx_superscript_o: '\^\{', srcrgx_superscript_c: '\}\^',
+ srcrgx_subscript_o: ',\{', srcrgx_subscript_c: '\},',
+ srcrgx_hilite_o: '\*\{', srcrgx_hilite_c: '\}\*',
+ srcrgx_monospace_o: '\#\{', srcrgx_monospace_c: '\}\#',
}
Mx[:fa_bold_o]= "#{Mx[:fa_o]}b#{Mx[:fa_o_c]}"
Mx[:fa_bold_c]= "#{Mx[:fa_c_o]}b#{Mx[:fa_c]}"
@@ -220,16 +241,6 @@ Px={
subscript_o: '[', subscript_c: ']',
hilite_o: '*', hilite_c: '*',
monospace_o: '', monospace_c: '',
- po_bold_o: '!{', po_bold_c: '}!',
- po_italics_o: '/{', po_italics_c: '}/',
- po_underscore_o: '_{', po_underscore_c: '}_',
- po_cite_o: '"{', po_cite_c: '}"',
- po_insert_o: '+{', po_insert_c: '}+',
- po_strike_o: '-{', po_strike_c: '}-',
- po_superscript_o: '^{', po_superscript_c: '}^',
- po_subscript_o: ',{', po_subscript_c: '},',
- po_hilite_o: '*{', po_hilite_c: '}*',
- po_monospace_o: '#{', po_monospace_c: '}#',
lng_lst: SiSU_is.language_list?,
lng_lst_rgx: SiSU_is.language_list_regex?,
lv1: '*',
@@ -352,7 +363,7 @@ check:
#˝ " λ Ω β α π Ѫ Ж Я Ѳ ѳ Ф ✠ ㈣
Ѳ ѳ Ф
♩ ♭  ✠  ▭ ▬ ▪
-【】〖〗◢ ◣ ◀ ▶ ◘ ◙
+【】〖〗◢ ◣ ◀ ▶ ◘ ◙ « ▲ »
《》「」
‹ › ∗  ∴ ∷
'〔lv1〕','〔lv2〕','〔lv3〕','〔lv4〕','〔lv5〕','〔lv6〕','〔lv7〕','〔lv8〕','〔lv9〕'
diff --git a/lib/sisu/current/db_drop.rb b/lib/sisu/current/db_drop.rb
index acdae9d..b90a81e 100644
--- a/lib/sisu/current/db_drop.rb
+++ b/lib/sisu/current/db_drop.rb
@@ -55,11 +55,11 @@
=end
module SiSU_DbDrop
+ require_relative 'utils_response' # utils_response.rb
class Drop
- require_relative 'utils_response' # utils_response.rb
+ include SiSU_Response
def initialize(opt,conn,db_info,sql_type)
@opt,@conn,@db_info,@sql_type=opt,conn,db_info,sql_type
- @ans=SiSU_Response::Response.new
case @sql_type
when :sqlite
cascade=''
@@ -82,7 +82,7 @@ module SiSU_DbDrop
case @sql_type
when :sqlite
puts msg_sqlite
- ans=@ans.response?('remove sql database?')
+ ans=response?('remove sql database?')
if ans \
and File.exist?(@db_info.sqlite.db)
@conn.close
@@ -133,7 +133,7 @@ module SiSU_DbDrop
rescue
case @sql_type
when :sqlite
- ans=@ans.response?('remove sql database?')
+ ans=response?('remove sql database?')
if ans and File.exist?(@db_info.sqlite.db); File.unlink(@db_info.sqlite.db)
end
else
diff --git a/lib/sisu/current/db_sqltxt.rb b/lib/sisu/current/db_sqltxt.rb
index a307dc1..de717cc 100644
--- a/lib/sisu/current/db_sqltxt.rb
+++ b/lib/sisu/current/db_sqltxt.rb
@@ -66,9 +66,9 @@ module SiSU_DbText
gsub(/#{Mx[:lnk_o]}\s*(.+?)\s*#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/m,'\1')
end
def clean_searchable_text_from_document_objects(arr)
- txt_arr,en=[],[]
+ en=[]
arr=(arr.is_a?(String)) ? [ arr ] : arr
- arr.each do |s|
+ txt_arr=arr.each.map do |s|
s=s.gsub(/#{Mx[:fa_o]}[a-z]{1,4}#{Mx[:fa_o_c]}/m,'').
gsub(/#{Mx[:fa_c_o]}[a-z]{1,4}#{Mx[:fa_c]}/m,'').
gsub(/<br>/m,' ')
@@ -77,25 +77,26 @@ module SiSU_DbText
gsub(/#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]}/m,'').
gsub(/ \s+/m,' ')
#p s if s =~/[^ \nA-Za-z0-9'"`?!#@$%^&*=+,.;:\[\]()<>{}‹›|\\\/~_-]/
- txt_arr << s
+ s
end
txt_arr=txt_arr << en
txt=txt_arr.flatten.join("\n")
special_character_escape(txt)
end
def clean_document_objects_body(arr)
- txt_arr,en,en_arr=[],[],[]
+ en=[]
arr=(arr.is_a?(String)) ? [ arr ] : arr
- arr.each do |s|
+ txt_arr=arr.each.map do |s|
en << s.scan(/#{Mx[:en_a_o]}\s*(.+?)\s*#{Mx[:en_a_c]}/m)
- s=s.gsub(/#{Mx[:en_a_o]}\s*(\d+).+?#{Mx[:en_a_c]}/m,'<sup>\1</sup>').
+ s=s.
+ gsub(/#{Mx[:en_a_o]}\s*(\d+).+?#{Mx[:en_a_c]}/m,
+ '<sup>\1</sup>').
gsub(/#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]}/m,'').
gsub(/ \s+/m,' ')
- txt_arr << s
+ s
end
- en.flatten.each do |e|
- e=e.sub(/^(\d+)\s*/,'<sup>\1</sup> ')
- en_arr << e
+ en_arr=en.flatten.each.map do |e|
+ e.sub(/^(\d+)\s*/,'<sup>\1</sup> ')
end
txt_arr=txt_arr << en_arr
txt=txt_arr.flatten.join("\n<br>")
@@ -106,7 +107,8 @@ module SiSU_DbText
arr=(arr.is_a?(String)) ? arr.split(/\n+/m) : arr
arr.each do |s|
s=s.gsub(/([*\/_-])\{(.+?)\}\1/m,'\2').
- gsub(/^(?:block|group|poem|code)\{/m,'').gsub(/^\}(?:block|group|poem|code)/m,'').
+ gsub(/^(?:block|group|poem|code)\{/m,'').
+ gsub(/^\}(?:block|group|poem|code)/m,'').
gsub(/\A(?:@\S+:\s+.+)\Z/m,'')
if s =~/^:A~/
if defined? @md.creator \
diff --git a/lib/sisu/current/dp.rb b/lib/sisu/current/dp.rb
index 4cf058e..8526477 100644
--- a/lib/sisu/current/dp.rb
+++ b/lib/sisu/current/dp.rb
@@ -132,8 +132,14 @@ module SiSU_Param
@@md=@md
else @@md
end
- @@md.opt=@opt
- @@md
+ begin
+ @@md.opt=@opt
+ @@md
+ rescue
+ SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).
+ mark('has an existing option been selected?')
+ exit
+ end
end
class MdDefault
def rights(author,date)
@@ -891,9 +897,9 @@ module SiSU_Param
@doc={ lv: [] }
@doc[:fns],@doc[:fnb],@doc[:scr_suffix]='','',''
@@publisher='SiSU scribe'
- attr_accessor :make,:env,:path,:file,:fn,:fns,:fno,:fnb,:fnn,:fnt,:fnl,:flv,:fnz,:fnstex,:ocn,:sfx_src,:pdf,:file_type,:dir_out,:dir_tex,:dir_lout,:txt_path,:sisu,:sisu_version,:ruby_version,:title,:subtitle,:full_title,:html_title,:subtitle_tex,:creator,:classify,:author_home,:author,:author_title,:author_nationality,:authors,:authorship,:translator,:illustrator,:prepared_by,:digitized_by,:subject,:description,:publisher,:current_publisher,:contributor,:date,:date_created,:date_issued,:date_available,:date_valid,:date_modified,:date_translated,:date_added_to_site,:date_scheme,:date_created_scheme,:date_issued_scheme,:date_available_scheme,:date_valid_scheme,:date_modified_scheme,:type,:format,:identifier,:source,:language,:language_original,:relation,:coverage,:rights,:keywords,:comments,:abstract,:cls_loc,:cls_dewey,:cls_pg,:cls_isbn,:papersize,:papersize_array,:toc,:lv0,:lv1,:lv2,:lv3,:lv4,:lv5,:lv6,:lvs,:pagenew,:pagebreak,:pageline,:num_top,:bold_match_list,:italics_match_list,:substitution_match_list,:emphasis_set_to,:toc_lev_limit,:flag_endnotes,:flag_auto_endnotes,:flag_separate_endnotes,:flag_separate_endnotes_make,:markup,:markup_instruction,:flag_tables,:vocabulary,:doc_css,:yaml,:lnk,:links,:prefix_a,:prefix_b,:suffix,:information,:contact,:icon,:image,:ad_url,:ad_png,:ad_alt,:ad_began,:flag_promo,:promo,:ad_home,:stmp,:stmpd,:sc_filename,:sc_number,:sc_date,:sc_time,:sc_info,:yamladdr,:locale,:wc_lines,:wc_words,:wc_bytes,:file_encoding,:filesize,:user,:home,:hostname,:pwd,:firstseg,:programs,:author_copymark,:i18n,:lang,:lang_code_insert,:en,:notes,:dgst,:generated,:tags,:tag_array,:concord_make,:seg_names,:seg_autoname_safe,:set_header_title,:set_heading_top,:set_heading_seg,:heading_seg_first,:heading_seg_first_flag,:base_program,:ec,:opt,:sem_tag,:book_idx,:topic_register,:topic_register_array,:original,:writing_focus,:audio,:daisy,:home_button_image,:home_button_links,:footer_links,:cover_image,:man_section
+ attr_accessor :make,:env,:path,:file,:fn,:fns,:fno,:fnb,:fnn,:fnt,:fnl,:flv,:fnz,:fnstex,:ocn,:sfx_src,:pdf,:file_type,:dir_out,:dir_tex,:dir_lout,:txt_path,:sisu,:project_details,:ruby_version,:title,:subtitle,:full_title,:html_title,:subtitle_tex,:creator,:classify,:author_home,:author,:author_title,:author_nationality,:authors,:authorship,:translator,:illustrator,:prepared_by,:digitized_by,:subject,:description,:publisher,:current_publisher,:contributor,:date,:date_created,:date_issued,:date_available,:date_valid,:date_modified,:date_translated,:date_added_to_site,:date_scheme,:date_created_scheme,:date_issued_scheme,:date_available_scheme,:date_valid_scheme,:date_modified_scheme,:type,:format,:identifier,:source,:language,:language_original,:relation,:coverage,:rights,:keywords,:comments,:abstract,:cls_loc,:cls_dewey,:cls_pg,:cls_isbn,:papersize,:papersize_array,:toc,:lv0,:lv1,:lv2,:lv3,:lv4,:lv5,:lv6,:lvs,:pagenew,:pagebreak,:pageline,:num_top,:bold_match_list,:italics_match_list,:substitution_match_list,:emphasis_set_to,:toc_lev_limit,:flag_biblio,:flag_auto_biblio,:flag_endnotes,:flag_auto_endnotes,:flag_separate_endnotes,:flag_separate_endnotes_make,:markup,:markup_instruction,:flag_tables,:vocabulary,:doc_css,:yaml,:lnk,:links,:prefix_a,:prefix_b,:suffix,:information,:contact,:icon,:image,:ad_url,:ad_png,:ad_alt,:ad_began,:flag_promo,:promo,:ad_home,:stmp,:stmpd,:sc_filename,:sc_number,:sc_date,:sc_time,:sc_info,:yamladdr,:locale,:wc_lines,:wc_words,:wc_bytes,:file_encoding,:filesize,:user,:home,:hostname,:pwd,:firstseg,:programs,:author_copymark,:i18n,:lang,:lang_code_insert,:en,:notes,:dgst,:generated,:tags,:tag_array,:concord_make,:seg_names,:seg_autoname_safe,:set_header_title,:set_heading_top,:set_heading_seg,:heading_seg_first,:heading_seg_first_flag,:base_program,:ec,:opt,:sem_tag,:book_idx,:topic_register,:topic_register_array,:original,:writing_focus,:audio,:daisy,:home_button_image,:home_button_links,:footer_links,:cover_image,:man_section
def initialize(fns_array,opt)
- @env=@path,@file=@fn=@fns=@fno=@fnb=@fnn=@fnt=@fnl=@flv=@fnz=@fnstex=@ocn=@sfx_src=@pdf=@file_type=@dir_out=@dir_tex=@dir_lout=@txt_path=@make=@flag_endnotes=@flag_auto_endnotes=@flag_separate_endnotes=@flag_separate_endnotes_make=@sisu=@sisu_version=@ruby_version=@title=@subtitle=@full_title=@html_title=@subtitle_tex=@creator=@classify=@author_home=@author=@author_title=@author_nationality=@translator=@illustrator=@prepared_by=@digitized_by=@subject=@description=@publisher=@current_publisher=@contributor=@date=@date_created=@date_issued=@date_available=@date_valid=@date_modified=@date_translated=@date_added_to_site=@date_scheme=@date_created_scheme=@date_issued_scheme=@date_available_scheme=@date_valid_scheme=@date_modified_scheme=@type=@format=@identifier=@source=@language=@language_original=@relation=@coverage=@rights=@keywords=@comments=@abstract=@cls_loc=@cls_dewey=@cls_pg=@cls_isbn=@papersize=@toc=@lv0=@lv1=@lv2=@lv3=@lv4=@lv5=@lv6=@pagenew=@pagebreak=@pageline=@num_top=@bold_match_list=@italics_match_list=@substitution_match_list=@emphasis_set_to=@toc_lev_limit=@flag_tables=@vocabulary=@doc_css=@yaml=@lnk=@links=@prefix_a=@prefix_b=@suffix=@information=@contact=@icon=@ad_url=@ad_png=@ad_alt=@ad_began=@promo=@ad_home=@stmp=@stmpd=@sc_filename=@sc_number=@sc_date=@sc_time=@sc_info=@yamladdr=@locale=@wc_lines=@wc_words=@wc_bytes=@file_encoding=@filesize=@firstseg=@programs=@author_copymark=@i18n=@lang=@lang_code_insert=@en=@notes=@dgst=@generated=@heading_seg_first=@base_program=@topic_register=@original=@writing_focus=@audio=@home_button_image=@home_button_links=@cover_image=@man_section=nil
+ @env=@path,@file=@fn=@fns=@fno=@fnb=@fnn=@fnt=@fnl=@flv=@fnz=@fnstex=@ocn=@sfx_src=@pdf=@file_type=@dir_out=@dir_tex=@dir_lout=@txt_path=@make=@flag_biblio=@flag_auto_biblio=@flag_endnotes=@flag_auto_endnotes=@flag_separate_endnotes=@flag_separate_endnotes_make=@sisu=@project_details=@ruby_version=@title=@subtitle=@full_title=@html_title=@subtitle_tex=@creator=@classify=@author_home=@author=@author_title=@author_nationality=@translator=@illustrator=@prepared_by=@digitized_by=@subject=@description=@publisher=@current_publisher=@contributor=@date=@date_created=@date_issued=@date_available=@date_valid=@date_modified=@date_translated=@date_added_to_site=@date_scheme=@date_created_scheme=@date_issued_scheme=@date_available_scheme=@date_valid_scheme=@date_modified_scheme=@type=@format=@identifier=@source=@language=@language_original=@relation=@coverage=@rights=@keywords=@comments=@abstract=@cls_loc=@cls_dewey=@cls_pg=@cls_isbn=@papersize=@toc=@lv0=@lv1=@lv2=@lv3=@lv4=@lv5=@lv6=@pagenew=@pagebreak=@pageline=@num_top=@bold_match_list=@italics_match_list=@substitution_match_list=@emphasis_set_to=@toc_lev_limit=@flag_tables=@vocabulary=@doc_css=@yaml=@lnk=@links=@prefix_a=@prefix_b=@suffix=@information=@contact=@icon=@ad_url=@ad_png=@ad_alt=@ad_began=@promo=@ad_home=@stmp=@stmpd=@sc_filename=@sc_number=@sc_date=@sc_time=@sc_info=@yamladdr=@locale=@wc_lines=@wc_words=@wc_bytes=@file_encoding=@filesize=@firstseg=@programs=@author_copymark=@i18n=@lang=@lang_code_insert=@en=@notes=@dgst=@generated=@heading_seg_first=@base_program=@topic_register=@original=@writing_focus=@audio=@home_button_image=@home_button_links=@cover_image=@man_section=nil
@data, @path, @fns, @fno, @opt=
fns_array,opt.pth,opt.fns,opt.fno,opt #@data used as data
@flag_tables,@set_header_title,@set_heading_top,@set_heading_seg,@heading_seg_first_flag,@flag_promo,@book_idx=
@@ -1008,22 +1014,35 @@ module SiSU_Param
@fnstex=@fns.gsub(/_/,'\_\-').gsub(/\./,'.\-')
@flag_endnotes,@flag_auto_endnotes,@flag_separate_endnotes=false,false,false
@flag_separate_endnotes_make=true
+ @flag_biblio,@flag_auto_biblio=false,false
ver=SiSU_Env::InfoVersion.instance
- @sisu_version=ver.get_version
+ @project_details=ver.get_version
@ruby_version=ver.rbversion
@generated=Time.now
fns_array=@data.dup
skip unless fns_array # consider
@code_flag=false
+ flag_code_curly=:not_code_curly
+ flag_code_tics=:not_code_tics
fns_array.each do |para| #% scan document
if para !~/^%+\s/ \
and para =~/<![abcdeghijklmnopqrstuvwxyz]/i # <!f not included
- raise "Old markup style in file #{@fns}, current version #{@sisu_version[:project]} #{@sisu_version[:version]} #{@sisu_version[:date_stamp]} #{@sisu_version[:date]}:\n\t\t#{para}\n\n"
+ raise "Old markup style in file #{@fns}, current version #{@project_details.project} #{@project_details.version} #{@project_details.date_stamp} #{@project_details.date}:\n\t\t#{para}\n\n"
+ end
+ if para =~/^code\{/
+ flag_code_curly=:code_curly
+ elsif para =~/^\}code/
+ flag_code_curly=:not_code_curly
+ elsif para =~/^``` code/
+ flag_code_tics=:code_tics
+ elsif flag_code_tics ==:code_tics \
+ and para =~/^```/
+ flag_code_tics=:not_code_tics
end
- @code_flag=case para
- when /^code\{\s*$/ then true
- when /^\}code\s*$/ then false
- else @code_flag
+ @code_flag=if flag_code_curly==:code_curly \
+ or flag_code_tics==:code_tics
+ true
+ else false
end
regx_header=/^@\S+?:[+-]?\s/
if para =~regx_header \
@@ -1196,6 +1215,16 @@ module SiSU_Param
%{#{title}#{creator}}
).txt_grey if @opt.act[:verbose][:set]==:on
end
+ unless @code_flag
+ if para =~/^1~biblio(?:graphy)?/
+ @flag_auto_biblio,@flag_biblio=false,true
+ #@flag_biblio=true
+ elsif @flag_biblio ==true \
+ and @flag_auto_biblio ==false \
+ and para =~/^(?:au|author):/m
+ @flag_auto_biblio =true
+ end
+ end
if not @book_idx \
and para =~/^=\{(.+?)\}[\s`]*\Z/m
@book_idx=true
diff --git a/lib/sisu/current/git.rb b/lib/sisu/current/git.rb
index 0ec3520..b8b5f10 100644
--- a/lib/sisu/current/git.rb
+++ b/lib/sisu/current/git.rb
@@ -132,14 +132,22 @@ module SiSU_Git
(found =~/bin\/git\b/) ? true : false
end
def make_dir_fnb
- FileUtils::mkdir_p(@git_path[:fnb]) unless FileTest.directory?(@git_path[:fnb])
- FileUtils::mkdir_p(@git_path[:doc]) unless FileTest.directory?(@git_path[:doc])
- FileUtils::mkdir_p(@git_path[:po]) unless FileTest.directory?(@git_path[:po])
- FileUtils::mkdir_p(@git_path[:pot]) unless FileTest.directory?(@git_path[:pot])
- FileUtils::mkdir_p(@git_path[:conf]) unless FileTest.directory?(@git_path[:conf])
- FileUtils::mkdir_p(@git_path[:image]) unless FileTest.directory?(@git_path[:image])
- #FileUtils::mkdir_p(@git_path[:audio]) unless FileTest.directory?(@git_path[:audio])
- #FileUtils::mkdir_p(@git_path[:video]) unless FileTest.directory?(@git_path[:video])
+ FileUtils::mkdir_p(@git_path[:fnb]) \
+ unless FileTest.directory?(@git_path[:fnb])
+ FileUtils::mkdir_p(@git_path[:doc]) \
+ unless FileTest.directory?(@git_path[:doc])
+ FileUtils::mkdir_p(@git_path[:po]) \
+ unless FileTest.directory?(@git_path[:po])
+ FileUtils::mkdir_p(@git_path[:pot]) \
+ unless FileTest.directory?(@git_path[:pot])
+ FileUtils::mkdir_p(@git_path[:conf]) \
+ unless FileTest.directory?(@git_path[:conf])
+ FileUtils::mkdir_p(@git_path[:image]) \
+ unless FileTest.directory?(@git_path[:image])
+ #FileUtils::mkdir_p(@git_path[:audio]) \
+ # unless FileTest.directory?(@git_path[:audio])
+ #FileUtils::mkdir_p(@git_path[:video]) \
+ # unless FileTest.directory?(@git_path[:video])
end
def git_init
unless FileTest.directory?("#{@git_path[:fnb]}/.git")
@@ -168,13 +176,23 @@ module SiSU_Git
p __LINE__
end
def copy_src_head
- if @opt.f_pth[:lng]
- FileUtils::cp_r("#{@env.path.pwd}/#{@opt.f_pth[:lng]}/#{@opt.fns}",@git_path[:doc])
+ if @opt.f_pth[:lng] \
+ and File.exist?("#{@env.path.pwd}/#{@opt.f_pth[:lng]}/#{@opt.fns}")
+ FileUtils::cp_r(
+ "#{@env.path.pwd}/#{@opt.f_pth[:lng]}/#{@opt.fns}",
+ @git_path[:doc]
+ )
elsif @opt.fns =~/\.ssm\.sst/
ssm=@opt.fns.gsub(/\.ssm\.sst/,'.ssm')
- FileUtils::cp_r("#{@env.path.pwd}/#{ssm}",@git_path[:doc])
- else
- FileUtils::cp_r("#{@env.path.pwd}/#{@opt.fns}",@git_path[:doc])
+ FileUtils::cp_r(
+ "#{@env.path.pwd}/#{ssm}",
+ @git_path[:doc]
+ )
+ elsif File.exist?("#{@env.path.pwd}/#{@opt.fns}")
+ FileUtils::cp_r(
+ "#{@env.path.pwd}/#{@opt.fns}",
+ @git_path[:doc]
+ )
end
end
def copy_related_sst_ssi
@@ -183,14 +201,21 @@ module SiSU_Git
file_array=IO.readlines(@opt.fns,'')
file_array.each do |f|
if f =~@rgx_doc_import
- doc_import = doc_import + f.scan(@rgx_doc_import).uniq.flatten
+ doc_import = doc_import \
+ + f.scan(@rgx_doc_import).uniq.flatten
end
end
doc_import.each do |f|
if @opt.f_pth[:lng]
- FileUtils::cp_r("#{@env.path.pwd}/#{@opt.f_pth[:lng]}/#{f}",@git_path[:doc])
+ FileUtils::cp_r(
+ "#{@env.path.pwd}/#{@opt.f_pth[:lng]}/#{f}",
+ @git_path[:doc]
+ )
else
- FileUtils::cp_r("#{@env.path.pwd}/#{f}",@git_path[:doc])
+ FileUtils::cp_r(
+ "#{@env.path.pwd}/#{f}",
+ @git_path[:doc]
+ )
end
end
end
@@ -200,10 +225,19 @@ module SiSU_Git
and not @opt.act[:ao][:set]==:on
##SiSU_Assemble::Composite.new(@opt).read
#SiSU_AO::Source.new(@opt).read # -m
- "#{@env.processing_path.composite_file}/#{@opt.fnb}.ssm.sst"
+ @env.processing_path.composite_file \
+ + '/' \
+ + @opt.fnb \
+ + '.ssm.sst'
elsif composite_src
- "#{@env.processing_path.composite_file}/#{@opt.fnb}.ssm.sst"
- else "#{@env.path.pwd}/#{@opt.fns}"
+ @env.processing_path.composite_file \
+ + '/' \
+ + @opt.fnb \
+ + '.ssm.sst'
+ else
+ @env.path.pwd
+ + '/' \
+ + @opt.fns
end
end
def read_composite
diff --git a/lib/sisu/current/html.rb b/lib/sisu/current/html.rb
index 582773e..3aab3be 100644
--- a/lib/sisu/current/html.rb
+++ b/lib/sisu/current/html.rb
@@ -165,11 +165,10 @@ module SiSU_HTML
end
end
SiSU_Env::Clear.new(@opt.selections.str,@opt.fns,@md).param_instantiate
- @@flag,@@scr,@@seg,@@seg_endnotes,@@seg_subtoc,@@seg_ad={},{},{},{},{},{}
- @@seg_total,@@tracker,@@loop_count,@@tablehead,@@number_of_cols=0,0,0,0,0
- @@seg_name,@@seg_name_html,@@seg_subtoc_array,@@seg_endnotes_array,@@segtocband,@@tablefoot=Array.new(7){[]}
- @@filename_seg,@@seg_url,@@fn,@@to_lev4,@@get_hash_to,@@get_hash_fn='','','','','','',''
- @@is4=@@is3=@@is2=@@is1=@@heading1=@@heading2=@@heading3=@@heading4=0
+ @@flag,@@scr,@@seg,@@seg_endnotes,@@seg_subtoc={},{},{},{},{}
+ @@tracker=0
+ @@seg_name,@@seg_name_x,@@seg_subtoc_array,@@seg_endnotes_array,@@tablefoot=Array.new(5){[]}
+ @@filename_seg,@@seg_url,@@to_lev4,@@get_hash_to,@@get_hash_fn='','','','',''
end
end
private
@@ -262,8 +261,6 @@ module SiSU_HTML
@@firstseg=nil
def initialize(md=nil,data='')
@data,@md=data,md
- @ocn_html_identifier=
- SiSU_Env::ProcessingSettings.new(@md).ocn_html_identifier
@tell=SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set]) if @md
end
def songsheet #extracts toc for scroll & seg
@@ -378,7 +375,7 @@ WOK
title=if dob.ocn ==0 then linkname
else
@@toc[:scr] << '<br>'
- %{<b><a href="##{@ocn_html_identifier}#{dob.ocn}">#{linkname}</a></b>}
+ %{<b><a href="##{dob.ocn}">#{linkname}</a></b>}
end
txt_obj={ txt: title }
format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj)
@@ -420,7 +417,7 @@ WOK
end
else
@@toc[:scr] << '<br>'
- %{<b><a href="##{@ocn_html_identifier}#{dob.ocn}">#{linkname}</a></b>}
+ %{<b><a href="##{dob.ocn}">#{linkname}</a></b>}
end
txt_obj={ txt: title }
format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj)
@@ -537,7 +534,7 @@ WOK
}
f=@md.file.base_filename.html_seg(fnh)
p_num=SiSU_HTML_Format::ParagraphNumber.new(@md,ocn)
- lnk_n_txt=%{ <a href="#{f}##{@ocn_html_identifier}#{ocn}">
+ lnk_n_txt=%{ <a href="#{f}##{ocn}">
#{linkname}
</a>}
txt_obj={ txt: lnk_n_txt }
@@ -562,7 +559,7 @@ WOK
}
f=@md.file.base_filename.html_seg(fnh)
p_num=SiSU_HTML_Format::ParagraphNumber.new(@md,ocn)
- lnk_n_txt=%{ <a href="#{f}##{@ocn_html_identifier}#{ocn}">
+ lnk_n_txt=%{ <a href="#{f}##{ocn}">
#{linkname}
</a>}
txt_obj={ txt: lnk_n_txt }
diff --git a/lib/sisu/current/html_format.rb b/lib/sisu/current/html_format.rb
index 8f83219..b350170 100644
--- a/lib/sisu/current/html_format.rb
+++ b/lib/sisu/current/html_format.rb
@@ -60,7 +60,6 @@ module SiSU_HTML_Format
def initialize(md,ocn)
@md,@ocn=md,ocn.to_s
@ocn ||=''
- @ocn_html_identifier=SiSU_Env::ProcessingSettings.new(@md).ocn_html_identifier
@make=SiSU_Env::ProcessingSettings.new(@md)
end
def ocn_display
@@ -69,7 +68,7 @@ module SiSU_HTML_Format
or @ocn.empty?
''
else
- %{<label class="ocn"><a href="##{@ocn_html_identifier}#{@ocn}" class="lnkocn">#{@ocn}</a></label>}
+ %{<label class="ocn"><a href="##{@ocn}" class="lnkocn">#{@ocn}</a></label>}
end
else
''
@@ -84,10 +83,12 @@ module SiSU_HTML_Format
end
end
def id #w3c? "tidy" complains about numbers as identifiers ! annoying
- (@ocn==nil || @ocn.empty?) ? '' : %{id="#{Mx[:ocn_id_char]}#{@ocn}"}
+ (@ocn==nil || @ocn.empty?) \
+ ? '' : %{id="#{Mx[:ocn_id_char]}#{@ocn}"}
end
def goto
- (@ocn==nil || @ocn.empty?) ? '' : %{<a href="##{@ocn_html_identifier}#{@ocn}">}
+ (@ocn==nil || @ocn.empty?) \
+ ? '' : %{<a href="##{@ocn}">}
end
end
class HeadInformation
@@ -99,8 +100,9 @@ module SiSU_HTML_Format
@md=md
# DublinCore 1 - title
@bits=SiSU_Proj_HTML::Bits.new
- @seg_name_html=(SiSU_HTML::Source::Seg.new.seg_name_html || [])
- @seg_name_html_tracker=(SiSU_HTML::Source::Seg.new.seg_name_html_tracker || [])
+ @per=SiSU_HTML_Persist::Persist.new
+ @per.seg_name_x=SiSU_HTML::Seg.new.seg_name_x
+ @per.seg_name_x_tracker=SiSU_HTML::Seg.new.seg_name_x_tracker
@tocband_scroll,@tocband_segtoc=nil,nil
@stylesheet=SiSU_Style::CSS_HeadInfo.new(md).stylesheet
@o_str ||=SiSU_Env::ProcessingSettings.new(md).output_dir_structure
@@ -403,7 +405,7 @@ WOK
<head>
<meta charset="utf-8">
<title>
- #{@md.html_title}
+ #{@md.title.full}
</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
#{rdf.metatag_html}
@@ -615,9 +617,9 @@ WOK
super(md)
end
def dot_control_pre_next
- pre="#{@seg_name_html[@seg_name_html_tracker-1]}#{@md.lang_code_insert}#{Sfx[:html]}"
+ pre="#{@per.seg_name_x[@per.seg_name_x_tracker-1]}#{@md.lang_code_insert}#{Sfx[:html]}"
up=@toc
- nxt="#{@seg_name_html[@seg_name_html_tracker+1]}#{@md.lang_code_insert}#{Sfx[:html]}"
+ nxt="#{@per.seg_name_x[@per.seg_name_x_tracker+1]}#{@md.lang_code_insert}#{Sfx[:html]}"
if nxt=~/sisu_manifest\.html/
@file=SiSU_Env::FileOp.new(@md) if @md
if @file.output_dir_structure.by_language_code? \
@@ -643,7 +645,7 @@ WOK
#{the_table_close}}
end
def dot_control_pre
- pre="#{@seg_name_html[@seg_name_html_tracker-2]}#{@md.lang_code_insert}#{Sfx[:html]}"
+ pre="#{@per.seg_name_x[@per.seg_name_x_tracker-2]}#{@md.lang_code_insert}#{Sfx[:html]}"
up=@toc
nxt="#{@md.file.base_filename.html_segtoc}"
%{<table summary="segment hidden control pre" width="100%" border="0" cellpadding="0" bgcolor=#{the_color.grey_pale} align="center">
@@ -671,12 +673,12 @@ WOK
</a>
</td>}
pre=%{<td align="center" bgcolor=#{the_color.band1}>
- <a href="#{@seg_name_html[@seg_name_html_tracker-use]}#{@md.lang_code_insert}#{Sfx[:html]}" target="_top">
+ <a href="#{@per.seg_name_x[@per.seg_name_x_tracker-use]}#{@md.lang_code_insert}#{Sfx[:html]}" target="_top">
#{png_nav.pre}
</a>
</td>} if f_pre==true
nxt=%{<td align="center" bgcolor=#{the_color.band1}>
- <a href="#{@seg_name_html[@seg_name_html_tracker+1]}#{@md.lang_code_insert}#{Sfx[:html]}" target="_top">
+ <a href="#{@per.seg_name_x[@per.seg_name_x_tracker+1]}#{@md.lang_code_insert}#{Sfx[:html]}" target="_top">
#{png_nav.nxt}
</a>
</td>} if f_nxt==true
@@ -721,23 +723,6 @@ WOK
else ''
end
end
- def navigation_table
- %{<table summary="navigation segment table" width=#{the_width.table1} border="0" bgcolor="white" cellpadding="0">
-<tr><th width="#{@@indent['leve_1']}" align="right">
-</td>
-<td valign="top">
- <font size=2>}
- end
- def navigation_table1
- %{<table summary="navigation segment table1" width=#{the_width.table1} border="0" cellpadding=#{the_table_cellpad_box} bgcolor=#{the_color.table1} align="left">
-<tr><td valign="top">
- <font size="2">}
- end
- def navigation_table2
- %{<table summary="navigation segment table2" width=#{the_width.table2} border="0" cellpadding=#{the_table_cellpad_box} bgcolor=#{the_color.table2} align="left">
-<tr><td valign="top">
- <font size="2">}
- end
def credit
%{
<div class="main_column">
@@ -799,8 +784,8 @@ WOK
<head>
<meta charset="utf-8">
<title>
- #{@seg_name_html[@seg_name_html_tracker]} -
- #{@md.html_title}
+ #{@per.seg_name_x[@per.seg_name_x_tracker]} -
+ #{@md.title.main}
</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
#{rdf.metatag_html}
@@ -1161,7 +1146,6 @@ WOK
end
def subtoc_lev(tag,attrib)
@txt=clean(@txt)
- @ocn_html_identifier=SiSU_Env::ProcessingSettings.new(@md).ocn_html_identifier
txt=if @txt \
and @txt =~/<\/?i>|<a\s+name="\S+?">/mi
@txt.gsub(/<\/?i>|<a\s+name="\S+?">/mi,'') #removes name markers from subtoc, go directly to substantive text
@@ -1175,7 +1159,7 @@ WOK
gsub(/<a[\s]+name="-\d+"[\s]+href="#_\d+">&nbsp;<sup>\d+<\/sup>&nbsp;/m,'')
end
%{<#{tag} class="#{attrib}">
- <a href="##{@ocn_html_identifier}#{@ocn}"><i>#{txt}</i></a> #{note}
+ <a href="##{@ocn}"><i>#{txt}</i></a> #{note}
</#{tag}>}
end
def subtoc_lev5
diff --git a/lib/sisu/current/html_harvest_authors.rb b/lib/sisu/current/html_harvest_authors.rb
index cbbd153..4a91b69 100644
--- a/lib/sisu/current/html_harvest_authors.rb
+++ b/lib/sisu/current/html_harvest_authors.rb
@@ -322,7 +322,7 @@ module SiSU_HarvestAuthors
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="dc.title" content= "SiSU metadata harvest, Authors - SiSU information Structuring Universe, Structured information Serialised Units" />
<meta name="dc.subject" content= "document structuring, ebook, publishing, PDF, LaTeX, XML, ODF, SQL, postgresql, sqlite, electronic book, electronic publishing, electronic document, electronic citation, data structure, citation systems, granular search, digital library" />
-<meta name="generator" content="#{sv[:project]} #{sv[:version]} of #{sv[:date_stamp]} (n*x and Ruby!)" />
+<meta name="generator" content="#{sv.project} #{sv.version} of #{sv.date_stamp} (n*x and Ruby!)" />
<link rel="generator" href="http://www.jus.uio.no/sisu/SiSU" />
<link href="#{css_path}" rel="stylesheet" >
<link rel="shortcut icon" href="../_sisu/image/rb7.ico" />
diff --git a/lib/sisu/current/html_harvest_topics.rb b/lib/sisu/current/html_harvest_topics.rb
index 58f92bc..4b6f493 100644
--- a/lib/sisu/current/html_harvest_topics.rb
+++ b/lib/sisu/current/html_harvest_topics.rb
@@ -158,10 +158,9 @@ module SiSU_HarvestTopics
end
idx_array[lang] <<=if @idx_list =~/;/
g=@idx_list.scan(/[^;]+/)
- idxl=[]
- g.each do |i|
+ g.each.map do |i|
i=i.strip
- idxl << {
+ {
filename: filename,
file: file,
rough_idx: i,
@@ -171,7 +170,6 @@ module SiSU_HarvestTopics
lang: lang
}
end
- idxl
else {
filename: filename,
file: file,
@@ -691,7 +689,7 @@ module SiSU_HarvestTopics
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="dc.title" content= "SiSU metadata harvest, Topics - SiSU information Structuring Universe, Structured information Serialised Units" />
<meta name="dc.subject" content= "document structuring, ebook, publishing, PDF, LaTeX, XML, ODF, SQL, postgresql, sqlite, electronic book, electronic publishing, electronic document, electronic citation, data structure, citation systems, granular search, digital library" />
-<meta name="generator" content="#{sv[:project]} #{sv[:version]} of #{sv[:date_stamp]} (n*x and Ruby!)" />
+<meta name="generator" content="#{sv.project} #{sv.version} of #{sv.date_stamp} (n*x and Ruby!)" />
<link rel="generator" href="http://www.jus.uio.no/sisu/SiSU" />
<link href="#{css_path}" rel="stylesheet">
<link rel="shortcut icon" href="../_sisu/image/rb7.ico" />
diff --git a/lib/sisu/current/html_lite_shared.rb b/lib/sisu/current/html_lite_shared.rb
index aac5372..55e49bd 100644
--- a/lib/sisu/current/html_lite_shared.rb
+++ b/lib/sisu/current/html_lite_shared.rb
@@ -75,7 +75,6 @@ module SiSU_FormatShared
else @@hname
end
@tab="\t"
- @ocn_html_identifier=SiSU_Env::ProcessingSettings.new(@md).ocn_html_identifier
@@tablehead,@@tablefoot=[],[]
@env=SiSU_Env::InfoEnv.new(@md.fns)
@base_url="#{@env.url.root}/#{@md.fnb}/#{@hname}.html"
@@ -204,7 +203,7 @@ GSUB
%{<p class="#{h[:class]}" type="#{h[:type]}">#{h[:txt]}</a></p>\n} << "\n"
end
def lev_toc_hname
- %{<p class="toc#{@lv}" header="#{@hname}"><a href="##{@ocn_html_identifier}#{@ocn}">#{@txt}</a></p>\n} #<< "\n"
+ %{<p class="toc#{@lv}" header="#{@hname}"><a href="##{@ocn}">#{@txt}</a></p>\n} #<< "\n"
end
def lev_toc
h={ txt: txt, class: "toc#{@lv}", type: 'toc' }
diff --git a/lib/sisu/current/html_manifest.rb b/lib/sisu/current/html_manifest.rb
index 4409438..7cffad7 100644
--- a/lib/sisu/current/html_manifest.rb
+++ b/lib/sisu/current/html_manifest.rb
@@ -160,19 +160,19 @@ module SiSU_Manifest
%{<p class="tiny">#{the_url_decoration.xml_open}<a href="#{url}/#{file}">#{url}/#{file}</a>#{the_url_decoration.xml_close}</p>}
end
end
- def summarize(id,file,pth='',rel='',url='',img='● ')
+ def summarize(desc,id,file,pth='',rel='',url='',img='● ')
size=(File.size("#{pth}/#{file}")/1024.00).to_s
kb=/([0-9]+\.[0-9]{0,1})/m.match(size)[1]
- @manifest[:txt] << "#{file} #{id} #{kb}\n"
- @manifest[:html] << %{<tr><th class="left"><p class="norm"><a href="#{rel}/#{file}">#{img}#{id}</a></p></th><td><p class="small"><a href="#{rel}/#{file}">#{file}</a></p>#{url_make(url,file)}</td><td class="right"><p class="right">#{kb}</p></td></tr>\n}
+ @manifest[:txt] << "#{file} #{desc} #{kb}\n"
+ @manifest[:html] << %{<tr><th class="left"><p class="norm"><a href="#{rel}/#{file}">#{img}#{desc}</a></p></th><td><p class="small"><a href="#{rel}/#{file}">#{file}</a></p>#{url_make(url,file)}</td><td class="right"><p class="right">#{kb}</p></td></tr>\n}
end
- def summarize_html_seg(id,file,pth='',rel='',url='',img='● ')
+ def summarize_html_seg(desc,id,file,pth='',rel='',url='',img='● ')
size=(File.size("#{pth}/#{file}")/1024.00).to_s
kb=/([0-9]+\.[0-9]{0,1})/m.match(size)[1]
- @manifest[:txt] << "#{file} #{id} #{kb}\n"
- @manifest[:html] << %{<tr><th class="left"><p class="norm"><a href="#{rel}/#{file}">#{img}#{id}</a></p></th><td><p class="small"><a href="#{rel}/#{file}">#{file}</a></p>#{url_make(url,file)}</td><td class="right"><p class="right">#{kb}</p></td></tr>\n}
+ @manifest[:txt] << "#{file} #{desc} #{kb}\n"
+ @manifest[:html] << %{<tr><th class="left"><p class="norm"><a href="#{rel}/#{file}">#{img}#{desc}</a></p></th><td><p class="small"><a href="#{rel}/#{file}">#{file}</a></p>#{url_make(url,file)}</td><td class="right"><p class="right">#{kb}</p></td></tr>\n}
end
- def summarize_sources(id,file,pth,rel,url)
+ def summarize_sources(desc,id,file,pth,rel,url)
sys=SiSU_Env::SystemCall.new
dgst=case @dg
when :sha512
@@ -194,9 +194,9 @@ module SiSU_Manifest
end
size=(File.size("#{pth}/#{file}")/1024.00).to_s
kb=/([0-9]+\.[0-9]{0,1})/m.match(size)[1]
- @manifest[:txt] << "#{file} #{id} #{kb}\n"
+ @manifest[:txt] << "#{file} #{desc} #{kb}\n"
@manifest[:html] << %{<tr>} \
- + %{<th class="left"><p class="norm"><a href="#{rel}/#{file}">#{id}</a></p></th>} \
+ + %{<th class="left"><p class="norm" id="#{id}"><a href="#{rel}/#{file}">#{desc}</a></p></th>} \
+ %{<td class="right"><p class="tiny"><a href="#{rel}/#{file}">#{file}</a> &nbsp;&nbsp;#{dgst[1]}#{url_make(url,file,:src)}</p></td>} \
+ %{<td class="right"><p class="right">#{kb}</p></td>} \
+ %{</tr>\n} \
@@ -246,7 +246,7 @@ module SiSU_Manifest
end
@m=@m.uniq
end
- def languages(id,file)
+ def languages(desc,file)
@manifest[:html] << %{<tr><th class="left"><div id="horizontal_links"><ul id="horizontal">\n}
published_manifests?.each do |l|
SiSU_Translate::Source.new(@md,@language,l[:n]).language_list
@@ -255,15 +255,15 @@ module SiSU_Manifest
end
@manifest[:html] << %{</ul></div></th></tr>\n}
end
- def published_languages(id)
+ def published_languages(desc)
published_manifests?.each do |l|
@manifest[:txt] << "#{l[:mu]} #{l[:l]}\n"
@manifest[:html] << %{<tr><th class="left"><p class="bold"><a href="#{l[:mu]}">#{l[:l]}</a></p></th><td><p class="norm">#{l[:l]}</p><p class="tiny">#{the_url_decoration.xml_open}<a href="#{l[:mu]}">#{l[:mu]}</a>#{the_url_decoration.xml_close}</p></td><td class="right"><p class="right">&nbsp;</p></td></tr>\n}
end
end
- def metadata(id,info)
+ def metadata(desc,id,info)
info=info.to_s.gsub(/(?:#{Mx[:br_line]}|\\)+/,'<br>')
- @manifest[:html] << %{<tr><th class="left"><p class="bold_left">#{id}:</p></th><td><p class="left">#{info}</p></td></tr>\n}
+ @manifest[:html] << %{<tr><th class="left"><p class="bold_left" id="#{id}">#{desc}:</p></th><td><p class="left">#{info}</p></td></tr>\n}
end
def links(url,lnk,target)
static=if url =~/^\.\// then url.gsub(/^\.(\.)?/,@base_url)
@@ -278,271 +278,278 @@ module SiSU_Manifest
pth=@f.output_path.html_seg.dir
rel=@f.output_path.html_seg.rel_sm
url=@f.output_path.html_seg.url
- id,file='HTML, table of contents (for segmented text)',@f.base_filename.html_segtoc
- summarize_html_seg(id,file,pth,rel,url,img)
+ desc,id,file='HTML, table of contents (for segmented text)','html',@f.base_filename.html_segtoc
+ summarize_html_seg(desc,id,file,pth,rel,url,img)
end
if FileTest.file?(@f.place_file.html_scroll.dir)==true
img=%{<img border="0" height="15" width="15" src="#{@image_path}/b_doc.png" alt="Full Text" /> }
pth=@f.output_path.html_scroll.dir
rel=@f.output_path.html_scroll.rel_sm
url=@f.output_path.html_scroll.url
- id,file='HTML, full length document',@f.base_filename.html_scroll
- summarize(id,file,pth,rel,url,img)
+ desc,id,file='HTML, full length document','html_scroll',@f.base_filename.html_scroll
+ summarize(desc,id,file,pth,rel,url,img)
end
if FileTest.file?(@f.place_file.html_book_index.dir)==true
pth=@f.output_path.html_seg.dir
rel=@f.output_path.html_seg.rel_sm
url=@f.output_path.html_seg.url
- id,file='HTML, (book type) index',@f.base_filename.html_book_index
- summarize(id,file,pth,rel,url)
+ desc,id,file='HTML, (book type) index','html_book',@f.base_filename.html_book_index
+ summarize(desc,id,file,pth,rel,url)
end
if FileTest.file?(@f.place_file.html_concordance.dir)==true
pth=@f.output_path.html_seg.dir
rel=@f.output_path.html_seg.rel_sm
url=@f.output_path.html_seg.url
- id,file='HTML, concordance file',@f.base_filename.html_concordance
- summarize(id,file,pth,rel,url)
+ desc,id,file='HTML, concordance file','concordance',@f.base_filename.html_concordance
+ summarize(desc,id,file,pth,rel,url)
end
if FileTest.file?(@f.place_file.epub.dir)==true
img=%{<img border="0" height="18" width="18" src="#{@image_path}/b_epub.png" alt="EPUB" /> }
- id,file='EPUB (Electronic Publication, e-book standard)',@f.base_filename.epub
+ desc,id,file='EPUB (Electronic Publication, e-book standard)','epub',@f.base_filename.epub
pth=@f.output_path.epub.dir
rel=@f.output_path.epub.rel_sm
url=@f.output_path.epub.url
- summarize(id,file,pth,rel,url,img)
+ summarize(desc,id,file,pth,rel,url,img)
end
if FileTest.file?("#{@f.output_path.pdf.dir}/#{@f.base_filename.pdf_p_letter}")==true
img=%{<img border="0" height="18" width="15" src="#{@image_path}/b_pdf.png" alt="PDF portrait" /> }
pth=@f.output_path.pdf.dir
rel=@f.output_path.pdf.rel_sm
url=@f.output_path.pdf.url
- id,file="PDF, U.S. letter size, portrait/vertical document (recommended for printing)","#{@f.base_filename.pdf_p_letter}"
- summarize(id,file,pth,rel,url,img)
+ desc,id,file="PDF, U.S. letter size, portrait/vertical document (recommended for printing)",'pdf_letter',"#{@f.base_filename.pdf_p_letter}"
+ summarize(desc,id,file,pth,rel,url,img)
end
if FileTest.file?("#{@f.output_path.pdf.dir}/#{@f.base_filename.pdf_l_letter}")==true
img=%{<img border="0" height="15" width="18" src="#{@image_path}/b_pdf.png" alt="PDF landscape" /> }
pth=@f.output_path.pdf.dir
rel=@f.output_path.pdf.rel_sm
url=@f.output_path.pdf.url
- id,file="PDF, U.S. letter size, landscape/horizontal document (recommended for screen viewing)","#{@f.base_filename.pdf_l_letter}"
- summarize(id,file,pth,rel,url,img)
+ desc,id,file="PDF, U.S. letter size, landscape/horizontal document (recommended for screen viewing)",'pdf_letter_landscape',"#{@f.base_filename.pdf_l_letter}"
+ summarize(desc,id,file,pth,rel,url,img)
end
if FileTest.file?("#{@f.output_path.pdf.dir}/#{@f.base_filename.pdf_p_a4}")==true
img=%{<img border="0" height="18" width="15" src="#{@image_path}/b_pdf.png" alt="PDF portrait" /> }
pth=@f.output_path.pdf.dir
rel=@f.output_path.pdf.rel_sm
url=@f.output_path.pdf.url
- id,file="PDF, A4 size, portrait/vertical document (recommended for printing)","#{@f.base_filename.pdf_p_a4}"
- summarize(id,file,pth,rel,url,img)
+ desc,id,file="PDF, A4 size, portrait/vertical document (recommended for printing)",'pdf_a4',"#{@f.base_filename.pdf_p_a4}"
+ summarize(desc,id,file,pth,rel,url,img)
end
if FileTest.file?("#{@f.output_path.pdf.dir}/#{@f.base_filename.pdf_l_a4}")==true
img=%{<img border="0" height="15" width="18" src="#{@image_path}/b_pdf.png" alt="PDF landscape" /> }
pth=@f.output_path.pdf.dir
rel=@f.output_path.pdf.rel_sm
url=@f.output_path.pdf.url
- id,file="PDF, A4 size, landscape/horizontal document (recommended for screen viewing)","#{@f.base_filename.pdf_l_a4}"
- summarize(id,file,pth,rel,url,img)
+ desc,id,file="PDF, A4 size, landscape/horizontal document (recommended for screen viewing)",'pdf_a4_landscape',"#{@f.base_filename.pdf_l_a4}"
+ summarize(desc,id,file,pth,rel,url,img)
end
if FileTest.file?("#{@f.output_path.pdf.dir}/#{@f.base_filename.pdf_p_a5}")==true
img=%{<img border="0" height="18" width="15" src="#{@image_path}/b_pdf.png" alt="PDF portrait" /> }
pth=@f.output_path.pdf.dir
rel=@f.output_path.pdf.rel_sm
url=@f.output_path.pdf.url
- id,file="PDF, A5 (book) size, portrait/vertical document (recommended for printing)","#{@f.base_filename.pdf_p_a5}"
- summarize(id,file,pth,rel,url,img)
+ desc,id,file="PDF, A5 (book) size, portrait/vertical document (recommended for printing)",'pdf_a5',"#{@f.base_filename.pdf_p_a5}"
+ summarize(desc,id,file,pth,rel,url,img)
end
if FileTest.file?("#{@f.output_path.pdf.dir}/#{@f.base_filename.pdf_l_a5}")==true
img=%{<img border="0" height="15" width="18" src="#{@image_path}/b_pdf.png" alt="PDF landscape" /> }
pth=@f.output_path.pdf.dir
rel=@f.output_path.pdf.rel_sm
url=@f.output_path.pdf.url
- id,file="PDF, A5 (book) size, landscape/horizontal document (recommended for screen viewing)","#{@f.base_filename.pdf_l_a5}"
- summarize(id,file,pth,rel,url,img)
+ desc,id,file="PDF, A5 (book) size, landscape/horizontal document (recommended for screen viewing)",'pdf_a5_landscape',"#{@f.base_filename.pdf_l_a5}"
+ summarize(desc,id,file,pth,rel,url,img)
end
if FileTest.file?("#{@f.output_path.pdf.dir}/#{@f.base_filename.pdf_p_b5}")==true
img=%{<img border="0" height="18" width="15" src="#{@image_path}/b_pdf.png" alt="PDF portrait" /> }
pth=@f.output_path.pdf.dir
rel=@f.output_path.pdf.rel_sm
url=@f.output_path.pdf.url
- id,file="PDF, B5 (book) size, portrait/vertical document (recommended for printing)","#{@f.base_filename.pdf_p_b5}"
- summarize(id,file,pth,rel,url,img)
+ desc,id,file="PDF, B5 (book) size, portrait/vertical document (recommended for printing)",'pdf_b5',"#{@f.base_filename.pdf_p_b5}"
+ summarize(desc,id,file,pth,rel,url,img)
end
if FileTest.file?("#{@f.output_path.pdf.dir}/#{@f.base_filename.pdf_l_b5}")==true
img=%{<img border="0" height="15" width="18" src="#{@image_path}/b_pdf.png" alt="PDF landscape" /> }
pth=@f.output_path.pdf.dir
rel=@f.output_path.pdf.rel_sm
url=@f.output_path.pdf.url
- id,file="PDF, B5 (book) size, landscape/horizontal document (recommended for screen viewing)","#{@f.base_filename.pdf_l_b5}"
- summarize(id,file,pth,rel,url,img)
+ desc,id,file="PDF, B5 (book) size, landscape/horizontal document (recommended for screen viewing)",'pdf_a5_landscape',"#{@f.base_filename.pdf_l_b5}"
+ summarize(desc,id,file,pth,rel,url,img)
end
if FileTest.file?("#{@f.output_path.pdf.dir}/#{@f.base_filename.pdf_p_legal}")==true
img=%{<img border="0" height="18" width="15" src="#{@image_path}/b_pdf.png" alt="PDF portrait" /> }
pth=@f.output_path.pdf.dir
rel=@f.output_path.pdf.rel_sm
url=@f.output_path.pdf.url
- id,file="PDF, U.S. legal size, portrait/vertical document (recommended for printing)","#{@f.base_filename.pdf_p_legal}"
- summarize(id,file,pth,rel,url,img)
+ desc,id,file="PDF, U.S. legal size, portrait/vertical document (recommended for printing)",'pdf_legal',"#{@f.base_filename.pdf_p_legal}"
+ summarize(desc,id,file,pth,rel,url,img)
end
if FileTest.file?("#{@f.output_path.pdf.dir}/#{@f.base_filename.pdf_l_legal}")==true
img=%{<img border="0" height="15" width="18" src="#{@image_path}/b_pdf.png" alt="PDF landscape" /> }
pth=@f.output_path.pdf.dir
rel=@f.output_path.pdf.rel_sm
url=@f.output_path.pdf.url
- id,file="PDF, U.S. legal size, landscape/horizontal document (recommended for screen viewing)","#{@f.base_filename.pdf_l_legal}"
- summarize(id,file,pth,rel,url,img)
+ desc,id,file="PDF, U.S. legal size, landscape/horizontal document (recommended for screen viewing)",'pdf_legal_landscape',"#{@f.base_filename.pdf_l_legal}"
+ summarize(desc,id,file,pth,rel,url,img)
end
if FileTest.file?(@f.place_file.odt.dir)==true
img=%{<img border="0" height="18" width="18" src="#{@image_path}/b_odf.png" alt="ODF/ODT" /> }
pth=@f.output_path.odt.dir
rel=@f.output_path.odt.rel_sm
url=@f.output_path.odt.url
- id,file='ODF:ODT (Open Document Format)',@f.base_filename.odt
- summarize(id,file,pth,rel,url,img)
+ desc,id,file='ODF:ODT (Open Document Format)','odt',@f.base_filename.odt
+ summarize(desc,id,file,pth,rel,url,img)
end
if FileTest.file?(@f.place_file.xhtml.dir)==true
pth=@f.output_path.xhtml.dir
rel=@f.output_path.xhtml.rel_sm
url=@f.output_path.xhtml.url
- id,file='ODF:ODT (Open Document Format)',@f.base_filename.odt
- id,file='XHTML',@f.base_filename.xhtml
- summarize(id,file,pth,rel,url)
+ desc,id,file='XHTML','xhtml',@f.base_filename.xhtml
+ summarize(desc,id,file,pth,rel,url)
end
if FileTest.file?(@f.place_file.xml_sax.dir)==true
pth=@f.output_path.xml_sax.dir
rel=@f.output_path.xml_sax.rel_sm
url=@f.output_path.xml_sax.url
- id,file='XML SAX',@f.base_filename.xml_sax
- summarize(id,file,pth,rel,url)
+ desc,id,file='XML SAX','xml_sax',@f.base_filename.xml_sax
+ summarize(desc,id,file,pth,rel,url)
end
if FileTest.file?(@f.place_file.xml_dom.dir)==true
pth=@f.output_path.xml_dom.dir
rel=@f.output_path.xml_dom.rel_sm
url=@f.output_path.xml_dom.url
- id,file='XML DOM',@f.base_filename.xml_dom
- summarize(id,file,pth,rel,url)
+ desc,id,file='XML DOM','xml_dom',@f.base_filename.xml_dom
+ summarize(desc,id,file,pth,rel,url)
end
if FileTest.file?(@f.place_file.xml_docbook_article.dir)==true
pth=@f.output_path.xml_docbook_article.dir
rel=@f.output_path.xml_docbook_article.rel_sm
url=@f.output_path.xml_docbook_article.url
- id,file='XML Docbook Book',@f.base_filename.xml_docbook_article
- summarize(id,file,pth,rel,url)
+ desc,id,file='XML Docbook Article','docbook_article',@f.base_filename.xml_docbook_article
+ summarize(desc,id,file,pth,rel,url)
end
if FileTest.file?(@f.place_file.xml_docbook_book.dir)==true
pth=@f.output_path.xml_docbook_book.dir
rel=@f.output_path.xml_docbook_book.rel_sm
url=@f.output_path.xml_docbook_book.url
- id,file='XML Docbook Book',@f.base_filename.xml_docbook_book
- summarize(id,file,pth,rel,url)
+ desc,id,file='XML Docbook Book','docbook',@f.base_filename.xml_docbook_book
+ summarize(desc,id,file,pth,rel,url)
end
if FileTest.file?(@f.place_file.xml_fictionbook.dir)==true
pth=@f.output_path.xml_fictionbook.dir
rel=@f.output_path.xml_fictionbook.rel_sm
url=@f.output_path.xml_fictionbook.url
- id,file='XML Fictionbook',@f.base_filename.xml_fictionbook
- summarize(id,file,pth,rel,url)
+ desc,id,file='XML Fictionbook','fictionbook',@f.base_filename.xml_fictionbook
+ summarize(desc,id,file,pth,rel,url)
end
if FileTest.file?(@f.place_file.xml_scaffold_structure_sisu.dir)==true
pth=@f.output_path.xml_scaffold_structure_sisu.dir
rel=@f.output_path.xml_scaffold_structure_sisu.rel_sm
url=@f.output_path.xml_scaffold_structure_sisu.url
- id,file='XML Scaffold sisu structure',@f.base_filename.xml_scaffold_structure_sisu
- summarize(id,file,pth,rel,url)
+ desc,id,file='XML Scaffold sisu structure','xml_scaffold',@f.base_filename.xml_scaffold_structure_sisu
+ summarize(desc,id,file,pth,rel,url)
end
if FileTest.file?(@f.place_file.xml_scaffold_structure_collapse.dir)==true
pth=@f.output_path.xml_scaffold_structure_collapse.dir
rel=@f.output_path.xml_scaffold_structure_collapse.rel_sm
url=@f.output_path.xml_scaffold_structure_collapse.url
- id,file='XML Scaffold collapsed structure',@f.base_filename.xml_scaffold_structure_collapse
- summarize(id,file,pth,rel,url)
+ desc,id,file='XML Scaffold collapsed structure','xml_collapsed',@f.base_filename.xml_scaffold_structure_collapse
+ summarize(desc,id,file,pth,rel,url)
end
if FileTest.file?(@f.place_file.info.dir)==true
pth=@f.output_path.texinfo.dir
rel=@f.output_path.texinfo.rel_sm
url=@f.output_path.texinfo.url
- id,file='Info file',@f.base_filename.info
- summarize(id,file,pth,rel,url)
+ desc,id,file='Info file','info',@f.base_filename.info
+ summarize(desc,id,file,pth,rel,url)
end
if FileTest.file?(@f.place_file.manpage.dir)==true
pth=@f.output_path.manpage.dir
rel=@f.output_path.manpage.rel_sm
url=@f.output_path.manpage.url
- id,file='Manpage',@f.base_filename.manpage
- summarize(id,file,pth,rel,url)
+ desc,id,file='Manpage','manpage',@f.base_filename.manpage
+ summarize(desc,id,file,pth,rel,url)
end
if FileTest.file?(@f.place_file.sqlite_discrete.dir)==true
- id,file='SQLite3 file',@f.base_filename.sqlite_discrete
+ desc,id,file='SQLite3 file','sqlite',@f.base_filename.sqlite_discrete
pth=@f.output_path.sqlite_discrete.dir
rel=@f.output_path.sqlite_discrete.rel_sm
url=@f.output_path.sqlite_discrete.url
- summarize(id,file,pth,rel,url)
+ summarize(desc,id,file,pth,rel,url)
end
if FileTest.file?(@f.place_file.txt.dir)==true
- id='Plaintext (UTF-8)'
+ desc,id='Plaintext (UTF-8)','text'
pth=@f.output_path.txt.dir
rel=@f.output_path.txt.rel_sm
url=@f.output_path.txt.url
file=@f.base_filename.txt
- summarize(id,file,pth,rel,url)
+ summarize(desc,id,file,pth,rel,url)
end
if FileTest.file?(@f.place_file.textile.dir)==true
- id='Textile text (UTF-8)'
+ desc,id='Textile text (UTF-8)','textile'
pth=@f.output_path.textile.dir
rel=@f.output_path.textile.rel_sm
url=@f.output_path.textile.url
file=@f.base_filename.textile
- summarize(id,file,pth,rel,url)
+ summarize(desc,id,file,pth,rel,url)
end
if FileTest.file?(@f.place_file.asciidoc.dir)==true
- id='AsciiDoc text (UTF-8)'
+ desc,id='AsciiDoc text (UTF-8)','asciidoc'
pth=@f.output_path.asciidoc.dir
rel=@f.output_path.asciidoc.rel_sm
url=@f.output_path.asciidoc.url
file=@f.base_filename.asciidoc
- summarize(id,file,pth,rel,url)
+ summarize(desc,id,file,pth,rel,url)
end
if FileTest.file?(@f.place_file.markdown.dir)==true
- id='Markdown text (UTF-8)'
+ desc,id='Markdown text (UTF-8)','markdown'
pth=@f.output_path.markdown.dir
rel=@f.output_path.markdown.rel_sm
url=@f.output_path.markdown.url
file=@f.base_filename.markdown
- summarize(id,file,pth,rel,url)
+ summarize(desc,id,file,pth,rel,url)
end
if FileTest.file?(@f.place_file.rst.dir)==true
- id='rST text (UTF-8)'
+ desc,id='rST text (UTF-8)','rst'
pth=@f.output_path.rst.dir
rel=@f.output_path.rst.rel_sm
url=@f.output_path.rst.url
file=@f.base_filename.rst
- summarize(id,file,pth,rel,url)
+ summarize(desc,id,file,pth,rel,url)
+ end
+ if FileTest.file?(@f.place_file.orgmode.dir)==true
+ desc,id='OrgMode structure text (UTF-8)','org'
+ pth=@f.output_path.orgmode.dir
+ rel=@f.output_path.orgmode.rel_sm
+ url=@f.output_path.orgmode.url
+ file=@f.base_filename.orgmode
+ summarize(desc,id,file,pth,rel,url)
end
if FileTest.file?("#{@base_path}/#{@md.fns}.tex")==true
- id,file='LaTeX (portrait)',"#{@md.fns}.tex"
+ desc,id,file='LaTeX (portrait)','latex',"#{@md.fns}.tex"
pth,rel,url='','',''
- summarize(id,file,pth,rel,url)
+ summarize(desc,id,file,pth,rel,url)
end
if FileTest.file?("#{@base_path}/#{@md.fns}.tex")==true
- id,file='LaTeX (landscape)',"#{@md.fns}.landscape.tex"
+ desc,id,file='LaTeX (landscape)','latex_landscape',"#{@md.fns}.landscape.tex"
pth,rel,url='','',''
- summarize(id,file,pth,rel,url)
+ summarize(desc,id,file,pth,rel,url)
end
if FileTest.file?(@f.place_file.hash_digest.dir)==true
pth=@f.output_path.hash_digest.dir
rel=@f.output_path.hash_digest.rel_sm
url=@f.output_path.hash_digest.url
- id,file="Digest/DCC - Document Content Certificate (#{@dg})",@f.base_filename.hash_digest
- summarize(id,file,pth,rel,url)
+ desc,id,file="Digest/DCC - Document Content Certificate (#{@dg})",'digests',@f.base_filename.hash_digest
+ summarize(desc,id,file,pth,rel,url)
end
end
def published_versions
- id,file='Markup (SiSU source)',@md.fns
- languages(id,file)
+ desc,file='Markup (SiSU source)','source',@md.fns
+ languages(desc,file)
end
def language_versions
if FileTest.file?(@f.place_file.manifest.dir)==true
- id='Markup (SiSU source)'
- published_languages(id)
+ desc='Markup (SiSU source)'
+ published_languages(desc)
end
end
def qrc_image
@@ -582,165 +589,165 @@ WOK
pth=@f.output_path.src.dir
rel=@f.output_path.src.rel_sm
url=@f.output_path.src.url
- id,file='Markup Composite File (SiSU source)',@f.base_filename.src
- summarize_sources(id,file,pth,rel,url)
+ desc,id,file='Markup Composite File (SiSU source)','source',@f.base_filename.src
+ summarize_sources(desc,id,file,pth,rel,url)
end
else
if FileTest.file?(@f.place_file.src.dir)==true
pth=@f.output_path.src.dir
rel=@f.output_path.src.rel_sm
url=@f.output_path.src.url
- id,file='Markup (SiSU source)',@f.base_filename.src
- summarize_sources(id,file,pth,rel,url)
+ desc,id,file='Markup (SiSU source)','composite',@f.base_filename.src
+ summarize_sources(desc,id,file,pth,rel,url)
end
end
if FileTest.file?(@f.place_file.sisupod.dir)==true
pth=@f.output_path.sisupod.dir
rel=@f.output_path.sisupod.rel_sm
url=@f.output_path.sisupod.url
- id,file='SiSU doc (tar.xz)',@f.base_filename.sisupod
- summarize_sources(id,file,pth,rel,url)
+ desc,id,file='SiSUdoc pod (tar.xz)','sisupod',@f.base_filename.sisupod
+ summarize_sources(desc,id,file,pth,rel,url)
end
if FileTest.file?(@f.place_file.pot.dir)==true
pth=@f.output_path.pot.dir
rel=@f.output_path.pot.rel_sm
url=@f.output_path.pot.url
- id,file='SiSU pot',@f.base_filename.pot
- summarize_sources(id,file,pth,rel,url)
+ desc,id,file='SiSU pot','pot',@f.base_filename.pot
+ summarize_sources(desc,id,file,pth,rel,url)
end
end
def metadata_tests
if defined? @md.title #%
if defined? @md.title.full \
and @md.title.full=~/\S+/
- id,info=@translate.full_title,@md.title.full
- metadata(id,info)
+ desc,id,info=@translate.full_title,'title',@md.title.full
+ metadata(desc,id,info)
end
end
if defined? @md.creator #%
if defined? @md.creator.author \
and @md.creator.author=~/\S+/
- id,info=@translate.author,@md.creator.author
- metadata(id,info)
+ desc,id,info=@translate.author,'author',@md.creator.author
+ metadata(desc,id,info)
end
if defined? @md.creator.editor \
and @md.creator.editor=~/\S+/
- id,info=@translate.editor,@md.creator.editor
- metadata(id,info)
+ desc,id,info=@translate.editor,'editor',@md.creator.editor
+ metadata(desc,id,info)
end
if defined? @md.creator.contributor \
and @md.creator.contributor=~/\S+/
- id,info=@translate.contributor,@md.creator.contributor
- metadata(id,info)
+ desc,id,info=@translate.contributor,'contributor',@md.creator.contributor
+ metadata(desc,id,info)
end
if defined? @md.creator.translator \
and @md.creator.translator=~/\S+/
- id,info=@translate.translator,@md.creator.translator
- metadata(id,info)
+ desc,id,info=@translate.translator,'creator',@md.creator.translator
+ metadata(desc,id,info)
end
if defined? @md.creator.illustrator \
and @md.creator.illustrator=~/\S+/
- id,info=@translate.illustrator,@md.creator.illustrator
- metadata(id,info)
+ desc,id,info=@translate.illustrator,'illustrator',@md.creator.illustrator
+ metadata(desc,id,info)
end
if defined? @md.creator.prepared_by \
and @md.creator.prepared_by=~/\S+/
- id,info=@translate.prepared_by,@md.creator.prepared_by
- metadata(id,info)
+ desc,id,info=@translate.prepared_by,'prepared_by',@md.creator.prepared_by
+ metadata(desc,id,info)
end
if defined? @md.creator.digitized_by \
and @md.creator.digitized_by=~/\S+/
- id,info=@translate.digitized_by,@md.creator.digitized_by
- metadata(id,info)
+ desc,id,info=@translate.digitized_by,'designed_by',@md.creator.digitized_by
+ metadata(desc,id,info)
end
end
if defined? @md.rights
if defined? @md.rights.all \
and @md.rights.all=~/\S+/ #dc
- id,info=@translate.rights,@md.rights.all
- metadata(id,info)
+ desc,id,info=@translate.rights,'rights',@md.rights.all
+ metadata(desc,id,info)
end
end
if defined? @md.date #%
if defined? @md.date.published \
and @md.date.published=~/\S+/ #dc
- id,info=@translate.date,@md.date.published
- metadata(id,info)
+ desc,id,info=@translate.date,'date',@md.date.published
+ metadata(desc,id,info)
end
if defined? @md.date.created \
and @md.date.created=~/\S+/ #dc
- id,info=@translate.date_created,@md.date.created
- metadata(id,info)
+ desc,id,info=@translate.date_created,'date_created',@md.date.created
+ metadata(desc,id,info)
end
if defined? @md.date.issued \
and @md.date.issued=~/\S+/ #dc
- id,info=@translate.date_issued,@md.date.issued
- metadata(id,info)
+ desc,id,info=@translate.date_issued,'date_issued',@md.date.issued
+ metadata(desc,id,info)
end
if defined? @md.date.available \
and @md.date.available=~/\S+/ #dc
- id,info=@translate.date_available,@md.date.available
- metadata(id,info)
+ desc,id,info=@translate.date_available,'date_available',@md.date.available
+ metadata(desc,id,info)
end
if defined? @md.date.modified \
and @md.date.modified=~/\S+/ #dc
- id,info=@translate.date_modified,@md.date.modified
- metadata(id,info)
+ desc,id,info=@translate.date_modified,'date_modified',@md.date.modified
+ metadata(desc,id,info)
end
if defined? @md.date.valid \
and @md.date.valid=~/\S+/ #dc
- id,info=@translate.date_valid,@md.date.valid
- metadata(id,info)
+ desc,id,info=@translate.date_valid,'date_valid',@md.date.valid
+ metadata(desc,id,info)
end
end
if defined? @md.publisher \
and @md.publisher=~/\S+/ #dc
- id,info=@translate.publisher,@md.publisher
- metadata(id,info)
+ desc,id,info=@translate.publisher,'publisher',@md.publisher
+ metadata(desc,id,info)
end
if defined? @md.notes #%
if defined? @md.notes.description \
and @md.notes.description=~/\S+/
- id,info=@translate.description,@md.notes.description
- metadata(id,info)
+ desc,id,info=@translate.description,'description',@md.notes.description
+ metadata(desc,id,info)
end
if defined? @md.notes.abstract \
and @md.notes.abstract=~/\S+/
- id,info=@translate.abstract,@md.notes.abstract
- metadata(id,info)
+ desc,id,info=@translate.abstract,'abstract',@md.notes.abstract
+ metadata(desc,id,info)
end
if defined? @md.notes.comment \
and @md.notes.comment=~/\S+/
- id,info=@translate.comments,@md.notes.comment
- metadata(id,info)
+ desc,id,info=@translate.comments,'comment',@md.notes.comment
+ metadata(desc,id,info)
end
if defined? @md.notes.prefix_a \
and @md.notes.prefix_a=~/\S+/
- id,info=@translate.prefix_a,@md.notes.prefix_a
- metadata(id,info)
+ desc,id,info=@translate.prefix_a,'prefix',@md.notes.prefix_a
+ metadata(desc,id,info)
end
if defined? @md.notes.prefix_b \
and @md.notes.prefix_b=~/\S+/
- id,info=@translate.prefix_b,@md.notes.prefix_b
- metadata(id,info)
+ desc,id,info=@translate.prefix_b,'prefix_b',@md.notes.prefix_b
+ metadata(desc,id,info)
end
end
if defined? @md.title #%
if defined? @md.title.language \
and @md.title.language=~/\S+/
- id,info=@translate.language,@md.title.language
- metadata(id,info)
+ desc,id,info=@translate.language,'language',@md.title.language
+ metadata(desc,id,info)
end
if defined? @md.original.language \
and @md.original.language=~/\S+/
- id,info=@translate.language_original,@md.original.language
- metadata(id,info)
+ desc,id,info=@translate.language_original,'language_original',@md.original.language
+ metadata(desc,id,info)
end
end
if defined? @md.classify #%
if defined? @md.topic_register_array \
and @md.topic_register_array.length > 0
- @manifest[:html] << %{<tr><th class="left"><p class="bold_left">#{@translate.topic_register}:</p></th><td>\n}
+ @manifest[:html] << %{<tr><th class="left"><p class="bold_left" id="topics">#{@translate.topic_register}:</p></th><td>\n}
@md.topic_register_array.each do |t|
t.each_with_index do |st,i|
if st.is_a?(Array)
@@ -761,104 +768,104 @@ WOK
end
if defined? @md.classify.subject \
and @md.classify.subject=~/\S+/
- id,info=@translate.subject,@md.classify.subject
- metadata(id,info)
+ desc,id,info=@translate.subject,'subject',@md.classify.subject
+ metadata(desc,id,info)
end
if defined? @md.classify.keywords \
and @md.classify.keywords=~/\S+/
- id,info=@translate.keywords,@md.classify.keywords
- metadata(id,info)
+ desc,id,info=@translate.keywords,'keywords',@md.classify.keywords
+ metadata(desc,id,info)
end
if defined? @md.classify.loc \
and @md.classify.loc=~/\S+/
- id,info=@translate.cls_loc,@md.classify.loc
- metadata(id,info)
+ desc,id,info=@translate.cls_loc,'loc',@md.classify.loc
+ metadata(desc,id,info)
end
if defined? @md.classify.dewey \
and @md.classify.dewey=~/\S+/
- id,info=@translate.cls_dewey,@md.classify.dewey
- metadata(id,info)
+ desc,id,info=@translate.cls_dewey,'dewey',@md.classify.dewey
+ metadata(desc,id,info)
end
if defined? @md.notes.coverage \
and @md.notes.coverage=~/\S+/
- id,info=@translate.coverage,@md.notes.coverage
- metadata(id,info)
+ desc,id,info=@translate.coverage,'coverage',@md.notes.coverage
+ metadata(desc,id,info)
end
if defined? @md.notes.relation \
and @md.notes.relation=~/\S+/
- id,info=@translate.relation,@md.notes.relation
- metadata(id,info)
+ desc,id,info=@translate.relation,'relation',@md.notes.relation
+ metadata(desc,id,info)
end
if defined? @md.notes.type \
and @md.notes.type=~/\S+/ #dc
- id,info=@translate.type,@md.notes.type
- metadata(id,info)
+ desc,id,info=@translate.type,'type',@md.notes.type
+ metadata(desc,id,info)
end
if defined? @md.notes.format \
and @md.notes.format=~/\S+/
- id,info=@transate.format,@md.notes.format
- metadata(id,info)
+ desc,id,info=@transate.format,'format',@md.notes.format
+ metadata(desc,id,info)
end
end
if defined? @md.identifier #%
if defined? @md.identifier.oclc \
and @md.identifier.oclc=~/\S+/
- id,info=@translate.cls_oclc,@md.identifier.oclc
- @manifest[:html] << %{<tr><th class="left"><p class="bold_left">#{id}:</p></th><td>\n}
+ desc,id,info=@translate.cls_oclc,'',@md.identifier.oclc
+ @manifest[:html] << %{<tr><th class="left"><p class="bold_left">#{desc}:</p></th><td>\n}
@manifest[:html] << %{<p class="left"><a href="http://worldcat.org/oclc/#{info}">#{info}</a></p>\n}
@manifest[:html] << %{</td></tr>\n}
end
if defined? @md.identifier.pg \
and @md.identifier.pg=~/\S+/
- id,info=@translate.cls_gutenberg,@md.identifier.pg
- metadata(id,info)
+ desc,id,info=@translate.cls_gutenberg,'ocalc',@md.identifier.pg
+ metadata(desc,id,info)
end
if defined? @md.identifier.isbn \
and @md.identifier.isbn=~/\S+/
- id,info=@translate.cls_isbn,@md.identifier.isbn
- metadata(id,info)
+ desc,id,info=@translate.cls_isbn,'isbn',@md.identifier.isbn
+ metadata(desc,id,info)
end
end
if defined? @md.original.source \
and @md.original.source=~/\S+/
- id,info=@translate.source,@md.original.source
- metadata(id,info)
+ desc,id,info=@translate.source,'source_original',@md.original.source
+ metadata(desc,id,info)
end
if @md.fns
- id,info=@translate.sourcefile,@md.fns
- metadata(id,info)
+ desc,id,info=@translate.sourcefile,'source_filename',@md.fns
+ metadata(desc,id,info)
end
if @md.en[:mismatch] > 0
- id,info='WARNING document error in endnote markup, number mismatch',"endnotes: #{@md.en[:note]} != endnote reference marks: #{@md.en[:mark]} (difference = #{@md.en[:mismatch]})"
- metadata(id,info)
+ desc,id,info='WARNING document error in endnote markup, number mismatch','',"endnotes: #{@md.en[:note]} != endnote reference marks: #{@md.en[:mark]} (difference = #{@md.en[:mismatch]})"
+ metadata(desc,id,info)
end
if @md.wc_words
- id,info=@translate.word_count,@md.wc_words
- metadata(id,info)
+ desc,id,info=@translate.word_count,'wordcount',@md.wc_words
+ metadata(desc,id,info)
end
if @md.dgst
- id,info="#{@translate.sourcefile_digest} (#{@dg})",@md.dgst[1]
- metadata(id,info)
+ desc,id,info="#{@translate.sourcefile_digest} (#{@dg})",'digests',@md.dgst[1]
+ metadata(desc,id,info)
end
if @md.sc_number
- id,info=@translate.sc_number,@md.sc_number
- metadata(id,info)
+ desc,id,info=@translate.sc_number,'sc_number',@md.sc_number
+ metadata(desc,id,info)
end
if @md.sc_date
- id,info=@translate.sc_date,"#{@md.sc_date} at #{@md.sc_time}"
- metadata(id,info)
+ desc,id,info=@translate.sc_date,'sc_date',"#{@md.sc_date} at #{@md.sc_time}"
+ metadata(desc,id,info)
end
if @md.generated
- id,info=@translate.last_generated,@md.generated
- metadata(id,info)
+ desc,id,info=@translate.last_generated,'generated',@md.generated
+ metadata(desc,id,info)
end
- if @md.sisu_version
- id,info=@translate.sisu_version,"#{@md.sisu_version[:project]} #{@md.sisu_version[:version]} #{@md.sisu_version[:date_stamp]} (#{@md.sisu_version[:date]})#{@md.sisu_version[:install_method]}"
- metadata(id,info)
+ if @md.project_details
+ desc,id,info=@translate.sisu_version,'project',"#{@md.project_details.project} #{@md.project_details.version} #{@md.project_details.date_stamp} (#{@md.project_details.date})#{@md.project_details.install_method}"
+ metadata(desc,id,info)
end
if @md.ruby_version
- id,info=@translate.ruby_version,@md.ruby_version
- metadata(id,info)
+ desc,id,info=@translate.ruby_version,'ruby',@md.ruby_version
+ metadata(desc,id,info)
end
end
def links_tests
@@ -979,7 +986,7 @@ WOK
@manifest[:html] <<<<WOK
<h2 class="small"><a name="metadata">#{@translate.manifest_description_metadata}</a></h2>
<table summary="document metadata" width="100%" border="0" cellpadding="2" align="center">
-<tr> <th class="left"><p class="bold">#{@translate.metadata}</p></th><th class="left"><p class="bold">#{@translate.description}</p></th></tr>
+<tr> <th class="left"><p class="bold" id="metadata">#{@translate.metadata}</p></th><th class="left"><p class="bold">#{@translate.description}</p></th></tr>
WOK
metadata_tests
@manifest[:html] <<<<WOK
diff --git a/lib/sisu/current/html_minitoc.rb b/lib/sisu/current/html_minitoc.rb
index 902a68d..d2d890c 100644
--- a/lib/sisu/current/html_minitoc.rb
+++ b/lib/sisu/current/html_minitoc.rb
@@ -64,7 +64,6 @@
def initialize(md,data)
@md,@data=md,data
@pat_strip_heading_name=/<a name="h?\d.*?">(.+?)<\/a>/
- @ocn_html_identifier=SiSU_Env::ProcessingSettings.new(@md).ocn_html_identifier
@tell=SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set]) if @md
end
def songsheet
@@ -199,7 +198,7 @@
fn: @@seg_url,
}
f=@md.file.base_filename.html_seg(fnh)
- lnk_n_txt=%{ <a href="#{f}##{@ocn_html_identifier}#{txt.ocn}">
+ lnk_n_txt=%{ <a href="#{f}##{txt.ocn}">
#{txt.obj}
</a>}
txt_obj={ txt: lnk_n_txt }
@@ -218,7 +217,7 @@
fn: @@seg_url,
}
f=@md.file.base_filename.html_seg(fnh)
- lnk_n_txt=%{ <a href="#{f}##{@ocn_html_identifier}#{txt.ocn}">
+ lnk_n_txt=%{ <a href="#{f}##{txt.ocn}">
#{txt.obj}
</a>}
txt_obj={ txt: lnk_n_txt }
diff --git a/lib/sisu/current/html_parts.rb b/lib/sisu/current/html_parts.rb
index db7cdb7..ae828ed 100644
--- a/lib/sisu/current/html_parts.rb
+++ b/lib/sisu/current/html_parts.rb
@@ -293,7 +293,7 @@ module SiSU_Proj_HTML
#@date=SiSU_Env::InfoDate.new #{@date.year}
end
def txt_generator
- %{ <meta name="generator" content="#{@v[:project]} #{@v[:version]} of #{@v[:date_stamp]} (#{@v[:date]}) (n*x and Ruby!)" />
+ %{ <meta name="generator" content="#{@v.project} #{@v.version} of #{@v.date_stamp} (#{@v.date}) (n*x and Ruby!)" />
<link rel="generator" href="http://www.sisudoc.org/" />}
end
def widget_sisu_text
@@ -301,9 +301,9 @@ module SiSU_Proj_HTML
<p class="tiny"><font color="#666666" size="2">
Output generated by
<a href="#{the_url.sisu}">
- #{@v[:project]}
+ #{@v.project}
</a>
- #{@v[:version]} #{@v[:date]} (#{@v[:date_stamp]})
+ #{@v.version} #{@v.date} (#{@v.date_stamp})
</font></p>
WOK
end
@@ -362,7 +362,7 @@ WOK
<meta name="dc.publisher" content= "SiSU http://www.sisudoc.org/" />
<meta name="dc.language" content="en" />
<meta name="dc.rights" content="Copyright Ralph Amissah" />
-<meta name="generator" content="#{@v[:project]} #{@v[:version]} of #{@v[:date_stamp]} (#{@v[:date]}) (n*x and Ruby!)" />
+<meta name="generator" content="#{@v.project} #{@v.version} of #{@v.date_stamp} (#{@v.date}) (n*x and Ruby!)" />
<link rel="generator" href="http://www.sisudoc.org/" />
<link rel="stylesheet" href="./#{@dir.path.style}/harvest.css" type="text/css" />
<link rel="shortcut icon" href="./_sisu/image/rb7.ico" />
@@ -420,7 +420,7 @@ Outputs include: plaintext, HTML, EPUB, ODT (OpenDocumentText), (XHTML, XML,) La
</a>
</p>
<p class="tiny">
-#{@v[:project]} #{@v[:version]} of #{@v[:date_stamp]} (#{@v[:date]}) (n*x and Ruby!), #{@date.year_static}.
+#{@v.project} #{@v.version} of #{@v.date_stamp} (#{@v.date}) (n*x and Ruby!), #{@date.year_static}.
</p>
<p class="tiny">
w3 since October 3 1993.
diff --git a/lib/sisu/current/html_persist.rb b/lib/sisu/current/html_persist.rb
new file mode 100644
index 0000000..ff151ef
--- /dev/null
+++ b/lib/sisu/current/html_persist.rb
@@ -0,0 +1,237 @@
+# encoding: utf-8
+=begin
+
+* Name: SiSU
+
+** Description: documents, structuring, processing, publishing, search
+*** html segment generation, processing
+
+** Author: Ralph Amissah
+ <ralph@amissah.com>
+ <ralph.amissah@gmail.com>
+
+** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
+ 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah,
+ All Rights Reserved.
+
+** License: GPL 3 or later:
+
+ SiSU, a framework for document structuring, publishing and search
+
+ Copyright (C) Ralph Amissah
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the Free
+ Software Foundation, either version 3 of the License, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ more details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program. If not, see <http://www.gnu.org/licenses/>.
+
+ If you have Internet connection, the latest version of the GPL should be
+ available at these locations:
+ <http://www.fsf.org/licensing/licenses/gpl.html>
+ <http://www.gnu.org/licenses/gpl.html>
+
+ <http://www.sisudoc.org/sisu/en/manifest/gpl.fsf.html>
+
+** SiSU uses:
+ * Standard SiSU markup syntax,
+ * Standard SiSU meta-markup syntax, and the
+ * Standard SiSU object citation numbering and system
+
+** Hompages:
+ <http://www.jus.uio.no/sisu>
+ <http://www.sisudoc.org>
+
+** Git
+ <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=summary>
+ <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=blob;f=lib/sisu/current/html_persist.rb;hb=HEAD>
+
+=end
+module SiSU_HTML_Persist
+ class Persist
+ @@persist=nil
+ attr_accessor :is0,:is1,:is2,:is3,:is4,:heading0,:heading1,:heading2,:heading3,:heading4, :title, :dot_nav, :tocband_banner, :tocband_bannerless, :headings, :heading_endnotes, :main, :endnote_all, :tail, :credits, :heading_idx, :idx, :seg_endnotes, :seg_endnotes_array, :segtocband, :get_hash_fn, :get_hash_to, :seg_subtoc, :seg_subtoc_array, :fn, :seg_name ,:seg_name_x,:seg_name_x_tracker
+ def initialize(args=nil)
+ @@persist=args=(args ? args : (@@persist || persist_init_hash_values))
+ @is0=args[:is0]
+ @is1=args[:is1]
+ @is2=args[:is2]
+ @is3=args[:is3]
+ @is4=args[:is4]
+ @heading0=args[:heading0]
+ @heading1=args[:heading1]
+ @heading2=args[:heading2]
+ @heading3=args[:heading3]
+ @heading4=args[:heading4]
+ @title=args[:title]
+ @dot_nav=args[:dot_nav]
+ @tocband_banner=args[:tocband_banner]
+ @tocband_bannerless=args[:tocband_bannerless]
+ @headings=args[:headings]
+ @heading_endnotes=args[:heading_endnotes]
+ @main=args[:main]
+ @endnote_all=args[:endnote_all]
+ @tail=args[:tail]
+ @credits=args[:credits]
+ @heading_idx=args[:heading_idx]
+ @idx=args[:idx]
+ @seg_endnotes=args[:seg_endnotes]
+ @seg_endnotes_array=args[:seg_endnotes_array]
+ @get_hash_to=args[:get_hash_to]
+ @get_hash_fn=args[:get_hash_fn]
+ @seg_subtoc=args[:seg_subtoc]
+ @seg_subtoc_array=args[:seg_subtoc_array]
+ @segtocband=args[:fn]
+ @fn=args[:fn]
+ @seg_name=args[:seg_name]
+ @seg_name_x=args[:seg_name_x]
+ @seg_name_x_tracker=args[:seg_name_x_tracker]
+ end
+ def is0
+ @is0
+ end
+ def is1
+ @is1
+ end
+ def is2
+ @is2
+ end
+ def is3
+ @is3
+ end
+ def is4
+ @is4
+ end
+ def heading0
+ @heading0
+ end
+ def heading1
+ @heading1
+ end
+ def heading2
+ @heading2
+ end
+ def heading3
+ @heading3
+ end
+ def heading4
+ @heading4
+ end
+ def title
+ @title
+ end
+ def dot_nav
+ @dot_nav
+ end
+ def tocband_banner
+ @tocband_banner
+ end
+ def tocband_bannerless
+ @tocband_bannerless
+ end
+ def headings
+ @headings
+ end
+ def heading_endnotes
+ @heading_endnotes
+ end
+ def main
+ @main
+ end
+ def endnote_all
+ @endnote_all
+ end
+ def tail
+ @tail
+ end
+ def credits
+ @credits
+ end
+ def heading_idx
+ @heading_idx
+ end
+ def idx
+ @idx
+ end
+ def seg_endnotes
+ @seg_endnotes
+ end
+ def seg_endnotes_array
+ @seg_endnotes_array
+ end
+ def get_hash_to
+ @get_hash_to
+ end
+ def get_hash_fn
+ @get_hash_fn
+ end
+ def seg_subtoc
+ @seg_subtoc
+ end
+ def seg_subtoc_array
+ @seg_subtoc_array
+ end
+ def segtocband
+ @segtocband
+ end
+ def fn
+ @fn
+ end
+ def seg_name
+ @seg_name
+ end
+ def seg_name_x
+ @seg_name_x
+ end
+ def seg_name_x_tracker
+ @seg_name_x_tracker
+ end
+ def persist_init_hash_values
+ {
+ is0: 0,
+ is1: 0,
+ is2: 0,
+ is3: 0,
+ is4: 0,
+ heading0: '',
+ heading1: '',
+ heading2: '',
+ heading3: '',
+ heading4: '',
+ tocband_banner: [],
+ tocband_bannerless: [],
+ title: [],
+ headings: [],
+ main: [],
+ idx: [],
+ tail: [],
+ credits: [],
+ endnote_all: [],
+ heading_endnotes: '',
+ seg_endnotes: {},
+ seg_endnotes_array: [],
+ get_hash_fn: '',
+ get_hash_to: '',
+ seg_subtoc: {},
+ seg_subtoc_array: [],
+ segtocband: '',
+ fn: '',
+ seg_name: [],
+ seg_name_x: [],
+ seg_name_x_tracker: 0,
+ }
+ end
+ def persist_init
+ @@persist=nil
+ Persist.new(persist_init_hash_values)
+ end
+ end
+end
+__END__
diff --git a/lib/sisu/current/html_segments.rb b/lib/sisu/current/html_segments.rb
index 3288b8f..4b413b0 100644
--- a/lib/sisu/current/html_segments.rb
+++ b/lib/sisu/current/html_segments.rb
@@ -57,12 +57,13 @@
module SiSU_HTML_Seg
require_relative 'html_shared' # html_shared.rb
require_relative 'html' # html.rb
+ require_relative 'html_persist' # html_persist.rb
require_relative 'html_promo' # html_promo.rb
require_relative 'shared_metadata' # shared_metadata.rb
class Output
- def initialize(md,outputfile,seg,minitoc,type='')
- @md, @output_seg_file,@seg,@minitoc,@type=
- md,outputfile, seg,minitoc, type
+ def initialize(md,outputfile,per,minitoc,type='')
+ @md, @output_seg_file,@per,@minitoc,@type=
+ md,outputfile, per,minitoc, type
@title_banner_=SiSU_Env::CreateSite.new(@md.opt).html_seg_title_banner?
@file=SiSU_Env::FileOp.new(@md)
@make=SiSU_Env::ProcessingSettings.new(@md)
@@ -71,67 +72,68 @@ module SiSU_HTML_Seg
: 'content0'
end
def output
- if @seg[:title] =~/\S/
+ if @per.title =~/\S/
filename_seg=[]
if @make.build.html_top_band?
filename_seg \
- << @seg[:title] \
- << @seg[:tocband_banner]
+ << @per.title \
+ << @per.tocband_banner
else
filename_seg \
- << @seg[:title]
+ << @per.title
end
if @type=='endnotes'
- @seg[:headings]=[]
+ @per.headings=[]
format_head_seg=SiSU_HTML_Format::HeadSeg.new(@md)
if @title_banner_
- @seg[:headings] \
+ @per.headings \
<< format_head_seg.
title_banner(@md.title.main,@md.title.sub,@author)
end
txt_obj={ txt: 'Endnotes', ocn_display: '' }
format_seg=SiSU_HTML_Format::FormatSeg.new(@md,txt_obj)
- @seg[:headings] \
+ @per.headings \
<< format_seg.title_heading1
filename_seg \
- << @seg[:heading_endnotes] \
- << @minitoc << @seg[:headings] \
+ << @per.heading_endnotes \
+ << @minitoc << @per.headings \
<< %{\n<div class="#{@cl}">\n} \
- << @seg[:endnote_all] \
+ << @per.endnote_all \
<< '</div>' # << '</div>'
elsif @type=='idx'
- @seg[:headings]=[]
+ @per.headings=[]
format_head_seg=SiSU_HTML_Format::HeadSeg.new(@md)
if @title_banner_
- @seg[:headings] \
+ @per.headings \
<< format_head_seg.
title_banner(@md.title.main,@md.title.sub,@author)
end
txt_obj={ txt: 'Index', ocn_display: '' }
format_seg=SiSU_HTML_Format::FormatSeg.new(@md,txt_obj)
- @seg[:headings] << format_seg.title_heading1
+ @per.headings << format_seg.title_heading1
filename_seg \
- << @seg[:heading_idx] \
- << @minitoc << @seg[:headings] \
+ << @per.heading_idx \
+ << @minitoc << @per.headings \
<< %{\n<div class="#{@cl}">\n} \
- << @seg[:idx] \
+ << @per.idx \
<< '</div>' # << '</div>'
elsif @type=='metadata'
metadata=SiSU_Metadata::Summary.new(@md).html_display.metadata
- @seg[:headings]=[]
+ @per.headings=[]
format_head_seg=SiSU_HTML_Format::HeadSeg.new(@md)
if @title_banner_
- @seg[:headings] \
+ @per.headings \
<< format_head_seg.
title_banner(@md.title.main,@md.title.sub,@author)
end
txt_obj={ txt: 'Metadata', ocn_display: '' }
format_seg=SiSU_HTML_Format::FormatSeg.new(@md,txt_obj)
- @seg[:headings] << format_seg.title_heading1
+ @per.headings \
+ << format_seg.title_heading1
filename_seg \
- << @seg[:heading_idx] \
+ << @per.heading_idx \
<< @minitoc \
- << @seg[:headings] \
+ << @per.headings \
<< %{\n<div class="#{@cl}">\n} \
<< metadata \
<< '</div>' # << '</div>'
@@ -139,23 +141,23 @@ module SiSU_HTML_Seg
if @make.build.html_top_band?
filename_seg \
<< @minitoc \
- << @seg[:headings] \
- << @seg[:main] \
+ << @per.headings \
+ << @per.main \
<< "\n</div>\n"
else
filename_seg \
<< @minitoc \
- << @seg[:main] \
+ << @per.main \
<< "\n</div>\n"
end
end
filename_seg <<=if @make.build.html_top_band?
- @seg[:tail] \
- << @seg[:tocband_bannerless] \
- << @seg[:credits]
+ @per.tail \
+ << @per.tocband_bannerless \
+ << @per.credits
else
- @seg[:tail] \
- << @seg[:credits]
+ @per.tail \
+ << @per.credits
end
filename_seg=filename_seg.flatten.compact #watch
filename_seg.each do |str|
@@ -173,32 +175,15 @@ module SiSU_HTML_Seg
end
end
class Seg
- @@seg,@@seg_subtoc,@@seg_endnotes,@@seg_ad={},{},{},{}
- @@seg_name,@@seg_name_html=[],[]
- @@seg_url=@@fn=@@get_hash_to=@@get_hash_fn=''
- @@loop_count=@@seg_total=@@tracker=0
- @@is4=@@is3=@@is2=@@is1=@@is0=0
- @@heading0=@@heading1=@@heading2=@@heading3=@@heading4=0
- @@seg[:tocband_banner],
- @@seg[:tocband_bannerless],
- @@seg[:title],@@seg[:headings],
- @@seg[:main],
- @@seg[:idx],
- @@seg[:tail],
- @@seg[:credits],
- @@seg_subtoc_array,
- @@seg_endnotes_array,
- @@seg[:endnote_all]=
- Array.new(11){[]}
- @@seg[:heading_endnotes]=''
- @@tablehead,@@number_of_cols=0,0
- @@dp,@@segtocband=nil,nil
- @@fns_previous=''
- attr_reader :seg_name_html,:seg_name_html_tracker
+ @@seg_url=''
+ @@tracker=0
+ @@seg_name=[]
+ attr_reader :seg_name_x,:seg_name_x_tracker
def initialize(md=nil,data='')
@md,@data=md,data
- @seg_name_html=@@seg_name_html || nil
- @seg_name_html_tracker=@@tracker || nil
+ @per=SiSU_HTML_Persist::Persist.new
+ @seg_name_x=@per.seg_name_x=(@@seg_name || [])
+ @seg_name_x_tracker=@per.seg_name_x_tracker=(@@tracker || 0)
@env=SiSU_Env::InfoEnv.new(@md.fns) if @md
if @md
@make=SiSU_Env::ProcessingSettings.new(@md)
@@ -214,22 +199,24 @@ module SiSU_HTML_Seg
def songsheet
begin
@minitoc=SiSU_HTML::Source::Toc.new(@md,@data).minitoc
- data=get_subtoc_endnotes(@data)
- data=articles(data)
- SiSU_HTML_Seg::Seg.new.cleanup # (((( added ))))
+ @per=SiSU_HTML_Persist::Persist.new
+ data=get_subtoc_endnotes(@data,@per)
+ data=articles(data,@per)
+ cleanup(@md,@per) # (((( added ))))
#### (((( END )))) ####
rescue
SiSU_Errors::Rescued.new($!,$@,@md.opt.selections.str,@md.fns).location do
__LINE__.to_s + ':' + __FILE__
end
ensure
- @@seg_name=[]
+ SiSU_HTML_Persist::Persist.new.persist_init
+ @@seg_name=@per.seg_name=[]
end
end
protected
- def articles(data)
+ def articles(data,per)
+ @per=per
tracking,newfile=0,0
- @@is4=@@is3=@@is2=@@is1=@@is0=0
printed_endnote_seg='n'
idx_html=nil
if @md.book_idx
@@ -237,27 +224,28 @@ module SiSU_HTML_Seg
idx_html=SiSU_Particulars::CombinedSingleton.
instance.get_idx_html(@md.opt).html_idx
idx_html.each do |x|
- @@seg[:idx] << x
+ @per.idx << x
end
- @@seg[:heading_idx]=''
+ @per.heading_idx=''
end
data.each do |dob|
if (dob.is == :heading \
|| dob.is == :heading_insert) \
&& dob.ln == 4
@@seg_name << dob.name
+ @per.seg_name = @@seg_name
dob.name
end
end
- @@seg_name_html=@@seg_name
- @@seg_total=@@seg_name.length
- testforartnum=@@seg_name_html
+ @per.seg_name_x=@per.seg_name
+ @per.seg_name.length
+ testforartnum=@per.seg_name_x
if (@md.opt.act[:verbose][:set]==:on \
|| @md.opt.act[:verbose_plus][:set]==:on \
|| @md.opt.act[:maintenance][:set]==:on)
SiSU_Screen::Ansi.new(
@md.opt.act[:color_state][:set],
- @@seg_name.length
+ @per.seg_name.length
).segmented
end
map_nametags=SiSU_Particulars::CombinedSingleton.
@@ -285,41 +273,41 @@ module SiSU_HTML_Seg
if (dob.is==:heading \
|| dob.is==:heading_insert) \
&& dob.ln==4
- @@heading4=dob.obj
- @@is4=newfile=1
+ @per.heading4=dob.obj
+ @per.is4=newfile=1
end
if (dob.is==:heading \
|| dob.is==:heading_insert) \
&& dob.ln==3
- @@heading3=dob.obj
- @@is4,@@is3=0,1
+ @per.heading3=dob.obj
+ @per.is4,@per.is3=0,1
end
if (dob.is==:heading \
|| dob.is==:heading_insert) \
&& dob.ln==2
- @@heading2=dob.obj
- @@is4,@@is3,@@is2=0,0,1
+ @per.heading2=dob.obj
+ @per.is4,@per.is3,@per.is2=0,0,1
end
if (dob.is==:heading \
|| dob.is==:heading_insert) \
&& dob.ln==1
- @@heading1=dob.obj
- @@is4,@@is3,@@is2,@@is1=0,0,0,1
+ @per.heading1=dob.obj
+ @per.is4,@per.is3,@per.is2,@per.is1=0,0,0,1
end
if (dob.is==:heading \
|| dob.is==:heading_insert) \
&& dob.ln==0
- @@heading0=dob.obj
- @@is4,@@is3,@@is2,@@is1,@@is0=0,0,0,0,1
+ @per.heading0=dob.obj
+ @per.is4,@per.is3,@per.is2,@per.is1,@per.is0=0,0,0,0,1
end
- if (@@is1 && !@@is2 && !@@is3 && !@@is4)
+ if (@per.is1 && !@per.is2 && !@per.is3 && !@per.is4)
if not (dob.is==:heading \
|| dob.is==:heading_insert) \
&& dob.ln==0
$_ #; check
end
end
- if @@is4==1
+ if @per.is4==1
if newfile==1 \
or dob.obj =~/^#{Mx[:br_endnotes]}|^#{Mx[:br_eof]}/
newfile=0
@@ -332,43 +320,46 @@ module SiSU_HTML_Seg
FileUtils::mkdir_p(@file.output_path.html_seg.dir) \
if File.writable?("#{@file.output_path.base.dir}/.")
end
- SiSU_HTML_Seg::Seg.new(@md).tail
+ tail(@md,@per)
+ #SiSU_HTML_Seg::Seg.new(@md,@per).tail
fnh={
- fn: @@seg_name_html[tracking-1],
+ fn: @per.seg_name_x[tracking-1],
}
fn=@md.file.base_filename.html_seg(fnh)
segfilename="#{@file.output_path.html_seg.dir}/#{fn}"
- output_seg_file=File.new(segfilename,'w') if @@seg_name_html[tracking-1]
+ output_seg_file=File.new(segfilename,'w') if @per.seg_name_x[tracking-1]
minitoc=(@make.build.html_minitoc?) ? @minitoc : ''
if dob.is==:heading \
- || (@@seg_name_html[tracking-1] !~/endnotes|book_index|metadata/)
- SiSU_HTML_Seg::Output.new(@md,output_seg_file,@@seg,minitoc).output
+ || (@per.seg_name_x[tracking-1] !~/endnotes|book_index|metadata/)
+ SiSU_HTML_Seg::Output.new(@md,output_seg_file,@per,minitoc).output
elsif dob.is==:heading_insert
- if @@seg_name_html[tracking-1]=='endnotes'
- SiSU_HTML_Seg::Output.new(@md,output_seg_file,@@seg,minitoc,'endnotes').output
- elsif @@seg_name_html[tracking-1]=='book_index'
- SiSU_HTML_Seg::Output.new(@md,output_seg_file,@@seg,minitoc,'idx').output
- @@seg[:idx]=[]
- elsif @@seg_name_html[tracking-1]=='metadata'
- SiSU_HTML_Seg::Output.new(@md,output_seg_file,@@seg,minitoc,'metadata').output
+ if @per.seg_name_x[tracking-1]=='endnotes'
+ SiSU_HTML_Seg::Output.new(@md,output_seg_file,@per,minitoc,'endnotes').output
+ elsif @per.seg_name_x[tracking-1]=='book_index'
+ SiSU_HTML_Seg::Output.new(@md,output_seg_file,@per,minitoc,'idx').output
+ @per.idx=[]
+ elsif @per.seg_name_x[tracking-1]=='metadata'
+ SiSU_HTML_Seg::Output.new(@md,output_seg_file,@per,minitoc,'metadata').output
else puts "#{__FILE__}::#{__LINE__}"
end
else puts "#{__FILE__}::#{__LINE__}"
end
- SiSU_HTML_Seg::Seg.new.reinitialise
+ SiSU_HTML_Seg::Seg.new.reinitialise(per)
+ #per=persist_init
heading_art(dob)
head(dob)
#keep use for last segment, eg if metadata is last segment
- if @@seg_name_html[tracking] =='metadata' # this is for metadata
- fnh={
- fn: @@seg_name_html[tracking],
- }
- fn=@md.file.base_filename.html_seg(fnh)
- segfilename="#{@file.output_path.html_seg.dir}/#{fn}"
- output_seg_file=File.new(segfilename,'w')
- SiSU_HTML_Seg::Output.new(@md,output_seg_file,@@seg,minitoc,'metadata').output
- Seg.new.reinitialise
- end
+ if @per.seg_name_x[tracking] =='metadata' # this is for metadata
+ fnh={
+ fn: @per.seg_name_x[tracking],
+ }
+ fn=@md.file.base_filename.html_seg(fnh)
+ segfilename="#{@file.output_path.html_seg.dir}/#{fn}"
+ output_seg_file=File.new(segfilename,'w')
+ SiSU_HTML_Seg::Output.new(@md,output_seg_file,@per,minitoc,'metadata').output
+ #per=persist_init
+ Seg.new.reinitialise(per)
+ end
end
if tracking==0
heading_art(dob)
@@ -381,8 +372,8 @@ module SiSU_HTML_Seg
|| dob.is==:heading_insert) \
&& dob.ln==4 \
&& dob.name
- @@get_hash_to=dob.name
- @@get_hash_fn=dob.name
+ @per.get_hash_to=dob.name
+ @per.get_hash_fn=dob.name
end
if dob.obj.is_a?(String)
markup(dob)
@@ -402,108 +393,108 @@ module SiSU_HTML_Seg
end
def heading_art(dob)
format_head_seg=SiSU_HTML_Format::HeadSeg.new(@md)
- @@seg[:dot_nav]=if (@make.build.html_navigation?) \
+ @per.dot_nav=if (@make.build.html_navigation?) \
&& (@make.build.html_navigation_bar?)
x=if (dob.is==:heading \
|| dob.is==:heading_insert) \
&& (dob.ln.to_s =~/^[0-7]/)
- x=if @@tracker < @@seg_total-1
+ x=if @@tracker < @per.seg_name.length-1
format_head_seg.dot_control_pre_next
else
format_head_seg.dot_control_pre
end
- else @@seg[:dot_nav]
+ else @per.dot_nav
end
- else @@seg[:dot_nav]=''
+ else @per.dot_nav=''
end
ads=SiSU_HTML_Promo::Ad.new(@md)
- @@seg[:title]=format_head_seg.head_seg << ads.div.major
+ @per.title=format_head_seg.head_seg << ads.div.major
end
def head(dob)
clean=/<!.*?!>|<:.*?>/
format_head_seg=SiSU_HTML_Format::HeadSeg.new(@md)
if @make.build.html_navigation?
- if @@tracker < @@seg_total-1
- @@segtocband=if @@tracker==0
+ if @@tracker < @per.seg_name.length-1
+ @per.segtocband=if @@tracker==0
format_head_seg.toc_next2
else
format_head_seg.toc_pre_next2
end
- else @@segtocband=format_head_seg.toc_pre2
+ else @per.segtocband=format_head_seg.toc_pre2
end
- else @@segtocband=''
+ else @per.segtocband=''
end
@p_num ||= ''
- if @@is0==1
+ if @per.is0==1
@author=%{<b>#{@md.author}</b>\n} if @md.author.to_s =~/\S/
- @@seg[:tocband_banner] \
- << format_head_seg.navigation_band(@@segtocband,@@seg[:dot_nav])
- @@seg[:tocband_bannerless] \
+ @per.tocband_banner \
+ << format_head_seg.navigation_band(@per.segtocband,@per.dot_nav)
+ @per.tocband_bannerless \
<< '<br>' \
- << format_head_seg.navigation_band_bottom(@@segtocband,@@seg[:dot_nav])
+ << format_head_seg.navigation_band_bottom(@per.segtocband,@per.dot_nav)
if @title_banner_
- @@seg[:headings] \
+ @per.headings \
<< format_head_seg.title_banner(@md.title.main,@md.title.sub,@author).gsub(clean,'')
end
- ocn=(@@heading0[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/]) \
+ ocn=(@per.heading0[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/]) \
? $1
: ''
@p_num=SiSU_HTML_Format::ParagraphNumber.new(@md,ocn)
- txt_obj={ txt: @@heading0, ocn_display: @p_num.ocn_display }
+ txt_obj={ txt: @per.heading0, ocn_display: @p_num.ocn_display }
format_seg=SiSU_HTML_Format::FormatSeg.new(@md,txt_obj)
- @@seg[:headings] \
+ @per.headings \
<< format_seg.title_heading0.gsub(clean,'')
- @@heading0=@@heading0.
+ @per.heading0=@per.heading0.
gsub(/&nbsp;<a name="-[\d*+]+" href="#_[\d*+]+">&nbsp;<sup>[\d*+]+<\/sup>&nbsp;<\/a>/,'')
end
- if @@is1==1
- heading1=@@heading1
+ if @per.is1==1
+ heading1=@per.heading1
ocn=(heading1[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/]) \
? $1
: ''
@p_num=SiSU_HTML_Format::ParagraphNumber.new(@md,ocn)
txt_obj={ txt: heading1, ocn_display: @p_num.ocn_display }
format_seg=SiSU_HTML_Format::FormatSeg.new(@md,txt_obj)
- @@seg[:headings] \
+ @per.headings \
<< format_seg.title_heading1.gsub(clean,'')
- @@heading1=@@heading1.
+ @per.heading1=@per.heading1.
gsub(/&nbsp;<a name="-[\d*+]+" href="#_[\d*+]+">&nbsp;<sup>[\d*+]+<\/sup>&nbsp;<\/a>/,'')
end
- if @@is2==1
- heading2=@@heading2
+ if @per.is2==1
+ heading2=@per.heading2
ocn=(heading2[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/]) \
? $1
: ''
@p_num=SiSU_HTML_Format::ParagraphNumber.new(@md,ocn)
txt_obj={ txt: heading2, ocn_display: @p_num.ocn_display }
format_seg=SiSU_HTML_Format::FormatSeg.new(@md,txt_obj)
- @@seg[:headings] \
+ @per.headings \
<< format_seg.title_heading2.gsub(clean,'')
- @@heading2=@@heading2.
+ @per.heading2=@per.heading2.
gsub(/&nbsp;<a name="-[\d*+]+" href="#_[\d*+]+">&nbsp;<sup>[\d*+]+<\/sup>&nbsp;<\/a>/,'')
end
- if @@is3==1
- heading3=@@heading3
+ if @per.is3==1
+ heading3=@per.heading3
ocn=(heading3[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/]) \
? $1
: ''
@p_num=SiSU_HTML_Format::ParagraphNumber.new(@md,ocn)
txt_obj={ txt: heading3, ocn_display: @p_num.ocn_display }
format_seg=SiSU_HTML_Format::FormatSeg.new(@md,txt_obj)
- @@seg[:headings] \
+ @per.headings \
<< format_seg.title_heading3.gsub(clean,'')
- @@heading3=@@heading3.
+ @per.heading3=@per.heading3.
gsub(/&nbsp;<a name="-[\d*+]+" href="#_[\d*+]+">&nbsp;<sup>[\d*+]+<\/sup>&nbsp;<\/a>/,'')
end
- if @@is4==1
- heading4=@@heading4
+ if @per.is4==1
+ heading4=@per.heading4
ocn=(heading4[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/]) \
? $1
: ''
@p_num=SiSU_HTML_Format::ParagraphNumber.new(@md,ocn)
txt_obj={ txt: heading4, ocn_display: @p_num.ocn_display }
format_seg=SiSU_HTML_Format::FormatSeg.new(@md,txt_obj)
- @@seg[:headings] \
+ @per.headings \
<< format_seg.title_heading4.gsub(clean,'')
end
@@tracker=@@tracker+1
@@ -586,66 +577,73 @@ module SiSU_HTML_Seg
if (dob.is==:heading \
|| dob.is==:heading_insert) \
&& dob.ln==4
- @@seg[:main] << %{\n<div class="#{@cl}">\n}
- @@seg[:main] << dob_html
+ @per.main << %{\n<div class="#{@cl}">\n}
+ @per.main << dob_html
if @make.build.segsubtoc?
- @@seg[:main] << @@seg_subtoc[@@get_hash_fn] #% insertion of sub-toc
+ @per.main << @per.seg_subtoc[@per.get_hash_fn] #% insertion of sub-toc
end
else
- @@seg[:main] << dob_html #unless @@flag_alt==true
+ @per.main << dob_html #unless @@flag_alt==true
end
end
end
- def tail
+ def tail(md,per)
+ @md,@per=md,per
format_head_seg=SiSU_HTML_Format::HeadSeg.new(@md)
- if @md.flag_auto_endnotes and @@seg_endnotes[@@get_hash_fn]
- @@seg[:tail] << %{\n<div class="#{@cl}">\n<div class="endnote">\n}
- if @@seg_endnotes[@@get_hash_fn].flatten.length > 0
- @@seg[:tail] << format_head_seg.endnote_mark
- @@seg[:tail] << @@seg_endnotes[@@get_hash_fn].flatten #endnotes deposited at end of individual segments ||@|EXTRACTION OF ENDNOTES|
+ if @md.flag_auto_endnotes \
+ and @per.seg_endnotes[@per.get_hash_fn]
+ @per.tail << %{\n<div class="#{@cl}">\n<div class="endnote">\n}
+ if @per.seg_endnotes[@per.get_hash_fn].flatten.length > 0
+ @per.tail << format_head_seg.endnote_mark
+ @per.tail << @per.seg_endnotes[@per.get_hash_fn].flatten #endnotes deposited at end of individual segments ||@|EXTRACTION OF ENDNOTES|
end
- @@seg[:tail] << '</div>'
- @@seg[:tail] << '</div>' #this div closes div class content
+ @per.tail << '</div>'
+ @per.tail << '</div>' #this div closes div class content
end
ads=SiSU_HTML_Promo::Ad.new(@md)
- @@seg[:credits] << format_head_seg.credit << ads.div.close << ads.display << format_head_seg.html_close
+ @per.credits \
+ << format_head_seg.credit \
+ << ads.div.close \
+ << ads.display \
+ << format_head_seg.html_close
end
- def reinitialise
- @@seg[:title],@@seg[:dot_nav],@@seg[:tocband_banner],@@seg[:tocband_bannerless],@@seg[:headings],@@seg[:main],@@seg[:tail],@@seg[:credits]=Array.new(8){[]}
- @@segtocband=nil
+ def reinitialise(per)
+ per.title,per.dot_nav,per.tocband_banner,per.tocband_bannerless,per.headings,per.main,per.tail,per.credits=Array.new(8){[]}
+ @per.segtocband=nil
end
- def cleanup
- reinitialise
- @@seg_total,@@tracker=0,0
- @@seg_endnotes,@@seg_subtoc={},{}
- @@seg_endnotes_array,@@seg_subtoc_array=[],[]
- @@seg[:endnote_all]=[]
+ def cleanup(md,per)
+ #per=persist_init
+ reinitialise(per)
+ @@tracker=0
+ @per.seg_endnotes,@per.seg_subtoc={},{}
+ @per.seg_endnotes_array,@per.seg_subtoc_array=[],[]
+ per.endnote_all=[]
end
- def get_subtoc_endnotes(data) #get endnotes & sub-table of contents subtoc
+ def get_subtoc_endnotes(data,per) #get endnotes & sub-table of contents subtoc
+ @per=per
data.each do |dob|
dob.obj=dob.obj.gsub(/<a name=\"h\d.*?\">(.+?)<\/a>/mi,'\1')
if @md.flag_auto_endnotes
if (dob.is==:heading \
|| dob.is==:heading_insert) \
&& (dob.ln.to_s =~/^[0-4]/) \
- and not @@fn.to_s.empty?
- @@seg_endnotes[@@fn]=[]
- @@seg_endnotes[@@fn] << @@seg_endnotes_array
- @@seg_endnotes_array=[] if dob.ln==4
- @@fns_previous=@md.fns if dob.ln==4 and dob.name =~/^meta/
+ and not @per.fn.to_s.empty?
+ @per.seg_endnotes[@per.fn]=[]
+ @per.seg_endnotes[@per.fn] << @per.seg_endnotes_array
+ @per.seg_endnotes_array=[] if dob.ln==4
end
if (dob.is==:heading \
|| dob.is==:heading_insert) \
&& dob.ln==4 #% EXTRACTION OF SUB-TOCs & SEGMENT NAME, after EXTRACTION OF ENDNOTES & SUB-TOCs
- @@seg_subtoc[@@fn]=@@seg_subtoc_array
- @@seg_subtoc_array=[]
+ @per.seg_subtoc[@per.fn]=@per.seg_subtoc_array
+ @per.seg_subtoc_array=[]
if dob.name \
and dob.obj
- @@fn=dob.name
+ @per.fn=dob.name
else
if dob.name =~/\S+/
- @@fn=dob.name
- else @@fn=''
+ @per.fn=dob.name
+ else @per.fn=''
end
end
end
@@ -666,7 +664,7 @@ module SiSU_HTML_Seg
format_seg=SiSU_HTML_Format::FormatSeg.new(@md,txt_obj)
subtoc=format_seg.subtoc_lev7 #keep and make available, this is the subtoc
end
- @@seg_subtoc_array << subtoc
+ @per.seg_subtoc_array << subtoc
end
if @md.flag_auto_endnotes
if (dob.obj =~/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]})[\d*+]+\s*<a href="##{Mx[:note_ref]}[\d*+]+"/) \
@@ -676,10 +674,12 @@ module SiSU_HTML_Seg
endnote_array << dob.obj.scan(/#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}/m)
end
if dob.obj=~/#{Mx[:en_b_o]}[*]\d+\s.+?#{Mx[:en_b_c]}/m
- endnote_array << dob.obj.scan(/#{Mx[:en_b_o]}[*]\d+\s.+?#{Mx[:en_b_c]}/m)
+ endnote_array \
+ << dob.obj.scan(/#{Mx[:en_b_o]}[*]\d+\s.+?#{Mx[:en_b_c]}/m)
end
if dob.obj=~/#{Mx[:en_b_o]}[+]\d+\s.+?#{Mx[:en_b_c]}/m
- endnote_array << dob.obj.scan(/#{Mx[:en_b_o]}[+]\d+\s.+?#{Mx[:en_b_c]}/m)
+ endnote_array \
+ << dob.obj.scan(/#{Mx[:en_b_o]}[+]\d+\s.+?#{Mx[:en_b_c]}/m)
end
endnote_array=endnote_array.flatten.compact #watch, check compacting
endnote_array.each do |note|
@@ -694,7 +694,7 @@ module SiSU_HTML_Seg
format_seg.endnote_body_indent
else format_seg.endnote_body
end
- @@seg_endnotes_array << note_match
+ @per.seg_endnotes_array << note_match
end
try.join('<br>')
#% creation of separate end segment/page of all endnotes referenced back to reference segment
@@ -703,8 +703,8 @@ module SiSU_HTML_Seg
endnote_part_b=note_match_seg[m,2]
txt_obj={ endnote_part_a: endnote_part_a, endnote_part_b: endnote_part_b }
format_seg=SiSU_HTML_Format::FormatSeg.new(@md,txt_obj)
- note_match_all_seg=format_seg.endnote_seg_body(@@fn) #BUG WATCH 200408
- @@seg[:endnote_all] << note_match_all_seg
+ note_match_all_seg=format_seg.endnote_seg_body(@per.fn) #BUG WATCH 200408
+ @per.endnote_all << note_match_all_seg
end
dob.obj=dob.obj.gsub(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ')
end
diff --git a/lib/sisu/current/html_tune.rb b/lib/sisu/current/html_tune.rb
index 5a4575c..c02fc49 100644
--- a/lib/sisu/current/html_tune.rb
+++ b/lib/sisu/current/html_tune.rb
@@ -151,7 +151,6 @@ module SiSU_HTML_Tune
end
def songsheet_array(data)
data_tuned=[]
- #@tuned_file=[]
data.each do |dob|
dob=amp_angle_brackets(dob)
dob=endnotes_html(dob)
@@ -162,9 +161,8 @@ module SiSU_HTML_Tune
data_tuned
end
def urls(data)
- @words=[]
- data.each do |word|
- @words << if word=~/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}|image)/
+ @words=data.each.map do |word|
+ if word=~/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}|image)/
http_=true
if word =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/
m,u=/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/.match(word).captures
@@ -208,9 +206,7 @@ module SiSU_HTML_Tune
word
else word
end
- word
- end
- @words=@words.join(' ')
+ end.join(' ')
end
def url_markup(dob)
unless dob.is==:code
@@ -293,10 +289,9 @@ module SiSU_HTML_Tune
end
def output
data=@data
- @tuned_file=[]
- data.each do |dob|
+ @tuned_file=data.each.map do |dob|
dob.obj=dob.obj.strip.chomp
- @tuned_file << dob
+ dob
end
@tuned_file << "\n<EOF>" if (@md.fns =~/\.sst0/) #remove
@tuned_file
diff --git a/lib/sisu/current/hub.rb b/lib/sisu/current/hub.rb
index eb6ab19..58d75b0 100644
--- a/lib/sisu/current/hub.rb
+++ b/lib/sisu/current/hub.rb
@@ -133,6 +133,7 @@ module SiSU
actions.outputs.each_file.xml?
actions.outputs.each_file.pdf?
actions.outputs.each_file.man_or_info?
+ actions.outputs.each_file.po4a_make?
actions.outputs.each_file.sqlite_discrete?
actions.outputs.each_file.manifest?
end
@@ -181,6 +182,9 @@ module SiSU
if defined? actions.outputs.loop_files.run_termsheet?
actions.outputs.loop_files.run_termsheet?
end
+ if defined? actions.outputs.loop_files.po4a_setup?
+ actions.outputs.loop_files.po4a_setup?
+ end
if defined? actions.outputs.loop_files.sql?
actions.outputs.loop_files.sql?
end
@@ -198,7 +202,7 @@ module SiSU
def actions_without_files
actions=SiSU_Hub_Actions::HubActions.new(@opt)
actions.report.version_info?
- actions.report.version_dir?
+ actions.report.version_info_extra?
actions.prepare.site?
actions.prepare.sql?
end
diff --git a/lib/sisu/current/hub_actions.rb b/lib/sisu/current/hub_actions.rb
index 8878855..1ea67bf 100644
--- a/lib/sisu/current/hub_actions.rb
+++ b/lib/sisu/current/hub_actions.rb
@@ -56,6 +56,8 @@
=end
module SiSU_Hub_Actions
class HubActions
+ require_relative 'utils_composite' # utils_composite.rb
+ include SiSU_Composite_Doc_Utils # composite doc, .ssm, extract all related insert files, array of filenames test
def initialize(opt)
@opt=opt
end
@@ -65,6 +67,17 @@ module SiSU_Hub_Actions
SiSU_Env::InfoAbout.new(@opt).sisu_version
end
end
+ def version_number_git?
+ if @opt.act[:version_info][:set]==:on \
+ || @opt.act[:verbose][:set]==:on \
+ || @opt.act[:verbose_plus][:set]==:on \
+ || @opt.act[:maintenance][:set]==:on
+ SiSU_Screen::Ansi.new(
+ @opt.act[:color_state][:set],
+ ' ' + SiSU_is.git_version_info?
+ ).grey
+ end
+ end
def version_dir?
if @opt.act[:version_info][:set]==:on \
|| @opt.act[:verbose][:set]==:on \
@@ -76,6 +89,25 @@ module SiSU_Hub_Actions
).grey
end
end
+ def version_info_extra?
+ if @opt.act[:version_info][:set]==:on \
+ || @opt.act[:verbose][:set]==:on \
+ || @opt.act[:verbose_plus][:set]==:on \
+ || @opt.act[:maintenance][:set]==:on
+ if SiSU_is.git_version_info?
+ SiSU_Screen::Ansi.new(
+ @opt.act[:color_state][:set],
+ ' ' + File.dirname(__FILE__) + \
+ ' vcr: ' + SiSU_is.git_version_info?
+ ).grey
+ else
+ SiSU_Screen::Ansi.new(
+ @opt.act[:color_state][:set],
+ ' ' + File.dirname(__FILE__)
+ ).grey
+ end
+ end
+ end
self
end
def prepare
@@ -156,7 +188,7 @@ module SiSU_Hub_Actions
def abstract_objects?
if @opt.act[:ao][:set]==:on #% --ao --dal, -m
if @opt.f_pths.length > 0
- unless @opt.act[:po4a][:set]==:on # --po4a, -P
+ unless @opt.act[:po4a_shelf][:set]==:on # --po4a-shelf
if @opt.fno =~ /\.ssm$/
require_relative 'ao_composite' # ao_composite.rb #pre-processing
SiSU_Assemble::Composite.new(@opt).read
@@ -278,6 +310,20 @@ module SiSU_Hub_Actions
end
end
end
+ if @opt.act[:txt_orgmode][:set]==:on #% --orgmode
+ if @opt.f_pths.length > 0
+ require_relative 'txt_orgmode' # txt_orgmode.rb
+ SiSU_Txt_OrgMode::Source.new(@opt).read
+ else
+ msg='orgmode request requires sisu markup files'
+ if (@opt.act[:verbose_plus][:set]==:on \
+ || @opt.act[:maintenance][:set]==:on)
+ SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:yellow).
+ mark(msg)
+ else puts msg
+ end
+ end
+ end
end
def html?
if @opt.act[:html][:set]==:on #% --html, -h
@@ -532,15 +578,51 @@ module SiSU_Hub_Actions
end
end
end
+ def po4a_make?
+ if @opt.act[:po4a_sst_ao_sst][:set]==:on #% --po4a-ao
+ if @opt.f_pths.length > 0
+ require_relative 'src_po4a_sst_ao_sst'
+ SiSU_SStm_AO_SStm::Source.new(@opt).read_process_src_files # src_po4a_sst_ao_sst.rb
+ else
+ msg='sst request requires sisu markup files'
+ if (@opt.act[:verbose_plus][:set]==:on \
+ || @opt.act[:maintenance][:set]==:on)
+ SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:cyan).
+ mark(msg)
+ else puts msg
+ end
+ end
+ end
+ end
+ def elasticsearch?
+ if @opt.act[:elasticsearch][:set]==:on #% --elastic, -x
+ if @opt.f_pths.length > 0
+ require_relative 'json_elastic' # json_elastic.rb
+ SiSU_Elastic::Source.new(@opt).read
+ else
+ msg='easticsearch request requires sisu markup files'
+ if (@opt.act[:verbose_plus][:set]==:on \
+ || @opt.act[:maintenance][:set]==:on)
+ SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:yellow).
+ mark(msg)
+ else puts msg
+ end
+ end
+ end
+ end
def manifest?
if @opt.act[:manifest][:set]==:on #% --manifest, -y
if @opt.f_pths.length > 0
- require_relative 'html_manifest' # html_manifest.rb
- ((@opt.act[:sisupod][:set]==:on \
- || @opt.act[:share_source][:set]==:on) \
- && @opt.f_pths.length < 2 ) \
- ? nil
- : SiSU_Manifest::Source.new(@opt).read
+ begin
+ require_relative 'html_manifest' # html_manifest.rb
+ ((@opt.act[:sisupod][:set]==:on \
+ || @opt.act[:share_source][:set]==:on \
+ || @opt.act[:po4a_sstm][:set]==:on) \
+ && @opt.f_pths.length < 2 ) \
+ ? nil
+ : SiSU_Manifest::Source.new(@opt).read
+ rescue
+ end
else
msg='manifest request requires sisu markup files'
if (@opt.act[:verbose_plus][:set]==:on \
@@ -572,8 +654,9 @@ module SiSU_Hub_Actions
end
def loop_files
def share_source?
- if @opt.act[:share_source][:set]==:on \
- or @opt.act[:sisupod][:set]==:on \
+ if @opt.act[:sisupod][:set]==:on \
+ or @opt.act[:share_source][:set]==:on \
+ or @opt.act[:po4a_sstm][:set]==:on \
or @opt.act[:git][:set]==:on
begin
if @opt.f_pths.length > 0
@@ -591,26 +674,6 @@ module SiSU_Hub_Actions
else puts msg
end
end
- if @opt.act[:share_source][:set]==:on
- if @opt.f_pths.length > 0
- require_relative 'src_share' # src_share.rb
- begin
- ensure
- SiSU_Hub_Loops::OptionLoopFiles.new(@opt).
- loop_files_on_given_option_bundle do
- SiSU_Markup::Source.new(@opt).read
- end
- end
- else
- msg='share markup source request requires sisu markup files'
- if (@opt.act[:verbose_plus][:set]==:on \
- || @opt.act[:maintenance][:set]==:on)
- SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:cyan).
- mark(msg)
- else puts msg
- end
- end
- end
if @opt.act[:sisupod][:set]==:on #% --sisupod, -S
if @opt.f_pths.length > 0
require_relative 'src_sisupod_make' # src_sisupod_make.rb
@@ -656,7 +719,8 @@ module SiSU_Hub_Actions
end
end
if (@opt.act[:sisupod][:set]==:on \
- || @opt.act[:share_source][:set]==:on) \
+ || @opt.act[:share_source][:set]==:on \
+ || @opt.act[:po4a_sstm][:set]==:on) \
and @opt.act[:manifest][:set]==:on #% --manifest, -y
if @opt.f_pths.length > 0
require_relative 'html_manifest' # html_manifest.rb
@@ -691,18 +755,78 @@ module SiSU_Hub_Actions
end
end
end
- if @opt.act[:po4a][:set]==:on #% --po4a, -P
+ if @opt.act[:share_source][:set]==:on
+ if @opt.f_pths.length > 0
+ require_relative 'src_sisupod_sstm' # src_sisupod_sstm.rb
+ begin
+ ensure
+ SiSU_Hub_Loops::OptionLoopFiles.new(@opt).
+ loop_files_on_given_option_bundle do
+ SiSU_Markup::Source_Sisupod.new(@opt).read
+ end
+ end
+ else
+ msg='share markup source request requires sisu markup files'
+ if (@opt.act[:verbose_plus][:set]==:on \
+ || @opt.act[:maintenance][:set]==:on)
+ SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:cyan).
+ mark(msg)
+ else puts msg
+ end
+ end
+ end
+ if @opt.act[:po4a_sstm][:set]==:on #% --po4a-sst
+ if @opt.f_pths.length > 0
+ require_relative 'src_po4a_sstm'
+ begin
+ SiSU_Hub_Loops::OptionLoopFiles.new(@opt).
+ loop_files_on_given_option do
+ SiSU_Markup::Source_Po4a.new(@opt).read # src_po4a_sstm.rb
+ end
+ ensure
+ end
+ else
+ msg='sst request requires sisu markup files'
+ if (@opt.act[:verbose_plus][:set]==:on \
+ || @opt.act[:maintenance][:set]==:on)
+ SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:cyan).
+ mark(msg)
+ else puts msg
+ end
+ end
+ end
+ if @opt.act[:po4a_sst_ao_sst][:set]==:on #% --po4a-ao
+ if @opt.f_pths.length > 0
+ require_relative 'src_po4a_sst_ao_sst'
+ begin
+ SiSU_Hub_Loops::OptionLoopFiles.new(@opt).
+ loop_files_on_given_option do
+ SiSU_SStm_AO_SStm::Source.new(@opt).read_setup # src_po4a_sst_ao_sst.rb
+ end
+ ensure
+ end
+ else
+ msg='sst request requires sisu markup files'
+ if (@opt.act[:verbose_plus][:set]==:on \
+ || @opt.act[:maintenance][:set]==:on)
+ SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:cyan).
+ mark(msg)
+ else puts msg
+ end
+ end
+ end
+ if @opt.act[:po4a_shelf][:set]==:on #% --po4a-shelf
if @opt.f_pths.length > 0
- require_relative 'po4a'
+ require_relative 'src_po4a_shelf'
begin
SiSU_Hub_Loops::OptionLoopFiles.new(@opt).
loop_files_on_given_option do
- SiSU_Po4a::Source.new(@opt).read # po4a.rb
+ SiSU_Po4a::Source.new(@opt).read # src_po4a_shelf.rb
end
ensure
end
else
- msg='po4a request requires sisu markup files'
+ msg='src_po4a_shelf request requires sisu markup files'
if (@opt.act[:verbose_plus][:set]==:on \
|| @opt.act[:maintenance][:set]==:on)
SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:cyan).
diff --git a/lib/sisu/current/hub_loop_markup_files.rb b/lib/sisu/current/hub_loop_markup_files.rb
index 626dc8e..495739a 100644
--- a/lib/sisu/current/hub_loop_markup_files.rb
+++ b/lib/sisu/current/hub_loop_markup_files.rb
@@ -136,6 +136,9 @@ module SiSU_Hub_Loops
files_translated_idx << x[1]
end
end
+ #files_translated_idx=number_of_files.select do |x|
+ # x[1] if x[1].length > 1
+ #end
if files_translated_idx.flatten.length > 1
SiSU_Screen::Ansi.new(
@opt.act[:color_state][:set],
diff --git a/lib/sisu/current/hub_options.rb b/lib/sisu/current/hub_options.rb
index 8a9af15..c36ba4c 100644
--- a/lib/sisu/current/hub_options.rb
+++ b/lib/sisu/current/hub_options.rb
@@ -175,8 +175,8 @@ module SiSU_Commandline
@make_instructions_pod=nil
init
end
- def sisu_run_from?
- @sisu_run_from
+ def sisu_called_from?
+ @call_path
end
def sisu_bin_filepath?
@sisu_run_from
@@ -184,6 +184,9 @@ module SiSU_Commandline
def sisu_install_type?
@sisu_install_type
end
+ def sisu_lib_dir?
+ File.dirname(__FILE__)
+ end
def sisu_data_dir?
env=RbConfig::CONFIG
if sisu_install_type? ==:full_path_to_sisu_bin_in_sisu_dir_tree
@@ -275,17 +278,15 @@ module SiSU_Commandline
end
end
def init_selected_lang_dirs(a)
- @z=[]
- a.each do |y|
+ @z=a.each.map do |y|
if y =~/^#{lng_base}\/(\S+?\.ss[tm])$/
@fn=$1
- @z << y
+ y
elsif y =~/^#{@lang_regx}\/?$/
- @z << "#{y}/#{@fn}"
- else @z << y
+ "#{y}/#{@fn}"
+ else y
end
end
- @z
end
def init
a=@a
@@ -640,7 +641,7 @@ module SiSU_Commandline
if ch =~/N/ then select_arr << '--digests'
ch=ch.gsub(/[N]/,'')
end
- if ch =~/P/ then select_arr << '--po4a'
+ if ch =~/P/ then select_arr << '--po4a-sst'
ch=ch.gsub(/[P]/,'')
end
if ch =~/d/ then select_arr << '--sqlite'
@@ -1176,6 +1177,10 @@ module SiSU_Commandline
=~/"--rst"|"--rest"|"--restructuredtext"/) \
? { bool: true, set: :on }
: { bool: false, set: :na }
+ act[:txt_orgmode]=(select_arr.inspect \
+ =~/"--org"|"--orgmode"/) \
+ ? { bool: true, set: :on }
+ : { bool: false, set: :na }
act[:manpage]=(select_arr.inspect \
=~/"--manpage"|"--man"/) \
? { bool: true, set: :on }
@@ -1323,10 +1328,56 @@ module SiSU_Commandline
=~/"--harvest"/) \
? { bool: true, set: :on }
: { bool: false, set: :na }
- act[:po4a]=(select_arr.inspect \
- =~/"--po4a"|"--pot?"/) \
+ act[:po4a_sstm]=(select_arr.inspect \
+ =~/"--po4a-ss[tm]"/) \
+ ? { bool: true, set: :on }
+ : { bool: false, set: :na }
+ act[:po4a_sst_ao_sst]=(select_arr.inspect \
+ =~/"--po4a-ao(?:-ss[tm])?"/) \
+ ? { bool: true, set: :on }
+ : { bool: false, set: :na }
+ act[:po4a_shelf]=(select_arr.inspect \
+ =~/"--po4a-shelf"|"--pot?-shelf"/) \
? { bool: true, set: :on }
: { bool: false, set: :na }
+ if act[:po4a_shelf][:set]==:on \
+ or act[:po4a_sst_ao_sst][:set]==:on \
+ or act[:po4a_sstm][:set]==:on
+ act[:po4a_lang]=if select_arr.inspect \
+ =~/"--(?:trans|init)-([a-z]{2}):((?:(?:[a-z]{2}\b),?)+)/
+ lng_src,lng_trn=$1,$2.split(',')
+ { bool: true, set: :on, src: lng_src, trn: lng_trn }
+ elsif select_arr.inspect \
+ =~/"--trans"/
+ { bool: true, set: :on }
+ { bool: true, set: :on, src: 'en', trn: [] }
+ else
+ { bool: false, set: :na }
+ end
+ act[:po4a_lang_trans]=if select_arr.inspect \
+ =~/"--trans-([a-z]{2}):((?:(?:[a-z]{2}\b),?)+)/
+ lng_src,lng_trn=$1,$2.split(',')
+ { bool: true, set: :on, src: lng_src, trn: lng_trn }
+ elsif select_arr.inspect \
+ =~/"--trans"/
+ { bool: true, set: :on }
+ { bool: true, set: :on, src: 'en', trn: [] }
+ else
+ { bool: false, set: :na }
+ end
+ act[:po4a_lang_init]=if select_arr.inspect \
+ =~/"--init-([a-z]{2}):((?:(?:[a-z]{2}\b),?)+)/
+ lng_src,lng_trn=$1,$2.split(',')
+ { bool: true, set: :on, src: lng_src, trn: lng_trn }
+ else
+ { bool: false, set: :na }
+ end
+ else
+ act[:po4a_lang_trans]= \
+ { bool: false, set: :na }
+ act[:po4a_lang_init]= \
+ { bool: false, set: :na }
+ end
act[:git]=(select_arr.inspect \
=~/"--git"/) \
? { bool: true, set: :on }
@@ -1433,6 +1484,7 @@ module SiSU_Commandline
|| act[:txt_asciidoc][:set]==:on \
|| act[:txt_markdown][:set]==:on \
|| act[:txt_rst][:set]==:on \
+ || act[:txt_orgmode][:set]==:on \
|| act[:xhtml][:set]==:on \
|| act[:epub][:set]==:on \
|| act[:html][:set]==:on \
@@ -1446,8 +1498,9 @@ module SiSU_Commandline
|| act[:pdf_p][:set]==:on \
|| act[:pdf_l][:set]==:on \
|| act[:qrcode][:set]==:on \
- || act[:share_source][:set]==:on \
|| act[:sisupod][:set]==:on \
+ || act[:share_source][:set]==:on \
+ || act[:po4a_sstm][:set]==:on \
|| act[:concordance][:set]==:on \
|| act[:sqlite_discrete][:set]==:on \
|| act[:sqlite_import][:set]==:on \
@@ -1481,6 +1534,7 @@ module SiSU_Commandline
|| act[:txt_asciidoc][:set]==:on \
|| act[:txt_markdown][:set]==:on \
|| act[:txt_rst][:set]==:on \
+ || act[:txt_orgmode][:set]==:on \
|| act[:xhtml][:set]==:on \
|| act[:epub][:set]==:on \
|| act[:html][:set]==:on \
@@ -1494,8 +1548,9 @@ module SiSU_Commandline
|| act[:pdf_p][:set]==:on \
|| act[:pdf_l][:set]==:on \
|| act[:qrcode][:set]==:on \
- || act[:share_source][:set]==:on \
|| act[:sisupod][:set]==:on \
+ || act[:share_source][:set]==:on \
+ || act[:po4a_sstm][:set]==:on \
|| act[:concordance][:set]==:on \
|| act[:xml_dom][:set]==:on \
|| act[:xml_sax][:set]==:on \
diff --git a/lib/sisu/current/manpage.rb b/lib/sisu/current/manpage.rb
index fb5a1f3..f297db5 100644
--- a/lib/sisu/current/manpage.rb
+++ b/lib/sisu/current/manpage.rb
@@ -63,10 +63,13 @@ module SiSU_Manpage
include SiSU_ManpageFormat
require_relative 'shared_metadata' # shared_metadata.rb
require_relative 'generic_parts' # generic_parts.rb
+ require_relative 'txt_read' # txt_read.rb
+ require_relative 'txt_output' # txt_output.rb
require_relative 'txt_shared' # txt_shared.rb
- @@alt_id_count,@@alt_id_count,@@tablehead,@@number_of_cols=0,0,0,0
+ @@alt_id_count,@@alt_id_count=0,0
@@tablefoot=''
class Source
+ include SiSU_Txt_Read
def initialize(opt)
@opt=opt
if @opt.fns =~/(.+?)\.(?:-|ssm\.)?sst$/
@@ -77,37 +80,14 @@ module SiSU_Manpage
end
def read
begin
- @md=SiSU_Param::Parameters.new(@opt).get
- @env=SiSU_Env::InfoEnv.new(@opt.fns)
- tool=(@opt.act[:verbose][:set]==:on \
- || @opt.act[:verbose_plus][:set]==:on \
- || @opt.act[:maintenance][:set]==:on) \
- ? "#{@env.program.text_editor} #{@md.file.output_path.manpage.dir}/#{@md.file.base_filename.manpage}"
- : "[#{@opt.f_pth[:lng_is]}] #{@opt.fno}"
- (@opt.act[:verbose][:set]==:on \
- || @opt.act[:verbose_plus][:set]==:on \
- || @opt.act[:maintenance][:set]==:on) \
- && @opt.act[:quiet][:set]==:on \
- ? SiSU_Screen::Ansi.new(
- @opt.act[:color_state][:set],
- 'Manpage',
- tool
- ).green_hi_blue
- : SiSU_Screen::Ansi.new(
- @opt.act[:color_state][:set],
- 'Manpage',
- tool
- ).green_title_hi
- if (@opt.act[:verbose_plus][:set]==:on \
- || @opt.act[:maintenance][:set]==:on)
- SiSU_Screen::Ansi.new(
- @opt.act[:color_state][:set],
- @opt.fns,
- "#{@md.file.output_path.manpage.dir}/#{@md.file.base_filename.manpage}"
- ).flow
- end
- @ao_array=SiSU_AO::Source.new(@opt).get # ao file drawn here
- SiSU_Manpage::Source::Scroll.new(@md,@ao_array).songsheet
+ md=SiSU_Param::Parameters.new(@opt).get
+ specific={
+ description: 'Manpage',
+ output_path: md.file.output_path.manpage.dir,
+ output_file: md.file.base_filename.manpage,
+ }
+ read_generic(@opt,specific)
+ SiSU_Manpage::Source::Scroll.new(md,@ao_array,@wrap_width).songsheet
rescue
SiSU_Errors::Rescued.new($!,$@,@opt.selections.str,@opt.fns).location do
__LINE__.to_s + ':' + __FILE__
@@ -121,8 +101,8 @@ module SiSU_Manpage
include SiSU_Parts_Generic
include SiSU_TextUtils
@@endnotes={ para: [], end: [] }
- def initialize(md,data)
- @md,@data=md,data
+ def initialize(md,data,wrap_width)
+ @md,@data,@wrap_width=md,data,wrap_width
@tab="\t"
@@notes=:end
@manpage={ body: [], open: [], close: [], head: [], metadata: [], tail: [], endnotes: [] }
@@ -153,8 +133,8 @@ module SiSU_Manpage
notes=@n.flatten
notes.each do |e|
util=(e.to_s =~/^\[[\d*+]+\]:/) \
- ? (SiSU_TextUtils::Wrap.new(e.to_s,78,4,1))
- : (SiSU_TextUtils::Wrap.new(e.to_s,78,0,1))
+ ? (SiSU_TextUtils::Wrap.new(e.to_s,@wrap_width,4,1))
+ : (SiSU_TextUtils::Wrap.new(e.to_s,@wrap_width,0,1))
wrap=util.line_wrap
wrap=if wrap =~ /^\s*[\d*+]+\s+.+?\s*\Z/m
wrap.gsub(/(^|&nbsp;|#{Mx[:nbsp]}|\s|\*)\\\*/,'\1\\\\\*'). #man page requires
@@ -219,19 +199,19 @@ WOK
if dob.indent =~/[1-9]/ \
and dob.indent == dob.hang
util=if dob.bullet_
- SiSU_TextUtils::Wrap.new("* #{paragraph}",78,dob.indent.to_i*2)
- else SiSU_TextUtils::Wrap.new(paragraph,78,dob.indent.to_i*2)
+ SiSU_TextUtils::Wrap.new("* #{paragraph}",@wrap_width,dob.indent.to_i*2)
+ else SiSU_TextUtils::Wrap.new(paragraph,@wrap_width,dob.indent.to_i*2)
end
elsif dob.hang =~/[0-9]/ \
and dob.indent != dob.hang # NOT yet implemented
- util=SiSU_TextUtils::Wrap.new(paragraph,78,dob.indent.to_i*2)
+ util=SiSU_TextUtils::Wrap.new(paragraph,@wrap_width,dob.indent.to_i*2)
else
util=if dob.bullet_
- SiSU_TextUtils::Wrap.new("* #{paragraph}",78,0)
- else SiSU_TextUtils::Wrap.new(paragraph,78,0)
+ SiSU_TextUtils::Wrap.new("* #{paragraph}",@wrap_width,0)
+ else SiSU_TextUtils::Wrap.new(paragraph,@wrap_width,0)
end
end
- else util=SiSU_TextUtils::Wrap.new(paragraph,78,0)
+ else util=SiSU_TextUtils::Wrap.new(paragraph,@wrap_width,0)
end
w=util.line_wrap
w=w.gsub(/^(\\\.)/,' \1')
@@ -239,7 +219,7 @@ WOK
end
if lv
times=wrapped.length
- times=78 if times > 78
+ times=@wrap_width if times > @wrap_width
@manpage[:body] << case lv
when 0 then '.SH ' << wrapped.upcase << break_line << break_line
when 1..3 then '.SH ' << wrapped.upcase << break_line << break_line
@@ -380,49 +360,18 @@ WOK
else SiSU_Env::InfoDate.new.year #date missing decide on action
end
proj=SiSU_Env::InfoVersion.instance.get_version
- manpage[:open] = %{.TH "#{@md.fnb}" "#{@md.make.manpage['section']}" "#{date}" "#{proj[:version]}" "#{@md.title.main}"#{@md.make.manpage['name']}#{@md.make.manpage['synopsis']}}
+ manpage[:open] = %{.TH "#{@md.fnb}" "#{@md.make.manpage['section']}" "#{date}" "#{proj.version}" "#{@md.title.main}"#{@md.make.manpage['name']}#{@md.make.manpage['synopsis']}}
content << manpage[:open]
content << manpage[:head]
content << manpage[:body]
content << @@endnotes[:end] if @@notes==:end
content << manpage[:metadata]
content << manpage[:tail]
- Output.new(@md,content).manpage
+ outputfile=SiSU_Env::FileOp.new(@md).write_file.manpage
+ Txt_Output::Output.new.document(content,outputfile)
@@endnotes={ para: [], end: [] }
end
end
- class Output <Source
- include SiSU_Param
- include SiSU_Env
- def initialize(md,content)
- @md,@content=md,content
- end
- def manpage #%manpage output
- SiSU_Env::FileOp.new(@md).mkdir
- filename_manpage=SiSU_Env::FileOp.new(@md).write_file.manpage
- @sisu=[]
- emptyline=0
- @content.each do |para| # this is a hack
- if para.is_a?(Array) \
- and para.length > 0
- para.each do |line|
- if line
- line=line.gsub(/[ \t]+$/m,'').
- gsub(/^\A[ ]*\Z/m,'')
- (line=~/^\A\Z/) \
- ? (emptyline+=1)
- : emptyline=0
- if emptyline < 2 #remove additional empty lines
- filename_manpage.puts line #unix manpage
- end
- end
- end
- else filename_manpage.puts para #unix manpage # /^([*=-]|\.){5}/
- end
- end
- filename_manpage.close
- end
- end
end
end
__END__
diff --git a/lib/sisu/current/object_munge.rb b/lib/sisu/current/object_munge.rb
new file mode 100644
index 0000000..1baa8ca
--- /dev/null
+++ b/lib/sisu/current/object_munge.rb
@@ -0,0 +1,307 @@
+# encoding: utf-8
+=begin
+
+* Name: SiSU
+
+** Description: documents, structuring, processing, publishing, search
+*** object munge
+
+** Author: Ralph Amissah
+ <ralph@amissah.com>
+ <ralph.amissah@gmail.com>
+
+** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
+ 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah,
+ All Rights Reserved.
+
+** License: GPL 3 or later:
+
+ SiSU, a framework for document structuring, publishing and search
+
+ Copyright (C) Ralph Amissah
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the Free
+ Software Foundation, either version 3 of the License, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ more details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program. If not, see <http://www.gnu.org/licenses/>.
+
+ If you have Internet connection, the latest version of the GPL should be
+ available at these locations:
+ <http://www.fsf.org/licensing/licenses/gpl.html>
+ <http://www.gnu.org/licenses/gpl.html>
+
+ <http://www.sisudoc.org/sisu/en/manifest/gpl.fsf.html>
+
+** SiSU uses:
+ * Standard SiSU markup syntax,
+ * Standard SiSU meta-markup syntax, and the
+ * Standard SiSU object citation numbering and system
+
+** Hompages:
+ <http://www.jus.uio.no/sisu>
+ <http://www.sisudoc.org>
+
+** Git
+ <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=summary>
+ <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=blob;f=lib/sisu/current/html_parts.rb;hb=HEAD>
+
+=end
+module SiSU_Object_Munge
+ def i_src_o_strip_markup(txtobj)
+ txtobj=txtobj.
+ gsub(/#{Mx[:srcrgx_bold_o]}(.+?)#{Mx[:srcrgx_bold_c]}/m,'\1').
+ gsub(/#{Mx[:srcrgx_italics_o]}(.+?)#{Mx[:srcrgx_italics_c]}/m,'\1').
+ gsub(/#{Mx[:srcrgx_underscore_o]}(.+?)#{Mx[:srcrgx_underscore_c]}/m,'\1').
+ gsub(/#{Mx[:srcrgx_cite_o]}(.+?)#{Mx[:srcrgx_cite_c]}/m,'\1').
+ gsub(/#{Mx[:srcrgx_insert_o]}(.+?)#{Mx[:srcrgx_insert_c]}/m,'\1').
+ gsub(/#{Mx[:srcrgx_strike_o]}(.+?)#{Mx[:srcrgx_strike_c]}/m,'\1').
+ gsub(/#{Mx[:srcrgx_superscript_o]}(\d+)#{Mx[:srcrgx_superscript_c]}/m,'[\1]').
+ gsub(/#{Mx[:srcrgx_superscript_o]}(.+?)#{Mx[:srcrgx_superscript_c]}/m,'\1').
+ gsub(/#{Mx[:srcrgx_subscript_o]}(.+?)#{Mx[:srcrgx_subscript_c]}/m,'\1').
+ gsub(/#{Mx[:srcrgx_hilite_o]}(.+?)#{Mx[:srcrgx_hilite_c]}/m,'\1').
+ gsub(/#{Mx[:gl_o]}#(?:126|152)#{Mx[:gl_c]}/i,'~').
+ gsub(/#{Mx[:en_a_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_a_c]}/m,''). # endnote removed
+ gsub(/#{Mx[:en_b_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_b_c]}/m,''). # endnote removed
+ gsub(/(?:#{Mx[:nbsp]})+/,' ').
+ gsub(/(?:#{Mx[:br_nl]})+/,"\n").
+ gsub(/(?:#{Mx[:br_paragraph]})+/,"\n").
+ gsub(/(?:#{Mx[:br_line]})+/,"\n").
+ gsub(/#{Mx[:gl_o]}(?:#lt|#060)#{Mx[:gl_c]}/,'<').
+ gsub(/#{Mx[:gl_o]}(?:#gt|#062)#{Mx[:gl_c]}/,'>').
+ gsub(/#{Mx[:gl_o]}#(?:038|amp)#{Mx[:gl_c]}/,'&').
+ gsub(/#{Mx[:gl_o]}#033#{Mx[:gl_c]}/,'!').
+ gsub(/#{Mx[:gl_o]}#035#{Mx[:gl_c]}/,'#').
+ gsub(/#{Mx[:gl_o]}#042#{Mx[:gl_c]}/,'*').
+ gsub(/#{Mx[:gl_o]}#045#{Mx[:gl_c]}/,'-').
+ gsub(/#{Mx[:gl_o]}#047#{Mx[:gl_c]}/,'/').
+ gsub(/#{Mx[:gl_o]}#095#{Mx[:gl_c]}/,'_').
+ gsub(/#{Mx[:gl_o]}#123#{Mx[:gl_c]}/,'{').
+ gsub(/#{Mx[:gl_o]}#125#{Mx[:gl_c]}/,'}').
+ gsub(/#{Mx[:gl_o]}#126#{Mx[:gl_c]}/,'~').
+ gsub(/#{Mx[:gl_o]}#169#{Mx[:gl_c]}/,'©').
+ gsub(/[ ][ ]s+/,' ').
+ strip
+if txtobj =~/Reading this/
+ puts txtobj
+ if txtobj =~ /#{Mx[:srcrgx_italics_o]}(.+?)#{Mx[:srcrgx_italics_c]}/
+ puts __LINE__
+ puts Mx[:srcrgx_italics_o]
+ puts txtobj
+ end
+end
+; txtobj
+ end
+ def i_ao_o_strip_markup(txtobj)
+ txtobj=txtobj.gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'\1').
+ gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'\1').
+ gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'\1').
+ gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'\1').
+ gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'\1').
+ gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'\1').
+ gsub(/#{Mx[:fa_superscript_o]}(\d+)#{Mx[:fa_superscript_c]}/,'[\1]').
+ gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,'\1').
+ gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,'\1').
+ gsub(/#{Mx[:fa_hilite_o]}(.+?)#{Mx[:fa_hilite_c]}/,'\1').
+ gsub(/#{Mx[:gl_o]}#(?:126|152)#{Mx[:gl_c]}/i,'~').
+ gsub(/#{Mx[:en_a_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_a_c]}/,''). # endnote removed
+ gsub(/#{Mx[:en_b_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_b_c]}/,''). # endnote removed
+ gsub(/(?:#{Mx[:nbsp]})+/,' ').
+ gsub(/(?:#{Mx[:br_nl]})+/,"\n").
+ gsub(/(?:#{Mx[:br_paragraph]})+/,"\n").
+ gsub(/(?:#{Mx[:br_line]})+/,"\n").
+ gsub(/#{Mx[:gl_o]}(?:#lt|#060)#{Mx[:gl_c]}/,'<').
+ gsub(/#{Mx[:gl_o]}(?:#gt|#062)#{Mx[:gl_c]}/,'>').
+ gsub(/#{Mx[:gl_o]}#(?:038|amp)#{Mx[:gl_c]}/,'&').
+ gsub(/#{Mx[:gl_o]}#033#{Mx[:gl_c]}/,'!').
+ gsub(/#{Mx[:gl_o]}#035#{Mx[:gl_c]}/,'#').
+ gsub(/#{Mx[:gl_o]}#042#{Mx[:gl_c]}/,'*').
+ gsub(/#{Mx[:gl_o]}#045#{Mx[:gl_c]}/,'-').
+ gsub(/#{Mx[:gl_o]}#047#{Mx[:gl_c]}/,'/').
+ gsub(/#{Mx[:gl_o]}#095#{Mx[:gl_c]}/,'_').
+ gsub(/#{Mx[:gl_o]}#123#{Mx[:gl_c]}/,'{').
+ gsub(/#{Mx[:gl_o]}#125#{Mx[:gl_c]}/,'}').
+ gsub(/#{Mx[:gl_o]}#126#{Mx[:gl_c]}/,'~').
+ gsub(/#{Mx[:gl_o]}#169#{Mx[:gl_c]}/,'©').
+ gsub(/[ ][ ]s+/,' ').
+ strip
+ end
+ def i_ao_o_src_markup_restore(txtobj)
+ @txtobj=txtobj
+ def textface_marks
+ @txtobj.gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'*{\1}*').
+ gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'/{\1}/').
+ gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'_{\1}_').
+ gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'"{\1}"').
+ gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'+{\1}+').
+ gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'-{\1}-').
+ gsub(/#{Mx[:fa_superscript_o]}(\d+)#{Mx[:fa_superscript_c]}/,'^{[\1]}^').
+ gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,'^{\1}^').
+ gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,',{\1},').
+ gsub(/#{Mx[:fa_hilite_o]}(.+?)#{Mx[:fa_hilite_c]}/,'\1').
+ gsub(/#{Mx[:gl_o]}#(?:126|152)#{Mx[:gl_c]}/i,'~').
+ gsub(/#{Mx[:en_a_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_a_c]}/,'~{\1 \2}~').
+ gsub(/#{Mx[:en_b_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_b_c]}/,''). # endnote removed
+ gsub(/(?:#{Mx[:nbsp]})+/,' ').
+ gsub(/(?:#{Mx[:br_nl]})+/,"\n").
+ gsub(/(?:#{Mx[:br_paragraph]})+/,"\n").
+ gsub(/(?:#{Mx[:br_line]})+/,"\n").
+ gsub(/#{Mx[:gl_o]}(?:#lt|#060)#{Mx[:gl_c]}/,'<').
+ gsub(/#{Mx[:gl_o]}(?:#gt|#062)#{Mx[:gl_c]}/,'>').
+ gsub(/#{Mx[:gl_o]}#(?:038|amp)#{Mx[:gl_c]}/,'&').
+ gsub(/#{Mx[:gl_o]}#033#{Mx[:gl_c]}/,'!').
+ gsub(/#{Mx[:gl_o]}#035#{Mx[:gl_c]}/,'#').
+ gsub(/#{Mx[:gl_o]}#042#{Mx[:gl_c]}/,'*').
+ gsub(/#{Mx[:gl_o]}#045#{Mx[:gl_c]}/,'-').
+ gsub(/#{Mx[:gl_o]}#047#{Mx[:gl_c]}/,'/').
+ gsub(/#{Mx[:gl_o]}#095#{Mx[:gl_c]}/,'_').
+ gsub(/#{Mx[:gl_o]}#123#{Mx[:gl_c]}/,'{').
+ gsub(/#{Mx[:gl_o]}#125#{Mx[:gl_c]}/,'}').
+ gsub(/#{Mx[:gl_o]}#126#{Mx[:gl_c]}/,'~').
+ gsub(/#{Mx[:gl_o]}#169#{Mx[:gl_c]}/,'©').
+ gsub(/[ ][ ]s+/,' ').
+ strip
+ end
+ def object_marks
+ @txtobj
+ end
+ self
+ end
+ def clean_text(txtobj,markup=:ao)
+ if txtobj.class==String
+ txtobj=if markup ==:ao
+ i_ao_o_strip_markup(txtobj)
+ elsif markup ==:src
+ i_src_o_strip_markup(txtobj)
+ else p __FILE__; p __LINE__
+ end
+ elsif txtobj.class.inspect=~/^SiSU_AO_DocumentStructure::/
+ txtobj.obj=i_ao_o_strip_markup(txtobj.obj)
+ else p 'error'
+ end
+ txtobj
+ end
+ def footnotes_inline(txtobj)
+ end
+ def footnotes_ref_and_note(txtobj)
+ end
+ def src_markup(txtobj)
+ txtobj
+ end
+ def extract_endnotes(doc_obj_txt,endnotes_) #% used for extraction of endnotes from paragraphs
+ if endnotes_ ==:separate
+ notes_a=doc_obj_txt.scan(/#{Mx[:en_a_o]}([\d]+\s+.+?)#{Mx[:en_a_c]}/)
+ ##notes_a=doc_obj_txt.scan(/#{Mx[:en_a_o]}([\d*+]+\s+.+?)#{Mx[:en_a_c]}/)
+ #notes_b=doc_obj_txt.scan(/#{Mx[:en_b_o]}([\d*+]+\s+.+?)#{Mx[:en_b_c]}/)
+ n=[]
+ notes_a.flatten.each do |note| #high cost to deal with <br> appropriately within plaintext, consider
+ note=note.dup.to_s
+ note=note.gsub(/^([\d]+)\s+/,'^~\1 ').
+ gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,
+ ' \\\\\\ ')
+ n << note
+ end
+ notes_a=n.flatten
+ doc_obj_txt=doc_obj_txt.
+ gsub(/#{Mx[:en_a_o]}([\d]+)\s+(?:.+?)#{Mx[:en_a_c]}/,'~^') # endnote marker marked up
+ else
+ doc_obj_txt=doc_obj_txt.
+ gsub(/#{Mx[:en_b_o]}[\d]+\s+(.+?)#{Mx[:en_b_c]}/,
+ '~[ \1 ]~'). # inline endnote with marker marked up
+ gsub(/#{Mx[:en_a_o]}([*+]+)\s+(.+?)#{Mx[:en_a_c]}/,
+ '~{\1 \2 }~'). # inline endnote with marker marked up
+ gsub(/#{Mx[:en_b_o]}([*+]+)\s+(.+?)#{Mx[:en_b_c]}/,
+ '~[\1 \2 ]~') # inline endnote with marker marked up
+ end
+ [doc_obj_txt,notes_a]
+ end
+ def objects #def i_ao_o_src_markup_restore(txtobj)
+ def code_(dob)
+ if dob.is==:code
+ dob.obj=dob.obj.gsub(/(^|[^}])_([<>])/m,'\1\2'). # _> _<
+ gsub(/(^|[^}])_([<>])/m,'\1\2') # _<_<
+ end
+ dob
+ end
+ def block_(dob)
+ dob.obj=if dob.of==:block # watch
+ dob.obj.gsub(/#{Mx[:gl_o]}●#{Mx[:gl_c]}/,"* ").
+ gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,"\n")
+ else dob.obj.gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,"\n\n")
+ end
+ dob
+ end
+ def textface_marks_po4a(dob,endnotes_=:inline)
+ notes=''
+ dob.obj=dob.obj.
+ gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,
+ Mx[:src_bold_o] + '\1' + Mx[:src_bold_c]).
+ gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,
+ Mx[:src_italics_o] + '\1' + Mx[:src_italics_c]).
+ gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,
+ Mx[:src_underscore_o] + '\1' + Mx[:src_underscore_c]).
+ gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,
+ Mx[:src_subscript_o] + '\1' + Mx[:src_subscript_c]).
+ gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,
+ Mx[:src_superscript_o] + '\1' + Mx[:src_superscript_c]).
+ gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,
+ Mx[:src_insert_o] + '\1' + Mx[:src_insert_c]).
+ gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,
+ Mx[:src_cite_o] + '\1' + Mx[:src_cite_c]).
+ gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,
+ Mx[:src_strike_o] + '\1' + Mx[:src_strike_c]).
+ gsub(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/,
+ Mx[:src_monospace_o] + '\1' + Mx[:src_monospace_c])
+ unless dob.is==:code
+ dob.obj=dob.obj.
+ gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/,'\1').
+ gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'\1').
+ gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,
+ '\1 [link: <\2>]').
+ gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}image/,
+ '\1 [link: local image]').
+ gsub(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,'\1')
+ dob.obj,notes=extract_endnotes(dob.obj,endnotes_)
+ dob.obj=dob.obj.
+ gsub(/#{Mx[:gl_o]}(?:#lt|#060)#{Mx[:gl_c]}/,'<').
+ gsub(/#{Mx[:gl_o]}(?:#gt|#062)#{Mx[:gl_c]}/,'>').
+ gsub(/#{Mx[:gl_o]}#(?:038|amp)#{Mx[:gl_c]}/,'&').
+ gsub(/#{Mx[:gl_o]}#033#{Mx[:gl_c]}/,'!').
+ gsub(/#{Mx[:gl_o]}#035#{Mx[:gl_c]}/,'#').
+ gsub(/#{Mx[:gl_o]}#042#{Mx[:gl_c]}/,'*').
+ gsub(/#{Mx[:gl_o]}#045#{Mx[:gl_c]}/,'-').
+ gsub(/#{Mx[:gl_o]}#047#{Mx[:gl_c]}/,'/').
+ gsub(/#{Mx[:gl_o]}#095#{Mx[:gl_c]}/,'_').
+ gsub(/#{Mx[:gl_o]}#123#{Mx[:gl_c]}/,'{').
+ gsub(/#{Mx[:gl_o]}#125#{Mx[:gl_c]}/,'}').
+ gsub(/#{Mx[:gl_o]}#126#{Mx[:gl_c]}/,'~').
+ gsub(/#{Mx[:gl_o]}#169#{Mx[:gl_c]}/,'©')
+ end
+ dob=block_(dob)
+ dob=code_(dob)
+ dob.obj=dob.obj.gsub(/#{Mx[:br_page]}\s*|#{Mx[:br_page_new]}/,''). # remove page breaks
+ gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'\1').
+ gsub(/#{Mx[:mk_o]}:name#(\S+?)#{Mx[:mk_c]}/,''). # remove name links
+ gsub(/&nbsp;|#{Mx[:nbsp]}/,' '). # decide on
+ gsub(/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/,
+ ' [ \1 ]'). #"[ #{dir.url.images_local}\/\\1 ]")
+ gsub(/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}image/,
+ ' [ \1 ]'). #"[ #{dir.url.images_local}\/\\1 ]")
+ gsub(/(?:^|[^_\\])\{\s*\S+?\.(?:png|jpg|gif)\s+.+?"(.*?)"\s*\}\S+/,
+ '[image: "\1"]')
+ [dob,notes]
+ end
+ def object_marks
+ @txtobj
+ end
+ self
+ end
+end
+__END__
diff --git a/lib/sisu/current/se_clear.rb b/lib/sisu/current/se_clear.rb
index 1d76926..31621ee 100644
--- a/lib/sisu/current/se_clear.rb
+++ b/lib/sisu/current/se_clear.rb
@@ -98,7 +98,6 @@ module SiSU_Clear
def param_instantiate
@cX||=SiSU_Screen::Ansi.new(@cmd)
@@date=SiSU_Env::InfoDate.new
- @@proc=@@filename_txt=@@filename_texinfo=@@filename_html_scroll=@@filename_html_index=@@filename_html_segtoc=@@filename_semantic=@@filename_rss=@@newfile=@@drr=@@yaml=@@yamladdr=nil
@@publisher='SiSU scribe'
end
end
diff --git a/lib/sisu/current/se_file_op.rb b/lib/sisu/current/se_file_op.rb
index 3f9cb83..f70af90 100644
--- a/lib/sisu/current/se_file_op.rb
+++ b/lib/sisu/current/se_file_op.rb
@@ -347,6 +347,12 @@ module SiSU_File_Op
fn=base_filename.rst
make_file(path,fn)
end
+ def orgmode
+ path=output_path.orgmode.dir
+ make_path(path)
+ fn=base_filename.orgmode
+ make_file(path,fn)
+ end
def html_scroll
pth=output_path.html.dir
make_path(pth)
@@ -456,18 +462,30 @@ module SiSU_File_Op
fn=base_filename.manifest_txt
make_file(path,fn)
end
+ def po4a_cfg
+ path=output_path.po4a.dir
+ make_path(path)
+ fn=base_filename.po4a_cfg
+ make_file(path,fn)
+ end
def pot
path=output_path.pot.dir
make_path(path)
fn=base_filename.pot
make_file(path,fn)
end
- def po
- path=output_path.po.dir
+ def po(lng=@md.opt.lng)
+ path=output_path.po(lng).dir
make_path(path)
fn=base_filename.po
make_file(path,fn)
end
+ def po4a_sst(lng=@md.opt.lng)
+ path=output_path.po4a_sst(lng).dir
+ make_path(path)
+ fn=base_filename.po4a_sst
+ make_file(path,fn)
+ end
self
end
def place_file
@@ -526,6 +544,17 @@ module SiSU_File_Op
end
self
end
+ def orgmode
+ def dir
+ output_path.orgmode.dir + '/' \
+ + base_filename.orgmode
+ end
+ def rel
+ output_path.orgmode.rel + '/' \
+ + base_filename.orgmode
+ end
+ self
+ end
def html_scroll
def dir
output_path.html_scroll.dir + '/' \
@@ -961,6 +990,24 @@ module SiSU_File_Op
end
i18n(fnh)
end
+ def orgmode(fh=nil)
+ fh=default_hash_build(fh,Sfx[:txt_orgmode])
+ fh[:lng]=lang_code?(fh[:lng])
+ fnh=if output_dir_structure.by_filename?
+ {
+ fn: 'plain',
+ ft: fh[:ft],
+ lng: fh[:lng],
+ }
+ else
+ {
+ fn: fh[:fn],
+ ft: fh[:ft],
+ lng: fh[:lng],
+ }
+ end
+ i18n(fnh)
+ end
def html_scroll(fh=nil)
fh=default_hash_build(fh,Sfx[:html])
fh[:lng]=lang_code?(fh[:lng])
@@ -1411,6 +1458,9 @@ module SiSU_File_Op
def src
@md.fno
end
+ def po4a_cfg
+ 'po4a.cfg'
+ end
def po #check
(@fno.empty?) \
? (@md.fn[:po])
@@ -1421,6 +1471,9 @@ module SiSU_File_Op
? (@md.fn[:pot])
: (@fno + '.pot')
end
+ def po4a_sst #check
+ @fno
+ end
def sisupod
(@md.fns =~/\.ssm\.sst$/) \
? @md.fns.gsub(/(?:\~\S{2,3})?\.ssm\.sst$/,'.ssm.txz')
@@ -1712,17 +1765,33 @@ module SiSU_File_Op
end
self
end
- def po
+ def po4a
+ def dir
+ output_path.base.dir + '/' \
+ + Gt[:src] + '/' \
+ + @md.opt.fng + '/po4a'
+ end
+ def url
+ output_path.base.url + '/po4a/' \
+ + @md.fnb
+ end
+ def rcp
+ #p "#{output_path.base.dir}/po4a/#{@md.fnb}"
+ end
+ self
+ end
+ def po(lng=@md.opt.lng)
+ @lng=lng
def dir
output_path.base.dir + '/' \
+ Gt[:src] + '/' \
+ @md.opt.fng + '/po4a/po/' \
- + @md.opt.lng
+ + @lng
end
def url
output_path.base.url + '/po4a/' \
+ @md.fnb + '/po/' \
- + @md.opt.lng
+ + @lng
end
self
end
@@ -1766,6 +1835,21 @@ module SiSU_File_Op
end
self
end
+ def po4a_sst(lng=@md.opt.lng)
+ @lng=lng
+ def dir
+ output_path.base.dir + '/' \
+ + Gt[:src] + '/' \
+ + @md.opt.fng + '/po4a/' \
+ + @lng
+ end
+ def url
+ output_path.base.url + '/po4a/' \
+ + @md.fnb \
+ + @lng
+ end
+ self
+ end
def md_harvest
manifest
self
@@ -1879,6 +1963,28 @@ module SiSU_File_Op
end
self
end
+ def orgmode
+ def ft
+ 'orgmode' \
+ + DEVELOPER[:under_construction]
+ end
+ def dir
+ set_path(ft).dir.abc
+ end
+ def url
+ set_path(ft).url.abc
+ end
+ def rel
+ set_path(ft).rel.abc
+ end
+ def rcp
+ set_path(ft).rcp.abc
+ end
+ def rel_sm
+ set_path(ft).rel_sm.ab
+ end
+ self
+ end
def html_scroll
def ft
'html'
diff --git a/lib/sisu/current/se_filemap.rb b/lib/sisu/current/se_filemap.rb
index 8258002..3e4dce0 100644
--- a/lib/sisu/current/se_filemap.rb
+++ b/lib/sisu/current/se_filemap.rb
@@ -96,6 +96,9 @@ module SiSU_File_Map
if @md.opt.act[:txt_rst][:set]==:on #% --rst, --rest
ft << @md.fn[:txt_rst]
end
+ if @md.opt.act[:txt_orgmode][:set]==:on #% --orgmode
+ ft << @md.fn[:txt_orgmode]
+ end
if @md.opt.act[:xhtml][:set]==:on #% --xhtml, -b xhtml
ft << @md.fn[:xhtml]
end
@@ -164,6 +167,9 @@ module SiSU_File_Map
if @opt.act[:txt_rst][:set]==:on #% --rst, --rest
ft << 'plain.txt' << '??.plain.txt' << 'plain.??.txt'
end
+ if @opt.act[:txt_orgmode][:set]==:on #% --orgmode
+ ft << 'plain.txt' << '??.plain.txt' << 'plain.??.txt'
+ end
if @opt.act[:xhtml][:set]==:on #% --xhtml, -b xhtml
ft << 'scroll.xhtml' << '??.scroll.xhtml' << 'scroll.??.xhtml'
end
diff --git a/lib/sisu/current/se_get_init.rb b/lib/sisu/current/se_get_init.rb
index a299cd1..1a28a5a 100644
--- a/lib/sisu/current/se_get_init.rb
+++ b/lib/sisu/current/se_get_init.rb
@@ -79,15 +79,39 @@ module SiSU_Get_Init
@@tx ||=SiSU_Parts_TeXpdf::TeX.new
end
def rc_path_options
+ v=SiSU_Env::InfoVersion.instance.get_version
[
- "#{$sisu_document_markup_directory_base_fixed_path}/.sisu/#{SiSU_is.branch_version?}",
- "#{$sisu_document_markup_directory_base_fixed_path}/.sisu",
- "#{$sisu_document_markup_directory_base_fixed_path}/_sisu/#{SiSU_is.branch_version?}",
- "#{$sisu_document_markup_directory_base_fixed_path}/_sisu",
- "#{@@home}/.sisu/#{SiSU_is.branch_version?}",
- "#{@@home}/.sisu",
- "#{@@sisu_etc}/#{SiSU_is.branch_version?}",
- "#{@@sisu_etc}",
+ $sisu_document_markup_directory_base_fixed_path \
+ + '/.sisu/' \
+ + v.branch_name,
+ $sisu_document_markup_directory_base_fixed_path \
+ + '/.sisu/' \
+ + v.branch_version,
+ $sisu_document_markup_directory_base_fixed_path \
+ + '/.sisu',
+ $sisu_document_markup_directory_base_fixed_path \
+ + '/_sisu/' \
+ + v.branch_name,
+ $sisu_document_markup_directory_base_fixed_path \
+ + '/_sisu/' \
+ + v.branch_version,
+ $sisu_document_markup_directory_base_fixed_path \
+ + '/_sisu',
+ @@home \
+ + '/.sisu/' \
+ + v.branch_name,
+ @@home \
+ + '/.sisu/' \
+ + v.branch_version,
+ @@home \
+ + '/.sisu', \
+ @@sisu_etc \
+ + '/' \
+ + v.branch_name,
+ @@sisu_etc \
+ + '/' \
+ + v.branch_version,
+ @@sisu_etc,
]
end
def sisu_document_make
@@ -167,12 +191,16 @@ module SiSU_Get_Init
tell_no_yaml='WARNING - YAML loading switched off, to enable delete the file:'
if @markup_dir_changed_
@ad_path=[
+ "#{$sisu_document_markup_directory_base_fixed_path}/.sisu/#{SiSU_is.branch_name?}/skin/yml",
"#{$sisu_document_markup_directory_base_fixed_path}/.sisu/#{SiSU_is.branch_version?}/skin/yml",
"#{$sisu_document_markup_directory_base_fixed_path}/.sisu/skin/yml",
+ "#{$sisu_document_markup_directory_base_fixed_path}/_sisu/#{SiSU_is.branch_name?}/skin/yml",
"#{$sisu_document_markup_directory_base_fixed_path}/_sisu/#{SiSU_is.branch_version?}/skin/yml",
"#{$sisu_document_markup_directory_base_fixed_path}/_sisu/skin/yml",
+ "#{@@home}/.sisu/#{SiSU_is.branch_name?}/skin/yml",
"#{@@home}/.sisu/#{SiSU_is.branch_version?}/skin/yml",
"#{@@home}/.sisu/skin/yml",
+ "#{@@sisu_etc}/#{SiSU_is.branch_name?}/skin/yml",
"#{@@sisu_etc}/#{SiSU_is.branch_version?}/skin/yml",
"#{@@sisu_etc}/skin/yml",
]
diff --git a/lib/sisu/current/se_info_env.rb b/lib/sisu/current/se_info_env.rb
index 297a0a1..b411b9a 100644
--- a/lib/sisu/current/se_info_env.rb
+++ b/lib/sisu/current/se_info_env.rb
@@ -568,6 +568,12 @@ module SiSU_Info_Env
? @rc['rst']['ocn']
: false
end
+ def orgmode_ocn?
+ ((defined? @rc['orgmode']['ocn']) \
+ && @rc['orgmode']['ocn']==true) \
+ ? @rc['orgmode']['ocn']
+ : false
+ end
def widget #needs (md) #move
@rc=SiSU_Env::GetInit.new.sisu_yaml.rc
@ad=SiSU_Env::GetInit.new.ads
@@ -2112,14 +2118,6 @@ WOK
? @rc['default']['papersize'].downcase
: (defaults[:papersize].downcase)
end
- def odf_structure
- FileUtils::rm_rf(processing_path.processing_path.odf_pth)
- FileUtils::mkdir_p(processing_path.processing_path.odf_pth)
- system(
- "unzip -q #{path.share}/#{SiSU_is.branch_name?}/odf/odt.zip -d #{processing_path.odf_pth}"
- #"unzip -q #{path.share}/#{SiSU_is.branch_version?}/odf/odt.zip -d #{processing_path.odf_pth}"
- )
- end
def sisupod_gen(fns_pod)
sisupod_gen_v3(fns_pod)
end
diff --git a/lib/sisu/current/se_programs.rb b/lib/sisu/current/se_programs.rb
index 83c5797..c2b0e35 100644
--- a/lib/sisu/current/se_programs.rb
+++ b/lib/sisu/current/se_programs.rb
@@ -134,6 +134,16 @@ module SiSU_Sys_Call
false
end
end
+ def po4a #po4a
+ program='po4a'
+ program_ref="\n\t\tpo4a"
+ if program_found?(program); true
+ else
+ SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).
+ warn("#{program} is not installed #{program_ref}")
+ false
+ end
+ end
def zip #zip
program='zip'
program_ref="\n\t\tused to in the making of number of file formats, odf, epub"
diff --git a/lib/sisu/current/se_version.rb b/lib/sisu/current/se_version.rb
index 464af3d..bbbf596 100644
--- a/lib/sisu/current/se_version.rb
+++ b/lib/sisu/current/se_version.rb
@@ -75,7 +75,7 @@ module SiSU_Info_Version
end
@@lib_path=nil
def get_version
- @version={}
+ version={}
@pwd=ENV['PWD']
lib_path=
@@lib_path \
@@ -83,19 +83,47 @@ module SiSU_Info_Version
: `echo $RUBYLIB`.split(':')
@@lib_path ||=lib_path
if File.exist?(SiSU_is.version_info_path?)
- @version=YAML::load(File::open(SiSU_is.version_info_path?))
+ version=YAML::load(File::open(SiSU_is.version_info_path?))
end
- @version[:install_method]=if SiSU_is.runtime_type? ==:gem_install
+ version[:branch_version]=SiSU_is.branch_version?
+ version[:branch_number]=/^v([0-9]+)/.match(version[:branch_version])[1]
+ version[:branch_name]=SiSU_is.branch_name?
+ version[:install_method]=if SiSU_is.runtime_type? ==:gem_install
spec = Gem::Specification.find_by_name("sisu")
gem_root = spec.gem_dir
(File.dirname(__FILE__.gsub(/\/lib\/sisu\/#{SiSU_is.branch_name?}/,'')) == gem_root) \
? ' (ruby gem install)' : ''
else ''
end
- @version[:branch_name]=SiSU_is.branch_name?
- @version[:branch_version]=SiSU_is.branch_version?
- @version[:branch_number]=/^v([0-9]+)$/.match(@version[:branch_version])[1]
- @version
+ @version=version
+ def version_details_hash
+ @version
+ end
+ def project
+ version_details_hash[:project]
+ end
+ def date
+ version_details_hash[:date]
+ end
+ def date_stamp
+ version_details_hash[:date_stamp]
+ end
+ def version
+ version_details_hash[:version]
+ end
+ def branch_version
+ version_details_hash[:branch_version]
+ end
+ def branch_number
+ version_details_hash[:branch_number]
+ end
+ def branch_name
+ version_details_hash[:branch_name]
+ end
+ def install_method
+ version_details_hash[:install_method]
+ end
+ self
end
def rbversion
%x{ruby -v}.strip
@@ -118,7 +146,7 @@ module SiSU_Info_About
def sisu_version
version=SiSU_Env::InfoVersion.instance.get_version
rb_ver=SiSU_Env::InfoVersion.instance.rbversion
- if version[:version]
+ if version.version
opt_cmd=if defined? @color.cmd \
and @color.cmd =~/[ck]/
@color.cmd
@@ -126,11 +154,11 @@ module SiSU_Info_About
end
SiSU_Screen::Ansi.new(
opt_cmd,
- version[:project],
- version[:version],
- version[:date_stamp],
- version[:date],
- version[:install_method],
+ version.project,
+ version.version,
+ version.date_stamp,
+ version.date,
+ version.install_method,
rb_ver
).version
else puts 'SiSU (version information not available)'
diff --git a/lib/sisu/current/shared_markup_alt.rb b/lib/sisu/current/shared_markup_alt.rb
index 50984a2..252662b 100644
--- a/lib/sisu/current/shared_markup_alt.rb
+++ b/lib/sisu/current/shared_markup_alt.rb
@@ -79,9 +79,8 @@ module SiSU_TextRepresentation
gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'\1').
gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'\1').
gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'\1').
- gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strke_c]}/,'\1').
+ gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'\1').
gsub(/#{Mx[:fa_superscript_o]}(\d+)#{Mx[:fa_superscript_c]}/,'[\1]').
- gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,'\1').
gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,'\1').
gsub(/#{Mx[:fa_hilite_o]}(.+?)#{Mx[:fa_hilite_c]}/,'\1').
gsub(/#{Mx[:gl_o]}#(?:126|152)#{Mx[:gl_c]}/i,'~').
diff --git a/lib/sisu/current/shared_metadata.rb b/lib/sisu/current/shared_metadata.rb
index 92d32dd..1aa0a72 100644
--- a/lib/sisu/current/shared_metadata.rb
+++ b/lib/sisu/current/shared_metadata.rb
@@ -280,13 +280,13 @@ module SiSU_Metadata
@tag,@inf=%{<b><u>Generated</u></b>},''
meta << self.meta_para
end
- if defined? @md.sisu_version \
- and @md.sisu_version[:version]=~/\S+/
+ if defined? @md.project_details \
+ and @md.project_details.version=~/\S+/
v="#{tr.sisu_version}: " +
- "#{@md.sisu_version[:project]} " +
- "#{@md.sisu_version[:version]} " +
- "of #{@md.sisu_version[:date_stamp]} " +
- "(#{@md.sisu_version[:date]})"
+ "#{@md.project_details.project} " +
+ "#{@md.project_details.version} " +
+ "of #{@md.project_details.date_stamp} " +
+ "(#{@md.project_details.date})"
@tag,@inf,@class='Generated by',v,'ver'
meta << self.meta_para
end
@@ -461,7 +461,7 @@ module SiSU_Metadata
def language
if defined? @md.title.language \
and @md.title.language
- ' :language: ' + @md.title.language.join(', ')
+ ' :language: ' + @md.title.language
else nil
end
end
@@ -674,13 +674,13 @@ module SiSU_Metadata
# end
nil
end
- def identifier
- if defined? @md.classify.identifier \
- and @md.classify.identifier
- ' :identifier: ' + @md.classify.identifier
- else nil
- end
- end
+ #def identifier
+ # if defined? @md.classify.identifier \
+ # and @md.classify.identifier
+ # ' :identifier: ' + @md.classify.identifier
+ # else nil
+ # end
+ #end
def loc
if defined? @md.classify.loc \
and @md.classify.loc
@@ -1216,13 +1216,13 @@ WOK
tag,inf=tr.last_generated,@md.generated
meta << meta_para(tag,inf)
end
- if defined? @md.sisu_version \
- and @md.sisu_version[:version]=~/\S+/
+ if defined? @md.project_details \
+ and @md.project_details.version=~/\S+/
tag=tr.sisu_version
- inf="#{@md.sisu_version[:project]} " +
- "#{@md.sisu_version[:version]} " +
- "of #{@md.sisu_version[:date_stamp]} " +
- "(#{@md.sisu_version[:date]})"
+ inf="#{@md.project_details.project} " +
+ "#{@md.project_details.version} " +
+ "of #{@md.project_details.date_stamp} " +
+ "(#{@md.project_details.date})"
meta << meta_para(tag,inf)
end
if defined? @md.ruby_version \
diff --git a/lib/sisu/current/src_po4a_share.rb b/lib/sisu/current/src_po4a_share.rb
new file mode 100644
index 0000000..6b81d62
--- /dev/null
+++ b/lib/sisu/current/src_po4a_share.rb
@@ -0,0 +1,309 @@
+# encoding: utf-8
+=begin
+
+* Name: SiSU
+
+** Description: documents, structuring, processing, publishing, search
+*** pot file generation
+
+** Author: Ralph Amissah
+ <ralph@amissah.com>
+ <ralph.amissah@gmail.com>
+
+** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
+ 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah,
+ All Rights Reserved.
+
+** License: GPL 3 or later:
+
+ SiSU, a framework for document structuring, publishing and search
+
+ Copyright (C) Ralph Amissah
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the Free
+ Software Foundation, either version 3 of the License, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ more details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program. If not, see <http://www.gnu.org/licenses/>.
+
+ If you have Internet connection, the latest version of the GPL should be
+ available at these locations:
+ <http://www.fsf.org/licensing/licenses/gpl.html>
+ <http://www.gnu.org/licenses/gpl.html>
+
+ <http://www.sisudoc.org/sisu/en/manifest/gpl.fsf.html>
+
+** SiSU uses:
+ * Standard SiSU markup syntax,
+ * Standard SiSU meta-markup syntax, and the
+ * Standard SiSU object citation numbering and system
+
+** Hompages:
+ <http://www.jus.uio.no/sisu>
+ <http://www.sisudoc.org>
+
+** Git
+ <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=summary>
+ <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=blob;f=lib/sisu/current/src_po4a_share.rb;hb=HEAD>
+
+=end
+#module SiSU_SStm_AO_SStm
+module SiSU_Languages_Selected
+ require_relative 'utils_response' # utils_response.rb
+ def language
+ def sisu_languages_available
+ Px[:lng_lst]
+ end
+ def source_language_selected_str
+ @opt.act[:po4a_lang][:src] \
+ ? @opt.act[:po4a_lang][:src]
+ : 'en'
+ end
+ def translation_languages_selected
+ @opt.act[:po4a_lang][:trn] \
+ ? @opt.act[:po4a_lang][:trn]
+ : []
+ end
+ def translation_languages_available
+ sisu_languages_available - [source_language_selected_str]
+ end
+ def translation_languages_selected_that_are_available
+ translation_languages_selected & sisu_languages_available
+ end
+ def translation_languages_selected_that_are_available_str
+ translation_languages_selected_that_are_available.join(' ')
+ end
+ def translation_languages_selected_str
+ @opt.act[:po4a_lang][:trn].join(' ')
+ end
+ self
+ end
+end
+module SiSU_Po4a_Project
+ class Po4aCfg
+ include SiSU_Composite_Doc_Utils # composite doc, .ssm, extract all related insert files, array of filenames test
+ include SiSU_Response
+ include SiSU_Languages_Selected
+ def initialize(opt,file)
+ @opt,@file=opt,file
+ end
+ def song
+ if @opt.lng==language.source_language_selected_str
+ ans=response?('po4a config file')
+ if ans
+ po4a_cfg
+ end
+ end
+ end
+ def po4a_cfg_filename
+ 'po4a.cfg'
+ end
+ def dir
+ def pwd
+ Dir.pwd
+ end
+ def po4a_
+ 'po4a/' # ''
+ end
+ def pot
+ #po4a_ + 'pot'
+ 'pot'
+ end
+ def po
+ #po4a_ + 'po'
+ 'po'
+ end
+ self
+ end
+ def po4a_cfg_file
+ File.open("#{Dir.pwd}/#{po4a_cfg_filename}",'w')
+ end
+ def po4a_cfg
+ lng=language.source_language_selected_str
+ doc_import_list=composite_and_imported_filenames_array(@opt.fno)
+ po4a_cfg_arr=[]
+ po4a_cfg_arr \
+ << "[po4a_langs] #{language.translation_languages_selected_that_are_available_str}"
+ po4a_cfg_arr \
+ << "[po4a_paths] #{dir.pot}/$master.pot $lang:#{dir.po}/$lang/$master.po"
+ doc_import_list.each do |file_src|
+ file_src_fn=
+ file_src.gsub(/#{language.source_language_selected_str}\//,'')
+ po4a_cfg_arr \
+ << "[type: text] #{lng}/#{file_src} $lang:$lang/#{file_src_fn}"
+ end
+ file=@file.write_file.po4a_cfg
+ po4a_cfg_arr.each do |txt|
+ puts txt
+ file << txt << "\n"
+ end
+ file.close
+ end
+ end
+ class Po4aProject
+ include SiSU_Languages_Selected
+ include SiSU_Response
+ def initialize(opt,file)
+ @opt,@file=opt,file
+ end
+ def song
+ make_paths
+ if FileTest.directory?(@file.output_path.po4a.dir)
+ Dir.chdir(@file.output_path.po4a.dir)
+ dirs=Dir['*/']
+ dirs_language=[]
+ dirs.each do |x|
+ dirs_language << x.gsub(/\/$/,'')
+ end
+ dirs_translation = \
+ (language.translation_languages_available & dirs_language)
+ end
+ if (language.translation_languages_available & [@opt.lng]).length == 1
+ puts %{gettext for: #{dirs_translation}
+in #{Dir.pwd}}
+ ans=response?('gettext?')
+ if ans
+ gettext_if_any_build_src_trans_po
+ end
+ end
+ ans=response?('build project?')
+ if ans
+ build_src_master_to_pot_and_po_and_srcs
+ end
+ end
+ def flags
+ def debug
+ '-d -v'
+ end
+ def normal
+ ''
+ end
+ def quiet
+ '-q'
+ end
+ self
+ end
+ def build_src_master_to_pot_and_po_and_srcs
+ if SiSU_Sys_Call::SystemCall.new.po4a
+ pwd=Dir.pwd
+ #cmd='po4a --keep 0 -M UTF-8 --no-backups ' \
+ #+ '--package-name ' \
+ #+ 'sisu-manual' + ' ' \
+ #+ flags.normal + ' ' \
+ #+ filename.po4a_cfg
+ cmd='po4a --keep 0 -M UTF-8' \
+ + flags.normal + ' ' \
+ + @file.base_filename.po4a_cfg
+ Dir.chdir(@file.output_path.po4a.dir)
+ system("
+ cd #{@file.output_path.po4a.dir}
+ #{cmd}
+ cd -
+ "); puts cmd
+ Dir.chdir(pwd)
+ end
+ end
+ def gettext_if_any_build_src_trans_po
+ Dir.chdir(@file.output_path.po4a.dir)
+ dirs=Dir['*/']
+ dirs_language=[]
+ dirs.each do |x|
+ dirs_language << x.gsub(/\/$/,'')
+ end
+ dirs_translation = \
+ (language.translation_languages_available & dirs_language)
+ files_src=Dir.glob("./#{source_language_selected_str}/*.ss[tmi]")
+ dirs_translation.each do |lng|
+ files_src.each do |file|
+ fn=file.gsub(/\.\/#{source_language_selected_str}\//,'')
+ system("
+ po4a-gettextize -f text -M utf-8 \
+ -m ./#{source_language_selected_str}/#{fn} \
+ -l ./#{lng}/#{fn} \
+ -p ./po/#{lng}/#{fn}.po
+ ")
+ puts fn
+ end
+ end
+ end
+ def dir_mk(dir)
+ unless FileTest.directory?(dir)
+ FileUtils::mkdir_p(dir)
+ end
+ end
+ def make_paths
+ dir_mk(@file.output_path.pot.dir)
+ dir_mk(@file.output_path.po.dir)
+ end
+ def clean
+ #rm -f po/*/*.po~
+ #rm -rf ../build
+ FileUtils.rm_f Dir.glob("./#{dir.po}/*/*.po~")
+ end
+ def distclean
+ #rm -f po4a.cfg
+ #rm -rf $(LANGUAGES)
+ FileUtils::rm_f(filename.po4a_cfg)
+ FileUtils::rm_r(language.possible_translations,:force => true)
+ #FileUtils::rm_r(language.translation_languages_selected_that_are_available,:force => true)
+ end
+ end
+ class Po4aDistClean
+ include SiSU_Languages_Selected
+ include SiSU_Response
+ def initialize(opt,file)
+ @opt,@file=opt,file
+ end
+ def song
+ pwd=Dir.pwd
+ if FileTest.directory?(@file.output_path.po4a.dir)
+ Dir.chdir(@file.output_path.po4a.dir)
+ dirs=Dir['*/']
+ dirs_language=[]
+ dirs.each do |x|
+ dirs_language << x.gsub(/\/$/,'')
+ end
+ dirs_translation = \
+ (language.translation_languages_available & dirs_language)
+ if dirs_translation.length > 0
+ puts %{remove language translation directorie(s): #{dirs_translation}
+in #{Dir .pwd}}
+ ans=response?('disclean?')
+ if ans
+ FileUtils::rm_f(@file.base_filename.po4a_cfg)
+ FileUtils::rm_r(dirs_translation,:force => true)
+ #FileUtils::rm_r(language.translation_languages_available,:force => true)
+ end
+ end
+ Dir.chdir(pwd)
+ end
+ end
+ end
+end
+#end
+__END__
+REMOVE
+&#033;\|&#035;\|&&#042;\|&#045;\|&#047;\|&#095;\|&#123;\|&#125;\|&#126;\|&#
+
+tables are problematic, difficult to reconstitute instruction, check
+
+metadata, move to top? and work on
+
+footnotes, different types, asterisk, also do you want to have separate
+paragraphs, or breaks within one block?
+
+where no ocn appropriately use ~# or -# or indeed 1~name-
+
+comments in document, what to do about them, not sure they are currently
+retained in dal, could be quite valuable to keep
+
+Translate Shell
+http://www.soimort.org/translate-shell/
+translate.google.com
diff --git a/lib/sisu/current/po4a.rb b/lib/sisu/current/src_po4a_shelf.rb
index 3de3ff7..6a473b1 100644
--- a/lib/sisu/current/po4a.rb
+++ b/lib/sisu/current/src_po4a_shelf.rb
@@ -51,7 +51,7 @@
** Git
<http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=summary>
- <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=blob;f=lib/sisu/current/po4a.rb;hb=HEAD>
+ <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=blob;f=lib/sisu/current/src_po4a_shelf.rb;hb=HEAD>
=end
module SiSU_Po4a
@@ -60,11 +60,15 @@ module SiSU_Po4a
include SiSU_Env
require_relative 'ao_composite' # ao_composite.rb
require_relative 'shared_metadata' # shared_metadata.rb
- require_relative 'po4a_set' # po4a_set.rb
+ require_relative 'src_po4a_shelf_set' # src_po4a_shelf_set.rb
include SiSU_Param
+ require_relative 'object_munge' # object_munge.rb
+ require_relative 'utils_composite' # utils_composite.rb
class Source
+ include SiSU_Object_Munge
@@opt_src,@@opt_trn,@@opt_src_,@@opt_trn_,@@md_src,@@md_trn=
nil, nil, nil, nil, nil, nil
+ @@auto_translation_ = :go
def initialize(opt,fn=nil)
@opt,@fn=opt,fn
#unless @opt.fns =~/(.+?\.(?:-|ssm\.)?sst)$/
@@ -85,6 +89,95 @@ module SiSU_Po4a
@@md_src=SiSU_Param::Parameters.new(opt).get
end
end
+ def wrap_width_set(md,env)
+ if defined? md.make.plaintext_wrap \
+ and md.make.plaintext_wrap
+ md.make.plaintext_wrap
+ elsif defined? env.plaintext_wrap \
+ and env.plaintext_wrap
+ env.plaintext_wrap
+ else 78
+ end
+ end
+ def process_file(md,env,file,wrap_width,fn)
+ unless @opt.act[:quiet][:set]==:on
+ tool=(@opt.act[:verbose][:set]==:on \
+ || @opt.act[:verbose_plus][:set]==:on \
+ || @opt.act[:maintenance][:set]==:on) \
+ ? "#{env.program.text_editor} #{file.output_path.pot.dir}/"
+ : @opt.fns
+ (@opt.act[:verbose][:set]==:on \
+ || @opt.act[:verbose_plus][:set]==:on \
+ || @opt.act[:maintenance][:set]==:on) \
+ ? SiSU_Screen::Ansi.new(
+ @opt.act[:color_state][:set],
+ 'Pot po4a',
+ tool
+ ).green_hi_blue
+ : SiSU_Screen::Ansi.new(
+ @opt.act[:color_state][:set],
+ 'Pot po4a',
+ tool
+ ).green_title_hi
+ if (@opt.act[:verbose][:set]==:on \
+ || @opt.act[:verbose_plus][:set]==:on \
+ || @opt.act[:maintenance][:set]==:on)
+ SiSU_Screen::Ansi.new(
+ @opt.act[:color_state][:set],
+ @opt.fns,
+ file.output_path.pot.dir
+ ).flow
+ end
+ end
+ if @opt.fns =~/\S+?~#{@lang_regx}\.ss[mti]/ \
+ or @opt.f_pth[:lng] !=@opt.lng_base
+ opt_lang_trn_fn=fn
+ @ao_arr_lang_trans=
+ SiSU_AO::Source.new(@opt,opt_lang_trn_fn,:po4a).get # ao file drawn here
+ opt_lang_src_fn=(fn =~/\S+?~\S{2}(?:_\S{2})?\.ss[mti]/) \
+ ? (fn.gsub(/(\S+?)~\S{2}(?:_\S{2})?(\.ss[mti])/,'\1\2')) #check i
+ : fn
+ transdir,srcdir=Dir.pwd,Dir.pwd
+ if Dir.pwd.to_s =~/\/#{@lang_regx}$/
+ transdir=Dir.pwd
+ srcdir=transdir.
+ gsub(/\/#{@lang_regx}$/,
+ "/#{@opt.lng_base}")
+ if FileTest.directory?(srcdir)
+ Dir.chdir(srcdir)
+ end
+ else nil
+ end
+ if FileTest.file?("#{srcdir}/#{opt_lang_src_fn}")
+ @ao_arr_lang_src=
+ SiSU_AO::Source.new(
+ @@opt_src,
+ opt_lang_src_fn,
+ :po4a
+ ).get # ao file drawn here
+ else
+ puts "no identified source document"
+ exit
+ end
+ Dir.chdir(transdir) if transdir
+ else
+ @ao_arr_lang_src=
+ SiSU_AO::Source.new(
+ @opt,
+ fn,
+ :po4a
+ ).get # ao file drawn here
+ @ao_arr_lang_trans=nil
+ end
+ SiSU_Po4a::Source::Scroll.new(
+ fn,
+ @ao_arr_lang_src,
+ @ao_arr_lang_trans,
+ @@md_src,
+ @@md_trn,
+ wrap_width
+ ).songsheet
+ end
def read
begin
src={}
@@ -96,86 +189,12 @@ module SiSU_Po4a
[@opt.fns]
end
md=SiSU_Param::Parameters.new(@opt).get
+ env=SiSU_Env::InfoEnv.new(@opt.fns)
+ file=SiSU_Env::FileOp.new(md)
+ Po4aCfg.new(@opt,file).po4a_cfg
+ wrap_width=wrap_width_set(md,env)
src[:files].each do |fn|
- env=SiSU_Env::InfoEnv.new(@opt.fns)
- file=SiSU_Env::FileOp.new(md)
- m=/((.+?)(?:\~\w\w(?:_\w\w)?)?)\.((?:-|ssm\.)?sst|ssm|ssi)$/ #watch added match for sss
- @fnn,@fnb,@fnt=fn[m,1],fn[m,2],fn[m,3]
- unless @opt.act[:quiet][:set]==:on
- tool=(@opt.act[:verbose][:set]==:on \
- || @opt.act[:verbose_plus][:set]==:on \
- || @opt.act[:maintenance][:set]==:on) \
- ? "#{env.program.text_editor} #{file.output_path.pot.dir}/"
- : @opt.fns
- (@opt.act[:verbose][:set]==:on \
- || @opt.act[:verbose_plus][:set]==:on \
- || @opt.act[:maintenance][:set]==:on) \
- ? SiSU_Screen::Ansi.new(
- @opt.act[:color_state][:set],
- 'Pot po4a',
- tool
- ).green_hi_blue
- : SiSU_Screen::Ansi.new(
- @opt.act[:color_state][:set],
- 'Pot po4a',
- tool
- ).green_title_hi
- if (@opt.act[:verbose][:set]==:on \
- || @opt.act[:verbose_plus][:set]==:on \
- || @opt.act[:maintenance][:set]==:on)
- SiSU_Screen::Ansi.new(
- @opt.act[:color_state][:set],
- @opt.fns,
- file.output_path.pot.dir
- ).flow
- end
- end
- if @opt.fns =~/\S+?~#{@lang_regx}\.ss[mti]/ \
- or @opt.f_pth[:lng] !=@opt.lng_base
- opt_lang_trn_fn=fn
- @ao_array_lang_translation=
- SiSU_AO::Source.new(@opt,opt_lang_trn_fn,:po4a).get # ao file drawn here
- opt_lang_src_fn=if fn =~/\S+?~\S{2}(?:_\S{2})?\.ss[mti]/
- fn.gsub(/(\S+?)~\S{2}(?:_\S{2})?(\.ss[mti])/,'\1\2') #check i
- else fn
- end
- transdir,srcdir=Dir.pwd,Dir.pwd
- if Dir.pwd.to_s =~/\/#{@lang_regx}$/
- transdir=Dir.pwd
- srcdir=transdir.gsub(/\/#{@lang_regx}$/,"/#{@opt.lng_base}")
- if FileTest.directory?(srcdir)
- Dir.chdir(srcdir)
- end
- else nil
- end
- if FileTest.file?("#{srcdir}/#{opt_lang_src_fn}")
- @ao_array_lang_src=
- SiSU_AO::Source.new(@@opt_src,opt_lang_src_fn,:po4a).get # ao file drawn here
- else
- puts "no identified source document"
- exit
- end
- Dir.chdir(transdir) if transdir
- else
- @ao_array_lang_src=
- SiSU_AO::Source.new(@opt,fn,:po4a).get # ao file drawn here
- @ao_array_lang_translation=nil
- end
- wrap_width=if defined? md.make.plaintext_wrap \
- and md.make.plaintext_wrap
- md.make.plaintext_wrap
- elsif defined? env.plaintext_wrap \
- and env.plaintext_wrap
- env.plaintext_wrap
- else 78
- end
- SiSU_Po4a::Source::Scroll.new(
- fn,
- @ao_array_lang_src,
- @ao_array_lang_translation,
- @@md_src,@@md_trn,
- wrap_width
- ).songsheet
+ process_file(md,env,file,wrap_width,fn)
end
rescue
SiSU_Errors::Rescued.new($!,$@,@opt.selections.str,@opt.fns).location do
@@ -195,7 +214,9 @@ module SiSU_Po4a
? md_src
: md_trn
@tab="\t"
- @@endnotes_=(@md.opt.selections.str =~/--endnote/) ? true : false # --footnote
+ @@endnotes_=(@md.opt.selections.str =~/--endnote/) \
+ ? true
+ : false # --footnote
@pot={
body: [],
open: [],
@@ -209,24 +230,20 @@ module SiSU_Po4a
(@md.opt.selections.str =~/--dos/) ? "\r\n" : "\n" # --unix
end
def songsheet
-############## BUG @fn changes value
fn=@fn
pot=pot_markup(@data_src,@data_trn)
publish(fn,pot)
end
- def extract_endnotes(dob='') #% used for extraction of endnotes from paragraphs
- notes_a=dob.obj.scan(/#{Mx[:en_a_o]}([\d]+\s+.+?)#{Mx[:en_a_c]}/)
- ##notes_a=dob.obj.scan(/#{Mx[:en_a_o]}([\d*+]+\s+.+?)#{Mx[:en_a_c]}/)
- #notes_b=dob.obj.scan(/#{Mx[:en_b_o]}([\d*+]+\s+.+?)#{Mx[:en_b_c]}/)
- @n=[]
- notes_a.flatten.each do |n| #high cost to deal with <br> appropriately within plaintext, consider
- n=n.dup.to_s
- n=n.gsub(/^([\d]+)\s+/,'^~\1 ').
- gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,
- ' \\\\\\ ')
- @n << n
- end
- notes_a=@n.flatten
+ def pot_structure_wrap(desc,orig,trans,indent=0,hang=0)
+ SiSU_Po4aUtils::Wrap.new(
+ @md,
+ orig,
+ trans,
+ desc,
+ @wrap_width,
+ indent,
+ hang
+ )
end
def wrap_endnotes(orig_notes='',trn_notes='')
nt=@@endnotes_ ? 'endnote' : 'footnote'
@@ -258,7 +275,7 @@ module SiSU_Po4a
: trn_notes[i].to_s
else ''
end
- util=pot_structure(desc,orig,trans)
+ util=pot_structure_wrap(desc,orig,trans)
wrap=util.line_wrap
wrap=if wrap =~ /^\s*\^~[\d*+]+\s+.+?\s*\Z/m
wrap.gsub(/^\s*(\^~[\d*+]+)\s+(.+?)\s*\Z/m, <<GSUB
@@ -533,247 +550,327 @@ GSUB
#puts z unless z.empty?
end
end
- def pot_structure(desc,orig,trans,indent=0,hang=0)
- SiSU_Po4aUtils::Wrap.new(
- @md,
- orig,
- trans,
- desc,
- @wrap_width,
- indent,
- hang
- )
- end
- def pot_structure_heading(dob_src='',notes_s='',dob_trn='',notes_t='') #% used to extract the structure of a document
- lv=n=n3=nil
- lv=dob_src.ln
- n=lv - 1
- n3=lv + 2
- util=nil
- fn=(dob_src.name=~/[a-z\d]/i) ? dob_src.name : ''
- mark="#{dob_src.lv}~#{fn} "
- d="#{dob_src.is.to_s} (level #{dob_src.lv})"
- instruct=s_mark=''
- if @md.opt.act[:maintenance][:set]==:on
- instruct=%{\n# markup for headings is marker at the start of the line/object, } \
- + %{indicating the heading level, and if provided an associated name tag, } \
- + %{this heading is "#{mark}"}
- s_mark="\n# " + %{"\\n\\n#{mark}...\\n\\n"}
- end
- desc="#{d}#{s_mark}#{instruct}"
- orig="#{s_mark}#{dob_src.obj}"
- trans=(dob_trn=='') ? '' : "#{s_mark}#{dob_trn.obj}"
- util=pot_structure(desc,orig,trans)
- wrapped=util.line_wrap
- @pot[:body] << wrapped << br # main text, contents, body KEEP
- if @@endnotes[:para] \
- and notes_s.length > 0 \
- and not @@endnotes_
- @pot[:body] << br
- wrap_endnotes(notes_s,notes_t)
- elsif @@endnotes[:para] \
- and @@endnotes_
- @pot[:body] << br*2
+ def auto_translate?(set_to=nil)
+ @@auto_translation_=
+ if @md.opt.act[:po4a_lang_trans][:set]==:on
+ set_to \
+ ? set_to
+ : @@auto_translation_
+ else :skip
end
end
- def pot_structure_para(dob_src='',notes_s='',dob_trn='',notes_t='') #% used to extract the structure of a document
- util=nil
- wrapped=if dob_src.indent =~/[1-9]/ \
- and dob_src.indent == dob_src.hang
- s_mark=desc=orig=trans=''
- if dob_src.bullet_
- mark="_#{dob_src.indent}* "
- d="#{dob_src.is.to_s}: indent #{dob_src.indent}, bullet"
- instruct=s_mark=''
- if @md.opt.act[:maintenance][:set]==:on
- instruct=%{\n# markup for indented bullet text is at the start of the line/object, } \
- + %{an underscore followed by the indent level and an asterisk "#{mark}"}
- s_mark="\n# " + %{"\\n\\n#{mark}...\\n\\n"}
- end
- desc="#{d}#{s_mark}#{instruct}"
- else
- mark="_#{dob_src.indent} "
- d="#{dob_src.is.to_s}: indent #{dob_src.indent}"
- instruct=s_mark=''
- if @md.opt.act[:maintenance][:set]==:on
- instruct=%{\n# markup for indented text is at the start of the line/object, } \
- + %{an underscore followed by the indent level "#{mark}"}
- s_mark="\n# " + %{"\\n\\n#{mark}...\\n\\n"}
- end
- desc="#{d}#{s_mark}#{instruct}"
+ def auto_translation(src_txt,markup=:src) # check for an appropriate request flag
+ auto_translate?(:skip)
+ begin
+ src_txt_clean=clean_text(src_txt,markup)
+ src_txt_clean=src_txt_clean.
+ gsub(/\n/,' ').
+ gsub(/"/,'\"').
+ gsub(/([()])/,'\\\\\1')
+ trans=''
+ unless auto_translate? == :skip
+ require 'timeout'
+ Timeout::timeout(60) {
+ trans=`trans -b -no-ansi en:#{@md.opt.f_pth[:lng_is]} #{src_txt_clean}`.strip
+ unless trans.empty?
+ trans + ' {[G.Tr]}http://translate.google.com'
+ end
+ }
end
- orig="#{s_mark}#{dob_src.obj}"
- trans=(dob_trn=='') ? '' : "#{s_mark}#{dob_trn.obj}"
- util=pot_structure(desc,orig,trans)
- elsif dob_src.hang =~/[0-9]/ \
- and dob_src.indent != dob_src.hang
- s_mark=desc=orig=trans=''
- mark="_#{dob_src.hang}_#{dob_src.indent} "
- d="#{dob_src.is.to_s}: hang #{dob_src.hang} indent #{dob_src.indent}"
+ trans
+ rescue
+ auto_translate?(:skip)
+ p 'timeout issues with translation, skip remaining'
+ end
+ end
+ def pot_structure
+ def heading(dob_src='',notes_s='',dob_trn='',notes_t='') #% used to extract the structure of a document
+ lv=n=n3=nil
+ lv=dob_src.ln
+ n=lv - 1
+ n3=lv + 2
+ util=nil
+ fn=(dob_src.name=~/[a-z\d]/i) ? dob_src.name : ''
+ mark="#{dob_src.lv}~#{fn} "
+ d="#{dob_src.is.to_s} (level #{dob_src.lv})"
instruct=s_mark=''
if @md.opt.act[:maintenance][:set]==:on
- instruct=%{\n# markup for indented text with a first line indented } \
- + %{to a different level from the rest of the paragraph, } \
- + %{is at the start of the line/object, } \
- + %{an underscore and the first indent level } \
- + %{a second underscore and the indent level for the rest of the paragraph, "#{mark1}"}
+ instruct=%{\n# markup for headings is marker at the start of the line/object, } \
+ + %{indicating the heading level, and if provided an associated name tag, } \
+ + %{this heading is "#{mark}"}
s_mark="\n# " + %{"\\n\\n#{mark}...\\n\\n"}
end
desc="#{d}#{s_mark}#{instruct}"
orig="#{s_mark}#{dob_src.obj}"
- trans=(dob_trn=='') ? '' : "#{s_mark}#{dob_trn.obj}"
- util=pot_structure(desc,orig,trans)
- else
- s_mark=desc=orig=trans=''
- if dob_src.bullet_
- mark='_* '
- d="#{dob_src.is.to_s}: bullet"
+ trans=((dob_trn=='') \
+ || (dob_src.obj == dob_trn.obj)) \
+ ? ''
+ : "#{s_mark}#{dob_trn.obj}"
+ if @md.opt.f_pth[:lng_is] !=@md.opt.lng_base \
+ and trans.empty? \
+ and auto_translate?
+ trans=auto_translation(dob_src.obj,:src)
+ end
+ util=pot_structure_wrap(desc,orig,trans)
+ wrapped=util.line_wrap
+ @pot[:body] << wrapped << br # main text, contents, body KEEP
+ if @@endnotes[:para] \
+ and notes_s.length > 0 \
+ and not @@endnotes_
+ @pot[:body] << br
+ wrap_endnotes(notes_s,notes_t)
+ elsif @@endnotes[:para] \
+ and @@endnotes_
+ @pot[:body] << br*2
+ end
+ end
+ def para(dob_src='',notes_s='',dob_trn='',notes_t='') #% used to extract the structure of a document
+ util=nil
+ wrapped=if dob_src.indent =~/[1-9]/ \
+ and dob_src.indent == dob_src.hang
+ s_mark=desc=orig=trans=''
+ if dob_src.bullet_
+ mark="_#{dob_src.indent}* "
+ d="#{dob_src.is.to_s}: indent #{dob_src.indent}, bullet"
+ instruct=s_mark=''
+ if @md.opt.act[:maintenance][:set]==:on
+ instruct=%{\n# markup for indented bullet text is at the start of the line/object, } \
+ + %{an underscore followed by the indent level and an asterisk "#{mark}"}
+ s_mark="\n# " + %{"\\n\\n#{mark}...\\n\\n"}
+ end
+ desc="#{d}#{s_mark}#{instruct}"
+ else
+ mark="_#{dob_src.indent} "
+ d="#{dob_src.is.to_s}: indent #{dob_src.indent}"
+ instruct=s_mark=''
+ if @md.opt.act[:maintenance][:set]==:on
+ instruct=%{\n# markup for indented text is at the start of the line/object, } \
+ + %{an underscore followed by the indent level "#{mark}"}
+ s_mark="\n# " + %{"\\n\\n#{mark}...\\n\\n"}
+ end
+ desc="#{d}#{s_mark}#{instruct}"
+ end
+ orig="#{s_mark}#{dob_src.obj}"
+ trans=((dob_trn=='') \
+ || (dob_src.obj == dob_trn.obj)) \
+ ? ''
+ : "#{s_mark}#{dob_trn.obj}"
+ if @md.opt.f_pth[:lng_is] !=@md.opt.lng_base \
+ and trans.empty? \
+ and auto_translate?
+ trans=auto_translation(dob_src.obj,:src)
+ end
+ util=pot_structure_wrap(desc,orig,trans)
+ elsif dob_src.hang =~/[0-9]/ \
+ and dob_src.indent != dob_src.hang
+ s_mark=desc=orig=trans=''
+ mark="_#{dob_src.hang}_#{dob_src.indent} "
+ d="#{dob_src.is.to_s}: hang #{dob_src.hang} indent #{dob_src.indent}"
instruct=s_mark=''
if @md.opt.act[:maintenance][:set]==:on
- instruct=%{\n# markup for indented text is at the start of the line/object, } \
- + %{an underscore followed by an asterisk "#{mark}"}
+ instruct=%{\n# markup for indented text with a first line indented } \
+ + %{to a different level from the rest of the paragraph, } \
+ + %{is at the start of the line/object, } \
+ + %{an underscore and the first indent level } \
+ + %{a second underscore and the indent level for the rest of the paragraph, "#{mark1}"}
s_mark="\n# " + %{"\\n\\n#{mark}...\\n\\n"}
end
desc="#{d}#{s_mark}#{instruct}"
orig="#{s_mark}#{dob_src.obj}"
- trans=(dob_trn=='') ? '' : "#{s_mark}#{dob_trn.obj}"
+ trans=((dob_trn=='') \
+ || (dob_src.obj == dob_trn.obj)) \
+ ? ''
+ : "#{s_mark}#{dob_trn.obj}"
+ if @md.opt.f_pth[:lng_is] !=@md.opt.lng_base \
+ and trans.empty? \
+ and auto_translate?
+ trans=auto_translation(dob_src.obj,:src)
+ end
+ util=pot_structure_wrap(desc,orig,trans)
else
- mark=''
- d=dob_src.is.to_s
- instruct=%{\n# regular paragraph, no special markup}
- if @md.opt.act[:maintenance][:set]==:on
- instruct="\n# "
- s_mark="\n# " + %{"\\n\\n#{mark}...\\n\\n"}
+ s_mark=desc=orig=trans=''
+ if dob_src.bullet_
+ mark='_* '
+ d="#{dob_src.is.to_s}: bullet"
+ instruct=s_mark=''
+ if @md.opt.act[:maintenance][:set]==:on
+ instruct=%{\n# markup for indented text is at the start of the line/object, } \
+ + %{an underscore followed by an asterisk "#{mark}"}
+ s_mark="\n# " + %{"\\n\\n#{mark}...\\n\\n"}
+ end
+ desc="#{d}#{s_mark}#{instruct}"
+ orig="#{s_mark}#{dob_src.obj}"
+ trans=((dob_trn=='') \
+ || (dob_src.obj == dob_trn.obj)) \
+ ? ''
+ : "#{s_mark}#{dob_trn.obj}"
+ if @md.opt.f_pth[:lng_is] !=@md.opt.lng_base \
+ and trans.empty? \
+ and auto_translate?
+ trans=auto_translation(dob_src.obj,:src)
+ end
+ else
+ mark=''
+ d=dob_src.is.to_s
+ instruct=%{\n# regular paragraph, no special markup}
+ if @md.opt.act[:maintenance][:set]==:on
+ instruct="\n# "
+ s_mark="\n# " + %{"\\n\\n#{mark}...\\n\\n"}
+ end
+ desc="#{d}#{s_mark}#{instruct}"
+ orig=dob_src.obj
+ trans=((dob_trn=='') \
+ || (dob_src.obj == dob_trn.obj)) \
+ ? ''
+ : "#{s_mark}#{dob_trn.obj}"
+ if @md.opt.f_pth[:lng_is] !=@md.opt.lng_base \
+ and trans.empty? \
+ and auto_translate?
+ trans=auto_translation(dob_src.obj,:src)
+ end
end
- desc="#{d}#{s_mark}#{instruct}"
- orig=dob_src.obj
- trans=(dob_trn=='') ? '' : dob_trn.obj
+ util=pot_structure_wrap(desc,orig,trans)
+ end
+ wrapped=util.line_wrap
+ @pot[:body] << wrapped << br # main text, contents, body KEEP
+ if @@endnotes[:para] \
+ and notes_s.length > 0 \
+ and not @@endnotes_
+ @pot[:body] << br
+ wrap_endnotes(notes_s,notes_t)
+ elsif @@endnotes[:para] \
+ and @@endnotes_
+ @pot[:body] << br*2
end
- util=pot_structure(desc,orig,trans)
- end
- wrapped=util.line_wrap
- @pot[:body] << wrapped << br # main text, contents, body KEEP
- if @@endnotes[:para] \
- and notes_s.length > 0 \
- and not @@endnotes_
- @pot[:body] << br
- wrap_endnotes(notes_s,notes_t)
- elsif @@endnotes[:para] \
- and @@endnotes_
- @pot[:body] << br*2
end
- end
- def pot_structure_block(dob_src='',notes_s='',dob_trn='',notes_t='') #% used to extract the structure of a document
- mark="block{\\n\\n...\\n\\n}block"
- d=dob_src.is.to_s
- instruct=s_mark=''
- if @md.opt.act[:maintenance][:set]==:on
- instruct=%{\n# block text is a text block with an opening and closing marker, } \
- + %{the content of which may be wrapped}
- s_mark="\n# " + %{"\\n\\n#{mark}\\n\\n"}
+ def block(dob_src='',notes_s='',dob_trn='',notes_t='') #% used to extract the structure of a document
+ mark="block{\\n\\n...\\n\\n}block"
+ d=dob_src.is.to_s
+ instruct=s_mark=''
+ if @md.opt.act[:maintenance][:set]==:on
+ instruct=%{\n# block text is a text block with an opening and closing marker, } \
+ + %{the content of which may be wrapped}
+ s_mark="\n# " + %{"\\n\\n#{mark}\\n\\n"}
+ end
+ desc="#{d}#{s_mark}#{instruct}"
+ orig=dob_src.obj
+ trans=((dob_trn=='') \
+ || (dob_src.obj == dob_trn.obj)) \
+ ? ''
+ : "#{s_mark}#{dob_trn.obj}"
+ if @md.opt.f_pth[:lng_is] !=@md.opt.lng_base \
+ and trans.empty? \
+ and auto_translate?
+ trans=auto_translation(dob_src.obj,:src)
+ end
+ util=pot_structure_wrap(desc,orig,trans)
+ unwrapped=util.no_line_wrap_block
+ @pot[:body] << unwrapped << br
end
- desc="#{d}#{s_mark}#{instruct}"
- orig=dob_src.obj
- trans=(dob_trn=='') ? '' : dob_trn.obj
- util=pot_structure(desc,orig,trans)
- unwrapped=util.no_line_wrap_block
- @pot[:body] << unwrapped << br
- end
- def pot_structure_group(dob_src='',notes_s='',dob_trn='',notes_t='') #% used to extract the structure of a document
- mark="group{\\n\\n...\\n\\n}group"
- d=dob_src.is.to_s
- instruct=s_mark=''
- if @md.opt.act[:maintenance][:set]==:on
- instruct=%{\n# group text is a text block with an opening and closing marker, } \
- + %{the content of which may be wrapped}
- s_mark="\n# " + %{"\\n\\n#{mark}\\n\\n"}
+ def group(dob_src='',notes_s='',dob_trn='',notes_t='') #% used to extract the structure of a document
+ mark="group{\\n\\n...\\n\\n}group"
+ d=dob_src.is.to_s
+ instruct=s_mark=''
+ if @md.opt.act[:maintenance][:set]==:on
+ instruct=%{\n# group text is a text block with an opening and closing marker, } \
+ + %{the content of which may be wrapped}
+ s_mark="\n# " + %{"\\n\\n#{mark}\\n\\n"}
+ end
+ desc="#{d}#{s_mark}#{instruct}"
+ orig=dob_src.obj
+ trans=((dob_trn=='') \
+ || (dob_src.obj == dob_trn.obj)) \
+ ? ''
+ : "#{s_mark}#{dob_trn.obj}"
+ if @md.opt.f_pth[:lng_is] !=@md.opt.lng_base \
+ and trans.empty? \
+ and auto_translate?
+ trans=auto_translation(dob_src.obj,:src)
+ end
+ util=pot_structure_wrap(desc,orig,trans)
+ unwrapped=util.no_line_wrap_block
+ @pot[:body] << unwrapped << br
end
- desc="#{d}#{s_mark}#{instruct}"
- orig=dob_src.obj
- trans=(dob_trn=='') ? '' : dob_trn.obj
- util=pot_structure(desc,orig,trans)
- unwrapped=util.no_line_wrap_block
- @pot[:body] << unwrapped << br
- end
- def pot_structure_verse(dob_src='',notes_s='',dob_trn='',notes_t='') #% used to extract the structure of a document
- mark="poem{\n\nverse\n\nverse\n\n...\n\n}poem"
- d=dob_src.is.to_s
- instruct=s_mark=''
- if @md.opt.act[:maintenance][:set]==:on
- instruct=%{\n# verse are part of the text block described as a poem, } \
- + %{the first verse is preceeded by an opening marker, } \
- + %{and the last verse by a closing marker, } \
- + %{the content of which should remain unwrapped}
- s_mark="\n# " + %{"\\n\\n#{mark}\\n\\n"}
+ def verse(dob_src='',notes_s='',dob_trn='',notes_t='') #% used to extract the structure of a document
+ mark="poem{\n\nverse\n\nverse\n\n...\n\n}poem"
+ d=dob_src.is.to_s
+ instruct=s_mark=''
+ if @md.opt.act[:maintenance][:set]==:on
+ instruct=%{\n# verse are part of the text block described as a poem, } \
+ + %{the first verse is preceeded by an opening marker, } \
+ + %{and the last verse by a closing marker, } \
+ + %{the content of which should remain unwrapped}
+ s_mark="\n# " + %{"\\n\\n#{mark}\\n\\n"}
+ end
+ desc="#{d}#{s_mark}#{instruct}"
+ orig=dob_src.obj
+ trans=(dob_trn=='') ? '' : dob_trn.obj
+ util=pot_structure_wrap(desc,orig,trans)
+ unwrapped=util.no_line_wrap_block
+ @pot[:body] << unwrapped << br
end
- desc="#{d}#{s_mark}#{instruct}"
- orig=dob_src.obj
- trans=(dob_trn=='') ? '' : dob_trn.obj
- util=pot_structure(desc,orig,trans)
- unwrapped=util.no_line_wrap_block
- @pot[:body] << unwrapped << br
- end
- def pot_structure_code(dob_src='',notes_s='',dob_trn='',notes_t='') #% used to extract the structure of a document
- mark="code{\\n\\n...\\n\\n}code"
- d=dob_src.is.to_s
- instruct=s_mark=''
- if @md.opt.act[:maintenance][:set]==:on
- instruct=%{\n# codeblocks are a text block with an opening and closing marker, } \
- + %{the content of which should remain unwrapped}
- s_mark="\n# " + %{"\\n\\n#{mark}\\n\\n"}
+ def code(dob_src='',notes_s='',dob_trn='',notes_t='') #% used to extract the structure of a document
+ mark="code{\\n\\n...\\n\\n}code"
+ d=dob_src.is.to_s
+ instruct=s_mark=''
+ if @md.opt.act[:maintenance][:set]==:on
+ instruct=%{\n# codeblocks are a text block with an opening and closing marker, } \
+ + %{the content of which should remain unwrapped}
+ s_mark="\n# " + %{"\\n\\n#{mark}\\n\\n"}
+ end
+ desc="#{d}#{s_mark}#{instruct}"
+ orig=dob_src.obj
+ trans=(dob_trn=='') ? '' : dob_trn.obj
+ util=pot_structure_wrap(desc,orig,trans)
+ unwrapped=util.no_line_wrap_block
+ @pot[:body] << unwrapped << br
end
- desc="#{d}#{s_mark}#{instruct}"
- orig=dob_src.obj
- trans=(dob_trn=='') ? '' : dob_trn.obj
- util=pot_structure(desc,orig,trans)
- unwrapped=util.no_line_wrap_block
- @pot[:body] << unwrapped << br
- end
- def pot_structure_table(dob_src='',notes_s='',dob_trn='',notes_t='') #% used to extract the structure of a document
- mark="table{\\n\\n...\\n\\n}table"
- d=dob_src.is.to_s
- instruct=s_mark=''
- if @md.opt.act[:maintenance][:set]==:on
- instruct=%{\n# tables are a text block with an opening and closing marker, } \
- + %{the content of which should remain unwrapped}
- s_mark="\n# " + %{"\\n\\n#{mark}\\n\\n"}
+ def table(dob_src='',notes_s='',dob_trn='',notes_t='') #% used to extract the structure of a document
+ mark="table{\\n\\n...\\n\\n}table"
+ d=dob_src.is.to_s
+ instruct=s_mark=''
+ if @md.opt.act[:maintenance][:set]==:on
+ instruct=%{\n# tables are a text block with an opening and closing marker, } \
+ + %{the content of which should remain unwrapped}
+ s_mark="\n# " + %{"\\n\\n#{mark}\\n\\n"}
+ end
+ desc="#{d}#{s_mark}#{instruct}"
+ orig=dob_src.obj
+ orig=orig.gsub(/#{Mx[:tc_c]}/,"\n")
+ trans=(dob_trn=='') ? '' : dob_trn.obj
+ trans=trans.gsub(/#{Mx[:tc_c]}/,"\n")
+ util=pot_structure_wrap(desc,orig,trans)
+ unwrapped=util.no_line_wrap_block
+ @pot[:body] << unwrapped << br
end
- desc="#{d}#{s_mark}#{instruct}"
- orig=dob_src.obj
- orig=orig.gsub(/#{Mx[:tc_c]}/,"\n")
- trans=(dob_trn=='') ? '' : dob_trn.obj
- trans=trans.gsub(/#{Mx[:tc_c]}/,"\n")
- util=pot_structure(desc,orig,trans)
- unwrapped=util.no_line_wrap_block
- @pot[:body] << unwrapped << br
- end
- def pot_structure_idx_markup(idx)
- struct=['={']
- idx.sort.each do |x|
- x.each_with_index do |y,i0|
- case y
- when String
- struct << ';' unless struct[-1] =~/=\{/
- struct << y
- if x[i0+1].class == Hash \
- and x[i0+1][:sub].length > 0
- struct << ':'
- end
- when Hash
- if y[:plus].to_i > 0
- struct << '+' + y[:plus].to_s
- end
- if y[:sub].length > 0
- y[:sub].each_with_index do |z,i1|
- z.each_with_index do |a,i2|
- #p a
- if z.length > 0
- struct << a[0]
- if a[1][:plus].to_i > 0
- struct << '+' + a[1][:plus].to_s
- end
- if (i1 + 1) < y[:sub].length
- struct << '|'
+ def idx_markup(idx)
+ struct=['={']
+ idx.sort.each do |x|
+ x.each_with_index do |y,i0|
+ case y
+ when String
+ struct << ';' unless struct[-1] =~/=\{/
+ struct << y
+ if x[i0+1].class == Hash \
+ and x[i0+1][:sub].length > 0
+ struct << ':'
+ end
+ when Hash
+ if y[:plus].to_i > 0
+ struct << '+' + y[:plus].to_s
+ end
+ if y[:sub].length > 0
+ y[:sub].each_with_index do |z,i1|
+ z.each_with_index do |a,i2|
+ #p a
+ if z.length > 0
+ struct << a[0]
+ if a[1][:plus].to_i > 0
+ struct << '+' + a[1][:plus].to_s
+ end
+ if (i1 + 1) < y[:sub].length
+ struct << '|'
+ end
end
end
end
@@ -781,31 +878,32 @@ GSUB
end
end
end
+ struct << '}'
+ #puts struct.join
+ struct.join
end
- struct << '}'
- #puts struct.join
- struct.join
- end
- def pot_structure_idx(dob_src='',dob_trn='') #% used for book index but broken as original markup lost, already abstracted, fix
- mark="={ ... }"
- instruct=s_mark=''
- if @md.opt.act[:maintenance][:set]==:on
- instruct=%{\n# the book index should be attached unwrapped to the preceding text block } \
- + %{(there should be a new line, but no empty line)}
- s_mark="\n# " + %{"\\n#{mark}\\n\\n"}
- end
- d='book-idx'
- desc="#{d}#{s_mark}#{instruct}"
- orig=pot_structure_idx_markup(dob_src.idx) #'={' + dob_src.idx + '}'
- trans=if defined? dob_trn.idx \
- and not dob_trn.idx.nil? \
- and not dob_trn.idx.empty?
- pot_structure_idx_markup(dob_trn.idx) #'={' + dob_trn.idx + '}'
- else ''
+ def idx(dob_src='',dob_trn='') #% used for book index but broken as original markup lost, already abstracted, fix
+ mark="={ ... }"
+ instruct=s_mark=''
+ if @md.opt.act[:maintenance][:set]==:on
+ instruct=%{\n# the book index should be attached unwrapped to the preceding text block } \
+ + %{(there should be a new line, but no empty line)}
+ s_mark="\n# " + %{"\\n#{mark}\\n\\n"}
+ end
+ d='book-idx'
+ desc="#{d}#{s_mark}#{instruct}"
+ orig=pot_structure.idx_markup(dob_src.idx) #'={' + dob_src.idx + '}'
+ trans=if defined? dob_trn.idx \
+ and not dob_trn.idx.nil? \
+ and not dob_trn.idx.empty?
+ pot_structure.idx_markup(dob_trn.idx) #'={' + dob_trn.idx + '}'
+ else ''
+ end
+ util=pot_structure_wrap(desc,orig,trans)
+ unwrapped=util.no_line_wrap_block
+ @pot[:body] << unwrapped << br
end
- util=pot_structure(desc,orig,trans)
- unwrapped=util.no_line_wrap_block
- @pot[:body] << unwrapped << br
+ self
end
def pot_markup(data_src,data_trn)
#@endnotes,@copen,@pot_contents_close=Array.new(3){[]}
@@ -926,24 +1024,24 @@ GSUB
end
case dob_src.is
when :heading
- pot_structure_heading(dob_src,notes_s,dob_trn,notes_t)
+ pot_structure.heading(dob_src,notes_s,dob_trn,notes_t)
when :para
- pot_structure_para(dob_src,notes_s,dob_trn,notes_t)
+ pot_structure.para(dob_src,notes_s,dob_trn,notes_t)
when :group
- pot_structure_group(dob_src,notes_s,dob_trn,notes_t)
+ pot_structure.group(dob_src,notes_s,dob_trn,notes_t)
when :block
- pot_structure_block(dob_src,notes_s,dob_trn,notes_t)
+ pot_structure.block(dob_src,notes_s,dob_trn,notes_t)
when :verse
- pot_structure_verse(dob_src,notes_s,dob_trn,notes_t)
+ pot_structure.verse(dob_src,notes_s,dob_trn,notes_t)
when :code
- pot_structure_code(dob_src,notes_s,dob_trn,notes_t)
+ pot_structure.code(dob_src,notes_s,dob_trn,notes_t)
when :table
- pot_structure_table(dob_src,notes_s,dob_trn,notes_t)
+ pot_structure.table(dob_src,notes_s,dob_trn,notes_t)
end
if defined? dob_src.idx \
and not dob_src.idx.nil? \
and not dob_src.idx.empty?
- pot_structure_idx(dob_src,dob_trn)
+ pot_structure.idx(dob_src,dob_trn)
end
dob_src='' if (dob_src.obj =~/<a name="n\d+">/ \
and dob_src.obj =~/^(-\{{2}~\d+|<!e[:_]\d+!>)/) # -endnote
@@ -954,83 +1052,8 @@ GSUB
end
#[dob_src,dob_trn]
end
- def markup(dob) # used for major markup instructions
- SiSU_Env::InfoEnv.new(@md.fns)
- dob.obj=dob.obj.
- gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,
- "#{Px[:po_bold_o]}\\1#{Px[:po_bold_c]}").
- gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,
- "#{Px[:po_italics_o]}\\1#{Px[:po_italics_c]}").
- gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,
- "#{Px[:po_underscore_o]}\\1#{Px[:po_underscore_c]}").
- gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,
- "#{Px[:po_subscript_o]}\\1#{Px[:po_subscript_c]}").
- gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,
- "#{Px[:po_superscript_o]}\\1#{Px[:po_superscript_c]}").
- gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,
- "#{Px[:po_insert_o]}\\1#{Px[:po_insert_c]}").
- gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,
- "#{Px[:po_cite_o]}\\1#{Px[:po_cite_c]}").
- gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,
- "#{Px[:po_strike_o]}\\1#{Px[:po_strike_c]}").
- gsub(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/,
- "#{Px[:po_monospace_o]}\\1#{Px[:po_monospace_c]}")
- notes=''
- unless dob.is==:code
- dob.obj=dob.obj.
- gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/,'\1').
- gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'\1').
- gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,
- '\1 [link: <\2>]').
- gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}image/,
- '\1 [link: local image]').
- gsub(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,'\1')
- notes=extract_endnotes(dob)
- #% ### footnotes current state - extracted
- dob.obj=dob.obj.
- gsub(/#{Mx[:en_a_o]}([\d]+)\s+(?:.+?)#{Mx[:en_a_c]}/,'~^'). # endnote marker marked up
- #% ### footnotes current state - keep inline
- #dob.obj.gsub!(/#{Mx[:en_a_o]}[\d]+\s+(.+?)#{Mx[:en_a_c]}/,'~{ \1 }~') # inline endnote with marker marked up
- gsub(/#{Mx[:en_b_o]}[\d]+\s+(.+?)#{Mx[:en_b_c]}/,
- '~[ \1 ]~'). # inline endnote with marker marked up
- gsub(/#{Mx[:en_a_o]}([*+]+)\s+(.+?)#{Mx[:en_a_c]}/,
- '~{\1 \2 }~'). # inline endnote with marker marked up
- gsub(/#{Mx[:en_b_o]}([*+]+)\s+(.+?)#{Mx[:en_b_c]}/,
- '~[\1 \2 ]~'). # inline endnote with marker marked up
- gsub(/#{Mx[:gl_o]}(?:#lt|#060)#{Mx[:gl_c]}/,'<').
- gsub(/#{Mx[:gl_o]}(?:#gt|#062)#{Mx[:gl_c]}/,'>').
- gsub(/#{Mx[:gl_o]}#(?:038|amp)#{Mx[:gl_c]}/,'&').
- gsub(/#{Mx[:gl_o]}#033#{Mx[:gl_c]}/,'!').
- gsub(/#{Mx[:gl_o]}#035#{Mx[:gl_c]}/,'#').
- gsub(/#{Mx[:gl_o]}#042#{Mx[:gl_c]}/,'*').
- gsub(/#{Mx[:gl_o]}#045#{Mx[:gl_c]}/,'-').
- gsub(/#{Mx[:gl_o]}#047#{Mx[:gl_c]}/,'/').
- gsub(/#{Mx[:gl_o]}#095#{Mx[:gl_c]}/,'_').
- gsub(/#{Mx[:gl_o]}#123#{Mx[:gl_c]}/,'{').
- gsub(/#{Mx[:gl_o]}#125#{Mx[:gl_c]}/,'}').
- gsub(/#{Mx[:gl_o]}#126#{Mx[:gl_c]}/,'~').
- gsub(/#{Mx[:gl_o]}#169#{Mx[:gl_c]}/,'©')
- end
- dob.obj=if dob.of==:block # watch
- dob.obj.gsub(/#{Mx[:gl_o]}●#{Mx[:gl_c]}/,"* ").
- gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,"\n")
- else dob.obj.gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,"\n\n")
- end
- if dob.is==:code
- dob.obj=dob.obj.gsub(/(^|[^}])_([<>])/m,'\1\2'). # _> _<
- gsub(/(^|[^}])_([<>])/m,'\1\2') # _<_<
- end
- dob.obj=dob.obj.gsub(/#{Mx[:br_page]}\s*|#{Mx[:br_page_new]}/,''). # remove page breaks
- gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'\1').
- gsub(/<a href=".+?">(.+?)<\/a>/m,'\1').
- gsub(/#{Mx[:mk_o]}:name#(\S+?)#{Mx[:mk_c]}/,''). # remove name links
- gsub(/&nbsp;|#{Mx[:nbsp]}/,' '). # decide on
- gsub(/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/,
- ' [ \1 ]'). #"[ #{dir.url.images_local}\/\\1 ]")
- gsub(/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}image/,
- ' [ \1 ]'). #"[ #{dir.url.images_local}\/\\1 ]")
- gsub(/(?:^|[^_\\])\{\s*\S+?\.(?:png|jpg|gif)\s+.+?"(.*?)"\s*\}\S+/,
- '[image: "\1"]')
+ def markup(dob)
+ dob,notes=objects.textface_marks_po4a(dob,:separate)
[dob,notes]
end
def publish(fn,pot)
@@ -1044,6 +1067,78 @@ GSUB
@@endnotes={ para: [], end: [] }
end
end
+ class Po4aCfg
+ include SiSU_Composite_Doc_Utils # composite doc, .ssm, extract all related insert files, array of filenames test
+ def initialize(opt,file)
+ @opt,@file=opt,file
+ end
+ def po4a_cfg_filename
+ 'po4a.cfg'
+ end
+ def dir
+ def pwd
+ Dir.pwd
+ end
+ def po4a_
+ 'po4a/' # ''
+ end
+ def pot
+ po4a_ + 'pot'
+ end
+ def po
+ po4a_ + 'po'
+ end
+ self
+ end
+ def po4a_cfg_file
+ File.open("#{Dir.pwd}/#{po4a_cfg_filename}",'w')
+ end
+ def language
+ def sisu_languages_available
+ Px[:lng_lst]
+ end
+ def translation_languages_selected
+ @opt.act[:po4a_lang_trans][:trn] \
+ ? @opt.act[:po4a_lang_trans][:trn]
+ : []
+ end
+ def translation_languages_selected_that_are_available
+ translation_languages_selected & sisu_languages_available
+ end
+ def source_language_selected_str
+ @opt.act[:po4a_lang_trans][:src] \
+ ? @opt.act[:po4a_lang_trans][:src]
+ : 'en'
+ end
+ def translation_languages_selected_that_are_available_str
+ translation_languages_selected_that_are_available.join(' ')
+ end
+ def translation_languages_selected_str
+ @opt.act[:po4a_lang_trans][:trn].join(' ')
+ end
+ self
+ end
+ def po4a_cfg
+ doc_import_list=composite_and_imported_filenames_array(@opt.fno)
+ po4a_cfg_arr=[]
+ po4a_cfg_arr \
+ << "[po4a_langs] #{language.translation_languages_selected_that_are_available_str}"
+ po4a_cfg_arr \
+ << "[po4a_paths] #{dir.pot}/$master.pot $lang:#{dir.po}/$lang/$master.po"
+ doc_import_list.each do |file_src|
+ file_src_fn=
+ file_src.gsub(/#{language.source_language_selected_str}\//,'')
+ po4a_cfg_arr \
+ << "[type: text] #{file_src} $lang:$lang/#{file_src_fn}"
+ end
+ file=@file.write_file.po4a_cfg
+ po4a_cfg_arr.each do |txt|
+ puts txt
+ file << txt << "\n"
+ end
+ file.close
+ end
+ end
class Output <Source
include SiSU_Param
include SiSU_Env
@@ -1052,7 +1147,7 @@ GSUB
@file=SiSU_Env::FileOp.new(md,fn)
end
def po4a #%pot output
- file_pot=(@md.opt.f_pth[:lng] ==@md.opt.lng_base) \
+ file_pot=(@md.opt.f_pth[:lng] == @md.opt.lng_base) \
? @file.write_file.pot
: @file.write_file.po
@sisu=[]
@@ -1085,7 +1180,7 @@ GSUB
unless FileTest.directory?(@file.output_path.pot_git.dir)
git.create_file_structure_git
end
- if @md.opt.f_pth[:lng] ==@md.opt.lng_base
+ if @md.opt.f_pth[:lng] == @md.opt.lng_base
FileUtils::cp(
@file.place_file.pot.dir,
@file.output_path.pot_git.dir
@@ -1116,3 +1211,7 @@ where no ocn appropriately use ~# or -# or indeed 1~name-
comments in document, what to do about them, not sure they are currently
retained in dal, could be quite valuable to keep
+
+Translate Shell
+http://www.soimort.org/translate-shell/
+translate.google.com
diff --git a/lib/sisu/current/po4a_set.rb b/lib/sisu/current/src_po4a_shelf_set.rb
index a08eea3..113475b 100644
--- a/lib/sisu/current/po4a_set.rb
+++ b/lib/sisu/current/src_po4a_shelf_set.rb
@@ -51,13 +51,14 @@
** Git
<http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=summary>
- <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=blob;f=lib/sisu/current/po4a_set.rb;hb=HEAD>
+ <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=blob;f=lib/sisu/current/src_po4a_shelf_set.rb;hb=HEAD>
=end
module SiSU_Po4aUtils
class Wrap
def initialize(md,orig='',trans='',is_desc='',n_char_max=76,n_indent=0,n_hang=nil)
- @md,@orig,@trans,@is_desc,@n_char_max,@n_indent=md,orig,trans,is_desc,n_char_max,n_indent
+ @md,@orig,@trans,@is_desc,@n_char_max,@n_indent=
+ md, orig, trans, is_desc, n_char_max, n_indent
@n_char_max_extend = n_char_max
@br="\n"
@n_hang=n_hang ? n_hang : @n_indent
@@ -66,7 +67,8 @@ module SiSU_Po4aUtils
end
def line_wrap
space=' '
- spaces_indent,spaces_hang="#{@br}#{space*@n_indent}",space*@n_hang
+ spaces_indent,spaces_hang=
+ "#{@br}#{space*@n_indent}",space*@n_hang
pot,i=[],0
pot_array=(@trans.empty?) ? [@orig] : [@orig,@trans]
pot_array.each do |pa|
@@ -76,7 +78,7 @@ module SiSU_Po4aUtils
@oldword='' #REMOVE @oldword
pa=pa.gsub(/<br>/,' <br> ').
gsub(/#{Mx[:br_nl]}/,"\n\n")
- words=pa.scan(/\n\n|<br>|\S+/m)
+ words=pa.scan(/\n\n|\\\\\\|<br>|\S+/m)
while words != ''
word=words.shift
if not word
diff --git a/lib/sisu/current/src_po4a_sst_ao_sst.rb b/lib/sisu/current/src_po4a_sst_ao_sst.rb
new file mode 100644
index 0000000..57dfbd3
--- /dev/null
+++ b/lib/sisu/current/src_po4a_sst_ao_sst.rb
@@ -0,0 +1,893 @@
+# encoding: utf-8
+=begin
+
+* Name: SiSU
+
+** Description: documents, structuring, processing, publishing, search
+*** pot file generation
+
+** Author: Ralph Amissah
+ <ralph@amissah.com>
+ <ralph.amissah@gmail.com>
+
+** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
+ 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah,
+ All Rights Reserved.
+
+** License: GPL 3 or later:
+
+ SiSU, a framework for document structuring, publishing and search
+
+ Copyright (C) Ralph Amissah
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the Free
+ Software Foundation, either version 3 of the License, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ more details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program. If not, see <http://www.gnu.org/licenses/>.
+
+ If you have Internet connection, the latest version of the GPL should be
+ available at these locations:
+ <http://www.fsf.org/licensing/licenses/gpl.html>
+ <http://www.gnu.org/licenses/gpl.html>
+
+ <http://www.sisudoc.org/sisu/en/manifest/gpl.fsf.html>
+
+** SiSU uses:
+ * Standard SiSU markup syntax,
+ * Standard SiSU meta-markup syntax, and the
+ * Standard SiSU object citation numbering and system
+
+** Hompages:
+ <http://www.jus.uio.no/sisu>
+ <http://www.sisudoc.org>
+
+** Git
+ <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=summary>
+ <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=blob;f=lib/sisu/current/src_po4a_sst_ao_sst.rb;hb=HEAD>
+
+=end
+module SiSU_SStm_AO_SStm
+ require_relative 'ao' # ao.rb
+ require_relative 'se' # se.rb
+ include SiSU_Env
+ require_relative 'ao_composite' # ao_composite.rb
+ require_relative 'shared_metadata' # shared_metadata.rb
+ require_relative 'src_po4a_share' # src_po4a_share.rb
+ require_relative 'src_po4a_sst_ao_sst_set' # src_po4a_sst_ao_sst_set.rb
+ include SiSU_Param
+ require_relative 'object_munge' # object_munge.rb
+ require_relative 'utils_composite' # utils_composite.rb
+ require_relative 'utils_response' # utils_response.rb
+ class Source
+ include SiSU_Object_Munge
+ include SiSU_Languages_Selected
+ include SiSU_Response
+ @@md_src,@@md_master=
+ nil, nil
+ @@auto_translation_ = :go
+ def initialize(opt,fn=nil)
+ @opt,@fn=opt,fn
+ #unless @opt.fns =~/(.+?\.(?:-|ssm\.)?sst)$/
+ # puts "#{@opt.fns} not a processed file type"
+ #end
+ file_arr=SiSU_Info_Env::InfoEnv.new.
+ source_file_processing_array(@opt.fno)
+ SiSU_Param::Parameters::Instructions.new(file_arr,@opt).extract
+ r=Px[:lng_lst_rgx].gsub(/\|#{language.source_language_selected_str}\|/,'|')
+ @lang_regx=%r{(?:#{r})}
+ @@todo=if source_language_selected_str == opt.f_pth[:lng]
+ :same_file
+ else :compare
+ end
+ if opt.f_pth[:lng]==@opt.lng_base \
+ and opt.f_pth[:lng]==source_language_selected_str
+ @@md_master=SiSU_Param::Parameters.new(opt).get
+ end
+ end
+ def wrap_width_set(md,env)
+ if defined? md.make.plaintext_wrap \
+ and md.make.plaintext_wrap
+ md.make.plaintext_wrap
+ elsif defined? env.plaintext_wrap \
+ and env.plaintext_wrap
+ #env.plaintext_wrap # 78 use 75
+ 75
+ else 75 #78
+ end
+ end
+ def process_file(md,env,file,wrap_width,fn)
+ if source_language_selected_str == @opt.f_pth[:lng]
+ @@ao_arr_lang_trans=
+ SiSU_AO::Source.new(
+ @opt,
+ fn,
+ :po4a
+ ).get # ao file drawn here
+ end
+ @ao_arr_lang_src=
+ SiSU_AO::Source.new(
+ @opt,
+ fn,
+ :po4a
+ ).get # ao file drawn here
+ SiSU_SStm_AO_SStm::Source::Scroll.new(
+ fn,
+ @ao_arr_lang_src,
+ @@ao_arr_lang_trans,
+ @@md_src,
+ @@md_master,
+ wrap_width
+ ).songsheet
+ end
+ def read_process_src_files
+ begin
+ src={}
+ src[:pth]=@opt.f_pth[:pth]
+ src[:files]=if @opt.fns =~ /\.(?:(?:-|ssm\.)sst|ssm)$/
+ @opt.fns=@opt.fns.gsub(/\.ssm\.sst$/,'.ssm')
+ SiSU_Assemble::CompositeFileList.new(@opt).read
+ else
+ [@opt.fns]
+ end
+ md=SiSU_Param::Parameters.new(@opt).get
+ env=SiSU_Env::InfoEnv.new(@opt.fns)
+ file=SiSU_Env::FileOp.new(md)
+ lng=/\/([^\/]+)$/.match(src[:pth])[1]
+ if language.source_language_selected_str == lng
+ SiSU_Po4a_Project::Po4aDistClean.new(@opt,file).song
+ end
+ wrap_width=wrap_width_set(md,env)
+ lng = /\/([^\/]+)$/.match(src[:pth])[1]
+ ans=response?('process files?')
+ if ans
+ src[:files].each do |fn|
+ puts "[#{lng}] #{fn}"
+ process_file(md,env,file,wrap_width,fn)
+ end
+ end
+ rescue
+ SiSU_Errors::Rescued.new($!,$@,@opt.selections.str,@opt.fns).location do
+ __LINE__.to_s + ':' + __FILE__
+ end
+ ensure
+ end
+ end
+ def read_setup
+ begin
+ md=SiSU_Param::Parameters.new(@opt).get
+ file=SiSU_Env::FileOp.new(md)
+ SiSU_Po4a_Project::Po4aCfg.new(@opt,file).song
+ SiSU_Po4a_Project::Po4aProject.new(@opt,file).song
+ rescue
+ SiSU_Errors::Rescued.new($!,$@,@opt.selections.str,@opt.fns).location do
+ __LINE__.to_s + ':' + __FILE__
+ end
+ ensure
+ end
+ end
+ private
+ class Scroll <Source
+ include SiSU_Po4aUtils
+ @@endnotes={ para: [], end: [] }
+ def initialize(fn,data_src,data_master,md_src,md_master,wrap_width)
+ @fn,@data_src,@data_master,@md_src,@md_master,@wrap_width=
+ fn, data_src, data_master, md_src, md_master, wrap_width
+ @md=md_src
+ @tab="\t"
+ @@endnotes_=(@md.opt.selections.str =~/--endnote/) \
+ ? true
+ : false # --footnote
+ @pot={
+ body: [],
+ open: [],
+ close: [],
+ head: [],
+ metadata: [],
+ tail: []
+ }
+ end
+ def br
+ (@md.opt.selections.str =~/--dos/) ? "\r\n" : "\n" # --unix
+ end
+ def songsheet
+ fn=@fn
+ pot=compare_structure_src_trn(@data_src,@data_master,@@todo)
+ publish(fn,pot)
+ end
+ def pot_structure_wrap(orig,trans,indent=0,hang=0)
+ SiSU_Po4aUtils::Wrap.new(
+ @md,
+ orig,
+ trans,
+ @wrap_width,
+ indent,
+ hang
+ )
+ end
+ def wrap_endnotes(orig_notes='',trn_notes='')
+ #nt=@@endnotes_ ? 'endnote' : 'footnote'
+ @fn=0
+ a_l=orig_notes.length
+ 0.upto(a_l-1) do |i|
+ @fn=if orig_notes[i].to_s =~/^\^~([\d*+]+)/ # provides endnote number within paragraph
+ @fn += 1
+ else @fn
+ end
+ #mark="^~ "
+ orig=(orig_notes[i].to_s =~/^\^~[\d*+]+/) \
+ ? (orig_notes[i].to_s.gsub(/^\^~[\d*+]+/,'^~'))
+ : orig_notes[i].to_s
+ trans=if trn_notes.is_a?(Array) \
+ and trn_notes.length==orig_notes.length
+ (trn_notes[i].to_s =~/^\^~[\d*+]+/) \
+ ? (trn_notes[i].to_s.gsub(/^\^~[\d*+]+/,'^~'))
+ : trn_notes[i].to_s
+ else ''
+ end
+ util=pot_structure_wrap(orig,trans)
+ wrap=util.line_wrap
+ wrap=if wrap =~ /^\s*\^~[\d*+]+\s+.+?\s*\Z/m
+ wrap.gsub(/^\s*(\^~[\d*+]+)\s+(.+?)\s*\Z/m, <<GSUB
+\\1 \\2
+GSUB
+ )
+ else
+ wrap.gsub(/^(.+)\Z/m, <<GSUB
+\\1
+GSUB
+ )
+ end
+ @@endnotes[:para] << wrap
+ @@endnotes[:end] << '' << wrap
+ end
+ @@endnotes[:para].each {|e| @pot[:body] << e << br}
+ @@endnotes[:para]=[]
+ @@endnotes
+ end
+ def pot_metadata_src
+ @po4a_identify_type='type: SiSU doc' #'type: Plain text'
+ meta_src=SiSU_Metadata::Summary.new(@md_src)
+ w=[]
+ w << [
+ meta_src.metadata_tags.title.main,
+ meta_src.metadata_tags.title.sub,
+ meta_src.metadata_tags.title.edition,
+ meta_src.metadata_tags.title.note,
+ meta_src.metadata_tags.title.short,
+ meta_src.metadata_tags.title.language,
+ meta_src.metadata_tags.title.language_char,
+ ]
+ w << [
+ meta_src.metadata_tags.creator.head,
+ meta_src.metadata_tags.creator.author,
+ meta_src.metadata_tags.creator.contributor,
+ meta_src.metadata_tags.creator.illustrator,
+ meta_src.metadata_tags.creator.photographer,
+ meta_src.metadata_tags.creator.translator,
+ meta_src.metadata_tags.creator.audio,
+ meta_src.metadata_tags.creator.digitized_by,
+ meta_src.metadata_tags.creator.prepared_by,
+ ]
+ w << [
+ meta_src.metadata_tags.rights.head,
+ meta_src.metadata_tags.rights.copyright.text,
+ meta_src.metadata_tags.rights.copyright.translation,
+ meta_src.metadata_tags.rights.copyright.illustrations,
+ meta_src.metadata_tags.rights.copyright.photographs,
+ meta_src.metadata_tags.rights.copyright.digitization,
+ meta_src.metadata_tags.rights.copyright.audio,
+ meta_src.metadata_tags.rights.license,
+ ]
+ w << [
+ meta_src.metadata_tags.classify.head,
+ meta_src.metadata_tags.classify.subject,
+ meta_src.metadata_tags.classify.topic_register,
+ meta_src.metadata_tags.classify.loc,
+ meta_src.metadata_tags.classify.dewey,
+ ]
+ w << [
+ meta_src.metadata_tags.date.head,
+ meta_src.metadata_tags.date.added_to_site,
+ meta_src.metadata_tags.date.available,
+ meta_src.metadata_tags.date.created,
+ meta_src.metadata_tags.date.issued,
+ meta_src.metadata_tags.date.modified,
+ meta_src.metadata_tags.date.published,
+ meta_src.metadata_tags.date.valid,
+ ]
+ w << [
+ meta_src.processing_tags.make.language,
+ meta_src.processing_tags.make.headings,
+ meta_src.processing_tags.make.num_top,
+ meta_src.processing_tags.make.breaks,
+ meta_src.processing_tags.make.emphasis,
+ meta_src.processing_tags.make.bold,
+ meta_src.processing_tags.make.italics,
+ meta_src.processing_tags.make.texpdf_font,
+ ]
+ w.each do |y|
+ z=''
+ y.each do |x|
+ if x
+ z += x + "\n" if x =~/^#|^msg(?:id|str)/
+ z += %{#{x}\n} if x =~/^@\S+?:(?: |$)/
+ z += %{#{x}\n} if x =~/^\s+:\S+?: /
+ end
+ end
+ @pot[:metadata] << z << br
+ #puts z unless z.empty?
+ end
+ end
+ def pot_metadata_src_trn
+ #@po4a_identify_type='type: Plain text'
+ meta_src=SiSU_Metadata::Summary.new(@md_src)
+ w=[]
+ w << [
+ meta_src.metadata_tags.title.main,
+ meta_src.metadata_tags.title.sub,
+ meta_src.metadata_tags.title.edition,
+ meta_src.metadata_tags.title.note,
+ meta_src.metadata_tags.title.short,
+ meta_src.metadata_tags.title.language,
+ meta_src.metadata_tags.title.language_char,
+ ]
+ w << [
+ meta_src.metadata_tags.creator.head,
+ meta_src.metadata_tags.creator.author,
+ meta_src.metadata_tags.creator.contributor,
+ meta_src.metadata_tags.creator.illustrator,
+ meta_src.metadata_tags.creator.photographer,
+ meta_src.metadata_tags.creator.translator,
+ meta_src.metadata_tags.creator.audio,
+ meta_src.metadata_tags.creator.digitized_by,
+ meta_src.metadata_tags.creator.prepared_by,
+ ]
+ w << [
+ meta_src.metadata_tags.rights.head,
+ meta_src.metadata_tags.rights.copyright.text,
+ meta_src.metadata_tags.rights.copyright.translation,
+ meta_src.metadata_tags.rights.copyright.illustrations,
+ meta_src.metadata_tags.rights.copyright.photographs,
+ meta_src.metadata_tags.rights.copyright.digitization,
+ meta_src.metadata_tags.rights.copyright.audio,
+ meta_src.metadata_tags.rights.license,
+ ]
+ w << [
+ meta_src.metadata_tags.classify.head,
+ meta_src.metadata_tags.classify.subject,
+ meta_src.metadata_tags.classify.topic_register,
+ meta_src.metadata_tags.classify.loc,
+ meta_src.metadata_tags.classify.dewey,
+ ]
+ w << [
+ meta_src.metadata_tags.date.head,
+ meta_src.metadata_tags.date.added_to_site,
+ meta_src.metadata_tags.date.available,
+ meta_src.metadata_tags.date.created,
+ meta_src.metadata_tags.date.issued,
+ meta_src.metadata_tags.date.modified,
+ meta_src.metadata_tags.date.published,
+ meta_src.metadata_tags.date.valid,
+ ]
+ w << [
+ meta_src.processing_tags.make.language,
+ meta_src.processing_tags.make.headings,
+ meta_src.processing_tags.make.num_top,
+ meta_src.processing_tags.make.breaks,
+ meta_src.processing_tags.make.emphasis,
+ meta_src.processing_tags.make.bold,
+ meta_src.processing_tags.make.italics,
+ meta_src.processing_tags.make.texpdf_font,
+ ]
+ w.each do |y|
+ z=''
+ y.each do |x|
+ if x
+ z += x + "\n" if x =~/^#|^msg(?:id|str)/
+ z += %{#{x}\n} if x =~/^@\S+?:(?: |$)/
+ z += %{#{x}\n} if x =~/^\s+:\S+?: /
+ end
+ end
+ @pot[:metadata] << z << br
+ #puts z unless z.empty?
+ end
+ end
+ def auto_translate?(set_to=nil)
+ @@auto_translation_=
+ if @md.opt.act[:po4a_lang_trans][:set]==:on
+ set_to \
+ ? set_to
+ : @@auto_translation_
+ else :skip
+ end
+ end
+ def auto_translation(src_txt,markup=:src) # check for an appropriate request flag
+ auto_translate?(:skip)
+ begin
+ src_txt_clean=clean_text(src_txt,markup)
+ src_txt_clean=src_txt_clean.
+ gsub(/\n/,' ').
+ gsub(/"/,'\"').
+ gsub(/([()])/,'\\\\\1')
+ trans=''
+ unless auto_translate? == :skip
+ require 'timeout'
+ Timeout::timeout(60) {
+ trans=`trans -b -no-ansi en:#{@md.opt.f_pth[:lng_is]} #{src_txt_clean}`.strip
+ unless trans.empty?
+ trans + ' {[G.Tr]}http://translate.google.com'
+ end
+ }
+ end
+ trans
+ rescue
+ auto_translate?(:skip)
+ p 'timeout issues with translation, skip remaining'
+ end
+ end
+ def pot_structure
+ def heading(dob_src='',notes_s='',dob_trn='',notes_t='') #% used to extract the structure of a document
+ lv=n=n3=nil
+ lv=dob_src.ln
+ n=lv - 1
+ n3=lv + 2
+ util=nil
+ fn=(dob_src.name=~/[a-z\d]/i) ? dob_src.name : ''
+ mark="#{dob_src.lv}~#{fn} "
+ orig="#{mark}#{dob_src.obj}"
+ trans=((dob_trn=='') \
+ || (dob_src.obj == dob_trn.obj)) \
+ ? ''
+ : "#{mark}#{dob_trn.obj}"
+ if @md.opt.f_pth[:lng_is] !=@md.opt.lng_base \
+ and trans.empty? \
+ and auto_translate?
+ trans=auto_translation(dob_src.obj,:src)
+ end
+ util=pot_structure_wrap(orig,trans)
+ wrapped=util.line_wrap
+ @pot[:body] << wrapped << br # main text, contents, body KEEP
+ if @@endnotes[:para] \
+ and notes_s.length > 0 \
+ and not @@endnotes_
+ @pot[:body] << br
+ wrap_endnotes(notes_s,notes_t)
+ elsif @@endnotes[:para] \
+ and @@endnotes_
+ @pot[:body] << br*2
+ end
+ end
+ def para(dob_src='',notes_s='',dob_trn='',notes_t='') #% used to extract the structure of a document
+ util=nil
+ wrapped=if dob_src.indent =~/[1-9]/ \
+ and dob_src.indent == dob_src.hang
+ s_mark=desc=orig=trans=''
+ mark=if dob_src.bullet_
+ "_#{dob_src.indent}* "
+ else
+ "_#{dob_src.indent} "
+ end
+ orig="#{mark}#{dob_src.obj}"
+ trans=((dob_trn=='') \
+ || (dob_src.obj == dob_trn.obj)) \
+ ? ''
+ : "#{mark}#{dob_trn.obj}"
+ if @md.opt.f_pth[:lng_is] !=@md.opt.lng_base \
+ and trans.empty? \
+ and auto_translate?
+ trans=auto_translation(dob_src.obj,:src)
+ end
+ util=pot_structure_wrap(orig,trans)
+ elsif dob_src.hang =~/[0-9]/ \
+ and dob_src.indent != dob_src.hang
+ s_mark=desc=orig=trans=''
+ mark="_#{dob_src.hang}_#{dob_src.indent} "
+ orig="#{mark}#{dob_src.obj}"
+ trans=((dob_trn=='') \
+ || (dob_src.obj == dob_trn.obj)) \
+ ? ''
+ : "#{mark}#{dob_trn.obj}"
+ if @md.opt.f_pth[:lng_is] !=@md.opt.lng_base \
+ and trans.empty? \
+ and auto_translate?
+ trans=auto_translation(dob_src.obj,:src)
+ end
+ util=pot_structure_wrap(orig,trans)
+ else
+ s_mark=desc=orig=trans=''
+ if dob_src.bullet_
+ mark='_* '
+ orig="#{mark}#{dob_src.obj}"
+ trans=((dob_trn=='') \
+ || (dob_src.obj == dob_trn.obj)) \
+ ? ''
+ : "#{mark}#{dob_trn.obj}"
+ if @md.opt.f_pth[:lng_is] !=@md.opt.lng_base \
+ and trans.empty? \
+ and auto_translate?
+ trans=auto_translation(dob_src.obj,:src)
+ end
+ else
+ mark=''
+ orig=dob_src.obj
+ trans=((dob_trn=='') \
+ || (dob_src.obj == dob_trn.obj)) \
+ ? ''
+ : "#{mark}#{dob_trn.obj}"
+ if @md.opt.f_pth[:lng_is] !=@md.opt.lng_base \
+ and trans.empty? \
+ and auto_translate?
+ trans=auto_translation(dob_src.obj,:src)
+ end
+ end
+ util=pot_structure_wrap(orig,trans)
+ end
+ wrapped=util.line_wrap
+ @pot[:body] << wrapped << br # main text, contents, body KEEP
+ if @@endnotes[:para] \
+ and notes_s.length > 0 \
+ and not @@endnotes_
+ @pot[:body] << br
+ wrap_endnotes(notes_s,notes_t)
+ elsif @@endnotes[:para] \
+ and @@endnotes_
+ @pot[:body] << br*2
+ end
+ end
+ def block(dob_src='',notes_s='',dob_trn='',notes_t='') #% used to extract the structure of a document
+ mark_o ="block{\n\n"
+ mark_c ="\n\n}block"
+ orig="#{mark_o}#{dob_src.obj}#{mark_c}"
+ trans=((dob_trn=='') \
+ || (dob_src.obj == dob_trn.obj)) \
+ ? ''
+ : "#{mark_o}#{dob_trn.obj}#{mark_c}"
+ if @md.opt.f_pth[:lng_is] !=@md.opt.lng_base \
+ and trans.empty? \
+ and auto_translate?
+ trans=auto_translation(dob_src.obj,:src)
+ end
+ util=pot_structure_wrap(orig,trans)
+ unwrapped=util.no_line_wrap_block
+ @pot[:body] << unwrapped << br
+ end
+ def group(dob_src='',notes_s='',dob_trn='',notes_t='') #% used to extract the structure of a document
+ mark_o ="group{\n\n"
+ mark_c ="\n\n}group"
+ orig="#{mark_o}#{dob_src.obj}#{mark_c}"
+ trans=((dob_trn=='') \
+ || (dob_src.obj == dob_trn.obj)) \
+ ? ''
+ : "#{mark_o}#{dob_trn.obj}#{mark_c}"
+ if @md.opt.f_pth[:lng_is] !=@md.opt.lng_base \
+ and trans.empty? \
+ and auto_translate?
+ trans=auto_translation(dob_src.obj,:src)
+ end
+ util=pot_structure_wrap(orig,trans)
+ unwrapped=util.no_line_wrap_block
+ @pot[:body] << unwrapped << br
+ end
+ def verse(dob_src='',notes_s='',dob_trn='',notes_t='') #% used to extract the structure of a document
+ mark="poem{\n\nverse\n\nverse\n\n...\n\n}poem"
+ instruct=s_mark=''
+ if @md.opt.act[:maintenance][:set]==:on
+ instruct=%{\n# verse are part of the text block described as a poem, } \
+ + %{the first verse is preceeded by an opening marker, } \
+ + %{and the last verse by a closing marker, } \
+ + %{the content of which should remain unwrapped}
+ s_mark="\n# " + %{"\\n\\n#{mark}\\n\\n"}
+ end
+ orig=dob_src.obj
+ trans=(dob_trn=='') \
+ ? ''
+ : dob_trn.obj
+ util=pot_structure_wrap(orig,trans)
+ unwrapped=util.no_line_wrap_block
+ @pot[:body] << unwrapped << br
+ end
+ def code(dob_src='',notes_s='',dob_trn='',notes_t='') #% used to extract the structure of a document
+ mark_o ="code{\n\n"
+ mark_c ="\n\n}code"
+ orig="#{mark_o}#{dob_src.obj}#{mark_c}"
+ trans=(dob_trn=='') \
+ ? ''
+ : "#{mark_o}#{dob_trn.obj}#{mark_c}"
+ util=pot_structure_wrap(orig,trans)
+ unwrapped=util.no_line_wrap_block
+ @pot[:body] << unwrapped << br
+ end
+ def table(dob_src='',notes_s='',dob_trn='',notes_t='') #% used to extract the structure of a document
+ mark_o ="table{\n\n"
+ mark_c ="\n\n}table"
+ orig="#{mark_o}#{dob_src.obj}#{mark_c}"
+ orig=orig.gsub(/#{Mx[:tc_c]}/m,"\n")
+ trans=(dob_trn=='') \
+ ? ''
+ : "#{mark_o}#{dob_trn.obj}#{mark_c}"
+ trans=trans.gsub(/#{Mx[:tc_c]}/m,"\n")
+ util=pot_structure_wrap(orig,trans)
+ unwrapped=util.no_line_wrap_block
+ @pot[:body] << unwrapped << br
+ end
+ def idx_markup(idx)
+ struct=['={' + "\n "]
+ idx.sort.each do |x|
+ x.each_with_index do |y,i0|
+ case y
+ when String
+ unless struct[-1] =~/=\{/
+ struct << ' ;' + "\n "
+ end
+ struct << y
+ if x[i0+1].class == Hash \
+ and x[i0+1][:sub].length > 0
+ struct << ' :' + "\n "
+ end
+ when Hash
+ if y[:plus].to_i > 0
+ struct << '+' + y[:plus].to_s
+ end
+ if y[:sub].length > 0
+ y[:sub].each_with_index do |z,i1|
+ z.each_with_index do |a,i2|
+ if z.length > 0
+ struct << a[0]
+ if a[1][:plus].to_i > 0
+ struct << '+' + a[1][:plus].to_s
+ end
+ if (i1 + 1) < y[:sub].length
+ struct << '|'
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+ struct << "\n" + '}'
+ #puts struct.join
+ struct.join
+ end
+ def idx(dob_src='') #% used for book index but broken as original markup lost, already abstracted, fix
+ orig=pot_structure.idx_markup(dob_src.idx) #'={' + dob_src.idx + '}'
+ util=pot_structure_wrap(orig,'')
+ unwrapped=util.no_line_wrap_block
+ if @pot[:body][-1] == "\n"
+ @pot[:body][-1] = unwrapped #<< br
+ @pot[:body] << br
+ else # expect to catch all above, problem if wraps, must =~/^=\{/
+ @pot[:body] << unwrapped << br # places idx in separate object
+ end
+ end
+ self
+ end
+ def compare_structure_src_trn(data_src,data_trn,todo)
+ #@endnotes,@copen,@pot_contents_close=Array.new(3){[]}
+ a_l= data_src.length
+ s,t=0,0
+ 0.upto(a_l-1) do |i|
+ if todo==:compare
+ unless data_src[s] \
+ and data_trn[t]
+ break
+ end
+ if data_src[s].of == :comment \
+ and data_trn[t].of == :comment \
+ and (data_src[s].is == data_trn[t].is)
+ s+=1;t+=1
+ next
+ end
+ if ((data_src[s].is == :comment) \
+ || (data_trn[t].is == :comment)) \
+ and (data_src[s].is != data_trn[t].is)
+ if data_src[s].is == :comment
+ if @md.opt.act[:maintenance][:set]==:on
+ puts "src (comment):\n\t" \
+ + data_src[s].obj
+ end
+ s+=1
+ #next if data_src[s].is == :comment
+ elsif data_trn[t].is == :comment
+ if @md.opt.act[:maintenance][:set]==:on
+ puts "trans (comment):\n\t" \
+ + data_trn[t].obj
+ end
+ t+=1
+ #next if data_trn[t].is == :comment
+ end
+ end
+ if ((defined? data_src[s].ocn) \
+ && (data_src[s].ocn.is_a?(Fixnum))) \
+ and ((defined? data_trn[t].ocn) \
+ && (data_trn[t].ocn.is_a?(Fixnum))) \
+ and (data_src[s].ocn == data_trn[t].ocn)
+ @m_s,@m_t=s,t
+ elsif ((defined? data_src[s].ocn) \
+ && (data_src[s].ocn.is_a?(Fixnum))) \
+ and ((defined? data_trn[t].ocn) \
+ && (data_trn[t].ocn.is_a?(Fixnum))) \
+ and (data_src[s].ocn != data_trn[t].ocn)
+ p '--- OCN ---'
+ p 'mis-match'
+ p data_src[s].ocn if defined? data_src[s].ocn
+ p data_src[s].obj if defined? data_src[s].obj
+ p data_trn[t].ocn if defined? data_trn[t].ocn
+ p data_trn[t].obj if defined? data_trn[t].obj
+ p '---'
+ p 'previous match'
+ p data_src[@m_s].ocn if defined? data_src[@m_s].ocn
+ p data_src[@m_s].obj if defined? data_src[@m_s].obj
+ p data_trn[@m_t].ocn if defined? data_trn[@m_t].ocn
+ p data_trn[@m_t].obj if defined? data_trn[@m_s].obj
+ exit
+ elsif (((defined? data_src[s].ocn) \
+ && (defined? data_trn[t].ocn)) \
+ and data_src[s].ocn.class != data_trn[t].ocn.class)
+ p '--- OCN class ---'
+ p 'mis-match'
+ p data_src[s].ocn if defined? data_src[s].ocn
+ p data_src[s].obj if defined? data_src[s].obj
+ p data_trn[t].ocn if defined? data_trn[t].ocn
+ p data_trn[t].obj if defined? data_trn[t].obj
+ #p '---'
+ #p 'previous match'
+ #p data_src[@m_s].ocn
+ #p data_src[@m_s].obj
+ #p data_trn[@m_t].ocn
+ #p data_trn[@m_t].obj
+ #elsif (defined? data_src[s].ocn != defined? data_trn[t].ocn) \
+ #and (data_src[s].ocn.nil? != data_trn[t].ocn.nil?)
+ # p '--- missing OCN? ---'
+ # p 'mis-match'
+ # p data_src[s].ocn if defined? data_src[s].ocn
+ # p data_src[s].obj
+ # p data_trn[t].ocn if defined? data_trn[t].ocn
+ # p data_trn[t].obj
+ else
+ end
+ end
+ notes_s=''
+ data_src[s],notes_s=markup(data_src[s])
+ data_src[s],nul=pot_data(data_src[s],notes_s)
+ s+=1;t+=1
+ end
+ @pot #watch
+ end
+ def pot_data(dob_src='',notes_s)
+ if dob_src.obj !~/(^#{Rx[:meta]}|#{Mx[:br_eof]}|#{Mx[:br_endnotes]})/
+ if defined? dob_src.ocn \
+ and dob_src.ocn.to_s =~/\d+/
+ paranum=dob_src.ocn.to_s
+ @p_num=SiSU_Po4aUtils::ParagraphNumber.new(paranum)
+ end
+ case dob_src.is
+ when :heading
+ pot_structure.heading(dob_src,notes_s)
+ when :para
+ pot_structure.para(dob_src,notes_s)
+ when :group
+ pot_structure.group(dob_src,notes_s)
+ when :block
+ pot_structure.block(dob_src,notes_s)
+ when :verse
+ pot_structure.verse(dob_src,notes_s)
+ when :code
+ pot_structure.code(dob_src,notes_s)
+ when :table
+ pot_structure.table(dob_src,notes_s)
+ end
+ if defined? dob_src.idx \
+ and not dob_src.idx.nil? \
+ and not dob_src.idx.empty?
+ pot_structure.idx(dob_src)
+ end
+ #if dob_src ## Clean Prepared Text
+ # dob_src.obj=dob_src.obj.gsub(/<!.+!>/,' ').
+ # gsub(/<:\S+>/,' ') if dob_src ## Clean Prepared Text
+ #end
+ end
+ #[dob_src,dob_trn]
+ end
+ def markup(dob)
+ dob,notes=objects.textface_marks_po4a(dob,:separate)
+ [dob,notes]
+ end
+ def publish(fn,pot)
+ content=[]
+ content << pot[:open]
+ content << pot[:head]
+ content << pot[:metadata]
+ content << pot[:body]
+ content << @@endnotes[:end] if @@endnotes_
+ Output.new(fn,content,@md,@process).po4a
+ @@endnotes={ para: [], end: [] }
+ end
+ end
+ class Output <Source
+ include SiSU_Param
+ include SiSU_Env
+ def initialize(fn,content,md,process=:complete)
+ @fn,@content,@md,@process=fn,content,md,process
+ @file=SiSU_Env::FileOp.new(md,fn)
+ end
+ def po4a #%pot output
+ file_pot=@file.write_file.po4a_sst
+ #file_pot=(@md.opt.f_pth[:lng] == @md.opt.lng_base) \
+ #? @file.write_file.pot
+ #: @file.write_file.po
+ @sisu=[]
+ emptyline=0
+ @content.each do |para| # this is a hack
+ if para.is_a?(Array) \
+ and para.length > 0
+ para.each do |line|
+ if line
+ line=line.gsub(/\s+$/m,'').
+ gsub(/^\A[ ]*\Z/m,'')
+ if line=~/^\A[ ]*\Z/m
+ emptyline+=1
+ else emptyline=0
+ end
+ file_pot.puts line if emptyline < 2 #remove extra line spaces (fix upstream)
+ end
+ end
+ else file_pot.puts para #unix plaintext # /^([*=-]|\.){5}/
+ end
+ end
+ file_pot.close
+ SiSU_Po4aUtils::PotNumber.new.reset
+ #po4a_git
+ end
+ def po4a_git
+ unless @md.opt.act[:maintenance][:set]==:on
+ require_relative 'git' # git.rb
+ git=SiSU_Git::Source.new(@md.opt,@process)
+ unless FileTest.directory?(@file.output_path.pot_git.dir)
+ git.create_file_structure_git
+ end
+ if @md.opt.f_pth[:lng] == @md.opt.lng_base
+ FileUtils::cp(
+ @file.place_file.pot.dir,
+ @file.output_path.pot_git.dir
+ )
+ else # naive, work on -->
+ FileUtils::cp(
+ @file.place_file.po.dir,
+ @file.output_path.po_git.dir
+ ) #unless FileTest.file?(@file.place_file.po_git.dir)
+ end
+ git.read
+ end
+ end
+ end
+ end
+end
+__END__
+REMOVE
+&#033;\|&#035;\|&&#042;\|&#045;\|&#047;\|&#095;\|&#123;\|&#125;\|&#126;\|&#
+
+tables are problematic, difficult to reconstitute instruction, check
+
+metadata, move to top? and work on
+
+footnotes, different types, asterisk, also do you want to have separate
+paragraphs, or breaks within one block?
+
+where no ocn appropriately use ~# or -# or indeed 1~name-
+
+comments in document, what to do about them, not sure they are currently
+retained in dal, could be quite valuable to keep
+
+Translate Shell
+http://www.soimort.org/translate-shell/
+translate.google.com
diff --git a/lib/sisu/current/src_po4a_sst_ao_sst_set.rb b/lib/sisu/current/src_po4a_sst_ao_sst_set.rb
new file mode 100644
index 0000000..637ed38
--- /dev/null
+++ b/lib/sisu/current/src_po4a_sst_ao_sst_set.rb
@@ -0,0 +1,284 @@
+# encoding: utf-8
+=begin
+
+* Name: SiSU
+
+** Description: documents, structuring, processing, publishing, search
+*** po4a
+
+** Author: Ralph Amissah
+ <ralph@amissah.com>
+ <ralph.amissah@gmail.com>
+
+** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
+ 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah,
+ All Rights Reserved.
+
+** License: GPL 3 or later:
+
+ SiSU, a framework for document structuring, publishing and search
+
+ Copyright (C) Ralph Amissah
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the Free
+ Software Foundation, either version 3 of the License, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ more details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program. If not, see <http://www.gnu.org/licenses/>.
+
+ If you have Internet connection, the latest version of the GPL should be
+ available at these locations:
+ <http://www.fsf.org/licensing/licenses/gpl.html>
+ <http://www.gnu.org/licenses/gpl.html>
+
+ <http://www.sisudoc.org/sisu/en/manifest/gpl.fsf.html>
+
+** SiSU uses:
+ * Standard SiSU markup syntax,
+ * Standard SiSU meta-markup syntax, and the
+ * Standard SiSU object citation numbering and system
+
+** Hompages:
+ <http://www.jus.uio.no/sisu>
+ <http://www.sisudoc.org>
+
+** Git
+ <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=summary>
+ <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=blob;f=lib/sisu/current/src_po4a_sst_ao_sst_set.rb;hb=HEAD>
+
+=end
+module SiSU_Po4aUtils
+ class Wrap
+ def initialize(md,orig='',trans='',n_char_max=76,n_indent=0,n_hang=nil)
+ @md,@orig,@trans,@n_char_max,@n_indent=
+ md, orig, trans, n_char_max, n_indent
+ @n_char_max_extend = n_char_max
+ @br="\n"
+ @n_hang=n_hang ? n_hang : @n_indent
+ @po4a_identify_type='type: SiSU doc'
+ #@po4a_identify_type='type: Plain text'
+ end
+ def line_wrap
+ space=' '
+ spaces_indent,spaces_hang=
+ "#{@br}#{space*@n_indent}",space*@n_hang
+ pot,i=[],0
+ pot_array=(@trans.empty?) ? [@orig] : [@orig,@trans]
+ pot_array.each do |pa|
+ line=0
+ out=[]
+ out[line]=''
+ @oldword='' #REMOVE @oldword
+ pa=pa.gsub(/<br>/,' <br> ').
+ gsub(/#{Mx[:br_nl]}/,"\n\n")
+ words=pa.scan(/\n\n|\\\\\\|<br>|\S+/m)
+ while words != ''
+ word=words.shift
+ if not word
+ out[line] unless out[line].empty? #check
+ break
+ elsif word =~/\n\n/
+ word="\n"
+ @n_char_max_extend = @n_char_max + out[line].length
+ line=line
+ elsif (out[line].length + word.length) > (@n_char_max_extend - @n_indent) \
+ and out[line] =~/\S+/
+ @n_char_max_extend = @n_char_max
+ out[line].squeeze!(' ')
+ line += 1
+ end
+ if word
+ out[line]=if out[line] \
+ and out[line] !~/\S+$/m
+ "#{out[line]}#{word}"
+ elsif out[line] \
+ and out[line] =~/\S+/
+ "#{out[line]} #{word}"
+ else "#{word.strip}"
+ end
+ end
+ @oldword=word if word =~/\S+/
+ end
+ x=out.join(spaces_indent).gsub(/\A\n+/m,'').insert(0,spaces_hang)
+ z=[]
+ x.split(/\n/).each do |y|
+ z << y
+ end
+ pot[i]=z.join("\n")
+ i +=1
+ pot
+ end
+ trans=(pot.length == 2) ? pot[1] : ''
+ po_str=<<WOK
+#{pot[0]}
+WOK
+#{trans}
+ po_str
+ end
+ def no_line_wrap_block
+ pot,i=[],0
+ pot_array=(@trans.empty?) ? [@orig] : [@orig,@trans]
+ pot_array.each do |pa|
+ z=[]
+ pa.split(/\n\n/).each do |y|
+ z << y if not y.empty?
+ end
+ pot[i]=z.join("\n")
+ i +=1
+ pot
+ end
+ trans=(pot.length == 2) ? pot[1] : ''
+ po_str=<<WOK
+#{pot[0]}
+WOK
+#{trans}
+ po_str
+ end
+ def line_wrap_indent1
+ @n_indent,@n_hang=2,2
+ line_wrap
+ end
+ def line_wrap_endnote
+ @n_indent,@n_hang=4,2
+ line_wrap
+ end
+ def array_wrap
+ if @orig.is_a?(Array)
+ @arr=[]
+ @orig.each do |line|
+ @arr << SiSU_TextUtils::Wrap.new(line,@n_char_max,@n_indent,@n_hang).line_wrap
+ end
+ end
+ @arr
+ end
+ end
+ class HeaderScan
+ def initialize(md,para)
+ @md,@p=md,para
+ end
+ def extract(tag,tag_content,type,attrib)
+ if dc_tag \
+ and dc_content
+ [dc_tag,dc_content,{dc_tag=>dc_content}]
+ else nil
+ end
+ end
+ def header(tag,tag_content,type='',attrib='') #this will break stuff and must be tested thoroughly 20060825
+ @tag,@tag_content,@type,@attrib=tag,tag_content,type,attrib
+ def label #element
+ @tag
+ end
+ def type
+ @type
+ end
+ def text
+ @tag_content
+ end
+ def info #element text
+ @tag_content
+ end
+ def attribute
+ @attrib
+ end
+ def element
+ @tag
+ end
+ def attrib
+ @attrib
+ end
+ def el
+ @tag
+ end
+ self
+ end
+ def start_is_match
+ case @p
+ when /^#{Mx[:meta_o]}(title)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,@md.title.full,'meta','dc') #dc 1
+ when /^#{Mx[:meta_o]}(creator|author)#{Mx[:meta_c]}\s*(.+?)$/ then header('creator',$2,'meta','dc') #dc 2
+ when /^#{Mx[:meta_o]}(subject)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','dc') #dc 3
+ when /^#{Mx[:meta_o]}(description)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','dc') #dc 4
+ when /^#{Mx[:meta_o]}(publisher)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','dc') #dc 5
+ when /^#{Mx[:meta_o]}(contributor)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','dc') #dc 6
+ when /^#{Mx[:meta_o]}(date)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','dc') #dc 7
+ when /^#{Mx[:meta_o]}(date\.created)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','extra')
+ when /^#{Mx[:meta_o]}(date\.issued)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','extra')
+ when /^#{Mx[:meta_o]}(date\.available)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','extra')
+ when /^#{Mx[:meta_o]}(date\.valid)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','extra')
+ when /^#{Mx[:meta_o]}(date\.modified)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','extra')
+ when /^#{Mx[:meta_o]}(type)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','dc') #dc 8
+ when /^#{Mx[:meta_o]}(format)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','dc') #dc 9
+ when /^#{Mx[:meta_o]}(identifier)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','dc') #dc 10
+ when /^#{Mx[:meta_o]}(source)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','dc') #dc 11
+ when /^#{Mx[:meta_o]}(language)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','dc') #dc 12
+ when /^#{Mx[:meta_o]}(relation)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','dc') #dc 13
+ when /^#{Mx[:meta_o]}(coverage)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','dc') #dc 14
+ when /^#{Mx[:meta_o]}(rights)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','dc') #dc 15
+ when /^#{Mx[:meta_o]}(keywords)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','extra')
+ when /^#{Mx[:meta_o]}(copyright)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','extra')
+ when /^#{Mx[:meta_o]}(translator|translated_by)#{Mx[:meta_c]}\s*(.+?)$/ then header('translator',$2)
+ when /^#{Mx[:meta_o]}(illustrator|illustrated_by)#{Mx[:meta_c]}\s*(.+?)$/ then header('illustrator',$2)
+ when /^#{Mx[:meta_o]}(prepared_by)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','extra')
+ when /^#{Mx[:meta_o]}(digitized_by)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','extra')
+ when /^#{Mx[:meta_o]}(comments?)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','extra')
+ when /^#{Mx[:meta_o]}(abstract)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','extra')
+ when /^#{Mx[:meta_o]}(tags?)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','extra')
+ when /^#{Mx[:meta_o]}(catalogue)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','extra')
+ when /^#{Mx[:meta_o]}(class(?:ify)?_loc)#{Mx[:meta_c]}\s*(.+?)$/ then header('classify_loc',$2,'meta','extra')
+ when /^#{Mx[:meta_o]}(class(?:ify)?_dewey)#{Mx[:meta_c]}\s*(.+?)$/ then header('classify_dewey',$2,'meta','extra')
+ when /^#{Mx[:meta_o]}(class(?:ify)?_pg)#{Mx[:meta_c]}\s*(.+?)$/ then header('classify_pg',$2,'meta','extra')
+ when /^#{Mx[:meta_o]}(class(?:ify)?_isbn)#{Mx[:meta_c]}\s*(.+?)$/ then header('classify_isbn',$2,'meta','extra')
+ when /^#{Mx[:meta_o]}(toc|structure)#{Mx[:meta_c]}\s*(.+?)$/ then header('structure',$2,'process','instruct')
+ when /^#{Mx[:meta_o]}(level|page|markup)#{Mx[:meta_c]}\s*(.+?)$/ then header('markup',$2,'process','instruct')
+ when /^#{Mx[:meta_o]}(bold)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'process','instruct')
+ when /^#{Mx[:meta_o]}(italics|itali[sz]e)#{Mx[:meta_c]}\s*(.+?)$/ then header('italicize',$2,'process','instruct')
+ when /^#{Mx[:meta_o]}(vocabulary|wordlist)#{Mx[:meta_c]}\s*(.+?)$/ then header('vocabulary',$2,'process','instruct')
+ when /^#{Mx[:meta_o]}(css|stylesheet)#{Mx[:meta_c]}\s*(.+?)$/ then header('css',$2,'process','instruct')
+ when /^#{Mx[:meta_o]}(links)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'process','instruct')
+ when /^#{Mx[:meta_o]}(prefix)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'process','instruct') #add a & b
+ when /^#{Mx[:meta_o]}(suffix)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'process','instruct')
+ when /^#{Mx[:meta_o]}(information)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'process','instruct')
+ when /^#{Mx[:meta_o]}(contact)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'process','instruct')
+ when /^#{Mx[:meta_o]}(rcs|cvs)#{Mx[:meta_c]}\s*(.+?)$/ then header('version',$2,'process','instruct')
+ else nil
+ end
+ end
+ def dublin
+ (@p =~/^#{Mx[:meta_o]}\S+?#{Mx[:meta_c]}/) \
+ ? start_is_match
+ : nil
+ end
+ def meta
+ (@p =~/^#{Mx[:meta_o]}\S+?#{Mx[:meta_c]}/) \
+ ? start_is_match
+ : nil
+ end
+ end
+ class ParagraphNumber
+ def initialize(paranum)
+ @paranum=/(\d+)/m.match(paranum)[1]
+ end
+ def display
+ @paranum.gsub(/(\d+)/,'#\1')
+ end
+ end
+ class PotNumber
+ @@n=0
+ def initialize
+ @@n +=2
+ end
+ def num
+ @@n
+ end
+ def reset
+ @@n=0
+ end
+ end
+end
+__END__
diff --git a/lib/sisu/current/src_po4a_sstm.rb b/lib/sisu/current/src_po4a_sstm.rb
new file mode 100644
index 0000000..b625574
--- /dev/null
+++ b/lib/sisu/current/src_po4a_sstm.rb
@@ -0,0 +1,135 @@
+# encoding: utf-8
+=begin
+
+* Name: SiSU
+
+** Description: documents, structuring, processing, publishing, search
+*** share sisu source markup file, copy it to output directory!
+
+** Author: Ralph Amissah
+ <ralph@amissah.com>
+ <ralph.amissah@gmail.com>
+
+** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
+ 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah,
+ All Rights Reserved.
+
+** License: GPL 3 or later:
+
+ SiSU, a framework for document structuring, publishing and search
+
+ Copyright (C) Ralph Amissah
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the Free
+ Software Foundation, either version 3 of the License, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ more details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program. If not, see <http://www.gnu.org/licenses/>.
+
+ If you have Internet connection, the latest version of the GPL should be
+ available at these locations:
+ <http://www.fsf.org/licensing/licenses/gpl.html>
+ <http://www.gnu.org/licenses/gpl.html>
+
+ <http://www.sisudoc.org/sisu/en/manifest/gpl.fsf.html>
+
+** SiSU uses:
+ * Standard SiSU markup syntax,
+ * Standard SiSU meta-markup syntax, and the
+ * Standard SiSU object citation numbering and system
+
+** Hompages:
+ <http://www.jus.uio.no/sisu>
+ <http://www.sisudoc.org>
+
+** Git
+ <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=summary>
+ <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=blob;f=lib/sisu/current/src_po4a_sstm.rb;hb=HEAD>
+
+=end
+module SiSU_Markup
+ require_relative 'src_shared' # src_shared.rb
+ include SiSU_Source
+ require_relative 'src_po4a_share' # src_po4a_share.rb
+ require_relative 'se' # se.rb
+ include SiSU_Env
+ class Source_Po4a < SiSU_Source::SiSUpodSource
+ def initialize(opt,build=nil,place=nil)
+ super(opt,build,place)
+ @opt=opt
+ md=SiSU_Param::Parameters.new(opt).get
+ @file=SiSU_Env::FileOp.new(md,opt.fno)
+ end
+ def dir_mk(dir)
+ unless FileTest.directory?(dir)
+ FileUtils::mkdir_p(dir)
+ end
+ end
+ def make_paths
+ dir_mk(@file.output_path.pot.dir)
+ dir_mk(@file.output_path.po.dir)
+ end
+ def language
+ def source_language_selected_str
+ @opt.act[:po4a_lang][:src] \
+ ? @opt.act[:po4a_lang][:src]
+ : 'en'
+ end
+ self
+ end
+ def read
+ unless @opt.act[:quiet][:set]==:on
+ (@opt.act[:verbose][:set]==:on \
+ || @opt.act[:verbose_plus][:set]==:on \
+ || @opt.act[:maintenance][:set]==:on) \
+ ? SiSU_Screen::Ansi.new(
+ @opt.act[:color_state][:set],
+ 'Share document markup text source',
+ @opt.fns
+ ).cyan_hi_blue
+ : SiSU_Screen::Ansi.new(
+ @opt.act[:color_state][:set],
+ 'Share document markup text source',
+ @opt.fns
+ ).cyan_title_hi
+ end
+ make_paths
+ if FileTest.directory?(@path_pod[:fnb])
+ FileUtils::mkdir_p(@file.output_path.src.dir) \
+ unless FileTest.directory?(@file.output_path.src.dir)
+ v=(@opt.act[:maintenance][:set]==:on) \
+ ? 'v' : ''
+ system(%{
+ #rsync -a#{v} #{@path_pod[:fnb]}/sisupod/doc/* #{@file.output_path.po4a.dir}
+ rsync -a#{v} #{@path_pod[:fnb]}/sisupod/doc/#{language.source_language_selected_str}* #{@file.output_path.po4a.dir}
+ chbk=`pwd`
+ cd #{@file.output_path.sisupod.dir}
+ for I in `find -type d` ; do chmod 755 $I ; done
+ for I in `find -type f` ; do chmod 644 $I ; done
+ cd ${chbk}
+ })
+ md=SiSU_Param::Parameters.new(@opt).get
+ file=SiSU_Env::FileOp.new(md)
+ SiSU_Po4a_Project::Po4aCfg.new(@opt,file).song
+ SiSU_Po4a_Project::Po4aProject.new(@opt,file).song
+ else
+ if (@opt.act[:verbose][:set]==:on \
+ || @opt.act[:verbose_plus][:set]==:on \
+ || @opt.act[:maintenance][:set]==:on)
+ SiSU_Screen::Ansi.new(
+ '',
+ "#{@opt.fno} not available"
+ ).blue_tab
+ end
+ end
+ end
+ end
+end
+__END__
diff --git a/lib/sisu/current/src_shared.rb b/lib/sisu/current/src_shared.rb
index a6c41c2..05d22da 100644
--- a/lib/sisu/current/src_shared.rb
+++ b/lib/sisu/current/src_shared.rb
@@ -59,11 +59,13 @@ module SiSU_Source
class SiSUpodSource
require_relative 'se' # se.rb
require_relative 'se_hub_particulars' # se_hub_particulars.rb
+ require_relative 'utils_composite' # utils_composite.rb
+ include SiSU_Composite_Doc_Utils # composite doc, .ssm, extract all related insert files, array of filenames test
def initialize(opt,build=nil,place=nil)
@opt=opt
@date=SiSU_Env::InfoDate.new.dt
@env=SiSU_Env::InfoEnv.new(opt.fns)
- @ver=SiSU_Env::InfoVersion.instance.get_version
+ #@ver=SiSU_Env::InfoVersion.instance.get_version
@v=(@opt.act[:verbose_plus][:set]==:on \
|| @opt.act[:maintenance][:set]==:on) \
? 'v' : ''
@@ -74,7 +76,6 @@ module SiSU_Source
processing_sisupod.make
path_pod=processing_sisupod.paths[:sisupod]
path_pod_fnb=processing_sisupod.paths[:fnb]
- @doc_import_list=[]
FileUtils::mkdir_p(path_pod) unless FileTest.directory?(path_pod)
@path_pod={
fnb: path_pod_fnb,
@@ -102,8 +103,7 @@ module SiSU_Source
end
unless @opt.fns.empty?
directories
- file_array=IO.readlines(@opt.fno,'')
- doc_import_list=pod_source_build(file_array) #this needs to be built in case of multi-lingual for all of them, before single pass tar
+ doc_import_list=composite_and_imported_filenames_array(@opt.fno)
doc_import_list=[@opt.fno, doc_import_list].flatten
image_extraction(doc_import_list)
language_versions
@@ -165,25 +165,37 @@ module SiSU_Source
images=images.uniq
images.each do |i|
if FileTest.file?("#{images_pwd}/#{i}")
- FileUtils::cp("#{images_pwd}/#{i}","#{@path_pod[:image]}/#{i}")
+ FileUtils::cp(
+ "#{images_pwd}/#{i}",
+ "#{@path_pod[:image]}/#{i}"
+ )
else
STDERR.puts \
- %{\t*WARN* did not find image - "#{images_pwd}/#{i}" [#{__FILE__}:#{__LINE__}]}
+ %{\t*WARN* did not find image - } \
+ + %{"#{images_pwd}/#{i}" } \
+ + %{[#{__FILE__}:#{__LINE__}]}
end
end
else
STDERR.puts \
- %{\t*WARN* did not find - #{images_pwd} #{@path_pod[:image]} [#{__FILE__}:#{__LINE__}]}
+ %{\t*WARN* did not find - } \
+ + %{#{images_pwd} #{@path_pod[:image]} } \
+ + %{[#{__FILE__}:#{__LINE__}]}
end
end
if doc_import_list.length > 0 \
and @opt.fno =~/\.ssm$/
doc_import_list.each do |f|
if FileTest.file?("#{@opt.base_path}#{doc_import_dir}/#{f}")
- FileUtils::cp("#{@opt.base_path}#{doc_import_dir}/#{f}","#{@path_pod[:doc]}/#{f}")
+ FileUtils::cp(
+ "#{@opt.base_path}#{doc_import_dir}/#{f}",
+ "#{@path_pod[:doc]}/#{f}"
+ )
else
STDERR.puts \
- %{\t*WARN* did not find image - "#{@opt.base_path}#{doc_import_dir}/#{f}" [#{__FILE__}:#{__LINE__}]}
+ %{\t*WARN* did not find image - } \
+ + %{"#{@opt.base_path}#{doc_import_dir}/#{f}" } \
+ + %{[#{__FILE__}:#{__LINE__}]}
end
end
end
@@ -194,17 +206,22 @@ module SiSU_Source
if x[:f] \
and x[:f].length > 0 #store multiple document language versions, sisupod
x[:f].each do |f|
- FileUtils::mkdir_p(@path_pod[:doc]) unless FileTest.directory?(@path_pod[:doc])
+ FileUtils::mkdir_p(@path_pod[:doc]) \
+ unless FileTest.directory?(@path_pod[:doc])
if f[:f] =~/\~(\S{2,3})\.ss[tm]$/
lng_f=$1
if @opt.lng == lng_f
if @opt.fno =~/\.ssm$/
if FileTest.file?("#{@opt.base_path}#{doc_import_dir}/#{f[:f]}")
- FileUtils::cp("#{@opt.base_path}#{doc_import_dir}/#{f[:f]}",
- "#{@path_pod[:doc]}/#{f[:n]}")
+ FileUtils::cp(
+ "#{@opt.base_path}#{doc_import_dir}/#{f[:f]}",
+ "#{@path_pod[:doc]}/#{f[:n]}"
+ )
else
STDERR.puts \
- %{\t*WARN* did not find - "#{@opt.base_path}#{doc_import_dir}/#{f[:f]}" [#{__FILE__}:#{__LINE__}]}
+ %{\t*WARN* did not find - } \
+ + %{"#{@opt.base_path}#{doc_import_dir}/#{f[:f]}" } \
+ + %{[#{__FILE__}:#{__LINE__}]}
end
else
if FileTest.file?("#{@opt.base_path}/#{f[:f]}")
@@ -218,23 +235,31 @@ module SiSU_Source
else :no
end
if cpy == :yes
- FileUtils::cp("#{@opt.base_path}/#{f[:f]}",
- "#{@path_pod[:doc]}/#{f[:n]}")
+ FileUtils::cp(
+ "#{@opt.base_path}/#{f[:f]}",
+ "#{@path_pod[:doc]}/#{f[:n]}"
+ )
end
else
STDERR.puts \
- %{\t*WARN* did not find - "#{@opt.base_path}/#{f[:f]}" [#{__FILE__}:#{__LINE__}]}
+ %{\t*WARN* did not find - } \
+ + %{"#{@opt.base_path}/#{f[:f]}" } \
+ + %{[#{__FILE__}:#{__LINE__}]}
end
end
end
else
if @opt.fno =~/\.ssm$/
if FileTest.file?("#{@opt.base_path}#{doc_import_dir}/#{f[:f]}")
- FileUtils::cp_r("#{@opt.base_path}#{doc_import_dir}/#{f[:f]}",
- "#{@path_pod[:doc]}/#{f[:n]}")
+ FileUtils::cp_r(
+ "#{@opt.base_path}#{doc_import_dir}/#{f[:f]}",
+ "#{@path_pod[:doc]}/#{f[:n]}"
+ )
else
STDERR.puts \
- %{\t*WARN* did not find - "#{@opt.base_path}#{doc_import_dir}/#{f[:f]}" [#{__FILE__}:#{__LINE__}]}
+ %{\t*WARN* did not find - } \
+ + %{"#{@opt.base_path}#{doc_import_dir}/#{f[:f]}" } \
+ + %{[#{__FILE__}:#{__LINE__}]}
end
else
if FileTest.file?("#{@opt.base_path}#{doc_import_dir}/#{f[:f]}")
@@ -248,12 +273,16 @@ module SiSU_Source
else :no
end
if cpy == :yes
- FileUtils::cp("#{@opt.base_path}#{doc_import_dir}/#{f[:f]}",
- "#{@path_pod[:doc]}/#{f[:n]}")
+ FileUtils::cp(
+ "#{@opt.base_path}#{doc_import_dir}/#{f[:f]}",
+ "#{@path_pod[:doc]}/#{f[:n]}"
+ )
end
else
STDERR.puts \
- %{\t*WARN* did not find - "#{@opt.base_path}#{doc_import_dir}/#{f[:f]}" [#{__FILE__}:#{__LINE__}]}
+ %{\t*WARN* did not find - } \
+ + %{"#{@opt.base_path}#{doc_import_dir}/#{f[:f]}" } \
+ + %{[#{__FILE__}:#{__LINE__}]}
end
end
end
@@ -263,35 +292,6 @@ module SiSU_Source
def directories
SiSU_Env::InfoEnv.new.sisupod_v4(@opt)
end
- def ssm_doc_import_list(f)
- if @opt.fno =~/\.ss[mi]$/
- doc_import_list=[]
- if f =~@rgx_doc_import
- doc_import_list << f.scan(@rgx_doc_import)
- end
- doc_import_list.flatten.each do |i|
- if i =~/.ssi/
- file_array=IO.readlines(i,'')
- pod_source_build(file_array)
- end
- end
- end
- doc_import_list.uniq.flatten
- end
- def pod_source_build(file_array)
- @pwd=Dir.pwd
- @rgx_doc_import=/^<<\s*(\S+?\.ss[ti])/
- doc_import_list=[]
- file_array.each do |f| #% work area
- if f !~/^%+\s/
- if @opt.fno =~/\.ss[mi]$/
- @doc_import_list << ssm_doc_import_list(f)
- doc_import_list=@doc_import_list.flatten.uniq
- end
- end
- end
- doc_import_list
- end
end
end
__END__
diff --git a/lib/sisu/current/src_share.rb b/lib/sisu/current/src_sisupod_sstm.rb
index 7d3564f..48aefc6 100644
--- a/lib/sisu/current/src_share.rb
+++ b/lib/sisu/current/src_sisupod_sstm.rb
@@ -51,7 +51,7 @@
** Git
<http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=summary>
- <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=blob;f=lib/sisu/current/src_share.rb;hb=HEAD>
+ <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=blob;f=lib/sisu/current/src_sisupod_sstm.rb;hb=HEAD>
=end
module SiSU_Markup
@@ -59,7 +59,7 @@ module SiSU_Markup
include SiSU_Source
require_relative 'se' # se.rb
include SiSU_Env
- class Source < SiSU_Source::SiSUpodSource
+ class Source_Sisupod < SiSU_Source::SiSUpodSource
def initialize(opt,build=nil,place=nil)
super(opt,build,place)
@opt=opt
diff --git a/lib/sisu/current/sst_convert_markup.rb b/lib/sisu/current/sst_convert_markup.rb
index 447514f..3b81cf2 100644
--- a/lib/sisu/current/sst_convert_markup.rb
+++ b/lib/sisu/current/sst_convert_markup.rb
@@ -61,11 +61,10 @@ module SiSU_Modify
require_relative 'sst_from_xml' # sst_from_xml.rb
require_relative 'utils_response' # utils_response.rb
class ConvertMarkup
+ include SiSU_Response
def initialize(opt)
@opt=opt
@description='This is a script that contains canned text conversions for reuse'
- @response=SiSU_Response::Response.new
- @ask=SiSU_Response::Response.new
@warn='WARNING, PROCEED AT YOUR OWN RISK, will make file changes.'
end
def current_match_and_replace
@@ -75,7 +74,7 @@ module SiSU_Modify
response=''
unless @opt.cmd=~/QQ/ \
or @opt.act[:quiet][:set]==:on
- response=@ask.response?(%{#{ text}\nProceed? })
+ response=response?(%{#{ text}\nProceed? })
end
end
def help
diff --git a/lib/sisu/current/sst_from_xml.rb b/lib/sisu/current/sst_from_xml.rb
index 3b25377..8c2a9da 100644
--- a/lib/sisu/current/sst_from_xml.rb
+++ b/lib/sisu/current/sst_from_xml.rb
@@ -116,7 +116,7 @@ module SiSU_sstFromXML
out_file=File.new(@output_file_name,'w')
head=@doc.root.get_elements('//head/header')
body=@doc.root.get_elements('//object/text')
- out_file.puts "% SiSU text #{@ver[:version]} (generated from a SiSU XML markup representation)\n\n"
+ out_file.puts "% SiSU text #{@ver.version} (generated from a SiSU XML markup representation)\n\n"
head.each do |x|
if x.name=='header'
head=markup_head(x.to_s)
diff --git a/lib/sisu/current/sst_to_s_xml_sax.rb b/lib/sisu/current/sst_to_s_xml_sax.rb
index f82f44b..9805133 100644
--- a/lib/sisu/current/sst_to_s_xml_sax.rb
+++ b/lib/sisu/current/sst_to_s_xml_sax.rb
@@ -69,7 +69,7 @@ module SiSU_SimpleXML_ModelSax
include SiSU_XML_Format
require_relative 'rexml' # rexml.rb
include SiSU_Rexml
- @@alt_id_count,@@tablehead,@@number_of_cols=0,0,0
+ @@alt_id_count=0
@@tablefoot=''
class Convert
@@fns=nil
diff --git a/lib/sisu/current/texinfo_format.rb b/lib/sisu/current/texinfo_format.rb
index c03e2ec..7695a31 100644
--- a/lib/sisu/current/texinfo_format.rb
+++ b/lib/sisu/current/texinfo_format.rb
@@ -90,7 +90,7 @@ module SiSU_TexInfoFormat
author=@md.author if @md.author
author ||=''
author=author.gsub(/[\*]/,'') #if author
- SiSU_Env::InfoVersion.instance.get_version
+ #SiSU_Env::InfoVersion.instance.get_version
head =<<WOK
\\input texinfo @c -*-texinfo-*-
@comment %**start of header
diff --git a/lib/sisu/current/texpdf_format.rb b/lib/sisu/current/texpdf_format.rb
index a1a147e..0841102 100644
--- a/lib/sisu/current/texpdf_format.rb
+++ b/lib/sisu/current/texpdf_format.rb
@@ -890,7 +890,7 @@ module SiSU_TeX_Pdf
end
end
def tex_head_info
- generator="Generated by: #{@md.sisu_version[:project]} #{@md.sisu_version[:version]} of #{@md.sisu_version[:date_stamp]} (#{@md.sisu_version[:date]})" if @md.sisu_version[:version]
+ generator="Generated by: #{@md.project_details.project} #{@md.project_details.version} of #{@md.project_details.date_stamp} (#{@md.project_details.date})" if @md.project_details.version
lastdone="Last Generated on: #{Time.now}"
rubyv="Ruby version: #{@md.ruby_version}"
<<-WOK
@@ -1560,7 +1560,7 @@ module SiSU_TeX_Pdf
<<-WOK
\\\\ ~
{\\begin{footnotesize}#{base_prog_txt}
-\\\\ Generated by \\href{http://www.jus.uio.no/sisu}{SiSU} \\begin{tiny}[ #{v[:project]} #{v[:version]} of #{v[:date_stamp]} ]\\end{tiny} \\href{http://www.jus.uio.no/sisu}{www.jus.uio.no/sisu}
+\\\\ Generated by \\href{http://www.jus.uio.no/sisu}{SiSU} \\begin{tiny}[ #{v.project} #{v.version} of #{v.date_stamp} ]\\end{tiny} \\href{http://www.jus.uio.no/sisu}{www.jus.uio.no/sisu}
\\\\ Copyright #{@copymark} 1997, current #{@date.year_static} Ralph Amissah, All Rights Reserved.
\\\\ SiSU is software for document structuring, publishing and search (with object citation numbering), \\href{http://www.sisudoc.org}{www.sisudoc.org}
\\\\ SiSU is released under \\href{http://www.fsf.org/licenses/gpl.html}{GPL 3 } or later, #{url_brace.tex_open}\\href{http://www.fsf.org/licenses/gpl.html}{http://www.fsf.org/licenses/gpl.html}#{url_brace.tex_close}.
@@ -1584,7 +1584,7 @@ module SiSU_TeX_Pdf
Document version information: \\\\
\\emph{sourcefile} \\uline{#{@md.fnstex}}; \\emph{version} \\uline{#{@md.sc_number}}; \\emph{date} \\uline{#{@md.sc_date}}; \\emph{time} \\uline{#{@md.sc_time}} \\\\
Generated by \\href{http://www.jus.uio.no/sisu}{SiSU www.jus.uio.no/sisu }\\- version information: \\\\
-\\uline{ #{v[:project]} #{v[:version]} of #{v[:date_stamp]}}
+\\uline{ #{v.project} #{v.version} of #{v.date_stamp}}
\\end{footnotesize}}&
WOK
end
@@ -1596,7 +1596,7 @@ Generated by \\href{http://www.jus.uio.no/sisu}{SiSU www.jus.uio.no/sisu }\\- ve
Document information: \\\\
\\emph{sourcefile} \\uline{#{@md.fnstex}} \\\\
Generated by \\href{http://www.jus.uio.no/sisu}{SiSU www.jus.uio.no/sisu } \\\\ version information: \\
-\\uline{ #{v[:project]} #{v[:version]} of #{v[:date_stamp]}}
+\\uline{ #{v.project} #{v.version} of #{v.date_stamp}}
\\end{small}}&
WOK
diff --git a/lib/sisu/current/txt_asciidoc.rb b/lib/sisu/current/txt_asciidoc.rb
index 65488bd..540d80e 100644
--- a/lib/sisu/current/txt_asciidoc.rb
+++ b/lib/sisu/current/txt_asciidoc.rb
@@ -51,7 +51,7 @@
** Git
<http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=summary>
- <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=blob;f=lib/sisu/current/plaintext_asciidoc.rb;hb=HEAD>
+ <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=blob;f=lib/sisu/current/txt_asciidoc.rb;hb=HEAD>
=end
module SiSU_Txt_AsciiDoc
@@ -60,11 +60,15 @@ module SiSU_Txt_AsciiDoc
include SiSU_Env
require_relative 'shared_metadata' # shared_metadata.rb
require_relative 'generic_parts' # generic_parts.rb
+ require_relative 'txt_read' # txt_read.rb
require_relative 'txt_shared' # txt_shared.rb
+ require_relative 'txt_asciidoc_decorate' # txt_decorate.rb
+ require_relative 'txt_output' # txt_output.rb
include SiSU_Param
- @@alt_id_count,@@alt_id_count,@@tablehead,@@number_of_cols=0,0,0,0
+ @@alt_id_count,@@alt_id_count=0,0
@@tablefoot=''
class Source
+ include SiSU_Txt_Read
def initialize(opt)
@opt=opt
unless @opt.fns =~/(.+?)\.(?:-|ssm\.)?sst$/
@@ -74,46 +78,13 @@ module SiSU_Txt_AsciiDoc
def read
begin
md=SiSU_Param::Parameters.new(@opt).get
- env=SiSU_Env::InfoEnv.new(@opt.fns)
- unless @opt.act[:quiet][:set]==:on
- tool=(@opt.act[:verbose][:set]==:on \
- || @opt.act[:verbose_plus][:set]==:on \
- || @opt.act[:maintenance][:set]==:on) \
- ? "#{env.program.text_editor} #{md.file.output_path.asciidoc.dir}/#{md.file.base_filename.asciidoc}"
- : "[#{@opt.f_pth[:lng_is]}] #{@opt.fno}"
- (@opt.act[:verbose][:set]==:on \
- || @opt.act[:verbose_plus][:set]==:on \
- || @opt.act[:maintenance][:set]==:on) \
- ? SiSU_Screen::Ansi.new(
- @opt.act[:color_state][:set],
- 'AsciiDoc (plaintext utf-8)',
- tool
- ).green_hi_blue
- : SiSU_Screen::Ansi.new(
- @opt.act[:color_state][:set],
- 'AsciiDoc (plaintext utf-8)',
- tool
- ).green_title_hi
- if (@opt.act[:verbose_plus][:set]==:on \
- || @opt.act[:maintenance][:set]==:on)
- SiSU_Screen::Ansi.new(
- @opt.act[:color_state][:set],
- @opt.fns,
- "#{md.file.output_path.asciidoc.dir}/#{md.file.base_filename.asciidoc}"
- ).flow
- end
- end
- ao_array=SiSU_AO::Source.new(@opt).get # ao file drawn here
- wrap_width=if defined? md.make.plaintext_wrap \
- and md.make.plaintext_wrap
- md.make.plaintext_wrap
- elsif defined? env.plaintext_wrap \
- and env.plaintext_wrap
- env.plaintext_wrap
- else 78
- end
- #wrap_width=(defined? md.make.plaintext_wrap) ? md.make.plaintext_wrap : 78
- SiSU_Txt_AsciiDoc::Source::Scroll.new(md,ao_array,wrap_width).songsheet
+ specific={
+ description: 'AsciiDoc (plaintext utf-8)',
+ output_path: md.file.output_path.asciidoc.dir,
+ output_file: md.file.base_filename.asciidoc,
+ }
+ read_generic(@opt,specific)
+ SiSU_Txt_AsciiDoc::Source::Scroll.new(md,@ao_array,@wrap_width).songsheet
rescue
SiSU_Errors::Rescued.new($!,$@,@opt.selections.str,@opt.fns).location do
__LINE__.to_s + ':' + __FILE__
@@ -125,6 +96,7 @@ module SiSU_Txt_AsciiDoc
class Scroll <Source
include SiSU_Parts_Generic
include SiSU_TextUtils
+ include SiSU_Decorate_Txt_AsciiDoc
@@endnotes={ para: [], end: [] }
def initialize(md,data,wrap_width)
@md,@data,@wrap_width=md,data,wrap_width
@@ -161,7 +133,7 @@ WOK
end
def plaintext_tail
# env=SiSU_Env::InfoEnv.new(@md.fns)
- generator="Generated by: #{@md.sisu_version[:project]} #{@md.sisu_version[:version]} of #{@md.sisu_version[:date_stamp]} (#{@md.sisu_version[:date]})" if @md.sisu_version[:version]
+ generator="Generated by: #{@md.project_details.project} #{@md.project_details.version} of #{@md.project_details.date_stamp} (#{@md.project_details.date})" if @md.project_details.version
lastdone="Last Generated on: #{Time.now}"
rubyv="Ruby version: #{@md.ruby_version}"
sc=if @md.sc_info
@@ -185,153 +157,6 @@ at:
* SiSU #{the_url.sisu_txt}
WOK
end
- def decorate
- def heading
- def inline
- def l0
- '='
- end
- def l1
- '=='
- end
- def l2
- '==='
- end
- def l3
- '===='
- end
- def l4
- '====='
- end
- def l5
- '' #'======' #logical
- end
- self
- end
- def underscore
- def l0
- '='
- end
- def l1
- '-'
- end
- def l2
- '~'
- end
- def l3
- '^'
- end
- def l4
- '+'
- end
- def l5
- '.' #'.' #proposed
- end
- self
- end
- self
- end
- def bold
- def open
- '*'
- end
- def close
- '*'
- end
- self
- end
- def italics
- def open
- '_'
- end
- def close
- '_'
- end
- self
- end
- def underscore
- def open
- ''
- end
- def close
- ''
- end
- self
- end
- #def emphasis
- # def open
- # ''
- # end
- # def close
- # ''
- # end
- # self
- #end
- def cite
- def open
- '"'
- end
- def close
- '"'
- end
- self
- end
- def insert
- def open
- ''
- end
- def close
- ''
- end
- self
- end
- def strike
- def open
- '-'
- end
- def close
- '-'
- end
- self
- end
- def superscript
- def open
- '^'
- end
- def close
- '^'
- end
- self
- end
- def subscript
- def open
- '~'
- end
- def close
- '~'
- end
- self
- end
- def hilite #bold
- def open
- '*'
- end
- def close
- '*'
- end
- self
- end
- def monospace
- def open
- '+'
- end
- def close
- '+'
- end
- self
- end
- self
- end
def heading_decorated_inline(dob)
if dob.is==:heading
heading_inline = case dob.lc
@@ -519,41 +344,11 @@ WOK
content << plaintext[:metadata]
content << "#{break_line}#{divider*@wrap_width}#{break_line}" if @md.stmp =~/\w+/ #not used?
content << plaintext[:tail]
- Output.new(content,@md).asciidoc
+ outputfile=SiSU_Env::FileOp.new(@md).write_file.asciidoc
+ Txt_Output::Output.new.document(content,outputfile)
@@endnotes={ para: [], end: [] }
end
end
- class Output <Source
- include SiSU_Param
- include SiSU_Env
- def initialize(content,md)
- @content,@md=content,md
- end
- def asciidoc
- file_plaintext=SiSU_Env::FileOp.new(@md).write_file.asciidoc
- @sisu=[]
- emptyline=0
- @content.each do |para| # this is a hack
- if para.is_a?(Array) \
- and para.length > 0
- para.each do |line|
- if line
- line=line.gsub(/[ \t]+$/m,'').
- gsub(/^\A[ ]*\Z/m,'')
- (line=~/^\A\Z/) \
- ? (emptyline+=1)
- : emptyline=0
- if emptyline < 2 #remove additional empty lines
- file_plaintext.puts line
- end
- end
- end
- else file_plaintext.puts para #unix plaintext # /^([*=-]|\.){5}/
- end
- end
- file_plaintext.close
- end
- end
end
end
__END__
diff --git a/lib/sisu/current/txt_asciidoc_decorate.rb b/lib/sisu/current/txt_asciidoc_decorate.rb
new file mode 100644
index 0000000..faa5b91
--- /dev/null
+++ b/lib/sisu/current/txt_asciidoc_decorate.rb
@@ -0,0 +1,207 @@
+# encoding: utf-8
+=begin
+
+* Name: SiSU
+
+** Description: documents, structuring, processing, publishing, search
+*** plaintext decoration
+
+** Author: Ralph Amissah
+ <ralph@amissah.com>
+ <ralph.amissah@gmail.com>
+
+** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
+ 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah,
+ All Rights Reserved.
+
+** License: GPL 3 or later:
+
+ SiSU, a framework for document structuring, publishing and search
+
+ Copyright (C) Ralph Amissah
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the Free
+ Software Foundation, either version 3 of the License, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ more details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program. If not, see <http://www.gnu.org/licenses/>.
+
+ If you have Internet connection, the latest version of the GPL should be
+ available at these locations:
+ <http://www.fsf.org/licensing/licenses/gpl.html>
+ <http://www.gnu.org/licenses/gpl.html>
+
+ <http://www.sisudoc.org/sisu/en/manifest/gpl.fsf.html>
+
+** SiSU uses:
+ * Standard SiSU markup syntax,
+ * Standard SiSU meta-markup syntax, and the
+ * Standard SiSU object citation numbering and system
+
+** Hompages:
+ <http://www.jus.uio.no/sisu>
+ <http://www.sisudoc.org>
+
+** Git
+ <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=summary>
+ <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=blob;f=lib/sisu/current/txt_asciidoc_decorate.rb;hb=HEAD>
+
+=end
+
+module SiSU_Decorate_Txt_AsciiDoc
+ def decorate
+ def heading
+ def inline
+ def l0
+ '='
+ end
+ def l1
+ '=='
+ end
+ def l2
+ '==='
+ end
+ def l3
+ '===='
+ end
+ def l4
+ '====='
+ end
+ def l5
+ '' #'======' #logical
+ end
+ self
+ end
+ def underscore
+ def l0
+ '='
+ end
+ def l1
+ '-'
+ end
+ def l2
+ '~'
+ end
+ def l3
+ '^'
+ end
+ def l4
+ '+'
+ end
+ def l5
+ '.' #'.' #proposed
+ end
+ self
+ end
+ self
+ end
+ def bold
+ def open
+ '*'
+ end
+ def close
+ '*'
+ end
+ self
+ end
+ def italics
+ def open
+ '_'
+ end
+ def close
+ '_'
+ end
+ self
+ end
+ def underscore
+ def open
+ ''
+ end
+ def close
+ ''
+ end
+ self
+ end
+ #def emphasis
+ # def open
+ # ''
+ # end
+ # def close
+ # ''
+ # end
+ # self
+ #end
+ def cite
+ def open
+ '"'
+ end
+ def close
+ '"'
+ end
+ self
+ end
+ def insert
+ def open
+ ''
+ end
+ def close
+ ''
+ end
+ self
+ end
+ def strike
+ def open
+ '-'
+ end
+ def close
+ '-'
+ end
+ self
+ end
+ def superscript
+ def open
+ '^'
+ end
+ def close
+ '^'
+ end
+ self
+ end
+ def subscript
+ def open
+ '~'
+ end
+ def close
+ '~'
+ end
+ self
+ end
+ def hilite #bold
+ def open
+ '*'
+ end
+ def close
+ '*'
+ end
+ self
+ end
+ def monospace
+ def open
+ '+'
+ end
+ def close
+ '+'
+ end
+ self
+ end
+ self
+ end
+end
+__END__
diff --git a/lib/sisu/current/txt_markdown.rb b/lib/sisu/current/txt_markdown.rb
index 1ec2bdf..497cf5b 100644
--- a/lib/sisu/current/txt_markdown.rb
+++ b/lib/sisu/current/txt_markdown.rb
@@ -51,7 +51,7 @@
** Git
<http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=summary>
- <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=blob;f=lib/sisu/current/plaintext_markdown.rb;hb=HEAD>
+ <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=blob;f=lib/sisu/current/txt_markdown.rb;hb=HEAD>
=end
module SiSU_Txt_Markdown
@@ -60,11 +60,15 @@ module SiSU_Txt_Markdown
include SiSU_Env
require_relative 'shared_metadata' # shared_metadata.rb
require_relative 'generic_parts' # generic_parts.rb
+ require_relative 'txt_read' # txt_read.rb
require_relative 'txt_shared' # txt_shared.rb
+ require_relative 'txt_markdown_decorate' # txt_markdown_decorate.rb
+ require_relative 'txt_output' # txt_output.rb
include SiSU_Param
- @@alt_id_count,@@alt_id_count,@@tablehead,@@number_of_cols=0,0,0,0
+ @@alt_id_count,@@alt_id_count=0,0
@@tablefoot=''
class Source
+ include SiSU_Txt_Read
def initialize(opt)
@opt=opt
unless @opt.fns =~/(.+?)\.(?:-|ssm\.)?sst$/
@@ -74,45 +78,13 @@ module SiSU_Txt_Markdown
def read
begin
md=SiSU_Param::Parameters.new(@opt).get
- env=SiSU_Env::InfoEnv.new(@opt.fns)
- unless @opt.act[:quiet][:set]==:on
- tool=(@opt.act[:verbose][:set]==:on \
- || @opt.act[:verbose_plus][:set]==:on \
- || @opt.act[:maintenance][:set]==:on) \
- ? "#{env.program.text_editor} #{md.file.output_path.markdown.dir}/#{md.file.base_filename.markdown}"
- : "[#{@opt.f_pth[:lng_is]}] #{@opt.fno}"
- (@opt.act[:verbose][:set]==:on \
- || @opt.act[:verbose_plus][:set]==:on \
- || @opt.act[:maintenance][:set]==:on) \
- ? SiSU_Screen::Ansi.new(
- @opt.act[:color_state][:set],
- 'Markdown (plaintext utf-8)',
- tool
- ).green_hi_blue
- : SiSU_Screen::Ansi.new(
- @opt.act[:color_state][:set],
- 'Markdown (plaintext utf-8)',
- tool
- ).green_title_hi
- if (@opt.act[:verbose_plus][:set]==:on \
- || @opt.act[:maintenance][:set]==:on)
- SiSU_Screen::Ansi.new(
- @opt.act[:color_state][:set],
- @opt.fns,"#{md.file.output_path.markdown.dir}/#{md.file.base_filename.markdown}"
- ).flow
- end
- end
- ao_array=SiSU_AO::Source.new(@opt).get # ao file drawn here
- wrap_width=if defined? md.make.plaintext_wrap \
- and md.make.plaintext_wrap
- md.make.plaintext_wrap
- elsif defined? env.plaintext_wrap \
- and env.plaintext_wrap
- env.plaintext_wrap
- else 78
- end
- #wrap_width=(defined? md.make.plaintext_wrap) ? md.make.plaintext_wrap : 78
- SiSU_Txt_Markdown::Source::Scroll.new(md,ao_array,wrap_width).songsheet
+ specific={
+ description: 'Markdown (plaintext utf-8)',
+ output_path: md.file.output_path.markdown.dir,
+ output_file: md.file.base_filename.markdown,
+ }
+ read_generic(@opt,specific)
+ SiSU_Txt_Markdown::Source::Scroll.new(md,@ao_array,@wrap_width).songsheet
rescue
SiSU_Errors::Rescued.new($!,$@,@opt.selections.str,@opt.fns).location do
__LINE__.to_s + ':' + __FILE__
@@ -124,6 +96,7 @@ module SiSU_Txt_Markdown
class Scroll <Source
include SiSU_Parts_Generic
include SiSU_TextUtils
+ include SiSU_Decorate_Txt_Markdown
@@endnotes={ para: [], end: [] }
def initialize(md,data,wrap_width)
@md,@data,@wrap_width=md,data,wrap_width
@@ -152,10 +125,10 @@ module SiSU_Txt_Markdown
if n =~/#{Mx[:br_line]}|#{Mx[:br_nl]}/
fix = n.split(/#{Mx[:br_line]}|#{Mx[:br_nl]}/) #watch #added
fix.each do |x|
- unless x.empty?; @n << x
+ unless x.empty? then @n << x
end
end
- else @n << n
+ else @n << n
end
end
notes=@n.flatten
@@ -196,7 +169,7 @@ WOK
end
def plaintext_tail
# env=SiSU_Env::InfoEnv.new(@md.fns)
- generator="Generated by: #{@md.sisu_version[:project]} #{@md.sisu_version[:version]} of #{@md.sisu_version[:date_stamp]} (#{@md.sisu_version[:date]})" if @md.sisu_version[:version]
+ generator="Generated by: #{@md.project_details.project} #{@md.project_details.version} of #{@md.project_details.date_stamp} (#{@md.project_details.date})" if @md.project_details.version
lastdone="Last Generated on: #{Time.now}"
rubyv="Ruby version: #{@md.ruby_version}"
sc=if @md.sc_info
@@ -220,153 +193,6 @@ at:
* SiSU #{the_url.sisu_txt}
WOK
end
- def decorate
- def heading
- def inline #atx
- def l0
- '#'
- end
- def l1
- '##'
- end
- def l2
- '###'
- end
- def l3
- '####'
- end
- def l4
- '#####'
- end
- def l5
- '######'
- end
- self
- end
- def underscore #Setext
- def l1
- '='
- end
- def l2
- '-'
- end
- def l3
- ''
- end
- def l4
- ''
- end
- def l5
- ''
- end
- def l6
- ''
- end
- self
- end
- self
- end
- def bold
- def open
- '**'
- end
- def close
- '**'
- end
- self
- end
- def italics
- def open
- '*'
- end
- def close
- '*'
- end
- self
- end
- def underscore
- def open
- '_'
- end
- def close
- '_'
- end
- self
- end
- #def emphasis
- # def open
- # ''
- # end
- # def close
- # ''
- # end
- # self
- #end
- def cite
- def open
- '"'
- end
- def close
- '"'
- end
- self
- end
- def insert
- def open
- '+'
- end
- def close
- '+'
- end
- self
- end
- def strike
- def open
- '-'
- end
- def close
- '-'
- end
- self
- end
- def superscript
- def open
- '^'
- end
- def close
- '^'
- end
- self
- end
- def subscript
- def open
- '['
- end
- def close
- ']'
- end
- self
- end
- def hilite
- def open
- '**'
- end
- def close
- '**'
- end
- self
- end
- def monospace
- def open
- '`'
- end
- def close
- '`'
- end
- self
- end
- self
- end
def heading_decorated_inline(dob)
if dob.is==:heading
heading_inline = case dob.lc
@@ -553,41 +379,11 @@ WOK
content << plaintext[:metadata]
content << "#{break_line}#{divider*@wrap_width}#{break_line}" if @md.stmp =~/\w+/ #not used?
content << plaintext[:tail]
- Output.new(content,@md).markdown
+ outputfile=SiSU_Env::FileOp.new(@md).write_file.markdown
+ Txt_Output::Output.new.document(content,outputfile)
@@endnotes={ para: [], end: [] }
end
end
- class Output <Source
- include SiSU_Param
- include SiSU_Env
- def initialize(content,md)
- @content,@md=content,md
- end
- def markdown
- file_plaintext=SiSU_Env::FileOp.new(@md).write_file.markdown
- @sisu=[]
- emptyline=0
- @content.each do |para| # this is a hack
- if para.is_a?(Array) \
- and para.length > 0
- para.each do |line|
- if line
- line=line.gsub(/[ \t]+$/m,'').
- gsub(/^\A[ ]*\Z/m,'')
- (line=~/^\A\Z/) \
- ? (emptyline+=1)
- : emptyline=0
- if emptyline < 2 #remove additional empty lines
- file_plaintext.puts line
- end
- end
- end
- else file_plaintext.puts para #unix plaintext # /^([*=-]|\.){5}/
- end
- end
- file_plaintext.close
- end
- end
end
end
__END__
diff --git a/lib/sisu/current/txt_markdown_decorate.rb b/lib/sisu/current/txt_markdown_decorate.rb
new file mode 100644
index 0000000..0902623
--- /dev/null
+++ b/lib/sisu/current/txt_markdown_decorate.rb
@@ -0,0 +1,207 @@
+# encoding: utf-8
+=begin
+
+* Name: SiSU
+
+** Description: documents, structuring, processing, publishing, search
+*** plaintext decoration
+
+** Author: Ralph Amissah
+ <ralph@amissah.com>
+ <ralph.amissah@gmail.com>
+
+** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
+ 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah,
+ All Rights Reserved.
+
+** License: GPL 3 or later:
+
+ SiSU, a framework for document structuring, publishing and search
+
+ Copyright (C) Ralph Amissah
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the Free
+ Software Foundation, either version 3 of the License, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ more details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program. If not, see <http://www.gnu.org/licenses/>.
+
+ If you have Internet connection, the latest version of the GPL should be
+ available at these locations:
+ <http://www.fsf.org/licensing/licenses/gpl.html>
+ <http://www.gnu.org/licenses/gpl.html>
+
+ <http://www.sisudoc.org/sisu/en/manifest/gpl.fsf.html>
+
+** SiSU uses:
+ * Standard SiSU markup syntax,
+ * Standard SiSU meta-markup syntax, and the
+ * Standard SiSU object citation numbering and system
+
+** Hompages:
+ <http://www.jus.uio.no/sisu>
+ <http://www.sisudoc.org>
+
+** Git
+ <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=summary>
+ <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=blob;f=lib/sisu/current/txt_markdown_decorate.rb;hb=HEAD>
+
+=end
+
+module SiSU_Decorate_Txt_Markdown
+ def decorate
+ def heading
+ def inline #atx
+ def l0
+ '#'
+ end
+ def l1
+ '##'
+ end
+ def l2
+ '###'
+ end
+ def l3
+ '####'
+ end
+ def l4
+ '#####'
+ end
+ def l5
+ '######'
+ end
+ self
+ end
+ def underscore #Setext
+ def l1
+ '='
+ end
+ def l2
+ '-'
+ end
+ def l3
+ ''
+ end
+ def l4
+ ''
+ end
+ def l5
+ ''
+ end
+ def l6
+ ''
+ end
+ self
+ end
+ self
+ end
+ def bold
+ def open
+ '**'
+ end
+ def close
+ '**'
+ end
+ self
+ end
+ def italics
+ def open
+ '*'
+ end
+ def close
+ '*'
+ end
+ self
+ end
+ def underscore
+ def open
+ '_'
+ end
+ def close
+ '_'
+ end
+ self
+ end
+ #def emphasis
+ # def open
+ # ''
+ # end
+ # def close
+ # ''
+ # end
+ # self
+ #end
+ def cite
+ def open
+ '"'
+ end
+ def close
+ '"'
+ end
+ self
+ end
+ def insert
+ def open
+ '+'
+ end
+ def close
+ '+'
+ end
+ self
+ end
+ def strike
+ def open
+ '-'
+ end
+ def close
+ '-'
+ end
+ self
+ end
+ def superscript
+ def open
+ '^'
+ end
+ def close
+ '^'
+ end
+ self
+ end
+ def subscript
+ def open
+ '['
+ end
+ def close
+ ']'
+ end
+ self
+ end
+ def hilite
+ def open
+ '**'
+ end
+ def close
+ '**'
+ end
+ self
+ end
+ def monospace
+ def open
+ '`'
+ end
+ def close
+ '`'
+ end
+ self
+ end
+ self
+ end
+end
+__END__
diff --git a/lib/sisu/current/txt_orgmode.rb b/lib/sisu/current/txt_orgmode.rb
new file mode 100644
index 0000000..720c9f6
--- /dev/null
+++ b/lib/sisu/current/txt_orgmode.rb
@@ -0,0 +1,376 @@
+# encoding: utf-8
+=begin
+
+* Name: SiSU
+
+** Description: documents, structuring, processing, publishing, search
+*** plaintext (smarttext) generation, orgmode structure
+
+** Author: Ralph Amissah
+ <ralph@amissah.com>
+ <ralph.amissah@gmail.com>
+
+** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
+ 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah,
+ All Rights Reserved.
+
+** License: GPL 3 or later:
+
+ SiSU, a framework for document structuring, publishing and search
+
+ Copyright (C) Ralph Amissah
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the Free
+ Software Foundation, either version 3 of the License, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ more details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program. If not, see <http://www.gnu.org/licenses/>.
+
+ If you have Internet connection, the latest version of the GPL should be
+ available at these locations:
+ <http://www.fsf.org/licensing/licenses/gpl.html>
+ <http://www.gnu.org/licenses/gpl.html>
+
+ <http://www.sisudoc.org/sisu/en/manifest/gpl.fsf.html>
+
+** SiSU uses:
+ * Standard SiSU markup syntax,
+ * Standard SiSU meta-markup syntax, and the
+ * Standard SiSU object citation numbering and system
+
+** Hompages:
+ <http://www.jus.uio.no/sisu>
+ <http://www.sisudoc.org>
+
+** Git
+ <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=summary>
+ <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=blob;f=lib/sisu/current/txt_orgmode.rb;hb=HEAD>
+
+=end
+module SiSU_Txt_OrgMode
+ require_relative 'ao' # ao.rb
+ require_relative 'se' # se.rb
+ include SiSU_Env
+ require_relative 'shared_metadata' # shared_metadata.rb
+ require_relative 'generic_parts' # generic_parts.rb
+ require_relative 'txt_read' # txt_read.rb
+ require_relative 'txt_shared' # txt_shared.rb
+ require_relative 'txt_orgmode_decorate' # txt_orgmode_decorate.rb
+ require_relative 'txt_output' # txt_output.rb
+ include SiSU_Param
+ @@alt_id_count,@@alt_id_count=0,0
+ @@tablefoot=''
+ class Source
+ include SiSU_Txt_Read
+ def initialize(opt)
+ @opt=opt
+ unless @opt.fns =~/(.+?)\.(?:-|ssm\.)?sst$/
+ puts "#{sf} not a processed file type"
+ end
+ end
+ def read
+ begin
+ md=SiSU_Param::Parameters.new(@opt).get
+ specific={
+ description: 'OrgMode (plaintext utf-8)',
+ output_path: md.file.output_path.orgmode.dir,
+ output_file: md.file.base_filename.orgmode,
+ }
+ read_generic(@opt,specific)
+ SiSU_Txt_OrgMode::Source::Scroll.new(md,@ao_array,@wrap_width).songsheet
+ rescue
+ SiSU_Errors::Rescued.new($!,$@,@opt.selections.str,@opt.fns).location do
+ __LINE__.to_s + ':' + __FILE__
+ end
+ ensure
+ end
+ end
+ private
+ class Scroll <Source
+ include SiSU_Parts_Generic
+ include SiSU_TextUtils
+ include SiSU_Decorate_Txt_OrgMode
+ @@endnotes={ para: [], end: [] }
+ def initialize(md,data,wrap_width)
+ @md,@data,@wrap_width=md,data,wrap_width
+ @env=SiSU_Env::InfoEnv.new(@md.fns)
+ @tab="\t"
+ @@endnotes_=case md.opt.selections.str
+ when /--footnote/ then false
+ when /--endnote/ then true
+ else true
+ end
+ @plaintext={ body: [], open: [], close: [], head: [], endnotes: [], metadata: [], tail: [] }
+ end
+ def songsheet
+ plaintext=markup(@data)
+ publish(plaintext)
+ end
+ def break_line
+ "\n"
+ end
+ def extract_endnotes(dob='')
+ notes=dob.obj.scan(/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]})([\d*+]+\s+.+?)(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/)
+ @n=[]
+ notes.flatten.each do |n| #high cost to deal with <br> appropriately within plaintext, consider
+ n=n.dup.to_s
+ if n =~/#{Mx[:br_line]}|#{Mx[:br_nl]}/
+ fix = n.split(/#{Mx[:br_line]}|#{Mx[:br_nl]}/) #watch #added
+ fix.each do |x|
+ unless x.empty? then @n << x
+ end
+ end
+ else @n << n
+ end
+ end
+ notes=@n.flatten
+ notes.each do |e|
+ util=(e.to_s =~/^\[[\d*+]+\]:/) \
+ ? (SiSU_TextUtils::Wrap.new(e.to_s,@wrap_width,4,1))
+ : (SiSU_TextUtils::Wrap.new(e.to_s,@wrap_width,1,1))
+ wrap=util.line_wrap
+ wrap=if wrap =~ /^\s*[\d*+]+\s+.+?\s*\Z/m
+ wrap.gsub(/^(\s*)([\d*+]+)\s+(.+?)\s*\Z/m, <<-GSUB
+\\1[\\2]: \\3
+ GSUB
+ )
+ else
+ wrap.gsub(/^(.+)\Z/m, <<-GSUB
+\\1
+ GSUB
+ )
+ end
+ @@endnotes[:para] << "-#{wrap}"
+ @@endnotes[:end] << '' << wrap
+ end
+ @@endnotes
+ end
+ # Used for extraction of endnotes from paragraphs
+ def plaintext_metadata
+ array=SiSU_Metadata::Summary.new(@md).plaintext.metadata
+ array.each do |meta|
+ tag,inf=meta.scan(/^.+?:\s|.+/)
+ if tag and inf
+ util=SiSU_TextUtils::Wrap.new(inf,@wrap_width,15,1)
+ txt=util.line_wrap
+ @plaintext[:metadata] <<<<WOK
+
+#{@tab}#{tag}#{txt}
+WOK
+ end
+ end
+ end
+ def plaintext_tail
+# env=SiSU_Env::InfoEnv.new(@md.fns)
+ generator="Generated by: #{@md.project_details.project} #{@md.project_details.version} of #{@md.project_details.date_stamp} (#{@md.project_details.date})" if @md.project_details.version
+ lastdone="Last Generated on: #{Time.now}"
+ rubyv="Ruby version: #{@md.ruby_version}"
+ sc=if @md.sc_info
+ "Source file: #{@md.sc_filename}#{break_line}Version number: #{@md.sc_number}#{break_line}Version date: #{@md.sc_date}#{break_line}"
+ else ''
+ end
+ @plaintext[:tail] <<<<WOK
+** Metadata
+#{break_line}
+plaintext (plain text):
+ #{@md.file.output_path.orgmode.url}/#{@md.file.base_filename.orgmode}#{break_line}
+Other versions of this document: #{break_line}
+manifest:
+ #{@md.file.output_path.manifest.url}/#{@md.file.base_filename.manifest}#{break_line}
+at:
+ #{@md.file.output_path.base.url}#{break_line}
+
+ #{sc}
+ * #{generator}
+ * #{rubyv}
+ * #{lastdone}
+ * SiSU #{the_url.sisu_txt}
+WOK
+ end
+ def heading_decorated_inline(dob)
+ if dob.is==:heading
+ heading_inline = case dob.lc
+ when 0 then decorate.heading.inline.l0
+ when 1 then decorate.heading.inline.l1
+ when 2 then decorate.heading.inline.l2
+ when 3 then decorate.heading.inline.l3
+ when 4 then decorate.heading.inline.l4
+ when 5 then decorate.heading.inline.l5
+ when 6 then decorate.heading.inline.l6
+ end
+ heading_inline + ' ' + dob.obj
+ end
+ end
+ def plaintext_structure(dob='',p_num='') #% Used to extract the structure of a document
+ heading_decoration=:inline #(:inline|:underscore) #switch heading decoration between inline & underscore options
+ util=nil
+ wrapped=if dob.is==:para \
+ || dob.is==:heading
+ if dob.is==:heading
+ util=(heading_decoration== :inline) \
+ ? (SiSU_TextUtils::Wrap.new(heading_decorated_inline(dob),@wrap_width,0))
+ : (SiSU_TextUtils::Wrap.new(dob.obj,@wrap_width,0))
+ elsif dob.is==:para
+ if dob.hang \
+ and dob.hang =~/[0-9]/ \
+ and dob.indent != dob.hang
+ util=SiSU_TextUtils::Wrap.new(dob.obj,@wrap_width,dob.indent.to_i*2,dob.hang.to_i*2)
+ #util=SiSU_TextUtils::Wrap.new(dob.obj,@wrap_width,dob.hang.to_i*2,0)
+ elsif dob.indent =~/[1-9]/
+ util=if dob.bullet_
+ SiSU_TextUtils::Wrap.new("* #{dob.obj}",@wrap_width,dob.indent.to_i*2)
+ else SiSU_TextUtils::Wrap.new(dob.obj,@wrap_width,dob.indent.to_i*2)
+ end
+ else
+ util=if dob.bullet_
+ SiSU_TextUtils::Wrap.new("* #{dob.obj}",@wrap_width,0)
+ else SiSU_TextUtils::Wrap.new(dob.obj,@wrap_width,0)
+ end
+ end
+ else util=SiSU_TextUtils::Wrap.new(dob.obj,@wrap_width,0)
+ end
+ dob.is==:heading ? util.no_wrap_no_breaks : util.line_wrap
+ end
+ if dob.is==:para \
+ || dob.is==:heading
+ @plaintext[:body] << wrapped + p_num << break_line # main text, contents, body KEEP
+ end
+# remove ...
+ if @@endnotes[:para] \
+ and not @@endnotes_
+ @@endnotes[:para].each {|e| @plaintext[:body] << e << break_line}
+ elsif @@endnotes[:para] \
+ and @@endnotes_
+ @@endnotes[:para].each {|e| @plaintext[:endnotes] << e << break_line}
+ end
+ @@endnotes[:para]=[]
+ end
+ def markup(data) # Used for major markup instructions
+ SiSU_Env::InfoEnv.new(@md.fns)
+ @data_mod,@endnotes,@level,@cont,@copen,@plaintext_contents_close=Array.new(6){[]}
+ (0..6).each { |x| @cont[x]=@level[x]=false }
+ (4..6).each { |x| @plaintext_contents_close[x]='' }
+ plaintext_tail #($1,$2)
+ plaintext_metadata
+ table_message='[table conversion awaited, see other document formats]'
+ data.each do |dob|
+ dob.obj=dob.obj.gsub(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}.+/um,"#{break_line}#{table_message}"). #fix
+ gsub(/.+?#{Mx[:gl_o]}-##{Mx[:gl_c]}/,''). # remove dummy headings (used by html) #check also [~-]#
+ gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,
+ "#{decorate.bold.open}\\1#{decorate.bold.close}").
+ gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,
+ "#{decorate.italics.open}\\1#{decorate.italics.close}").
+ gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,
+ "#{decorate.underscore.open}\\1#{decorate.underscore.close}").
+ gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,
+ "#{decorate.subscript.open}\\1#{decorate.subscript.close}").
+ gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,
+ "#{decorate.superscript.open}\\1#{decorate.superscript.close}").
+ gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,
+ "#{decorate.insert.open}\\1#{decorate.insert.close}").
+ gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,
+ "#{decorate.cite.open}\\1#{decorate.cite.close}").
+ gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,
+ "#{decorate.strike.open}\\1#{decorate.strike.close}").
+ gsub(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/,
+ "#{decorate.monospace.open}\\1#{decorate.monospace.close}")
+ unless dob.is==:code
+ dob.obj=dob.obj.gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/,'\1').
+ gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'\1').
+ gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,'\1 [link: <\2>]').
+ gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}image/,'\1 [link: local image]').
+ gsub(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,"#{the_text.url_open}\\1#{the_text.url_close}")
+ extract_endnotes(dob)
+ dob.obj=dob.obj.gsub(/#{Mx[:en_a_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_a_c]}/,'[^\1]'). # endnote marker marked up
+ gsub(/#{Mx[:en_b_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_b_c]}/,'[^\1]'). # endnote marker marked up
+ gsub(/#{Mx[:gl_o]}(?:#lt|#060)#{Mx[:gl_c]}/,'<').
+ gsub(/#{Mx[:gl_o]}(?:#gt|#062)#{Mx[:gl_c]}/,'>').
+ gsub(/#{Mx[:gl_o]}#(?:038|amp)#{Mx[:gl_c]}/,'&').
+ gsub(/#{Mx[:gl_o]}#033#{Mx[:gl_c]}/,'!').
+ gsub(/#{Mx[:gl_o]}#035#{Mx[:gl_c]}/,'#').
+ gsub(/#{Mx[:gl_o]}#042#{Mx[:gl_c]}/,'*').
+ gsub(/#{Mx[:gl_o]}#045#{Mx[:gl_c]}/,'-').
+ gsub(/#{Mx[:gl_o]}#047#{Mx[:gl_c]}/,'/').
+ gsub(/#{Mx[:gl_o]}#095#{Mx[:gl_c]}/,'_').
+ gsub(/#{Mx[:gl_o]}#123#{Mx[:gl_c]}/,'{').
+ gsub(/#{Mx[:gl_o]}#125#{Mx[:gl_c]}/,'}').
+ gsub(/#{Mx[:gl_o]}#126#{Mx[:gl_c]}/,'~').
+ gsub(/#{Mx[:gl_o]}#169#{Mx[:gl_c]}/,'©').
+ gsub(/#{Mx[:gl_o]}#092#{Mx[:gl_c]}/,'\\')
+ end
+ dob.obj=if dob.of==:block # watch
+ dob.obj.gsub(/#{Mx[:gl_o]}●#{Mx[:gl_c]}/m,"* ").
+ gsub(/\n?#{Mx[:br_line]}\n?|\n?#{Mx[:br_nl]}\n?/m,break_line)
+ else dob.obj.gsub(/\n?#{Mx[:br_line]}\n?|\n?#{Mx[:br_nl]}\n?/m,break_line*2)
+ end
+ if dob.is==:code
+ dob.obj=dob.obj.gsub(/(^|[^}])_([<>])/m,'\1\2'). # _> _<
+ gsub(/(^|[^}])_([<>])/m,'\1\2') # _<_<
+ end
+ dob.obj=dob.obj.gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'\1').
+ gsub(/<a href=".+?">(.+?)<\/a>/m,'\1').
+ gsub(/#{Mx[:mk_o]}:name#(\S+?)#{Mx[:mk_c]}/,''). # remove name links
+ gsub(/&nbsp;|#{Mx[:nbsp]}/,' '). # decide on
+ gsub(/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/,' [ \1 ]'). #"[ #{dir.url.images_local}\/\\1 ]")
+ gsub(/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}image/,' [ \1 ]').
+ gsub(/(?:^|[^_\\])\{\s*\S+?\.(?:png|jpg|gif)\s+.+?"(.*?)"\s*\}\S+/,'[image: "\1"]')
+ if dob.obj !~/(^#{Rx[:meta]}|#{Mx[:br_eof]}|#{Mx[:br_endnotes]})/
+ p_num=''
+ #ocn
+ if dob.is==:heading \
+ or dob.is==:para
+ plaintext_structure(dob,p_num)
+ elsif dob.is==:group \
+ or dob.is==:block \
+ or dob.is==:verse \
+ or dob.is==:code \
+ or dob.is==:table
+ @plaintext[:body] << dob.obj + p_num << break_line
+ elsif dob.is==:break
+ sp=' '
+ ln='<' #ln='-'
+ @plaintext[:body] <<=if dob.obj==Mx[:br_page] \
+ or dob.obj==Mx[:br_page_new] \
+ or dob.obj==Mx[:br_page_line]
+ "#{break_line}#{ln*40}#{break_line*2}"
+ elsif dob.obj ==Mx[:br_obj]
+ "#{break_line}#{sp*20}* * *#{break_line*2}"
+ end # following empty line (break_line) missing, fix
+ end
+ dob='' if (dob.obj =~/<a name="n\d+">/ \
+ and dob.obj =~/^(-\{{2}~\d+|<!e[:_]\d+!>)/) # -endnote
+ if dob ## Clean Prepared Text
+ dob.obj=dob.obj.gsub(/<!.+!>/,' ').
+ gsub(/<:\S+>/,' ')
+ end
+ end
+ end
+ @plaintext
+ end
+ def publish(plaintext)
+ divider='='
+ content=[]
+ content << plaintext[:open]
+ content << plaintext[:head]
+ content << plaintext[:body]
+ if @@endnotes_
+ content << '** Endnotes' << @@endnotes[:end]
+ end
+ content << plaintext[:metadata]
+ content << "#{break_line}#{divider*@wrap_width}#{break_line}" if @md.stmp =~/\w+/ #not used?
+ content << plaintext[:tail]
+ outputfile=SiSU_Env::FileOp.new(@md).write_file.orgmode
+ Txt_Output::Output.new.document(content,outputfile)
+ @@endnotes={ para: [], end: [] }
+ end
+ end
+ end
+end
+__END__
diff --git a/lib/sisu/current/txt_orgmode_decorate.rb b/lib/sisu/current/txt_orgmode_decorate.rb
new file mode 100644
index 0000000..6534247
--- /dev/null
+++ b/lib/sisu/current/txt_orgmode_decorate.rb
@@ -0,0 +1,186 @@
+# encoding: utf-8
+=begin
+
+* Name: SiSU
+
+** Description: documents, structuring, processing, publishing, search
+*** plaintext decoration
+
+** Author: Ralph Amissah
+ <ralph@amissah.com>
+ <ralph.amissah@gmail.com>
+
+** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
+ 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah,
+ All Rights Reserved.
+
+** License: GPL 3 or later:
+
+ SiSU, a framework for document structuring, publishing and search
+
+ Copyright (C) Ralph Amissah
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the Free
+ Software Foundation, either version 3 of the License, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ more details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program. If not, see <http://www.gnu.org/licenses/>.
+
+ If you have Internet connection, the latest version of the GPL should be
+ available at these locations:
+ <http://www.fsf.org/licensing/licenses/gpl.html>
+ <http://www.gnu.org/licenses/gpl.html>
+
+ <http://www.sisudoc.org/sisu/en/manifest/gpl.fsf.html>
+
+** SiSU uses:
+ * Standard SiSU markup syntax,
+ * Standard SiSU meta-markup syntax, and the
+ * Standard SiSU object citation numbering and system
+
+** Hompages:
+ <http://www.jus.uio.no/sisu>
+ <http://www.sisudoc.org>
+
+** Git
+ <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=summary>
+ <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=blob;f=lib/sisu/current/txt_orgmode_decorate.rb;hb=HEAD>
+
+=end
+
+module SiSU_Decorate_Txt_OrgMode
+ def decorate
+ def heading
+ def inline
+ def l0
+ '*'
+ end
+ def l1
+ '**'
+ end
+ def l2
+ '***'
+ end
+ def l3
+ '****'
+ end
+ def l4
+ '*****'
+ end
+ def l5
+ '******'
+ end
+ self
+ end
+ self
+ end
+ def bold
+ def open
+ '*'
+ end
+ def close
+ '*'
+ end
+ self
+ end
+ def italics
+ def open
+ '/'
+ end
+ def close
+ '/'
+ end
+ self
+ end
+ def underscore
+ def open
+ ''
+ end
+ def close
+ ''
+ end
+ self
+ end
+ #def emphasis
+ # def open
+ # ''
+ # end
+ # def close
+ # ''
+ # end
+ # self
+ #end
+ def cite
+ def open
+ '"'
+ end
+ def close
+ '"'
+ end
+ self
+ end
+ def insert
+ def open
+ ''
+ end
+ def close
+ ''
+ end
+ self
+ end
+ def strike
+ def open
+ '+'
+ end
+ def close
+ '+'
+ end
+ self
+ end
+ def superscript
+ def open
+ '^'
+ end
+ def close
+ '^'
+ end
+ self
+ end
+ def subscript
+ def open
+ '~'
+ end
+ def close
+ '~'
+ end
+ self
+ end
+ def hilite #bold
+ def open
+ '*'
+ end
+ def close
+ '*'
+ end
+ self
+ end
+ def monospace
+ def open
+ '~'
+ end
+ def close
+ '~'
+ end
+ self
+ end
+ self
+ end
+end
+__END__
diff --git a/lib/sisu/current/txt_output.rb b/lib/sisu/current/txt_output.rb
new file mode 100644
index 0000000..a025b54
--- /dev/null
+++ b/lib/sisu/current/txt_output.rb
@@ -0,0 +1,86 @@
+# encoding: utf-8
+=begin
+
+* Name: SiSU
+
+** Description: documents, structuring, processing, publishing, search
+*** plaintext
+
+** Author: Ralph Amissah
+ <ralph@amissah.com>
+ <ralph.amissah@gmail.com>
+
+** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
+ 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah,
+ All Rights Reserved.
+
+** License: GPL 3 or later:
+
+ SiSU, a framework for document structuring, publishing and search
+
+ Copyright (C) Ralph Amissah
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the Free
+ Software Foundation, either version 3 of the License, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ more details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program. If not, see <http://www.gnu.org/licenses/>.
+
+ If you have Internet connection, the latest version of the GPL should be
+ available at these locations:
+ <http://www.fsf.org/licensing/licenses/gpl.html>
+ <http://www.gnu.org/licenses/gpl.html>
+
+ <http://www.sisudoc.org/sisu/en/manifest/gpl.fsf.html>
+
+** SiSU uses:
+ * Standard SiSU markup syntax,
+ * Standard SiSU meta-markup syntax, and the
+ * Standard SiSU object citation numbering and system
+
+** Hompages:
+ <http://www.jus.uio.no/sisu>
+ <http://www.sisudoc.org>
+
+** Git
+ <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=summary>
+ <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=blob;f=lib/sisu/current/txt_output.rb;hb=HEAD>
+
+=end
+module Txt_Output
+ class Output
+ include SiSU_Param
+ include SiSU_Env
+ def document(content,outputfile)
+ emptyline=0
+ content.each do |para| # this is a hack
+ if para.is_a?(Array) \
+ and para.length > 0
+ para.each do |line|
+ if line
+ line=line.gsub(/[ \t]+$/m,'').
+ gsub(/^\A[ ]*\Z/m,'')
+ (line=~/^\A\Z/) \
+ ? (emptyline+=1)
+ : emptyline=0
+ if emptyline < 2 #remove additional empty lines
+ outputfile.puts line
+ end
+ end
+ end
+ else outputfile.puts para #unix plaintext # /^([*=-]|\.){5}/
+ end
+ end
+ outputfile.close
+ end
+ end
+end
+__END__
+
diff --git a/lib/sisu/current/txt_plain.rb b/lib/sisu/current/txt_plain.rb
index 0edd655..5e8ff66 100644
--- a/lib/sisu/current/txt_plain.rb
+++ b/lib/sisu/current/txt_plain.rb
@@ -51,7 +51,7 @@
** Git
<http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=summary>
- <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=blob;f=lib/sisu/current/plaintext.rb;hb=HEAD>
+ <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=blob;f=lib/sisu/current/txt.rb;hb=HEAD>
=end
module SiSU_Txt_Plain
@@ -60,11 +60,15 @@ module SiSU_Txt_Plain
include SiSU_Env
require_relative 'shared_metadata' # shared_metadata.rb
require_relative 'generic_parts' # generic_parts.rb
+ require_relative 'txt_read' # txt_read.rb
require_relative 'txt_shared' # txt_shared.rb
+ require_relative 'txt_plain_decorate' # txt_plain_decorate.rb
+ require_relative 'txt_output' # txt_output.rb
include SiSU_Param
- @@alt_id_count,@@alt_id_count,@@tablehead,@@number_of_cols=0,0,0,0
+ @@alt_id_count,@@alt_id_count=0,0
@@tablefoot=''
class Source
+ include SiSU_Txt_Read
def initialize(opt)
@opt=opt
unless @opt.fns =~/(.+?)\.(?:-|ssm\.)?sst$/
@@ -74,46 +78,13 @@ module SiSU_Txt_Plain
def read
begin
md=SiSU_Param::Parameters.new(@opt).get
- env=SiSU_Env::InfoEnv.new(@opt.fns)
- unless @opt.act[:quiet][:set]==:on
- tool=(@opt.act[:verbose][:set]==:on \
- || @opt.act[:verbose_plus][:set]==:on \
- || @opt.act[:maintenance][:set]==:on) \
- ? "#{env.program.text_editor} #{md.file.output_path.txt.dir}/#{md.file.base_filename.txt}"
- : "[#{@opt.f_pth[:lng_is]}] #{@opt.fno}"
- (@opt.act[:verbose][:set]==:on \
- || @opt.act[:verbose_plus][:set]==:on \
- || @opt.act[:maintenance][:set]==:on) \
- ? SiSU_Screen::Ansi.new(
- @opt.act[:color_state][:set],
- 'Plaintext',
- tool
- ).green_hi_blue
- : SiSU_Screen::Ansi.new(
- @opt.act[:color_state][:set],
- 'Plaintext',
- tool
- ).green_title_hi
- if (@opt.act[:verbose_plus][:set]==:on \
- || @opt.act[:maintenance][:set]==:on)
- SiSU_Screen::Ansi.new(
- @opt.act[:color_state][:set],
- @opt.fns,
- "#{md.file.output_path.txt.dir}/#{md.file.base_filename.txt}"
- ).flow
- end
- end
- ao_array=SiSU_AO::Source.new(@opt).get # ao file drawn here
- wrap_width=if defined? md.make.plaintext_wrap \
- and md.make.plaintext_wrap
- md.make.plaintext_wrap
- elsif defined? env.plaintext_wrap \
- and env.plaintext_wrap
- env.plaintext_wrap
- else 78
- end
- #wrap_width=(defined? md.make.plaintext_wrap) ? md.make.plaintext_wrap : 78
- SiSU_Txt_Plain::Source::Scroll.new(md,ao_array,wrap_width).songsheet
+ specific={
+ description: 'Plaintext (utf-8)',
+ output_path: md.file.output_path.txt.dir,
+ output_file: md.file.base_filename.txt,
+ }
+ read_generic(@opt,specific)
+ SiSU_Txt_Plain::Source::Scroll.new(md,@ao_array,@wrap_width).songsheet
rescue
SiSU_Errors::Rescued.new($!,$@,@opt.selections.str,@opt.fns).location do
__LINE__.to_s + ':' + __FILE__
@@ -125,6 +96,7 @@ module SiSU_Txt_Plain
class Scroll <Source
include SiSU_Parts_Generic
include SiSU_TextUtils
+ include SiSU_Decorate_Txt_Plain
@@endnotes={ para: [], end: [] }
def initialize(md,data,wrap_width)
@md,@data,@wrap_width=md,data,wrap_width
@@ -133,7 +105,7 @@ module SiSU_Txt_Plain
@@endnotes_=case md.opt.selections.str
when /--footnote/ then false
when /--endnote/ then true
- else true
+ else true
end
@plaintext={ body: [], open: [], close: [], head: [], metadata: [], tail: [] }
end
@@ -197,7 +169,7 @@ WOK
end
def plaintext_tail
# env=SiSU_Env::InfoEnv.new(@md.fns)
- generator="Generated by: #{@md.sisu_version[:project]} #{@md.sisu_version[:version]} of #{@md.sisu_version[:date_stamp]} (#{@md.sisu_version[:date]})" if @md.sisu_version[:version]
+ generator="Generated by: #{@md.project_details.project} #{@md.project_details.version} of #{@md.project_details.date_stamp} (#{@md.project_details.date})" if @md.project_details.version
lastdone="Last Generated on: #{Time.now}"
rubyv="Ruby version: #{@md.ruby_version}"
sc=if @md.sc_info
@@ -221,135 +193,6 @@ at:
* SiSU #{the_url.sisu_txt}
WOK
end
- def decorate
- def heading_underscore
- def l0
- '='
- end
- def l1
- '*'
- end
- def l2
- '+'
- end
- def l3
- '~'
- end
- def l4
- '-'
- end
- def l5
- '.'
- end
- def l6
- '.'
- end
- def l7
- '.'
- end
- self
- end
- def bold
- def open
- '*'
- end
- def close
- '*'
- end
- self
- end
- def italics
- def open
- '/'
- end
- def close
- '/'
- end
- self
- end
- def underscore
- def open
- '_'
- end
- def close
- '_'
- end
- self
- end
- #def emphasis
- # def open
- # ''
- # end
- # def close
- # ''
- # end
- # self
- #end
- def cite
- def open
- '"'
- end
- def close
- '"'
- end
- self
- end
- def insert
- def open
- '+'
- end
- def close
- '+'
- end
- self
- end
- def strike
- def open
- '-'
- end
- def close
- '-'
- end
- self
- end
- def superscript
- def open
- '^'
- end
- def close
- '^'
- end
- self
- end
- def subscript
- def open
- '['
- end
- def close
- ']'
- end
- self
- end
- def hilite
- def open
- '*'
- end
- def close
- '*'
- end
- self
- end
- def monospace
- def open
- '#'
- end
- def close
- '#'
- end
- self
- end
- self
- end
def plaintext_structure(dob='',p_num='') #% Used to extract the structure of a document
lv=n=n3=nil
if dob.is==:heading
@@ -535,41 +378,11 @@ WOK
content << plaintext[:metadata]
content << "#{break_line}#{divider*@wrap_width}#{break_line}" if @md.stmp =~/\w+/ #not used?
content << plaintext[:tail]
- Output.new(content,@md).plaintext
+ outputfile=SiSU_Env::FileOp.new(@md).write_file.txt
+ Txt_Output::Output.new.document(content,outputfile)
@@endnotes={ para: [], end: [] }
end
end
- class Output <Source
- include SiSU_Param
- include SiSU_Env
- def initialize(content,md)
- @content,@md=content,md
- end
- def plaintext #%plaintext output
- file_plaintext=SiSU_Env::FileOp.new(@md).write_file.txt
- @sisu=[]
- emptyline=0
- @content.each do |para| # this is a hack
- if para.is_a?(Array) \
- and para.length > 0
- para.each do |line|
- if line
- line=line.gsub(/[ \t]+$/m,'').
- gsub(/^\A[ ]*\Z/m,'')
- (line=~/^\A\Z/) \
- ? (emptyline+=1)
- : emptyline=0
- if emptyline < 2 #remove additional empty lines
- file_plaintext.puts line
- end
- end
- end
- else file_plaintext.puts para #unix plaintext # /^([*=-]|\.){5}/
- end
- end
- file_plaintext.close
- end
- end
end
end
__END__
@@ -585,13 +398,13 @@ __END__
subscript_o: '[', subscript_c: ']',
hilite_o: '*', hilite_c: '*',
monospace_o: '', monospace_c: '',
- po_bold_o: '!{', po_bold_c: '}!',
- po_italics_o: '/{', po_italics_c: '}/',
- po_underscore_o: '_{', po_underscore_c: '}_',
- po_cite_o: '"{', po_cite_c: '}"',
- po_insert_o: '+{', po_insert_c: '}+',
- po_strike_o: '-{', po_strike_c: '}-',
- po_superscript_o: '^{', po_superscript_c: '}^',
- po_subscript_o: ',{', po_subscript_c: '},',
- po_hilite_o: '*{', po_hilite_c: '}*',
- po_monospace_o: '#{', po_monospace_c: '}#',
+ p_bold_o: '!{', p_bold_c: '}!',
+ p_italics_o: '/{', p_italics_c: '}/',
+ p_underscore_o: '_{', p_underscore_c: '}_',
+ p_cite_o: '"{', p_cite_c: '}"',
+ p_insert_o: '+{', p_insert_c: '}+',
+ p_strike_o: '-{', p_strike_c: '}-',
+ p_superscript_o: '^{', p_superscript_c: '}^',
+ p_subscript_o: ',{', p_subscript_c: '},',
+ p_hilite_o: '*{', p_hilite_c: '}*',
+ p_monospace_o: '#{', p_monospace_c: '}#',
diff --git a/lib/sisu/current/txt_plain_decorate.rb b/lib/sisu/current/txt_plain_decorate.rb
new file mode 100644
index 0000000..f4ee82e
--- /dev/null
+++ b/lib/sisu/current/txt_plain_decorate.rb
@@ -0,0 +1,189 @@
+# encoding: utf-8
+=begin
+
+* Name: SiSU
+
+** Description: documents, structuring, processing, publishing, search
+*** plaintext decoration
+
+** Author: Ralph Amissah
+ <ralph@amissah.com>
+ <ralph.amissah@gmail.com>
+
+** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
+ 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah,
+ All Rights Reserved.
+
+** License: GPL 3 or later:
+
+ SiSU, a framework for document structuring, publishing and search
+
+ Copyright (C) Ralph Amissah
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the Free
+ Software Foundation, either version 3 of the License, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ more details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program. If not, see <http://www.gnu.org/licenses/>.
+
+ If you have Internet connection, the latest version of the GPL should be
+ available at these locations:
+ <http://www.fsf.org/licensing/licenses/gpl.html>
+ <http://www.gnu.org/licenses/gpl.html>
+
+ <http://www.sisudoc.org/sisu/en/manifest/gpl.fsf.html>
+
+** SiSU uses:
+ * Standard SiSU markup syntax,
+ * Standard SiSU meta-markup syntax, and the
+ * Standard SiSU object citation numbering and system
+
+** Hompages:
+ <http://www.jus.uio.no/sisu>
+ <http://www.sisudoc.org>
+
+** Git
+ <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=summary>
+ <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=blob;f=lib/sisu/current/txt_plain_decorate.rb;hb=HEAD>
+
+=end
+
+module SiSU_Decorate_Txt_Plain
+ def decorate
+ def heading_underscore
+ def l0
+ '='
+ end
+ def l1
+ '*'
+ end
+ def l2
+ '+'
+ end
+ def l3
+ '~'
+ end
+ def l4
+ '-'
+ end
+ def l5
+ '.'
+ end
+ def l6
+ '.'
+ end
+ def l7
+ '.'
+ end
+ self
+ end
+ def bold
+ def open
+ '*'
+ end
+ def close
+ '*'
+ end
+ self
+ end
+ def italics
+ def open
+ '/'
+ end
+ def close
+ '/'
+ end
+ self
+ end
+ def underscore
+ def open
+ '_'
+ end
+ def close
+ '_'
+ end
+ self
+ end
+ #def emphasis
+ # def open
+ # ''
+ # end
+ # def close
+ # ''
+ # end
+ # self
+ #end
+ def cite
+ def open
+ '"'
+ end
+ def close
+ '"'
+ end
+ self
+ end
+ def insert
+ def open
+ '+'
+ end
+ def close
+ '+'
+ end
+ self
+ end
+ def strike
+ def open
+ '-'
+ end
+ def close
+ '-'
+ end
+ self
+ end
+ def superscript
+ def open
+ '^'
+ end
+ def close
+ '^'
+ end
+ self
+ end
+ def subscript
+ def open
+ '['
+ end
+ def close
+ ']'
+ end
+ self
+ end
+ def hilite
+ def open
+ '*'
+ end
+ def close
+ '*'
+ end
+ self
+ end
+ def monospace
+ def open
+ '#'
+ end
+ def close
+ '#'
+ end
+ self
+ end
+ self
+ end
+end
+__END__
diff --git a/lib/sisu/current/txt_read.rb b/lib/sisu/current/txt_read.rb
new file mode 100644
index 0000000..0e2ce0f
--- /dev/null
+++ b/lib/sisu/current/txt_read.rb
@@ -0,0 +1,109 @@
+# encoding: utf-8
+=begin
+
+* Name: SiSU
+
+** Description: documents, structuring, processing, publishing, search
+*** plaintext
+
+** Author: Ralph Amissah
+ <ralph@amissah.com>
+ <ralph.amissah@gmail.com>
+
+** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
+ 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah,
+ All Rights Reserved.
+
+** License: GPL 3 or later:
+
+ SiSU, a framework for document structuring, publishing and search
+
+ Copyright (C) Ralph Amissah
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the Free
+ Software Foundation, either version 3 of the License, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ more details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program. If not, see <http://www.gnu.org/licenses/>.
+
+ If you have Internet connection, the latest version of the GPL should be
+ available at these locations:
+ <http://www.fsf.org/licensing/licenses/gpl.html>
+ <http://www.gnu.org/licenses/gpl.html>
+
+ <http://www.sisudoc.org/sisu/en/manifest/gpl.fsf.html>
+
+** SiSU uses:
+ * Standard SiSU markup syntax,
+ * Standard SiSU meta-markup syntax, and the
+ * Standard SiSU object citation numbering and system
+
+** Hompages:
+ <http://www.jus.uio.no/sisu>
+ <http://www.sisudoc.org>
+
+** Git
+ <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=summary>
+ <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=blob;f=lib/sisu/current/txt_read.rb;hb=HEAD>
+
+=end
+module SiSU_Txt_Read
+ require_relative 'se' # se.rb
+ include SiSU_Env
+ def read_generic(opt,specific)
+ begin
+ env=SiSU_Env::InfoEnv.new(opt.fns)
+ unless opt.act[:quiet][:set]==:on
+ tool=(opt.act[:verbose][:set]==:on \
+ || opt.act[:verbose_plus][:set]==:on \
+ || opt.act[:maintenance][:set]==:on) \
+ ? "#{env.program.text_editor} #{specific[:output_path]}/#{specific[:output_file]}"
+ : "[#{opt.f_pth[:lng_is]}] #{opt.fno}"
+ (opt.act[:verbose][:set]==:on \
+ || opt.act[:verbose_plus][:set]==:on \
+ || opt.act[:maintenance][:set]==:on) \
+ ? SiSU_Screen::Ansi.new(
+ opt.act[:color_state][:set],
+ specific[:description],
+ tool
+ ).green_hi_blue
+ : SiSU_Screen::Ansi.new(
+ opt.act[:color_state][:set],
+ specific[:description],
+ tool
+ ).green_title_hi
+ if (opt.act[:verbose_plus][:set]==:on \
+ || opt.act[:maintenance][:set]==:on)
+ SiSU_Screen::Ansi.new(
+ opt.act[:color_state][:set],
+ opt.fns,
+ "#{specific[:output_path]}/#{specific[:output_file]}"
+ ).flow
+ end
+ end
+ @ao_array=SiSU_AO::Source.new(opt).get # ao file drawn here
+ @wrap_width=if defined? md.make.plaintext_wrap \
+ and md.make.plaintext_wrap
+ md.make.plaintext_wrap
+ elsif defined? env.plaintext_wrap \
+ and env.plaintext_wrap
+ env.plaintext_wrap
+ else 78
+ end
+ #wrap_width=(defined? md.make.plaintext_wrap) ? md.make.plaintext_wrap : 78
+ rescue
+ SiSU_Errors::Rescued.new($!,$@,opt.selections.str,opt.fns).location do
+ __LINE__.to_s + ':' + __FILE__
+ end
+ ensure
+ end
+ end
+end
+
diff --git a/lib/sisu/current/txt_rst.rb b/lib/sisu/current/txt_rst.rb
index 238c0bb..969cb1c 100644
--- a/lib/sisu/current/txt_rst.rb
+++ b/lib/sisu/current/txt_rst.rb
@@ -51,7 +51,7 @@
** Git
<http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=summary>
- <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=blob;f=lib/sisu/current/plaintext_rst.rb;hb=HEAD>
+ <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=blob;f=lib/sisu/current/txt_rst.rb;hb=HEAD>
=end
module SiSU_Txt_rST
@@ -60,11 +60,15 @@ module SiSU_Txt_rST
include SiSU_Env
require_relative 'shared_metadata' # shared_metadata.rb
require_relative 'generic_parts' # generic_parts.rb
+ require_relative 'txt_read' # txt_read.rb
require_relative 'txt_shared' # txt_shared.rb
+ require_relative 'txt_rst_decorate' # txt_rst_decorate.rb
+ require_relative 'txt_output' # txt_output.rb
include SiSU_Param
- @@alt_id_count,@@alt_id_count,@@tablehead,@@number_of_cols=0,0,0,0
+ @@alt_id_count,@@alt_id_count=0,0
@@tablefoot=''
class Source
+ include SiSU_Txt_Read
def initialize(opt)
@opt=opt
unless @opt.fns =~/(.+?)\.(?:-|ssm\.)?sst$/
@@ -74,46 +78,13 @@ module SiSU_Txt_rST
def read
begin
md=SiSU_Param::Parameters.new(@opt).get
- env=SiSU_Env::InfoEnv.new(@opt.fns)
- unless @opt.act[:quiet][:set]==:on
- tool=(@opt.act[:verbose][:set]==:on \
- || @opt.act[:verbose_plus][:set]==:on \
- || @opt.act[:maintenance][:set]==:on) \
- ? "#{env.program.text_editor} #{md.file.output_path.rst.dir}/#{md.file.base_filename.rst}"
- : "[#{@opt.f_pth[:lng_is]}] #{@opt.fno}"
- (@opt.act[:verbose][:set]==:on \
- || @opt.act[:verbose_plus][:set]==:on \
- || @opt.act[:maintenance][:set]==:on) \
- ? SiSU_Screen::Ansi.new(
- @opt.act[:color_state][:set],
- 'rST (plaintext utf-8)',
- tool
- ).green_hi_blue
- : SiSU_Screen::Ansi.new(
- @opt.act[:color_state][:set],
- 'rST (plaintext utf-8)',
- tool
- ).green_title_hi
- if (@opt.act[:verbose_plus][:set]==:on \
- || @opt.act[:maintenance][:set]==:on)
- SiSU_Screen::Ansi.new(
- @opt.act[:color_state][:set],
- @opt.fns,
- "#{md.file.output_path.rst.dir}/#{md.file.base_filename.rst}"
- ).flow
- end
- end
- ao_array=SiSU_AO::Source.new(@opt).get # ao file drawn here
- wrap_width=if defined? md.make.plaintext_wrap \
- and md.make.plaintext_wrap
- md.make.plaintext_wrap
- elsif defined? env.plaintext_wrap \
- and env.plaintext_wrap
- env.plaintext_wrap
- else 78
- end
- #wrap_width=(defined? md.make.plaintext_wrap) ? md.make.plaintext_wrap : 78
- SiSU_Txt_rST::Source::Scroll.new(md,ao_array,wrap_width).songsheet
+ specific={
+ description: 'rST (plaintext utf-8)',
+ output_path: md.file.output_path.rst.dir,
+ output_file: md.file.base_filename.rst,
+ }
+ read_generic(@opt,specific)
+ SiSU_Txt_rST::Source::Scroll.new(md,@ao_array,@wrap_width).songsheet
rescue
SiSU_Errors::Rescued.new($!,$@,@opt.selections.str,@opt.fns).location do
__LINE__.to_s + ':' + __FILE__
@@ -125,6 +96,7 @@ module SiSU_Txt_rST
class Scroll <Source
include SiSU_Parts_Generic
include SiSU_TextUtils
+ include SiSU_Decorate_Txt_rST
@@endnotes={ para: [], end: [] }
def initialize(md,data,wrap_width)
@md,@data,@wrap_width=md,data,wrap_width
@@ -197,7 +169,7 @@ WOK
end
def plaintext_tail
# env=SiSU_Env::InfoEnv.new(@md.fns)
- generator="Generated by: #{@md.sisu_version[:project]} #{@md.sisu_version[:version]} of #{@md.sisu_version[:date_stamp]} (#{@md.sisu_version[:date]})" if @md.sisu_version[:version]
+ generator="Generated by: #{@md.project_details.project} #{@md.project_details.version} of #{@md.project_details.date_stamp} (#{@md.project_details.date})" if @md.project_details.version
lastdone="Last Generated on: #{Time.now}"
rubyv="Ruby version: #{@md.ruby_version}"
sc=if @md.sc_info
@@ -221,132 +193,6 @@ at:
* SiSU #{the_url.sisu_txt}
WOK
end
- def decorate
- def heading
- def underscore
- def l0
- '='
- end
- def l1
- '-'
- end
- def l2
- '`'
- end
- def l3
- ':'
- end
- def l4
- "'"
- end
- def l5
- '"'
- end
- self
- end
- self
- end
- def bold
- def open
- '*'
- end
- def close
- '*'
- end
- self
- end
- def italics
- def open
- '/'
- end
- def close
- '/'
- end
- self
- end
- def underscore
- def open
- '_'
- end
- def close
- '_'
- end
- self
- end
- #def emphasis
- # def open
- # ''
- # end
- # def close
- # ''
- # end
- # self
- #end
- def cite
- def open
- '"'
- end
- def close
- '"'
- end
- self
- end
- def insert
- def open
- '+'
- end
- def close
- '+'
- end
- self
- end
- def strike
- def open
- '-'
- end
- def close
- '-'
- end
- self
- end
- def superscript
- def open
- '^'
- end
- def close
- '^'
- end
- self
- end
- def subscript
- def open
- '['
- end
- def close
- ']'
- end
- self
- end
- def hilite
- def open
- '*'
- end
- def close
- '*'
- end
- self
- end
- def monospace
- def open
- '#'
- end
- def close
- '#'
- end
- self
- end
- self
- end
def heading_decorated_underscore(dob,times,p_num)
if dob.is==:heading
#times=@wrap_width if times > @wrap_width
@@ -515,41 +361,11 @@ WOK
content << plaintext[:metadata]
content << "#{break_line}#{divider*@wrap_width}#{break_line}" if @md.stmp =~/\w+/ #not used?
content << plaintext[:tail]
- Output.new(content,@md).rst
+ outputfile=SiSU_Env::FileOp.new(@md).write_file.rst
+ Txt_Output::Output.new.document(content,outputfile)
@@endnotes={ para: [], end: [] }
end
end
- class Output <Source
- include SiSU_Param
- include SiSU_Env
- def initialize(content,md)
- @content,@md=content,md
- end
- def rst
- file_plaintext=SiSU_Env::FileOp.new(@md).write_file.rst
- @sisu=[]
- emptyline=0
- @content.each do |para| # this is a hack
- if para.is_a?(Array) \
- and para.length > 0
- para.each do |line|
- if line
- line=line.gsub(/[ \t]+$/m,'').
- gsub(/^\A[ ]*\Z/m,'')
- (line=~/^\A\Z/) \
- ? (emptyline+=1)
- : emptyline=0
- if emptyline < 2 #remove additional empty lines
- file_plaintext.puts line
- end
- end
- end
- else file_plaintext.puts para #unix plaintext # /^([*=-]|\.){5}/
- end
- end
- file_plaintext.close
- end
- end
end
end
__END__
diff --git a/lib/sisu/current/txt_rst_decorate.rb b/lib/sisu/current/txt_rst_decorate.rb
new file mode 100644
index 0000000..2898ba1
--- /dev/null
+++ b/lib/sisu/current/txt_rst_decorate.rb
@@ -0,0 +1,186 @@
+# encoding: utf-8
+=begin
+
+* Name: SiSU
+
+** Description: documents, structuring, processing, publishing, search
+*** plaintext decoration
+
+** Author: Ralph Amissah
+ <ralph@amissah.com>
+ <ralph.amissah@gmail.com>
+
+** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
+ 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah,
+ All Rights Reserved.
+
+** License: GPL 3 or later:
+
+ SiSU, a framework for document structuring, publishing and search
+
+ Copyright (C) Ralph Amissah
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the Free
+ Software Foundation, either version 3 of the License, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ more details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program. If not, see <http://www.gnu.org/licenses/>.
+
+ If you have Internet connection, the latest version of the GPL should be
+ available at these locations:
+ <http://www.fsf.org/licensing/licenses/gpl.html>
+ <http://www.gnu.org/licenses/gpl.html>
+
+ <http://www.sisudoc.org/sisu/en/manifest/gpl.fsf.html>
+
+** SiSU uses:
+ * Standard SiSU markup syntax,
+ * Standard SiSU meta-markup syntax, and the
+ * Standard SiSU object citation numbering and system
+
+** Hompages:
+ <http://www.jus.uio.no/sisu>
+ <http://www.sisudoc.org>
+
+** Git
+ <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=summary>
+ <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=blob;f=lib/sisu/current/txt_rst_decorate.rb;hb=HEAD>
+
+=end
+
+module SiSU_Decorate_Txt_rST
+ def decorate
+ def heading
+ def underscore
+ def l0
+ '='
+ end
+ def l1
+ '-'
+ end
+ def l2
+ '`'
+ end
+ def l3
+ ':'
+ end
+ def l4
+ "'"
+ end
+ def l5
+ '"'
+ end
+ self
+ end
+ self
+ end
+ def bold
+ def open
+ '*'
+ end
+ def close
+ '*'
+ end
+ self
+ end
+ def italics
+ def open
+ '/'
+ end
+ def close
+ '/'
+ end
+ self
+ end
+ def underscore
+ def open
+ '_'
+ end
+ def close
+ '_'
+ end
+ self
+ end
+ #def emphasis
+ # def open
+ # ''
+ # end
+ # def close
+ # ''
+ # end
+ # self
+ #end
+ def cite
+ def open
+ '"'
+ end
+ def close
+ '"'
+ end
+ self
+ end
+ def insert
+ def open
+ '+'
+ end
+ def close
+ '+'
+ end
+ self
+ end
+ def strike
+ def open
+ '-'
+ end
+ def close
+ '-'
+ end
+ self
+ end
+ def superscript
+ def open
+ '^'
+ end
+ def close
+ '^'
+ end
+ self
+ end
+ def subscript
+ def open
+ '['
+ end
+ def close
+ ']'
+ end
+ self
+ end
+ def hilite
+ def open
+ '*'
+ end
+ def close
+ '*'
+ end
+ self
+ end
+ def monospace
+ def open
+ '#'
+ end
+ def close
+ '#'
+ end
+ self
+ end
+ self
+ end
+end
+__END__
diff --git a/lib/sisu/current/txt_textile.rb b/lib/sisu/current/txt_textile.rb
index 86187a3..3ff3fe1 100644
--- a/lib/sisu/current/txt_textile.rb
+++ b/lib/sisu/current/txt_textile.rb
@@ -51,7 +51,7 @@
** Git
<http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=summary>
- <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=blob;f=lib/sisu/current/plaintext_textile.rb;hb=HEAD>
+ <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=blob;f=lib/sisu/current/txt_textile.rb;hb=HEAD>
=end
module SiSU_Txt_Textile
@@ -60,12 +60,16 @@ module SiSU_Txt_Textile
include SiSU_Env
require_relative 'shared_metadata' # shared_metadata.rb
require_relative 'generic_parts' # generic_parts.rb
+ require_relative 'txt_read' # txt_read.rb
require_relative 'txt_shared' # txt_shared.rb
+ require_relative 'txt_textile_decorate' # txt_textile_decorate.rb
+ require_relative 'txt_output' # txt_output.rb
include SiSU_Param
- @@alt_id_count,@@alt_id_count,@@tablehead,@@number_of_cols=0,0,0,0
+ @@alt_id_count,@@alt_id_count=0,0
@@tablefoot=''
class Source
- include SiSU_Parts_Generic
+ include SiSU_Txt_Read
+ #include SiSU_Parts_Generic
def initialize(opt)
@opt=opt
unless @opt.fns =~/(.+?)\.(?:-|ssm\.)?sst$/
@@ -75,46 +79,13 @@ module SiSU_Txt_Textile
def read
begin
md=SiSU_Param::Parameters.new(@opt).get
- env=SiSU_Env::InfoEnv.new(@opt.fns)
- unless @opt.act[:quiet][:set]==:on
- tool=(@opt.act[:verbose][:set]==:on \
- || @opt.act[:verbose_plus][:set]==:on \
- || @opt.act[:maintenance][:set]==:on) \
- ? "#{env.program.text_editor} #{md.file.output_path.textile.dir}/#{md.file.base_filename.textile}"
- : "[#{@opt.f_pth[:lng_is]}] #{@opt.fno}"
- (@opt.act[:verbose][:set]==:on \
- || @opt.act[:verbose_plus][:set]==:on \
- || @opt.act[:maintenance][:set]==:on) \
- ? SiSU_Screen::Ansi.new(
- @opt.act[:color_state][:set],
- 'Textile (plaintext utf-8)',
- tool
- ).green_hi_blue
- : SiSU_Screen::Ansi.new(
- @opt.act[:color_state][:set],
- 'Textile (plaintext utf-8)',
- tool
- ).green_title_hi
- if (@opt.act[:verbose_plus][:set]==:on \
- || @opt.act[:maintenance][:set]==:on)
- SiSU_Screen::Ansi.new(
- @opt.act[:color_state][:set],
- @opt.fns,
- "#{md.file.output_path.textile.dir}/#{md.file.base_filename.textile}"
- ).flow
- end
- end
- ao_array=SiSU_AO::Source.new(@opt).get # ao file drawn here
- wrap_width=if defined? md.make.plaintext_wrap \
- and md.make.plaintext_wrap
- md.make.plaintext_wrap
- elsif defined? env.plaintext_wrap \
- and env.plaintext_wrap
- env.plaintext_wrap
- else 78
- end
- #wrap_width=(defined? md.make.plaintext_wrap) ? md.make.plaintext_wrap : 78
- SiSU_Txt_Textile::Source::Scroll.new(md,ao_array,wrap_width).songsheet
+ specific={
+ description: 'Textile (plaintext utf-8)',
+ output_path: md.file.output_path.textile.dir,
+ output_file: md.file.base_filename.textile,
+ }
+ read_generic(@opt,specific)
+ SiSU_Txt_Textile::Source::Scroll.new(md,@ao_array,@wrap_width).songsheet
rescue
SiSU_Errors::Rescued.new($!,$@,@opt.selections.str,@opt.fns).location do
__LINE__.to_s + ':' + __FILE__
@@ -126,6 +97,7 @@ module SiSU_Txt_Textile
class Scroll <Source
include SiSU_Parts_Generic
include SiSU_TextUtils
+ include SiSU_Decorate_Txt_Textile
@@endnotes={ para: [], end: [] }
def initialize(md,data,wrap_width)
@md,@data,@wrap_width=md,data,wrap_width
@@ -198,7 +170,7 @@ WOK
end
def plaintext_tail
# env=SiSU_Env::InfoEnv.new(@md.fns)
- generator="Generated by: #{@md.sisu_version[:project]} #{@md.sisu_version[:version]} of #{@md.sisu_version[:date_stamp]} (#{@md.sisu_version[:date]})" if @md.sisu_version[:version]
+ generator="Generated by: #{@md.project_details.project} #{@md.project_details.version} of #{@md.project_details.date_stamp} (#{@md.project_details.date})" if @md.project_details.version
lastdone="Last Generated on: #{Time.now}"
rubyv="Ruby version: #{@md.ruby_version}"
sc=if @md.sc_info
@@ -222,143 +194,19 @@ at:
* SiSU #{the_url.sisu_txt}
WOK
end
- def decorate
- def heading
- def inline
- def l0
- 'h1. '
- end
- def l1
- 'h2. '
- end
- def l2
- 'h3. '
- end
- def l3
- 'h4. '
- end
- def l4
- 'h5. '
- end
- def l5
- 'h6. '
- end
- self
- end
- self
- end
- def bold
- def open
- '*'
- end
- def close
- '*'
- end
- self
- end
- def italics
- def open
- '_'
- end
- def close
- '_'
- end
- self
- end
- def underscore
- def open
- '+'
- end
- def close
- '+'
- end
- self
- end
- #def emphasis
- # def open
- # ''
- # end
- # def close
- # ''
- # end
- # self
- #end
- def cite
- def open
- '"'
- end
- def close
- '"'
- end
- self
- end
- def insert
- def open
- ''
- end
- def close
- ''
- end
- self
- end
- def strike
- def open
- '-'
- end
- def close
- '-'
- end
- self
- end
- def superscript
- def open
- '^'
- end
- def close
- '^'
- end
- self
- end
- def subscript
- def open
- '~'
- end
- def close
- '~'
- end
- self
- end
- def hilite
- def open
- '*'
- end
- def close
- '*'
- end
- self
- end
- def monospace
- def open
- ''
- end
- def close
- ''
- end
- self
- end
- self
- end
def heading_decorated_inline(dob)
- heading_inline = case dob.lc
- when 0 then decorate.heading.inline.l0
- when 1 then decorate.heading.inline.l1
- when 2 then decorate.heading.inline.l2
- when 3 then decorate.heading.inline.l3
- when 4 then decorate.heading.inline.l4
- when 5 then decorate.heading.inline.l5
- when 6 then decorate.heading.inline.l6
+ if dob.is==:heading
+ heading_inline = case dob.lc
+ when 0 then decorate.heading.inline.l0
+ when 1 then decorate.heading.inline.l1
+ when 2 then decorate.heading.inline.l2
+ when 3 then decorate.heading.inline.l3
+ when 4 then decorate.heading.inline.l4
+ when 5 then decorate.heading.inline.l5
+ when 6 then decorate.heading.inline.l6
+ end
+ heading_inline + ' ' + dob.obj
end
- heading_inline + ' ' + dob.obj
end
def plaintext_structure(dob='',p_num='') #% Used to extract the structure of a document
util=nil
@@ -509,41 +357,11 @@ WOK
content << plaintext[:metadata]
content << "#{break_line}#{divider*@wrap_width}#{break_line}" if @md.stmp =~/\w+/ #not used?
content << plaintext[:tail]
- Output.new(content,@md).textile
+ outputfile=SiSU_Env::FileOp.new(@md).write_file.textile
+ Txt_Output::Output.new.document(content,outputfile)
@@endnotes={ para: [], end: [] }
end
end
- class Output <Source
- include SiSU_Param
- include SiSU_Env
- def initialize(content,md)
- @content,@md=content,md
- end
- def textile
- file_plaintext=SiSU_Env::FileOp.new(@md).write_file.textile
- @sisu=[]
- emptyline=0
- @content.each do |para| # this is a hack
- if para.is_a?(Array) \
- and para.length > 0
- para.each do |line|
- if line
- line=line.gsub(/[ \t]+$/m,'').
- gsub(/^\A[ ]*\Z/m,'')
- (line=~/^\A\Z/) \
- ? (emptyline+=1)
- : emptyline=0
- if emptyline < 2 #remove additional empty lines
- file_plaintext.puts line
- end
- end
- end
- else file_plaintext.puts para #unix plaintext # /^([*=-]|\.){5}/
- end
- end
- file_plaintext.close
- end
- end
end
end
__END__
diff --git a/lib/sisu/current/txt_textile_decorate.rb b/lib/sisu/current/txt_textile_decorate.rb
new file mode 100644
index 0000000..7e338e2
--- /dev/null
+++ b/lib/sisu/current/txt_textile_decorate.rb
@@ -0,0 +1,186 @@
+# encoding: utf-8
+=begin
+
+* Name: SiSU
+
+** Description: documents, structuring, processing, publishing, search
+*** plaintext decoration
+
+** Author: Ralph Amissah
+ <ralph@amissah.com>
+ <ralph.amissah@gmail.com>
+
+** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
+ 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah,
+ All Rights Reserved.
+
+** License: GPL 3 or later:
+
+ SiSU, a framework for document structuring, publishing and search
+
+ Copyright (C) Ralph Amissah
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the Free
+ Software Foundation, either version 3 of the License, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ more details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program. If not, see <http://www.gnu.org/licenses/>.
+
+ If you have Internet connection, the latest version of the GPL should be
+ available at these locations:
+ <http://www.fsf.org/licensing/licenses/gpl.html>
+ <http://www.gnu.org/licenses/gpl.html>
+
+ <http://www.sisudoc.org/sisu/en/manifest/gpl.fsf.html>
+
+** SiSU uses:
+ * Standard SiSU markup syntax,
+ * Standard SiSU meta-markup syntax, and the
+ * Standard SiSU object citation numbering and system
+
+** Hompages:
+ <http://www.jus.uio.no/sisu>
+ <http://www.sisudoc.org>
+
+** Git
+ <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=summary>
+ <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=blob;f=lib/sisu/current/txt_textile_decorate.rb;hb=HEAD>
+
+=end
+
+module SiSU_Decorate_Txt_Textile
+ def decorate
+ def heading
+ def inline
+ def l0
+ 'h1. '
+ end
+ def l1
+ 'h2. '
+ end
+ def l2
+ 'h3. '
+ end
+ def l3
+ 'h4. '
+ end
+ def l4
+ 'h5. '
+ end
+ def l5
+ 'h6. '
+ end
+ self
+ end
+ self
+ end
+ def bold
+ def open
+ '*'
+ end
+ def close
+ '*'
+ end
+ self
+ end
+ def italics
+ def open
+ '_'
+ end
+ def close
+ '_'
+ end
+ self
+ end
+ def underscore
+ def open
+ '+'
+ end
+ def close
+ '+'
+ end
+ self
+ end
+ #def emphasis
+ # def open
+ # ''
+ # end
+ # def close
+ # ''
+ # end
+ # self
+ #end
+ def cite
+ def open
+ '"'
+ end
+ def close
+ '"'
+ end
+ self
+ end
+ def insert
+ def open
+ ''
+ end
+ def close
+ ''
+ end
+ self
+ end
+ def strike
+ def open
+ '-'
+ end
+ def close
+ '-'
+ end
+ self
+ end
+ def superscript
+ def open
+ '^'
+ end
+ def close
+ '^'
+ end
+ self
+ end
+ def subscript
+ def open
+ '~'
+ end
+ def close
+ '~'
+ end
+ self
+ end
+ def hilite
+ def open
+ '*'
+ end
+ def close
+ '*'
+ end
+ self
+ end
+ def monospace
+ def open
+ ''
+ end
+ def close
+ ''
+ end
+ self
+ end
+ self
+ end
+end
+__END__
diff --git a/lib/sisu/current/urls.rb b/lib/sisu/current/urls.rb
index db31282..c69f617 100644
--- a/lib/sisu/current/urls.rb
+++ b/lib/sisu/current/urls.rb
@@ -197,6 +197,15 @@ module SiSU_Urls
fn: @fn[:txt_textile],
}
end
+ def orgmode
+ {
+ cmd: '--orgmode',
+ viewer: @prog.web_browser,
+ f_pth: @md.file.output_path.orgmode.dir + '/' \
+ + @md.file.base_filename.orgmode,
+ fn: @fn[:txt_orgmode],
+ }
+ end
self
end
def html
@@ -539,18 +548,27 @@ module SiSU_Urls
|| @opt.act[:maintenance][:set]==:on)
if @opt.act[:txt][:set]==:on
show.report(report_info.text.txt)
+ #show.maintenance(report_info.text.txt)
end
if @opt.act[:txt_textile][:set]==:on
show.report(report_info.text.textile)
+ #show.maintenance(report_info.text.textile)
end
if @opt.act[:txt_asciidoc][:set]==:on
show.report(report_info.text.asciidoc)
+ #show.maintenance(report_info.text.asciidoc)
end
if @opt.act[:txt_markdown][:set]==:on
show.report(report_info.text.markdown)
+ #show.maintenance(report_info.text.markdown)
end
if @opt.act[:txt_rst][:set]==:on
show.report(report_info.text.rst)
+ #show.maintenance(report_info.text.rst)
+ end
+ if @opt.act[:txt_orgmode][:set]==:on
+ show.report(report_info.text.orgmode)
+ #show.maintenance(report_info.text.orgmode)
end
if (@opt.act[:html][:set]==:on \
or @opt.act[:html_scroll][:set]==:on \
@@ -566,6 +584,7 @@ module SiSU_Urls
end
if @opt.act[:concordance][:set]==:on
show.report(report_info.html.concordance)
+ #show.maintenance(report_info.html.concordance)
end
if @opt.act[:xhtml][:set]==:on
show.report(report_info.xhtml.xhtml)
@@ -581,21 +600,27 @@ module SiSU_Urls
end
if @opt.act[:xml_dom][:set]==:on
show.report(report_info.xml.dom)
+ #show.maintenance(report_info.xml.dom)
end
if @opt.act[:xml_sax][:set]==:on
show.report(report_info.xml.sax)
+ #show.maintenance(report_info.xml.sax)
end
if @opt.act[:xml_docbook_book][:set]==:on
show.report(report_info.xml.docbook)
+ #show.maintenance(report_info.xml.docbook)
end
if @opt.act[:xml_fictionbook][:set]==:on
show.report(report_info.xml.fictionbook)
+ #show.maintenance(report_info.xml.fictionbook)
end
if @opt.act[:xml_scaffold_structure_sisu][:set]==:on
show.report(report_info.xml.scaffold_structure_sisu)
+ #show.maintenance(report_info.xml.scaffold_structure_sisu)
end
if @opt.act[:xml_scaffold_structure_collapse][:set]==:on
show.report(report_info.xml.scaffold_collapse)
+ #show.maintenance(report_info.xml.scaffold_collapse)
end
if (@opt.act[:pdf][:set]==:on \
or @opt.act[:pdf_p][:set]==:on \
@@ -623,14 +648,17 @@ module SiSU_Urls
end
if @opt.act[:texinfo][:set]==:on
show.report(report_info.texinfo)
+ #show.maintenance(report_info.texinfo)
end
if @opt.act[:manpage][:set]==:on
show.report(report_info.manpage)
+ #show.maintenance(report_info.manpage)
end
if @opt.act[:hash_digests][:set]==:on
show.report(report_info.hash_digests)
+ #show.maintenance(report_info.hash_digests)
end
- if @opt.act[:po4a][:set]==:on
+ if @opt.act[:po4a_shelf][:set]==:on
#if @opt.fns =~/\S+?~\S{2}(?:_\S{2})?\.ss[mt]/
#else
#end
@@ -645,6 +673,7 @@ module SiSU_Urls
end
if @opt.act[:qrcode][:set]==:on
show.report(report_info.qrcode)
+ #show.maintenance(report_info.qrcode)
end
if @opt.act[:manifest][:set]==:on
show.report(report_info.manifest)
diff --git a/lib/sisu/current/utils_composite.rb b/lib/sisu/current/utils_composite.rb
new file mode 100644
index 0000000..cdd844f
--- /dev/null
+++ b/lib/sisu/current/utils_composite.rb
@@ -0,0 +1,115 @@
+# encoding: utf-8
+=begin
+
+* Name: SiSU
+
+** Description: documents, structuring, processing, publishing, search
+*** system environment, debug related
+
+** Author: Ralph Amissah
+ <ralph@amissah.com>
+ <ralph.amissah@gmail.com>
+
+** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
+ 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah,
+ All Rights Reserved.
+
+** License: GPL 3 or later:
+
+ SiSU, a framework for document structuring, publishing and search
+
+ Copyright (C) Ralph Amissah
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the Free
+ Software Foundation, either version 3 of the License, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ more details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program. If not, see <http://www.gnu.org/licenses/>.
+
+ If you have Internet connection, the latest version of the GPL should be
+ available at these locations:
+ <http://www.fsf.org/licensing/licenses/gpl.html>
+ <http://www.gnu.org/licenses/gpl.html>
+
+ <http://www.sisudoc.org/sisu/en/manifest/gpl.fsf.html>
+
+** SiSU uses:
+ * Standard SiSU markup syntax,
+ * Standard SiSU meta-markup syntax, and the
+ * Standard SiSU object citation numbering and system
+
+** Hompages:
+ <http://www.jus.uio.no/sisu>
+ <http://www.sisudoc.org>
+
+** Git
+ <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=summary>
+ <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=blob;f=lib/sisu/current/utils_composite.rb;hb=HEAD>
+
+=end
+module SiSU_Composite_Doc_Utils
+ def inserts_array(loadfilename)
+ IO.readlines(loadfilename,'')
+ end
+ def insert_filename?(para)
+ if para =~ /^<<\s+((?:https?|file):\/\/\S+?\.ss[it])$/ # and NetTest
+ url($1.strip)
+ elsif para =~/^<<\s*(\S+?\.ss[it])$/
+ $1.strip
+ end
+ end
+ def extract_filenames(loadfilename,file_names_arr)
+ file_names_arr << loadfilename
+ ssi_files=[]
+ if loadfilename =~/\S+?\.ss[im]$/
+ inserts_array(loadfilename).each do |para|
+ filen=insert_filename?(para)
+ file_names_arr << filen
+ if filen =~/\S+?\.ssi$/
+ ssi_files << filen
+ end
+ end
+ end
+ ssi_files.each do |fn|
+ extract_filenames(fn,file_names_arr)
+ end
+ file_names_arr.flatten.compact.uniq.sort
+ end
+ def composite_and_imported_filenames_array(loadfilename)
+ file_names_arr=[]
+ begin
+ if FileTest.file?(loadfilename)
+ if loadfilename =~/\S+?\.ss[itm]$/
+ if (@opt.act[:verbose][:set]==:on \
+ || @opt.act[:verbose_plus][:set]==:on \
+ || @opt.act[:maintenance][:set]==:on)
+ SiSU_Screen::Ansi.new(
+ @opt.act[:color_state][:set],
+ 'loading:',
+ loadfilename,
+ ).txt_grey
+ end
+ file_names_arr=extract_filenames(loadfilename,file_names_arr)
+ end
+ end
+ if (@opt.act[:verbose_plus][:set]==:on \
+ || @opt.act[:maintenance][:set]==:on)
+ p file_names_arr ;p file_names_arr.length
+ end
+ file_names_arr
+ rescue
+ SiSU_Errors::Rescued.new($!,$@,@opt.selections.str,@opt.fns).location do
+ __LINE__.to_s + ':' + __FILE__
+ end
+ ensure
+ end
+ end
+end
+__END__
diff --git a/lib/sisu/current/utils_response.rb b/lib/sisu/current/utils_response.rb
index c47fab2..2343dad 100644
--- a/lib/sisu/current/utils_response.rb
+++ b/lib/sisu/current/utils_response.rb
@@ -55,18 +55,19 @@
=end
module SiSU_Response
- class Response
- def response?(ask) #move to more appropriate directory later
- response='redo'
- print ask + " ['yes', 'no' or 'quit']: "
- response=File.new('/dev/tty').gets.strip
- ans=if response=='yes' then true
- elsif response=='no' then false
- elsif response =~/^quit|exit$/ then exit
- else puts "[please type: 'yes', 'no' or 'quit']"
- response?(ask)
- end
- ans
+ def available_selections_
+ %{'yes', 'no', 'quit' or 'exit'; [ynqx]}
+ end
+ def response?(ask)
+ response='redo'
+ print ask + %{ [#{available_selections_}]: }
+ response=File.new('/dev/tty').gets.strip
+ case response
+ when /^(?:y|yes)$/ then true
+ when /^(?:n|no)$/ then false
+ when /^(?:[qx]|quit|exit)$/ then exit
+ else puts %{[please type: #{available_selections_}]}
+ response?(ask)
end
end
def query
diff --git a/lib/sisu/current/wikispeak.rb b/lib/sisu/current/wikispeak.rb
index a40f642..7c55a75 100644
--- a/lib/sisu/current/wikispeak.rb
+++ b/lib/sisu/current/wikispeak.rb
@@ -64,7 +64,7 @@ module SiSU_Wikispeak
include Format
require_relative 'html_parts' # html_parts.rb
require_relative 'txt_shared'
- @@alt_id_count,@@alt_id_count,@@tablehead,@@number_of_cols=0,0,0,0
+ @@alt_id_count,@@alt_id_count=0,0
@@tablefoot=''
class Source
def initialize(opt)
@@ -185,7 +185,7 @@ WOK
end
end
def wiki_tail
- generator="Generated by: #{@md.sisu_version[:project]} #{@md.sisu_version[:version]} of #{@md.sisu_version[:date_stamp]} (#{@md.sisu_version[:date]})" if @md.sisu_version[:version]
+ generator="Generated by: #{@md.project_details.project} #{@md.project_details.version} of #{@md.project_details.date_stamp} (#{@md.project_details.date})" if @md.project_details.version
lastdone="Last Generated on: #{Time.now}"
rubyv="Ruby version: #{@md.ruby_version}"
sc=if @md.sc_info
diff --git a/lib/sisu/current/xhtml.rb b/lib/sisu/current/xhtml.rb
index 8a7cc17..b40b755 100644
--- a/lib/sisu/current/xhtml.rb
+++ b/lib/sisu/current/xhtml.rb
@@ -63,10 +63,11 @@ module SiSU_XHTML
include SiSU_XML_Munge
require_relative 'xml_format' # xml_format.rb
include SiSU_XML_Format
+ require_relative 'xml_persist' # xml_persist.rb
require_relative 'rexml' # rexml.rb
include SiSU_Rexml
require_relative 'shared_metadata' # shared_metadata.rb
- @@alt_id_count,@@tablehead,@@number_of_cols=0,0,0
+ @@alt_id_count=0
@@tablefoot=''
class Source
def initialize(opt)
@@ -144,18 +145,22 @@ module SiSU_XHTML
require_relative 'txt_shared' # txt_shared.rb
include SiSU_TextUtils
require_relative 'css' # css.rb
- @@xml={ body: [], sisu: [], open: [], close: [], head: [] }
def initialize(particulars)
@env,@md,@ao_array=particulars.env,particulars.md,particulars.ao_array
@tab="\t"
@trans=SiSU_XML_Munge::Trans.new(@md)
@sys=SiSU_Env::SystemCall.new
+ @per=SiSU_XML_Persist::Persist.new
end
def songsheet
- pre
- @data=markup(@ao_array)
- post
- publish
+ begin
+ pre
+ @data=markup(@ao_array)
+ post
+ publish
+ ensure
+ SiSU_XML_Persist::Persist.new.persist_init
+ end
end
protected
def embedded_endnotes(dob='')
@@ -202,7 +207,7 @@ WOK
end
def xml_head
metadata=SiSU_Metadata::Summary.new(@md).xhtml_scroll.metadata
- @@xml[:head] << metadata
+ @per.head << metadata
end
def name_tags(dob)
tags=''
@@ -228,15 +233,15 @@ WOK
gsub(/#{Mx[:en_b_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_b_c]}/,'<en>\1</en>')
util=SiSU_TextUtils::Wrap.new(dob.obj,70)
wrapped=util.line_wrap
- @@xml[:body] << if defined? dob.ocn
+ @per.body << if defined? dob.ocn
%{#{Ax[:tab]*0}<object id="#{dob.ocn}">}
else "#{Ax[:tab]*0}<object>"
end
- @@xml[:body] << %{#{Ax[:tab]*1}<text class="#{type}">#{named}\n#{Ax[:tab]*2}#{wrapped}\n#{Ax[:tab]*1}</text>} unless lv # main text, contents, body KEEP
- @@xml[:body] << %{#{Ax[:tab]*1}<text class="h#{lv}">#{named}\n#{Ax[:tab]*2}#{wrapped}\n#{Ax[:tab]*1}</text>} if lv # main text, contents, body KEEP
- @@xml[:body] << @endnotes.compact.join if @endnotes.length > 0 # main text, endnotes KEEP
- @@xml[:body] << "#{Ax[:tab]*1}<ocn>#{dob.ocn}</ocn>" if defined? dob.ocn
- @@xml[:body] << "#{Ax[:tab]*0}</object>"
+ @per.body << %{#{Ax[:tab]*1}<text class="#{type}">#{named}\n#{Ax[:tab]*2}#{wrapped}\n#{Ax[:tab]*1}</text>} unless lv # main text, contents, body KEEP
+ @per.body << %{#{Ax[:tab]*1}<text class="h#{lv}">#{named}\n#{Ax[:tab]*2}#{wrapped}\n#{Ax[:tab]*1}</text>} if lv # main text, contents, body KEEP
+ @per.body << @endnotes.compact.join if @endnotes.length > 0 # main text, endnotes KEEP
+ @per.body << "#{Ax[:tab]*1}<ocn>#{dob.ocn}</ocn>" if defined? dob.ocn
+ @per.body << "#{Ax[:tab]*0}</object>"
@endnotes=[]
end
end
@@ -246,12 +251,12 @@ WOK
dob.obj=dob.obj.strip.
gsub(/#{Mx[:en_a_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_a_c]}/,'<en>\1</en>'). #footnote/endnote clean
gsub(/#{Mx[:en_b_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_b_c]}/,'<en>\1</en>') #footnote/endnote clean
- @@xml[:body] << %{#{Ax[:tab]*0}<object id="#{dob.ocn}">}
- @@xml[:body] << %{#{Ax[:tab]*1}<ocn>#{dob.ocn}</ocn>}
- @@xml[:body] << %{#{Ax[:tab]*1}<text class="block">#{named}#{Ax[:tab]*1}}
- @@xml[:body] << %{#{Ax[:tab]*2}#{dob.obj}#{Ax[:tab]*1}}
- @@xml[:body] << %{#{Ax[:tab]*1}</text>}
- @@xml[:body] << "#{Ax[:tab]*0}</object>"
+ @per.body << %{#{Ax[:tab]*0}<object id="#{dob.ocn}">}
+ @per.body << %{#{Ax[:tab]*1}<ocn>#{dob.ocn}</ocn>}
+ @per.body << %{#{Ax[:tab]*1}<text class="block">#{named}#{Ax[:tab]*1}}
+ @per.body << %{#{Ax[:tab]*2}#{dob.obj}#{Ax[:tab]*1}}
+ @per.body << %{#{Ax[:tab]*1}</text>}
+ @per.body << "#{Ax[:tab]*0}</object>"
end
def group_structure(dob)
named=name_tags(dob)
@@ -259,42 +264,42 @@ WOK
dob.obj=dob.obj.strip.
gsub(/#{Mx[:en_a_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_a_c]}/,'<en>\1</en>'). #footnote/endnote clean
gsub(/#{Mx[:en_b_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_b_c]}/,'<en>\1</en>') #footnote/endnote clean
- @@xml[:body] << %{#{Ax[:tab]*0}<object id="#{dob.ocn}">}
- @@xml[:body] << %{#{Ax[:tab]*1}<ocn>#{dob.ocn}</ocn>}
- @@xml[:body] << %{#{Ax[:tab]*1}<text class="group">#{named}#{Ax[:tab]*1}}
- @@xml[:body] << %{#{Ax[:tab]*2}#{dob.obj}#{Ax[:tab]*1}}
- @@xml[:body] << %{#{Ax[:tab]*1}</text>}
- @@xml[:body] << "#{Ax[:tab]*0}</object>"
+ @per.body << %{#{Ax[:tab]*0}<object id="#{dob.ocn}">}
+ @per.body << %{#{Ax[:tab]*1}<ocn>#{dob.ocn}</ocn>}
+ @per.body << %{#{Ax[:tab]*1}<text class="group">#{named}#{Ax[:tab]*1}}
+ @per.body << %{#{Ax[:tab]*2}#{dob.obj}#{Ax[:tab]*1}}
+ @per.body << %{#{Ax[:tab]*1}</text>}
+ @per.body << "#{Ax[:tab]*0}</object>"
end
def poem_structure(dob)
named=name_tags(dob)
dob=@trans.markup_group(dob)
dob.obj=dob.obj.strip
- @@xml[:body] << %{#{Ax[:tab]*0}<object id="#{dob.ocn}">}
- @@xml[:body] << %{#{Ax[:tab]*1}<ocn>#{dob.ocn}</ocn>}
- @@xml[:body] << %{#{Ax[:tab]*1}<text class="verse">#{named}#{Ax[:tab]*1}}
- @@xml[:body] << %{#{Ax[:tab]*2}#{dob.obj}#{Ax[:tab]*1}}
- @@xml[:body] << %{#{Ax[:tab]*1}</text>}
- @@xml[:body] << "#{Ax[:tab]*0}</object>"
+ @per.body << %{#{Ax[:tab]*0}<object id="#{dob.ocn}">}
+ @per.body << %{#{Ax[:tab]*1}<ocn>#{dob.ocn}</ocn>}
+ @per.body << %{#{Ax[:tab]*1}<text class="verse">#{named}#{Ax[:tab]*1}}
+ @per.body << %{#{Ax[:tab]*2}#{dob.obj}#{Ax[:tab]*1}}
+ @per.body << %{#{Ax[:tab]*1}</text>}
+ @per.body << "#{Ax[:tab]*0}</object>"
end
def code_structure(dob)
named=name_tags(dob)
dob=@trans.markup_group(dob)
dob.obj=dob.obj.gsub(/\s\s/,'&#160;&#160;').strip
- @@xml[:body] << %{#{Ax[:tab]*0}<object id="#{dob.ocn}">}
- @@xml[:body] << %{#{Ax[:tab]*1}<ocn>#{dob.ocn}</ocn>}
- @@xml[:body] << %{#{Ax[:tab]*1}<text class="code">#{named}#{Ax[:tab]*1}}
- @@xml[:body] << %{#{Ax[:tab]*2}#{dob.obj}#{Ax[:tab]*1}}
- @@xml[:body] << %{#{Ax[:tab]*1}</text>}
- @@xml[:body] << "#{Ax[:tab]*0}</object>"
+ @per.body << %{#{Ax[:tab]*0}<object id="#{dob.ocn}">}
+ @per.body << %{#{Ax[:tab]*1}<ocn>#{dob.ocn}</ocn>}
+ @per.body << %{#{Ax[:tab]*1}<text class="code">#{named}#{Ax[:tab]*1}}
+ @per.body << %{#{Ax[:tab]*2}#{dob.obj}#{Ax[:tab]*1}}
+ @per.body << %{#{Ax[:tab]*1}</text>}
+ @per.body << "#{Ax[:tab]*0}</object>"
end
def table_structure(dob)
named=name_tags(dob)
table=SiSU_XHTML_Shared::TableXHTML.new(dob)
- @@xml[:body] << %{#{Ax[:tab]*0}<object id="#{dob.ocn}">}
- @@xml[:body] << %{#{Ax[:tab]*1}<ocn>#{dob.ocn}</ocn>}
- @@xml[:body] << %{#{Ax[:tab]*2}#{named}#{table.table.obj}}
- @@xml[:body] << "#{Ax[:tab]*0}</object>"
+ @per.body << %{#{Ax[:tab]*0}<object id="#{dob.ocn}">}
+ @per.body << %{#{Ax[:tab]*1}<ocn>#{dob.ocn}</ocn>}
+ @per.body << %{#{Ax[:tab]*2}#{named}#{table.table.obj}}
+ @per.body << "#{Ax[:tab]*0}</object>"
end
def markup(data)
@endnotes=[]
@@ -370,39 +375,38 @@ WOK
end
6.downto(4) do |x|
y=x - 1; v=x - 3
- @@xml[:body] << "#{Ax[:tab]*5}</content>\n#{Ax[:tab]*y}</contents#{v}>" if @level[x]==true
+ @per.body << "#{Ax[:tab]*5}</content>\n#{Ax[:tab]*y}</contents#{v}>" if @level[x]==true
end
3.downto(1) do |x|
y=x - 1
- @@xml[:body] << "#{Ax[:tab]*y}</heading#{x}>" if @level[x]==true
+ @per.body << "#{Ax[:tab]*y}</heading#{x}>" if @level[x]==true
end
end
def pre
rdf=SiSU_XML_Tags::RDF.new(@md)
- @@xml[:head],@@xml[:body]=[],[]
+ @per.head,@per.body=[],[]
stylesheet=SiSU_Style::CSS_HeadInfo.new(@md,'xhtml').stylesheet
encoding=(@sys.locale =~/utf-?8/i) \
? '<?xml version="1.0" encoding="UTF-8" standalone="no"?>'
: '<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>'
- @@xml[:open] =<<WOK
+ @per.open =<<WOK
#{encoding}
#{stylesheet.css_head_xml}
#{rdf.comment_xml}
<document>
WOK
- @@xml[:head] << %{<head>\n\t<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />}
- @@xml[:body] << '<body>'
+ @per.head << %{<head>\n\t<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />}
+ @per.body << '<body>'
end
def post
- @@xml[:head] << '</head>'
- @@xml[:body] << '</body>'
- @@xml[:close] = '</document>'
+ @per.head << '</head>'
+ @per.body << '</body>'
+ @per.close = '</document>'
end
def publish
content=[]
- content << @@xml[:open] << @@xml[:head] << @@xml[:body] << @@xml[:metadata]
- content << @@xml[:owner_details] if @md.stmp =~/\w\w/
- content << @@xml[:tail] << @@xml[:close]
+ content << @per.open << @per.head << @per.body << @per.metadata
+ content << @per.tail << @per.close
content=content.flatten.compact
Output.new(content,@md).xhtml
@@xml={}
@@ -440,11 +444,11 @@ WOK
'check document structure'
).colorize
tell=SiSU_Screen::Ansi.new(
- @md.opt.act[:color_state][:set],
- 'invert',
- '',
- ''
- )
+ @md.opt.act[:color_state][:set],
+ 'invert',
+ '',
+ ''
+ )
tell.grey_open
end
tidyfile='/dev/null' #don't want one or screen output, check for alternative flags
diff --git a/lib/sisu/current/xhtml_epub2.rb b/lib/sisu/current/xhtml_epub2.rb
index 9072bf9..3fc6c4e 100644
--- a/lib/sisu/current/xhtml_epub2.rb
+++ b/lib/sisu/current/xhtml_epub2.rb
@@ -73,6 +73,7 @@ module SiSU_XHTML_EPUB2
require_relative 'xhtml_epub2_tune' # xhtml_epub2_tune.rb
include SiSU_XHTML_EPUB2_Tune
require_relative 'xhtml_epub2_concordance' # xhtml_epub2_concordance.rb
+ require_relative 'xhtml_epub2_persist' # xhtml_epub2_persist.rb
class Source
def initialize(opt)
@opt=opt
@@ -124,9 +125,9 @@ module SiSU_XHTML_EPUB2
SiSU_Env::FileOp.new(@md).mkdir.output.epub
@tuned_file_array=SiSU_XHTML_EPUB2::Source::XHTML_Environment.new(@particulars).tuned_file_instructions
data=@tuned_file_array
- toc=SiSU_XHTML_EPUB2::Source::Toc.new(@md,data).songsheet
+ per=SiSU_XHTML_EPUB2::Source::Toc.new(@md,data).songsheet
data=@tuned_file_array
- SiSU_XHTML_EPUB2::Source::ScrollHeadAndSegToc.new(@md,toc).in_common #watch
+ SiSU_XHTML_EPUB2::Source::ScrollHeadAndSegToc.new(@md,per).in_common #watch
SiSU_XHTML_EPUB2::Source::Seg.new(@md,data).songsheet
SiSU_XHTML_EPUB2::Source::Output.new(@md).songsheet
rescue
@@ -144,11 +145,10 @@ module SiSU_XHTML_EPUB2
end
end
SiSU_Env::Clear.new(@opt.selections.str,@opt.fns).param_instantiate
- @@flag,@@scr,@@seg,@@seg_endnotes,@@seg_subtoc,@@seg_ad={},{},{},{},{},{}
- @@seg_total,@@tracker,@@loop_count,@@tablehead,@@number_of_cols=0,0,0,0,0
- @@seg_name,@@seg_name_html,@@seg_subtoc_array,@@seg_endnotes_array,@@segtocband,@@tablefoot=Array.new(7){[]}
- @@filename_seg,@@seg_url,@@fn,@@to_lev4,@@get_hash_to,@@get_hash_fn='','','','','','',''
- @@is4=@@is3=@@is2=@@is1=@@heading1=@@heading2=@@heading3=@@heading4=0
+ @@flag,@@scr,@@seg,@@seg_endnotes,@@seg_subtoc={},{},{},{},{}
+ @@tracker=0
+ @@seg_name,@@seg_name_html,@@seg_subtoc_array,@@seg_endnotes_array,@@tablefoot=Array.new(5){[]}
+ @@filename_seg,@@seg_url,@@to_lev4,@@get_hash_to,@@get_hash_fn='','','','',''
end
end
private
@@ -202,7 +202,6 @@ module SiSU_XHTML_EPUB2
end
end
class Toc
- @@toc={ seg: [], seg_mini: [], scr: [], ncx: [], opf: [] }
@@seg_url=''
@@firstseg=nil
def initialize(md=nil,data='')
@@ -210,237 +209,242 @@ module SiSU_XHTML_EPUB2
@epub=SiSU_XHTML_EPUB2_Format::HeadInformation.new(@md)
@tell=SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set]) if @md
@make=SiSU_Env::ProcessingSettings.new(@md)
+ @per=SiSU_XHTML_EPUB2_Persist::PersistTOC.new
end
def songsheet #extracts toc for scroll & seg
- if (@md.opt.act[:verbose][:set]==:on \
- || @md.opt.act[:verbose_plus][:set]==:on \
- || @md.opt.act[:maintenance][:set]==:on)
- SiSU_Screen::Ansi.new(
- @md.opt.act[:color_state][:set],
- 'Toc'
- ).txt_grey
- end
- toc=nil
- @@firstseg=nil
- @@toc={ seg: [], seg_mini: [], scr: [], ncx: [], opf: [] }
- md_opf_a_content,md_opf_a_spine,md_opf_a_guide=[],[],[]
- @nav_no=0
- @s_a_no,@s_b_no,@s_c_no,@s_d_no,@lv5_no,@lv6_no=0,0,0,0,0,0
- @@toc[:ncx] << @epub.toc_ncx.open #epub ncx navmap
- @@toc[:ncx] << @epub.toc_ncx.head_open << @epub.toc_ncx.head << @epub.toc_ncx.head_close
- @@toc[:ncx] << @epub.toc_ncx.doc_title << @epub.toc_ncx.doc_author
- @@toc[:ncx] << @epub.toc_ncx.navmap_open
- @@toc[:opf] << @epub.metadata_opf.package_open
- @@toc[:opf] << @epub.metadata_opf.metadata
- @@toc[:opf] << @epub.metadata_opf.manifest_open
- @@toc[:seg] << %{<div class="content">\n<div class="substance">}
- @@toc[:scr] << %{<div class="content">\n<div class="substance">}
- if defined? @md.make.cover_image \
- and @md.make.cover_image.is_a?(Hash) \
- and @md.make.cover_image[:cover] =~/\S+/
- md_opf_a_content << @epub.metadata_opf.manifest_cover_image_information(@md)
- md_opf_a_spine << @epub.metadata_opf.spine_cover_image
- md_opf_a_guide << @epub.metadata_opf.guide_cover_image
- end
- md_opf_a_content << @epub.metadata_opf.manifest_content_sisu_toc
- if @make.build.toc?
- md_opf_a_spine << @epub.metadata_opf.spine_sisu_toc
- md_opf_a_guide << @epub.metadata_opf.guide_sisu_toc
- end
- @ncxo=[false,false,false,false,false,false,false]
- @dob_toc2,@dob_toc3=nil,nil
- @ncx_cls=[]
- @level_a_first_occurrence=true
- @data.each do |dob|
- if dob.is==:heading \
- || dob.is==:heading_insert
- dob_toc=dob.dup
- toc=case dob_toc.ln
- when 0
- @s_a_no +=1
- lv_name='section_a' + @s_a_no.to_s
- @nav_no+=1
- @nav_no2=@nav_no
- @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[7]
- @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[6]
- @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[5]
- @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[4]
- @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[3]
- @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[2]
- @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[1]
- @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[0]
- @ncxo[0],@ncxo[1],@ncxo[2],@ncxo[3],@ncxo[4],@ncxo[5],@ncxo[6],@ncxo[7]=
- true, false, false, false, false, false, false, false
- @epub.sections(dob_toc,lv_name)
- if @level_a_first_occurrence \
- && @make.build.toc?
- @@toc[:ncx] << @epub.toc_ncx.navmap_sisu_toc(@nav_no) #epub ncx navmap, toc
+ begin
+ if (@md.opt.act[:verbose][:set]==:on \
+ || @md.opt.act[:verbose_plus][:set]==:on \
+ || @md.opt.act[:maintenance][:set]==:on)
+ SiSU_Screen::Ansi.new(
+ @md.opt.act[:color_state][:set],
+ 'Toc'
+ ).txt_grey
+ end
+ toc=nil
+ @@firstseg=nil
+ SiSU_XHTML_EPUB2_Persist::PersistTOC.new.persist_init
+ md_opf_a_content,md_opf_a_spine,md_opf_a_guide=[],[],[]
+ @nav_no=0
+ @s_a_no,@s_b_no,@s_c_no,@s_d_no,@lv5_no,@lv6_no=0,0,0,0,0,0
+ @per.ncx << @epub.toc_ncx.open #epub ncx navmap
+ @per.ncx << @epub.toc_ncx.head_open << @epub.toc_ncx.head << @epub.toc_ncx.head_close
+ @per.ncx << @epub.toc_ncx.doc_title << @epub.toc_ncx.doc_author
+ @per.ncx << @epub.toc_ncx.navmap_open
+ @per.opf << @epub.metadata_opf.package_open
+ @per.opf << @epub.metadata_opf.metadata
+ @per.opf << @epub.metadata_opf.manifest_open
+ @per.seg << %{<div class="content">\n<div class="substance">}
+ @per.scr << %{<div class="content">\n<div class="substance">}
+ if defined? @md.make.cover_image \
+ and @md.make.cover_image.is_a?(Hash) \
+ and @md.make.cover_image[:cover] =~/\S+/
+ md_opf_a_content << @epub.metadata_opf.manifest_cover_image_information(@md)
+ md_opf_a_spine << @epub.metadata_opf.spine_cover_image
+ md_opf_a_guide << @epub.metadata_opf.guide_cover_image
+ end
+ md_opf_a_content << @epub.metadata_opf.manifest_content_sisu_toc
+ if @make.build.toc?
+ md_opf_a_spine << @epub.metadata_opf.spine_sisu_toc
+ md_opf_a_guide << @epub.metadata_opf.guide_sisu_toc
+ end
+ @ncxo=[false,false,false,false,false,false,false]
+ @dob_toc2,@dob_toc3=nil,nil
+ @ncx_cls=[]
+ @level_a_first_occurrence=true
+ @data.each do |dob|
+ if dob.is==:heading \
+ || dob.is==:heading_insert
+ dob_toc=dob.dup
+ toc=case dob_toc.ln
+ when 0
+ @s_a_no +=1
+ lv_name='section_a' + @s_a_no.to_s
+ @nav_no+=1
+ @nav_no2=@nav_no
+ @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[7]
+ @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[6]
+ @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[5]
+ @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[4]
+ @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[3]
+ @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[2]
+ @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[1]
+ @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[0]
+ @ncxo[0],@ncxo[1],@ncxo[2],@ncxo[3],@ncxo[4],@ncxo[5],@ncxo[6],@ncxo[7]=
+ true, false, false, false, false, false, false, false
+ @epub.sections(dob_toc,lv_name)
+ if @level_a_first_occurrence \
+ && @make.build.toc?
+ @per.ncx << @epub.toc_ncx.navmap_sisu_toc(@nav_no) #epub ncx navmap, toc
+ @nav_no+=1
+ @level_a_first_occurrence=false
+ end
+ @per.ncx << @epub.toc_ncx.navpoint(dob_toc,@nav_no,lv_name) if dob_toc
+ md_opf_a_content << @epub.metadata_opf.manifest_content(dob_toc,lv_name)
+ md_opf_a_spine << @epub.metadata_opf.spine(dob_toc,lv_name)
+ md_opf_a_guide << @epub.metadata_opf.guide(dob_toc,lv_name)
+ SiSU_XHTML_EPUB2::Source::Toc.new(@md,dob_toc).level_0
+ when 1
+ @s_b_no +=1
+ lv_name='section_b' + @s_b_no.to_s
+ @nav_no+=1
+ @nav_no2=@nav_no
+ @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[7]
+ @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[6]
+ @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[5]
+ @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[4]
+ @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[3]
+ @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[2]
+ @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[1]
+ @ncxo[1],@ncxo[2],@ncxo[3],@ncxo[4],@ncxo[5],@ncxo[6],@ncxo[7]=
+ true, false, false, false, false, false, false
+ @epub.sections(dob_toc,lv_name)
+ @per.ncx << @epub.toc_ncx.navpoint(dob_toc,@nav_no,lv_name) if dob_toc
+ md_opf_a_content << @epub.metadata_opf.manifest_content(dob_toc,lv_name)
+ md_opf_a_spine << @epub.metadata_opf.spine(dob_toc,lv_name)
+ md_opf_a_guide << @epub.metadata_opf.guide(dob_toc,lv_name)
+ SiSU_XHTML_EPUB2::Source::Toc.new(@md,dob_toc).level_1
+ when 2
+ @s_c_no +=1
+ lv_name='section_c' + @s_c_no.to_s
+ @nav_no+=1
+ @nav_no2=@nav_no
+ @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[7]
+ @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[6]
+ @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[5]
+ @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[4]
+ @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[3]
+ @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[2]
+ @ncxo[2],@ncxo[3],@ncxo[4],@ncxo[5],@ncxo[6],@ncxo[7]=
+ true, false, false, false, false, false
+ @epub.sections(dob_toc,lv_name)
+ @per.ncx << @epub.toc_ncx.navpoint(dob_toc,@nav_no,lv_name) if dob_toc
+ md_opf_a_content << @epub.metadata_opf.manifest_content(dob_toc,lv_name)
+ md_opf_a_spine << @epub.metadata_opf.spine(dob_toc,lv_name)
+ md_opf_a_guide << @epub.metadata_opf.guide(dob_toc,lv_name)
+ SiSU_XHTML_EPUB2::Source::Toc.new(@md,dob_toc).level_2
+ when 3
+ @s_d_no +=1
+ lv_name='section_d' + @s_d_no.to_s
+ @nav_no+=1
+ @nav_no3=@nav_no
+ @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[7]
+ @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[6]
+ @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[5]
+ @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[4]
+ @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[3]
+ @ncxo[3],@ncxo[4],@ncxo[5],@ncxo[6],@ncxo[7]=
+ true, false, false, false, false
+ @epub.sections(dob_toc,lv_name)
+ @per.ncx << @epub.toc_ncx.navpoint(dob_toc,@nav_no,lv_name) if dob_toc
+ md_opf_a_content << @epub.metadata_opf.manifest_content(dob_toc,lv_name)
+ md_opf_a_spine << @epub.metadata_opf.spine(dob_toc,lv_name)
+ md_opf_a_guide << @epub.metadata_opf.guide(dob_toc,lv_name)
+ SiSU_XHTML_EPUB2::Source::Toc.new(@md,dob_toc).level_3
+ when 4
+ @ncx_cls=[]
+ lv_name=dob_toc.name
@nav_no+=1
- @level_a_first_occurrence=false
+ @dob_name=dob.name
+ @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[7]
+ @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[6]
+ @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[5]
+ @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[4]
+ @ncxo[4],@ncxo[5],@ncxo[6],@ncxo[7]=
+ true, false, false, false
+ @per.ncx << @epub.toc_ncx.navpoint(dob_toc,@nav_no,lv_name) if dob_toc
+ md_opf_a_content << @epub.metadata_opf.manifest_content(dob_toc,lv_name)
+ md_opf_a_spine << @epub.metadata_opf.spine(dob_toc,lv_name)
+ md_opf_a_guide << @epub.metadata_opf.guide(dob_toc,lv_name)
+ SiSU_XHTML_EPUB2::Source::Toc.new(@md,dob_toc).level_4
+ when 5
+ @ncx_cls=[]
+ hashtag='#o' + dob_toc.ocn.to_s
+ lv_name=@dob_name
+ @nav_no+=1
+ @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[7]
+ @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[6]
+ @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[5]
+ @ncxo[5],@ncxo[6],@ncxo[7]=
+ true, false, false
+ @per.ncx << @epub.toc_ncx.navpoint(dob_toc,@nav_no,lv_name,hashtag) if dob_toc
+ md_opf_a_content << @epub.metadata_opf.manifest_content(dob_toc,lv_name,hashtag)
+ md_opf_a_spine << @epub.metadata_opf.spine(dob_toc,lv_name,hashtag)
+ md_opf_a_guide << @epub.metadata_opf.guide(dob_toc,lv_name,hashtag)
+ SiSU_XHTML_EPUB2::Source::Toc.new(@md,dob_toc).level_5
+ when 6
+ @ncx_cls=[]
+ hashtag='#o' + dob_toc.ocn.to_s
+ lv_name=@dob_name
+ @nav_no+=1
+ @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[7]
+ @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[6]
+ @ncxo[6],@ncxo[7]=
+ true, false
+ @per.ncx << @epub.toc_ncx.navpoint(dob_toc,@nav_no,lv_name,hashtag) if dob_toc
+ md_opf_a_content << @epub.metadata_opf.manifest_content(dob_toc,lv_name,hashtag)
+ md_opf_a_spine << @epub.metadata_opf.spine(dob_toc,lv_name,hashtag)
+ md_opf_a_guide << @epub.metadata_opf.guide(dob_toc,lv_name,hashtag)
+ SiSU_XHTML_EPUB2::Source::Toc.new(@md,dob_toc).level_6
+ when 7
+ @ncx_cls=[]
+ hashtag='#o' + dob_toc.ocn.to_s
+ lv_name=@dob_name
+ @nav_no+=1
+ @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[7]
+ @ncxo[7]=true
+ @per.ncx << @epub.toc_ncx.navpoint(dob_toc,@nav_no,lv_name,hashtag) if dob_toc
+ md_opf_a_content << @epub.metadata_opf.manifest_content(dob_toc,lv_name,hashtag)
+ md_opf_a_spine << @epub.metadata_opf.spine(dob_toc,lv_name,hashtag)
+ md_opf_a_guide << @epub.metadata_opf.guide(dob_toc,lv_name,hashtag)
+ SiSU_XHTML_EPUB2::Source::Toc.new(@md,dob_toc).level_7
+ else nil
end
- @@toc[:ncx] << @epub.toc_ncx.navpoint(dob_toc,@nav_no,lv_name) if dob_toc
- md_opf_a_content << @epub.metadata_opf.manifest_content(dob_toc,lv_name)
- md_opf_a_spine << @epub.metadata_opf.spine(dob_toc,lv_name)
- md_opf_a_guide << @epub.metadata_opf.guide(dob_toc,lv_name)
- SiSU_XHTML_EPUB2::Source::Toc.new(@md,dob_toc).level_0
- when 1
- @s_b_no +=1
- lv_name='section_b' + @s_b_no.to_s
- @nav_no+=1
- @nav_no2=@nav_no
- @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[7]
- @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[6]
- @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[5]
- @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[4]
- @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[3]
- @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[2]
- @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[1]
- @ncxo[1],@ncxo[2],@ncxo[3],@ncxo[4],@ncxo[5],@ncxo[6],@ncxo[7]=
- true, false, false, false, false, false, false
- @epub.sections(dob_toc,lv_name)
- @@toc[:ncx] << @epub.toc_ncx.navpoint(dob_toc,@nav_no,lv_name) if dob_toc
- md_opf_a_content << @epub.metadata_opf.manifest_content(dob_toc,lv_name)
- md_opf_a_spine << @epub.metadata_opf.spine(dob_toc,lv_name)
- md_opf_a_guide << @epub.metadata_opf.guide(dob_toc,lv_name)
- SiSU_XHTML_EPUB2::Source::Toc.new(@md,dob_toc).level_1
- when 2
- @s_c_no +=1
- lv_name='section_c' + @s_c_no.to_s
- @nav_no+=1
- @nav_no2=@nav_no
- @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[7]
- @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[6]
- @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[5]
- @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[4]
- @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[3]
- @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[2]
- @ncxo[2],@ncxo[3],@ncxo[4],@ncxo[5],@ncxo[6],@ncxo[7]=
- true, false, false, false, false, false
- @epub.sections(dob_toc,lv_name)
- @@toc[:ncx] << @epub.toc_ncx.navpoint(dob_toc,@nav_no,lv_name) if dob_toc
- md_opf_a_content << @epub.metadata_opf.manifest_content(dob_toc,lv_name)
- md_opf_a_spine << @epub.metadata_opf.spine(dob_toc,lv_name)
- md_opf_a_guide << @epub.metadata_opf.guide(dob_toc,lv_name)
- SiSU_XHTML_EPUB2::Source::Toc.new(@md,dob_toc).level_2
- when 3
- @s_d_no +=1
- lv_name='section_d' + @s_d_no.to_s
- @nav_no+=1
- @nav_no3=@nav_no
- @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[7]
- @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[6]
- @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[5]
- @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[4]
- @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[3]
- @ncxo[3],@ncxo[4],@ncxo[5],@ncxo[6],@ncxo[7]=
- true, false, false, false, false
- @epub.sections(dob_toc,lv_name)
- @@toc[:ncx] << @epub.toc_ncx.navpoint(dob_toc,@nav_no,lv_name) if dob_toc
- md_opf_a_content << @epub.metadata_opf.manifest_content(dob_toc,lv_name)
- md_opf_a_spine << @epub.metadata_opf.spine(dob_toc,lv_name)
- md_opf_a_guide << @epub.metadata_opf.guide(dob_toc,lv_name)
- SiSU_XHTML_EPUB2::Source::Toc.new(@md,dob_toc).level_3
- when 4
- @ncx_cls=[]
- lv_name=dob_toc.name
- @nav_no+=1
- @dob_name=dob.name
- @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[7]
- @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[6]
- @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[5]
- @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[4]
- @ncxo[4],@ncxo[5],@ncxo[6],@ncxo[7]=
- true, false, false, false
- @@toc[:ncx] << @epub.toc_ncx.navpoint(dob_toc,@nav_no,lv_name) if dob_toc
- md_opf_a_content << @epub.metadata_opf.manifest_content(dob_toc,lv_name)
- md_opf_a_spine << @epub.metadata_opf.spine(dob_toc,lv_name)
- md_opf_a_guide << @epub.metadata_opf.guide(dob_toc,lv_name)
- SiSU_XHTML_EPUB2::Source::Toc.new(@md,dob_toc).level_4
- when 5
- @ncx_cls=[]
- hashtag='#o' + dob_toc.ocn.to_s
- lv_name=@dob_name
- @nav_no+=1
- @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[7]
- @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[6]
- @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[5]
- @ncxo[5],@ncxo[6],@ncxo[7]=
- true, false, false
- @@toc[:ncx] << @epub.toc_ncx.navpoint(dob_toc,@nav_no,lv_name,hashtag) if dob_toc
- md_opf_a_content << @epub.metadata_opf.manifest_content(dob_toc,lv_name,hashtag)
- md_opf_a_spine << @epub.metadata_opf.spine(dob_toc,lv_name,hashtag)
- md_opf_a_guide << @epub.metadata_opf.guide(dob_toc,lv_name,hashtag)
- SiSU_XHTML_EPUB2::Source::Toc.new(@md,dob_toc).level_5
- when 6
- @ncx_cls=[]
- hashtag='#o' + dob_toc.ocn.to_s
- lv_name=@dob_name
- @nav_no+=1
- @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[7]
- @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[6]
- @ncxo[6],@ncxo[7]=
- true, false
- @@toc[:ncx] << @epub.toc_ncx.navpoint(dob_toc,@nav_no,lv_name,hashtag) if dob_toc
- md_opf_a_content << @epub.metadata_opf.manifest_content(dob_toc,lv_name,hashtag)
- md_opf_a_spine << @epub.metadata_opf.spine(dob_toc,lv_name,hashtag)
- md_opf_a_guide << @epub.metadata_opf.guide(dob_toc,lv_name,hashtag)
- SiSU_XHTML_EPUB2::Source::Toc.new(@md,dob_toc).level_6
- when 7
- @ncx_cls=[]
- hashtag='#o' + dob_toc.ocn.to_s
- lv_name=@dob_name
- @nav_no+=1
- @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[7]
- @ncxo[7]=true
- @@toc[:ncx] << @epub.toc_ncx.navpoint(dob_toc,@nav_no,lv_name,hashtag) if dob_toc
- md_opf_a_content << @epub.metadata_opf.manifest_content(dob_toc,lv_name,hashtag)
- md_opf_a_spine << @epub.metadata_opf.spine(dob_toc,lv_name,hashtag)
- md_opf_a_guide << @epub.metadata_opf.guide(dob_toc,lv_name,hashtag)
- SiSU_XHTML_EPUB2::Source::Toc.new(@md,dob_toc).level_7
- else nil
- end
- toc.each do |k,d|
- d.gsub!(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ')
- end if toc
- if @@firstseg.nil? \
- and dob.ln==4 \
- and dob.name =~/\S+/
- @@firstseg=dob.name
- end
- if toc
- begin
- @@toc[:seg] << toc[:seg]
- @@toc[:scr] << toc[:seg]
- rescue
- SiSU_Errors::Rescued.new($!,$@,@md.opt.selections.str,@md.fns).location do
- __LINE__.to_s + ':' + __FILE__
+ toc.each do |k,d|
+ d.gsub!(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ')
+ end if toc
+ if @@firstseg.nil? \
+ and dob.ln==4 \
+ and dob.name =~/\S+/
+ @@firstseg=dob.name
+ end
+ if toc
+ begin
+ @per.seg << toc[:seg]
+ @per.scr << toc[:seg]
+ rescue
+ SiSU_Errors::Rescued.new($!,$@,@md.opt.selections.str,@md.fns).location do
+ __LINE__.to_s + ':' + __FILE__
+ end
end
end
end
end
+ @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[6]
+ @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[5]
+ @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[4]
+ @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[3]
+ @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[2]
+ @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[1]
+ @per.ncx << @epub.toc_ncx.navpoint_close if @ncxo[0]
+ @ncxo[0],@ncxo[1],@ncxo[2],@ncxo[3],@ncxo[4],@ncxo[5],@ncxo[6]=false,false,false,false,false,false,false
+ md_opf_a_content << @epub.metadata_opf.manifest_images(@md.ec[:image])
+ @per.seg << "</div>\n</div>"
+ @per.scr << "</div>\n</div>"
+ @per.ncx << @epub.toc_ncx.navmap_close
+ @per.ncx << @epub.toc_ncx.close
+ @per.opf << md_opf_a_content << @epub.metadata_opf.manifest_close
+ @per.opf << @epub.metadata_opf.spine_open << md_opf_a_spine << @epub.metadata_opf.spine_close
+ @per.opf << @epub.metadata_opf.guide_open << md_opf_a_guide << @epub.metadata_opf.guide_close
+ @per.opf << @epub.metadata_opf.package_close
+ @per.opf=@per.opf.flatten
+ SiSU_XHTML_EPUB2::Source::Output.new(@md,@per.opf).epub_metadata_opf
+ SiSU_XHTML_EPUB2::Source::Output.new(@md,@per.ncx).epub_toc_ncx
+ @md.firstseg=@@firstseg
+ @per
+ ensure
+ SiSU_XHTML_EPUB2_Persist::Persist.new.persist_init
end
- @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[6]
- @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[5]
- @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[4]
- @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[3]
- @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[2]
- @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[1]
- @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[0]
- @ncxo[0],@ncxo[1],@ncxo[2],@ncxo[3],@ncxo[4],@ncxo[5],@ncxo[6]=false,false,false,false,false,false,false
- md_opf_a_content << @epub.metadata_opf.manifest_images(@md.ec[:image])
- @@toc[:seg] << "</div>\n</div>"
- @@toc[:scr] << "</div>\n</div>"
- @@toc[:ncx] << @epub.toc_ncx.navmap_close
- @@toc[:ncx] << @epub.toc_ncx.close
- @@toc[:opf] << md_opf_a_content << @epub.metadata_opf.manifest_close
- @@toc[:opf] << @epub.metadata_opf.spine_open << md_opf_a_spine << @epub.metadata_opf.spine_close
- @@toc[:opf] << @epub.metadata_opf.guide_open << md_opf_a_guide << @epub.metadata_opf.guide_close
- @@toc[:opf] << @epub.metadata_opf.package_close
- @@toc[:opf]=@@toc[:opf].flatten
- SiSU_XHTML_EPUB2::Source::Output.new(@md,@@toc[:opf]).epub_metadata_opf
- SiSU_XHTML_EPUB2::Source::Output.new(@md,@@toc[:ncx]).epub_toc_ncx
- @md.firstseg=@@firstseg
- @@toc
end
protected
def level_0
@@ -454,7 +458,7 @@ module SiSU_XHTML_EPUB2
toc[:seg]=format_toc.lev1
title=if dob.ocn ==0 then linkname
else
- @@toc[:scr] << '<br />'
+ @per.scr << '<br />'
link=(dob.ln) \
? dob.ln
: ''
@@ -490,7 +494,7 @@ module SiSU_XHTML_EPUB2
else linkname
end
else
- @@toc[:scr] << '<br />'
+ @per.scr << '<br />'
link=(dob.ln) \
? dob.ln
: ''
@@ -636,8 +640,8 @@ module SiSU_XHTML_EPUB2
end
end
class ScrollHeadAndSegToc < Toc
- def initialize(md='',toc='',links_guide_toc='')
- @md,@toc,@links_guide_toc=md,toc,links_guide_toc
+ def initialize(md='',per='',links_guide_toc='')
+ @md,@per,@links_guide_toc=md,per,links_guide_toc
end
def in_common
toc_shared=[]
@@ -699,9 +703,9 @@ module SiSU_XHTML_EPUB2
toc_shared << prefix_b
end
#Table of Contents added/appended here
- toc_shared << @toc[:scr]
+ toc_shared << @per.scr
segtoc << @links_guide_toc
- segtoc << @toc[:seg]
+ segtoc << @per.seg
if defined? @md.rights.all \
and @md.rights.all
segtoc << rights
@@ -716,7 +720,7 @@ module SiSU_XHTML_EPUB2
SiSU_XHTML_EPUB2::Source::Output.new(@md).make_cover_image
SiSU_XHTML_EPUB2::Source::Output.new(@md,segtoc).make_segtoc
segtoc=[]
- @toc[:scr],@toc[:seg]=[],[]
+ @per.scr,@per.seg=[],[]
toc_shared
end
end
diff --git a/lib/sisu/current/xhtml_epub2_format.rb b/lib/sisu/current/xhtml_epub2_format.rb
index 9cfc573..4f8aa93 100644
--- a/lib/sisu/current/xhtml_epub2_format.rb
+++ b/lib/sisu/current/xhtml_epub2_format.rb
@@ -1251,8 +1251,9 @@ module SiSU_XHTML_EPUB2_Format
@md=md
# DublinCore 1 - title
@css=SiSU_Env::CSS_Stylesheet.new(md)
- @seg_name_xhtml=(SiSU_XHTML_EPUB2::Source::Seg.new.seg_name_xhtml || [])
- @seg_name_xhtml_tracker=(SiSU_XHTML_EPUB2::Source::Seg.new.seg_name_xhtml_tracker || [])
+ @per=SiSU_XHTML_EPUB2_Persist::Persist.new
+ @per.seg_name_x=SiSU_XHTML_EPUB2::Seg.new.seg_name_x
+ @per.seg_name_x_tracker=SiSU_XHTML_EPUB2::Seg.new.seg_name_x_tracker
@tocband_scroll,@tocband_segtoc=nil,nil
@index,@metalink='index','#metadata'
end
@@ -1827,7 +1828,7 @@ output_epub_cont_seg.close
%{#{doc_type}
<head>
<title>
- #{@seg_name_xhtml[@seg_name_xhtml_tracker]} -
+ #{@per.seg_name_x[@per.seg_name_x_tracker]} -
#{@md.html_title}
</title>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
diff --git a/lib/sisu/current/xhtml_epub2_persist.rb b/lib/sisu/current/xhtml_epub2_persist.rb
new file mode 100644
index 0000000..175149f
--- /dev/null
+++ b/lib/sisu/current/xhtml_epub2_persist.rb
@@ -0,0 +1,278 @@
+# encoding: utf-8
+=begin
+
+* Name: SiSU
+
+** Description: documents, structuring, processing, publishing, search
+*** html segment generation, processing
+
+** Author: Ralph Amissah
+ <ralph@amissah.com>
+ <ralph.amissah@gmail.com>
+
+** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
+ 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah,
+ All Rights Reserved.
+
+** License: GPL 3 or later:
+
+ SiSU, a framework for document structuring, publishing and search
+
+ Copyright (C) Ralph Amissah
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the Free
+ Software Foundation, either version 3 of the License, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ more details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program. If not, see <http://www.gnu.org/licenses/>.
+
+ If you have Internet connection, the latest version of the GPL should be
+ available at these locations:
+ <http://www.fsf.org/licensing/licenses/gpl.html>
+ <http://www.gnu.org/licenses/gpl.html>
+
+ <http://www.sisudoc.org/sisu/en/manifest/gpl.fsf.html>
+
+** SiSU uses:
+ * Standard SiSU markup syntax,
+ * Standard SiSU meta-markup syntax, and the
+ * Standard SiSU object citation numbering and system
+
+** Hompages:
+ <http://www.jus.uio.no/sisu>
+ <http://www.sisudoc.org>
+
+** Git
+ <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=summary>
+ <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=blob;f=lib/sisu/current/xhtml_epub2_persist.rb;hb=HEAD>
+
+=end
+module SiSU_XHTML_EPUB2_Persist
+ class Persist
+ @@persist=nil
+ attr_accessor :is0,:is1,:is2,:is3,:is4,:heading0,:heading1,:heading2,:heading3,:heading4, :title, :nav, :tocband_banner, :tocband_bannerless, :headings, :heading_endnotes, :main, :endnote_all, :tail, :credits, :heading_idx, :idx, :seg_endnotes, :seg_endnotes_array, :closed, :get_hash_fn, :get_hash_to, :seg_subtoc, :seg_subtoc_array, :fn, :seg_name ,:seg_name_x,:seg_name_x_tracker
+ def initialize(args=nil)
+ @@persist=args=(args ? args : (@@persist || persist_init_hash_values))
+ @is0=args[:is0]
+ @is1=args[:is1]
+ @is2=args[:is2]
+ @is3=args[:is3]
+ @is4=args[:is4]
+ @heading0=args[:heading0]
+ @heading1=args[:heading1]
+ @heading2=args[:heading2]
+ @heading3=args[:heading3]
+ @heading4=args[:heading4]
+ @title=args[:title]
+ @nav=args[:nav]
+ @tocband_banner=args[:tocband_banner]
+ @tocband_bannerless=args[:tocband_bannerless]
+ @headings=args[:headings]
+ @heading_endnotes=args[:heading_endnotes]
+ @main=args[:main]
+ @endnote_all=args[:endnote_all]
+ @tail=args[:tail]
+ @credits=args[:credits]
+ #@heading_idx=args[:heading_idx]
+ @idx=args[:idx]
+ @seg_endnotes=args[:seg_endnotes]
+ @seg_endnotes_array=args[:seg_endnotes_array]
+ @closed=args[:closed]
+ @get_hash_to=args[:get_hash_to]
+ @get_hash_fn=args[:get_hash_fn]
+ @seg_subtoc=args[:seg_subtoc]
+ @seg_subtoc_array=args[:seg_subtoc_array]
+ @fn=args[:fn]
+ @seg_name=args[:seg_name]
+ @seg_name_x=args[:seg_name_x]
+ @seg_name_x_tracker=args[:seg_name_x_tracker]
+ end
+ def is0
+ @is0
+ end
+ def is1
+ @is1
+ end
+ def is2
+ @is2
+ end
+ def is3
+ @is3
+ end
+ def is4
+ @is4
+ end
+ def heading0
+ @heading0
+ end
+ def heading1
+ @heading1
+ end
+ def heading2
+ @heading2
+ end
+ def heading3
+ @heading3
+ end
+ def heading4
+ @heading4
+ end
+ def title
+ @title
+ end
+ def nav
+ @nav
+ end
+ def tocband_banner
+ @tocband_banner
+ end
+ def tocband_bannerless
+ @tocband_bannerless
+ end
+ def headings
+ @headings
+ end
+ def heading_endnotes
+ @heading_endnotes
+ end
+ def main
+ @main
+ end
+ def endnote_all
+ @endnote_all
+ end
+ def tail
+ @tail
+ end
+ def credits
+ @credits
+ end
+ def heading_idx
+ @heading_idx
+ end
+ def idx
+ @idx
+ end
+ def seg_endnotes
+ @seg_endnotes
+ end
+ def seg_endnotes_array
+ @seg_endnotes_array
+ end
+ def closed
+ @closed
+ end
+ def get_hash_to
+ @get_hash_to
+ end
+ def get_hash_fn
+ @get_hash_fn
+ end
+ def seg_subtoc
+ @seg_subtoc
+ end
+ def seg_subtoc_array
+ @seg_subtoc_array
+ end
+ def fn
+ @fn
+ end
+ def seg_name
+ @seg_name
+ end
+ def seg_name_x
+ @seg_name_x
+ end
+ def seg_name_x_tracker
+ @seg_name_x_tracker
+ end
+ def persist_init_hash_values
+ {
+ is0: 0,
+ is1: 0,
+ is2: 0,
+ is3: 0,
+ is4: 0,
+ heading0: '',
+ heading1: '',
+ heading2: '',
+ heading3: '',
+ heading4: '',
+ tocband_banner: [],
+ tocband_bannerless: [],
+ title: [],
+ nav: [],
+ headings: [],
+ main: [],
+ idx: [],
+ tail: [],
+ credits: [],
+ endnote_all: [],
+ heading_endnotes: '',
+ seg_endnotes: {},
+ seg_endnotes_array: [],
+ closed: [],
+ get_hash_fn: '',
+ get_hash_to: '',
+ seg_subtoc: {},
+ seg_subtoc_array: [],
+ fn: '',
+ seg_name: [],
+ seg_name_x: [],
+ seg_name_x_tracker: 0,
+ }
+ end
+ def persist_init
+ @@persist=nil
+ Persist.new(persist_init_hash_values)
+ end
+ end
+ class PersistTOC
+ @@persist=nil
+ attr_accessor :seg,:seg_mini,:scr,:ncx,:opf
+ def initialize(args=nil)
+ @@persist=args=(args ? args : (@@persist || persist_init_hash_values))
+ @seg=args[:seg]
+ @seg_mini=args[:seg_mini]
+ @scr=args[:scr]
+ @ncx=args[:ncx]
+ @opf=args[:opf]
+ end
+ def seg
+ @seg
+ end
+ def seg_mini
+ @seg_mini
+ end
+ def scr
+ @scr
+ end
+ def ncx
+ @ncx
+ end
+ def opf
+ @opf
+ end
+ def persist_init_hash_values
+ {
+ seg: [],
+ seg_mini: [],
+ scr: [],
+ ncx: [],
+ opf: [],
+ }
+ end
+ def persist_init
+ @@persist=nil
+ PersistTOC.new(persist_init_hash_values)
+ end
+ end
+end
+__END__
diff --git a/lib/sisu/current/xhtml_epub2_segments.rb b/lib/sisu/current/xhtml_epub2_segments.rb
index b8af25d..b376002 100644
--- a/lib/sisu/current/xhtml_epub2_segments.rb
+++ b/lib/sisu/current/xhtml_epub2_segments.rb
@@ -57,37 +57,60 @@
module SiSU_XHTML_EPUB2_Seg
require_relative 'xhtml_shared' # xhtml_shared.rb
require_relative 'xhtml_epub2' # xhtml_epub2.rb
+ require_relative 'xhtml_epub2_persist' # xhtml_epub2_persist.rb
require_relative 'shared_metadata' # shared_metadata.rb
class Output
- def initialize(md,outputfile,seg,type='')
- @md,@output_epub_cont_seg,@seg,@type=md,outputfile,seg,type
+ def initialize(md,outputfile,per,type='')
+ @md, @output_epub_cont_seg,@per,@type=
+ md,outputfile, per, type
end
- def output #CONSIDER
- if @seg[:title] =~/\S/
+ def output
+ if @per.title =~/\S/
filename_seg=[]
- filename_seg << @seg[:title] << @seg[:nav]
+ filename_seg \
+ << @per.title \
+ << @per.nav
if @type=='endnotes'
- @seg[:headings]=[] #watch
+ @per.headings=[] #watch
txt_obj={ txt: 'Endnotes', ocn_display: ''}
format_seg=SiSU_XHTML_EPUB2_Format::FormatSeg.new(@md,txt_obj)
- @seg[:headings] << format_seg.title_heading1
- filename_seg << @seg[:heading_endnotes] << @seg[:headings] << %{\n<div class="content">\n} << @seg[:endnote_all] << '</div>'
+ @per.headings \
+ << format_seg.title_heading1
+ filename_seg \
+ << @per.heading_endnotes \
+ << @per.headings \
+ << %{\n<div class="content">\n} \
+ << @per.endnote_all \
+ << '</div>'
elsif @type=='idx'
- @seg[:headings]=[]
+ @per.headings=[]
txt_obj={ txt: 'Index', ocn_display: ''}
format_seg=SiSU_XHTML_EPUB2_Format::FormatSeg.new(@md,txt_obj)
- @seg[:headings] << format_seg.title_heading1
- filename_seg << @seg[:heading_idx] << @seg[:headings] << %{\n<div class="content">\n} << @seg[:idx] << '</div>'
+ @per.headings << format_seg.title_heading1
+ filename_seg \
+ << @per.heading_idx \
+ << @per.headings \
+ << %{\n<div class="content">\n} \
+ << @per.idx \
+ << '</div>'
elsif @type=='metadata'
metadata=SiSU_Metadata::Summary.new(@md).xhtml_display.metadata
- @seg[:headings]=[]
+ @per.headings=[]
txt_obj={ txt: 'Metadata', ocn_display: ''}
format_seg=SiSU_XHTML_EPUB2_Format::FormatSeg.new(@md,txt_obj)
- @seg[:headings] << format_seg.title_heading1
- filename_seg << @seg[:heading_idx] << @seg[:headings] << %{\n<div class="content">\n} << metadata << '</div>'
+ @per.headings \
+ << format_seg.title_heading1
+ filename_seg \
+ << @per.heading_idx \
+ << @per.headings \
+ << %{\n<div class="content">\n} \
+ << metadata \
+ << '</div>'
elsif @type=='sisu_manifest'
env=SiSU_Env::InfoEnv.new(@md.fns)
- path_and_name,url_and_name="#{env.path.output}/#{@md.fnb}/sisu_manifest.html","#{env.url.root}/#{@md.fnb}/sisu_manifest.html"
+ path_and_name,url_and_name= \
+ "#{env.path.output}/#{@md.fnb}/sisu_manifest.html",
+ "#{env.url.root}/#{@md.fnb}/sisu_manifest.html"
manifest=if FileTest.file?("#{path_and_name}")==true
<<WOK
<p>A list of available output types may be available at the following url:</p>
@@ -95,19 +118,32 @@ module SiSU_XHTML_EPUB2_Seg
WOK
else ''
end
- @seg[:headings]=[]
+ @per.headings=[]
txt_obj={ txt: 'Manifest', ocn_display: ''}
format_seg=SiSU_XHTML_EPUB2_Format::FormatSeg.new(@md,txt_obj)
- @seg[:headings] << format_seg.title_heading1
- filename_seg << @seg[:heading_idx] << @seg[:headings] << %{\n<div class="content">\n} << manifest << '</div>'
+ @per.headings \
+ << format_seg.title_heading1
+ filename_seg \
+ << @per.heading_idx \
+ << @per.headings \
+ << %{\n<div class="content">\n} \
+ << manifest \
+ << '</div>'
else
- filename_seg << @seg[:headings] << @seg[:main] << "\n</div>\n"
+ filename_seg \
+ << @per.headings \
+ << @per.main \
+ << "\n</div>\n"
end
- filename_seg << @seg[:tail] << @seg[:nav] << @seg[:close]
+ filename_seg \
+ << @per.tail \
+ << @per.nav \
+ << @per.closed
filename_seg=filename_seg.flatten.compact #watch
filename_seg.each do |str|
unless str =~/\A\s*\Z/
- @output_epub_cont_seg << str.strip
+ @output_epub_cont_seg \
+ << str.strip
end
end
@output_epub_cont_seg.close
@@ -115,68 +151,68 @@ WOK
end
end
class Seg
- @@seg,@@seg_subtoc,@@seg_endnotes,@@seg_ad={},{},{},{}
- @@seg_name,@@seg_name_xhtml=[],[]
- @@seg_url=@@fn=@@get_hash_to=@@get_hash_fn=''
- @@loop_count=@@seg_total=@@tracker=0
- @@is4=@@is3=@@is2=@@is1=@@is0=0
- @@heading0=@@heading1=@@heading2=@@heading3=@@heading4=0
- @@seg[:headings],@@seg[:main],@@seg[:idx],@@seg[:tail],@@seg_subtoc_array,@@seg_endnotes_array,@@seg[:endnote_all]=Array.new(7){[]}
- @@seg[:heading_endnotes]=''
- @@tablehead,@@number_of_cols=0,0
- @@fns_previous=''
- attr_reader :seg_name_xhtml,:seg_name_xhtml_tracker
+ @@seg_name=[]
+ @@seg_url=''
+ @@tracker=0
+ attr_reader :seg_name_x,:seg_name_x_tracker
def initialize(md='',data='')
@md,@data=md,data
- @seg_name_xhtml=@@seg_name_xhtml || nil
- @seg_name_xhtml_tracker=@@tracker || nil
+ @per=SiSU_XHTML_EPUB2_Persist::Persist.new
+ @seg_name_x=@per.seg_name_x=(@@seg_name || [])
+ @seg_name_x_tracker=@per.seg_name_x_tracker=(@@tracker || 0)
@make=SiSU_Env::ProcessingSettings.new(@md) if @md
end
def songsheet
begin
- data=get_subtoc_endnotes(@data)
- data=articles(data)
- SiSU_XHTML_EPUB2_Seg::Seg.new.cleanup # (((( added ))))
+ data=get_subtoc_endnotes(@data,@per)
+ data=articles(data,@per)
+ SiSU_XHTML_EPUB2_Seg::Seg.new.cleanup(@md,@per) # (((( added ))))
#### (((( END )))) ####
rescue
SiSU_Errors::Rescued.new($!,$@,@md.opt.selections.str,@md.fns).location do
__LINE__.to_s + ':' + __FILE__
end
ensure
- @@seg_name=[]
+ SiSU_XHTML_EPUB2_Persist::Persist.new.persist_init
+ @@seg_name=@per.seg_name=[]
end
end
protected
- def articles(data)
+ def articles(data,per)
+ @per=per
tracking,newfile=0,0
- @@is4=@@is3=@@is2=@@is1=@@is0=0
printed_endnote_seg='n'
idx_xhtml=nil
if @md.book_idx
- idx_xhtml=SiSU_Particulars::CombinedSingleton.instance.get_idx_xhtml(@md).xhtml_idx
- idx_xhtml.each {|x| @@seg[:idx] << x }
- @@seg[:heading_idx]=''
+ idx_xhtml=SiSU_Particulars::CombinedSingleton.
+ instance.get_idx_xhtml(@md).xhtml_idx
+ idx_xhtml.each do |x|
+ @per.idx << x
+ end
+ @per.heading_idx=''
end
data.each do |dob|
- if (dob.is==:heading \
- || dob.is==:heading_insert) \
- and dob.ln==4
+ if (dob.is == :heading \
+ || dob.is == :heading_insert) \
+ && dob.ln == 4
@@seg_name << dob.name
+ @per.seg_name = @@seg_name
dob.name
end
end
- @@seg_name_xhtml=@@seg_name
- @@seg_total=@@seg_name.length
- testforartnum=@@seg_name_xhtml
+ @per.seg_name_x=@per.seg_name
+ @per.seg_name.length
+ testforartnum=@per.seg_name_x
if (@md.opt.act[:verbose][:set]==:on \
|| @md.opt.act[:verbose_plus][:set]==:on \
|| @md.opt.act[:maintenance][:set]==:on)
SiSU_Screen::Ansi.new(
@md.opt.act[:color_state][:set],
- @@seg_name.length
+ @per.seg_name.length
)
end
- SiSU_Particulars::CombinedSingleton.instance.get_map_nametags(@md).nametags_map #p map_nametags
+ SiSU_Particulars::CombinedSingleton.
+ instance.get_map_nametags(@md).nametags_map #p map_nametags
data.each do |dob|
#if defined? dob.obj \
#and dob.obj =~/href="#{Xx[:segment]}#+\S+?"/
@@ -194,41 +230,41 @@ WOK
if (dob.is==:heading \
|| dob.is==:heading_insert) \
&& dob.ln==4
- @@heading4=dob.obj
- @@is4=newfile=1
+ @per.heading4=dob.obj
+ @per.is4=newfile=1
end
if (dob.is==:heading \
|| dob.is==:heading_insert) \
&& dob.ln==3
- @@heading3=dob.obj
- @@is4,@@is3=0,1
+ @per.heading3=dob.obj
+ @per.is4,@per.is3=0,1
end
if (dob.is==:heading \
|| dob.is==:heading_insert) \
&& dob.ln==2
- @@heading2=dob.obj
- @@is4,@@is3,@@is2=0,0,1
+ @per.heading2=dob.obj
+ @per.is4,@per.is3,@per.is2=0,0,1
end
if (dob.is==:heading \
|| dob.is==:heading_insert) \
&& dob.ln==1
- @@heading1=dob.obj
- @@is4,@@is3,@@is2,@@is1=0,0,0,1
+ @per.heading1=dob.obj
+ @per.is4,@per.is3,@per.is2,@per.is1=0,0,0,1
end
if (dob.is==:heading \
|| dob.is==:heading_insert) \
&& dob.ln==0
- @@heading0=dob.obj
- @@is4,@@is3,@@is2,@@is1,@@is0=0,0,0,0,1
+ @per.heading0=dob.obj
+ @per.is4,@per.is3,@per.is2,@per.is1,@per.is0=0,0,0,0,1
end
- if (@@is0 && !@@is1 && !@@is2 && !@@is3 && !@@is4)
+ if (@per.is0 && !@per.is1 && !@per.is2 && !@per.is3 && !@per.is4)
if not (dob.is==:heading \
|| dob.is==:heading_insert) \
&& dob.ln==0
$_ #; check
end
end
- if @@is4==1
+ if @per.is4==1
dir_epub_cont="#{@md.env.processing_path.epub}/#{Ep[:d_oebps]}"
if newfile==1 \
or dob.obj =~/^#{Mx[:br_endnotes]}|^#{Mx[:br_eof]}/
@@ -237,34 +273,36 @@ WOK
|| dob.is==:heading_insert) \
&& dob.ln==4
if tracking != 0
- SiSU_XHTML_EPUB2_Seg::Seg.new(@md).tail
- segfilename="#{dir_epub_cont}/#{@@seg_name_xhtml[tracking-1]}#{Sfx[:epub_xhtml]}"
- output_epub_cont_seg=File.new(segfilename,'w') if @@seg_name_xhtml[tracking-1]
+ tail(@md,@per)
+ #SiSU_XHTML_EPUB2_Seg::Seg.new(@md,@per).tail
+ segfilename="#{dir_epub_cont}/#{@per.seg_name_x[tracking-1]}#{Sfx[:epub_xhtml]}"
+ output_epub_cont_seg=File.new(segfilename,'w') if @per.seg_name_x[tracking-1]
if dob.is==:heading \
- or @@seg_name_xhtml[tracking-1] !~/endnotes|book_index|metadata/
- SiSU_XHTML_EPUB2_Seg::Output.new(@md,output_epub_cont_seg,@@seg).output
+ or @per.seg_name_x[tracking-1] !~/endnotes|book_index|metadata/
+ SiSU_XHTML_EPUB2_Seg::Output.new(@md,output_epub_cont_seg,@per).output
elsif dob.is==:heading_insert
- if @@seg_name_xhtml[tracking-1]=='endnotes'
- SiSU_XHTML_EPUB2_Seg::Output.new(@md,output_epub_cont_seg,@@seg,'endnotes').output
- elsif @@seg_name_xhtml[tracking-1]=='book_index'
- SiSU_XHTML_EPUB2_Seg::Output.new(@md,output_epub_cont_seg,@@seg,'idx').output
- @@seg[:idx]=[]
- elsif @@seg_name_xhtml[tracking-1]=='metadata' # navigation bug FIX
- SiSU_XHTML_EPUB2_Seg::Output.new(@md,output_epub_cont_seg,@@seg,'metadata').output
+ if @per.seg_name_x[tracking-1]=='endnotes'
+ SiSU_XHTML_EPUB2_Seg::Output.new(@md,output_epub_cont_seg,@per,'endnotes').output
+ elsif @per.seg_name_x[tracking-1]=='book_index'
+ SiSU_XHTML_EPUB2_Seg::Output.new(@md,output_epub_cont_seg,@per,'idx').output
+ @per.idx=[]
+ elsif @per.seg_name_x[tracking-1]=='metadata' # navigation bug FIX
+ SiSU_XHTML_EPUB2_Seg::Output.new(@md,output_epub_cont_seg,@per,'metadata').output
else puts "#{__FILE__}::#{__LINE__}"
end
else puts "#{__FILE__}::#{__LINE__}"
end
- SiSU_XHTML_EPUB2_Seg::Seg.new.reinitialise
+ SiSU_XHTML_EPUB2_Seg::Seg.new.reinitialise(per)
heading_art(dob)
head(dob)
- if @@seg_name_xhtml[tracking] =='metadata'
- segfilename="#{dir_epub_cont}/#{@@seg_name_xhtml[tracking]}#{Sfx[:epub_xhtml]}"
+ if @per.seg_name_x[tracking] =='metadata'
+ segfilename="#{dir_epub_cont}/#{@per.seg_name_x[tracking]}#{Sfx[:epub_xhtml]}"
output_epub_cont_seg=File.new(segfilename,'w')
- SiSU_XHTML_EPUB2_Seg::Output.new(@md,output_epub_cont_seg,@@seg,'metadata').output
- SiSU_XHTML_EPUB2_Seg::Seg.new.reinitialise #BUG navigation bug with items following metadata, and occurring before manifest, this becomes a bug ... work area for book index, FIX
+ SiSU_XHTML_EPUB2_Seg::Output.new(@md,output_epub_cont_seg,@per,'metadata').output
+ SiSU_XHTML_EPUB2_Seg::Seg.new.reinitialise(per)
+ #BUG navigation bug with items following metadata, and occurring before manifest, this becomes a bug ... work area for book index, FIX
end
- #@output_epub_cont_seg.close #%(((( EOF )))) -->
+ #@output_epub_cont_seg.closed #%(((( EOF )))) -->
end
if tracking==0
heading_art(dob)
@@ -277,8 +315,8 @@ WOK
|| dob.is==:heading_insert) \
&& dob.ln==4 \
&& dob.name
- @@get_hash_to=dob.name
- @@get_hash_fn=dob.name
+ @per.get_hash_to=dob.name
+ @per.get_hash_fn=dob.name
end
if dob.obj.is_a?(String)
markup(dob)
@@ -297,51 +335,56 @@ WOK
data
end
def heading_art(dob)
- @@seg[:title]=SiSU_XHTML_EPUB2_Format::HeadSeg.new(@md).head
+ @per.title=SiSU_XHTML_EPUB2_Format::HeadSeg.new(@md).head
end
def head(dob)
clean=/<!.*?!>|<:.*?>$/
@p_num ||= ''
- if @@is0==1
+ if @per.is0==1
if defined? @md.creator.author \
and @md.creator.author
@author=%{<b>#{@md.creator.author}</b>\n}
end
@p_num=SiSU_XHTML_EPUB2_Format::ParagraphNumber.new(@md,dob.ocn)
- txt_obj={ txt: @@heading0, ocn_display: @p_num.ocn_display }
+ txt_obj={ txt: @per.heading0, ocn_display: @p_num.ocn_display }
format_seg=SiSU_XHTML_EPUB2_Format::FormatSeg.new(@md,txt_obj)
- @@seg[:headings] << format_seg.title_heading0.gsub(clean,'')
- @@heading0=@@heading0.gsub(/#{$ep[:hsp]}<a name="-[\d*+]+" href="#_[\d*+]+">#{$ep[:hsp]}<sup>[\d*+]+<\/sup>#{$ep[:hsp]}<\/a>/,'')
+ @per.headings << format_seg.title_heading0.gsub(clean,'')
+ @per.heading0=@per.heading0.
+ gsub(/#{$ep[:hsp]}<a name="-[\d*+]+" href="#_[\d*+]+">#{$ep[:hsp]}<sup>[\d*+]+<\/sup>#{$ep[:hsp]}<\/a>/,'')
end
- if @@is1==1
+ if @per.is1==1
@p_num=SiSU_XHTML_EPUB2_Format::ParagraphNumber.new(@md,dob.ocn)
- txt_obj={ txt: @@heading1, ocn_display: @p_num.ocn_display }
+ txt_obj={ txt: @per.heading1, ocn_display: @p_num.ocn_display }
format_seg=SiSU_XHTML_EPUB2_Format::FormatSeg.new(@md,txt_obj)
- @@seg[:headings] << format_seg.title_heading1.gsub(clean,'')
- @@heading1=@@heading1.gsub(/#{$ep[:hsp]}<a name="-[\d*+]+" href="#_[\d*+]+">#{$ep[:hsp]}<sup>[\d*+]+<\/sup>#{$ep[:hsp]}<\/a>/,'')
+ @per.headings << format_seg.title_heading1.gsub(clean,'')
+ @per.heading1=@per.heading1.
+ gsub(/#{$ep[:hsp]}<a name="-[\d*+]+" href="#_[\d*+]+">#{$ep[:hsp]}<sup>[\d*+]+<\/sup>#{$ep[:hsp]}<\/a>/,'')
end
- if @@is2==1
- heading2=@@heading2
+ if @per.is2==1
+ heading2=@per.heading2
@p_num=SiSU_XHTML_EPUB2_Format::ParagraphNumber.new(@md,dob.ocn)
txt_obj={ txt: heading2, ocn_display: @p_num.ocn_display }
format_seg=SiSU_XHTML_EPUB2_Format::FormatSeg.new(@md,txt_obj)
- @@seg[:headings] << format_seg.title_heading2.gsub(clean,'')
- @@heading2=@@heading2.gsub(/#{$ep[:hsp]}<a name="-[\d*+]+" href="#_[\d*+]+">#{$ep[:hsp]}<sup>[\d*+]+<\/sup>#{$ep[:hsp]}<\/a>/,'')
+ @per.headings << format_seg.title_heading2.gsub(clean,'')
+ @per.heading2=@per.heading2.
+ gsub(/#{$ep[:hsp]}<a name="-[\d*+]+" href="#_[\d*+]+">#{$ep[:hsp]}<sup>[\d*+]+<\/sup>#{$ep[:hsp]}<\/a>/,'')
end
- if @@is3==1
- heading3=@@heading3
+ if @per.is3==1
+ heading3=@per.heading3
@p_num=SiSU_XHTML_EPUB2_Format::ParagraphNumber.new(@md,dob.ocn)
txt_obj={ txt: heading3, ocn_display: @p_num.ocn_display }
format_seg=SiSU_XHTML_EPUB2_Format::FormatSeg.new(@md,txt_obj)
- @@seg[:headings] << format_seg.title_heading3.gsub(clean,'')
- @@heading3=@@heading3.gsub(/#{$ep[:hsp]}<a name="-[\d*+]+" href="#_[\d*+]+">#{$ep[:hsp]}<sup>[\d*+]+<\/sup>#{$ep[:hsp]}<\/a>/,'')
+ @per.headings << format_seg.title_heading3.gsub(clean,'')
+ @per.heading3=@per.heading3.
+ gsub(/#{$ep[:hsp]}<a name="-[\d*+]+" href="#_[\d*+]+">#{$ep[:hsp]}<sup>[\d*+]+<\/sup>#{$ep[:hsp]}<\/a>/,'')
end
- if @@is4==1
- heading4=@@heading4
+ if @per.is4==1
+ heading4=@per.heading4
@p_num=SiSU_XHTML_EPUB2_Format::ParagraphNumber.new(@md,dob.ocn)
txt_obj={ txt: heading4, ocn_display: @p_num.ocn_display }
format_seg=SiSU_XHTML_EPUB2_Format::FormatSeg.new(@md,txt_obj)
- @@seg[:headings] << format_seg.title_heading4.gsub(clean,'')
+ @per.headings \
+ << format_seg.title_heading4.gsub(clean,'')
end
@@tracker=@@tracker+1
end
@@ -400,7 +443,9 @@ WOK
sto.break
end
if @md.flag_separate_endnotes # may need to revisit, check
- dob.obj=dob.obj.gsub(/"\s+href="##{Mx[:note_ref]}(\d+)">/,%{" href=\"endnotes#{Sfx[:epub_xhtml]}##{Mx[:note_ref]}\\1">}) #endnote- twice #removed file type
+ dob.obj=dob.obj.gsub(/"\s+href="##{Mx[:note_ref]}(\d+)">/,
+ %{" href=\"endnotes#{Sfx[:epub_xhtml]}##{Mx[:note_ref]}\\1">})
+ #endnote- twice #removed file type
end
if (dob.is ==:heading \
|| dob.is==:heading_insert \
@@ -411,77 +456,82 @@ WOK
if (dob.is==:heading \
|| dob.is==:heading_insert \
|| dob.is==:para) \
- and dob.note_ #dob.obj =~/<a href="#note_ref\d+">&nbsp;<sup id=/ #endnote- note-
+ and dob.note_
+ #dob.obj =~/<a href="#note_ref\d+">&nbsp;<sup id=/ #endnote- note-
format_seg=SiSU_XHTML_EPUB2_Format::FormatSeg.new(@md,dob)
dob.obj=format_seg.no_paranum
end
if (dob.is==:heading \
|| dob.is==:heading_insert) \
and dob.ln==4
- @@seg[:main] << %{\n<div class="content">\n}
- @@seg[:main] << dob_xhtml
+ @per.main << %{\n<div class="content">\n}
+ @per.main << dob_xhtml
if @make.build.segsubtoc?
- @@seg[:main] << @@seg_subtoc[@@get_hash_fn] #% insertion of sub-toc
+ @per.main << @per.seg_subtoc[@per.get_hash_fn]
+ #% insertion of sub-toc
end
else
- @@seg[:main] << dob_xhtml
+ @per.main << dob_xhtml
end
end
- def tail
+ def tail(md,per)
+ @md,@per=md,per
format_head_seg=SiSU_XHTML_EPUB2_Format::HeadSeg.new(@md)
if @md.flag_auto_endnotes \
- and @@seg_endnotes[@@get_hash_fn]
- @@seg[:tail] << %{\n<div class="content">\n<div class="endnote">\n}
- if @@seg_endnotes[@@get_hash_fn].flatten.length > 0
- @@seg[:tail] << format_head_seg.endnote_mark
- @@seg[:tail] << @@seg_endnotes[@@get_hash_fn].flatten #endnotes deposited at end of individual segments ||@|EXTRACTION OF ENDNOTES|
+ and @per.seg_endnotes[@per.get_hash_fn]
+ @per.tail << %{\n<div class="content">\n<div class="endnote">\n}
+ if @per.seg_endnotes[@per.get_hash_fn].flatten.length > 0
+ @per.tail << format_head_seg.endnote_mark
+ @per.tail << @per.seg_endnotes[@per.get_hash_fn].flatten
+ #endnotes deposited at end of individual segments ||@|EXTRACTION OF ENDNOTES|
end
- @@seg[:tail] << '</div>'
- @@seg[:tail] << '</div>' #this div closes div class content
+ @per.tail << '</div>'
+ @per.tail << '</div>' #this div closes div class content
end
- @@seg[:close]=[]
- @@seg[:close] << format_head_seg.xhtml_close
+ @per.closed=[]
+ @per.closed << format_head_seg.xhtml_close
end
- def reinitialise
- @@seg[:headings],@@seg[:main],@@seg[:tail],@@seg[:credits]=Array.new(4){[]}
+ def reinitialise(per)
+ per.headings,per.main,per.tail,per.credits=Array.new(4){[]}
end
- def cleanup
- reinitialise
- @@seg_total,@@tracker=0,0
- @@seg_endnotes,@@seg_subtoc={},{}
- @@seg_endnotes_array,@@seg_subtoc_array=[],[]
- @@seg[:endnote_all]=[]
+ def cleanup(md,per)
+ reinitialise(per)
+ @@tracker=0
+ @per.seg_endnotes,@per.seg_subtoc={},{}
+ @per.seg_endnotes_array,@per.seg_subtoc_array=[],[]
+ per.endnote_all=[]
end
- def get_subtoc_endnotes(data) #get endnotes & sub-table of contents subtoc
+ def get_subtoc_endnotes(data,per) #get endnotes & sub-table of contents subtoc
+ @per=per
data.each do |dob|
dob.obj=dob.obj.gsub(/<a name=\"h\d.*?\">(.+?)<\/a>/mi,'\1')
if @md.flag_auto_endnotes
if (dob.is==:heading \
|| dob.is==:heading_insert) \
- and dob.ln.to_s =~/^[1234]/ \
- and not @@fn.to_s.empty?
- @@seg_endnotes[@@fn]=[]
- @@seg_endnotes[@@fn] << @@seg_endnotes_array
- @@seg_endnotes_array=[] if dob.ln==4
- @@fns_previous=@md.fns if dob.ln==4 and dob.name =~/^meta/
+ && dob.ln.to_s =~/^[1-4]/ \
+ and not @per.fn.to_s.empty?
+ @per.seg_endnotes[@per.fn]=[]
+ @per.seg_endnotes[@per.fn] << @per.seg_endnotes_array
+ @per.seg_endnotes_array=[] if dob.ln==4
end
if (dob.is==:heading \
|| dob.is==:heading_insert) \
- and dob.ln==4 #% EXTRACTION OF SUB-TOCs & SEGMENT NAME, after EXTRACTION OF ENDNOTES & SUB-TOCs
- @@seg_subtoc[@@fn]=@@seg_subtoc_array
- @@seg_subtoc_array=[]
+ && dob.ln==4
+ #% EXTRACTION OF SUB-TOCs & SEGMENT NAME, after EXTRACTION OF ENDNOTES & SUB-TOCs
+ @per.seg_subtoc[@per.fn]=@per.seg_subtoc_array
+ @per.seg_subtoc_array=[]
if dob.name \
and dob.obj
- @@fn=dob.name
+ @per.fn=dob.name
else
- @@fn=(dob.name =~/\S+/) \
+ @per.fn=(dob.name =~/\S+/) \
? dob.name
: ''
end
end
end
if dob.is==:heading \
- and dob.ln.to_s =~/^[5-7]/
+ && dob.ln.to_s =~/^[5-7]/
case dob.ln
when 5
format_seg=SiSU_XHTML_EPUB2_Format::FormatSeg.new(@md,dob)
@@ -493,7 +543,7 @@ WOK
format_seg=SiSU_XHTML_EPUB2_Format::FormatSeg.new(@md,dob)
subtoc=format_seg.subtoc_lev7 #keep and make available, this is the subtoc
end
- @@seg_subtoc_array << subtoc
+ @per.seg_subtoc_array << subtoc
end
if @md.flag_auto_endnotes
ast,pls='&#042;','&#043;'
@@ -504,17 +554,19 @@ WOK
endnote_array << dob.obj.scan(/#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}/m)
end
if dob.obj=~/#{Mx[:en_b_o]}#{ast}\d+\s.+?#{Mx[:en_b_c]}/m
- endnote_array << dob.obj.scan(/#{Mx[:en_b_o]}#{ast}\d+\s.+?#{Mx[:en_b_c]}/m)
+ endnote_array \
+ << dob.obj.scan(/#{Mx[:en_b_o]}#{ast}\d+\s.+?#{Mx[:en_b_c]}/m)
end
if dob.obj=~/#{Mx[:en_b_o]}#{pls}\d+\s.+?#{Mx[:en_b_c]}/m
- endnote_array << dob.obj.scan(/#{Mx[:en_b_o]}#{pls}\d+\s.+?#{Mx[:en_b_c]}/m)
+ endnote_array \
+ << dob.obj.scan(/#{Mx[:en_b_o]}#{pls}\d+\s.+?#{Mx[:en_b_c]}/m)
end
endnote_array=endnote_array.flatten #.compact #check compacting
endnote_array.each do |note|
note_match=note.dup
note_match_seg=note.dup
e_n=note_match_seg[/(?:#{Mx[:en_a_o]}(?:\d|#{ast}|#{pls})+|#{Mx[:en_b_o]}(?:#{ast}|#{pls})\d+)\s+(.+?)(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/m,1]
- try=e_n.split(/<br \/>/)
+ try=e_n.split(/<br(?: \/)?>/)
try.each do |e|
txt_obj={ txt: e }
format_seg=SiSU_XHTML_EPUB2_Format::FormatSeg.new(@md,txt_obj)
@@ -522,17 +574,20 @@ WOK
format_seg.endnote_body_indent
else format_seg.endnote_body
end
- @@seg_endnotes_array << note_match
+ @per.seg_endnotes_array << note_match
end
try.join('<br \/>')
#% creation of separate end segment/page of all endnotes referenced back to reference segment
m=/(?:#{Mx[:en_a_o]}(?:\d|#{ast}|#{pls})+|#{Mx[:en_b_o]}(?:#{ast}|#{pls})\d+)\s+(.+?href=")(##{Mx[:note_ref]}(?:\d|_a|_b)+".+)(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/mi
endnote_part_a=note_match_seg[m,1]
endnote_part_b=note_match_seg[m,2]
- txt_obj={ endnote_part_a: endnote_part_a, endnote_part_b: endnote_part_b }
+ txt_obj={
+ endnote_part_a: endnote_part_a,
+ endnote_part_b: endnote_part_b
+ }
format_seg=SiSU_XHTML_EPUB2_Format::FormatSeg.new(@md,txt_obj)
- note_match_all_seg=format_seg.endnote_seg_body(@@fn) #BUG WATCH 200408
- @@seg[:endnote_all] << note_match_all_seg
+ note_match_all_seg=format_seg.endnote_seg_body(@per.fn) #BUG WATCH 200408
+ @per.endnote_all << note_match_all_seg
end
dob.obj=dob.obj.gsub(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ')
end
diff --git a/lib/sisu/current/xhtml_parts.rb b/lib/sisu/current/xhtml_parts.rb
index 3a7cff0..a031527 100644
--- a/lib/sisu/current/xhtml_parts.rb
+++ b/lib/sisu/current/xhtml_parts.rb
@@ -174,7 +174,7 @@ module SiSU_Proj_XHTML
end
def credits_sisu_epub
%{<div class="substance">
-<p class="center"><a href="http://www.openebook.org"><b>EPUB</b></a> generated by <a href="http://www.sisudoc.org"><b>#{@v[:project]}</b></a> v#{@v[:version]}, GPL3</p>
+<p class="center"><a href="http://www.openebook.org"><b>EPUB</b></a> generated by <a href="http://www.sisudoc.org"><b>#{@v.project}</b></a> v#{@v.version}, GPL3</p>
</div>}
''
end
diff --git a/lib/sisu/current/xhtml_table.rb b/lib/sisu/current/xhtml_table.rb
index 42698f0..84e4bd9 100644
--- a/lib/sisu/current/xhtml_table.rb
+++ b/lib/sisu/current/xhtml_table.rb
@@ -58,7 +58,6 @@ module SiSU_XHTML_Table
require_relative 'xhtml_parts' # xhtml_parts.rb
class TableXHTML
include SiSU_Parts_XHTML
- @@tablehead=0
@@tablefoot=[] #watch
def initialize(table)
@table_obj=table
diff --git a/lib/sisu/current/xml_dom.rb b/lib/sisu/current/xml_dom.rb
index 9707dee..766b289 100644
--- a/lib/sisu/current/xml_dom.rb
+++ b/lib/sisu/current/xml_dom.rb
@@ -64,10 +64,11 @@ module SiSU_XML_DOM
include SiSU_XML_Munge
require_relative 'xml_format' # xml_format.rb
include SiSU_XML_Format
+ require_relative 'xml_persist' # xml_persist.rb
require_relative 'rexml' # rexml.rb
include SiSU_Rexml
require_relative 'shared_metadata' # shared_metadata.rb
- @@alt_id_count,@@tablehead,@@number_of_cols=0,0,0
+ @@alt_id_count=0
@@tablefoot=''
class Source
def initialize(opt)
@@ -158,18 +159,22 @@ module SiSU_XML_DOM
require_relative 'txt_shared' # txt_shared.rb
include SiSU_TextUtils
require_relative 'xhtml_shared' # decide use, whether xml rather than xhtml
- @@xml={ body: [], open: [], close: [], head: [], sc: [] }
def initialize(particulars)
@env, @md, @ao_arr=
particulars.env,particulars.md,particulars.ao_array
@trans=SiSU_XML_Munge::Trans.new(@md)
@sys=SiSU_Env::SystemCall.new
+ @per=SiSU_XML_Persist::Persist.new
end
def songsheet
- pre
- @data=markup(@ao_arr)
- post
- publish
+ begin
+ pre
+ @data=markup(@ao_arr)
+ post
+ publish
+ ensure
+ SiSU_XML_Persist::Persist.new.persist_init
+ end
end
protected
def xml_markup(dob='')
@@ -182,7 +187,7 @@ module SiSU_XML_DOM
end
def xml_head
metadata=SiSU_Metadata::Summary.new(@md).xml_dom.metadata
- @@xml[:head] << metadata
+ @per.head << metadata
end
def xml_sc(md='')
sc=if @md.sc_info
@@ -204,7 +209,7 @@ module SiSU_XML_DOM
WOK
else ''
end
- @@xml[:sc]=sc
+ @per.sc=sc
end
def xml_element(dob,xml_el='',xml_content='',type='norm')
n=n1=n2=n3=0
@@ -221,7 +226,7 @@ WOK
else ''
end
xml_el ||=''
- @@xml[:body] <<<<WOK
+ @per.body <<<<WOK
#{Ax[:tab]*n}#{xml_el}
#{Ax[:tab]*n1}<heading>
#{Ax[:tab]*n2}<object id="#{dob.ocn}">
@@ -262,26 +267,26 @@ WOK
if @cont[1] \
or @cont[2] \
or @cont[3]
- @@xml[:body] << "#{Ax[:tab]*5}</content>"
+ @per.body << "#{Ax[:tab]*5}</content>"
end
@cont[1]=false if @cont[1]
@cont[2]=false if @cont[2]
@cont[3]=false if @cont[3]
####### attempt to close contents
if @copen[4] # 4~
- [4,3,2,1].each { |v| @@xml[:body] << "#{Ax[:tab]*n}</contents#{v}>" }
+ [4,3,2,1].each { |v| @per.body << "#{Ax[:tab]*n}</contents#{v}>" }
@copen[1]=@copen[2]=@copen[3]=@copen[4]=false
elsif @copen[3] # 3~
- [3,2,1].each { |v| @@xml[:body] << "#{Ax[:tab]*n}</contents#{v}>" }
+ [3,2,1].each { |v| @per.body << "#{Ax[:tab]*n}</contents#{v}>" }
@copen[1]=@copen[2]=@copen[3]=false
elsif @copen[2] # 2~
- [2,1].each { |v| @@xml[:body] << "#{Ax[:tab]*n}</contents#{v}>" }
+ [2,1].each { |v| @per.body << "#{Ax[:tab]*n}</contents#{v}>" }
@copen[1]=@copen[2]=@copen[3]=false
elsif @copen[1] # 1~
- [1].each { |v| @@xml[:body] << "#{Ax[:tab]*n}</contents#{v}>" }
+ [1].each { |v| @per.body << "#{Ax[:tab]*n}</contents#{v}>" }
@copen[1]=@copen[2]=@copen[3]=false
end
- @@xml[:body] << "#{Ax[:tab]*y}</heading#{x}>" if @level[x]
+ @per.body << "#{Ax[:tab]*y}</heading#{x}>" if @level[x]
@level[x]=false
end
when 4..7
@@ -295,29 +300,29 @@ WOK
xml_content="\n#{Ax[:tab]*5}<content>"
case lv
when 4
- @@xml[:body] << "#{Ax[:tab]*5}</content>" if @cont[1]
+ @per.body << "#{Ax[:tab]*5}</content>" if @cont[1]
if @copen[4]==true # 4~
- [4,3,2,1].each { |v| @@xml[:body] << "#{Ax[:tab]*n}</contents#{v}>" }
+ [4,3,2,1].each { |v| @per.body << "#{Ax[:tab]*n}</contents#{v}>" }
elsif @copen[3]==true # 3~
- [3,2,1].each { |v| @@xml[:body] << "#{Ax[:tab]*n}</contents#{v}>" }
+ [3,2,1].each { |v| @per.body << "#{Ax[:tab]*n}</contents#{v}>" }
elsif @copen[2]==true # 2~
- [2,1].each { |v| @@xml[:body] << "#{Ax[:tab]*n}</contents#{v}>" }
+ [2,1].each { |v| @per.body << "#{Ax[:tab]*n}</contents#{v}>" }
elsif @copen[1]==true # 1~
- [1].each { |v| @@xml[:body] << "#{Ax[:tab]*n}</contents#{v}>" }
+ [1].each { |v| @per.body << "#{Ax[:tab]*n}</contents#{v}>" }
end
@cont[1]=true
when 5
if @cont[3] \
or @cont[2] \
or @cont[1]
- @@xml[:body] << "#{Ax[:tab]*5}</content>"
+ @per.body << "#{Ax[:tab]*5}</content>"
end
if @copen[4]==true #4~
- [4,3,2].each { |v| @@xml[:body] << "#{Ax[:tab]*n}</contents#{v}>" }
+ [4,3,2].each { |v| @per.body << "#{Ax[:tab]*n}</contents#{v}>" }
elsif @copen[3]==true #3~
- [3,2].each { |v| @@xml[:body] << "#{Ax[:tab]*n}</contents#{v}>" }
+ [3,2].each { |v| @per.body << "#{Ax[:tab]*n}</contents#{v}>" }
elsif @copen[2]==true #2~
- [2].each { |v| @@xml[:body] << "#{Ax[:tab]*n}</contents#{v}>" }
+ [2].each { |v| @per.body << "#{Ax[:tab]*n}</contents#{v}>" }
end
@cont[2]=true
when 6
@@ -325,12 +330,12 @@ WOK
or @cont[3] \
or @cont[2] \
or @cont[1]
- @@xml[:body] << "#{Ax[:tab]*5}</content>"
+ @per.body << "#{Ax[:tab]*5}</content>"
end
if @copen[4] #4~
- [4,3].each { |v| @@xml[:body] << "#{Ax[:tab]*n}</contents#{v}>" }
+ [4,3].each { |v| @per.body << "#{Ax[:tab]*n}</contents#{v}>" }
elsif @copen[3] #3~
- [3].each { |v| @@xml[:body] << "#{Ax[:tab]*n}</contents#{v}>" }
+ [3].each { |v| @per.body << "#{Ax[:tab]*n}</contents#{v}>" }
end
@cont[3]=true
when 7
@@ -338,10 +343,10 @@ WOK
or @cont[3] \
or @cont[2] \
or @cont[1]
- @@xml[:body] << "#{Ax[:tab]*5}</content>"
+ @per.body << "#{Ax[:tab]*5}</content>"
end
if @copen[4] #4~
- [4].each { |v| @@xml[:body] << "#{Ax[:tab]*n}</contents#{v}>" }
+ [4].each { |v| @per.body << "#{Ax[:tab]*n}</contents#{v}>" }
end
@cont[4]=true
end
@@ -357,15 +362,15 @@ WOK
if defined? dob.obj # main text, contents, body KEEP
if defined? dob.ocn \
and dob.ocn
- @@xml[:body] << %{#{Ax[:tab]*6}<object id="#{dob.ocn}">}
- @@xml[:body] << %{#{Ax[:tab]*7}<ocn>#{dob.ocn}</ocn>} if defined? dob.ocn
+ @per.body << %{#{Ax[:tab]*6}<object id="#{dob.ocn}">}
+ @per.body << %{#{Ax[:tab]*7}<ocn>#{dob.ocn}</ocn>} if defined? dob.ocn
end
- #@@xml[:body] << %{#{Ax[:tab]*7}<text class="#{type}">#{dob.obj}</text>}
- #@@xml[:body] << %{#{Ax[:tab]*7}<text class="#{dob.is}">#{Ax[:tab]*1}}
- @@xml[:body] << %{#{Ax[:tab]*7}<text class="#{type}">#{Ax[:tab]*1}}
- @@xml[:body] << %{#{Ax[:tab]*8}#{dob.obj}#{Ax[:tab]*1}}
- @@xml[:body] << %{#{Ax[:tab]*7}</text>}
- @@xml[:body] << %{#{Ax[:tab]*6}</object>}
+ #@per.body << %{#{Ax[:tab]*7}<text class="#{type}">#{dob.obj}</text>}
+ #@per.body << %{#{Ax[:tab]*7}<text class="#{dob.is}">#{Ax[:tab]*1}}
+ @per.body << %{#{Ax[:tab]*7}<text class="#{type}">#{Ax[:tab]*1}}
+ @per.body << %{#{Ax[:tab]*8}#{dob.obj}#{Ax[:tab]*1}}
+ @per.body << %{#{Ax[:tab]*7}</text>}
+ @per.body << %{#{Ax[:tab]*6}</object>}
end
end
def block_structure(dob)
@@ -523,16 +528,16 @@ WOK
y=x - 1; v=x - 3
if @level[x]==true #2004w36 bug fix? watch/test previous logic broke on free.for.all @coontent_flag introduced
if @content_flag==true
- @@xml[:body] << "#{Ax[:tab]*5}</content>\n#{Ax[:tab]*y}</contents#{v}>"
+ @per.body << "#{Ax[:tab]*5}</content>\n#{Ax[:tab]*y}</contents#{v}>"
@content_flag=false
else
- @@xml[:body] << "\n#{Ax[:tab]*y}</contents#{v}>"
+ @per.body << "\n#{Ax[:tab]*y}</contents#{v}>"
end
end
end
3.downto(1) do |x|
y=x - 1
- @@xml[:body] << "#{Ax[:tab]*y}</heading#{x}>" if @level[x]==true
+ @per.body << "#{Ax[:tab]*y}</heading#{x}>" if @level[x]==true
end
end
def pre
@@ -541,29 +546,28 @@ WOK
encoding=if @sys.locale =~/utf-?8/i then '<?xml version="1.0" encoding="UTF-8" standalone="no"?>'
else '<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>'
end
- @@xml[:open] =<<WOK
+ @per.open =<<WOK
#{encoding}
#{stylesheet.css_head_xml}
#{rdf.comment_xml}
<document>
WOK
- @@xml[:head] << '<head>'
- @@xml[:body] << '<body>'
+ @per.head << '<head>'
+ @per.body << '<body>'
end
def post
- @@xml[:head] << @@xml[:sc]
- @@xml[:head] << '</head>'
- @@xml[:body] << '</body>'
- @@xml[:close] = '</document>'
+ @per.head << @per.sc
+ @per.head << '</head>'
+ @per.body << '</body>'
+ @per.close << '</document>'
end
def publish
content=[]
- content << @@xml[:open] << @@xml[:head] << @@xml[:body] << @@xml[:metadata]
- content << @@xml[:owner_details] if @md.stmp =~/\w\w/
- content << @@xml[:tail] << @@xml[:close]
+ content << @per.open << @per.head << @per.body # << @per.metadata
+ content << @per.tail << @per.close
content=content.flatten.compact
Output.new(content,@md).xml
- @@xml[:head],@@xml[:body],@@xml[:tail]=[],[],[] # check whether should be nil
+ @per.head,@per.body,@per.tail=[],[],[] # check whether should be nil
end
end
class Output
@@ -591,19 +595,21 @@ WOK
if @prog.tidy !=false
if (@md.opt.act[:verbose_plus][:set]==:on \
|| @md.opt.act[:maintenance][:set]==:on)
- SiSU_Screen::Ansi.new(
- @md.opt.act[:color_state][:set],
- 'invert',
- 'Using XML Tidy',
- 'check document structure'
- ).colorize unless @md.opt.act[:quiet][:set]==:on
- tell=SiSU_Screen::Ansi.new(
- @md.opt.act[:color_state][:set],
- 'invert',
- '',
- ''
- )
- tell.grey_open unless @md.opt.act[:quiet][:set]==:on
+ unless @md.opt.act[:quiet][:set]==:on
+ SiSU_Screen::Ansi.new(
+ @md.opt.act[:color_state][:set],
+ 'invert',
+ 'Using XML Tidy',
+ 'check document structure'
+ ).colorize
+ tell=SiSU_Screen::Ansi.new(
+ @md.opt.act[:color_state][:set],
+ 'invert',
+ '',
+ ''
+ )
+ tell.grey_open
+ end
tidyfile='/dev/null' #don't want one or screen output, check for alternative flags
tidy=SiSU_Env::SystemCall.new(@file,tidyfile)
tidy.well_formed?
diff --git a/lib/sisu/current/xml_fictionbook2.rb b/lib/sisu/current/xml_fictionbook2.rb
index f8c0ed6..39de0e5 100644
--- a/lib/sisu/current/xml_fictionbook2.rb
+++ b/lib/sisu/current/xml_fictionbook2.rb
@@ -204,8 +204,8 @@ module SiSU_XML_Fictionbook
<last-name/>
<nickname/>
</author>
- <program-used>#{version[:project]} #{version[:version]} and #{rb_ver}</program-used>
- <date value="#{version[:date]}">#{version[:date]}</date>
+ <program-used>#{version.project} #{version.version} and #{rb_ver}</program-used>
+ <date value="#{version.date}">#{version.date}</date>
<src-url>#{@md.file.output_path.manifest.url}/#{@md.file.base_filename.manifest}</src-url>
<id></id>
<version>1.0</version>
diff --git a/lib/sisu/current/xml_odf_odt.rb b/lib/sisu/current/xml_odf_odt.rb
index 8b7c493..8a09fb8 100644
--- a/lib/sisu/current/xml_odf_odt.rb
+++ b/lib/sisu/current/xml_odf_odt.rb
@@ -67,7 +67,8 @@ module SiSU_XML_ODF_ODT
require_relative 'txt_shared' # txt_shared.rb
require_relative 'xml_shared' # xml_shared.rb
include SiSU_XML_Munge
- @@alt_id_count,@@alt_id_count,@@tablehead,@@number_of_cols=0,0,0,0
+ require_relative 'xml_persist' # xml_persist.rb
+ @@alt_id_count,@@alt_id_count=0,0
class Source
begin
require 'zlib'
@@ -128,7 +129,6 @@ module SiSU_XML_ODF_ODT
require_relative 'txt_shared' # txt_shared.rb
include SiSU_Parts_XML
@@img_count=0
- @@odf={ body: [], head: [], toc: [], metadata: [], tail: [], book_idx: [], endnotes: [] }
@@docstart=true
@@fns=nil
def initialize(particulars)
@@ -140,10 +140,12 @@ module SiSU_XML_ODF_ODT
end
def songsheet
begin
+ @per=SiSU_XML_Persist::Persist.new
pre
@data=markup(@ao_array)
publish
ensure
+ SiSU_XML_Persist::Persist.new.persist_init
unless (@md.opt.act[:verbose_plus][:set]==:on \
|| @md.opt.act[:maintenance][:set]==:on)
if @env.processing_path.odt =~/od[ft]/
@@ -187,18 +189,18 @@ module SiSU_XML_ODF_ODT
end
idx_arr << x.strip if x.is_a?(String)
end
- @@odf[:book_idx]=idx_arr.join
+ @per.book_idx=idx_arr.join
end
end
def odf_metadata
- @@odf[:metadata]=SiSU_Metadata::Summary.new(@md).
+ @per.metadata=SiSU_Metadata::Summary.new(@md).
odf.metadata
end
def odf_tail
manifest="#{@md.file.output_path.manifest.url}/#{@md.file.base_filename.manifest}"
- @@odf[:tail] << %{<text:p text:style-name="P_normal">Available document outputs: <br /> &lt;<text:a xl:type="simple" xl:href="#{manifest}">#{manifest}</text:a>&gt;</text:p>}
- @@odf[:tail] << %{\n<text:p text:style-name="P_normal">SiSU: &lt;<text:a xl:type="simple" xl:href="http://www.jus.uio.no/lm">www.jus.uio.no/sisu</text:a>&gt; and &lt;<text:a xl:type="simple" xl:href="http://www.sisudoc.org">www.sisudoc.org</text:a>&gt;</text:p>}
- @@odf[:tail] << "\n</office:text></office:body></office:document-content>"
+ @per.tail << %{<text:p text:style-name="P_normal">Available document outputs: <br /> &lt;<text:a xl:type="simple" xl:href="#{manifest}">#{manifest}</text:a>&gt;</text:p>}
+ @per.tail << %{\n<text:p text:style-name="P_normal">SiSU: &lt;<text:a xl:type="simple" xl:href="http://www.jus.uio.no/lm">www.jus.uio.no/sisu</text:a>&gt; and &lt;<text:a xl:type="simple" xl:href="http://www.sisudoc.org">www.sisudoc.org</text:a>&gt;</text:p>}
+ @per.tail << "\n</office:text></office:body></office:document-content>"
end
def set_bookmark_tag(dob)
SiSU_XML_ODF_ODT_Format::Tags.new.set_bookmark_tag(dob)
@@ -616,26 +618,26 @@ module SiSU_XML_ODF_ODT
end
end
if dob.is==:heading
- @@odf[:body] << heading(dob,p_num).obj << break_line*2
+ @per.body << heading(dob,p_num).obj << break_line*2
if SiSU_Env::ProcessingSettings.new(md).build.toc?
if dob.lv =~/[A-D1]/i
- @@odf[:toc] << toc(dob,p_num).obj
+ @per.toc << toc(dob,p_num).obj
end
end
elsif dob.is ==:verse
- @@odf[:body] << poem(dob,p_num).obj << break_line*2
+ @per.body << poem(dob,p_num).obj << break_line*2
elsif dob.is==:group
- @@odf[:body] << group(dob,p_num).obj << break_line*2
+ @per.body << group(dob,p_num).obj << break_line*2
elsif dob.is==:block
- @@odf[:body] << block(dob,p_num).obj << break_line*2
+ @per.body << block(dob,p_num).obj << break_line*2
elsif dob.is==:code
- @@odf[:body] << code(dob,p_num).obj << break_line*2
+ @per.body << code(dob,p_num).obj << break_line*2
elsif dob.is==:table #elsif dob.obj =~ /<!Th?¡/u
- @@odf[:body] << table(dob,p_num).obj << break_line*2
+ @per.body << table(dob,p_num).obj << break_line*2
elsif dob.is==:break
- @@odf[:body] << obj_break(dob).obj << break_line*2
+ @per.body << obj_break(dob).obj << break_line*2
else
- @@odf[:body] << normal(dob,p_num).obj << break_line*2 # main text, contents, body KEEP
+ @per.body << normal(dob,p_num).obj << break_line*2 # main text, contents, body KEEP
end
@@endnotes_para=[]
end
@@ -803,20 +805,20 @@ WOK
WOK
x=x.strip
x=x.gsub(/\n+/m,'') unless @md.opt.act[:maintenance][:set]==:on
- @@odf[:head] << x
+ @per.head << x
end
def publish
content=[]
br_pg='<text:p text:style-name="P_normal_page_new"> </text:p>'
content <<
- @@odf[:head] <<
- @@odf[:toc] <<
+ @per.head <<
+ @per.toc <<
br_pg <<
- @@odf[:body] <<
- @@odf[:book_idx] <<
+ @per.body <<
+ @per.book_idx <<
br_pg <<
- @@odf[:metadata] <<
- @@odf[:tail]
+ @per.metadata <<
+ @per.tail
SiSU_XML_ODF_ODT::Source::Output.new(content,@md,@env).odf
@@odf={ head: [], toc: [], body: [], tail: [], book_idx: [], metadata: [] }
end
diff --git a/lib/sisu/current/xml_odf_odt_format.rb b/lib/sisu/current/xml_odf_odt_format.rb
index 436c399..220f5de 100644
--- a/lib/sisu/current/xml_odf_odt_format.rb
+++ b/lib/sisu/current/xml_odf_odt_format.rb
@@ -162,7 +162,7 @@ module SiSU_XML_ODF_ODT_Format
end
end
class Table
- @@tablehead,@@table_counter=0,0 #reinitialise on new file
+ @@table_counter=0
@@tablefoot=[] #watch
@@fns=''
def initialize(md,dob,p_num)
@@ -265,7 +265,7 @@ module SiSU_XML_ODF_ODT_Format
class ODT_Head_1_2
def initialize(md)
@md=md
- @generator="#{@md.sisu_version[:project]} #{@md.sisu_version[:version]} #{@md.sisu_version[:date_stamp]} (#{@md.sisu_version[:date]})"
+ @generator="#{@md.project_details.project} #{@md.project_details.version} #{@md.project_details.date_stamp} (#{@md.project_details.date})"
end
def manifest_rdf
x=<<WOK
diff --git a/lib/sisu/current/xml_persist.rb b/lib/sisu/current/xml_persist.rb
new file mode 100644
index 0000000..73d2906
--- /dev/null
+++ b/lib/sisu/current/xml_persist.rb
@@ -0,0 +1,126 @@
+# encoding: utf-8
+=begin
+
+* Name: SiSU
+
+** Description: documents, structuring, processing, publishing, search
+*** html segment generation, processing
+
+** Author: Ralph Amissah
+ <ralph@amissah.com>
+ <ralph.amissah@gmail.com>
+
+** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
+ 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah,
+ All Rights Reserved.
+
+** License: GPL 3 or later:
+
+ SiSU, a framework for document structuring, publishing and search
+
+ Copyright (C) Ralph Amissah
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the Free
+ Software Foundation, either version 3 of the License, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ more details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program. If not, see <http://www.gnu.org/licenses/>.
+
+ If you have Internet connection, the latest version of the GPL should be
+ available at these locations:
+ <http://www.fsf.org/licensing/licenses/gpl.html>
+ <http://www.gnu.org/licenses/gpl.html>
+
+ <http://www.sisudoc.org/sisu/en/manifest/gpl.fsf.html>
+
+** SiSU uses:
+ * Standard SiSU markup syntax,
+ * Standard SiSU meta-markup syntax, and the
+ * Standard SiSU object citation numbering and system
+
+** Hompages:
+ <http://www.jus.uio.no/sisu>
+ <http://www.sisudoc.org>
+
+** Git
+ <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=summary>
+ <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=blob;f=lib/sisu/current/xml_persist.rb;hb=HEAD>
+
+=end
+module SiSU_XML_Persist
+ class Persist
+ @@persist=nil
+ attr_accessor :head,:toc,:body,:tail,:open,:close,:sc,:endnotes,:book_idx,:metadata
+ #attr_accessor :head,:body,:tail,:open,:close,:sc
+#@@odf={ body: [], head: [], toc: [], metadata: [], tail: [], book_idx: [], endnotes: [] }
+ def initialize(args=nil)
+ @@persist=args=(args ? args : (@@persist || persist_init_hash_values))
+ @head=args[:head]
+ @toc=args[:toc]
+ @body=args[:body]
+ @tail=args[:tail]
+ @open=args[:open]
+ @close=args[:close]
+ @sc=args[:sc]
+ @endnotes=args[:endnotes]
+ @book_idx=args[:book_idx]
+ @metadata=args[:metadata]
+ end
+ def head
+ @head
+ end
+ def toc
+ @toc
+ end
+ def body
+ @body
+ end
+ def tail
+ @tail
+ end
+ def open
+ @open
+ end
+ def close
+ @close
+ end
+ def sc
+ @sc
+ end
+ def endnotes
+ @endnotes
+ end
+ def book_idx
+ @book_idx
+ end
+ def metadata
+ @metadata
+ end
+ def persist_init_hash_values
+ {
+ head: [],
+ toc: [],
+ body: [],
+ tail: [],
+ open: [],
+ close: [],
+ sc: [],
+ endnotes: [],
+ book_idx: [],
+ metadata: [],
+ }
+ end
+ def persist_init
+ @@persist=nil
+ Persist.new(persist_init_hash_values)
+ end
+ end
+end
+__END__
diff --git a/lib/sisu/current/xml_sax.rb b/lib/sisu/current/xml_sax.rb
index 2145562..21e5d50 100644
--- a/lib/sisu/current/xml_sax.rb
+++ b/lib/sisu/current/xml_sax.rb
@@ -63,10 +63,11 @@ module SiSU_XML_SAX
include SiSU_XML_Munge
require_relative 'xml_format' # xml_format.rb
include SiSU_XML_Format
+ require_relative 'xml_persist' # xml_persist.rb
require_relative 'rexml' # rexml.rb
include SiSU_Rexml
require_relative 'shared_metadata' # shared_metadata.rb
- @@alt_id_count,@@tablehead,@@number_of_cols=0,0,0
+ @@alt_id_count=0
@@tablefoot=''
class Source
def initialize(opt)
@@ -159,18 +160,22 @@ module SiSU_XML_SAX
include SiSU_TextUtils
require_relative 'css' # css.rb
require_relative 'xhtml_shared' # decide use, whether xml rather than xhtml
- @@xml={ body: [], open: [], close: [], head: [] }
def initialize(particulars)
@env, @md, @ao_arr=
particulars.env,particulars.md,particulars.ao_array
@trans=SiSU_XML_Munge::Trans.new(@md)
@sys=SiSU_Env::SystemCall.new
+ @per=SiSU_XML_Persist::Persist.new
end
def songsheet
- pre
- @data=markup(@ao_arr)
- post
- publish
+ begin
+ pre
+ @data=markup(@ao_arr)
+ post
+ publish
+ ensure
+ SiSU_XML_Persist::Persist.new.persist_init
+ end
end
protected
def embedded_endnotes(dob='')
@@ -219,7 +224,7 @@ WOK
end
def xml_head
metadata=SiSU_Metadata::Summary.new(@md).xml_sax.metadata
- @@xml[:head] << metadata
+ @per.head << metadata
end
def xml_sc(md='')
sc=if @md.sc_info
@@ -241,7 +246,7 @@ WOK
WOK
else ''
end
- @@xml[:sc]=sc
+ @per.sc=sc
end
def xml_structure(dob,type='norm')
if dob.is==:heading
@@ -257,16 +262,16 @@ WOK
util=SiSU_TextUtils::Wrap.new(dob.obj,70)
wrapped=util.line_wrap
#end
- @@xml[:body] << if defined? dob.ocn; %{#{Ax[:tab]*0}<object id="#{dob.ocn}">}
+ @per.body << if defined? dob.ocn; %{#{Ax[:tab]*0}<object id="#{dob.ocn}">}
else "#{Ax[:tab]*0}<object>"
end
- @@xml[:body] << "#{Ax[:tab]*1}<ocn>#{dob.ocn}</ocn>" if defined? dob.ocn
- @@xml[:body] << if lv; %{#{Ax[:tab]*1}<text class="h#{lv}">\n#{Ax[:tab]*2}#{wrapped}\n#{Ax[:tab]*1}</text>}
+ @per.body << "#{Ax[:tab]*1}<ocn>#{dob.ocn}</ocn>" if defined? dob.ocn
+ @per.body << if lv; %{#{Ax[:tab]*1}<text class="h#{lv}">\n#{Ax[:tab]*2}#{wrapped}\n#{Ax[:tab]*1}</text>}
else %{#{Ax[:tab]*1}<text class="#{type}">\n#{Ax[:tab]*2}#{wrapped}\n#{Ax[:tab]*1}</text>} # main text, contents, body KEEP
end
- @@xml[:body] << @endnotes if @endnotes
- ##@@xml[:body] << "#{Ax[:tab]*1}<text>#{dob[@regx,2]}</text>" if dob[@regx,2] # old unwrapped main text, contents, body KEEP
- @@xml[:body] << "#{Ax[:tab]*0}</object>"
+ @per.body << @endnotes if @endnotes
+ ##@per.body << "#{Ax[:tab]*1}<text>#{dob[@regx,2]}</text>" if dob[@regx,2] # old unwrapped main text, contents, body KEEP
+ @per.body << "#{Ax[:tab]*0}</object>"
@endnotes=[]
end
def block_structure(dob='')
@@ -275,13 +280,13 @@ WOK
gsub(/#{Mx[:en_b_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_b_c]}/,'<en>\1</en>') #footnote/endnote clean
dob=@trans.markup_block(dob)
dob.obj=dob.obj.strip
- @@xml[:body] << %{#{Ax[:tab]*0}<object id="#{dob.ocn}">}
- @@xml[:body] << %{#{Ax[:tab]*1}<ocn>#{dob.ocn}</ocn>}
- @@xml[:body] << %{#{Ax[:tab]*1}<text class="block">#{Ax[:tab]*1}}
- @@xml[:body] << %{#{Ax[:tab]*2}#{dob.obj}#{Ax[:tab]*1}}
- @@xml[:body] << %{#{Ax[:tab]*1}</text>}
- @@xml[:body] << "#{Ax[:tab]*0}</object>"
- @@xml[:body] << @endnotes if @endnotes
+ @per.body << %{#{Ax[:tab]*0}<object id="#{dob.ocn}">}
+ @per.body << %{#{Ax[:tab]*1}<ocn>#{dob.ocn}</ocn>}
+ @per.body << %{#{Ax[:tab]*1}<text class="block">#{Ax[:tab]*1}}
+ @per.body << %{#{Ax[:tab]*2}#{dob.obj}#{Ax[:tab]*1}}
+ @per.body << %{#{Ax[:tab]*1}</text>}
+ @per.body << "#{Ax[:tab]*0}</object>"
+ @per.body << @endnotes if @endnotes
@endnotes=[]
end
def group_structure(dob='')
@@ -290,48 +295,48 @@ WOK
gsub(/#{Mx[:en_b_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_b_c]}/,'<en>\1</en>') #footnote/endnote clean
dob=@trans.markup_group(dob)
dob.obj=dob.obj.strip
- @@xml[:body] << %{#{Ax[:tab]*0}<object id="#{dob.ocn}">}
- @@xml[:body] << %{#{Ax[:tab]*1}<ocn>#{dob.ocn}</ocn>}
- @@xml[:body] << %{#{Ax[:tab]*1}<text class="group">#{Ax[:tab]*1}}
- @@xml[:body] << %{#{Ax[:tab]*2}#{dob.obj}#{Ax[:tab]*1}}
- @@xml[:body] << %{#{Ax[:tab]*1}</text>}
- @@xml[:body] << "#{Ax[:tab]*0}</object>"
- @@xml[:body] << @endnotes if @endnotes
+ @per.body << %{#{Ax[:tab]*0}<object id="#{dob.ocn}">}
+ @per.body << %{#{Ax[:tab]*1}<ocn>#{dob.ocn}</ocn>}
+ @per.body << %{#{Ax[:tab]*1}<text class="group">#{Ax[:tab]*1}}
+ @per.body << %{#{Ax[:tab]*2}#{dob.obj}#{Ax[:tab]*1}}
+ @per.body << %{#{Ax[:tab]*1}</text>}
+ @per.body << "#{Ax[:tab]*0}</object>"
+ @per.body << @endnotes if @endnotes
@endnotes=[]
end
def poem_structure(dob='')
dob=@trans.markup_group(dob)
#dob.obj.gsub(/\s\s/,'&#160;&#160;')
dob.obj=dob.obj.strip
- @@xml[:body] << %{#{Ax[:tab]*0}<object id="#{dob.ocn}">}
- @@xml[:body] << %{#{Ax[:tab]*1}<ocn>#{dob.ocn}</ocn>}
- @@xml[:body] << %{#{Ax[:tab]*1}<text class="verse">#{Ax[:tab]*1}}
- @@xml[:body] << %{#{Ax[:tab]*2}#{dob.obj}#{Ax[:tab]*1}}
- @@xml[:body] << %{#{Ax[:tab]*1}</text>}
- @@xml[:body] << %{#{Ax[:tab]*0}</object>}
+ @per.body << %{#{Ax[:tab]*0}<object id="#{dob.ocn}">}
+ @per.body << %{#{Ax[:tab]*1}<ocn>#{dob.ocn}</ocn>}
+ @per.body << %{#{Ax[:tab]*1}<text class="verse">#{Ax[:tab]*1}}
+ @per.body << %{#{Ax[:tab]*2}#{dob.obj}#{Ax[:tab]*1}}
+ @per.body << %{#{Ax[:tab]*1}</text>}
+ @per.body << %{#{Ax[:tab]*0}</object>}
end
def code_structure(dob='')
dob=@trans.markup_group(dob)
dob.obj=dob.obj.gsub(/\s\s/,'&#160;&#160;').strip
- @@xml[:body] << %{#{Ax[:tab]*0}<object id="#{dob.ocn}">}
- @@xml[:body] << %{#{Ax[:tab]*1}<ocn>#{dob.ocn}</ocn>}
- @@xml[:body] << %{#{Ax[:tab]*1}<text class="code">#{Ax[:tab]*1}}
- @@xml[:body] << %{#{Ax[:tab]*2}#{dob.obj}#{Ax[:tab]*1}}
- @@xml[:body] << %{#{Ax[:tab]*1}</text>}
- @@xml[:body] << "#{Ax[:tab]*0}</object>"
+ @per.body << %{#{Ax[:tab]*0}<object id="#{dob.ocn}">}
+ @per.body << %{#{Ax[:tab]*1}<ocn>#{dob.ocn}</ocn>}
+ @per.body << %{#{Ax[:tab]*1}<text class="code">#{Ax[:tab]*1}}
+ @per.body << %{#{Ax[:tab]*2}#{dob.obj}#{Ax[:tab]*1}}
+ @per.body << %{#{Ax[:tab]*1}</text>}
+ @per.body << "#{Ax[:tab]*0}</object>"
end
def table_structure(dob)
table=SiSU_XHTML_Shared::TableXHTML.new(dob)
- @@xml[:body] << %{#{Ax[:tab]*0}<object id="#{dob.ocn}">}
- @@xml[:body] << %{#{Ax[:tab]*1}<ocn>#{dob.ocn}</ocn>}
- @@xml[:body] << %{#{Ax[:tab]*1}<text class="table">#{Ax[:tab]*1}}
- @@xml[:body] << %{#{Ax[:tab]*2}#{table.table.obj}}
- @@xml[:body] << %{#{Ax[:tab]*1}</text>}
- #@@xml[:body] << %{#{tab*1}</text>}
- @@xml[:body] << "#{Ax[:tab]*0}</object>"
- #@@xml[:body] << %{#{Ax[:tab]*0}<object id="#{ocn}">}
- #@@xml[:body] << %{#{Ax[:tab]*1}#{table}\n#{Ax[:tab]*1}} # unless lv # main text, contents, body KEEP
- #@@xml[:body] << "#{Ax[:tab]*0}</object>"
+ @per.body << %{#{Ax[:tab]*0}<object id="#{dob.ocn}">}
+ @per.body << %{#{Ax[:tab]*1}<ocn>#{dob.ocn}</ocn>}
+ @per.body << %{#{Ax[:tab]*1}<text class="table">#{Ax[:tab]*1}}
+ @per.body << %{#{Ax[:tab]*2}#{table.table.obj}}
+ @per.body << %{#{Ax[:tab]*1}</text>}
+ #@per.body << %{#{tab*1}</text>}
+ @per.body << "#{Ax[:tab]*0}</object>"
+ #@per.body << %{#{Ax[:tab]*0}<object id="#{ocn}">}
+ #@per.body << %{#{Ax[:tab]*1}#{table}\n#{Ax[:tab]*1}} # unless lv # main text, contents, body KEEP
+ #@per.body << "#{Ax[:tab]*0}</object>"
#@endnotes=[]
end
def markup(data)
@@ -403,7 +408,7 @@ WOK
elsif dob.obj =~/(Owner Details)/
# txt_obj={ txt: '<br /><a name="owner.details">Owner Details</a>' }
# format_scroll=FormatScroll.new(@md,txt_obj)
-# @@xml[:owner_details]=format_scroll.bold_para
+# @per.owner_details=format_scroll.bold_para
dob.obj=''
end
if dob.obj =~/<a name="n\d+">/ \
@@ -424,41 +429,41 @@ WOK
end
7.downto(4) do |x|
y=x - 1; v=x - 3
- @@xml[:body] << "#{Ax[:tab]*5}</content>\n#{Ax[:tab]*y}</contents#{v}>" if @level[x]==true
+ @per.body << "#{Ax[:tab]*5}</content>\n#{Ax[:tab]*y}</contents#{v}>" if @level[x]==true
end
3.downto(1) do |x|
y=x - 1
- @@xml[:body] << "#{Ax[:tab]*y}</heading#{x}>" if @level[x]==true
+ @per.body << "#{Ax[:tab]*y}</heading#{x}>" if @level[x]==true
end
- #7.downto(1) { |x| y=x - 1; @@xml[:body] << "#{Ax[:tab]*y}</level #{x}>" if @level[x]==true }
+ #7.downto(1) { |x| y=x - 1; @per.body << "#{Ax[:tab]*y}</level #{x}>" if @level[x]==true }
end
def pre
rdf=SiSU_XML_Tags::RDF.new(@md)
- @@xml[:head],@@xml[:body]=[],[]
+ @per.head,@per.body=[],[]
stylesheet=SiSU_Style::CSS_HeadInfo.new(@md,'xml_sax').stylesheet
encoding=if @sys.locale =~/utf-?8/i then '<?xml version="1.0" encoding="UTF-8" standalone="no"?>'
else '<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>'
end
- @@xml[:open] =<<WOK
+ @per.open =<<WOK
#{encoding}
#{stylesheet.css_head_xml}
#{rdf.comment_xml}
<document>
WOK
- @@xml[:head] << '<head>'
- @@xml[:body] << '<body>'
+ @per.head << '<head>'
+ @per.body << '<body>'
end
def post
- @@xml[:head] << @@xml[:sc]
- @@xml[:head] << '</head>'
- @@xml[:body] << '</body>'
- @@xml[:close] = '</document>'
+ @per.head << @per.sc
+ @per.head << '</head>'
+ @per.body << '</body>'
+ @per.close = '</document>'
end
def publish
content=[]
- content << @@xml[:open] << @@xml[:head] << @@xml[:body] << @@xml[:metadata]
- content << @@xml[:owner_details] if @md.stmp =~/\w\w/
- content << @@xml[:tail] << @@xml[:close]
+ content << @per.open << @per.head << @per.body #<< @per.metadata
+ #content << @per.owner_details if @md.stmp =~/\w\w/
+ content << @per.tail << @per.close
content=content.flatten.compact
Output.new(content,@md).xml
@@xml={}
@@ -496,11 +501,11 @@ WOK
'check document structure'
).colorize
tell=SiSU_Screen::Ansi.new(
- @md.opt.act[:color_state][:set],
- 'invert',
- '',
- ''
- )
+ @md.opt.act[:color_state][:set],
+ 'invert',
+ '',
+ ''
+ )
tell.grey_open
end
tidyfile='/dev/null' #don't want one or screen output, check for alternative flags
diff --git a/lib/sisu/current/xml_shared.rb b/lib/sisu/current/xml_shared.rb
index f392d9f..4e16aa9 100644
--- a/lib/sisu/current/xml_shared.rb
+++ b/lib/sisu/current/xml_shared.rb
@@ -608,7 +608,7 @@ module SiSU_XML_Tags #Format
rdftoc
end
def comment_xml(extra='')
- generator="Generated by: #{@md.sisu_version[:project]} #{@md.sisu_version[:version]} of #{@md.sisu_version[:date_stamp]} (#{@md.sisu_version[:date]})" if @md.sisu_version[:version]
+ generator="Generated by: #{@md.project_details.project} #{@md.project_details.version} of #{@md.project_details.date_stamp} (#{@md.project_details.date})" if @md.project_details.version
lastdone="Last Generated on: #{Time.now}"
rubyv="Ruby version: #{@md.ruby_version}"
sc=if @md.sc_info