aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/sisu/v0/concordance.rb22
-rw-r--r--lib/sisu/v0/constants.rb2
-rw-r--r--lib/sisu/v0/dal.rb56
-rw-r--r--lib/sisu/v0/dal_idx.rb157
-rw-r--r--lib/sisu/v0/dal_syntax.rb1
-rw-r--r--lib/sisu/v0/html.rb3
-rw-r--r--lib/sisu/v0/html_segments.rb86
-rw-r--r--lib/sisu/v0/odf.rb1
-rw-r--r--lib/sisu/v0/particulars.rb13
-rw-r--r--lib/sisu/v0/plaintext.rb1
-rw-r--r--lib/sisu/v0/shared_xml.rb4
-rw-r--r--lib/sisu/v0/sysenv.rb6
-rw-r--r--lib/sisu/v0/texpdf.rb1
13 files changed, 211 insertions, 142 deletions
diff --git a/lib/sisu/v0/concordance.rb b/lib/sisu/v0/concordance.rb
index 485f3df5..fad91d14 100644
--- a/lib/sisu/v0/concordance.rb
+++ b/lib/sisu/v0/concordance.rb
@@ -121,8 +121,8 @@ WOK
end
def create
head_banner=SiSU_HTML_Format::Head_toc.new(@md)
-minitoc=SiSU_HTML_minitoc::Toc_mini.new(@md,@data).songsheet
-toc='<div class="toc">' + minitoc.to_s + '</div>'
+ minitoc=SiSU_HTML_minitoc::Toc_mini.new(@md,@data).songsheet
+ toc='<div class="toc">' + minitoc.to_s + '</div>'
<<WOK
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
@@ -199,7 +199,8 @@ WOK
@rxp_t3=Regexp.new('^T3')
@rxp_excluded1=/(?:https?|file|ftp):\/\/\S+/
@rxp_excluded0=/^(?:#{Mx[:fa_bold_o]}|#{Mx[:fa_italics_o]})?(?:to\d+|\d+|&nbsp;|#{Mx[:br_endnotes]}|EOF|#{Mx[:br_eof]}|thumb_\S+|snap_\S+|_+|-+|[(]?(?:ii+|iv|vi+|ix|xi+|xiv|xv|xvi+|xix|xx)[).]?|\S+?_\S+|[\d_]+\w\S+|[\w\d]{1,2}|\d{1,3}\w?|#@dp|[0-9a-f]{16,64}|\d{2,3}x\d{2,3}|\S{0,2}sha\d|\S{0,3}\d{4}w\d\d|\b\w\d+|\d_all\b|e\.?g\.?)(?:#{Mx[:fa_bold_c]}|#{Mx[:fa_italics_c]})?$/mi #this regex causes and cures a stack dump in ruby 1.9 !!!
- @rgx_scanlist=%r{#{Mx[:fa_italics_o]}[a-zA-Z0-9"\s]{2,12}#{Mx[:fa_italics_c]}|#{Mx[:fa_bold_o]}[a-zA-Z0-9"\s]{2,12}#{Mx[:fa_bold_c]}|(?:https?|file)://\S+|#{Mx[:gr_o]}code#{Mx[:gr_o]}.+?#{Mx[:gr_o]}code-end#{Mx[:gr_o]}|<\S+?>|#{Mx[:id_o]}\S+?#{Mx[:id_c]}|\w+|[a-zA-Z]+}mi
+ @rgx_splitlist=%r{[—.,;:-]|#{Mx[:id_o]}\S+?#{Mx[:id_c]}}mi
+ @rgx_scanlist=%r{#{Mx[:fa_italics_o]}[a-zA-Z0-9"\s]{2,12}#{Mx[:fa_italics_c]}|#{Mx[:fa_bold_o]}[a-zA-Z0-9"\s]{2,12}#{Mx[:fa_bold_c]}|(?:https?|file)://\S+|#{Mx[:gr_o]}code#{Mx[:gr_o]}.+?#{Mx[:gr_o]}code-end#{Mx[:gr_o]}|<\S+?>|\w+|[a-zA-Z]+}mi
rescue; SiSU_Errors::Info_error.new($!,$@,@md.cmd,@md.fns).error
end
end
@@ -223,13 +224,13 @@ WOK
@sfx='.html' #used for hardlinks, previous setting @sfx='', web server takes care of suffix
@word_location_seg=wordlocation.gsub(/(.+?)\#(\d+)/,"#{@md.fnl[:pre]}\\1#{@md.fnl[:mid]}#@sfx#{@md.fnl[:post]}#\\2") unless wordlocation.nil?
case @wordlocation
- when @rxp_t1
- %{[<a href="#{@md.fnl[:pre]}doc#{@md.fnl[:mid]}#@sfx#{@md.fnl[:post]}##@show">H</a>]#@show, }
- when @rxp_t2
- %{[<a href="#{@md.fnl[:pre]}doc#{@md.fnl[:mid]}#@sfx#{@md.fnl[:post]}##@show">H</a>]#@show, }
- when @rxp_t3
- %{[<a href="#{@md.fnl[:pre]}doc#{@md.fnl[:mid]}#@sfx#{@md.fnl[:post]}##@show">H</a>]#@show, }
- else %{<a href="#@word_location_seg">#@show</a>, }
+ when @rxp_t1
+ %{[<a href="#{@md.fnl[:pre]}doc#{@md.fnl[:mid]}#@sfx#{@md.fnl[:post]}##@show">H</a>]#@show, }
+ when @rxp_t2
+ %{[<a href="#{@md.fnl[:pre]}doc#{@md.fnl[:mid]}#@sfx#{@md.fnl[:post]}##@show">H</a>]#@show, }
+ when @rxp_t3
+ %{[<a href="#{@md.fnl[:pre]}doc#{@md.fnl[:mid]}#@sfx#{@md.fnl[:post]}##@show">H</a>]#@show, }
+ else %{<a href="#@word_location_seg">#@show</a>, }
end
end
def map_para
@@ -243,6 +244,7 @@ WOK
end
if toy =~/\d+/ \
and toy !~/^0$/
+ line=line.split(@rgx_splitlist).join(' ') #%take in word or other match
for word in line.scan(@rgx_scanlist) #%take in word or other match
#word.gsub!(@rxp_clean,'')
word.gsub!(/#{Mx[:lnk_o]}|#{Mx[:lnk_c]}(?:http)?/,'')
diff --git a/lib/sisu/v0/constants.rb b/lib/sisu/v0/constants.rb
index 3f050df7..414732e1 100644
--- a/lib/sisu/v0/constants.rb
+++ b/lib/sisu/v0/constants.rb
@@ -91,7 +91,7 @@ Mx[:gl_bullet]= "#{Mx[:gl_o]}●#{Mx[:gl_c]}"
Mx[:pa_non_object_dummy_heading]="#{Mx[:pa_o]}-##{Mx[:pa_c]}" #unnumbered paragraph, delete when not required [used in dummy headings, eg. for segmented html] (place marker at end of paragraph)
Mx[:pa_non_object_no_heading]="#{Mx[:pa_o]}~##{Mx[:pa_c]}" #unnumbered paragraph (place marker at end of paragraph)
Mx[:idx_o]='▢ '; Mx[:idx_c]='▢ ' #
-Mx[:nbsp]= '▭ '
+Mx[:nbsp]= '░' #'▭ '
Mx[:br_line]= "#{Mx[:mk_o]}br#{Mx[:mk_c]}"
Mx[:br_paragraph]= "#{Mx[:mk_o]}br#{Mx[:mk_c]}"
Mx[:br_nl]= "#{Mx[:mk_o]}nl#{Mx[:mk_c]}"
diff --git a/lib/sisu/v0/dal.rb b/lib/sisu/v0/dal.rb
index a00d307b..c01c2d0a 100644
--- a/lib/sisu/v0/dal.rb
+++ b/lib/sisu/v0/dal.rb
@@ -87,13 +87,14 @@ module SiSU_DAL
end
end
class Source <Instantiate
- @@dal_array=[]
+ @@dal_array,@@html_idx_array=[],[]
@@fns=nil
def initialize(opt)
@opt=opt
@@fns||@opt.fns
@my_make_fns=SiSU_Env::Create_file.new(@opt.cmd,@opt.fns)
@fnm=@my_make_fns.marshal_meta
+ @fnm_idx_html=@my_make_fns.marshal_meta_idx_html
SiSU_Env::Create_system_link.new.images
@env=SiSU_Env::Info_env.new
end
@@ -123,6 +124,21 @@ module SiSU_DAL
Instantiate.new
end
end
+ def get_idx_html #reads dal idx.html, #unless does not exist then creates first
+ begin
+ dal=[]
+ unless @@fns==@opt.fns
+ @@fns=@opt.fns
+ @@html_idx_array=[]
+ end
+ dal=if @@html_idx_array.empty?; read_fnm_idx_html
+ else @@html_idx_array.dup #check
+ end
+ rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error
+ ensure
+ Instantiate.new
+ end
+ end
protected
def create_dal
dal_array=[]
@@ -154,32 +170,56 @@ module SiSU_DAL
else SiSU_DAL::Source.new(@opt).create_dal
end
end
+ def read_fnm_idx_html
+ dal=[]
+ dal=if FileTest.file?(@fnm_idx_html)
+ if RUBY_VERSION < '1.9'
+ File.open(@fnm_idx_html){ |f| dal=Marshal.load(f)}
+ else File.open(@fnm_idx_html,'r:utf-8'){ |f| dal=Marshal.load(f)}
+ end
+ else nil
+ #SiSU_DAL::Source.new(@opt).create_dal
+ end
+#p dal; dal
+ end
end
class Output
def initialize(md,data)
@md,@data=md,data
@my_make=SiSU_Env::Create_file.new(@md.cmd,@md.fns)
- dir=SiSU_Env::Info_env.new(@md.fns)
- @hard="#{dir.path.dal}/#{@md.fns}.meta"
+ @dir=SiSU_Env::Info_env.new(@md.fns)
end
def hard_output
if @md.cmd =~/M/
filename_meta=@my_make.file_meta
@data.each {|s| filename_meta.puts s.strip + "\n\n" unless s.strip.empty?}
- else File.unlink(@hard) if FileTest.file?(@hard)
+ else
+ hard="#{@dir.path.dal}/#{@md.fns}.meta"
+ File.unlink(hard) if FileTest.file?(hard)
end
end
def marshal
marshal_meta=@my_make.marshal_meta
File.open(marshal_meta,'w'){|f| Marshal.dump(@data.to_a,f)}
end
+ def idx_html_hard_output
+ if @md.book_index and @md.cmd =~/M/
+ filename_meta=@my_make.file_meta_idx_html
+ @data.each {|s| filename_meta.puts s.strip + "\n" unless s.strip.empty?}
+ else
+ hard_idx_html="#{@dir.path.dal}/#{@md.fns}.idx.html"
+ File.unlink(hard_idx_html) if FileTest.file?(hard_idx_html)
+ end
+ end
+ def idx_html_marshal
+ marshal_meta=@my_make.marshal_meta_idx_html
+ File.open(marshal_meta,'w'){|f| Marshal.dump(@data.to_a,f)}
+ end
end
class Make
- #@@comment='%'
@@dp=nil
def initialize(md,data)
@md,@data=md,data
- #@@word_mode=[]
@env=SiSU_Env::Info_env.new(@md.fns)
@skin=SiSU_Env::Info_skin.new(@md)
@dp=@@dp ||=SiSU_Env::Info_env.new.digest.pattern
@@ -209,7 +249,7 @@ module SiSU_DAL
data=SiSU_images::Images.new(@md,data).images
data=SiSU_document_structure::Tables.new(@md,data).tables
data=SiSU_numbering::Numbering.new(@md,data).numbering_song
- data=SiSU_book_index::Book_index.new(@md,data,@env).indexing_song if @md.book_index
+ data,book_index,html_idx=SiSU_book_index::Book_index.new(@md,data,@env).indexing_song if @md.book_index
data=SiSU_endnotes::Endnotes.new(@md,data,endnote_array).endnotes
data=SiSU_hash::Object_digest.new(@md,data,@env).object_digest
meta=SiSU_metadata::Metadata.new(@md,data).metadata
@@ -218,6 +258,8 @@ module SiSU_DAL
if @md.cmd =~/[mM]/
SiSU_DAL::Output.new(@md,outputdata).hard_output
SiSU_DAL::Output.new(@md,outputdata).marshal
+ SiSU_DAL::Output.new(@md,html_idx).idx_html_hard_output
+ SiSU_DAL::Output.new(@md,html_idx).idx_html_marshal
end
reset
outputdata
diff --git a/lib/sisu/v0/dal_idx.rb b/lib/sisu/v0/dal_idx.rb
index 26fc66b6..74ec0d15 100644
--- a/lib/sisu/v0/dal_idx.rb
+++ b/lib/sisu/v0/dal_idx.rb
@@ -76,9 +76,10 @@ module SiSU_book_index
@env ||=SiSU_Env::Info_env.new(@md.fns)
end
def indexing_song
- @data=extract_book_index(@data)
- @data=clean_index(@data)
- @data
+ data=@data
+ data,sisu_markup_idx,html_idx=extract_book_index(data)
+ data=clean_and_insert_index(data,sisu_markup_idx)
+ [data,sisu_markup_idx,html_idx]
end
def extract_book_index(data)
tuned_file=[]
@@ -89,24 +90,30 @@ module SiSU_book_index
idx_array << @rgx_idx_ocn_init.match(para)[0].gsub(@rgx_idx_ocn_init,"\\1~\\2~#{@seg}") if para =~ @rgx_idx_ocn_init
tuned_file << para if para
end
- #idx_array.each do |i|
- # i.gsub!(@rgx_idx_ocn_init,'\1~\2')
- #end
idx_array=construct_idx_array(idx_array) if idx_array.length > 0
if idx_array.length > 0
- if @md.cmd.inspect =~/M/
- the_idx=construct_book_index(idx_array)
- screen_print(the_idx) if @md.cmd.inspect =~/M/
- puts "\n---"
- path="#{@env.path.output}/#{@md.fnb}"
- @file_index_all=File.open("#{path}/#{@md.fn[:book_index]}",'w')
- screen_html(the_idx)
- @file_index_all.close
- puts "\n---"
- screen_sisu_markup(the_idx)
+ the_idx=construct_book_index(idx_array)
+ #screen_print(the_idx) if @md.cmd.inspect =~/V/
+ sisu_markup_idx,html_idx=nil,nil
+ if @md.book_index
+ idx=index(the_idx)
+ output_html_idx(idx[:html])
+ html_idx=idx[:html]
+ sisu_markup_idx=idx[:sst]
end
end
- tuned_file
+ [tuned_file,sisu_markup_idx,html_idx]
+ end
+ def output_html_idx(html_idx)
+ if @md.book_index
+ path="#{@env.path.output}/#{@md.fnb}"
+ Dir.mkdir(path) unless FileTest.directory?(path)
+ html_index_file=File.new("#{path}/#{@md.fn[:book_index]}",'w')
+ puts "#{path}/#{@md.fn[:book_index]}"
+ #html_file(the_idx)
+ html_idx.each {|x| html_index_file << x }
+ html_index_file.close
+ end
end
def construct_idx_array(idx_array)
idx_lst=[]
@@ -163,11 +170,22 @@ module SiSU_book_index
#p the_idx; p '-----'
the_idx
end
- def screen_print(the_idx)
+ def index(the_idx)
+ @x=1
+ @idx={}
+ @idx[:sst],@idx[:html]=[],[]
+ @idx[:sst] << "\n\n#{Mx[:br_page_new]}"
+ @idx[:sst] << "\n\n#{Mx[:lv_o]}2:#{Mx[:lv_c]}Index #{Mx[:id_o]}~0;0:0;x0#{Mx[:id_c]}"
+ @idx[:sst] << "\n\n#{Mx[:lv_o]}4:idx#{Mx[:lv_c]} [Index] #{Mx[:pa_non_object_dummy_heading]} #{Mx[:id_o]}~0;0:0;x0#{Mx[:id_c]}"
the_idx.each do |i|
i.each do |x|
if x.class == String
- print "\n" + x + ', '
+ @idx[:sst] << %{\n\n#{Mx[:fa_bold_o]}#{x},#{Mx[:fa_bold_c]} }
+ aname=x.gsub(/\s+/,'_')
+ @idx[:html] << %{\n<p class="book_index_lev1"><a name="##{aname}"><b>#{x}</b></a>, }
+ @o=@idx[:sst].index(@idx[:sst].last) #@o=@idx[:sst].length - 1
+ @q=@idx[:html].index(@idx[:html].last) #@o=@idx[:html].length - 1
+ print "\n" + x + ', ' if @md.cmd =~/V/
elsif x.class == Array
p 'array error? -->'
print x
@@ -175,43 +193,55 @@ module SiSU_book_index
if x['a1'].class == Array
x['a1'].each do |a|
if a[:range]
- print a[:range] + ', '
+ @idx[:sst][@o]=@idx[:sst][@o] + %{#{Mx[:lnk_o]}#{a[:range]}#{Mx[:lnk_c]}#{@env.url.root}/#{@md.fnb}/#{a[:seg]}.html##{a[:ocn]}, }
+ @idx[:html][@q]=@idx[:html][@q] + %{<a href="#{a[:seg]}.html##{a[:ocn]}">#{a[:range]}</a>, }
+ print a[:range] + ', ' if @md.cmd =~/V/
elsif a[:ocn]
- print a[:ocn] + ', '
+ @idx[:sst][@o]=@idx[:sst][@o] + %{#{Mx[:lnk_o]}#{a[:ocn]}#{Mx[:lnk_c]}#{@env.url.root}/#{@md.fnb}/#{a[:seg]}.html##{a[:ocn]}, }
+ @idx[:html][@q]=@idx[:html][@q] + %{<a href="#{a[:seg]}.html##{a[:ocn]}">#{a[:ocn]}</a>, }
+ print a[:ocn] + ', ' if @md.cmd =~/V/
else p 'error'
end
end
+ @idx[:html][@q]=@idx[:html][@q] + '</p>'
end
if x['b1']
m=x['b1']
m=m.sort
m.each do |k,y|
if k !~/a1/
- print "\n\t" + k + ', '
- #p y
+ @idx[:sst][@o]=@idx[:sst][@o] + %{#{k}, }
+ @idx[:html][@q]=@idx[:html][@q] + %{\n<p class="book_index_lev2">#{k}, }
+ print "\n\t" + k + ', ' if @md.cmd =~/V/
y.each do |z|
if z[:range]
- print z[:range] + ', '
+ @idx[:sst][@o]=@idx[:sst][@o] + %{#{Mx[:lnk_o]}#{z[:range]}#{Mx[:lnk_c]}#{@env.url.root}/#{@md.fnb}/#{z[:seg]}.html##{z[:ocn]}, }
+ @idx[:html][@q]=@idx[:html][@q] + %{<a href="#{z[:seg]}.html##{z[:ocn]}">#{z[:range]}</a>, }
+ print z[:range] + ', ' if @md.cmd =~/V/
elsif z[:ocn]
- print z[:ocn] + ', '
+ @idx[:sst][@o]=@idx[:sst][@o] + %{#{Mx[:lnk_o]}#{z[:ocn]}#{Mx[:lnk_c]}#{@env.url.root}/#{@md.fnb}/#{z[:seg]}.html##{z[:ocn]}, }
+ @idx[:html][@q]=@idx[:html][@q] + %{<a href="#{z[:seg]}.html##{z[:ocn]}">#{z[:ocn]}</a>, }
+ print z[:ocn] + ', ' if @md.cmd =~/V/
else p 'error'
end
end
+ @idx[:html][@q]=@idx[:html][@q] + '</p>'
end
end
end
+ @idx[:sst][@o]=@idx[:sst][@o] + " #{Mx[:id_o]}~0;0:0;x#{@x}#{Mx[:id_c]}"
+ @x +=1
end
end
end
+ print "\n" if @md.cmd =~/V/
+ @idx
end
- def screen_html(the_idx)
- @file_index_all << %{\n <link rel="stylesheet" href="../_sisu/css/html.css" type="text/css" />}
+ def screen_print(the_idx)
the_idx.each do |i|
i.each do |x|
if x.class == String
- @file_index_all << %{\n<p class="book_index_lev1"><b>#{x}</b>, }
- #@file_index_all << %{<br />\n<b>#{x}</b>, }
- print %{<br />\n<b>#{x}</b>, }
+ print "\n" + x + ', '
elsif x.class == Array
p 'array error? -->'
print x
@@ -219,36 +249,28 @@ module SiSU_book_index
if x['a1'].class == Array
x['a1'].each do |a|
if a[:range]
- @file_index_all << %{<a href="#{a[:seg]}.html##{a[:ocn]}">#{a[:range]}</a>, }
- print %{<a href="#{a[:seg]}.html##{a[:ocn]}">#{a[:range]}</a>, }
+ print a[:range] + ', '
elsif a[:ocn]
- @file_index_all << %{<a href="#{a[:seg]}.html##{a[:ocn]}">#{a[:ocn]}</a>, }
- print %{<a href="#{a[:seg]}.html##{a[:ocn]}">#{a[:ocn]}</a>, }
+ print a[:ocn] + ', '
else p 'error'
end
end
- @file_index_all << '</p>'
end
if x['b1']
m=x['b1']
m=m.sort
m.each do |k,y|
if k !~/a1/
- @file_index_all << %{\n<p class="book_index_lev2">#{k}, }
- #@file_index_all << %{<br />\n\t#{k}, }
- print %{<br />\n\t#{k}, }
+ print "\n\t" + k + ', '
#p y
y.each do |z|
if z[:range]
- @file_index_all << %{<a href="#{z[:seg]}.html##{z[:ocn]}">#{z[:range]}</a>, }
- print %{<a href="#{z[:seg]}.html##{z[:ocn]}">#{z[:range]}</a>, }
+ print z[:range] + ', '
elsif z[:ocn]
- @file_index_all << %{<a href="#{z[:seg]}.html##{z[:ocn]}">#{z[:ocn]}</a>, }
- print %{<a href="#{z[:seg]}.html##{z[:ocn]}">#{z[:ocn]}</a>, }
+ print z[:ocn] + ', '
else p 'error'
end
end
- @file_index_all << '</p>'
end
end
end
@@ -256,49 +278,18 @@ module SiSU_book_index
end
end
end
- def screen_sisu_markup(the_idx)
- the_idx.each do |i|
- i.each do |x|
- if x.class == String
- print %{\n\n#{Mx[:fa_bold_o]}#{x}#{Mx[:fa_bold_c]}, }
- #print %{\n\n#{Mx[:gr_o]}\n#{Mx[:fa_bold_o]}#{x}#{Mx[:fa_bold_c]}, }
- #print "\n" + x + ', '
- elsif x.class == Array
- p 'array error? -->'
- print x
- elsif x.class == Hash
- if x['a1'].class == Array
- x['a1'].each do |a|
- if a[:range]
- print %{#{Mx[:lnk_o]}#{a[:range]}#{Mx[:lnk_c]}#{@env.url.root}/#{@md.fnb}/#{a[:seg]}.html##{a[:ocn]}, }
- elsif a[:ocn]
- print %{#{Mx[:lnk_o]}#{a[:ocn]}#{Mx[:lnk_c]}#{@env.url.root}/#{@md.fnb}/#{a[:seg]}.html##{a[:ocn]}, }
- else p 'error'
- end
- end
- end
- if x['b1']
- m=x['b1']
- m=m.sort
- m.each do |k,y|
- if k !~/a1/
- print %{\n #{k}, }
- #print "\n\t" + k + ', '
- y.each do |z|
- if z[:range]
- print %{#{Mx[:lnk_o]}#{z[:range]}#{Mx[:lnk_c]}#{@env.url.root}/#{@md.fnb}/#{z[:seg]}.html##{z[:ocn]}, }
- elsif z[:ocn]
- print %{#{Mx[:lnk_o]}#{z[:ocn]}#{Mx[:lnk_c]}#{@env.url.root}/#{@md.fnb}/#{z[:seg]}.html##{z[:ocn]}, }
- else p 'error'
- end
- end
- puts " #{Mx[:id_o]}~0;0:0;u0#{Mx[:id_c]}"
- end
- end
- end
+ def clean_and_insert_index(data,sisu_markup_idx)
+ tuned_file=[]
+ data.each do |para|
+ para.gsub!(/\n*#{@rgx_idx}/m,'')
+ tuned_file << para
+ if para =~/#{Mx[:br_endnotes]}/ and sisu_markup_idx
+ sisu_markup_idx.each do |idx|
+ tuned_file << idx
end
end
end
+ tuned_file
end
def clean_index(data)
tuned_file=[]
diff --git a/lib/sisu/v0/dal_syntax.rb b/lib/sisu/v0/dal_syntax.rb
index 80635f36..cbcd42f9 100644
--- a/lib/sisu/v0/dal_syntax.rb
+++ b/lib/sisu/v0/dal_syntax.rb
@@ -357,6 +357,7 @@ module SiSU_Syntax
line.gsub!(/_<(br(?: \/)?)_>/,'<\1>') #convert <br> <br /> back, clumsy
line.gsub!(/(^|#{Mx[:gl_c]}|\s)&lt;(br(?: \/)?)&gt;([\s,.]|$)/,'\1<\2>\3') #convert <br> <br /> back, clumsy
line.gsub!(/#{Mx[:gr_o]}codeline#{Mx[:gr_c]}/,"\n#{Mx[:nbsp]}#{Mx[:nbsp]}") #temporary fix, prefer: #line.gsub!(/<:codeline>/,"\n")
+ line
else # 0~
end
line
diff --git a/lib/sisu/v0/html.rb b/lib/sisu/v0/html.rb
index e73157bd..df53d1b7 100644
--- a/lib/sisu/v0/html.rb
+++ b/lib/sisu/v0/html.rb
@@ -173,9 +173,6 @@ module SiSU_HTML
@md.file_type='html' if @md.cmd =~/[hon]/
directories
newfilename=%{#{@env.path.output}/#{@md.fnb}/#{@md.fn[:index]}} if @md.file_type =~/html/
- my_make_source_file=SiSU_Env::Create_file.new(@md.cmd,@md.fns)
- @fnm=my_make_source_file.marshal_meta
- @tune_verse_marshal=my_make_source_file.marshal_tune
dal_array=@particulars.dal_array # dal file drawn here
@tuned_file_array=SiSU_Tune::Tune.new(dal_array,@md).songsheet
@tuned_file_array
diff --git a/lib/sisu/v0/html_segments.rb b/lib/sisu/v0/html_segments.rb
index 8d89de28..796c3939 100644
--- a/lib/sisu/v0/html_segments.rb
+++ b/lib/sisu/v0/html_segments.rb
@@ -62,14 +62,43 @@ module SiSU_HTML_seg
require "#{SiSU_lib}/shared_html"
require "#{SiSU_lib}/html"
require "#{SiSU_lib}/html_promo"
+ class Seg_output
+ def initialize(outputfile,seg,minitoc,type='')
+ @output_seg_file,@seg,@minitoc,@type=outputfile,seg,minitoc,type
+ end
+ def output #CONSIDER
+ if @seg[:title] =~/\S/ #kludge (for exception file better.ways, how ironic) get a real ruby test, e.g. test that not array or...
+ filename_seg=[]
+ filename_seg << @seg[:title] << @seg[:tocband_banner]
+ if @type =~/endnote/
+#p @seg[:headers] #FIX endnote header
+ filename_seg << @seg[:header_endnotes] << @minitoc << @seg[:headers] << %{\n<div class="content">\n} << @seg[:endnote_all] << '</div>' # << '</div>'
+ elsif @type =~/idx/
+#p @seg[:headers] #FIX inserted index header
+ filename_seg << @seg[:header_idx] << @minitoc << @seg[:headers] << %{\n<div class="content">\n} << @seg[:idx] << '</div>' # << '</div>'
+ else
+ filename_seg << @minitoc << @seg[:headers] << @seg[:main] << "\n</div>\n"
+ end
+ filename_seg << @seg[:tail] << @seg[:tocband_bannerless] << @seg[:credits]
+ filename_seg.flatten!.compact!
+ filename_seg.each do |para|
+ unless para =~/\A\s*\Z/
+ para.strip!
+ @output_seg_file << para
+ end
+ end
+ @output_seg_file.close
+ end
+ end
+ end
class Seg
@@seg,@@seg_subtoc,@@seg_endnotes,@@seg_ad={},{},{},{}
- @@seg_name,@@seg_name_html,@@seg_name_php=[],[],[]
- @@filename_seg=@@filename_segphp=@@seg_url=@@fn=@@to_lev4=@@get_hash_to=@@get_hash_fn=''
+ @@seg_name,@@seg_name_html=[],[]
+ @@seg_url=@@fn=@@to_lev4=@@get_hash_to=@@get_hash_fn=''
@@loop_count=@@seg_total=@@tracker=0
@@is4=@@is3=@@is2=@@is1=0
@@header1=@@header2=@@header3=@@header4=0
- @@seg[:tocband_banner],@@seg[:tocband_bannerless],@@seg[:title],@@seg[:headers],@@seg[:main],@@seg[:tail],@@seg[:credits],@@seg_subtoc_array,@@seg_endnotes_array,@@seg[:endnote_all]=Array.new(10){[]}
+ @@seg[:tocband_banner],@@seg[:tocband_bannerless],@@seg[:title],@@seg[:headers],@@seg[:main],@@seg[:idx],@@seg[:tail],@@seg[:credits],@@seg_subtoc_array,@@seg_endnotes_array,@@seg[:endnote_all]=Array.new(11){[]}
@@seg[:header_endnotes]=''
@@tablehead,@@number_of_cols=0,0
@@flag_alt=false
@@ -85,7 +114,7 @@ module SiSU_HTML_seg
end
def songsheet
begin
- @@minitoc=SiSU_HTML::Source::Toc.new(@data,@md).minitoc
+ @minitoc=SiSU_HTML::Source::Toc.new(@data,@md).minitoc
data=get_subtoc_endnotes(@data)
data=articles(data)
Seg.new.cleanup # (((( added ))))
@@ -103,6 +132,13 @@ module SiSU_HTML_seg
@h_sfx='.php' if @md.file_type =~/php/
@h_sfx=@md.sfx if @md.file_type =~/html/
@h_sfx='.html' if @md.file_type =~/html/ #used in creating file, not to be omitted.
+ idx_html=nil
+ if @md.book_index
+ my_make_source_file=SiSU_Env::Create_file.new(@md.cmd,@md.fns)
+ idx_html=SiSU_Particulars::Combined_singleton.instance.get_html_idx(@md.opt).html_idx
+ idx_html.each {|x| @@seg[:idx] << x }
+ @@seg[:header_idx]=''
+ end
data.each do |para|
if para =~/^#{Mx[:lv_o]}4:/
@@seg_name << para[/^#{Mx[:lv_o]}4:(\S+?)#{Mx[:lv_c]}/,1]
@@ -153,20 +189,24 @@ module SiSU_HTML_seg
mkdir_p(@md.dir_out) unless FileTest.directory?(@md.dir_out) #bug - added specifically for nav! not needed by regular seg, check !!!
Seg.new('',@md).tail
segfilename="#{@md.dir_out}/#{@md.fnl[:pre]}#{@@seg_name_html[tracking-1]}#{@md.fnl[:mid]}#@h_sfx#{@md.fnl[:post]}"
- @@filename_seg=File.new(segfilename,'w') if @@seg_name_html[tracking-1]
- unless (@@seg_name_html[tracking-1] =~/endnotes/)
- Seg.new.output
- else Seg.new.output('endnotes')
+ @output_seg_file=File.new(segfilename,'w') if @@seg_name_html[tracking-1]
+ if @@seg_name_html[tracking-1] !~/endnotes|idx/
+ Seg_output.new(@output_seg_file,@@seg,@minitoc).output
+ elsif @@seg_name_html[tracking-1] =~/endnotes/
+ Seg_output.new(@output_seg_file,@@seg,@minitoc,'endnotes').output
+ elsif @@seg_name_html[tracking-1] =~/idx/
+ Seg_output.new(@output_seg_file,@@seg,@minitoc,'idx').output
+ else p 'check'
end
Seg.new.reinitialise
header_art(para)
head(para)
if @@seg_name_html[tracking] =~/metadata/ # this is for metadata
segfilename="#{@md.dir_out}/#{@md.fnl[:pre]}#{@@seg_name_html[tracking]}#{@md.fnl[:mid]}#@h_sfx#{@md.fnl[:post]}"
- @@filename_seg=File.new(segfilename,'w')
- Seg.new.reinitialise
+ @output_seg_file=File.new(segfilename,'w')
+ Seg.new.reinitialise #BUG with items following endnote, and occurring before metadata, this becomes a bug ... work area for book index, FIX
flagend="x"
- @@filename_seg.close #%(((( EOF )))) -->
+ @output_seg_file.close #%(((( EOF )))) -->
end
end
if tracking == 0
@@ -391,26 +431,6 @@ module SiSU_HTML_seg
ads=SiSU_HTML_promo::Ad.new(@md)
@@seg[:credits] << format_head_seg.credit << ads.div.close << ads.display << format_head_seg.html_close
end
- def output(type='')
- if @@seg[:title] =~/\S/ #kludge (for exception file better.ways, how ironic) get a real ruby test, e.g. test that not array or...
- filename_seg=[]
- filename_seg << @@seg[:title] << @@seg[:tocband_banner]
- if type !~/endnote/
- filename_seg << @@minitoc << @@seg[:headers] << @@seg[:main] << "\n</div>\n"
- else
- filename_seg << @@seg[:header_endnotes] << @@minitoc << @@seg[:headers] << %{\n<div class="content">\n} << @@seg[:endnote_all] << '</div>'
- end
- filename_seg << @@seg[:tail] << @@seg[:tocband_bannerless] << @@seg[:credits]
- filename_seg.flatten!.compact!
- filename_seg.each do |para|
- unless para =~/\A\s*\Z/
- para.strip!
- @@filename_seg << para
- end
- end
- @@filename_seg.close
- end
- end
def reinitialise
@@seg[:title],@@seg[:dot_nav],@@seg[:tocband_banner],@@seg[:tocband_bannerless],@@seg[:headers],@@seg[:main],@@seg[:tail],@@seg[:credits]=Array.new(8){[]}
@@segtocband=nil
@@ -433,11 +453,9 @@ module SiSU_HTML_seg
@@seg_endnotes_array=[] if para=~/^#{Mx[:lv_o]}4:/
@@fns_previous=@md.fns if para=~/^#{Mx[:lv_o]}1:meta#{Mx[:lv_c]}/
end
- if para =~/^#{Mx[:lv_o]}4:/ #% EXTRACTION OF SUB-TOCs
+ if para =~/^#{Mx[:lv_o]}4:/ #% EXTRACTION OF SUB-TOCs & SEGMENT NAME, after EXTRACTION OF ENDNOTES & SUB-TOCs
@@seg_subtoc[@@fn]=@@seg_subtoc_array
@@seg_subtoc_array=[]
- end
- if para =~/^#{Mx[:lv_o]}4:/ #% SEGMENT NAME, after EXTRACTION OF ENDNOTES & SUB-TOCs
if para !~/^#{Mx[:lv_o]}4:metadata#{Mx[:lv_c]}/
m=para[/^#{Mx[:lv_o]}4:(\S+?)#{Mx[:lv_c]}.+?#{Mx[:id_o]}~(\d+);(?:[oh]|4:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/]
end
diff --git a/lib/sisu/v0/odf.rb b/lib/sisu/v0/odf.rb
index d6558634..05a6272c 100644
--- a/lib/sisu/v0/odf.rb
+++ b/lib/sisu/v0/odf.rb
@@ -439,6 +439,7 @@ module SiSU_ODF
bullet=image_src('bullet_09.png')
cp("#{bullet}/bullet_09.png","#{@env.path.odf}/Pictures/.") #if image_src('bullet_09.png')
data.each do |para|
+ para.gsub!(/#{Mx[:id_o]}~0;0:0;x\d+#{Mx[:id_c]}/,'') # if book index? remove
#p para if para =~safe_characters and @md.cmd =~/V/ #KEEP
#para.gsub!(/&lt;(~\d+;(?:\w|[0-6]:)\d+;\w\d+)&gt;&lt;(#@dp:#@dp)&gt;/,'<\1><\2>')
para='' if para =~/#{Mx[:lv_o]}\d+:.*?#{Mx[:lv_c]}.+?#{Mx[:pa_non_object_dummy_heading]}/
diff --git a/lib/sisu/v0/particulars.rb b/lib/sisu/v0/particulars.rb
index 8ae4f66e..59b8956b 100644
--- a/lib/sisu/v0/particulars.rb
+++ b/lib/sisu/v0/particulars.rb
@@ -92,7 +92,11 @@ module SiSU_Particulars
set_env
set_md
end
- attr_accessor :opt,:md
+ def get_html_idx(opt)
+ @opt=opt
+ set_html_idx
+ end
+ attr_accessor :opt,:md,:html_idx
def set_md
begin
@md=SiSU_Param::Parameters.new(@opt).get
@@ -116,6 +120,13 @@ module SiSU_Particulars
rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error
end
end
+ def set_html_idx
+ begin
+ @html_idx=SiSU_DAL::Source.new(@md).get_idx_html
+ self
+ rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error
+ end
+ end
end
end
__END__
diff --git a/lib/sisu/v0/plaintext.rb b/lib/sisu/v0/plaintext.rb
index fb4b1115..754e366d 100644
--- a/lib/sisu/v0/plaintext.rb
+++ b/lib/sisu/v0/plaintext.rb
@@ -275,6 +275,7 @@ WOK
table_message='[table omitted, see other document formats]'
fix=[]
data.each do |para|
+ para.gsub!(/#{Mx[:id_o]}~0;0:0;x\d+#{Mx[:id_c]}/,'') # if book index? remove
para.gsub!(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}.+/um,"#@br#{table_message}")
para.gsub!(/.+?#{Mx[:gl_o]}-##{Mx[:gl_c]}/,'') # remove dummy headings (used by html) #check
para.gsub!(/#{Mx[:gl_bullet]}\s*/,'* ') # bullet markup, marked down
diff --git a/lib/sisu/v0/shared_xml.rb b/lib/sisu/v0/shared_xml.rb
index bf59830f..41e8c393 100644
--- a/lib/sisu/v0/shared_xml.rb
+++ b/lib/sisu/v0/shared_xml.rb
@@ -423,13 +423,11 @@ module SiSU_XML_munge
%{\\1#{@url_brace.xml_open}<link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="\\2">\\2</link>#{@url_brace.xml_close}\\3})
para.gsub!(/\b[_\\]((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,
'<link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="\1">\1</link>\2') #escaped urls not linked, deal with later
- para.gsub!(/&nbsp;|#{Mx[:nbsp]}/,'&#160;')
- #para.gsub!(/&nbsp;/,' ') #clean
else
para.gsub!(/(^|[^}])_</m,'\1&lt;'); para.gsub!(/(^|[^}])_>/m,'\1&gt;') #code-block: angle brackets special characters
para.gsub!(/(^|[^}])_</m,'\1&lt;'); para.gsub!(/(^|[^}])_>/m,'\1&gt;')
- para.gsub!(/&nbsp;|#{Mx[:nbsp]}/,'&#160;')
end
+ para.gsub!(/&nbsp;|#{Mx[:nbsp]}/m,'&#160;')
para
end
def markup_light(para='')
diff --git a/lib/sisu/v0/sysenv.rb b/lib/sisu/v0/sysenv.rb
index 93e6ea8e..25cf90ec 100644
--- a/lib/sisu/v0/sysenv.rb
+++ b/lib/sisu/v0/sysenv.rb
@@ -3033,12 +3033,18 @@ WOK
def file_meta
File.new("#{@env.path.dal}/#@fns.meta",'w+')
end
+ def file_meta_idx_html
+ File.new("#{@env.path.dal}/#@fns.idx.html",'w+')
+ end
def file_note
File.new("#{Dir.pwd}/#@fns.fn",'w+')
end
def marshal_meta
"#{@env.path.dal}/#@fns.meta.rbm"
end
+ def marshal_meta_idx_html
+ "#{@env.path.dal}/#@fns.idx_html.rbm"
+ end
def meta
"#{@env.path.dal}/#@fns.meta"
end
diff --git a/lib/sisu/v0/texpdf.rb b/lib/sisu/v0/texpdf.rb
index 3cf560c4..885643cf 100644
--- a/lib/sisu/v0/texpdf.rb
+++ b/lib/sisu/v0/texpdf.rb
@@ -693,6 +693,7 @@ WOK
paranum=if ocn; para[m,2]
else ''
end
+ paranum = '' if paranum.to_i == 0
txt_obj={:txt =>parablock,:ocn =>paranum}
do_duo=SiSU_TeX_Pdf::Format_text_object.new(@md,txt_obj)
para=do_duo.para_num if parablock