aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2014-11-21 19:37:01 -0500
committerRalph Amissah <ralph@amissah.com>2014-12-08 00:18:15 -0500
commitda4985ca4b435a19081e8b481b622a865d1fbb03 (patch)
treeeedce4169b747f8c6570083b6709b8a262b745ee /lib
parentd: misc mostly minor (diff)
d: ao, rearrange, introduce new file
Diffstat (limited to 'lib')
-rw-r--r--lib/sisu/develop/ao.rb99
-rw-r--r--lib/sisu/develop/ao_composite.rb8
-rw-r--r--lib/sisu/develop/ao_doc_str.rb246
-rw-r--r--lib/sisu/develop/ao_persist.rb194
4 files changed, 354 insertions, 193 deletions
diff --git a/lib/sisu/develop/ao.rb b/lib/sisu/develop/ao.rb
index e3e4703b..585192b0 100644
--- a/lib/sisu/develop/ao.rb
+++ b/lib/sisu/develop/ao.rb
@@ -73,6 +73,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 +83,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)
@opt,@fnx=opt,fnx
- @@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,13 +108,14 @@ 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.selection,@@fns).location do
+ SiSU_Errors::Rescued.new($!,$@,@opt.selection,@per.fns).location do
__LINE__.to_s + ':' + __FILE__
end
ensure
@@ -126,16 +125,16 @@ module SiSU_AO
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.selection,@opt.fns).location do
__LINE__.to_s + ':' + __FILE__
@@ -147,16 +146,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.selection,@opt.fns).location do
__LINE__.to_s + ':' + __FILE__
@@ -168,16 +167,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.selection,@opt.fns).location do
__LINE__.to_s + ':' + __FILE__
@@ -189,16 +188,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.selection,@opt.fns).location do
__LINE__.to_s + ':' + __FILE__
@@ -210,16 +209,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.selection,@opt.fns).location do
__LINE__.to_s + ':' + __FILE__
@@ -231,16 +230,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.selection,@opt.fns).location do
__LINE__.to_s + ':' + __FILE__
@@ -252,16 +251,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.selection,@opt.fns).location do
__LINE__.to_s + ':' + __FILE__
diff --git a/lib/sisu/develop/ao_composite.rb b/lib/sisu/develop/ao_composite.rb
index 05d01dd6..d6a4867b 100644
--- a/lib/sisu/develop/ao_composite.rb
+++ b/lib/sisu/develop/ao_composite.rb
@@ -86,7 +86,6 @@ module SiSU_Assemble
end
end
class Composite
- @@imager={}
def initialize(opt)
@opt=opt
@env=SiSU_Env::InfoEnv.new
@@ -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/develop/ao_doc_str.rb b/lib/sisu/develop/ao_doc_str.rb
index ae029002..bf7716dc 100644
--- a/lib/sisu/develop/ao_doc_str.rb
+++ b/lib/sisu/develop/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
@@ -273,24 +249,24 @@ module SiSU_AO_DocumentStructureExtract
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 +274,7 @@ 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
+ 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 +289,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 +316,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 +340,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 +365,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 +400,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 +433,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 +465,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 +487,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 +515,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 +534,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 +549,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 +564,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 +579,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 +594,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 +615,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 +634,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 +773,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 +808,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 +824,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 +841,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 +851,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 +876,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 +899,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 +921,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 +943,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 +965,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 +976,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 +989,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 +1018,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}").
@@ -1168,7 +1144,7 @@ module SiSU_AO_DocumentStructureExtract
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
diff --git a/lib/sisu/develop/ao_persist.rb b/lib/sisu/develop/ao_persist.rb
new file mode 100644
index 00000000..51ff6e0b
--- /dev/null
+++ b/lib/sisu/develop/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/develop/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__