diff options
author | Ralph Amissah <ralph@amissah.com> | 2014-02-05 01:28:30 -0500 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2014-02-05 01:28:30 -0500 |
commit | ba017314c06829b8d8a92a85d2111a8582c4e1cc (patch) | |
tree | ae413a3c2eacce20422b238e0a57c16d5632adf8 /lib/sisu/v5 | |
parent | debian/changelog (5.3.0-1) (diff) | |
parent | README & manpage (sisu.1) update (diff) |
Merge tag 'sisu_5.3.1' into debian/sid
SiSU 5.3.1
Diffstat (limited to 'lib/sisu/v5')
41 files changed, 556 insertions, 229 deletions
diff --git a/lib/sisu/v5/ao_doc_str.rb b/lib/sisu/v5/ao_doc_str.rb index f7168c26..dd7f32f3 100644 --- a/lib/sisu/v5/ao_doc_str.rb +++ b/lib/sisu/v5/ao_doc_str.rb @@ -163,10 +163,13 @@ module SiSU_AO_DocumentStructureExtract str=str.gsub(/(^|[ ])\*~([a-z0-9._-]+)(?=[ #{Mx[:br_nl]}]|$)/i, "\\1#{Mx[:tag_o]}\\2#{Mx[:tag_c]}"). gsub(/ [ ]+/i,' ') - tags=str.scan(/#{Mx[:tag_o]}(\S+?)#{Mx[:tag_c]}/).flatten + tags=str.scan(/#{Mx[:tag_o]}(\S+?)#{Mx[:tag_c]}/).flatten.uniq str=str.gsub(/[ ]?#{Mx[:tag_o]}\S+?#{Mx[:tag_c]}[ ]?/,' ') #may be issues with spaces would leave one, but "code" blocks? end tags=nametag ? (tags << nametag) : tags + tags.each do |t| + t.gsub!(/[^a-z0-9._-]/,'') + end end [str,tags] end diff --git a/lib/sisu/v5/ao_hash_digest.rb b/lib/sisu/v5/ao_hash_digest.rb index 585ff659..3f372893 100644 --- a/lib/sisu/v5/ao_hash_digest.rb +++ b/lib/sisu/v5/ao_hash_digest.rb @@ -75,7 +75,11 @@ module SiSU_AO_Hash data=@data.compact @tuned_file=[] sha_ =(@env.digest.type=='sha256' ? true : false) - sha_ ? (require 'digest/sha2') : (require 'digest/md5') + begin + sha_ ? (require 'digest/sha2') : (require 'digest/md5') + rescue LoadError + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error((sha_ ? 'digest/sha2' : 'digest/md5') + ' NOT FOUND') + end data.each do |t_o| unless t_o.obj.is_a?(Array) t_o.obj=t_o.obj.strip diff --git a/lib/sisu/v5/ao_images.rb b/lib/sisu/v5/ao_images.rb index ab42034d..d01c98b8 100644 --- a/lib/sisu/v5/ao_images.rb +++ b/lib/sisu/v5/ao_images.rb @@ -62,8 +62,12 @@ =end module SiSU_AO_Images class Images - #require 'RMagick' - #include Magick + #begin + # require 'RMagick' + # include Magick + #rescue LoadError + # SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('RMagic NOT FOUND (LoadError)') + #end def initialize(md,data) @md,@data=md,data end diff --git a/lib/sisu/v5/ao_numbering.rb b/lib/sisu/v5/ao_numbering.rb index 8caa5ccc..984675cc 100644 --- a/lib/sisu/v5/ao_numbering.rb +++ b/lib/sisu/v5/ao_numbering.rb @@ -78,6 +78,14 @@ module SiSU_AO_Numbering data=set_heading_top(data) unless @md.set_heading_top [data,tags_map,ocn_html_seg_map] end + def set_tags(tags,tag) + tags=if not tag.empty? \ + and tag !~/^\d+$/ + tag=tag.gsub(/[^a-z0-9._-]/,'') + [tag,tags].flatten + else tags + end + end def number_plaintext_para(data) @tuned_file=[] data.each do |dob| @@ -168,10 +176,10 @@ module SiSU_AO_Numbering and not @md.seg_names.include?(title_no) if dob.ln==no1 dob.name="#{title_no}" if not dob.name - dob.tags=[title_no,dob.tags].flatten if title_no !~/^\d+$/ #check whether will work across file types with stop signs + dob.tags=set_tags(dob.tags,title_no) tag=dob.obj.gsub(/(Article|Clause|Section|Chapter)\s+/,"\\1_#{title_no}").downcase tag=heading_tag_clean(tag) - dob.tags=[tag,dob.tags].flatten if tag !~/^\d+$/ #check whether will work across file types with stop signs + dob.tags=set_tags(dob.tags,tag) dob.obj=(dob.obj =~/(Article|Clause|Section)\s+/) \ ? (dob.obj.gsub(/(Article|Clause|Section)\s+/,"\\1 #{title_no} ")) : (dob.obj.gsub(/^/,"#{title_no}. ")) #fix stop later @@ -179,7 +187,7 @@ module SiSU_AO_Numbering if dob.ln !=no1 \ and dob.obj =~/^[\d.]+\s/ #fix -> if the title starts with a numbering scheme, do not auto-number, review dob.name ="#{title_no}" if not dob.name - dob.tags=[title_no,dob.tags].flatten if title_no !~/^\d+$/ #check whether will work across file types with stop signs + dob.tags=set_tags(dob.tags,title_no) dob.obj=dob.obj.gsub(/^/,"#{title_no}. ") end @md.seg_names << title_no @@ -187,28 +195,28 @@ module SiSU_AO_Numbering if dob.ln!=no1 \ and dob.name!~/^[a-z_\.]+$/ \ and dob.obj !~/[A-Z]\.?\s/ #bug -> tmp fix, excludes A. B. C. lettering, but not roman numerals, is arbitrary, review required # not fixed, work on - dob.tags=[title_no,dob.tags].flatten if title_no !~/^\d+$/ #check whether will work across file types with stop signs + dob.tags=set_tags(dob.tags,title_no) dob.obj=dob.obj.gsub(/^/i,"#{title_no}. ") end end if dob.ln==no1 #watch because here you change dob.name - dob.tags=["h#{title_no}",dob.tags].flatten #check whether will work across file types with stop signs + dob.tags=set_tags(dob.tags,"h#{title_no}") end if dob.ln==no2 #watch because here you change dob.name t_no2+=1; t_no3=0 title_no="#{t_no1}.#{t_no2}" - dob.tags=["h#{title_no}",dob.tags].flatten #check whether will work across file types with stop signs + dob.tags=set_tags(dob.tags,"h#{title_no}") dob=number_sub_heading(dob,no2,title_no) end if dob.ln==no3 #watch because here you change dob.name t_no3+=1 title_no="#{t_no1}.#{t_no2}.#{t_no3}" - dob.tags=["h#{title_no}",dob.tags].flatten #check whether will work across file types with stop signs + dob.tags=set_tags(dob.tags,"h#{title_no}") dob=number_sub_heading(dob,no3,title_no) end elsif dob.ln.to_s =~/^[0-6]/ \ and dob.name =~ /^[\w-]+-/ # endnotes, watch2005# endnotes, watch2005 - dob.tags=[dob.name,dob.tags].flatten if dob.name !~/^\d+$/ #check whether will work across file types with stop signs + dob.tags=set_tags(dob.tags,dob.name) dob.name.gsub(/^([a-z_\.]+)-$/,'\1') end elsif dob.is ==:heading \ @@ -219,13 +227,13 @@ module SiSU_AO_Numbering and dob.ln.to_s =~/^[0-9]/ \ and dob.obj =~ /^([\d\.]+)/ #risky (must be unique) consider output to 4~~\d instead of 4~\d dob.name=$1 - dob.tags=[dob.name,dob.tags].flatten if dob.name !~/^\d+$/ #check whether will work across file types with stop signs + dob.tags=set_tags(dob.tags,dob.name) end if @md.toc_lev_limit end elsif defined? dob.name \ and dob.name - dob.tags=[dob.name,dob.tags].flatten if dob.name !~/^\d+$/ #check whether will work across file types with stop signs + dob.tags=set_tags(dob.tags,dob.name) end dob.tags=dob.tags.uniq if defined? dob.tags @tuned_file << dob @@ -312,7 +320,7 @@ module SiSU_AO_Numbering if @md.seg_names.is_a?(Array) \ and not @md.seg_names.include?(possible_seg_name) dob.name=possible_seg_name - dob.tags=[dob.name,dob.tags].flatten if dob.name !~/^\d+$/ + dob.tags=set_tags(dob.tags,dob.name) @md.seg_names << possible_seg_name elsif (@md.opt.act[:verbose_plus][:set]==:on \ or @md.opt.act[:maintenance][:set]==:on) @@ -323,7 +331,7 @@ module SiSU_AO_Numbering and dob.name #extract segment name from embedded document structure info if @md.seg_names.is_a?(Array) \ and not @md.seg_names.include?(dob.name) - dob.tags=[dob.name,dob.tags].flatten if dob.name !~/^\d+$/ + dob.tags=set_tags(dob.tags,dob.name) @md.seg_names << dob.name end end @@ -334,7 +342,7 @@ module SiSU_AO_Numbering if @md.seg_names.is_a?(Array) \ and not @md.seg_names.include?(segn_auto) dob.name=segn_auto - dob.tags=[dob.name,dob.tags].flatten if dob.name !~/^\d+$/ #check whether will work across file types with stop signs + dob.tags=set_tags(dob.tags,dob.name) @md.seg_names << segn_auto else puts 'segment name (numbering) error' end diff --git a/lib/sisu/v5/cgi_pgsql.rb b/lib/sisu/v5/cgi_pgsql.rb index 33e43b46..4281d9d3 100644 --- a/lib/sisu/v5/cgi_pgsql.rb +++ b/lib/sisu/v5/cgi_pgsql.rb @@ -74,12 +74,12 @@ module SiSU_CGI_PgSQL get_init=SiSU_Env::GetInit.new @rc=get_init.sisu_yaml.rc @name_of={} - @name_of[:output_dir_structure]=if @opt.dir_structure_by.to_s =~/(?:language|filetype|filename)/ - @opt.dir_structure_by.to_s + @name_of[:output_dir_structure]=if opt.dir_structure_by.to_s =~/(?:language|filetype|filename)/ + opt.dir_structure_by.to_s else 'language' end - @name_of[:lingual]=if @opt.lingual.to_s =~/(?:mono|multi)/ - @opt.lingual.to_s + @name_of[:lingual]=if opt.lingual.to_s =~/(?:mono|multi)/ + opt.lingual.to_s else 'multi' end if defined? @rc['search'] \ @@ -93,13 +93,13 @@ module SiSU_CGI_PgSQL @name_of[:db]=@env.path.stub_pwd #'sisu' #breaks if not present false end - @name_of[:host_url_cgi]="#{@env.url.webserv_base_cgi(@opt)}/cgi-bin" - @name_of[:host_url_docs]=@env.url.webserv_files_from_db(@opt) - @name_of[:cgi_script]=@env.url.cgi_sample_search_form_name(@opt) - @name_of[:user]=@db.psql.user(@opt) + @name_of[:host_url_cgi]="#{@env.url.webserv_base_cgi(opt)}/cgi-bin" + @name_of[:host_url_docs]=@env.url.webserv_files_from_db(opt) + @name_of[:cgi_script]=@env.url.cgi_sample_search_form_name(opt) + @name_of[:user]=@db.psql.user(opt) @cgi_file_name=@name_of[:cgi_script] - @image_src="#{@env.url.webserv_base_cgi(@opt)}/_sisu/image_sys" - @common=SiSU_CGI_SQL::CGI_Common.new(@webserv,@opt,@image_src,@env) + @image_src="#{@env.url.webserv_base_cgi(opt)}/_sisu/image_sys" + @common=SiSU_CGI_SQL::CGI_Common.new(@webserv,opt,@image_src,@env) end def pgsql serve=[] @@ -174,13 +174,13 @@ module SiSU_CGI_PgSQL sudo chmod -v 755 /usr/lib/cgi-bin/#{@cgi_file_name} WOK end - SiSU_Screen::Ansi.new(opt.act[:color_state][:set],a).warn + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],a).warn a=<<-WOK #{@env.webserv_base_cgi(@opt)}/cgi-bin/#{@cgi_file_name} WOK - SiSU_Screen::Ansi.new(opt.act[:color_state][:set],a).print_blue + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],a).print_blue a="\n\t(to create and populate postgresql database see 'man sisu' and in particular the --pg option)\n\t[the database to be used for this directory (#{@db.psql.db}) will have to be created manually if it does not exist,\n\tusing postgresql tools directly: 'createdb #{@db.psql.db}' for a list of existing databases try 'psql --list']" - SiSU_Screen::Ansi.new(opt.act[:color_state][:set],a).txt_grey + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],a).txt_grey else puts 'failed in attempt to write #{@cgi_file_name} to present directory, is directory writable?' end end @@ -192,9 +192,13 @@ module SiSU_CGI_PgSQL * Description: generates naive cgi search form for search of sisu database (pgsql) #{gpl} =end - require 'cgi' - require 'fcgi' - require 'dbi' + begin + require 'cgi' + require 'fcgi' + require 'dbi' + rescue LoadError + puts 'cgi, fcgi or dbi NOT FOUND (LoadError)' + end @stub_default='#{@name_of[:db]}' @image_src='#{@image_src}' @hosturl_cgi='#{@name_of[:host_url_cgi]}' diff --git a/lib/sisu/v5/cgi_sqlite.rb b/lib/sisu/v5/cgi_sqlite.rb index 8ebe0c16..c4222ecb 100644 --- a/lib/sisu/v5/cgi_sqlite.rb +++ b/lib/sisu/v5/cgi_sqlite.rb @@ -69,18 +69,18 @@ module SiSU_CGI_SQLite @opt,@webserv=opt,webserv @cX=SiSU_Screen::Ansi.new(opt.act[:color_state][:set]).cX @env=SiSU_Env::InfoEnv.new('',opt) - @image_src="#{@env.url.webserv_cgi(@opt)}/_sisu/image_sys" + @image_src="#{@env.url.webserv_cgi(opt)}/_sisu/image_sys" @name_of={} - @name_of[:output_dir_structure]=if @opt.dir_structure_by.to_s =~/(?:language|filetype|filename)/ - @opt.dir_structure_by.to_s + @name_of[:output_dir_structure]=if opt.dir_structure_by.to_s =~/(?:language|filetype|filename)/ + opt.dir_structure_by.to_s else 'language' end - @name_of[:lingual]=if @opt.lingual.to_s =~/(?:mono|multi)/ - @opt.lingual.to_s + @name_of[:lingual]=if opt.lingual.to_s =~/(?:mono|multi)/ + opt.lingual.to_s else 'multi' end - @common=SiSU_CGI_SQL::CGI_Common.new(@webserv,@opt,@image_src,@env) - @cgi_file_name=@env.url.cgi_sample_search_form_name(@opt) + @common=SiSU_CGI_SQL::CGI_Common.new(@webserv,opt,@image_src,@env) + @cgi_file_name=@env.url.cgi_sample_search_form_name(opt) @name_of_sqlite_db_file='sisu_sqlite.db' end def sqlite @@ -147,13 +147,13 @@ module SiSU_CGI_SQLite WOK end b='(to create and populate sisu sqlite database see "man sisu" and in particular the -d flag)' - SiSU_Screen::Ansi.new(opt.act[:color_state][:set],a,b).warn + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],a,b).warn a=<<-WOK #{@env.webserv_base_cgi(@opt)}/cgi-bin/#{@cgi_file_name} WOK - SiSU_Screen::Ansi.new(opt.act[:color_state][:set],a).print_blue + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],a).print_blue else puts "failed in attempt to write #{@cgi_file_name} to present directory, is directory writable?" end end @@ -165,9 +165,13 @@ module SiSU_CGI_SQLite * Description: generates naive cgi search form for search of sisu database (sqlite) #{gpl} =end - require 'cgi' - require 'fcgi' - require 'dbi' + begin + require 'cgi' + require 'fcgi' + require 'dbi' + rescue LoadError + puts 'cgi, fcgi or dbi NOT FOUND (LoadError)' + end @stub_default='sisu_sqlite' @image_src='#{@image_src}' @hosturl_cgi='#{@env.url.webserv_base_cgi(@opt)}/cgi-bin' diff --git a/lib/sisu/v5/composite.rb b/lib/sisu/v5/composite.rb index c1457779..9e7ccb5c 100644 --- a/lib/sisu/v5/composite.rb +++ b/lib/sisu/v5/composite.rb @@ -178,10 +178,14 @@ module SiSU_Assemble end tuned_file << if loadfile =~ /(?:https?|file):\/\/\S+?\.ss[ti]$/ # and NetTest imagedir = /((?:https?|file):\/\/\S+?)\/[^\/]+?\.ss[ti]$/.match(loadfile).captures.join + '/_sisu/image' #watch - require 'uri' + begin + require 'uri' + require 'open-uri' + require 'pp' + rescue LoadError + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('uri, open-uri or pp NOT FOUND (LoadError)') + end image_uri=URI.parse(imagedir) - require 'open-uri' - require 'pp' insert=open(loadfile) insert_array=insert.dup insert.close diff --git a/lib/sisu/v5/concordance.rb b/lib/sisu/v5/concordance.rb index 55892ab7..b9030123 100644 --- a/lib/sisu/v5/concordance.rb +++ b/lib/sisu/v5/concordance.rb @@ -240,12 +240,13 @@ WOK end end protected - def location_scroll(wordlocation,show) - %{<a href="doc#{@md.lang_code_insert}#{Sfx[:html]}\##{wordlocation}">#{wordlocation}</a>; } + def location_scroll(wordlocation,show) # not used + %{<a href="doc#{@md.lang_code_insert}#{Sfx[:html]}\##{Mx[:ocn_id_char]}#{wordlocation}">#{wordlocation}</a>; } end - def location_seg(wordlocation,show) ##fix + def location_seg(wordlocation,show) unless wordlocation.nil? - wl=wordlocation.gsub(/(.+?)\#(\d+)/,"\\1#{@md.lang_code_insert}#{Sfx[:html]}#\\2") + wl=wordlocation.gsub(/(.+?)\#(\d+)/, + "\\1#{@md.lang_code_insert}#{Sfx[:html]}##{Mx[:ocn_id_char]}\\2") # id="o\d+" always available; a name="\d+" not available if html strict used case wordlocation when /#{@rxp_t1}|@rxp_t2}|#{@rxp_t3}/ %{[<a href="doc#{@md.lang_code_insert}#{Sfx[:html]}##{show}">H</a>]#{show}, } diff --git a/lib/sisu/v5/constants.rb b/lib/sisu/v5/constants.rb index e84c0901..a9be54f0 100644 --- a/lib/sisu/v5/constants.rb +++ b/lib/sisu/v5/constants.rb @@ -101,6 +101,13 @@ Xx={ html_relative1: '※', } Mx={ + ocn_id_char: 'o', + note: 'note_', + note_ref: 'noteref_', + note_astx: 'note_astx_', + note_ref_astx: 'noteref_astx_', + note_plus: 'note_plus_', + note_ref_plus: 'noteref_plus_', meta_o: '〔@', meta_c: '〕', lv_o_0: 0, lv_o_1: 1, diff --git a/lib/sisu/v5/db_import.rb b/lib/sisu/v5/db_import.rb index 8d9fc229..0dc5a29b 100644 --- a/lib/sisu/v5/db_import.rb +++ b/lib/sisu/v5/db_import.rb @@ -66,7 +66,6 @@ module SiSU_DbImport require_relative 'db_load_tuple' # db_load_tuple.rb require_relative 'db_sqltxt' # db_sqltxt.rb require_relative 'html_lite_shared' # html_lite_shared.rb - require 'sqlite3' class Import < SiSU_DbText::Prepare include SiSU_Param include SiSU_Screen diff --git a/lib/sisu/v5/dbi.rb b/lib/sisu/v5/dbi.rb index d92f1964..1ab9bc9c 100644 --- a/lib/sisu/v5/dbi.rb +++ b/lib/sisu/v5/dbi.rb @@ -120,9 +120,12 @@ manually create the database: "#{cX.green}#{@db.db}#{cX.off}" if it does not yet end def read_sqlite begin - @conn=@db.sqlite.conn_sqlite3 - rescue - ensure + begin + require 'sqlite3' + @conn=@db.sqlite.conn_sqlite3 + rescue LoadError + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('sqlite3 NOT FOUND (LoadError)') + end end end def connect diff --git a/lib/sisu/v5/dbi_discrete.rb b/lib/sisu/v5/dbi_discrete.rb index 0981455c..cd8c7de1 100644 --- a/lib/sisu/v5/dbi_discrete.rb +++ b/lib/sisu/v5/dbi_discrete.rb @@ -69,8 +69,12 @@ module SiSU_DBI_Discrete #% database building include SiSU_DbDBI require_relative 'html_lite_shared' # html_lite_shared.rb include SiSU_FormatShared - require 'fileutils' - include FileUtils::Verbose + begin + require 'fileutils' + include FileUtils::Verbose + rescue LoadError + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('fileutils NOT FOUND (LoadError)') + end class SQL def initialize(opt) SiSU_Env::Load.new('dbi',true).prog @@ -145,9 +149,12 @@ module SiSU_DBI_Discrete #% database building end def read_sqlite begin - @conn=@db.sqlite.conn_sqlite3 - rescue - ensure + begin + require 'sqlite3' + @conn=@db.sqlite.conn_sqlite3 + rescue LoadError + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('sqlite3 not available') + end end end def connect diff --git a/lib/sisu/v5/defaults.rb b/lib/sisu/v5/defaults.rb index fd56c2c4..25dd270a 100644 --- a/lib/sisu/v5/defaults.rb +++ b/lib/sisu/v5/defaults.rb @@ -62,7 +62,11 @@ =end $latex_run=nil module SiSU_Viz - require 'uri' + begin + require 'uri' + rescue LoadError + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('uri NOT FOUND (LoadError)') + end require_relative 'sysenv' # sysenv.rb include SiSU_Env require_relative 'css' # css.rb diff --git a/lib/sisu/v5/digests.rb b/lib/sisu/v5/digests.rb index 2b010374..7099b646 100644 --- a/lib/sisu/v5/digests.rb +++ b/lib/sisu/v5/digests.rb @@ -91,9 +91,13 @@ module SiSU_DigestView if @opt.act[:verbose_plus][:set]==:on \ or @opt.act[:maintenance][:set]==:on SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],@opt.fns,"file://#{@md.file.output_path.hash_digest.dir}/#{@md.file.base_filename.hash_digest}").flow + end + end + if SiSU_Env::SystemCall.new.openssl + SiSU_DigestView::Source::Scroll.new(@particulars).songsheet + else + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('*EXITED* hash digests will not run without openssl') end - end - SiSU_DigestView::Source::Scroll.new(@particulars).songsheet rescue SiSU_Errors::Rescued.new($!,$@,@opt.cmd,@opt.fns).location do __LINE__.to_s + ':' + __FILE__ diff --git a/lib/sisu/v5/html.rb b/lib/sisu/v5/html.rb index f473f1b7..4a911d2c 100644 --- a/lib/sisu/v5/html.rb +++ b/lib/sisu/v5/html.rb @@ -61,7 +61,11 @@ =end module SiSU_HTML - require 'pstore' + begin + require 'pstore' + rescue LoadError + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('pstore NOT FOUND (LoadError)') + end require_relative 'particulars' # particulars.rb include SiSU_Particulars require_relative 'defaults' # defaults.rb @@ -241,6 +245,7 @@ module SiSU_HTML def initialize(md=nil,data='') @data,@md=data,md @vz=SiSU_Viz::Defaults.new + @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 @@ -352,7 +357,7 @@ WOK title=if dob.ocn ==0 then linkname else @@toc[:scr] << '<br />' - %{<b><a href="##{dob.ocn}">#{linkname}</a></b>} + %{<b><a href="##{@ocn_html_identifier}#{dob.ocn}">#{linkname}</a></b>} end txt_obj={ txt: title } format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) @@ -394,7 +399,7 @@ WOK end else @@toc[:scr] << '<br />' - %{<b><a href="##{dob.ocn}">#{linkname}</a></b>} + %{<b><a href="##{@ocn_html_identifier}#{dob.ocn}">#{linkname}</a></b>} end txt_obj={ txt: title } format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) @@ -511,7 +516,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}"> + lnk_n_txt=%{ <a href="#{f}##{@ocn_html_identifier}#{ocn}"> #{linkname} </a>} txt_obj={ txt: lnk_n_txt } @@ -536,7 +541,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}"> + lnk_n_txt=%{ <a href="#{f}##{@ocn_html_identifier}#{ocn}"> #{linkname} </a>} txt_obj={ txt: lnk_n_txt } @@ -618,7 +623,8 @@ WOK toc_shared << format_txt_obj.center_bold @segtoc << format_txt_obj.center_bold if defined? @md.creator.author - creator_endnote=@md.creator.author.gsub(/(\*+)/, + creator=SiSU_HTML_Tune::CleanHTML.new(@md.creator.author).clean_for_html + creator_endnote=creator.gsub(/(\*+)/, %{ <sup><a href="#notes">\\1</a></sup>}) tmp_head=creator_endnote + "\n" txt_obj={ txt: tmp_head } diff --git a/lib/sisu/v5/html_format.rb b/lib/sisu/v5/html_format.rb index 3b15502f..e244bbb8 100644 --- a/lib/sisu/v5/html_format.rb +++ b/lib/sisu/v5/html_format.rb @@ -66,30 +66,36 @@ 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 - make=SiSU_Env::ProcessingSettings.new(@md) - if make.build.ocn? - ocn_class='ocn' + if @make.build.ocn? if @ocn.to_i==0 \ or @ocn.empty? - %{<label class="ocn_off"> </label>} + '' else + name=(@make.build.html_strict?) ? '' : %{ name="#{@ocn}"} @ocn.gsub(/^(\d+|)$/, - %{<label class="#{ocn_class}"><a name="#{@ocn}" href="##{@ocn}" class="lnk#{ocn_class}">\\1</a></label>}) + %{<label class="ocn"><a#{name} href="##{@ocn_html_identifier}#{@ocn}" class="lnkocn">\\1</a></label>}) end else - %{<label class="ocn_off"> </label>} + '' end end def name - (@ocn==nil || @ocn.empty?) ? '' : %{<a name="#{@ocn}"></a>} + if @make.build.html_strict? \ + or @ocn==(nil || @ocn.empty?) + '' + else + %{<a name="#{@ocn}"></a>} + end end def id #w3c? "tidy" complains about numbers as identifiers ! annoying (@ocn==nil || @ocn.empty?) ? '' : %{id="o#{@ocn}"} end def goto - (@ocn==nil || @ocn.empty?) ? '' : %{<a href="##{@ocn}">} + (@ocn==nil || @ocn.empty?) ? '' : %{<a href="##{@ocn_html_identifier}#{@ocn}">} end end class HeadInformation @@ -271,24 +277,6 @@ module SiSU_HTML_Format else '' end end - def pdf #retired 2.7.9 - pdf=if @md.programs[:pdf] \ - and @cf_defaults.cf_0 =~/p/ - %{ -<td align="center" bgcolor=#{@vz.color_band2}> - <a href="#{Xx[:html_relative1]}pdf/#{@file.base_filename.pdf_p}" target="_top"> - #{@vz.nav_txt_pdf_portrait} - </a> -</td> -<td align="center" bgcolor=#{@vz.color_band2}> - <a href="#{Xx[:html_relative1]}pdf/#{@file.base_filename.pdf_l}" target="_top"> - #{@vz.nav_txt_pdf_landscape} - </a> -</td> -} - else '' - end - end end class XML end @@ -514,7 +502,8 @@ WOK end def rights def all - rights=@md.rights.all.gsub(/^\s*Copyright\s+\(C\)/,'Copyright <sup>©</sup> ') + rights=SiSU_HTML_Tune::CleanHTML.new(@md.rights.all).clean_for_html + rights=rights.gsub(/^\s*Copyright\s+\(C\)/,'Copyright <sup>©</sup> ') %{<p class="small_left">Rights: #{rights}</p> <p />} end @@ -648,8 +637,6 @@ WOK def initialize(md) super(md) end - def title_banner(title,subtitle,creator) - end def dot_control_pre_next pre="#{@seg_name_html[@seg_name_html_tracker-1]}#{@md.lang_code_insert}#{Sfx[:html]}" up=@toc @@ -894,6 +881,7 @@ WOK attr_accessor :md,:t_o,:txt,:ocn,:format,:table,:link,:linkname,:paranum,:p_num,:headname,:banner,:url def initialize(md,t_o) @md,@t_o=md,t_o + @make=SiSU_Env::ProcessingSettings.new(@md) if t_o.is_a?(Hash) @txt =t_o[:txt] || nil @ocn =t_o[:ocn] || nil @@ -917,19 +905,19 @@ WOK p caller end end - @headnamed= (@headname ? %{<a name="h#{@headname}" id="h#{@headname}"></a>} : nil) + @headnamed=(@headname ? %{<a id="h#{@headname}"></a>} : nil) if @txt and not @txt.empty? @txt=@txt.gsub(/#{Mx[:mk_o]}[-~]##{Mx[:mk_c]}/,'') end @p_num=ParagraphNumber.new(@md,@ocn) @vz=SiSU_Viz::Defaults.new - @make=SiSU_Env::ProcessingSettings.new(@md) end def nametags_scroll(dob) tags='' if defined? dob.tags \ and dob.tags.length > 0 # insert tags "hypertargets" dob.tags.each do |t| + t=t.gsub(/[^a-z0-9._-]/,'') #use for all html tags? consider limiting to strict? or implementing earlier tags=tags << %{<named id="#{t}" />} end end @@ -940,7 +928,16 @@ WOK if defined? dob.tags \ and dob.tags.length > 0 # insert tags "hypertargets" dob.tags.each do |t| - tags=tags << %{<a name="#{t}" ></a>} + t=t.gsub(/[^a-z0-9._-]/,'') #use for all html tags? consider limiting to strict? or implementing earlier + if @make.build.html_strict? + tags=(t =~/^[#{Mx[:ocn_id_char]}]?[0-9.]+$/) \ + ? tags #check what can be sorted in ao + : (tags << %{<a name="#{t}" ></a>}) + else + tags=(t =~/^[#{Mx[:ocn_id_char]}][0-9.]+$/) \ + ? tags #check what can be sorted in ao + : (tags << %{<a name="#{t}" ></a>}) + end end end tags @@ -949,8 +946,8 @@ WOK hn=if @t_o.is ==:heading \ and not @t_o.name.empty? #determine use hn=(@t_o.is ==:heading) \ - ? (%{<a name="h#{@t_o.name}" id="h#{@t_o.name}"></a>}) - : (%{<a name="#{@t_o.name}" id="#{@t_o.name}"></a>}) + ? (%{<a id="h#{@t_o.name}"></a>}) + : (%{<a id="#{@t_o.name}"></a>}) else nil end hn @@ -981,7 +978,9 @@ WOK end def para_form_css(tag,attrib) # regular paragraphs shaped here ul=ulc='' - ul,ulc="<ul>\n ","\n </ul>" if @tag =~/li/ + if tag =~/li/ + ul,ulc="<ul>\n ","\n </ul>" + end %{ <div class="substance"> #{@p_num.ocn_display} @@ -1037,7 +1036,7 @@ WOK <div class="substance"> #{@p_num.ocn_display} <#{tag} class="#{attrib}" #{@p_num.id}>#{@p_num.name} - #{@named}<a name="h#{@headname}">#{@txt}</a> + #{@named}#{@txt} </#{tag}> </div> } @@ -1151,8 +1150,6 @@ WOK #{@vz.table_close}} end def bold_heading - @txt=@txt.gsub(/[1-9]~(\S+)/,'<a name="\1"></a>'). - gsub(/[1-9]~/,'') %{<p class="bold"> #{@txt} </p> @@ -1245,6 +1242,7 @@ 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 @@ -1253,12 +1251,12 @@ WOK note='' if txt =~/(#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})/m # had \s* at end note=$1 - note=note.gsub(/[\n\s]+/m,' ') + note=note.gsub(/[\s]+/m,' ') txt=txt.gsub(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' '). - gsub(/<a[\n\s]+name="-\d+"[\n\s]+href="#_\d+"> <sup>\d+<\/sup> /m,'') + gsub(/<a[\s]+name="-\d+"[\s]+href="#_\d+"> <sup>\d+<\/sup> /m,'') end %{<#{tag} class="#{attrib}"> - <a href="##{@ocn}"><i>#{txt}</i></a> #{note} + <a href="##{@ocn_html_identifier}#{@ocn}"><i>#{txt}</i></a> #{note} </#{tag}>} end def subtoc_lev5 diff --git a/lib/sisu/v5/html_lite_shared.rb b/lib/sisu/v5/html_lite_shared.rb index 8c447352..e109debc 100644 --- a/lib/sisu/v5/html_lite_shared.rb +++ b/lib/sisu/v5/html_lite_shared.rb @@ -83,6 +83,7 @@ module SiSU_FormatShared end @tab="\t" @brace_url=SiSU_Viz::Defaults.new.url_decoration + @ocn_html_identifier=SiSU_Env::ProcessingSettings.new(@md).ocn_html_identifier @@tablehead,@@tablefoot=[],[] @vz=SiSU_Viz::Defaults.new @env=SiSU_Env::InfoEnv.new(@md.fns) @@ -205,7 +206,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}">#{@txt}</a></p>\n} #<< "\n" + %{<p class="toc#{@lv}" header="#{@hname}"><a href="##{@ocn_html_identifier}#{@ocn}">#{@txt}</a></p>\n} #<< "\n" end def lev_toc h={ txt: txt, class: "toc#{@lv}", type: 'toc' } @@ -309,10 +310,10 @@ GSUB def paragraph attrib=%{class="#{@attrib}" } if @ocn - id=%{id="#{@ocn}" } + id=%{id="#{Mx[:ocn_id_char]}#{@ocn}" } type=%{type="substantive" } else - id=%{id="none" } + id='' type=%{type="comment" } end header=%{header="#{@hname}" } if @hname diff --git a/lib/sisu/v5/html_minitoc.rb b/lib/sisu/v5/html_minitoc.rb index dae74c46..5366b127 100644 --- a/lib/sisu/v5/html_minitoc.rb +++ b/lib/sisu/v5/html_minitoc.rb @@ -71,6 +71,7 @@ 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 @@ -204,7 +205,7 @@ fn: @@seg_url, } f=@md.file.base_filename.html_seg(fnh) - lnk_n_txt=%{ <a href="#{f}##{txt.ocn}"> + lnk_n_txt=%{ <a href="#{f}##{@ocn_html_identifier}#{txt.ocn}"> #{txt.obj} </a>} txt_obj={ txt: lnk_n_txt } @@ -223,7 +224,7 @@ fn: @@seg_url, } f=@md.file.base_filename.html_seg(fnh) - lnk_n_txt=%{ <a href="#{f}##{txt.ocn}"> + lnk_n_txt=%{ <a href="#{f}##{@ocn_html_identifier}#{txt.ocn}"> #{txt.obj} </a>} txt_obj={ txt: lnk_n_txt } diff --git a/lib/sisu/v5/html_segments.rb b/lib/sisu/v5/html_segments.rb index b710db81..7a368b9d 100644 --- a/lib/sisu/v5/html_segments.rb +++ b/lib/sisu/v5/html_segments.rb @@ -502,7 +502,7 @@ module SiSU_HTML_Seg '<br /><hr width=90% /><br />' end if @md.flag_separate_endnotes - dob.obj=dob.obj.gsub(/"\s+href="#_(\d+)">/,%{" href=\"endnotes#{Sfx[:html]}#_\\1">}) #endnote- twice #removed file type + dob.obj=dob.obj.gsub(/"\s+href="#(#{Mx[:note]}\d+)">/,%{" href=\"endnotes#{Sfx[:html]}#\\1">}) #endnote- twice #removed file type end if dob.obj !~/#{@vz.margin_txt_w1}|#{@vz.margin_txt_w2}/ if (dob.is==:heading \ @@ -600,7 +600,7 @@ module SiSU_HTML_Seg @@seg_subtoc_array << subtoc end if @md.flag_auto_endnotes - if (dob.obj =~/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]})[\d*+]+ <a name="_[\d*+]+"/) \ + if (dob.obj =~/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]})[\d*+]+ <a name="#{Mx[:note]}[\d*+]+"/) \ && dob.is !=:code # endnote- endnote_array=[] if dob.obj=~/#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}/m @@ -629,7 +629,7 @@ module SiSU_HTML_Seg end try.join('<br \/>') #% creation of separate end segment/page of all endnotes referenced back to reference segment - m=/(?:#{Mx[:en_a_o]}[\d*+]+|#{Mx[:en_b_o]}[*+]\d+)\s+(.+?href=")(#-[\d*+]+".+)(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/mi + m=/(?:#{Mx[:en_a_o]}[\d*+]+|#{Mx[:en_b_o]}[*+]\d+)\s+(.+?href=")(##{Mx[:note_ref]}[\d*+]+".+)(?:#{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 } diff --git a/lib/sisu/v5/html_tune.rb b/lib/sisu/v5/html_tune.rb index e9392ca8..39cbb708 100644 --- a/lib/sisu/v5/html_tune.rb +++ b/lib/sisu/v5/html_tune.rb @@ -104,6 +104,16 @@ module SiSU_HTML_Tune def initialize(html='') @html=html end + def clean_for_html + html=@html + str=if html.is_a?(String) + html + else html.obj + end + str=str.gsub(/#{Mx[:gl_o]}(#[0-9]{3})#{Mx[:gl_c]}/u,'&\1;'). + gsub(/#{Mx[:gl_o]}#([a-z]{2,4})#{Mx[:gl_c]}/u,'&\1;'). + gsub(/[<]/m,'<').gsub(/[>]/m,'>') + end def clean html=@html str=if html.is_a?(String) @@ -111,7 +121,8 @@ module SiSU_HTML_Tune else html.obj end str=str.gsub(/#{Mx[:gl_o]}(#[0-9]{3})#{Mx[:gl_c]}/u,'&\1;'). - gsub(/#{Mx[:gl_o]}#([a-z]{2,4})#{Mx[:gl_c]}/u,'&\1;') + gsub(/#{Mx[:gl_o]}#([a-z]{2,4})#{Mx[:gl_c]}/u,'&\1;'). + gsub(/[\\]{2}/m,'<br />') end end class Tune @@ -256,14 +267,14 @@ module SiSU_HTML_Tune def endnotes_html(dob) unless dob.is ==:code dob.obj=dob.obj.gsub(/(#{Mx[:en_a_o]}|#{Mx[:en_b_o]})(\d+)\s+(.+?)(#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/, - ' <a name="-\2" href="#_\2"> <sup>\2</sup> </a> ' + #note- endnote- - '\1\2 <a name="_\2" href="#-\2"> <sup>\2.</sup></a> \3 \4'). #endnote- note- (careful may have switched) + %{ <a name="#{Mx[:note_ref]}\\2" href="##{Mx[:note]}\\2"> <sup>\\2</sup> </a> } + + %{\\1\\2 <a name="#{Mx[:note]}\\2" href="##{Mx[:note_ref]}\\2"> <sup>\\2.</sup></a> \\3 \\4}). gsub(/(#{Mx[:en_b_o]})([*+]\d+)\s+(.+?)(#{Mx[:en_b_c]})/, - ' <a name="-\2" href="#_\2"> <sup>\2</sup> </a> ' + #note- endnote- - '\1\2 <a name="_\2" href="#-\2"> <sup>\2.</sup></a> \3 \4'). #endnote- note- (careful may have switched) + %{ <a name="#{Mx[:note_ref]}\\2" href="##{Mx[:note]}\\2"> <sup>\\2</sup> </a> } + + %{\\1\\2 <a name="#{Mx[:note]}\\2" href="##{Mx[:note_ref]}\\2"> <sup>\\2.</sup></a> \\3 \\4}). gsub(/(#{Mx[:en_a_o]})([*+]+)\s+(.+?)(#{Mx[:en_a_c]})/, - ' <a name="-\2" href="#_\2"> <sup>\2</sup> </a> ' + #note- endnote- - '\1\2 <a name="_\2" href="#-\2"> <sup>\2</sup></a> \3 \4') #endnote- note- (careful may have switched) + %{ <a name="#{Mx[:note_ref]}\\2" href="##{Mx[:note]}\\2"> <sup>\\2</sup> </a> } + + %{\\1\\2 <a name="#{Mx[:note]}\\2" href="##{Mx[:note_ref]}\\2"> <sup>\\2</sup></a> \\3 \\4}) end dob end diff --git a/lib/sisu/v5/hub.rb b/lib/sisu/v5/hub.rb index d0393a3b..8a430e71 100644 --- a/lib/sisu/v5/hub.rb +++ b/lib/sisu/v5/hub.rb @@ -72,7 +72,11 @@ module SiSU require_relative 'defaults' # defaults.rb include SiSU_Viz require_relative 'utils' # utils.rb - require 'uri' + begin + require 'uri' + rescue LoadError + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('uri NOT FOUND (LoadError)') + end class HubMaster def initialize(argv) pwd_the=Dir.pwd @@ -246,8 +250,12 @@ module SiSU end end class Processing - require 'fileutils' - include FileUtils + begin + require 'fileutils' + include FileUtils + rescue LoadError + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('fileutils NOT FOUND (LoadError)') + end @@env=nil attr_accessor :op def initialize(opt) @@ -645,7 +653,11 @@ module SiSU end def actions if @opt.act[:profile][:set]==:on - require 'profile' + begin + require 'profile' + rescue LoadError + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('profile NOT FOUND (LoadError)') + end end action_on_file_ =if @opt.act[:rsync][:set]==:on \ && @opt.act[:site_init][:set]==:on @@ -748,7 +760,7 @@ module SiSU STDERR.puts %{requested action requires valid sisu markup file [filename (.sst .ssm)] or wildcard (that includes a valid filename)} if (@opt.act[:verbose_plus][:set]==:on \ || @opt.act[:maintenance][:set]==:on) - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__).mark(:fuchsia) + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__).warn(:fuchsia) end end elsif @opt.mod.inspect =~/--query/ diff --git a/lib/sisu/v5/options.rb b/lib/sisu/v5/options.rb index 65af15b4..bce0a8a4 100644 --- a/lib/sisu/v5/options.rb +++ b/lib/sisu/v5/options.rb @@ -62,7 +62,11 @@ =end module SiSU_Commandline - require 'pathname' + begin + require 'pathname' + rescue LoadError + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('pathname NOT FOUND (LoadError)') + end require_relative 'sysenv' # sysenv.rb require_relative 'param_make' # param_make.rb @@sisu_call_origin_path=nil @@ -662,9 +666,9 @@ module SiSU_Commandline { set: :filetype } else { set: :na } end - act[:ocn]=if mod.inspect =~/"--inc-ocn"/ + act[:ocn]=if mod.inspect =~/"--ocn"|"--inc-ocn"/ { bool: true, set: :on } - elsif mod.inspect =~/"--(?:exc|no)-ocn"/ \ + elsif mod.inspect =~/"--no-ocn"|"--exc-ocn"/ \ || act[:switch][:off].inspect =~/"ocn"/ { bool: false, set: :off } else { bool: true, set: :na } @@ -765,12 +769,23 @@ module SiSU_Commandline { bool: false, set: :off } else { bool: true, set: :na } end - act[:html]=if (cmd =~/h/ \ + act[:html]=if mod.inspect =~/"--html-strict"/ \ + or ((cmd =~/h/ || mod.inspect =~/"--html"/) \ + && mod.inspect =~/"--strict"/) + act[:html_strict]={ bool: true, set: :on } + act[:html_scroll]={ bool: true, set: :on } + act[:html_seg]={ bool: true, set: :on } + { bool: true, set: :on } + elsif (cmd =~/h/ \ || mod.inspect =~/"--html"/) + act[:html_strict]={ bool: false, set: :off } act[:html_scroll]={ bool: true, set: :on } act[:html_seg]={ bool: true, set: :on } { bool: true, set: :on } else + act[:html_strict]=(mod.inspect =~/"--strict"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:html_scroll]=(mod.inspect =~/"--html-scroll"/) \ ? { bool: true, set: :on } : { bool: false, set: :na } @@ -850,10 +865,20 @@ module SiSU_Commandline || mod.inspect =~/"--epub"/) \ ? { bool: true, set: :on } : { bool: false, set: :na } - act[:odt]=(cmd =~/o/ \ - || mod.inspect =~/"--odt"|"--odf"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } + act[:odt]=if cmd =~/o/ \ + or mod.inspect =~/"--odt"|"--odf"|"--odt-ocn"|"--odf-ocn"/ + act[:odt_ocn]=if (mod.inspect =~/"--odt-ocn"|"--odf-ocn"/ \ + or mod.inspect =~/"--ocn"|"--inc-ocn"/) + { bool: true, set: :on } + elsif mod.inspect =~/"--no-ocn"|"--exc-ocn"/ + { bool: false, set: :off } + else + { bool: false, set: :na } + end + { bool: true, set: :on } + else + { bool: false, set: :na } + end act[:xml_sax]=(cmd =~/x/ \ || mod.inspect =~/"--xml-sax"/) \ ? { bool: true, set: :on } @@ -879,10 +904,20 @@ module SiSU_Commandline || mod.inspect =~/"--xhtml"/) \ ? { bool: true, set: :on } : { bool: false, set: :na } - act[:txt]=(cmd =~/[at]/ \ - || mod.inspect =~/"--txt"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } + act[:txt]=if cmd =~/[at]/ \ + or mod.inspect =~/"--txt"|"--text"|"--plaintext"|"--txt-ocn"|"--text-ocn"|"--plaintext-ocn"/ + act[:txt_ocn]=if (mod.inspect =~/"--txt-ocn"|"--text-ocn"|"--plaintext-ocn"/ \ + or mod.inspect =~/"--ocn"|"--inc-ocn"/) + { bool: true, set: :on } + elsif mod.inspect =~/"--no-ocn"|"--exc-ocn"/ + { bool: false, set: :off } + else + { bool: false, set: :na } + end + { bool: true, set: :on } + else + { bool: false, set: :na } + end act[:txt_textile]=(mod.inspect =~/"--textile"/) \ ? { bool: true, set: :on } : { bool: false, set: :na } diff --git a/lib/sisu/v5/param.rb b/lib/sisu/v5/param.rb index e8eb3fc6..ba75bfb0 100644 --- a/lib/sisu/v5/param.rb +++ b/lib/sisu/v5/param.rb @@ -61,8 +61,12 @@ =end module SiSU_Param - require 'uri' - require 'pstore' + begin + require 'uri' + require 'pstore' + rescue LoadError + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('uri or pstore NOT FOUND (LoadError)') + end require_relative 'sysenv' # sysenv.rb include SiSU_Env require_relative 'param_make' # param_make.rb @@ -95,8 +99,7 @@ module SiSU_Param # you may need to change Dir.pwd to @opt.f_pth[:pth] where the latter # has a path value that is different, however, f_pth is not always set! Dir.chdir(@opt.f_pth[:pth]) - p '-- bug alert -- ' - p __FILE__ + ':' + __LINE__.to_s + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('-- bug alert --') p 'f_pth ' + @opt.f_pth[:pth] p 'pwd ' + Dir.pwd end diff --git a/lib/sisu/v5/particulars.rb b/lib/sisu/v5/particulars.rb index 0687150a..6efbc94c 100644 --- a/lib/sisu/v5/particulars.rb +++ b/lib/sisu/v5/particulars.rb @@ -62,7 +62,11 @@ =end module SiSU_Particulars - require 'singleton' + begin + require 'singleton' + rescue LoadError + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('singleton NOT FOUND (LoadError)') + end require_relative 'sysenv' # sysenv.rb include SiSU_Env require_relative 'param' # param.rb diff --git a/lib/sisu/v5/remote.rb b/lib/sisu/v5/remote.rb index 145ec9b2..e06e7b33 100644 --- a/lib/sisu/v5/remote.rb +++ b/lib/sisu/v5/remote.rb @@ -112,8 +112,12 @@ module SiSU_Remote @tell=lambda { SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],@msg,"#{@msgs.inspect if @msgs}") } end def fns - require 'open-uri' - require 'pp' + begin + require 'open-uri' + require 'pp' + rescue LoadError + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('open-uri or pp NOT FOUND (LoadError)') + end require_relative 'composite' # composite.rb @rgx_image=/(?:^|[^_\\])\{\s*(\S+?\.(?:png|jpg|gif))/ threads=[] @@ -158,7 +162,11 @@ module SiSU_Remote def sisupod get_p=@get_s if get_p.length > 0 #% remote sisupod - require 'net/http' + begin + require 'net/http' + rescue LoadError + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('net/http NOT FOUND (LoadError)') + end for requested_pod in get_p pod_info=RemoteDownload.new(requested_pod) Net::HTTP.start(pod_info.pod.site) do |http| diff --git a/lib/sisu/v5/rexml.rb b/lib/sisu/v5/rexml.rb index c00797a3..bc9f7541 100644 --- a/lib/sisu/v5/rexml.rb +++ b/lib/sisu/v5/rexml.rb @@ -62,14 +62,22 @@ =end module SiSU_Rexml # load XML file for REXML parsing - require 'rexml/document' if FileTest.directory?("#{Config::CONFIG['rubylibdir']}/rexml") #Config::CONFIG['sitedir'] + begin + require 'rexml/document' if FileTest.directory?("#{Config::CONFIG['rubylibdir']}/rexml") #Config::CONFIG['sitedir'] + rescue LoadError + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('rexml/document NOT FOUND (LoadError)') + end require_relative 'param' # param.rb include SiSU_Param require_relative 'sysenv' # sysenv.rb include SiSU_Env include SiSU_Viz class Rexml - require 'rexml/document' if FileTest.directory?("#{Config::CONFIG['rubylibdir']}/rexml") #Config::CONFIG['sitedir'] + begin + require 'rexml/document' if FileTest.directory?("#{Config::CONFIG['rubylibdir']}/rexml") #Config::CONFIG['sitedir'] + rescue LoadError + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('rexml/document NOT FOUND (LoadError)') + end def initialize(md,fno) @md,@fno=md,fno @env=SiSU_Env::InfoEnv.new(@md.fns) diff --git a/lib/sisu/v5/shared_markup_alt.rb b/lib/sisu/v5/shared_markup_alt.rb index 4a1959e8..5a37c934 100644 --- a/lib/sisu/v5/shared_markup_alt.rb +++ b/lib/sisu/v5/shared_markup_alt.rb @@ -208,7 +208,11 @@ module SiSU_TextRepresentation end @env ||=SiSU_Env::InfoEnv.new(@md.fns) @sha_ =((@env.digest.type =='sha256') ? true : false) - @sha_ ? (require 'digest/sha2') : (require 'digest/md5') + begin + @sha_ ? (require 'digest/sha2') : (require 'digest/md5') + rescue LoadError + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error((@sha_ ? 'digest/sha2' : 'digest/md5') + ' NOT FOUND') + end end def digest(txt) d=nil diff --git a/lib/sisu/v5/src_kdissert_share.rb b/lib/sisu/v5/src_kdissert_share.rb index f91aec55..8ccb9708 100644 --- a/lib/sisu/v5/src_kdissert_share.rb +++ b/lib/sisu/v5/src_kdissert_share.rb @@ -64,8 +64,12 @@ module SiSU_KdiSource require_relative 'sysenv' # sysenv.rb include SiSU_Env class Source - require 'fileutils' - include FileUtils + begin + require 'fileutils' + include FileUtils + rescue LoadError + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('fileutils NOT FOUND (LoadError)') + end def initialize(opt) @opt=opt @env=SiSU_Env::InfoEnv.new(@opt.fns) diff --git a/lib/sisu/v5/sst_from_xml.rb b/lib/sisu/v5/sst_from_xml.rb index 110d7df5..c969ac31 100644 --- a/lib/sisu/v5/sst_from_xml.rb +++ b/lib/sisu/v5/sst_from_xml.rb @@ -64,8 +64,12 @@ module SiSU_sstFromXML require_relative 'sysenv' # sysenv.rb class Convert - require 'rexml/document' - include REXML + begin + require 'rexml/document' + include REXML + rescue LoadError + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('rexml/document NOT FOUND (LoadError)') + end def initialize(opt) @opt=opt @sisu,@sisu_base=[],[] diff --git a/lib/sisu/v5/sysenv.rb b/lib/sisu/v5/sysenv.rb index a8fcbd7a..f2b5bd27 100644 --- a/lib/sisu/v5/sysenv.rb +++ b/lib/sisu/v5/sysenv.rb @@ -66,12 +66,20 @@ module SiSU_Env require_relative 'constants' # constants.rb require_relative 'utils' # utils.rb - require 'fileutils' - include FileUtils::Verbose - require 'singleton' + begin + require 'singleton' + require 'fileutils' + include FileUtils::Verbose + rescue LoadError + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('singleton or fileutils NOT FOUND (LoadError)') + end @@noyaml=false class InfoDate - require 'date' + begin + require 'date' + rescue LoadError + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('date NOT FOUND (LoadError)') + end attr_accessor :dt,:t def initialize @dt,@t=Date.today.to_s,Time.now @@ -97,7 +105,11 @@ module SiSU_Env end end class InfoSystemGen - require 'rbconfig' + begin + require 'rbconfig' + rescue LoadError + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('rbconfig NOT FOUND (LoadError)') + end @@user,@@home,@@hostname,@@pwd,@@sisu_etc,@@host,@@arch,@@rbver,@@dir_arch,@@dir_sitearch,@@dir_bin,@@locale,@@rc,@@sisurc_path,@@ad=ENV['USER'],ENV['HOME'],ENV['HOSTNAME'],ENV['PWD'],Config::CONFIG['sysconfdir'] + '/sisu',Config::CONFIG['host'],Config::CONFIG['arch'],%x{ruby -v}.strip,Config::CONFIG['archdir'],Config::CONFIG['sitearchdir'],Config::CONFIG['bindir'],%x{locale charmap}.strip,nil,nil,{} # %x{ruby -v}.strip # Config::CONFIG['rb_ver'] out=Config::CONFIG['localstatedir'] etc=Config::CONFIG['sysconfdir'] + '/sisu' @@ -242,10 +254,18 @@ module SiSU_Env end if load_prog \ and @prog=~/dbi/ - require 'dbi' #revisit + begin + require 'dbi' + rescue LoadError + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('dbi NOT FOUND (LoadError)') + end end if load_prog - require @prog + begin + require @prog + rescue LoadError + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error("#{@prog} NOT FOUND (LoadError)") + end else @mandatory \ ? (SiSU_Screen::Ansi.new(@prog,"*WARN* module required: #{@prog}").warn) @@ -330,7 +350,11 @@ module SiSU_Env f=S_CONF[:rc_yml] p_f="#{v}/#{f}" if FileTest.exist?(p_f) - require 'yaml' + begin + require 'yaml' + rescue LoadError + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('yaml NOT FOUND (LoadError)') + end @@sisurc_path=v @@rc=YAML::load(File::open(p_f)) break @@ -339,7 +363,11 @@ module SiSU_Env f='sisurc.yaml' p_f="#{v}/#{f}" if FileTest.exist?(p_f) - require 'yaml' + begin + require 'yaml' + rescue LoadError + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('yaml NOT FOUND (LoadError)') + end @@sisurc_path=v @@rc=YAML::load(File::open(p_f)) break @@ -378,7 +406,11 @@ module SiSU_Env else if FileTest.exist?("#{v}/list.yml") unless @@ad[:promo_list] - require 'yaml' + begin + require 'yaml' + rescue LoadError + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('yaml NOT FOUND (LoadError)') + end @@ad[:promo_list] ||= YAML::load(File::open("#{v}/list.yml")) end @@ad[:flag_promo]=true @@ -396,7 +428,11 @@ module SiSU_Env else if FileTest.exist?("#{v}/promo.yml") unless @@ad[:promo] - require 'yaml' + begin + require 'yaml' + rescue LoadError + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('yaml NOT FOUND (LoadError)') + end @@ad[:promo] ||= YAML::load(File::open("#{v}/promo.yml")) end @@ad[:flag_promo]=true @@ -716,7 +752,7 @@ module SiSU_Env program='rcs' program_ref="\n\t\tdocument version information requested" if program_found?(program); true - else STDERR.puts "\t*WARN* #{program} is not installed #{program_ref}" #if @cmd =~/v/ + else SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).warn("#{program} is not installed #{program_ref}") false end end @@ -724,7 +760,15 @@ module SiSU_Env program='cvs' program_ref="\n\t\tdocument version information requested" if program_found?(program); true - else STDERR.puts "\t*WARN* #{program} is not installed #{program_ref}" #if @cmd =~/v/ + 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" + if program_found?(program); true + else SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).mark("*WARN* #{program} is not installed #{program_ref}") false end end @@ -732,7 +776,7 @@ module SiSU_Env program='openssl' program_ref="\n\t\tused to generate requested source document identification digest" if program_found?(program); true - else STDERR.puts "\t*WARN* #{program} is not installed #{program_ref}" #if @cmd =~/v/ + else SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).warn("#{program} is not installed #{program_ref}") false end end @@ -745,7 +789,7 @@ module SiSU_Env dgst=%x{openssl dgst -md5 #{File.basename(filename)}}.strip #use file name without file path Dir.chdir(pwd) dgst.scan(/\S+/) - else STDERR.puts "\t*WARN* #{program} is not installed #{program_ref}" #if @cmd =~/v/ + else SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).warn("#{program} is not installed #{program_ref}") false end end @@ -758,7 +802,7 @@ module SiSU_Env dgst=%x{openssl dgst -sha256 #{File.basename(filename)}}.strip #use file name without file path Dir.chdir(pwd) dgst.scan(/\S+/) - else STDERR.puts "\t*WARN* #{program} is not installed #{program_ref}" #if @cmd =~/v/ + else SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).warn("#{program} is not installed #{program_ref}") false end end @@ -766,7 +810,7 @@ module SiSU_Env program='psql' program_ref="\n\t\tpsql requested" if program_found?(program); true - else STDERR.puts "\t*WARN* #{program} is not installed #{program_ref}" #if @cmd =~/v/ + else SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).warn("#{program} is not installed #{program_ref}") false end end @@ -1030,9 +1074,13 @@ module SiSU_Env end end class InfoEnv < EnvCall - require 'pathname' - require 'fileutils' - include FileUtils + begin + require 'pathname' + require 'fileutils' + include FileUtils + rescue LoadError + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('pathname or fileutils NOT FOUND (LoadError)') + end attr_accessor :filename,:sys,:home,:hostname,:user,:env,:rc,:www,:fnb,:fnn,:fnt,:flv,:webserv_path,:stub_pwd,:stub_src,:webserv_host_cgi,:webserv_port_cgi,:processing,:processing_git,:etc,:yamlrc_dir @@image_flag,@@local_image=true,true #warning on @@image_flag @@fb,@@man_path=nil,nil @@ -1080,7 +1128,7 @@ module SiSU_Env elsif output_dir_structure.by_filename? '' else - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).mark('set output type, by: language, filetype or filename') + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).warn('set output type, by: language, filetype or filename') end @stub_set_manifest=stub + '/manifest' end @@ -3169,8 +3217,12 @@ WOK end end class CleanOutput - require 'fileutils' - include FileUtils::Verbose + begin + require 'fileutils' + include FileUtils::Verbose + rescue LoadError + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('fileutils NOT FOUND (LoadError)') + end def initialize(opt) @opt=opt z=SiSU_Env::FileMap.new(opt) @@ -3326,7 +3378,11 @@ WOK end class InfoRemote < FileMap @@flag_remote=false - require 'socket' + begin + require 'socket' + rescue LoadError + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('socket NOT FOUND (LoadError)') + end def initialize(opt) super(opt) # @opt=opt @@ -3674,8 +3730,12 @@ WOK end class InfoVersion <InfoEnv include Singleton - require 'rbconfig' - require 'yaml' + begin + require 'rbconfig' + require 'yaml' + rescue LoadError + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('rbconfig or yaml NOT FOUND (LoadError)') + end @@lib_path=nil def get_version @version={} @@ -3845,6 +3905,53 @@ WOK true end end + def plaintext_ocn? + if cmd_rc_act[:txt_ocn][:set]==:on \ + or cmd_rc_act[:ocn][:set]==:on + true + elsif cmd_rc_act[:txt_ocn][:set]==:off \ + or cmd_rc_act[:ocn][:set]==:off + false + elsif doc_rc.is_a?(Method) \ + and defined? doc_rc.ocn? \ + and doc_rc.toc? ==:off + false + elsif env_rc.build.ocn? ==:off + false + else + false + end + end + def odt_ocn? + if cmd_rc_act[:odt_ocn][:set]==:on \ + or cmd_rc_act[:ocn][:set]==:on + true + elsif cmd_rc_act[:odt_ocn][:set]==:off \ + or cmd_rc_act[:ocn][:set]==:off + false + elsif doc_rc.is_a?(Method) \ + and defined? doc_rc.ocn? \ + and doc_rc.toc? ==:off + false + elsif env_rc.build.ocn? ==:off + false + else + false + end + end + def html_strict? + if cmd_rc_act[:html_strict][:set]==:on + true + elsif cmd_rc_act[:html_strict][:set]==:off + false + elsif doc_rc.is_a?(Method) \ + and defined? doc_rc.html_strict? \ + and doc_rc.html_strict? ==:on + true + else + false + end + end def toc? if cmd_rc_act[:toc][:set]==:on true @@ -4081,6 +4188,11 @@ WOK end self end + def ocn_html_identifier + (build.html_strict?) \ + ? Mx[:ocn_id_char] + : '' + end def output_dir_structure def by_language_code? if cmd_rc_act[:output_by][:set] == :language @@ -4291,7 +4403,14 @@ WOK DBI.connect(sqlite_discrete.dbi) end def conn_sqlite3 - SQLite3::Database.new(sqlite_discrete.sqlite3) + begin + $sqlite3=:yes + require 'sqlite3' + SQLite3::Database.new(sqlite_discrete.sqlite3) + rescue LoadError + $sqlite3=:no + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('sqlite3 NOT FOUND (LoadError)') + end end self end diff --git a/lib/sisu/v5/texpdf.rb b/lib/sisu/v5/texpdf.rb index d0d88886..b67bb545 100644 --- a/lib/sisu/v5/texpdf.rb +++ b/lib/sisu/v5/texpdf.rb @@ -61,7 +61,11 @@ =end module SiSU_TeX - require 'pstore' + begin + require 'pstore' + rescue LoadError + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('pstore NOT FOUND (LoadError)') + end require_relative 'defaults' # defaults.rb include SiSU_Viz require_relative 'particulars' # particulars.rb @@ -78,7 +82,11 @@ module SiSU_TeX @@n=@@tableheader=@@rights=nil @@date ||=SiSU_Env::InfoDate.new class Source - require 'pstore' + begin + require 'pstore' + rescue LoadError + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('pstore NOT FOUND (LoadError)') + end require_relative 'sysenv' # sysenv.rb include SiSU_Env include SiSU_Viz @@ -270,7 +278,7 @@ module SiSU_TeX and File.size(texfile) > 0 #@tex_f_no+=1 else - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).mark("\tzero file size #{@env.processing_path.tex}/#{texfile}") + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error("\tzero file size #{@env.processing_path.tex}/#{texfile}") end end end @@ -365,7 +373,7 @@ module SiSU_TeX elsif @md.opt.act[:pdf_p][:set]==:on 'pdfTex portrait' else - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).mark('error: neither landscape nor portrait') + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('error: neither landscape nor portrait') end if (@md.opt.act[:verbose][:set]==:on \ || @md.opt.act[:verbose_plus][:set]==:on \ diff --git a/lib/sisu/v5/txt_plain.rb b/lib/sisu/v5/txt_plain.rb index ca944a1f..e27e9231 100644 --- a/lib/sisu/v5/txt_plain.rb +++ b/lib/sisu/v5/txt_plain.rb @@ -400,7 +400,8 @@ WOK @@endnotes[:para]=[] end def ocn_display(dob) - if @env.plaintext_ocn? + make=SiSU_Env::ProcessingSettings.new(@md) + if make.build.plaintext_ocn? if defined? dob.ocn \ and dob.ocn.is_a?(Fixnum) (defined? dob.ocn) ? "\n#{Dx[:ocn_o]}#{dob.ocn}#{Dx[:ocn_c]}" : '' diff --git a/lib/sisu/v5/utils.rb b/lib/sisu/v5/utils.rb index 97ca24be..1c04d886 100644 --- a/lib/sisu/v5/utils.rb +++ b/lib/sisu/v5/utils.rb @@ -127,6 +127,12 @@ module SiSU_Utils def mark(v=nil,x=nil) puts set(v,x) end + def warn(v=nil,x=nil) + STDERR.puts set(v,'*WARN* ' + x) + end + def error(v=nil,x=nil) + STDERR.puts set(v,'*ERROR* ' + x) + end end class Path def initialize(dir=Dir.pwd) diff --git a/lib/sisu/v5/webrick.rb b/lib/sisu/v5/webrick.rb index baf468c2..e43d8cd1 100644 --- a/lib/sisu/v5/webrick.rb +++ b/lib/sisu/v5/webrick.rb @@ -63,12 +63,16 @@ =end module SiSU_Webserv class WebrickStart + begin + require 'time' require 'webrick' include WEBrick - require 'time' - require_relative 'sysenv' # sysenv.rb - include SiSU_Env - include SiSU_Screen + rescue LoadError + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('time or webrick NOT FOUND (LoadError)') + end + require_relative 'sysenv' # sysenv.rb + include SiSU_Env + include SiSU_Screen def initialize begin #% @cX=SiSU_Screen::Ansi.new('yes').cX @@ -97,9 +101,13 @@ module SiSU_Webserv #% wb_top wb_top=%q(#!/usr/bin/env ruby # * arch-tag: webrick info on environment, mounted directories, and contents of pwd - require 'time' - require 'cgi' - require 'fcgi' + begin + require 'time' + require 'cgi' + require 'fcgi' + rescue LoadError + puts 'time, cgi or fcgi NOT FOUND (LoadError)' + end ls=Dir.entries('./') dir_contents=[] ls.each { |x| dir_contents << "<a href=\"./#{x}/\">#{x}</a><br>" unless x =~/^(\.)+$/ } diff --git a/lib/sisu/v5/xhtml_epub2.rb b/lib/sisu/v5/xhtml_epub2.rb index 33e3a529..40033101 100644 --- a/lib/sisu/v5/xhtml_epub2.rb +++ b/lib/sisu/v5/xhtml_epub2.rb @@ -61,7 +61,11 @@ =end module SiSU_XHTML_EPUB2 - require 'pstore' + begin + require 'pstore' + rescue LoadError + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('pstore NOT FOUND (LoadError)') + end require_relative 'particulars' # particulars.rb include SiSU_Particulars require_relative 'defaults' # defaults.rb @@ -744,7 +748,8 @@ module SiSU_XHTML_EPUB2 end def output_zip FileUtils::mkdir_p(@md.file.output_path.epub.dir) unless FileTest.directory?(@md.file.output_path.epub.dir) - if FileTest.directory?(@md.env.processing_path.epub) + if FileTest.directory?(@md.env.processing_path.epub) \ + and SiSU_Env::SystemCall.new.zip pwd=Dir.pwd Dir.chdir(@md.env.processing_path.epub) system(" @@ -755,6 +760,8 @@ module SiSU_XHTML_EPUB2 unless @md.opt.act[:maintenance][:set]==:on FileUtils::rm_r(@md.env.processing_path.epub) end + else + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).mark('*EXITED epub* zip program not found') unless SiSU_Env::SystemCall.new.zip end end def make_cover_image diff --git a/lib/sisu/v5/xhtml_epub2_format.rb b/lib/sisu/v5/xhtml_epub2_format.rb index 8dd8a88e..6522378b 100644 --- a/lib/sisu/v5/xhtml_epub2_format.rb +++ b/lib/sisu/v5/xhtml_epub2_format.rb @@ -1362,12 +1362,13 @@ output_epub_cont_seg.close depth=@md.lvs[1] + @md.lvs[2] + @md.lvs[3] + @md.lvs[4] title=SanitizeXML.xml(@md.title.full) author=SanitizeXML.xml(@md.author) + dgst=(@md.dgst.is_a?(Array) and @md.dgst.length > 1) ? @md.dgst[1] : 'na' <<-WOK <!-- four required metadata items (for all NCX documents, (including the relaxed constraints of OPS 2.0) --> <title>#{title} by #{author}</title> <link href="css/xhtml.css" rel="stylesheet" type="text/css" id="main-css" /> - <meta name="dtb:uid" content="urn:uuid:#{@md.dgst[1]}" /> + <meta name="dtb:uid" content="urn:uuid:#{dgst}" /> <!-- <meta name="epub-creator" content="#{@md.publisher}" /> --> <meta name="dtb:depth" content="#{depth}" /> <meta name="dtb:totalPageCount" content="0" /> @@ -1579,18 +1580,19 @@ output_epub_cont_seg.close else '' end f=SiSU_Env::FileOp.new(@md) + dgst=(@md.dgst.is_a?(Array) and @md.dgst.length > 1) ? @md.dgst[1] : 'na' <<-WOK <#{$ep[:o]}metadata xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:opf="http://www.idpf.org/2007/opf" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:dc="http://purl.org/dc/elements/1.1/" - unique-identifier="urn:uuid:#{@md.dgst[1]}" version="2.0"> + unique-identifier="urn:uuid:#{dgst}" version="2.0"> <dc:title>#{@md.title.full}</dc:title> #{cover_image}#{author}#{editor}#{translator}#{illustrator}#{language}#{date_published}#{subject}#{rights} <dc:identifier opf:scheme="URI">#{f.output_path.epub.url.gsub(/http:\/\//,'')}/#{f.base_filename.epub}</dc:identifier> - <dc:identifier id="bookid">urn:uuid:#{@md.dgst[1]}</dc:identifier> - <!-- <dc:identifier id="EPB-UUID">urn:uuid:#{@md.dgst[1]}</dc:identifier> --> + <dc:identifier id="bookid">urn:uuid:#{dgst}</dc:identifier> + <!-- <dc:identifier id="EPB-UUID">urn:uuid:#{dgst}</dc:identifier> --> </#{$ep[:o]}metadata> WOK end @@ -2132,10 +2134,10 @@ output_epub_cont_seg.close note='' if txt =~/(#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})/m # had \s* at end note=$1 - note=note.gsub(/[\n\s]+/m,' ') + note=note.gsub(/[\s]+/m,' ') txt=txt.gsub(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' '). - gsub(/<a[\n\s]+"[\n\s]+href="#note_ref\d+">#{$ep[:hsp]}<sup id="note\d+">\d+<\/sup>#{$ep[:hsp]}/m,''). - gsub(/<a[\n\s]+"[\n\s]+href="#note_ref\d+">#{$ep[:hsp]}<sup id="note\d+">\d+<\/sup>#{$ep[:hsp]}/m,'') #remove + gsub(/<a[\n\s]+"[\n\s]+href="##{Mx[:note_ref]}\d+">#{$ep[:hsp]}<sup id="#{Mx[:note]}\d+">\d+<\/sup>#{$ep[:hsp]}/m,''). + gsub(/<a[\n\s]+"[\n\s]+href="##{Mx[:note_ref]}\d+">#{$ep[:hsp]}<sup id="#{Mx[:note]}\d+">\d+<\/sup>#{$ep[:hsp]}/m,'') #remove end %{<#{tag} class="#{attrib}"> <a href="#o#{@ocn}"><i>#{txt}</i></a> #{note} diff --git a/lib/sisu/v5/xhtml_epub2_segments.rb b/lib/sisu/v5/xhtml_epub2_segments.rb index 764fcc17..8612696f 100644 --- a/lib/sisu/v5/xhtml_epub2_segments.rb +++ b/lib/sisu/v5/xhtml_epub2_segments.rb @@ -401,7 +401,7 @@ WOK sto.break end if @md.flag_separate_endnotes # may need to revisit, check - dob.obj=dob.obj.gsub(/"\s+href="#note_ref(\d+)">/,%{" href=\"endnotes#{Sfx[:epub_xhtml]}#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 \ diff --git a/lib/sisu/v5/xhtml_epub2_tune.rb b/lib/sisu/v5/xhtml_epub2_tune.rb index 6ac53c39..82f90366 100644 --- a/lib/sisu/v5/xhtml_epub2_tune.rb +++ b/lib/sisu/v5/xhtml_epub2_tune.rb @@ -298,22 +298,22 @@ module SiSU_XHTML_EPUB2_Tune data.each do |dob| unless dob.is ==:code dob.obj=dob.obj.gsub(/(#{Mx[:en_a_o]}|#{Mx[:en_b_o]})(\d+)\s+(.+?)(#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/, - %{#{Mx[:nbsp]}<a href="#note\\2">#{Mx[:nbsp]}<sup id="note_ref\\2">\\2</sup>#{Mx[:nbsp]}</a> } + #note- endnote- - %{\\1\\2 <a href="#note_ref\\2">#{Mx[:nbsp]}<sup id="note\\2">\\2.</sup></a> \\3 \\4}). #endnote- note- (careful may have switched) + %{#{Mx[:nbsp]}<a href="##{Mx[:note]}\\2">#{Mx[:nbsp]}<sup id="#{Mx[:note_ref]}\\2">\\2</sup>#{Mx[:nbsp]}</a> } + #note- endnote- + %{\\1\\2 <a href="##{Mx[:note_ref]}\\2">#{Mx[:nbsp]}<sup id="#{Mx[:note]}\\2">\\2.</sup></a> \\3 \\4}). #endnote- note- (careful may have switched) gsub(/(#{Mx[:en_b_o]})[*](\d+)\s+(.+?)(#{Mx[:en_b_c]})/, - %{#{Mx[:nbsp]}<a href="#note_astx\\2">#{Mx[:nbsp]}<sup id="note_ref_astx\\2">#{ast}\\2</sup>#{Mx[:nbsp]}</a> } + #note- endnote- - %{\\1#{ast}\\2 <a href="#note_ref_astx\\2">#{Mx[:nbsp]}<sup id="note_astx\\2">#{ast}\\2.</sup></a> \\3 \\4}). #endnote- note- (careful may have switched) + %{#{Mx[:nbsp]}<a href="##{Mx[:note_astx]}\\2">#{Mx[:nbsp]}<sup id="#{Mx[:note_ref_astx]}\\2">#{ast}\\2</sup>#{Mx[:nbsp]}</a> } + #note- endnote- + %{\\1#{ast}\\2 <a href="##{Mx[:note_ref_astx]}\\2">#{Mx[:nbsp]}<sup id="#{Mx[:note_astx]}\\2">#{ast}\\2.</sup></a> \\3 \\4}). #endnote- note- (careful may have switched) gsub(/(#{Mx[:en_b_o]})[+](\d+)\s+(.+?)(#{Mx[:en_b_c]})/, - %{#{Mx[:nbsp]}<a href="#note_plus\\2">#{Mx[:nbsp]}<sup id="note_ref_plus\\2">#{pls}\\2</sup>#{Mx[:nbsp]}</a> } + #note- endnote- - %{\\1#{pls}\\2 <a href="#note_ref_plus\\2">#{Mx[:nbsp]}<sup id="note_plus\\2">#{pls}\\2.</sup></a> \\3 \\4}) #endnote- note- (careful may have switched) # double-check there may here be a bug + %{#{Mx[:nbsp]}<a href="##{Mx[:note_plus]}\\2">#{Mx[:nbsp]}<sup id="#{Mx[:note_ref_plus]}\\2">#{pls}\\2</sup>#{Mx[:nbsp]}</a> } + #note- endnote- + %{\\1#{pls}\\2 <a href="##{Mx[:note_ref_plus]}\\2">#{Mx[:nbsp]}<sup id="#{Mx[:note_plus]}\\2">#{pls}\\2.</sup></a> \\3 \\4}) #endnote- note- (careful may have switched) # double-check there may here be a bug if dob.obj =~/#{Mx[:en_a_o]}([*+]+)\s+.+?#{Mx[:en_a_c]}/ m=$1.length.to_i dob.obj=dob.obj.gsub(/(#{Mx[:en_a_o]})[*]+\s+(.+?)(#{Mx[:en_a_c]})/, - %{#{Mx[:nbsp]}<a href="#note#{a*m}">#{Mx[:nbsp]}<sup id="note_ref#{a*m}">#{ast*m}</sup>#{Mx[:nbsp]}</a> } + #note- endnote- - %{\\1#{ast*m} <a href="#note_ref#{a*m}">#{Mx[:nbsp]}<sup id="note#{a*m}">#{ast*m}</sup></a> \\2 \\3}). #endnote- note- (careful may have switched) + %{#{Mx[:nbsp]}<a href="##{Mx[:note]}#{a*m}">#{Mx[:nbsp]}<sup id="#{Mx[:note_ref]}#{a*m}">#{ast*m}</sup>#{Mx[:nbsp]}</a> } + #note- endnote- + %{\\1#{ast*m} <a href="##{Mx[:note_ref]}#{a*m}">#{Mx[:nbsp]}<sup id="#{Mx[:note]}#{a*m}">#{ast*m}</sup></a> \\2 \\3}). #endnote- note- (careful may have switched) gsub(/(#{Mx[:en_a_o]})([+]+)\s+(.+?)(#{Mx[:en_a_c]})/, - %{#{Mx[:nbsp]}<a href="#note#{s*m}">#{Mx[:nbsp]}<sup id="note_ref#{s*m}">#{pls*m}</sup>#{Mx[:nbsp]}</a> } + #note- endnote- - %{\\1#{pls*m} <a href="#note_ref#{s*m}">#{Mx[:nbsp]}<sup id="note#{s*m}">#{pls*m}</sup></a> \\2 \\3}) #endnote- note- (careful may have switched) + %{#{Mx[:nbsp]}<a href="##{Mx[:note]}#{s*m}">#{Mx[:nbsp]}<sup id="#{Mx[:note_ref]}#{s*m}">#{pls*m}</sup>#{Mx[:nbsp]}</a> } + #note- endnote- + %{\\1#{pls*m} <a href="##{Mx[:note_ref]}#{s*m}">#{Mx[:nbsp]}<sup id="#{Mx[:note]}#{s*m}">#{pls*m}</sup></a> \\2 \\3}) #endnote- note- (careful may have switched) end end @tuned_file << dob diff --git a/lib/sisu/v5/xml_fictionbook2.rb b/lib/sisu/v5/xml_fictionbook2.rb index 6549fa12..c72332bb 100644 --- a/lib/sisu/v5/xml_fictionbook2.rb +++ b/lib/sisu/v5/xml_fictionbook2.rb @@ -227,7 +227,11 @@ module SiSU_XML_Fictionbook endnotes end def extract_images #work on - require "base64" + begin + require 'base64' + rescue LoadError + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('base64 NOT FOUND (LoadError)') + end images_raw,images_base64_fb2=[],[] images_base64={} if defined? @md.make.cover_image[:cover] diff --git a/lib/sisu/v5/xml_odf_odt.rb b/lib/sisu/v5/xml_odf_odt.rb index a6a7a127..d2ab0477 100644 --- a/lib/sisu/v5/xml_odf_odt.rb +++ b/lib/sisu/v5/xml_odf_odt.rb @@ -73,8 +73,12 @@ module SiSU_XML_ODF_ODT require_relative 'txt_shared' # txt_shared.rb @@alt_id_count,@@alt_id_count,@@tablehead,@@number_of_cols=0,0,0,0 class Source - require 'zlib' - require 'find' + begin + require 'zlib' + require 'find' + rescue LoadError + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('zlib or find NOT FOUND (LoadError)') + end def initialize(opt) @opt=opt @particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt) @@ -117,6 +121,7 @@ module SiSU_XML_ODF_ODT @@fns=nil def initialize(particulars) @md,@env,@ao_array=particulars.md,particulars.env,particulars.ao_array + @make=SiSU_Env::ProcessingSettings.new(@md) @vz=SiSU_Viz::Defaults.new @tab="\t" @brace_url=SiSU_Viz::Defaults.new.url_decoration @@ -552,10 +557,10 @@ module SiSU_XML_ODF_ODT end p_num={ display: '', set_ref: '' } if dob.is !~/(^#{Rx[:meta]}|#{Mx[:br_eof]}|#{Mx[:br_endnotes]})/ - if @env.odt_ocn? + if @make.build.odt_ocn? if defined? dob.ocn \ and dob.ocn.is_a?(Fixnum) - p_num=SiSU_XML_ODF_ODT_Format::ParagraphNumber.new(dob.ocn).set_bookmark_and_display + p_num=SiSU_XML_ODF_ODT_Format::ParagraphNumber.new(@make,dob.ocn).set_bookmark_and_display end end end @@ -678,7 +683,7 @@ module SiSU_XML_ODF_ODT and (dob.obj =~/~metadata/ or dob =~/#{Mx[:lv_o]}1:meta#{Mx[:lv_x]}\s*Document Information/) #fix Mx[:lv_o] if dob.is !~/(^#{Rx[:meta]}|#{Mx[:br_eof]}|#{Mx[:br_endnotes]})/ #check if defined? dob.ocn and dob.ocn =~/\d+/ - @p_num=SiSU_XML_ODF_ODT_Format::ParagraphNumber.new(dob.ocn) + @p_num=SiSU_XML_ODF_ODT_Format::ParagraphNumber.new(@make,dob.ocn) end if dob.is ==:heading \ || dob.is ==:para \ @@ -805,7 +810,8 @@ WOK od.close opendoc=@md.file.base_filename.odt #watch where output by language FileUtils::mkdir_p(@md.file.output_path.odt.dir) unless FileTest.directory?(@md.file.output_path.odt.dir) - if FileTest.directory?(@env.processing_path.odt) + if FileTest.directory?(@env.processing_path.odt) \ + and SiSU_Env::SystemCall.new.zip pwd=Dir.pwd Dir.chdir(@env.processing_path.odt) system(" @@ -813,6 +819,8 @@ WOK ") FileUtils::mv(opendoc, @md.file.place_file.odt.dir) Dir.chdir(pwd) + else + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).mark('*EXITED odf* zip program not found') unless SiSU_Env::SystemCall.new.zip end end end diff --git a/lib/sisu/v5/xml_odf_odt_format.rb b/lib/sisu/v5/xml_odf_odt_format.rb index 2a092011..b56e4284 100644 --- a/lib/sisu/v5/xml_odf_odt_format.rb +++ b/lib/sisu/v5/xml_odf_odt_format.rb @@ -65,17 +65,26 @@ module SiSU_XML_ODF_ODT_Format include SiSU_Param include SiSU_Viz class ParagraphNumber - def initialize(paranum) + def initialize(make,paranum) + @make=make @paranum=/(\d+)/m.match(paranum.to_s)[1] end def set_ref_and_display - set_ref=@paranum.gsub(/(\d+)/,' <text:span text:style-name="Span_subscript"><text:reference-mark-start text:name="\1"/><text:reference-mark-end text:name="\1"/></text:span>') - disp=@paranum.gsub(/(\d+)/,%{ <text:span text:style-name="Span_subscript">#{Dx[:ocn_o]}\\1#{Dx[:ocn_c]}</text:span>}) + set_ref=@paranum.gsub(/(\d+)/, + ' <text:span text:style-name="Span_subscript"><text:reference-mark-start text:name="\1"/><text:reference-mark-end text:name="\1"/></text:span>') + disp=@paranum.gsub(/(\d+)/, + (@make.build.odt_ocn?) \ + ? %{ <text:span text:style-name="Span_subscript">#{Dx[:ocn_o]}\\1#{Dx[:ocn_c]}</text:span>} + : '') { display: disp, set_ref: set_ref } end def set_bookmark_and_display - set_ref=@paranum.gsub(/(\d+)/,' <text:span text:style-name="Span_subscript"><text:bookmark-start text:name="\1"/><text:bookmark-end text:name="\1"/></text:span>') - disp=@paranum.gsub(/(\d+)/,%{ <text:span text:style-name="Span_subscript">#{Dx[:ocn_o]}\\1#{Dx[:ocn_c]}</text:span>}) + set_ref=@paranum.gsub(/(\d+)/, + ' <text:span text:style-name="Span_subscript"><text:bookmark-start text:name="\1"/><text:bookmark-end text:name="\1"/></text:span>') + disp=@paranum.gsub(/(\d+)/, + (@make.build.odt_ocn?) \ + ? %{ <text:span text:style-name="Span_subscript">#{Dx[:ocn_o]}\\1#{Dx[:ocn_c]}</text:span>} + : '') { display: disp, set_ref: set_ref } end def name |