diff options
author | Ralph Amissah <ralph@amissah.com> | 2012-03-19 22:07:29 -0400 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2012-03-19 22:07:33 -0400 |
commit | 6811ac91f21a434fc7d967c11e1b20f33918c6ea (patch) | |
tree | 30f39674ca96a79f8a604a9f02d571f24320e221 /lib/sisu/v3 | |
parent | v3: 3.2.0 version & changelog "opened" (diff) |
v3: 3.2 branch is main (v3dv --> v3); dev (v3dv) branch directories removed
* v3dv (3.2) "merged" into v3 (previously 3.1) (& removed)
* conf/sisu/v3dv --> conf/sisu/v3
* data/sisu/v3dv --> data/sisu/v3
* lib/sisu/v3dv --> lib/sisu/v3
* bin/sisu* (v3dv references changed to v3)
* (--dev modifier (superfluous for the time being) runs main v3 branch)
Diffstat (limited to 'lib/sisu/v3')
118 files changed, 6702 insertions, 5447 deletions
diff --git a/lib/sisu/v3/author_format.rb b/lib/sisu/v3/author_format.rb index 481674d0..cfc485f3 100644 --- a/lib/sisu/v3/author_format.rb +++ b/lib/sisu/v3/author_format.rb @@ -56,7 +56,7 @@ ** Description: system environment, resource control and configuration details =end -module FORMAT +module SiSU_FormatAuthor class Author def initialize(author_param) @author_param=author_param @@ -65,14 +65,14 @@ module FORMAT @authors,@author_array=[],[] authors=@author_param.scan(/[^;]+/) authors.each do |a| - a.strip! + a=a.strip if a =~/"(.+?)"/ @authors << { the: $1 } @author_array << $1.upcase else #if a =~/,/ x=a.scan(/[^,]+/) - x[0].strip! - x[1].strip! if x[1] + x[0]=x[0].strip + x[1]=x[1].strip if x[1] if x.length==1 @authors << { the: x[0] } @author_array << x[0].upcase diff --git a/lib/sisu/v3/cgi.rb b/lib/sisu/v3/cgi.rb index 779ee35a..b2a9c0b3 100644 --- a/lib/sisu/v3/cgi.rb +++ b/lib/sisu/v3/cgi.rb @@ -61,7 +61,7 @@ module SiSU_CGI require_relative 'sysenv' # sysenv.rb require_relative 'cgi_pgsql' # cgi_pgsql.rb require_relative 'cgi_sqlite' # cgi_sqlite.rb - class SiSU_search + class SearchSQL def initialize(opt) @opt=opt @webserv=@opt.files[0].to_s.strip @@ -74,8 +74,8 @@ module SiSU_CGI SiSU_Screen::Ansi.new(@opt.cmd,a).print_grey end def read - SiSU_CGI_sqlite::SiSU_search_sqlite.new(@opt,@webserv).sqlite - SiSU_CGI_pgsql::SiSU_search_pgsql.new(@opt,@webserv).pgsql + SiSU_CGI_SQLite::SearchSQLite.new(@opt,@webserv).sqlite + SiSU_CGI_PgSQL::SearchPgSQL.new(@opt,@webserv).pgsql search_info unless @opt.cmd =~/q/ end end diff --git a/lib/sisu/v3/cgi_pgsql.rb b/lib/sisu/v3/cgi_pgsql.rb index 6fb35714..8b3f0224 100644 --- a/lib/sisu/v3/cgi_pgsql.rb +++ b/lib/sisu/v3/cgi_pgsql.rb @@ -56,19 +56,19 @@ ** Description: generates naive cgi search form for search of sisu database (pgsql sqlite) =end -module SiSU_CGI_pgsql #% database building documents +module SiSU_CGI_PgSQL #% database building documents require_relative 'sysenv' # sysenv.rb require_relative 'cgi_sql_common' # cgi_sql_common.rb - include SiSU_CGI_sql - class SiSU_search_pgsql < SiSU_CGI_common + include SiSU_CGI_SQL + class SearchPgSQL < CGI_Common def initialize(opt,webserv) @opt,@webserv=opt,webserv - @env=SiSU_Env::Info_env.new('',opt) - @sys=SiSU_Env::System_call.new + @env=SiSU_Env::InfoEnv.new('',opt) + @sys=SiSU_Env::SystemCall.new @image_src="#{@env.url.webserv_cgi}/_sisu/image_sys" - @common=SiSU_CGI_sql::SiSU_CGI_common.new(@webserv,@opt,@image_src,@env) - @db=SiSU_Env::Info_db.new - @cgi_file_name="#{Db[:name_prefix_db]}by_#{opt.dir_structure_by}_pgsql.cgi" + @common=SiSU_CGI_SQL::CGI_Common.new(@webserv,@opt,@image_src,@env) + @db=SiSU_Env::InfoDb.new + @cgi_file_name="#{Db[:name_prefix_db]}by_#{opt.dir_structure_by.to_s}_pgsql.cgi" end def pgsql serve=[] @@ -82,7 +82,7 @@ module SiSU_CGI_pgsql end else put "WARNING: no postgresql database available, (have you created one?)" end - serve.sort! + serve=serve.sort f1,f2,f3='','','' serve.each do |x| f1 << %{ <option value="#{Db[:name_prefix]}#{x}">#{x}</option>\n} unless x =~/apache|sisu\/image/ #check @@ -140,7 +140,7 @@ module SiSU_CGI_pgsql end def search_statement <<-'WOK_SQL' - class Dbi_search_string + class DBI_SearchString def initialize(l,t,q,cse=false) @l,@t,@q,@c=l,t,q,cse end @@ -151,12 +151,12 @@ module SiSU_CGI_pgsql elsif @q =~/\S+/; unescaped_search=CGI.unescape(@q) end search_construct=[] - if @c - unescaped_search.gsub!(/\s*(AND|OR)\s*/,"' \) \\1 #{@l}~\( '") - unescaped_search.gsub!(/(.+)/,"#{@l}~\( '\\1' \)") + unescaped_search=if @c + unescaped_search.gsub(/\s*(AND|OR)\s*/,"' \) \\1 #{@l}~\( '"). + gsub(/(.+)/,"#{@l}~\( '\\1' \)") else - unescaped_search.gsub!(/\s*(AND|OR)\s*/,"' \) \\1 #{@l}~*\( '") - unescaped_search.gsub!(/(.+)/,"#{@l}~*\( '\\1' \)") + unescaped_search.gsub(/\s*(AND|OR)\s*/,"' \) \\1 #{@l}~*\( '"). + gsub(/(.+)/,"#{@l}~*\( '\\1' \)") end search_construct << unescaped_search search_construct=search_construct.join(' ') @@ -173,11 +173,11 @@ module SiSU_CGI_pgsql <<-'WOK_SQL' @search_text,@search_endnotes='','' search[:text].flatten.each {|x| @search_text << "#{x} AND " } - @search_text=@search_text.gsub!(/AND\s+$/m,'') #watch - @search_text.gsub!(/(doc_objects\.clean~[*]?\(\s*'[^']+'\s*\)\s+(?:(?:AND|OR)\s+doc_objects\.clean~[*]?\(\s*'[^']+'\s*\))+)/,'(\1)') + @search_text=@search_text.gsub(/AND\s+$/m,''). #watch + gsub(/(doc_objects\.clean~[*]?\(\s*'[^']+'\s*\)\s+(?:(?:AND|OR)\s+doc_objects\.clean~[*]?\(\s*'[^']+'\s*\))+)/,'(\1)') search[:endnotes].flatten.each {|x| @search_endnotes << "#{x} AND " } - @search_endnotes=@search_endnotes.gsub!(/AND\s+$/m,'') #watch - @search_endnotes.gsub!(/(endnotes\.clean~\(\s*'[^']+'\s*\)\s+(?:(?:AND|OR)\s+endnotes\.clean~\(\s*'[^']+'\s*\))+)/,'(\1)') + @search_endnotes=@search_endnotes.gsub(/AND\s+$/m,''). #watch + gsub(/(endnotes\.clean~\(\s*'[^']+'\s*\)\s+(?:(?:AND|OR)\s+endnotes\.clean~\(\s*'[^']+'\s*\))+)/,'(\1)') end WOK_SQL end diff --git a/lib/sisu/v3/cgi_sql_common.rb b/lib/sisu/v3/cgi_sql_common.rb index 9f4dd457..8a7c126f 100644 --- a/lib/sisu/v3/cgi_sql_common.rb +++ b/lib/sisu/v3/cgi_sql_common.rb @@ -56,8 +56,8 @@ ** Description: generates naive cgi search form for search of sisu database (pgsql sqlite) =end -module SiSU_CGI_sql - class SiSU_CGI_common +module SiSU_CGI_SQL + class CGI_Common def initialize(webserv,opt,image_src,dir) @webserv,@opt,@image_src,@env=webserv,opt,image_src,dir @cmd=opt.cmd @@ -230,7 +230,7 @@ module SiSU_CGI_sql end def search_request <<-'WOK_SQL' - class Search_request #% search_for + class SearchRequest #% search_for attr_accessor :text1,:fulltext,:keywords,:title,:author,:topic_register,:subject,:description,:publisher,:editor,:contributor,:date,:type,:format,:identifier,:source,:language,:relation,:coverage,:rights,:comment,:abstract,:owner,:date_created,:date_issued,:date_modified,:date_available,:date_valid,:filename def initialize(search_field='',q='') @search_field,@q=search_field,q @@ -311,12 +311,10 @@ module SiSU_CGI_sql elsif @search_field =~m[:string]; m[:string].match(@search_field)[1] else str=m[:word].match(@search_field)[1] - str.gsub!(/[()]/,'') + str=str.gsub(/[()]/,'') str end - search_string.strip! - search_string.gsub!(/\s+/,'+') - search_string + search_string=search_string.strip.search_string.gsub(/\s+/,'+') #else # "__" end @@ -326,7 +324,7 @@ module SiSU_CGI_sql end def search_statement_common <<-'WOK_SQL' - class Dbi_search_statement + class DBI_SearchStatement attr_reader :text_search_flag,:sql_select_body_format,:sql_select_endnotes_format,:sql_offset,:sql_limit def initialize(conn,search_for,q,c) @conn=conn @@ -336,114 +334,114 @@ module SiSU_CGI_sql #@offset+=@@limit search={ :text => [], :endnotes => [] } cse=(c =~/\S/) ? true : false - st=Dbi_search_string.new('doc_objects.clean',search_for.text1,q['s1'],cse).string - se=Dbi_search_string.new('endnotes.clean',search_for.text1,q['s1'],cse).string + st=DBI_SearchString.new('doc_objects.clean',search_for.text1,q['s1'],cse).string + se=DBI_SearchString.new('endnotes.clean',search_for.text1,q['s1'],cse).string @text_search_flag=st[:flag] if st[:flag] search[:text] << st[:search] search[:endnotes] << se[:search] end - st=Dbi_search_string.new('metadata_and_text.fulltext',search_for.fulltext,q['ft'],cse).string + st=DBI_SearchString.new('metadata_and_text.fulltext',search_for.fulltext,q['ft'],cse).string if st[:flag] search[:text] << st[:search] search[:endnotes] << st[:search] end - st=Dbi_search_string.new('metadata_and_text.classify_keywords',search_for.keywords,q['key'],cse).string + st=DBI_SearchString.new('metadata_and_text.classify_keywords',search_for.keywords,q['key'],cse).string if st[:flag] search[:text] << st[:search] search[:endnotes] << st[:search] end - st=Dbi_search_string.new('metadata_and_text.title',search_for.title,q['ti'],cse).string + st=DBI_SearchString.new('metadata_and_text.title',search_for.title,q['ti'],cse).string if st[:flag] search[:text] << st[:search] search[:endnotes] << st[:search] end - st=Dbi_search_string.new('metadata_and_text.creator_author',search_for.author,q['au'],cse).string + st=DBI_SearchString.new('metadata_and_text.creator_author',search_for.author,q['au'],cse).string if st[:flag] search[:text] << st[:search] search[:endnotes] << st[:search] end - st=Dbi_search_string.new('metadata_and_text.classify_topic_register',search_for.topic_register,q['tr'],cse).string + st=DBI_SearchString.new('metadata_and_text.classify_topic_register',search_for.topic_register,q['tr'],cse).string if st[:flag] search[:text] << st[:search] search[:endnotes] << st[:search] end - st=Dbi_search_string.new('metadata_and_text.classify_subject',search_for.subject,q['sj'],cse).string + st=DBI_SearchString.new('metadata_and_text.classify_subject',search_for.subject,q['sj'],cse).string if st[:flag] search[:text] << st[:search] search[:endnotes] << st[:search] end - st=Dbi_search_string.new('metadata_and_text.notes_description',search_for.description,q['dsc'],cse).string + st=DBI_SearchString.new('metadata_and_text.notes_description',search_for.description,q['dsc'],cse).string if st[:flag] search[:text] << st[:search] search[:endnotes] << st[:search] end - st=Dbi_search_string.new('metadata_and_text.publisher',search_for.publisher,q['pb'],cse).string + st=DBI_SearchString.new('metadata_and_text.publisher',search_for.publisher,q['pb'],cse).string if st[:flag] search[:text] << st[:search] search[:endnotes] << st[:search] end - st=Dbi_search_string.new('metadata_and_text.creator_editor',search_for.editor,q['cntr'],cse).string + st=DBI_SearchString.new('metadata_and_text.creator_editor',search_for.editor,q['cntr'],cse).string if st[:flag] search[:text] << st[:search] search[:endnotes] << st[:search] end - st=Dbi_search_string.new('metadata_and_text.creator_contributor',search_for.contributor,q['cntr'],cse).string + st=DBI_SearchString.new('metadata_and_text.creator_contributor',search_for.contributor,q['cntr'],cse).string if st[:flag] search[:text] << st[:search] search[:endnotes] << st[:search] end - st=Dbi_search_string.new('metadata_and_text.date_published',search_for.date,q['dt'],cse).string + st=DBI_SearchString.new('metadata_and_text.date_published',search_for.date,q['dt'],cse).string if st[:flag] search[:text] << st[:search] search[:endnotes] << st[:search] end - st=Dbi_search_string.new('metadata_and_text.classify_type',search_for.type,q['ty'],cse).string + st=DBI_SearchString.new('metadata_and_text.classify_type',search_for.type,q['ty'],cse).string if st[:flag] search[:text] << st[:search] search[:endnotes] << st[:search] end - st=Dbi_search_string.new('metadata_and_text.classify_identifier',search_for.identifier,q['id'],cse).string + st=DBI_SearchString.new('metadata_and_text.classify_identifier',search_for.identifier,q['id'],cse).string if st[:flag] search[:text] << st[:search] search[:endnotes] << st[:search] end - st=Dbi_search_string.new('metadata_and_text.original_source',search_for.source,q['src'],cse).string + st=DBI_SearchString.new('metadata_and_text.original_source',search_for.source,q['src'],cse).string if st[:flag] search[:text] << st[:search] search[:endnotes] << st[:search] end - st=Dbi_search_string.new('metadata_and_text.language_document_char',search_for.language,q['lang'],cse).string + st=DBI_SearchString.new('metadata_and_text.language_document_char',search_for.language,q['lang'],cse).string if st[:flag] search[:text] << st[:search] search[:endnotes] << st[:search] end - st=Dbi_search_string.new('metadata_and_text.classify_relation',search_for.relation,q['rel'],cse).string + st=DBI_SearchString.new('metadata_and_text.classify_relation',search_for.relation,q['rel'],cse).string if st[:flag] search[:text] << st[:search] search[:endnotes] << st[:search] end - st=Dbi_search_string.new('metadata_and_text.classify_coverage',search_for.coverage,q['cov'],cse).string + st=DBI_SearchString.new('metadata_and_text.classify_coverage',search_for.coverage,q['cov'],cse).string if st[:flag] search[:text] << st[:search] search[:endnotes] << st[:search] end - st=Dbi_search_string.new('metadata_and_text.rights_all',search_for.rights,q['cr'],cse).string + st=DBI_SearchString.new('metadata_and_text.rights_all',search_for.rights,q['cr'],cse).string if st[:flag] search[:text] << st[:search] search[:endnotes] << st[:search] end - st=Dbi_search_string.new('metadata_and_text.notes_comment',search_for.comment,q['co'],cse).string + st=DBI_SearchString.new('metadata_and_text.notes_comment',search_for.comment,q['co'],cse).string if st[:flag] search[:text] << st[:search] search[:endnotes] << st[:search] end - st=Dbi_search_string.new('metadata_and_text.notes_abstract',search_for.abstract,q['ab'],cse).string + st=DBI_SearchString.new('metadata_and_text.notes_abstract',search_for.abstract,q['ab'],cse).string if st[:flag] search[:text] << st[:search] search[:endnotes] << st[:search] end - st=Dbi_search_string.new('metadata_and_text.src_filename',search_for.filename,q['fns'],cse).string + st=DBI_SearchString.new('metadata_and_text.src_filename',search_for.filename,q['fns'],cse).string if st[:flag] search[:text] << st[:search] search[:endnotes] << st[:search] @@ -539,7 +537,7 @@ module SiSU_CGI_sql WOK_SQL end def tail - v=SiSU_Env::Info_version.instance.get_version + v=SiSU_Env::InfoVersion.instance.get_version <<-WOK_SQL def tail <<-'WOK' @@ -703,7 +701,7 @@ module SiSU_CGI_sql def main2 <<-'WOK_SQL' search_field=cgi['find'] if cgi['find'] # =~/\S+/ - @search_for=Search_request.new(search_field,q) #.analyze #% search_for + @search_for=SearchRequest.new(search_field,q) #.analyze #% search_for #% searches #Canned_search.new(@base,@search_for.text1,cgi) if @search_for.text1=~/\S+/ or @search_for.fulltext=~/\S+/ or @search_for.author=~/\S+/ or @search_for.topic_register=~/\S+/ #and search_field =~/\S/ @@ -756,13 +754,13 @@ module SiSU_CGI_sql elsif checked_all =~/checked/ or checked_url =~/checked/ canned_search=@@canned_search_url.scan(/(?:s1|ft|au|ti|fns|tr)=[^&]+/) af=canned_search.join('; ') - af.gsub!(/s1=/,'text: ') - af.gsub!(/ft=/,'fulltxt: ') - af.gsub!(/au=/,'author: ') - af.gsub!(/ti=/,'title: ') - af.gsub!(/fns=/,'filename: ') - af.gsub!(/tr=/,'topic_register: ') - af.gsub!(/%2B/,' ') + af=af.gsub(/s1=/,'text: '). + gsub(/ft=/,'fulltxt: '). + gsub(/au=/,'author: '). + gsub(/ti=/,'title: '). + gsub(/fns=/,'filename: '). + gsub(/tr=/,'topic_register: '). + gsub(/%2B/,' ') analyze_format=af st=af.split(/\s*;\s*/) search_field=st.join("\n") @@ -819,7 +817,7 @@ module SiSU_CGI_sql @search[:endnotes]<<%{endnotes.clean~*'#{CGI.unescape(s1)}'} end #% dbi_request - dbi_statement=Dbi_search_statement.new(@conn,@search_for,q,checked_case) + dbi_statement=DBI_SearchStatement.new(@conn,@search_for,q,checked_case) @text_search_flag=false @text_search_flag=dbi_statement.text_search_flag s_contents=dbi_statement.contents @@ -843,7 +841,7 @@ module SiSU_CGI_sql end def dir_structure case @opt.dir_structure_by - when /language/ + when :language <<-'WOK_SQL' def path_manifest(fn,ln=nil) "#{@hostpath}/#{ln}/manifest/#{fn}.html" @@ -864,7 +862,7 @@ module SiSU_CGI_sql "#{@hostpath}/#{ln}/html/#{fn}.html" end WOK_SQL - when /filetype/ + when :filetype <<-'WOK_SQL' def path_manifest(fn,ln=nil) "#{@hostpath}/manifest/#{fn}.#{ln}.html" @@ -916,7 +914,7 @@ module SiSU_CGI_sql file_suffix=c['src_filename'][/.+?\.(_?sst|ssm)$/,1] lang=if location =~ /\S+?~(\S\S\S?)$/ l=location[/\S+?~(\S\S\S?)$/,1] - location.gsub!(/(\S+?)~\S\S\S?/,'\1') + location=location.gsub(/(\S+?)~\S\S\S?/,'\1') l=".#{l}" else '' end @@ -1008,7 +1006,7 @@ module SiSU_CGI_sql file_suffix=e['src_filename'][/.+?\.(_?sst|ssm)$/,1] lang=if location =~ /\S+?~(\S\S\S?)$/ l=location[/\S+?~(\S\S\S?)$/,1] - location.gsub!(/(\S+?)~\S\S\S?/,'\1') + location=location.gsub(/(\S+?)~\S\S\S?/,'\1') l=".#{l}" else '' end diff --git a/lib/sisu/v3/cgi_sqlite.rb b/lib/sisu/v3/cgi_sqlite.rb index a046fe31..9c2a6a8d 100644 --- a/lib/sisu/v3/cgi_sqlite.rb +++ b/lib/sisu/v3/cgi_sqlite.rb @@ -56,17 +56,17 @@ ** Description: generates naive cgi search form for search of sisu database (pgsql sqlite) =end -module SiSU_CGI_sqlite #% database building documents +module SiSU_CGI_SQLite #% database building documents require_relative 'sysenv' # sysenv.rb require_relative 'cgi_sql_common' # cgi_sql_common.rb - include SiSU_CGI_sql - class SiSU_search_sqlite < SiSU_CGI_common + include SiSU_CGI_SQL + class SearchSQLite < CGI_Common def initialize(opt,webserv) @opt,@webserv=opt,webserv - @env=SiSU_Env::Info_env.new('',opt) + @env=SiSU_Env::InfoEnv.new('',opt) @image_src="#{@env.url.webserv_cgi}/_sisu/image_sys" - @common=SiSU_CGI_sql::SiSU_CGI_common.new(@webserv,@opt,@image_src,@env) - @cgi_file_name="#{Db[:name_prefix_db]}by_#{opt.dir_structure_by}_sqlite.cgi" + @common=SiSU_CGI_SQL::CGI_Common.new(@webserv,@opt,@image_src,@env) + @cgi_file_name="#{Db[:name_prefix_db]}by_#{opt.dir_structure_by.to_s}_sqlite.cgi" end def sqlite serve=[] @@ -78,7 +78,7 @@ module SiSU_CGI_sqlite end end end - serve.sort! + serve=serve.sort f1,f2,f3='','','' serve.each do |x| f1 << %{ <option value="#{Db[:name_prefix]}#{x}">#{x}</option>\n} @@ -137,7 +137,7 @@ module SiSU_CGI_sqlite end def search_statement <<-'WOK_SQL' - class Dbi_search_string + class DBI_SearchString def initialize(l,t,q,cse=false) @l,@t,@q=l,t,q end @@ -148,8 +148,8 @@ module SiSU_CGI_sqlite elsif @q =~/\S+/; unescaped_search=CGI.unescape(@q) end search_construct=[] - unescaped_search.gsub!(/\s*(AND|OR)\s*/,"%' \) \\1 #{@l} LIKE \( '%") - unescaped_search.gsub!(/(.+)/,"#{@l} LIKE \( '%\\1%' \)") + unescaped_search=unescaped_search.gsub(/\s*(AND|OR)\s*/,"%' \) \\1 #{@l} LIKE \( '%"). + gsub(/(.+)/,"#{@l} LIKE \( '%\\1%' \)") search_construct << unescaped_search search_construct=search_construct.join(' ') search[:search] << search_construct @@ -165,11 +165,11 @@ module SiSU_CGI_sqlite <<-'WOK_SQL' @search_text,@search_endnotes='','' search[:text].flatten.each {|x| @search_text << "#{x} AND " } - @search_text=@search_text.gsub!(/AND\s+$/m,'') - @search_text.gsub!(/(doc_objects\.clean\s+LIKE\s+\(\s*'%[^']+%'\s*\)\s+(?:(?:AND|OR)\s+doc_objects\.clean\s+LIKE\s+\(\s*'%[^']+%'\s*\))+)/,'(\1)') + @search_text=@search_text.gsub(/AND\s+$/m,''). + gsub(/(doc_objects\.clean\s+LIKE\s+\(\s*'%[^']+%'\s*\)\s+(?:(?:AND|OR)\s+doc_objects\.clean\s+LIKE\s+\(\s*'%[^']+%'\s*\))+)/,'(\1)') search[:endnotes].flatten.each {|x| @search_endnotes << "#{x} AND " } - @search_endnotes=@search_endnotes.gsub!(/AND\s+$/m,'') - @search_endnotes.gsub!(/(endnotes\.clean\s+LIKE\s+\(\s*'%[^']+%'\s*\)\s+(?:(?:AND|OR)\s+endnotes\.clean\s+LIKE\s+\(\s*'%[^']+%'\s*\))+)/,'(\1)') + @search_endnotes=@search_endnotes.gsub(/AND\s+$/m,''). + gsub(/(endnotes\.clean\s+LIKE\s+\(\s*'%[^']+%'\s*\)\s+(?:(?:AND|OR)\s+endnotes\.clean\s+LIKE\s+\(\s*'%[^']+%'\s*\))+)/,'(\1)') end WOK_SQL end diff --git a/lib/sisu/v3/character_encoding.rb b/lib/sisu/v3/character_encoding.rb index 0b565fb9..1931c466 100644 --- a/lib/sisu/v3/character_encoding.rb +++ b/lib/sisu/v3/character_encoding.rb @@ -57,7 +57,7 @@ output generators [requires kirbybase] =end -module SiSU_character_encode +module SiSU_CharacterEncode require 'kirbybase' require_relative 'sysenv' # sysenv.rb class Characters @@ -73,7 +73,7 @@ module SiSU_character_encode @ce_tbl=@db.create_table.documents(:character_encoding, :glyph,:String, :dec,:Integer, :hex,:String, :rb,:String, :html,:String, :html_name,:String, :tex,:String, :tex_licr,:String, :tex_alt,:String, :name,:String) end def db - x=Character_encoding.new.table + x=CharacterEncoding.new.table #x.each {|y| puts y[2].inspect} x.each do |c| #puts "#{c[0]}, #{c[1]}, #{c[2]}, #{c[3]}, #{c[4]}, #{c[5]}, #{c[6]}, #{c[7]}, #{c[8]}, #{c[9]}" @@ -138,7 +138,7 @@ module SiSU_character_encode end end end - class Character_encoding + class CharacterEncoding def table x=[] #:glyph, :dec,:hex, :rb, :xml , :html_name, :tex, :tex_licr, :tex_alt, :name diff --git a/lib/sisu/v3/composite.rb b/lib/sisu/v3/composite.rb index 95be6d1e..21adb030 100644 --- a/lib/sisu/v3/composite.rb +++ b/lib/sisu/v3/composite.rb @@ -59,9 +59,9 @@ =end module SiSU_Assemble require_relative 'sysenv' # sysenv.rb - class Remote_image + class RemoteImage def initialize - @env=SiSU_Env::Info_env.new + @env=SiSU_Env::InfoEnv.new end def image(dir) images=[] @@ -82,7 +82,7 @@ module SiSU_Assemble end output_path="#{@env.path.webserv}/#{@env.path.stub_pwd}/_sisu/image_external" FileUtils::mkdir_p(output_path) unless FileTest.directory?(output_path) - SiSU_Env::System_call.new("#{path}/*",output_path,'q').rsync + SiSU_Env::SystemCall.new("#{path}/*",output_path,'q').rsync end def download_doc_skin(doc_skin) #first element in array is source url path="#{@env.processing_path.processing}/external_document/skin/doc" @@ -104,14 +104,14 @@ module SiSU_Assemble @@imager={} def initialize(opt) @opt=opt - @env=SiSU_Env::Info_env.new + @env=SiSU_Env::InfoEnv.new end def read begin @fns_array=IO.readlines(@opt.fns,'') assembled=insertions? write(assembled) - rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error + rescue; SiSU_Errors::InfoError.new($!,$@,@opt.cmd,@opt.fns).error ensure end end @@ -161,11 +161,11 @@ module SiSU_Assemble end if not @code_flag \ and i !~/^%+\s/ - i.gsub!(/^([123]|:?[ABC])~\? /,'% [conditional heading:] \1~ ') #off conditional heading (consider syntax) + i=i.gsub(/^([123]|:?[ABC])~\? /,'% [conditional heading:] \1~ ') #off conditional heading (consider syntax) if i =~/^@\S+?:/ - i.gsub!(/\n/m,"\n% ") - i.gsub!(/\n%\s+$/m,'') - i.gsub!(/^@\S+?:/m,"\n% [imported header:] ") #off imported headers + i=i.gsub(/\n/m,"\n% "). + gsub(/\n%\s+$/m,''). + gsub(/^@\S+?:/m,"\n% [imported header:] ") #off imported headers end end file[:prepared] << i @@ -176,8 +176,7 @@ module SiSU_Assemble end file[:prepared] << "\n% end import" << "\n\n" if file[:images].length > 0 - file[:images].flatten! - file[:images].uniq! + file[:images]=file[:images].flatten.uniq file[:images].delete_if {|x| x =~/https?:\/\// } end file @@ -218,32 +217,30 @@ module SiSU_Assemble end else tuned_file << para end - tuned_file.flatten! - tuned_file.compact! + tuned_file=tuned_file.flatten.compact end if @@imager.length >0 @@imager.each do |d,i| - i.flatten! - i.uniq! + i=i.flatten.uniq image_info=d + i - download_images(mage_info.flatten) + download_images(image_info.flatten) end end tuned_file end end - class Composite_file_list + class CompositeFileList @@imager={} def initialize(opt) @opt=opt - @env=SiSU_Env::Info_env.new + @env=SiSU_Env::InfoEnv.new end def read begin @opt.fns=@opt.fns.gsub(/\.ssm\.sst$/,'.ssm') #FIX earlier, hub @fns_array=IO.readlines(@opt.fns,'') files=insertions? - rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error + rescue; SiSU_Errors::InfoError.new($!,$@,@opt.cmd,@opt.fns).error ensure end end diff --git a/lib/sisu/v3/concordance.rb b/lib/sisu/v3/concordance.rb index 96101585..3d8ab38a 100644 --- a/lib/sisu/v3/concordance.rb +++ b/lib/sisu/v3/concordance.rb @@ -70,7 +70,7 @@ module SiSU_Concordance class Source def initialize(opt) @opt=opt - @particulars=SiSU_Particulars::Combined_singleton.instance.get_all(opt) + @particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt) end def read begin @@ -95,23 +95,23 @@ module SiSU_Concordance SiSU_Screen::Ansi.new(@md.opt.cmd,"wc (word count) is off, concordance will be processed for all files including those over the max set size of: #{wordmax} words").warn unless @md.opt.cmd =~/q/ SiSU_Concordance::Source::Words.new(@particulars).songsheet end - rescue; SiSU_Errors::Info_error.new($!,$@,@md.opt.cmd,@md.fns).error + rescue; SiSU_Errors::InfoError.new($!,$@,@md.opt.cmd,@md.fns).error ensure end end private - class Doc_title + class DocTitle include SiSU_Viz #revisit, both requires (html & shared_xml) needed for stand alone operation (sisu -w [filename]) require_relative 'shared_xml' # shared_xml.rb require_relative 'html' # html.rb def initialize(particulars) @particulars,@md=particulars,particulars.md - @data=SiSU_HTML::Source::Html_environment.new(particulars).tuned_file_instructions - @file=SiSU_Env::SiSU_file.new(@md) - @vz=SiSU_Env::Get_init.instance.skin + @data=SiSU_HTML::Source::HTML_Environment.new(particulars).tuned_file_instructions + @file=SiSU_Env::FileOp.new(@md) + @vz=SiSU_Env::GetInit.instance.skin txt_path=%{#{@md.dir_out}} - SiSU_Env::Info_skin.new(@md).select + SiSU_Env::InfoSkin.new(@md).select @fnb=@md.fnb @lex_button=%{<a href="http://www.jus.uio.no/sisu/" target="_top"><img border="0" height="44" width="144" valign="center" src="#{@file.path_rel_links.html_seg_2}_sisu/image/sisu.png" alt="SiSU home -->"></a>} @doc_details =<<WOK @@ -119,10 +119,21 @@ module SiSU_Concordance WOK end def create - head_banner=SiSU_HTML_Format::Head_toc.new(@md) - minitoc=SiSU_HTML_minitoc::Toc_mini.new(@md,@data).songsheet.join("\n") - @css=SiSU_Env::CSS_stylesheet.new(@md) - toc='<div class="toc">' + minitoc + '</div>' + head_banner=SiSU_HTML_Format::HeadToc.new(@md) + minitoc=SiSU_HTML_MiniToc::TocMini.new(@md,@data).songsheet.join("\n") + stylesheet=SiSU_Style::CSS_HeadInfo.new(@md).stylesheet + make=SiSU_Env::ProcessingSettings.new(@md) + if make.build.manifest_minitoc? + toc='<div class="toc">' + minitoc + '</div>' + div_class='content' + else + toc='' + div_class='content0' + end + top_band=if make.build.html_top_band? + head_banner.concordance_navigation_band('pdf') + else '' + end <<WOK <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> @@ -136,14 +147,14 @@ WOK <meta name="generator" content="SiSU (Linux & Ruby!)"> <link rel="generator" href="http://www.jus.uio.no/sisu" /> <link rel="shortcut icon" href="../_sisu/image/rb7.ico" /> - #{@css.html_seg} + #{stylesheet.css_head_seg} #{@vz.js_head} </head> <body> #{@vz.js_top} - #{head_banner.concordance_navigation_band('pdf')} + #{top_band} #{toc} -<div class="content"> +<div class="#{div_class}"> #{@doc_details} <p>Word index links are to html versions of the text the segmented version followed by the scroll (single document) version.<br />[For segmented text references [T1], [T2] or [T3] appearing without a link, indicates that the word appears in a title (or subtitle) of the text (that is identifiable by the appended object citation number).]</p> <p>(The word listing/index is Case sensitive: Capitalized words appear before lower case)</p> @@ -185,11 +196,11 @@ WOK def initialize(particulars) @particulars=particulars begin - @vz=SiSU_Env::Get_init.instance.skin + @vz=SiSU_Env::GetInit.instance.skin @env,@md,@dal_array=particulars.env,particulars.md,particulars.dal_array - @file=SiSU_Env::SiSU_file.new(@md) + @file=SiSU_Env::FileOp.new(@md) @freq=Hash.new(0) - @dp=@@dp ||=SiSU_Env::Info_env.new.digest.pattern + @dp=@@dp ||=SiSU_Env::InfoEnv.new.digest.pattern @rxp_lv1=/^#{Mx[:lv_o]}1:/ #fix @rxp_lv # Mx[:lv_o] @rxp_lv2=/^#{Mx[:lv_o]}2:/ #fix @rxp_lv # Mx[:lv_o] @rxp_lv3=/^#{Mx[:lv_o]}3:/ #fix @rxp_lv # Mx[:lv_o] @@ -203,7 +214,7 @@ WOK @alph=SiSU_i18n::Alphabet.new(@md.opt.lng).hash_arrays @alphlst=SiSU_i18n::Alphabet.new(@md.opt.lng).hash_strings @rgx_scanlist=%r{#{Mx[:fa_italics_o]}[#{@alphlst[:l]}#{@alphlst[:u]}0-9"\s]{2,12}#{Mx[:fa_italics_c]}|#{Mx[:fa_bold_o]}[#{@alphlst[:l]}#{@alphlst[:u]}0-9"\s]{2,12}#{Mx[:fa_bold_c]}|(?:https?|file)://\S+|<\S+?>|[#{@alphlst[:l]}#{@alphlst[:u]}]+|\w+}mi - rescue; SiSU_Errors::Info_error.new($!,$@,@md.opt.cmd,@md.fns).error + rescue; SiSU_Errors::InfoError.new($!,$@,@md.opt.cmd,@md.fns).error end end def songsheet @@ -211,7 +222,7 @@ WOK FileUtils::mkdir_p(@file.output_path.html_concordance.dir) unless FileTest.directory?(@file.output_path.html_concordance.dir) @file_concordance=File.open(@file.place_file.html_concordance.dir,'w') map_para - rescue; SiSU_Errors::Info_error.new($!,$@,@md.opt.cmd,@md.fns).error + rescue; SiSU_Errors::InfoError.new($!,$@,@md.opt.cmd,@md.fns).error ensure @file_concordance.close end @@ -238,61 +249,63 @@ WOK @dal_array.each do |line| if defined? line.ocn \ and line.ocn.to_s =~/\d/ - if line.is =~/heading/ \ - and line.ln==4 + if (line.is ==:heading \ + || line.is ==:heading_insert) \ + && line.ln==4 @seg=line.name end ocn=line.ocn.to_s if ocn =~/\d+/ \ and ocn !~/^0$/ - line.obj.gsub!(/#{@rxp_excluded1}/,' ') + line.obj=line.obj.gsub(/#{@rxp_excluded1}/,' ') line.obj=line.obj.split(@rgx_splitlist).join(' ') #%take in word or other match for word in line.obj.scan(@rgx_scanlist) #%take in word or other match if word =~ /^([#{@alphlst[:l]}])/ firstletter=$1 flu=firstletter.tr(@alphlst[:l],@alphlst[:u]) - word.gsub!(/^#{firstletter}/,flu ) + word=word.gsub(/^#{firstletter}/,flu ) end - word.gsub!(/#{Mx[:lnk_o]}|#{Mx[:lnk_c]}|#{Mx[:url_o]}|#{Mx[:url_c]}/,'') - word.gsub!(/#{Mx[:fa_o]}\S+?#{Mx[:fa_o_c]}/,'') - word.gsub!(/#{Mx[:fa_c_o]}\S+?#{Mx[:fa_c]}/,'') - word.gsub!(/#{Mx[:gl_o]}#[a-z]+#{Mx[:gl_c]}/,'') - word.gsub!(/#{Mx[:gl_o]}#[0-9]+#{Mx[:gl_c]}/,'') - word.gsub!(/[0-9a-f]{10,}/,' ') if word =~/[0-9]/ - word.gsub!(/#{Mx[:br_line]}/,' ') - word.gsub!(/^ +/,'') - word.gsub!(/^\S$/,'') + word=word.gsub(/#{Mx[:lnk_o]}|#{Mx[:lnk_c]}|#{Mx[:url_o]}|#{Mx[:url_c]}/,''). + gsub(/#{Mx[:fa_o]}\S+?#{Mx[:fa_o_c]}/,''). + gsub(/#{Mx[:fa_c_o]}\S+?#{Mx[:fa_c]}/,''). + gsub(/#{Mx[:gl_o]}#[a-z]+#{Mx[:gl_c]}/,''). + gsub(/#{Mx[:gl_o]}#[0-9]+#{Mx[:gl_c]}/,'') + word=word.gsub(/[0-9a-f]{10,}/,' ') if word =~/[0-9]/ + word=word.gsub(/#{Mx[:br_line]}/,' '). + gsub(/^ +/,''). + gsub(/^\S$/,'') word=nil if word.empty? word=nil if word =~@rxp_excluded0 #watch word=nil if word =~/^\S$/ if word - word.gsub!(/#{Mx[:br_nl]}|#{Mx[:br_line]}/,' ') - word.gsub!(/#{Mx[:fa_o]}[a-z]{1,7}#{Mx[:fa_o_c]}|#{Mx[:fa_c_o]}[a-z]{1,7}#{Mx[:fa_c]}/,'') - word.gsub!(/#{Mx[:en_a_o]}(?:\d|[*+])*|#{Mx[:en_b_o]}(?:\d|[*+])*|#{Mx[:en_a_c]}|#{Mx[:en_b_c]}/mi,'') - word.gsub!(/#{Mx[:fa_o]}\S+?#{Mx[:fa_o_c]}/,''); word.gsub!(/#{Mx[:fa_c_o]}\S+?#{Mx[:fa_c]}/,'') - word.gsub!(/<\/?\S+?>/,'') - word.gsub!(/^\@+/,'') - word.strip! - word.gsub!(/#{Mx[:tc_p]}.+/,'') - word.gsub!(/[\.,;:"]$/,'') - word.gsub!(/["]/,'') - word.gsub!(/^\s*[\(]/,'') - word.gsub!(/[\(]\s*$/,'') - word.gsub!(/^(?:See|e\.?g\.?).+/,'') - word.gsub!(/^\s*[.,;:]\s*/,'') - word.strip! - word.gsub!(/^\(?[a-zA-Z]\)$/,'') - word.gsub!(/^\d+(st|nd|rd|th)$/,'') - word.gsub!(/^(\d+\.?)+$/, '') - word.gsub!(/#{Mx[:mk_o]}|#{Mx[:mk_c]}/,'') - word.gsub!(/:name#\S+/,'') - word.gsub!(/^\S$/,'') + word=word.gsub(/#{Mx[:br_nl]}|#{Mx[:br_line]}/,' '). + gsub(/#{Mx[:fa_o]}[a-z]{1,7}#{Mx[:fa_o_c]}|#{Mx[:fa_c_o]}[a-z]{1,7}#{Mx[:fa_c]}/,''). + gsub(/#{Mx[:en_a_o]}(?:\d|[*+])*|#{Mx[:en_b_o]}(?:\d|[*+])*|#{Mx[:en_a_c]}|#{Mx[:en_b_c]}/mi,''). + gsub(/#{Mx[:fa_o]}\S+?#{Mx[:fa_o_c]}/,''). + gsub(/#{Mx[:fa_c_o]}\S+?#{Mx[:fa_c]}/,''). + gsub(/<\/?\S+?>/,''). + gsub(/^\@+/,''). + strip. + gsub(/#{Mx[:tc_p]}.+/,''). + gsub(/[\.,;:"]$/,''). + gsub(/["]/,''). + gsub(/^\s*[\(]/,''). + gsub(/[\(]\s*$/,''). + gsub(/^(?:See|e\.?g\.?).+/,''). + gsub(/^\s*[.,;:]\s*/,''). + strip. + gsub(/^\(?[a-zA-Z]\)$/,''). + gsub(/^\d+(st|nd|rd|th)$/,''). + gsub(/^(\d+\.?)+$/, ''). + gsub(/#{Mx[:mk_o]}|#{Mx[:mk_c]}/,''). + gsub(/:name#\S+/,''). + gsub(/^\S$/,'') word=nil if word =~/^\S$/ word=nil if word =~/^\s*$/ #watch if word unless word =~/[A-Z][A-Z]/ \ or word =~/\w+\s\w+/ - word.capitalize! + word=word.capitalize end @freq[word] +=1 @word_map[word] ||= [] @@ -315,9 +328,9 @@ WOK end scr='<font size="1" color="#777777" face=times new roman><img border="0" height="15" width="15" src="../_sisu/image/b_doc.png" alt="Full Text"> scroll: </font><font size="1" color="#222222" face=times new roman>doc# </font> ' seg='' - head=SiSU_Concordance::Source::Doc_title.new(@particulars).create - head.gsub!(/#{Xx[:html_relative2]}/m,@file.path_rel_links.html_seg_2) - head.gsub!(/#{Xx[:html_relative1]}/m,@file.path_rel_links.html_seg_1) + head=SiSU_Concordance::Source::DocTitle.new(@particulars).create + head=head.gsub(/#{Xx[:html_relative2]}/m,@file.path_rel_links.html_seg_2). + gsub(/#{Xx[:html_relative1]}/m,@file.path_rel_links.html_seg_1) @file_concordance << head @file_concordance << '<p>' alph=@alph[:u] diff --git a/lib/sisu/v3/conf.rb b/lib/sisu/v3/conf.rb index 05bc8608..5eb1b116 100644 --- a/lib/sisu/v3/conf.rb +++ b/lib/sisu/v3/conf.rb @@ -61,7 +61,7 @@ module SiSU_Initialize include SiSU_Env include SiSU_Screen require_relative 'relaxng' # relaxng.rb - include SiSU_relaxng + include SiSU_Relaxng require_relative 'css' # css.rb include SiSU_Style class Source @@ -69,19 +69,19 @@ module SiSU_Initialize @opt=opt end def read - SiSU_Config.new(@opt).make_homepage - SiSU_Config.new(@opt).css - SiSU_Config.new(@opt).dtd - SiSU_Config.new(@opt).cp_local_images - SiSU_Config.new(@opt).cp_external_images - SiSU_Config.new(@opt).cp_webserver_images #if @opt.mod.inspect =~/--init(?:ialize)?=site/ + ConfigSite.new(@opt).make_homepage + ConfigSite.new(@opt).css + ConfigSite.new(@opt).dtd + ConfigSite.new(@opt).cp_local_images + ConfigSite.new(@opt).cp_external_images + ConfigSite.new(@opt).cp_webserver_images #if @opt.mod.inspect =~/--init(?:ialize)?=site/ end end - class SiSU_Config #config files such as css are not updated if they already exist unless forced using the --init=site modifier + class ConfigSite #config files such as css are not updated if they already exist unless forced using the --init=site modifier require_relative 'sysenv' # sysenv.rb def initialize(opt) @opt=opt - @env=SiSU_Env::Info_env.new(@opt.fns) + @env=SiSU_Env::InfoEnv.new(@opt.fns) @suffix,@path={},{} @suffix[:rnc]='rnc' @suffix[:rng]='rng' @@ -94,30 +94,30 @@ module SiSU_Initialize end def make_homepage SiSU_Screen::Ansi.new(@opt.cmd,'invert','Make homepage','').colorize unless @opt.cmd =~/q/ - SiSU_Env::Create_site.new(@opt.cmd).homepage + SiSU_Env::CreateSite.new(@opt.cmd).homepage end def cp_local_images SiSU_Screen::Ansi.new(@opt.cmd,'invert','Copy images','').colorize unless @opt.cmd =~/q/ - SiSU_Env::Create_site.new(@opt.cmd).cp_local_images - SiSU_Env::Create_site.new(@opt.cmd).cp_webserver_images_local #this should not have been necessary - SiSU_Env::Create_site.new(@opt.cmd).cp_base_images #base images (nav etc.) used by all html + SiSU_Env::CreateSite.new(@opt.cmd).cp_local_images + SiSU_Env::CreateSite.new(@opt.cmd).cp_webserver_images_local #this should not have been necessary + SiSU_Env::CreateSite.new(@opt.cmd).cp_base_images #base images (nav etc.) used by all html end def cp_external_images SiSU_Screen::Ansi.new(@opt.cmd,'invert','Copy external images','').colorize if @opt.cmd =~/V/ - SiSU_Env::Create_site.new(@opt.cmd).cp_external_images + SiSU_Env::CreateSite.new(@opt.cmd).cp_external_images end def cp_webserver_images SiSU_Screen::Ansi.new(@opt.cmd,'invert','Copy webserver/output file images','').colorize unless @opt.cmd =~/q/ - SiSU_Env::Create_site.new(@opt.cmd).cp_webserver_images - SiSU_Env::Create_system_link.new.images + SiSU_Env::CreateSite.new(@opt.cmd).cp_webserver_images + SiSU_Env::CreateSystemLink.new.images end def css SiSU_Screen::Ansi.new(@opt.cmd,'invert','Configuring CSSs','').colorize unless @opt.cmd =~/q/ - SiSU_Env::Create_site.new(@opt.cmd).cp_css + SiSU_Env::CreateSite.new(@opt.cmd).cp_css end def dtd SiSU_Screen::Ansi.new(@opt.cmd,'invert','Configuring DTDs','').colorize unless @opt.cmd =~/q/ - @rxng=SiSU_relaxng::RelaxNG.new + @rxng=SiSU_Relaxng::RelaxNG.new @path.each { |d| FileUtils::mkdir_p(d[1]) unless FileTest.directory?(d[1]) } #ugly code, sort later if @rxng.methods.join =~/[^_]dtd_sax\b/ @@ -167,10 +167,10 @@ module SiSU_Initialize rnc << @rxng.rnc_model_output_sax rnc.close #xsd - schema=SiSU_Env::System_call.new(rnc_src,xsd_file) + schema=SiSU_Env::SystemCall.new(rnc_src,xsd_file) schema.relaxng(@opt.cmd) #rng - schema=SiSU_Env::System_call.new(rnc_src,rng_file) + schema=SiSU_Env::SystemCall.new(rnc_src,rng_file) schema.relaxng(@opt.cmd) #rnc FileUtils::cp(rnc_src,rnc_file) @@ -186,10 +186,10 @@ module SiSU_Initialize rnc << @rxng.rnc_model_output_dom rnc.close #xsd - schema=SiSU_Env::System_call.new(rnc_src,xsd_file) + schema=SiSU_Env::SystemCall.new(rnc_src,xsd_file) schema.relaxng(@opt.cmd) #rng - schema=SiSU_Env::System_call.new(rnc_src,rng_file) + schema=SiSU_Env::SystemCall.new(rnc_src,rng_file) schema.relaxng(@opt.cmd) #rnc FileUtils::cp(rnc_src,rnc_file) @@ -205,10 +205,10 @@ module SiSU_Initialize rnc << @rxng.rnc_model_output_xhtml rnc.close #xsd - schema=SiSU_Env::System_call.new(rnc_src,xsd_file) + schema=SiSU_Env::SystemCall.new(rnc_src,xsd_file) schema.relaxng(@opt.cmd) #rng - schema=SiSU_Env::System_call.new(rnc_src,rng_file) + schema=SiSU_Env::SystemCall.new(rnc_src,rng_file) schema.relaxng(@opt.cmd) #rnc FileUtils::cp(rnc_src,rnc_file) @@ -220,7 +220,7 @@ module SiSU_Initialize rnc=File.new(rnc_file,'w') rnc << @rxng.rnc_model_output_sax rnc.close - schema=SiSU_Env::System_call.new(rnc_file,dtd_file) + schema=SiSU_Env::SystemCall.new(rnc_file,dtd_file) schema.relaxng(@opt.cmd) end def trang_rnc_model_input_dom @@ -229,7 +229,7 @@ module SiSU_Initialize rnc=File.new(rnc_file,'w') rnc << @rxng.rnc_model_output_dom rnc.close - schema=SiSU_Env::System_call.new(rnc_file,dtd_file) + schema=SiSU_Env::SystemCall.new(rnc_file,dtd_file) schema.relaxng(@opt.cmd) end def trang_rnc_model_input_node @@ -239,7 +239,7 @@ module SiSU_Initialize rnc=File.new(rnc_file,'w') rnc << @rxng.rnc_model_input_node rnc.close - schema=SiSU_Env::System_call.new(rnc_file,dtd_file) + schema=SiSU_Env::SystemCall.new(rnc_file,dtd_file) schema.relaxng(@opt.cmd) end end diff --git a/lib/sisu/v3/constants.rb b/lib/sisu/v3/constants.rb index d39c56ea..439dee68 100644 --- a/lib/sisu/v3/constants.rb +++ b/lib/sisu/v3/constants.rb @@ -273,8 +273,8 @@ puts "#{__FILE__} #{__LINE__} #{o.inspect}" puts __FILE__ + ' ' + __LINE__.to_s + '--> ' + o.inspect puts %{-\t#{__FILE__}::#{__LINE__}::#{caller}:\n"#{name}"} p "\t" + txt.obj + " << #{__FILE__} #{__LINE__} >>" -p (__FILE__ + ' ' + __LINE__.to_s + '--> ' + dob.inspect) if dob.is=='heading' -data.each {|o| p (__FILE__ + ' ' + __LINE__.to_s + '--> ' + o.inspect) if o.is=='heading'} +p (__FILE__ + ' ' + __LINE__.to_s + '--> ' + dob.inspect) if dob.is==:heading +data.each {|o| p (__FILE__ + ' ' + __LINE__.to_s + '--> ' + o.inspect) if o.is==:heading} puts "#{__FILE__} #{__LINE__} #{para}" if @opt.cmd =~/M/ puts "#{__FILE__} #{__LINE__} #{t_o}" if @opt.cmd =~/M/ dr ┌ 9484 dR ┍ 9485 Dr ┎ 9486 DR ┏ 9487 dl ┐ 9488 dL ┑ 9489 Dl ┒ 9490 LD ┓ 9491 ur └ 9492 uR ┕ 9493 Ur ┖ 9494 UR ┗ 9495 ul ┘ 9496 uL ┙ 9497 Ul ┚ 9498 UL ┛ 9499 vr ├ diff --git a/lib/sisu/v3/css.rb b/lib/sisu/v3/css.rb index 348c89e7..cbbd05ca 100644 --- a/lib/sisu/v3/css.rb +++ b/lib/sisu/v3/css.rb @@ -59,9 +59,101 @@ module SiSU_Style require_relative 'sysenv' # sysenv.rb require_relative 'defaults' # defaults.rb + class CSS_HeadInfo + def initialize(md,ft='html') + @md,@ft=md,ft + @env=SiSU_Env::InfoEnv.new('',md) + @fn_css ||=SiSU_Env::CSS_Default.new + @o_str ||=SiSU_Env::ProcessingSettings.new(md).output_dir_structure + css_copy + end + def stylesheet + def css_path + SiSU_Env::CSS_Stylesheet.new(@md) + end + def css_embed_content + @css_embed_content ||=SiSU_Style::CSS.new + end + def css_embed? + if @ft=='html' \ + && @o_str.dump_or_redirect? + true + else + false + end + end + def css_embed(css) + <<-WOK + <style TYPE="text/css"> + #{css} + </style> + WOK + end + def css_action + style_css=SiSU_Style::CSS.new + css=case @ft + when 'html' + css=css_embed_content.html + css_embed(css) + when 'xhtml' + css_path.xhtml + when 'xml_sax' + css_path.xml_sax + when 'xml_dom' + css_path.xml_dom + else + css_embed_content.html + end + end + def css_head + (css_embed?) \ + ? css_action + : "#{css_path.html}#{css_path.html_seg}" + end + def css_head_seg + (css_embed?) \ + ? css_action + : css_path.html_seg + end + def css_head_xml + css_action + end + self + end + def css_copy + if @o_str.dump_or_redirect? + css=SiSU_Style::CSS.new + if @o_str.dump? + css_pth="#{@md.opt.opt_act[:dump][:inst]}/#{@env.path.style}" + elsif @o_str.redirect? + css_pth="#{@md.opt.opt_act[:redirect][:inst]}/#{@md.fnb}/#{@env.path.style}" + end + FileUtils::mkdir_p(css_pth) unless FileTest.directory?(css_pth) + case @ft + when 'html' + style=File.new("#{css_pth}/#{@fn_css.html}",'w') + style << css.html + style.close + when 'xhtml' + style=File.new("#{css_pth}/#{@fn_css.xhtml}",'w') + style << css.xhtml + style.close + when 'xml_sax' + style=File.new("#{css_pth}/#{@fn_css.xml_sax}",'w') + style << css.xml_sax + style.close + when 'xml_dom' + style=File.new("#{css_pth}/#{@fn_css.xml_dom}",'w') + style << css.xml_dom + style.close + css_path.xml_dom + end + end + end + end class CSS def initialize - @vz=SiSU_Env::Get_init.instance.skin + @vz=SiSU_Env::GetInit.instance.skin end def fonts @vz.font_fonts @@ -1442,12 +1534,12 @@ WOK padding-left: 1em; padding-right: 1em; } -/* - div.content { - margin-left: 1em; - margin-right: 1em; + div.content0, div.main_column0 { + margin: 0; + padding: 0; + border-left: 0% solid #ffffff; + padding-left: 5%; } -*/ div.scroll { margin: 0; padding: 0; diff --git a/lib/sisu/v3/dal.rb b/lib/sisu/v3/dal.rb index 50cf94f9..bd8d32dd 100644 --- a/lib/sisu/v3/dal.rb +++ b/lib/sisu/v3/dal.rb @@ -66,7 +66,7 @@ module SiSU_DAL include SiSU_Param require_relative 'dal_doc_objects' # dal_doc_objects.rb require_relative 'dal_syntax' # dal_syntax.rb - include SiSU_Syntax + include SiSU_DAL_Syntax require_relative 'dal_doc_str' # dal_doc_str.rb require_relative 'dal_idx' # dal_idx.rb require_relative 'dal_numbering' # dal_numbering.rb @@ -94,9 +94,9 @@ module SiSU_DAL @opt,@fnx=opt,fnx @@fns||@opt.fns @make_fns=if @fnx and @fnx =~/\.ss[tmi]$/ - SiSU_Env::Info_file.new(@fnx) + SiSU_Env::InfoFile.new(@fnx) else - SiSU_Env::Info_file.new(@opt.fns) + SiSU_Env::InfoFile.new(@opt.fns) end @fnm=@make_fns.marshal.dal_metadata @fnc=@make_fns.marshal.dal_content @@ -106,8 +106,8 @@ module SiSU_DAL @idx_xhtml=@make_fns.marshal.dal_idx_xhtml @map_nametags=@make_fns.marshal.dal_map_nametags @map_ocn_htmlseg=@make_fns.marshal.dal_map_ocn_htmlseg - SiSU_Env::Create_system_link.new.images - @env=SiSU_Env::Info_env.new + SiSU_Env::CreateSystemLink.new.images + @env=SiSU_Env::InfoEnv.new end def read #creates dal begin @@ -117,9 +117,9 @@ module SiSU_DAL ? @fnx : @opt.fns create_dal - rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@@fns).error + rescue; SiSU_Errors::InfoError.new($!,$@,@opt.cmd,@@fns).error ensure - Instantiate.new + SiSU_DAL::Instantiate.new end end def get #reads dal, unless does not exist then creates first @@ -133,9 +133,9 @@ module SiSU_DAL @@dal_array=[] end dal=(@@dal_array.empty?) ? read_fnc : @@dal_array.dup - rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error + rescue; SiSU_Errors::InfoError.new($!,$@,@opt.cmd,@opt.fns).error ensure - Instantiate.new + SiSU_DAL::Instantiate.new end end def get_idx_sst #reads dal idx.sst, #unless does not exist then creates first @@ -149,9 +149,9 @@ module SiSU_DAL @@idx_arr[:sst]=[] end dal=(@@idx_arr[:sst].empty?) ? read_idx_sst : @@idx_arr[:sst].dup #check - rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error + rescue; SiSU_Errors::InfoError.new($!,$@,@opt.cmd,@opt.fns).error ensure - Instantiate.new + SiSU_DAL::Instantiate.new end end def get_idx_tex #reads dal idx.tex, #unless does not exist then creates first @@ -165,9 +165,9 @@ module SiSU_DAL @@idx_arr[:tex]=[] end dal=(@@idx_arr[:tex].empty?) ? read_idx_tex : @@idx_arr[:tex].dup #check - rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error + rescue; SiSU_Errors::InfoError.new($!,$@,@opt.cmd,@opt.fns).error ensure - Instantiate.new + SiSU_DAL::Instantiate.new end end def get_idx_html #reads dal idx.html, #unless does not exist then creates first @@ -181,9 +181,9 @@ module SiSU_DAL @@idx_arr[:html]=[] end dal=(@@idx_arr[:html].empty?) ? read_idx_html : @@idx_arr[:html].dup - rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error + rescue; SiSU_Errors::InfoError.new($!,$@,@opt.cmd,@opt.fns).error ensure - Instantiate.new + SiSU_DAL::Instantiate.new end end def get_idx_xhtml #reads dal idx.xhtml, #unless does not exist then creates first @@ -197,9 +197,9 @@ module SiSU_DAL @@idx_arr[:xthml]=[] end dal=(@@idx_arr[:xhtml].empty?) ? read_idx_xhtml : @@idx_arr[:xhtml].dup - rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error + rescue; SiSU_Errors::InfoError.new($!,$@,@opt.cmd,@opt.fns).error ensure - Instantiate.new + SiSU_DAL::Instantiate.new end end def get_map_nametags #reads dal map.nametags, #unless does not exist then creates first @@ -213,9 +213,9 @@ module SiSU_DAL @@map_arr[:nametags]=[] end dal=(@@map_arr[:nametags].empty?) ? read_map_nametags : @@map_arr[:nametags].dup - rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error + rescue; SiSU_Errors::InfoError.new($!,$@,@opt.cmd,@opt.fns).error ensure - Instantiate.new + SiSU_DAL::Instantiate.new end end def get_map_ocn_htmlseg #reads dal map.ocn_htmlseg, #unless does not exist then creates first @@ -229,9 +229,9 @@ module SiSU_DAL @@map_arr[:ocn_htmlseg]=[] end dal=(@@map_arr[:ocn_htmlseg].empty?) ? read_map_ocn_htmlseg : @@map_arr[:ocn_htmlseg].dup - rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error + rescue; SiSU_Errors::InfoError.new($!,$@,@opt.cmd,@opt.fns).error ensure - Instantiate.new + SiSU_DAL::Instantiate.new end end protected @@ -257,7 +257,7 @@ module SiSU_DAL meta=nil dal=SiSU_DAL::Make.new(fn,@md,file_array).song if @opt.cmd =~/[vM]/ - cf=SiSU_Env::Create_file.new(fn) + cf=SiSU_Env::CreateFile.new(fn) SiSU_Screen::Ansi.new(@opt.cmd,@opt.fns,"~meta/#{@opt.fns}.meta").output if @opt.cmd =~/v/i SiSU_Screen::Ansi.new(@opt.cmd,"dal -> #{cf.meta}").txt_grey if @opt.cmd =~/M/ end @@ -340,16 +340,16 @@ module SiSU_DAL class Output def initialize(fn,md,data) @fn,@md,@data=fn,md,data - @cf=SiSU_Env::Create_file.new(@fn) - @make=SiSU_Env::Info_file.new(@fn) - @dir=SiSU_Env::Info_env.new(@fn) + @cf=SiSU_Env::CreateFile.new(@fn) + @make=SiSU_Env::InfoFile.new(@fn) + @dir=SiSU_Env::InfoEnv.new(@fn) end def screen_dump(o) if defined? o.of print %{OF: #{o.of}; } end if defined? o.is - print %{IS: #{o.is}; } + print %{IS: #{o.is.to_s}; } end if defined? o.ocn print %{OCN: #{o.ocn}; } @@ -386,15 +386,15 @@ module SiSU_DAL @data.each do |o| if defined? o.ocn filename_txt.puts case o.is - when 'heading' - "[#{o.is} #{o.lv}~#{o.name} [#{o.ocn}]] #{o.obj}" - else "[#{o.is} [#{o.ocn}]] #{o.obj}" + when :heading + "[#{o.is.to_s} #{o.lv}~#{o.name} [#{o.ocn}]] #{o.obj}" + else "[#{o.is.to_s} [#{o.ocn}]] #{o.obj}" end else filename_txt.puts case o.is - when 'meta' + when :meta "[m~#{o.tag}] #{o.obj}" - else "[#{o.is}] #{o.obj}" + else "[#{o.is.to_s}] #{o.obj}" end end end @@ -402,8 +402,8 @@ module SiSU_DAL @data.each do |o| if defined? o.ocn case o.is - when 'heading' - filename_debug.puts "#{o.is} #{o.lv}~#{o.name} odv=#{o.odv} osp=#{o.osp} [#{o.ocn}] -->\n\t#{o.obj}" + when :heading + filename_debug.puts "#{o.is.to_s} #{o.lv}~#{o.name} odv=#{o.odv} osp=#{o.osp} [#{o.ocn}] -->\n\t#{o.obj}" end end end @@ -465,7 +465,7 @@ module SiSU_DAL class Make def initialize(fn,md,data) @fn,@md,@data=fn,md,data - @env=SiSU_Env::Info_env.new(@md.fns) + @env=SiSU_Env::InfoEnv.new(@md.fns) end def reset @@flag_vocab=0 @@ -475,15 +475,15 @@ module SiSU_DAL reset data=@data data=data.join.split("\n\n") - data=SiSU_insertions::Insertions.new(@md,data).expand_insertions? # dal_expand_insertions.rb - data=SiSU_substitute_and_insert::SI.new(@md,data).substitutions_and_insertions? # dal_substitutions_and_insertions.rb - data,metadata=SiSU_document_structure_extract::Build.new(@md,data).identify_parts # dal_doc_str.rb - data=SiSU_Syntax::Markup.new(@md,data).songsheet # dal_syntax.rb - data,endnote_array=SiSU_character_check::Check.new(data).character_check_and_oldstyle_endnote_array # dal_character_check.rb - data=SiSU_images::Images.new(@md,data).images # dal_images.rb - data,tags_map,ocn_html_seg_map=SiSU_numbering::Numbering.new(@md,data).numbering_song # dal_numbering.rb - data,book_index_rel,book_index_rel_html_seg,html_idx,xhtml_idx=SiSU_book_index::Book_index.new(@md,data,@env).indexing_song if @md.book_idx # dal_idx.rb - data=SiSU_endnotes::Endnotes.new(@md,data,endnote_array).endnotes # dal_endnotes.rb + data=SiSU_DAL_Insertions::Insertions.new(@md,data).expand_insertions? # dal_expand_insertions.rb + data=SiSU_DAL_SubstituteAndInsert::SI.new(@md,data).substitutions_and_insertions? # dal_substitutions_and_insertions.rb + data,metadata=SiSU_DAL_DocumentStructureExtract::Build.new(@md,data).identify_parts # dal_doc_str.rb + data=SiSU_DAL_Syntax::Markup.new(@md,data).songsheet # dal_syntax.rb + data,endnote_array=SiSU_DAL_CharacterCheck::Check.new(data).character_check_and_oldstyle_endnote_array # dal_character_check.rb + data=SiSU_DAL_Images::Images.new(@md,data).images # dal_images.rb + data,tags_map,ocn_html_seg_map=SiSU_DAL_Numbering::Numbering.new(@md,data).numbering_song # dal_numbering.rb + data,book_index_rel,book_index_rel_html_seg,html_idx,xhtml_idx=SiSU_DAL_BookIndex::BookIndex.new(@md,data,@env).indexing_song if @md.book_idx # dal_idx.rb + data=SiSU_DAL_Endnotes::Endnotes.new(@md,data,endnote_array).endnotes # dal_endnotes.rb outputdata=data if @md.opt.cmd =~/[mM]/ SiSU_DAL::Output.new(@fn,@md,outputdata).hard_output diff --git a/lib/sisu/v3/dal_character_check.rb b/lib/sisu/v3/dal_character_check.rb index 70cddf91..e5ab7578 100644 --- a/lib/sisu/v3/dal_character_check.rb +++ b/lib/sisu/v3/dal_character_check.rb @@ -56,7 +56,7 @@ ** Description: system environment, resource control and configuration details =end -module SiSU_character_check +module SiSU_DAL_CharacterCheck class Check def initialize(data) @data=data @@ -68,26 +68,27 @@ module SiSU_character_check @tuned_file,@endnote_array=[],[] endnote_no=1 data.each do |dob| - unless dob.is =='table' - dob.obj.strip! - dob.obj.gsub!(/^[{~}]\s*$/,'') - dob.obj.gsub!(/~#\s*/,"#{Mx[:pa_non_object_no_heading]}") - dob.obj.gsub!(/-#\s*/,"#{Mx[:pa_non_object_dummy_heading]}") - dob.obj.gsub!(/(#{Mx[:en_a_o]})\s*\s+/,'\1 '); dob.obj.gsub!(/(~\{\s*)\s+/,'\1 ') - dob.obj.gsub!(/ \/\//,"#{Mx[:br_line]}") - dob.obj.gsub!(/<br>/,"#{Mx[:br_line]}") #needed by xml, xhtml etc. - dob.obj.gsub!(/\t/,' ') - dob.obj.gsub!(/\342\200\231/u,"'") #if dob =~/’/ #Avoid #‘ ’ #“ ” - dob.obj.gsub!(/�/u,' ') #watch, replace with char code - dob.obj.gsub!(/·/u,'*') - dob.obj.gsub!(/\\copy(?:right)?\b/,'©') - dob.obj.gsub!(/\\trademark\b|\\tm\b/,'®') + unless dob.is ==:table + dob.obj=dob.obj.strip. + gsub(/^[{~}]\s*$/,''). + gsub(/~#\s*/,"#{Mx[:pa_non_object_no_heading]}"). + gsub(/-#\s*/,"#{Mx[:pa_non_object_dummy_heading]}"). + gsub(/(#{Mx[:en_a_o]})\s*\s+/,'\1 '). + gsub(/(~\{\s*)\s+/,'\1 '). + gsub(/ \/\//,"#{Mx[:br_line]}"). + gsub(/<br>/,"#{Mx[:br_line]}"). #needed by xml, xhtml etc. + gsub(/\t/,' '). + gsub(/\342\200\231/u,"'"). #if dob =~/’/ #Avoid #‘ ’ #“ ” + gsub(/�/u,' '). #watch, replace with char code + gsub(/·/u,'*'). + gsub(/\\copy(?:right)?\b/,'©'). + gsub(/\\trademark\b|\\tm\b/,'®') dob.obj=dob.obj + "\n" - unless dob.is =~/^code/ + unless dob.is ==:code case dob.obj when /\^~/ #% Note must do this first (earlier loop) and then enter gathered data into ~^\d+ sub_dob=dob.obj.dup - @endnote_array << sub_dob.gsub!(/\n/,'').gsub!(/\^~\s+(.+)\s*/,%{#{Mx[:en_a_o]}#{endnote_no} \\1 #{Mx[:en_a_c]}}).strip + @endnote_array << sub_dob.gsub(/\n/,'').gsub(/\^~\s+(.+)\s*/,%{#{Mx[:en_a_o]}#{endnote_no} \\1 #{Mx[:en_a_c]}}).strip endnote_no+=1 dob=nil if dob.obj =~/\^~ .+/ #watch, removes 'binary' endnote now in endnote array for later insertion end diff --git a/lib/sisu/v3/dal_doc_objects.rb b/lib/sisu/v3/dal_doc_objects.rb index 4e8b5c0f..e413993a 100644 --- a/lib/sisu/v3/dal_doc_objects.rb +++ b/lib/sisu/v3/dal_doc_objects.rb @@ -56,37 +56,37 @@ ** Description: document abstraction =end -module SiSU_document_structure +module SiSU_DAL_DocumentStructure class Extract def extract(h,o) obj=h ? h : o end end - class Object_metadata + class ObjectMetadata attr_accessor :is,:of,:tags,:obj,:digest def initialize @tags={} @is=@tmp=@digest=nil - @of='meta' + @of=:meta end def metadata(tags) of= @of #String, classification - group - is= 'meta' #String, classification - specific type + is= :meta #String, classification - specific type tags= tags || ((defined? o.tags) ? o.tags : {}) #String, metadata type/tag obj= nil @of,@is,@tags,@obj=of,is,tags,obj self end end - class Object_meta + class ObjectMeta attr_accessor :obj,:is,:of,:tag,:digest,:tmp def initialize @is=@obj=@tag=@digest=@digest=@tmp=nil - @of='meta' + @of=:meta end def metadata(h,o=nil) of= @of #String, classification - group - is= 'meta' #String, classification - specific type + is= :meta #String, classification - specific type tag= h[:tag] || ((defined? o.tag) ? o.tag : nil) #String, metadata type/tag obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use @@ -95,10 +95,10 @@ module SiSU_document_structure self end end - class Object_heading + class ObjectHeading attr_accessor :obj,:is,:tags,:of,:lv,:ln,:toc_,:name,:idx,:ocn,:odv,:osp,:node,:parent,:ocn_,:note_,:autonum_,:digest,:tmp def initialize - @of='para' + @of=:para @is=@obj=@lv=@ln=@toc_=@name=@idx=@size=@ocn=@odv=@osp=@node=@parent=@ocn_=@note_=@autonum_=@digest=@tmp=nil @tags=[] end @@ -135,7 +135,7 @@ module SiSU_document_structure h[:lv]=heading_lv(h[:ln]) end of= @of #String, classification - group - is= 'heading' #String, classification - specific type + is= :heading #String, classification - specific type name= h[:name] || ((defined? o.name) ? o.name : nil) #String, named object? tags= h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content @@ -162,20 +162,20 @@ module SiSU_document_structure end def heading_insert(h,o=nil) heading(h,o=nil) - @is= 'heading_insert' #String, classification - specific type + @is= :heading_insert #String, classification - specific type self end end - class Object_para + class ObjectPara attr_accessor :obj,:is,:tags,:of,:name,:idx,:bullet_,:indent,:hang,:ocn,:odv,:osp,:parent,:note_,:image_,:ocn_,:digest,:tmp def initialize - @of='para' + @of=:para @is=@obj=@name=@idx=@bullet_=@indent=@hang=@size=@ocn=@odv=@osp=@parent=@note_=@image_=@ocn_=@digest=@tmp=nil @tags=[] end def paragraph(h,o=nil) of= @of #String, classification - group - is= 'para' #String, classification - specific type + is= :para #String, classification - specific type name= h[:name] || ((defined? o.name) ? o.name : nil) #String, named object? tags= h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content @@ -199,7 +199,7 @@ module SiSU_document_structure end def docinfo(h,o=nil) of= @of #String, classification - group - is= 'docinfo' #String, classification - specific type + is= :docinfo #String, classification - specific type name= h[:name] || ((defined? o.name) ? o.name : nil) #String, named object? tags= h[:tags] || ((defined? o.tags) ? o.tags : nil) #Array, associated object tags, names if any obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content @@ -222,16 +222,16 @@ module SiSU_document_structure self end end - class Object_block_txt + class ObjectBlockTxt attr_accessor :obj,:is,:of,:tags,:idx,:ocn,:odv,:osp,:parent,:note_,:number_,:ocn_,:digest,:tmp def initialize - @of='block' + @of=:block @is=@obj=@idx=@ocn=@odv=@osp=@parent=@note_=@number_=@ocn_=@digest=@tmp=nil @tags=[] end def code(h,o=nil) of= @of #String, classification - group #alt 'code' - is= 'code' #String, classification - specific type + is= :code #String, classification - specific type tags= h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content idx= h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? @@ -251,7 +251,7 @@ module SiSU_document_structure end def block(h,o=nil) of= @of #String, classification - group - is= 'block' #String, classification - specific type + is= :block #String, classification - specific type tags= h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content idx= h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? @@ -270,7 +270,7 @@ module SiSU_document_structure end def group(h,o=nil) of= @of #String, classification - group - is= 'group' #String, classification - specific type + is= :group #String, classification - specific type tags= h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content idx= h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? @@ -289,7 +289,7 @@ module SiSU_document_structure end def alt(h,o=nil) #see block of= @of #String, classification - group - is= 'alt' #String, classification - specific type + is= :alt #String, classification - specific type tags= h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content idx= h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? @@ -308,7 +308,7 @@ module SiSU_document_structure end def verse(h,o=nil) #part of poem decide how you deal with this of= @of #String, classification - group - is= 'verse' #String, classification - specific type + is= :verse #String, classification - specific type tags= h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content idx= h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? @@ -326,16 +326,16 @@ module SiSU_document_structure self end end - class Object_table + class ObjectTable attr_accessor :obj,:is,:of,:lv,:tags,:name,:idx,:indent,:hang,:size,:ocn,:number,:head_,:cols,:widths,:odv,:osp,:parent,:note_,:ocn_,:digest,:tmp def initialize - @of='block' + @of=:block @is=@obj=@lv=@name=@idx=@indent=@hang=@size=@ocn,@number,@head_,@cols,@widths=@odv=@osp=@parent=@note_=@ocn_=@digest=@tmp=nil @tags=[] end def table(h,o=nil) of= @of #String, classification - group - is= 'table' #String, classification - specific type + is= :table #String, classification - specific type tags= h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any cols= h[:cols] || ((defined? o.cols) ? o.cols : nil) widths= h[:widths] || ((defined? o.widths) ? o.widths : nil) @@ -356,16 +356,16 @@ module SiSU_document_structure self end end - class Object_image + class ObjectImage attr_accessor :obj,:is,:of,:lv,:idx,:size,:ocn,:parent,:note_,:ocn_,:digest,:tmp def initialize - @of='image' + @of=:image @is=@obj=@lv=@idx=@size=@ocn=@parent=@note_=@ocn_=@tmp=@digest=nil @tags=[] end def image(h,o=nil) #not yet used, and what of a paragraph containing several images, consider of= @of #String, classification - group - is= 'image' #String, classification - specific type + is= :image #String, classification - specific type tags= h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content size= h[:size] || ((defined? o.size) ? o.size : nil) @@ -384,15 +384,15 @@ module SiSU_document_structure self end end - class Object_structure + class ObjectStructure attr_accessor :obj,:tag,:node,:lv,:ln,:status,:is,:of,:tmp def initialize - @of='structure' + @of=:structure @is=@obj=@node=@lv=@ln=@status=@tmp=nil end def xml_dom(h,o=nil) of= @of #String, classification - group - is= 'xml_dom' #String, classification - specific type + is= :xml_dom #String, classification - specific type obj= h[:obj] || ((defined? o.obj) ? o.obj : '') #String, text content lv= h[:lv] || ((defined? o.lv) ? o.lv : nil) #Alpha-numeric, document structure as used in markup, A-C then 1-6 ln= h[:ln] || ((defined? o.ln) ? o.ln : nil) #Integer, document structure level, for convenience in processing 1-9 @@ -403,30 +403,30 @@ module SiSU_document_structure self end end - class Object_comment + class ObjectComment attr_accessor :obj,:is,:of,:tmp def initialize - @of='comment' + @of=:comment @is=@obj=@tmp=nil end def comment(h,o=nil) of= @of #String, classification - group - is= 'comment' #String, classification - specific type + is= :comment #String, classification - specific type obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use @of,@is,@obj,@tmp=of,is,obj,tmp self end end - class Object_layout + class ObjectLayout attr_accessor :obj,:is,:of,:tmp def initialize - @of='layout' + @of=:layout @is=@obj=@tmp=nil end def break(h,o=nil) #decide how to deal with, perhaps no obj? of= @of #String, classification - group - is= 'break' #String, classification - specific type + is= :break #String, classification - specific type obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use @of,@is,@obj,@tmp=of,is,obj,tmp @@ -434,7 +434,7 @@ module SiSU_document_structure end def insert(h,o=nil) #decide how to deal with, could mimic paragraph? of= @of #String, classification - group - is= 'insert' #String, classification - specific type + is= :insert #String, classification - specific type obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use @of,@is,@obj,@tmp=of,is,obj,tmp diff --git a/lib/sisu/v3/dal_doc_str.rb b/lib/sisu/v3/dal_doc_str.rb index 7bc36e11..b4a98edd 100644 --- a/lib/sisu/v3/dal_doc_str.rb +++ b/lib/sisu/v3/dal_doc_str.rb @@ -56,7 +56,7 @@ ** Description: document abstraction =end -module SiSU_document_structure_extract +module SiSU_DAL_DocumentStructureExtract class Instantiate < SiSU_Param::Parameters::Instructions @@flag={} #Beware!! def initialize @@ -69,9 +69,9 @@ module SiSU_document_structure_extract @@flag={} #Beware!! def initialize(md,data) @md,@data=md,data - Instantiate.new - @pb=SiSU_document_structure::Object_layout.new.break(Hx[:br_page]) - @pbn=SiSU_document_structure::Object_layout.new.break(Hx[:br_page_new]) + SiSU_DAL_DocumentStructureExtract::Instantiate.new + @pb=SiSU_DAL_DocumentStructure::ObjectLayout.new.break(Hx[:br_page]) + @pbn=SiSU_DAL_DocumentStructure::ObjectLayout.new.break(Hx[:br_page_new]) end def ln_get(lv) ln=case lv @@ -131,11 +131,11 @@ module SiSU_document_structure_extract if str.nil? else if str =~/(?:^|[ ])\*~([a-z0-9._-]+)(?=[ #{Mx[:br_nl]}]|$)/ - str.gsub!(/(^|[ ])\*~([a-z0-9._-]+)(?=[ #{Mx[:br_nl]}]|$)/i, - "\\1#{Mx[:tag_o]}\\2#{Mx[:tag_c]}") - str.gsub!(/ [ ]+/i,' ') + 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 - str.gsub!(/[ ]?#{Mx[:tag_o]}\S+?#{Mx[:tag_c]}[ ]?/,' ') #may be issues with spaces would leave one, but "code" blocks? + 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 end @@ -148,7 +148,7 @@ module SiSU_document_structure_extract @@counter,@verse_count=0,0 @metadata={} @data.each do |t_o| - t_o.gsub!(/(?:\n\s*\n)+/m,"\n") unless @@flag['code'] + t_o=t_o.gsub(/(?:\n\s*\n)+/m,"\n") unless @@flag['code'] if t_o !~/^(?:code|poem|alt|group|block)\{|^\}(?:code|poem|alt|group|block)|^(?:table\{|\{table)[ ~]/ \ and not @@flag['code'] \ and not @@flag['poem'] \ @@ -158,7 +158,7 @@ module SiSU_document_structure_extract and not @@flag['table'] unless t_o =~/^(?:@\S+?:|%+)\s/ # extract book index for paragraph if any idx=if t_o=~/^=\{(.+)\}\s*$\Z/m; m=$1 - t_o.gsub!(/\n=\{.+\}\s*$\Z/m,'') + t_o=t_o.gsub(/\n=\{.+\}\s*$\Z/m,'') m else nil end @@ -173,7 +173,7 @@ module SiSU_document_structure_extract when /^%+\s/ #comment t_o=if t_o=~/^%+\s+(.+)/ h={obj: $1} - SiSU_document_structure::Object_comment.new.comment(h) + SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h) else nil end when /^:?([A-C1-6])\~/ #heading / lv @@ -184,19 +184,19 @@ module SiSU_document_structure_extract note=endnote_test?(obj) obj,tags=extract_tags(obj) h={ lv: lv, ln: ln, obj: obj, idx: idx, tags: tags } - SiSU_document_structure::Object_heading.new.heading(h) + SiSU_DAL_DocumentStructure::ObjectHeading.new.heading(h) elsif t_o=~/^:?[A-C1-6]\~(\S+?)-\s+(.+)/m name,obj=$1,$2 note=endnote_test?(obj) obj,tags=extract_tags(obj) h={ lv: lv, name: name, obj: obj, idx: idx, autonum_: false, tags: tags} - SiSU_document_structure::Object_heading.new.heading(h) + SiSU_DAL_DocumentStructure::ObjectHeading.new.heading(h) elsif t_o=~/^:?[A-C1-6]\~(\S+)\s+(.+)/m name,obj=$1,$2 note=endnote_test?(obj) obj,tags=extract_tags(obj,name) h={ lv: lv, name: name, obj: obj, idx: idx, tags: tags } - SiSU_document_structure::Object_heading.new.heading(h) + SiSU_DAL_DocumentStructure::ObjectHeading.new.heading(h) else nil end when /^_(?:[1-9]!?|[1-9]?\*)\s+/ #indented and/or bullet paragraph @@ -213,7 +213,7 @@ module SiSU_document_structure_extract obj,tags=extract_tags(obj) unless obj=~/\A\s*\Z/m h={ bullet_: bullet, hang: hang, indent: indent, obj: obj, idx: idx, note_: note, image_: image, tags: tags } - SiSU_document_structure::Object_para.new.paragraph(h) + SiSU_DAL_DocumentStructure::ObjectPara.new.paragraph(h) end else nil end @@ -230,23 +230,23 @@ module SiSU_document_structure_extract obj,tags=extract_tags(obj) unless obj=~/\A\s*\Z/m h={ hang: hang, indent: indent, obj: obj, idx: idx, note_: note, image_: image, tags: tags } - SiSU_document_structure::Object_para.new.paragraph(h) + SiSU_DAL_DocumentStructure::ObjectPara.new.paragraph(h) end else nil end when /^[<\[](?:br)?:(?:pa?r|o(?:bj|---)?)[>\]]\s*$/ #[br:par] #[br:obj] - SiSU_document_structure::Object_layout.new.break(Hx[:br_obj]) + SiSU_DAL_DocumentStructure::ObjectLayout.new.break(Hx[:br_obj]) when /^(?:[<\[](?:br)?:pg[>\]]|<?:pb>?)\s*$/ #[br:pg] - SiSU_document_structure::Object_layout.new.break(Hx[:br_page]) + SiSU_DAL_DocumentStructure::ObjectLayout.new.break(Hx[:br_page]) when /^[<\[](?:br)?:pg?n[>\]]\s*$/ #[br:pgn] - SiSU_document_structure::Object_layout.new.break(Hx[:br_page_new]) + SiSU_DAL_DocumentStructure::ObjectLayout.new.break(Hx[:br_page_new]) else #paragraph image=image_test(t_o) note=endnote_test?(t_o) obj,tags=extract_tags(t_o) unless obj=~/\A\s*\Z/m h={ bullet_: false, indent: 0, hang: 0, obj: obj, idx: idx, note_: note, image_: image, tags: tags } - SiSU_document_structure::Object_para.new.paragraph(h) + SiSU_DAL_DocumentStructure::ObjectPara.new.paragraph(h) end end elsif not @@flag['code'] @@ -255,30 +255,30 @@ module SiSU_document_structure_extract @@counter=1 @codeblock_numbered=(t_o =~/^code\{#/) ? true : false h={ obj: 'code block start' } #introduce a counter - t_o=SiSU_document_structure::Object_comment.new.comment(h) #t_o=SiSU_document_structure::Object_layout.new.insert(h) + t_o=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h) #t_o=SiSU_DAL_DocumentStructure::ObjectLayout.new.insert(h) elsif t_o =~/^poem\{/ @@flag['poem']=true h={ obj: 'poem start' } #introduce a counter - t_o=SiSU_document_structure::Object_comment.new.comment(h) #t_o=SiSU_document_structure::Object_layout.new.insert(h) + t_o=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h) #t_o=SiSU_DAL_DocumentStructure::ObjectLayout.new.insert(h) tuned_file << t_o elsif t_o =~/^group\{/ @@flag['group']=true h={ obj: 'group text start' } #introduce a counter - t_o=SiSU_document_structure::Object_comment.new.comment(h) #t_o=SiSU_document_structure::Object_layout.new.insert(h) + t_o=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h) #t_o=SiSU_DAL_DocumentStructure::ObjectLayout.new.insert(h) tuned_file << t_o elsif t_o =~/^block\{/ @@flag['block']=true h={ obj: 'block text start' } #introduce a counter - t_o=SiSU_document_structure::Object_comment.new.comment(h) #t_o=SiSU_document_structure::Object_layout.new.insert(h) + t_o=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h) #t_o=SiSU_DAL_DocumentStructure::ObjectLayout.new.insert(h) tuned_file << t_o elsif t_o =~/^alt\{/ @@flag['alt']=true h={ obj: 'alt text start' } #introduce a counter - t_o=SiSU_document_structure::Object_comment.new.comment(h) #t_o=SiSU_document_structure::Object_layout.new.insert(h) + t_o=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h) #t_o=SiSU_DAL_DocumentStructure::ObjectLayout.new.insert(h) tuned_file << t_o elsif t_o =~/^(?:table\{|\{table)[ ~]/ h={ obj: 'table start' } #introduce a counter - ins=SiSU_document_structure::Object_comment.new.comment(h) #ins=SiSU_document_structure::Object_layout.new.insert(h) + ins=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h) #ins=SiSU_DAL_DocumentStructure::ObjectLayout.new.insert(h) tuned_file << ins if t_o=~/^table\{(?:~h)?\s+/ @@flag['table']=true @@ -304,7 +304,7 @@ module SiSU_document_structure_extract cols=nil rws.each do |r| cols=(cols ? cols : (r.scan('|').length) +1) - r.gsub!(/\s*\|\s*/m,"#{Mx[:tc_p]}") #r.gsub!(/\|/m,"#{Mx[:tc_p]}") + r=r.gsub(/\s*\|\s*/m,"#{Mx[:tc_p]}") #r.gsub!(/\|/m,"#{Mx[:tc_p]}") rows += r + Mx[:tc_c] end col=[] @@ -318,10 +318,10 @@ module SiSU_document_structure_extract cols.times { col << width } end h={ head_: hd, cols: cols, widths: col, obj: rows, idx: idx, tags: tags } - t_o=SiSU_document_structure::Object_table.new.table(h) unless h.nil? + t_o=SiSU_DAL_DocumentStructure::ObjectTable.new.table(h) unless h.nil? tuned_file << t_o h={ obj: 'table end' } #introduce a counter - t_o=SiSU_document_structure::Object_comment.new.comment(h) + t_o=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h) t_o elsif t_o=~/^\{table(?:~h)?\s+/ m1,m2,hd=nil,nil,nil @@ -337,14 +337,14 @@ module SiSU_document_structure_extract rws=tbl.split(/\n/) rows='' rws.each do |r| - r.gsub!(/\s*\|\s*/m,"#{Mx[:tc_p]}") #r.gsub!(/\|/m,"#{Mx[:tc_p]}") + r=r.gsub(/\s*\|\s*/m,"#{Mx[:tc_p]}") #r.gsub!(/\|/m,"#{Mx[:tc_p]}") rows += r + Mx[:tc_c] end h={ head_: hd, cols: col.length, widths: col, obj: rows, idx: idx, tags: tags } - t_o=SiSU_document_structure::Object_table.new.table(h) unless h.nil? + t_o=SiSU_DAL_DocumentStructure::ObjectTable.new.table(h) unless h.nil? tuned_file << t_o h={ obj: 'table end' } #introduce a counter - t_o=SiSU_document_structure::Object_comment.new.comment(h) + t_o=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h) t_o end end @@ -356,18 +356,18 @@ module SiSU_document_structure_extract @@flag['table']=false headings,columns,widths,idx=@h[:head_],@h[:cols],@h[:widths],@h[:idx] @h={ head_: headings, cols: columns, widths: widths, idx: idx, obj: @rows } - t_o=SiSU_document_structure::Object_table.new.table(@h) + t_o=SiSU_DAL_DocumentStructure::ObjectTable.new.table(@h) tuned_file << t_o @h,@rows=nil,'' t_o h={ obj: 'table end' } #introduce a counter - t_o=SiSU_document_structure::Object_comment.new.comment(h) #t_o=SiSU_document_structure::Object_layout.new.insert(h) + t_o=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h) #t_o=SiSU_DAL_DocumentStructure::ObjectLayout.new.insert(h) t_o else if t_o !~/^table\{/ \ and not t_o.nil? - t_o.gsub!(/^\n+/m,'') #check added for ruby 1.9.2 not needed in 1.8 series (tested in v2) - t_o.gsub!(/\n+/m,"#{Mx[:tc_p]}") + t_o=t_o.gsub(/^\n+/m,''). #check added for ruby 1.9.2 not needed in 1.8 series (tested in v2) + gsub(/\n+/m,"#{Mx[:tc_p]}") @rows += t_o + Mx[:tc_c] end t_o=nil @@ -379,11 +379,11 @@ module SiSU_document_structure_extract obj=@tuned_code.join("\n") tags=[] h={ obj: obj, tags: tags, number_: @codeblock_numbered } - t_o=SiSU_document_structure::Object_block_txt.new.code(h) + t_o=SiSU_DAL_DocumentStructure::ObjectBlockTxt.new.code(h) @tuned_code=[] tuned_file << t_o h={ obj: 'code block end' } #introduce a counter - t_o=SiSU_document_structure::Object_comment.new.comment(h) #t_o=SiSU_document_structure::Object_layout.new.insert(h) + t_o=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h) #t_o=SiSU_DAL_DocumentStructure::ObjectLayout.new.insert(h) end if @@flag['code'] \ and t_o.class==String \ @@ -392,7 +392,7 @@ module SiSU_document_structure_extract @line_mode=sub_array.scan(/.+/) @line_mode=[] sub_array.scan(/.+/) {|w| @line_mode << w if w =~/[\S]+/} - t_o=SiSU_document_structure_extract::Build.new(@md,@line_mode).build_lines('code').join + t_o=SiSU_DAL_DocumentStructureExtract::Build.new(@md,@line_mode).build_lines('code').join @tuned_code << t_o t_o=nil end @@ -404,37 +404,37 @@ module SiSU_document_structure_extract and t_o =~/^\}poem/ @@flag['poem']=false h={ obj: 'poem end' } #introduce a counter - t_o=SiSU_document_structure::Object_comment.new.comment(h) #t_o=SiSU_document_structure::Object_layout.new.insert(h) + t_o=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h) #t_o=SiSU_DAL_DocumentStructure::ObjectLayout.new.insert(h) elsif ( @@flag['group'] \ and t_o =~/^\}group/ ) @@flag['group']=false obj,tags=extract_tags(@tuned_block.join("\n")) h={ obj: obj, tags: tags } @tuned_block=[] - t_o=SiSU_document_structure::Object_block_txt.new.group(h) + t_o=SiSU_DAL_DocumentStructure::ObjectBlockTxt.new.group(h) tuned_file << t_o h={ obj: 'group text end' } #introduce a counter - t_o=SiSU_document_structure::Object_comment.new.comment(h) #t_o=SiSU_document_structure::Object_layout.new.insert(h) + t_o=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h) #t_o=SiSU_DAL_DocumentStructure::ObjectLayout.new.insert(h) elsif ( @@flag['block'] \ and t_o =~/^\}block/ ) @@flag['block']=false obj,tags=extract_tags(@tuned_block.join("\n")) h={ obj: obj, tags: tags } @tuned_block=[] - t_o=SiSU_document_structure::Object_block_txt.new.block(h) + t_o=SiSU_DAL_DocumentStructure::ObjectBlockTxt.new.block(h) tuned_file << t_o h={ obj: 'block text end' } #introduce a counter - t_o=SiSU_document_structure::Object_comment.new.comment(h) #t_o=SiSU_document_structure::Object_layout.new.insert(h) + t_o=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h) #t_o=SiSU_DAL_DocumentStructure::ObjectLayout.new.insert(h) elsif ( @@flag['alt'] \ and t_o =~/^\}alt/ ) @@flag['alt']=false obj,tags=extract_tags(@tuned_block.join("\n")) h={ obj: obj, tags: tags } - t_o=SiSU_document_structure::Object_block_txt.new.alt(h) + t_o=SiSU_DAL_DocumentStructure::ObjectBlockTxt.new.alt(h) @tuned_block=[] tuned_file << t_o h={ obj: 'alt text end' } #introduce a counter - t_o=SiSU_document_structure::Object_comment.new.comment(h) #t_o=SiSU_document_structure::Object_layout.new.insert(h) + t_o=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h) #t_o=SiSU_DAL_DocumentStructure::ObjectLayout.new.insert(h) end if @@flag['poem'] \ or @@flag['group'] \ @@ -444,13 +444,13 @@ module SiSU_document_structure_extract sub_array=t_o.dup @line_mode=sub_array.scan(/.+/) type=if @@flag['poem']; 'poem' - t_o=SiSU_document_structure_extract::Build.new(@md,@line_mode).build_lines(type).join + t_o=SiSU_DAL_DocumentStructureExtract::Build.new(@md,@line_mode).build_lines(type).join poem=t_o.split(/\n\n/) poem.each do |v| - v.gsub!(/\n/m,"#{Mx[:br_nl]}\n") + v=v.gsub(/\n/m,"#{Mx[:br_nl]}\n") obj,tags=extract_tags(v) h={ obj: obj, tags: tags } - t_o=SiSU_document_structure::Object_block_txt.new.verse(h) + t_o=SiSU_DAL_DocumentStructure::ObjectBlockTxt.new.verse(h) tuned_file << t_o end else 'group' @@ -463,17 +463,17 @@ module SiSU_document_structure_extract or @@flag['group'] \ or @@flag['alt'] if t_o.class==String - t_o.gsub!(/\n/m,"#{Mx[:br_nl]}") - t_o.gsub!(/[ ][ ]/m,"#{Mx[:nbsp]*2}") - t_o.gsub!(/#{Mx[:nbsp]}\s/,"#{Mx[:nbsp]*2}") + t_o=t_o.gsub(/\n/m,"#{Mx[:br_nl]}"). + gsub(/[ ][ ]/m,"#{Mx[:nbsp]*2}"). + gsub(/#{Mx[:nbsp]}\s/,"#{Mx[:nbsp]*2}") t_o=t_o + Mx[:br_nl] if t_o =~/\S+/ - elsif t_o.is=='group' \ - or t_o.is=='block' \ - or t_o.is=='alt' \ - or t_o.is=='verse' - t_o.obj.gsub!(/\n/m,"#{Mx[:br_nl]}") - t_o.obj.gsub!(/[ ][ ]/m,"#{Mx[:nbsp]*2}") - t_o.obj.gsub!(/#{Mx[:nbsp]}\s/,"#{Mx[:nbsp]*2}") + elsif t_o.is==:group \ + || t_o.is==:block \ + || t_o.is==:alt \ + || t_o.is==:verse + t_o.obj=t_o.obj.gsub(/\n/m,"#{Mx[:br_nl]}"). + gsub(/[ ][ ]/m,"#{Mx[:nbsp]*2}"). + gsub(/#{Mx[:nbsp]}\s/,"#{Mx[:nbsp]*2}") end @tuned_block << t_o if t_o =~/\S+/ else tuned_file << t_o @@ -484,32 +484,27 @@ module SiSU_document_structure_extract if @md.flag_endnotes tuned_file << @pb h={ ln: 2, obj: 'Endnotes', autonum_: false } - tuned_file << SiSU_document_structure::Object_heading.new.heading_insert(h) + tuned_file << SiSU_DAL_DocumentStructure::ObjectHeading.new.heading_insert(h) h={ ln: 4, obj: 'Endnotes', name: 'endnotes', autonum_: false } - tuned_file << SiSU_document_structure::Object_heading.new.heading_insert(h) + tuned_file << SiSU_DAL_DocumentStructure::ObjectHeading.new.heading_insert(h) h={ obj: 'Endnotes' } end if @md.book_idx tuned_file << @pb h={ ln: 2, obj: 'Index', autonum_: false } - tuned_file << SiSU_document_structure::Object_heading.new.heading_insert(h) + tuned_file << SiSU_DAL_DocumentStructure::ObjectHeading.new.heading_insert(h) h={ ln: 4, obj: 'Index', name: 'book_index', autonum_: false } - tuned_file << SiSU_document_structure::Object_heading.new.heading_insert(h) + tuned_file << SiSU_DAL_DocumentStructure::ObjectHeading.new.heading_insert(h) h={ obj: 'Index' } end tuned_file << @pb h={ ln: 2, obj: 'Metadata', autonum_: false, ocn_: false } - tuned_file << SiSU_document_structure::Object_heading.new.heading_insert(h) + tuned_file << SiSU_DAL_DocumentStructure::ObjectHeading.new.heading_insert(h) h={ ln: 4, obj: 'SiSU Metadata, document information', name: 'metadata', autonum_: false, ocn_: false } - tuned_file << SiSU_document_structure::Object_heading.new.heading_insert(h) - tuned_file << @pb - h={ ln: 2, obj: 'Manifest', autonum_: false, ocn_: false } - tuned_file << SiSU_document_structure::Object_heading.new.heading_insert(h) - h={ ln: 4, obj: 'SiSU Manifest, alternative outputs etc.', name: 'sisu_manifest', autonum_: false, ocn_: false } - tuned_file << SiSU_document_structure::Object_heading.new.heading_insert(h) + tuned_file << SiSU_DAL_DocumentStructure::ObjectHeading.new.heading_insert(h) tuned_file h={ obj: 'eof' } - meta=SiSU_document_structure::Object_metadata.new.metadata(@metadata) + meta=SiSU_DAL_DocumentStructure::ObjectMetadata.new.metadata(@metadata) [tuned_file,meta] end def table_rows_and_columns_array(table_str) @@ -522,33 +517,33 @@ module SiSU_document_structure_extract end def meta_heading(h) h={ lv: h[:lv], ln: h[:ln], name: h[:name], obj: h[:obj], ocn: '0' } - SiSU_document_structure::Object_heading.new.heading(h) + SiSU_DAL_DocumentStructure::ObjectHeading.new.heading(h) end def meta_para(str) h={ obj: str, ocn_: false } - SiSU_document_structure::Object_para.new.paragraph(h) + SiSU_DAL_DocumentStructure::ObjectPara.new.paragraph(h) end def build_lines(type='') - data=@data - data.each do |line| - if line =~/\S/ \ + lines,lines_new=@data,[] + lines.each do |line| + line=if line =~/\S/ \ and line !~/^code\{|^\}code/ \ and line.class != Hash - line.gsub!(/\s\s/,"#{Mx[:nbsp]*2}") - line.gsub!(/#{Mx[:nbsp]}\s/,"#{Mx[:nbsp]*2}") - line.gsub!(/^/,"#{Mx[:gr_o]}codeline#{Mx[:gr_c]}") if type=='code' # REMOVE try sort for texpdf special case - if line =~/(?:https?|file|ftp):\/\/\S+$/ - line.gsub!(/\s*$/," #{Mx[:br_nl]}") - else line.gsub!(/\s*$/,"#{Mx[:br_nl]}") #unless type=='code' - end - if @@flag['code']; @@counter+=1 - else + @@counter+=1 if @@flag['code'] + line=line.gsub(/\s\s/,"#{Mx[:nbsp]*2}"). + gsub(/#{Mx[:nbsp]}\s/,"#{Mx[:nbsp]*2}") + line=line.gsub(/^/,"#{Mx[:gr_o]}codeline#{Mx[:gr_c]}") if type=='code' # REMOVE try sort for texpdf special case + line=if line =~/(?:https?|file|ftp):\/\/\S+$/ + line.gsub(/\s*$/," #{Mx[:br_nl]}") + else line.gsub(/\s*$/,"#{Mx[:br_nl]}") #unless type=='code' end elsif line =~/^\s*$/ - line.gsub!(/\s*$/,"#{Mx[:br_nl]}") + line.gsub(/\s*$/,"#{Mx[:br_nl]}") + else line end + lines_new << line end - data + lines_new end end class Structure # this must happen early @@ -561,29 +556,29 @@ module SiSU_document_structure_extract @dob end def structure_markup #build structure where structure provided only in meta header - @dob=if @dob.is =~/para/ \ - and ((@dob.hang !~/[1-9]/ and @dob.indent !~/[1-9]/) \ - or (@dob.hang != @dob.indent)) \ + @dob=if @dob.is ==:para \ + && (((@dob.hang !~/[1-9]/) && (@dob.indent !~/[1-9]/)) \ + || (@dob.hang != @dob.indent)) \ and not @dob.bullet_ @dob=case @dob.obj when /^#{@md.lv1}/ h={ lv: 'A', ln: 1 } - SiSU_document_structure::Object_heading.new.heading(h,@dob) + SiSU_DAL_DocumentStructure::ObjectHeading.new.heading(h,@dob) when /^#{@md.lv2}/ h={ lv: 'B', ln: 2 } - SiSU_document_structure::Object_heading.new.heading(h,@dob) + SiSU_DAL_DocumentStructure::ObjectHeading.new.heading(h,@dob) when /^#{@md.lv3}/ h={ lv: 'C', ln: 3 } - SiSU_document_structure::Object_heading.new.heading(h,@dob) + SiSU_DAL_DocumentStructure::ObjectHeading.new.heading(h,@dob) when /^#{@md.lv4}/ h={ lv: '1', ln: 4 } - SiSU_document_structure::Object_heading.new.heading(h,@dob) + SiSU_DAL_DocumentStructure::ObjectHeading.new.heading(h,@dob) when /^#{@md.lv5}/ h={ lv: '2', ln: 5 } - SiSU_document_structure::Object_heading.new.heading(h,@dob) + SiSU_DAL_DocumentStructure::ObjectHeading.new.heading(h,@dob) when /^#{@md.lv6}/ h={ lv: '3', ln: 6 } - SiSU_document_structure::Object_heading.new.heading(h,@dob) + SiSU_DAL_DocumentStructure::ObjectHeading.new.heading(h,@dob) else @dob end else @dob @@ -592,26 +587,26 @@ module SiSU_document_structure_extract end def structure_markup_normalize #needs a bit of thinking dob=if @md.markup_version.determined < 0.38 #%convert internal representation, consider making 0.38 structure default ([A-C1-6] instead of [1-9]), requires downstream changes - @dob.gsub!(/^[456]~/,'!_') - @dob.gsub!(/^3~(\S+)/,"#{Mx[:lv_o]}6:\\1#{Mx[:lv_c]}") - @dob.gsub!(/^3~\s+/,"#{Mx[:lv_o]}6:#{Mx[:lv_c]}") - @dob.gsub!(/^2~(\S+)/,"#{Mx[:lv_o]}5:\\1#{Mx[:lv_c]}") - @dob.gsub!(/^2~\s+/,"#{Mx[:lv_o]}5:#{Mx[:lv_c]}") - @dob.gsub!(/^1~(\S+)/,"#{Mx[:lv_o]}4:\\1#{Mx[:lv_c]}") - @dob.gsub!(/^1~\s+/,"#{Mx[:lv_o]}4:#{Mx[:lv_c]}") - @dob.gsub!(/^:?C~(\S+)/,"#{Mx[:lv_o]}3:\\1#{Mx[:lv_c]}") - @dob.gsub!(/^:?C~\s+/,"#{Mx[:lv_o]}3:#{Mx[:lv_c]}") - @dob.gsub!(/^:?B~(\S+)/,"#{Mx[:lv_o]}2:\\1#{Mx[:lv_c]}") - @dob.gsub!(/^:?B~\s+/,"#{Mx[:lv_o]}2:#{Mx[:lv_c]}") - @dob.gsub!(/^:?A~(\S+)/,"#{Mx[:lv_o]}1:\\1#{Mx[:lv_c]}") - @dob.gsub!(/^:?A~\s+/,"#{Mx[:lv_o]}1:#{Mx[:lv_c]}") + @dob=@dob.gsub(/^[456]~/,'!_'). + gsub(/^3~(\S+)/,"#{Mx[:lv_o]}6:\\1#{Mx[:lv_c]}"). + gsub(/^3~\s+/,"#{Mx[:lv_o]}6:#{Mx[:lv_c]}"). + gsub(/^2~(\S+)/,"#{Mx[:lv_o]}5:\\1#{Mx[:lv_c]}"). + gsub(/^2~\s+/,"#{Mx[:lv_o]}5:#{Mx[:lv_c]}"). + gsub(/^1~(\S+)/,"#{Mx[:lv_o]}4:\\1#{Mx[:lv_c]}"). + gsub(/^1~\s+/,"#{Mx[:lv_o]}4:#{Mx[:lv_c]}"). + gsub(/^:?C~(\S+)/,"#{Mx[:lv_o]}3:\\1#{Mx[:lv_c]}"). + gsub(/^:?C~\s+/,"#{Mx[:lv_o]}3:#{Mx[:lv_c]}"). + gsub(/^:?B~(\S+)/,"#{Mx[:lv_o]}2:\\1#{Mx[:lv_c]}"). + gsub(/^:?B~\s+/,"#{Mx[:lv_o]}2:#{Mx[:lv_c]}"). + gsub(/^:?A~(\S+)/,"#{Mx[:lv_o]}1:\\1#{Mx[:lv_c]}"). + gsub(/^:?A~\s+/,"#{Mx[:lv_o]}1:#{Mx[:lv_c]}") @dob=if @dob =~/^@(?:level|markup):\s/ - @dob.gsub!(/3/,'6') - @dob.gsub!(/2/,'5') - @dob.gsub!(/1/,'4') - @dob.gsub!(/:?C/,'3') - @dob.gsub!(/:?B/,'2') - @dob.gsub!(/:?A/,'1') + @dob=@dob.gsub(/3/,'6'). + gsub(/2/,'5'). + gsub(/1/,'4'). + gsub(/:?C/,'3'). + gsub(/:?B/,'2'). + gsub(/:?A/,'1') @dob else @dob end @@ -620,19 +615,19 @@ module SiSU_document_structure_extract end def structure_marks t_o=if @md.markup_version.determined < 0.38 - @t_o.gsub!(/^1~(\S+)/,"#{Mx[:lv_o]}1:\\1#{Mx[:lv_c]}") - @t_o.gsub!(/^1~\s+/,"#{Mx[:lv_o]}1:#{Mx[:lv_c]}") - @t_o.gsub!(/^2~(\S+)/,"#{Mx[:lv_o]}2:\\1#{Mx[:lv_c]}") - @t_o.gsub!(/^2~\s+/,"#{Mx[:lv_o]}2:#{Mx[:lv_c]}") - @t_o.gsub!(/^3~(\S+)/,"#{Mx[:lv_o]}3:\\1#{Mx[:lv_c]}") - @t_o.gsub!(/^3~\s+/,"#{Mx[:lv_o]}3:#{Mx[:lv_c]}") - @t_o.gsub!(/^4~(\S+)/,"#{Mx[:lv_o]}4:\\1#{Mx[:lv_c]}") - @t_o.gsub!(/^4~\s+/,"#{Mx[:lv_o]}4:#{Mx[:lv_c]}") - @t_o.gsub!(/^5~(\S+)/,"#{Mx[:lv_o]}5:\\1#{Mx[:lv_c]}") - @t_o.gsub!(/^5~\s+/,"#{Mx[:lv_o]}5:#{Mx[:lv_c]}") - @t_o.gsub!(/^6~(\S+)/,"#{Mx[:lv_o]}6:\\1#{Mx[:lv_c]}") - @t_o.gsub!(/^6~\s+/,"#{Mx[:lv_o]}6:#{Mx[:lv_c]}") - @t_o.gsub!(/^[789]~/,'!_') + @t_o=@t_o.gsub(/^1~(\S+)/,"#{Mx[:lv_o]}1:\\1#{Mx[:lv_c]}"). + gsub(/^1~\s+/,"#{Mx[:lv_o]}1:#{Mx[:lv_c]}"). + gsub(/^2~(\S+)/,"#{Mx[:lv_o]}2:\\1#{Mx[:lv_c]}"). + gsub(/^2~\s+/,"#{Mx[:lv_o]}2:#{Mx[:lv_c]}"). + gsub(/^3~(\S+)/,"#{Mx[:lv_o]}3:\\1#{Mx[:lv_c]}"). + gsub(/^3~\s+/,"#{Mx[:lv_o]}3:#{Mx[:lv_c]}"). + gsub(/^4~(\S+)/,"#{Mx[:lv_o]}4:\\1#{Mx[:lv_c]}"). + gsub(/^4~\s+/,"#{Mx[:lv_o]}4:#{Mx[:lv_c]}"). + gsub(/^5~(\S+)/,"#{Mx[:lv_o]}5:\\1#{Mx[:lv_c]}"). + gsub(/^5~\s+/,"#{Mx[:lv_o]}5:#{Mx[:lv_c]}"). + gsub(/^6~(\S+)/,"#{Mx[:lv_o]}6:\\1#{Mx[:lv_c]}"). + gsub(/^6~\s+/,"#{Mx[:lv_o]}6:#{Mx[:lv_c]}"). + gsub(/^[789]~/,'!_') @t_o else @t_o end @@ -651,12 +646,14 @@ module SiSU_document_structure_extract parent=node1=node2=node3=node4=node5=node6=nil data.each do |dob| h={} - if (dob.obj !~ regex_exclude_ocn_and_node || dob.is =='code') \ - and dob.of !~/(?:comment|layout|meta)/ \ - and dob.obj !~/#{Mx[:pa_non_object_no_heading]}|#{Mx[:pa_non_object_dummy_heading]}/ \ - and dob.ocn_ + if (dob.obj !~ regex_exclude_ocn_and_node || dob.is ==:code) \ + && (dob.of !=:comment \ + && dob.of !=:layout \ + && dob.of !=:meta) \ + && dob.obj !~/#{Mx[:pa_non_object_no_heading]}|#{Mx[:pa_non_object_dummy_heading]}/ \ + && dob.ocn_ #dob.ln now is determined, and set earlier, check how best to remove this --> - if dob.is=='heading' + if dob.is==:heading ln=case dob.lv when 'A'; 1 when 'B'; 2 @@ -672,7 +669,7 @@ module SiSU_document_structure_extract if not dob.obj =~/<:#>|~#|-#/ \ or not dob.toc_ # fix this no longer in dob.obj ocn+=1 - if dob.is=='heading' \ + if dob.is==:heading \ and (ln.to_s =~/^[1-9]/ \ or ln.to_s =~@md.lv1 \ or ln.to_s =~@md.lv2 \ @@ -708,56 +705,67 @@ module SiSU_document_structure_extract end else ocno+=1 - if dob.is=='table' + if dob.is==:table ocnt+=1 ocn_sp,parent="t#{ocnt}",node - elsif dob.is=='code' + elsif dob.is==:code ocnc+=1 ocn_sp,parent="c#{ocnc}",node - elsif dob.is=~/^(?:group|block|alt|verse)/ + elsif dob.is==:group \ + || dob.is==:block \ + || dob.is==:alt \ + || dob.is==:verse ocng+=1 #group, poem ocn_sp,parent="g#{ocng}",node - elsif dob.is=~/image|#{Mx[:lnk_o]}\S+?\.(?:png|jpg|gif)\s+/m + elsif dob.is==:image #check ocni+=1 ocn_sp,parent="i#{ocni}",node else ocnp+=1 #paragraph ocn_sp,parent="p#{ocnp}",node end end - if dob.is=='heading' + if dob.is==:heading dob.ln,dob.node,dob.ocn,dob.odv,dob.osp,dob.parent=ln,node,ocn,ocn_dv,ocn_sp,parent else - unless dob.of=~/meta|comment|layout/ + if dob.of !=:meta \ + && dob.of !=:comment \ + && dob.of !=:layout dob.ocn,dob.odv,dob.osp,dob.parent=ocn,ocn_dv,ocn_sp,parent end end else ocnu+=1 - dob.obj.gsub!(/#{Mx[:fa_o]}~##{Mx[:fa_c]}/,'') if dob.obj + dob.obj=dob.obj.gsub(/#{Mx[:fa_o]}~##{Mx[:fa_c]}/,'') if dob.obj ocn_dv,ocn_sp="u#{ocnu}","u#{ocnu}" dob.ocn,dob.odv,dob.osp=ocn,ocn_dv,ocn_sp end h elsif dob.obj=~/#{Mx[:pa_non_object_no_heading]}/ - dob.obj.gsub!(/#{Mx[:pa_non_object_no_heading]}/,'') - if dob.is=='para' + dob.obj=dob.obj.gsub(/#{Mx[:pa_non_object_no_heading]}/,'') + if dob.is==:para h={ obj: dob.obj, ocn_: false, ocn: nil } - dob=SiSU_document_structure::Object_para.new.paragraph(h,dob) - elsif dob.is=='heading' + dob=SiSU_DAL_DocumentStructure::ObjectPara.new.paragraph(h,dob) + elsif dob.is==:heading h={ obj: dob.obj, ocn_: false, ocn: nil, toc_: true } - dob=SiSU_document_structure::Object_heading.new.heading(h,dob) + dob=SiSU_DAL_DocumentStructure::ObjectHeading.new.heading(h,dob) end elsif dob.obj=~/#{Mx[:pa_non_object_dummy_heading]}/ - dob.obj.gsub!(/#{Mx[:pa_non_object_dummy_heading]}/,'') - if dob.is=='para' + dob.obj=dob.obj.gsub(/#{Mx[:pa_non_object_dummy_heading]}/,'') + if dob.is==:para h={ obj: dob.obj, ocn_: false, ocn: nil } - dob=SiSU_document_structure::Object_para.new.paragraph(h,dob) - elsif dob.is=='heading' + dob=SiSU_DAL_DocumentStructure::ObjectPara.new.paragraph(h,dob) + elsif dob.is==:heading h={ obj: dob.obj, ocn_: false, ocn: nil, toc_: false } - dob=SiSU_document_structure::Object_heading.new.heading(h,dob) + dob=SiSU_DAL_DocumentStructure::ObjectHeading.new.heading(h,dob) end else dob end - dob.obj.gsub!(/\n\n/,"\n") if dob.is =~/(?:code|verse|alt|group|block)/ #newlines taken out + if dob.is==:code \ + || dob.is==:verse \ + || dob.is==:alt \ + || dob.is==:group \ + || dob.is==:block + dob.obj=dob.obj.gsub(/\n\n/,"\n") #newlines taken out + end @o_array << dob end @o_array @@ -791,7 +799,8 @@ module SiSU_document_structure_extract puts "<#{@s[0]}>" end data.each_with_index do |o,i| - if o.is =~/^heading/ + if o.is ==:heading \ + || o.is ==:heading_insert case o.ln when 1 tuned_file << tag_close(o.ln,hs) @@ -847,8 +856,7 @@ module SiSU_document_structure_extract end puts_tag_close(0,hs) if @md.opt.cmd =~/V/ tuned_file << tag_close(0,hs) - tuned_file.flatten! - tuned_file + tuned_file=tuned_file.flatten end def tags(o) tag=if o[:status]=='open' @@ -867,7 +875,7 @@ module SiSU_document_structure_extract when '6'; 9 end h={ tag: tag, node: o[:node], lv: o[:lv], ln: ln, status: o[:status] } - SiSU_document_structure::Object_structure.new.xml_dom(h) #downstream code utilise else ignore like comments + SiSU_DAL_DocumentStructure::ObjectStructure.new.xml_dom(h) #downstream code utilise else ignore like comments end def tag_open(o,tag) t={ lv: tag[o.ln], node: o.node, status: 'open' } diff --git a/lib/sisu/v3/dal_endnotes.rb b/lib/sisu/v3/dal_endnotes.rb index 53b6e8d3..191260c4 100644 --- a/lib/sisu/v3/dal_endnotes.rb +++ b/lib/sisu/v3/dal_endnotes.rb @@ -56,7 +56,7 @@ ** Description: system environment, resource control and configuration details =end -module SiSU_endnotes +module SiSU_DAL_Endnotes class Endnotes def initialize(md,data,endnote_array=nil) @md,@data,@endnote_array=md,data,endnote_array @@ -69,17 +69,17 @@ module SiSU_endnotes data.each do |dob| # manually numbered endnotes <!e(\d)!> <!e_(\d)!> --> if @md.opt.mod.inspect =~/--no-asterisk|--no-annotate/ - dob.obj.gsub!(/#{Mx[:en_b_o]}\s.+?#{Mx[:en_b_c]}/,'') + dob.obj=dob.obj.gsub(/#{Mx[:en_b_o]}\s.+?#{Mx[:en_b_c]}/,'') end if @md.opt.mod.inspect =~/--no-dagger|--no-annotate/ - dob.obj.gsub!(/#{Mx[:en_b_o]}[+]\s.+?#{Mx[:en_b_c]}/,'') + dob.obj=dob.obj.gsub(/#{Mx[:en_b_o]}[+]\s.+?#{Mx[:en_b_c]}/,'') end - if defined? dob.obj \ - and defined? dob.is \ - and dob.is !~/^code/ + if (defined? dob.obj) \ + && (defined? dob.is) \ + && dob.is !=:code case dob.obj # auto-numbered endnotes <!e!> <!e_!> --> when /#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}[*+]\s+.+?#{Mx[:en_b_c]}/ - dob.obj.gsub!(/\s*(#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/,' \1') # required 2003w31 + dob.obj=dob.obj.gsub(/\s*(#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/,' \1') # required 2003w31 word_mode=dob.obj.scan(/\S+/m) word_mode=endnote_call_number(word_mode) dob.obj=word_mode.join(' ') diff --git a/lib/sisu/v3/dal_expand_insertions.rb b/lib/sisu/v3/dal_expand_insertions.rb index e48acd47..ef25fcdd 100644 --- a/lib/sisu/v3/dal_expand_insertions.rb +++ b/lib/sisu/v3/dal_expand_insertions.rb @@ -56,13 +56,13 @@ ** Description: system environment, resource control and configuration details =end -module SiSU_insertions +module SiSU_DAL_Insertions class Insertions def initialize(md,data) @md,@data=md,data end def output_filetypes_in_cmd(cmd_shortcut,lnk=nil) #make list of file types in shortcut command (as configured), e.g. when sisu -3 is used - cf_defaults=SiSU_Env::Info_processing_flag.new + cf_defaults=SiSU_Env::InfoProcessingFlag.new cmd_list=case cmd_shortcut.inspect when /0/; cf_defaults.cf_0 when /1/; cf_defaults.cf_1 @@ -141,7 +141,7 @@ module SiSU_insertions def xml_dom "#{@base_path}/xml/#{@linked_doc}.xml" end - def txt + def txt "#{@base_path}/txt/#{@linked_doc}.txt" end def digest @@ -241,7 +241,7 @@ module SiSU_insertions def xml_dom "#{@base_path}/scroll.#{@lng}.dom.xml" end - def txt + def txt "#{@base_path}/plain.#{@lng}.txt" end def digest @@ -270,17 +270,17 @@ module SiSU_insertions and not codeblock_ \ and para =~/\{(?:~\^\s+)?(.+?)\s\[(?:\d(?:[sS]*))\]\}(?:\.\.\/\S+?\/|\S+?\.ss[tm]\b)/ txt,cmd,source,linked_doc,note,manifest=nil,nil,nil,nil,nil,nil - @u=SiSU_Env::Info_env.new.url + @u=SiSU_Env::InfoEnv.new.url pre=txt=cmd=source=linked_doc=note='' if defined? @u.remote if /(?<pre>.+?)\{(?<txt>.+?)\s\[(?<cmd>\d[sS]*)\]\}(?<source>(?<linked_doc>\S+?)\.ss[tm]\b)(?<note>.*)/m =~ para - pre.strip! + pre=pre.strip elsif /\{(?<txt>.+?)\s\[(?<cmd>\d[sS]*)\]\}(?<source>(?<linked_doc>\S+?)\.ss[tm]\b)(?<note>.*)/m =~ para end - if linked_doc =~ /(\S+?)\/(\S+)/ + if linked_doc =~ /(\S+?)\/(\S+)/ linked_doc,linked_doc_lang=$1,$2 else - linked_doc,linked_doc_lang=linked_doc,@md.opt.lng_base + linked_doc,linked_doc_lang=linked_doc,@md.opt.lng_base end else puts "error, does currently support relative paths (reltive paths were removed, as had problems for citation, and was not suited to all output types should possibly reconsider) #{__FILE__} #{__LINE__}" @@ -289,7 +289,7 @@ module SiSU_insertions end lnk={} case @md.opt.dir_structure_by - when /language/ + when :language lnk={ manifest: by_language(linked_doc,linked_doc_lang).manifest, html_toc: by_language(linked_doc,linked_doc_lang).html_toc, @@ -307,7 +307,7 @@ module SiSU_insertions sisupod: by_language(linked_doc,linked_doc_lang,source).sisupod, source: by_language(linked_doc,linked_doc_lang,source).source, } - when /filetype/ + when :filetype lnk={ manifest: by_filetype(linked_doc,linked_doc_lang).manifest, html_toc: by_filetype(linked_doc,linked_doc_lang).html_toc, diff --git a/lib/sisu/v3/dal_hash_digest.rb b/lib/sisu/v3/dal_hash_digest.rb index 2c983919..ad201752 100644 --- a/lib/sisu/v3/dal_hash_digest.rb +++ b/lib/sisu/v3/dal_hash_digest.rb @@ -56,29 +56,30 @@ ** Description: system environment, resource control and configuration details =end -module SiSU_hash +module SiSU_DAL_Hash require_relative 'shared_markup_alt.rb' #shared_markup_alt.rb - class Object_digest + class ObjectDigest def initialize(md,data,env=nil) @md,@data,@env=md,data,env - @env ||=SiSU_Env::Info_env.new(@md.fns) + @env ||=SiSU_Env::InfoEnv.new(@md.fns) end def object_digest # 1. clean/stripped text without any markup, paragraph, headings etc. without endnotes # 2. endnotes clean/stripped text digest only (there may be several endnotes within a paragraph) # 3. whole object, text with markup and any endnotes, (question: with or without the endnote digests??? presumption better without, [however may be easier to check with?]) # [digests should not include other digests] - data=@data + data=@data.compact @tuned_file=[] - data.compact! sha_ =(@env.digest.type=='sha256' ? true : false) sha_ ? (require 'digest/sha2') : (require 'digest/md5') data.each do |t_o| unless t_o.obj.class==Array - t_o.obj.strip! + t_o.obj=t_o.obj.strip end - if t_o.of !~/structure|comment|layout/ \ - and t_o.ocn.class==Fixnum + if (t_o.of !=:structure \ + && t_o.of !=:comment \ + && t_o.of !=:layout) \ + && t_o.ocn.class==Fixnum if sha_ for hash_class in [ Digest::SHA256 ] @tuned_file << stamped(t_o,hash_class) @@ -101,7 +102,7 @@ module SiSU_hash when /#{Mx[:en_a_o]}|#{Mx[:en_b_o]}/ if en_plus =~/#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]}/ t_o_txt,en_open,en_txt,en_close=/(.*?)(#{Mx[:en_a_o]}|#{Mx[:en_b_o]})(.+?)(#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/m.match(en_plus)[1..4] - stripped_en=SiSU_text_representation::Alter.new(en_txt).strip_clean_of_markup + stripped_en=SiSU_TextRepresentation::Alter.new(en_txt).strip_clean_of_markup digest_en_strip=if @env.digest.type =~/sha256/ Digest::SHA256.hexdigest(stripped_en) else @@ -116,16 +117,16 @@ module SiSU_hash t_o_bit.join end def stamped(t_o,hash_class) #decide what hash information is most useful, is compromise necessary? - t_o.obj=SiSU_text_representation::Alter.new(t_o).strip_clean_of_extra_spaces + t_o.obj=SiSU_TextRepresentation::Alter.new(t_o).strip_clean_of_extra_spaces t_obj=t_o.inspect.sub(/:0x[0-9a-f]{8}\s/,': ') - stripped=SiSU_text_representation::Alter.new(t_o).strip_clean_of_markup - markup=SiSU_text_representation::Alter.new(t_o).semi_revert_markup - digests=SiSU_text_representation::Modified_text_plus_Hash_digest.new(@md,t_o).composite.dgst - unless t_o.is=='code' + stripped=SiSU_TextRepresentation::Alter.new(t_o).strip_clean_of_markup + markup=SiSU_TextRepresentation::Alter.new(t_o).semi_revert_markup + digests=SiSU_TextRepresentation::ModifiedTextPlusHashDigest.new(@md,t_o).composite.dgst + unless t_o.is==:code case t_o.obj when /#{Mx[:en_a_o]}[\d*+]+\s+.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}[*+]\d+\s+.+?#{Mx[:en_b_c]}/m en_and_t_o,en_and_t_o_digest=[],[] - t_o.obj.gsub!(/\s*(#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/m,' \1') #watch + t_o.obj=t_o.obj.gsub(/\s*(#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/m,' \1') #watch t_o_plus_en=t_o.obj.scan(/.*?#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|.*?#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]}/m) t_o_tail=if t_o.obj =~/(?:.*?#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|.*?#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})+([\s\S]+)/m /(?:.*?#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|.*?#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})+.*/m.match(t_o.obj)[1] @@ -144,11 +145,11 @@ module SiSU_hash def strip_clean_extra_spaces(s) # dal output tuned s=s.dup s=s.gsub(/[ ]+([,.;:?](?:$|\s))/,'\1') unless s =~/#{Mx[:en_a_o]}|#{Mx[:en_b_o]}/ - s=s.gsub(/ [ ]+/,' ') - s=s.gsub(/^ [ ]+/,'') - s=s.gsub(/ [ ]+$/,'') - s=s.gsub(/((?:#{Mx[:fa_bold_c]}|#{Mx[:fa_italics_c]})')[ ]+(s )/,'\1\2') - s=s.gsub(/((?:#{Mx[:fa_bold_c]}|#{Mx[:fa_italics_c]})')[ ]+(s )/,'\1\2') + s=s.gsub(/ [ ]+/,' '). + gsub(/^ [ ]+/,''). + gsub(/ [ ]+$/,''). + gsub(/((?:#{Mx[:fa_bold_c]}|#{Mx[:fa_italics_c]})')[ ]+(s )/,'\1\2'). + gsub(/((?:#{Mx[:fa_bold_c]}|#{Mx[:fa_italics_c]})')[ ]+(s )/,'\1\2') end end end diff --git a/lib/sisu/v3/dal_idx.rb b/lib/sisu/v3/dal_idx.rb index 5845437e..21567c14 100644 --- a/lib/sisu/v3/dal_idx.rb +++ b/lib/sisu/v3/dal_idx.rb @@ -56,14 +56,14 @@ ** Description: system environment, resource control and configuration details =end -module SiSU_book_index - class Book_index +module SiSU_DAL_BookIndex + class BookIndex def initialize(md,data,env=nil) @md,@data,@env=md,data,env @rgx_idx=/#{Mx[:idx_o]}(?:.+?)#{Mx[:idx_c]}\s*/ @rgx_idx_ocn_seg=/(.+?)~(\d+)~(\S+)/ @rgx_idx_ocn=/(.+?)~(\d+)/ - @env ||=SiSU_Env::Info_env.new(@md.fns) + @env ||=SiSU_Env::InfoEnv.new(@md.fns) end def indexing_song data=@data @@ -75,8 +75,9 @@ module SiSU_book_index tuned_file=[] idx_array=[] data.each do |dob| - if dob.is =~/heading/ \ - and dob.ln==4 + if (dob.is ==:heading \ + || dob.is ==:heading_insert) \ + && dob.ln==4 @seg=dob.name end idx_array << "#{dob.idx}~#{dob.ocn}~#{@seg}" if defined? dob.idx and not (dob.idx.nil? or dob.idx.empty?) @@ -101,21 +102,20 @@ module SiSU_book_index g=idx_list.scan(/[^;]+/) idxl=[] g.each do |i| - i.strip! + i=i.strip idxl << { rough_idx: i, ocn: ocn, seg: seg } end idxl else { rough_idx: idx_list, ocn: ocn, seg: seg } end end - idx_lst.flatten! - idx_lst + idx_lst=idx_lst.flatten end def construct_book_index(idx_array) the_idx={} idx_array.each do |idx| idx_lst=idx[:rough_idx].scan(/[^|:]+/) - idx_lst[0].strip! + idx_lst[0]=idx_lst[0].strip if idx_lst[0] =~/.+?\+\d+/ use,plus=/(.+?)\+(\d+)/.match(idx_lst[0])[1,2] else use=idx_lst[0] @@ -123,7 +123,7 @@ module SiSU_book_index use=use[0].chr.capitalize + use[1,use.length] the_idx[use]={} unless the_idx[use] and defined? the_idx[use] idx_lst.each do |i| - i.strip! + i=i.strip i,r=/(.+?)\+(\d+)/.match(i)[1,2] if i =~/.+?\+\d+/ x=if idx_lst.length==1 or idx_lst[0].gsub(/\+\d+/,'')==i the_idx[use]['term_node_lev1']=[] unless the_idx[use]['term_node_lev1'] and defined? the_idx[use]['term_node_lev1'] @@ -151,12 +151,12 @@ module SiSU_book_index the_idx end def clean_xml(str) - str.gsub!(/&/,'&') - str.gsub!(/\(/,'(') - str.gsub!(/\)/,')') - str.gsub!(/\*/,'*') - str.gsub!(/\+/,'+') - str.gsub!(/,/,',') + str=str.gsub(/&/,'&'). + gsub(/\(/,'('). + gsub(/\)/,')'). + gsub(/\*/,'*'). + gsub(/\+/,'+'). + gsub(/,/,',') str end def index(the_idx) @@ -164,15 +164,15 @@ module SiSU_book_index idx={} idx[:sst_rel_html_seg],idx[:sst_rel],idx[:html],idx[:xhtml]=[],[],[],[] h={obj: Mx[:br_page]} - o=SiSU_document_structure::Object_layout.new.break(h) + o=SiSU_DAL_DocumentStructure::ObjectLayout.new.break(h) idx[:sst_rel_html_seg] << o idx[:sst_rel] << o h={lv: '2', name: 'index', obj: "Index"} - o=SiSU_document_structure::Object_heading.new.heading(h) + o=SiSU_DAL_DocumentStructure::ObjectHeading.new.heading(h) idx[:sst_rel_html_seg] << o idx[:sst_rel] << o h={lv: '4', name: 'idx', obj: " [Index] #{Mx[:pa_non_object_dummy_heading]}"} - o=SiSU_document_structure::Object_heading.new.heading(h) + o=SiSU_DAL_DocumentStructure::ObjectHeading.new.heading(h) idx[:sst_rel_html_seg] << o idx[:sst_rel] << o alph=%W[9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z] @@ -347,7 +347,7 @@ module SiSU_book_index def clean_index(data) #check on use of dob tuned_file=[] data.each do |para| - para.gsub!(/\n*#{@rgx_idx}/m,'') + para=para.gsub(/\n*#{@rgx_idx}/m,'') tuned_file << para end tuned_file diff --git a/lib/sisu/v3/dal_images.rb b/lib/sisu/v3/dal_images.rb index 34157f74..6455daf1 100644 --- a/lib/sisu/v3/dal_images.rb +++ b/lib/sisu/v3/dal_images.rb @@ -56,7 +56,7 @@ ** Description: system environment, resource control and configuration details =end -module SiSU_images +module SiSU_DAL_Images class Images #require 'RMagick' #include Magick @@ -67,7 +67,7 @@ module SiSU_images data=@data tuned_file=[] @rmgk=false - imagemagick_=true #imagemagick_=SiSU_Env::Info_settings.new.program?('rmagick') + imagemagick_=true #imagemagick_=SiSU_Env::InfoSettings.new.program?('rmagick') if imagemagick_ begin @rmgk=SiSU_Env::Load.new('RMagick').prog @@ -80,8 +80,8 @@ module SiSU_images end end data.each do |dob| - unless dob.is =~/^table/ - dob.obj.strip! + unless dob.is ==:table + dob.obj=dob.obj.strip if dob.obj =~/#{Mx[:lnk_o]}\s*\S+\.(?:png|jpg|gif)(?:\s*|\s+.+)?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/ if dob.obj !~/#{Mx[:lnk_o]}\s*\S+\.(?:png|jpg|gif)\s+\d+x\d+/ m=/#{Mx[:lnk_o]}\s*(\S+\.(?:png|jpg|gif))/ @@ -89,7 +89,7 @@ module SiSU_images imgs=dob.obj.scan(m).flatten img_col=img_row=nil images=imgs.each do |image| - dir=SiSU_Env::Info_env.new(@md.fns) + dir=SiSU_Env::InfoEnv.new(@md.fns) path_image=[dir.path.image_source_include_local,dir.path.image_source_include_remote,dir.path.image_source_include] image_path=nil path_image.each do |img_pth| @@ -104,8 +104,8 @@ module SiSU_images if @md.opt.cmd =~/[vVM]/ SiSU_Screen::Ansi.new(@md.opt.cmd,'RMagick not present, will attempt to use imagemagick (identify) directly').warn end - imgk=SiSU_Env::System_call.new.imagemagick - gmgk=SiSU_Env::System_call.new.graphicksmagick + imgk=SiSU_Env::SystemCall.new.imagemagick + gmgk=SiSU_Env::SystemCall.new.graphicksmagick if imgk or gmgk if imgk imgsys=`identify #{image_path}/#{image}`.strip #system call @@ -133,8 +133,8 @@ module SiSU_images img_col=((1.00*img_row/row)*col).round end end - dob.obj.gsub!(/(#{image})/,"#{image} #{img_col}x#{img_row}") - else dob.obj.gsub!(/#{Mx[:lnk_o]}\s*(\S+)\.(png|jpg|gif).+?#{Mx[:lnk_c]}(#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/,'[ \1 (\2 missing) ]') + dob.obj=dob.obj.gsub(/(#{image})/,"#{image} #{img_col}x#{img_row}") + else dob.obj=dob.obj.gsub(/#{Mx[:lnk_o]}\s*(\S+)\.(png|jpg|gif).+?#{Mx[:lnk_c]}(#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/,'[ \1 (\2 missing) ]') end end else @@ -144,7 +144,9 @@ module SiSU_images end end end - dob.obj.gsub!(/(#{Mx[:lnk_o]})\s*(\S+\.(?:png|jpg|gif))\s+/i,'\1\2 ') if dob.obj =~/#{Mx[:lnk_o]}\s*\S+\.(?:png|jpg|gif).+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/ + if dob.obj =~/#{Mx[:lnk_o]}\s*\S+\.(?:png|jpg|gif).+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/ + dob.obj=dob.obj.gsub(/(#{Mx[:lnk_o]})\s*(\S+\.(?:png|jpg|gif))\s+/i,'\1\2 ') + end end tuned_file << dob unless dob.nil? end diff --git a/lib/sisu/v3/dal_metadata.rb b/lib/sisu/v3/dal_metadata.rb index 8647a075..f7dc9579 100644 --- a/lib/sisu/v3/dal_metadata.rb +++ b/lib/sisu/v3/dal_metadata.rb @@ -56,21 +56,21 @@ ** Description: system environment, resource control and configuration details =end -module SiSU_metadata +module SiSU_DAL_Metadata class Metadata def initialize(md,metad) @md,@metadata=md,metad - l=SiSU_Env::Standardise_language.new(@md.opt.lng).language + l=SiSU_Env::StandardiseLanguage.new(@md.opt.lng).language language=l[:n] @tr=SiSU_Translate::Source.new(md,language) end def make_para(obj,ocn) h={ obj: obj, ocn: 0 } - SiSU_document_structure::Object_para.new.paragraph(h) + SiSU_DAL_DocumentStructure::ObjectPara.new.paragraph(h) end def make_heading(obj,ocn,name,lv,ln) h={ lv: lv, ln: ln, name: name, obj: obj, ocn: 0 } - SiSU_document_structure::Object_heading.new.heading(h) + SiSU_DAL_DocumentStructure::ObjectHeading.new.heading(h) end def metadata end diff --git a/lib/sisu/v3/dal_numbering.rb b/lib/sisu/v3/dal_numbering.rb index 4b12793f..f5a09ef6 100644 --- a/lib/sisu/v3/dal_numbering.rb +++ b/lib/sisu/v3/dal_numbering.rb @@ -56,7 +56,7 @@ ** Description: system environment, resource control and configuration details =end -module SiSU_numbering +module SiSU_DAL_Numbering class Numbering attr_accessor :obj,:osp,:ocn,:lv,:name,:index,:comment def initialize(md,data) @@ -77,12 +77,15 @@ module SiSU_numbering def number_plaintext_para(data) @tuned_file=[] data.each do |dob| - if dob.of !~/(?:block|comment|layout)/ and dob.ocn_ #and dob.obj !~ /#{Mx[:gr_o]}Th|#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}/ #FIX - dob.obj.gsub!(/(.+)\n/,'\1 ') #messy, but idea is that tables should retain breaks + if (dob.of !=:block \ + && dob.of !=:comment \ + && dob.of !=:layout) \ + && dob.ocn_ #and dob.obj !~ /#{Mx[:gr_o]}Th|#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}/ #FIX + dob.obj=dob.obj.gsub(/(.+)\n/,'\1 ') #messy, but idea is that tables should retain breaks end unless dob.obj.class==Array - dob.obj.gsub!(/^\s+/,'') - dob.obj.gsub!(/\s$/,"\n") + dob.obj=dob.obj.gsub(/^\s+/,''). + gsub(/\s$/,"\n") end @tuned_file << dob end @@ -90,37 +93,35 @@ module SiSU_numbering end def number_sub_heading(dob,num,title_no) unless dob.obj =~/\d+\.|(?:chapter|article|section|clause)\s+\d+/i #name selection arbitrary, fix - case dob.name - when /-/; dob.obj.gsub!(/^/,"#{title_no} ") - when /^#/; dob.obj.gsub!(/^/,"#{title_no} ") - when /^[a-z_\.]+/ - dob.obj.gsub!(/^/,"#{title_no} ") + dob.obj=case dob.name + when /-/; dob.obj.gsub(/^/,"#{title_no} ") + when /^#/; dob.obj.gsub(/^/,"#{title_no} ") + when /^[a-z_\.]+/; dob.obj.gsub(/^/,"#{title_no} ") else dob.name=title_no if dob.name=~/^$/ #where title contains title number - dob.obj.gsub!(/^/,"#{title_no} ") if title_no =~/\d+/ #main, where title number is to be provided #watch changed placement + dob.obj.gsub(/^/,"#{title_no} ") if title_no =~/\d+/ #main, where title number is to be provided #watch changed placement end if @md.toc_lev_limit \ and @md.toc_lev_limit < num - dob.obj.gsub!(/^/,'!_ ') #bold line, watch + dob.obj=dob.obj.gsub(/^/,'!_ ') #bold line, watch end end dob end def heading_tag_clean(heading_tag) - heading_tag.gsub!(/[ ]+/,'_') - heading_tag.gsub!(/["']/,'') - heading_tag.gsub!(/[\/]/,'-') - heading_tag.gsub!(/#{Mx[:fa_bold_o]}|#{Mx[:fa_bold_c]}/,'') - heading_tag.gsub!(/#{Mx[:fa_italics_o]}|#{Mx[:fa_italics_c]}/,'') - heading_tag.gsub!(/#{Mx[:fa_underscore_o]}|#{Mx[:fa_underscore_c]}/,'') - heading_tag.gsub!(/#{Mx[:fa_cite_o]}|#{Mx[:fa_cite_c]}/,'') - heading_tag.gsub!(/#{Mx[:fa_insert_o]}|#{Mx[:fa_insert_c]}/,'') - heading_tag.gsub!(/#{Mx[:fa_strike_o]}|#{Mx[:fa_strike_c]}/,'') - heading_tag.gsub!(/#{Mx[:fa_superscript_o]}|#{Mx[:fa_superscript_c]}/,'') - heading_tag.gsub!(/#{Mx[:fa_subscript_o]}|#{Mx[:fa_subscript_c]}/,'') - heading_tag.gsub!(/#{Mx[:fa_hilite_o]}|#{Mx[:fa_hilite_c]}/,'') - heading_tag.gsub!(/#{Mx[:gl_bullet]}/,'') - heading_tag + heading_tag=heading_tag.gsub(/[ ]+/,'_'). + gsub(/["']/,''). + gsub(/[\/]/,'-'). + gsub(/#{Mx[:fa_bold_o]}|#{Mx[:fa_bold_c]}/,''). + gsub(/#{Mx[:fa_italics_o]}|#{Mx[:fa_italics_c]}/,''). + gsub(/#{Mx[:fa_underscore_o]}|#{Mx[:fa_underscore_c]}/,''). + gsub(/#{Mx[:fa_cite_o]}|#{Mx[:fa_cite_c]}/,''). + gsub(/#{Mx[:fa_insert_o]}|#{Mx[:fa_insert_c]}/,''). + gsub(/#{Mx[:fa_strike_o]}|#{Mx[:fa_strike_c]}/,''). + gsub(/#{Mx[:fa_superscript_o]}|#{Mx[:fa_superscript_c]}/,''). + gsub(/#{Mx[:fa_subscript_o]}|#{Mx[:fa_subscript_c]}/,''). + gsub(/#{Mx[:fa_hilite_o]}|#{Mx[:fa_hilite_c]}/,''). + gsub(/#{Mx[:gl_bullet]}/,'') end def auto_number_heading_ie_title(data) #also does some segment naming @tuned_file=[] @@ -135,20 +136,20 @@ module SiSU_numbering no1=num_top; no2=(num_top + 1); no3=(num_top + 2); no4=(num_top + 3) end t_not=0 - data.compact! chapter_number_counter=0 + data=data.compact data.each do |dob| #@md.seg_names << [additions to segment names] title_no=nil - dob=SiSU_document_structure_extract::Structure.new(@md,dob).structure_markup #must happen earlier, node info etc. require - if dob.is =='heading' \ - and dob.autonum_ \ + dob=SiSU_DAL_DocumentStructureExtract::Structure.new(@md,dob).structure_markup #must happen earlier, node info etc. require + if dob.is ==:heading \ + && dob.autonum_ \ and defined? @md.make.num_top \ and @md.make.num_top !~/^$/ if dob.lv=='1' \ and dob.obj =~/^#\s|\s#(?:\s|$)/ chapter_number_counter +=1 - dob.obj.gsub!(/^#\s/,"#{chapter_number_counter} ") - dob.obj.gsub!(/#([:,]?\s|[.]?$)/,"#{chapter_number_counter}\\1") + dob.obj=dob.obj.gsub(/^#\s/,"#{chapter_number_counter} "). + gsub(/#([:,]?\s|[.]?$)/,"#{chapter_number_counter}\\1") end if dob.ln==no1 @subnumber=1 @@ -168,15 +169,15 @@ module SiSU_numbering 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.obj =~/(Article|Clause|Section)\s+/) \ - ? (dob.obj.gsub!(/(Article|Clause|Section)\s+/,"\\1 #{title_no} ")) - : (dob.obj.gsub!(/^/,"#{title_no}. ")) #fix stop later + 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 end 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.obj.gsub!(/^/,"#{title_no}. ") + dob.obj=dob.obj.gsub(/^/,"#{title_no}. ") end @md.seg_names << title_no end @@ -184,7 +185,7 @@ module SiSU_numbering 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.obj.gsub!(/^/i,"#{title_no}. ") + dob.obj=dob.obj.gsub(/^/i,"#{title_no}. ") end end if dob.ln==no1 #watch because here you change dob.name @@ -207,7 +208,7 @@ module SiSU_numbering dob.tags=[dob.name,dob.tags].flatten if dob.name !~/^\d+$/ #check whether will work across file types with stop signs dob.name.gsub(/^([a-z_\.]+)-$/,'\1') end - elsif dob.is =='heading' \ + elsif dob.is ==:heading \ and dob.autonum_ \ and @md.markup =~/num_extract/ #AS DANGEROUS force enable with document, note already does this type of numbering for cisg, locate and coordinate logic, is currently misplaced in code, chengwei inspired 2004w23/4 #here lies a bug, as is nil when run from -Dv --update, FIX @@ -229,11 +230,11 @@ module SiSU_numbering @tuned_file=@tuned_file.flatten end def ocn(data) #and auto segment numbering increment - @tuned_file=SiSU_document_structure_extract::OCN.new(@md,data).ocn + @tuned_file=SiSU_DAL_DocumentStructureExtract::OCN.new(@md,data).ocn @tuned_file end def xml(data) - @tuned_file=SiSU_document_structure_extract::XML.new(@md,data).dom + @tuned_file=SiSU_DAL_DocumentStructureExtract::XML.new(@md,data).dom @tuned_file end def minor_numbering(data) #and auto segment numbering increment @@ -241,20 +242,23 @@ module SiSU_numbering number_small,letter_small=0,0 letter=%w( a b c d e f g h i j k l m n o p q r s t u v w x y z ) data.each do |dob| - if dob.of =~/heading|para|block/ - if dob.is =='heading' \ + if dob.of ==:heading \ + || dob.of ==:heading_insert \ + || dob.of ==:para \ + || dob.of ==:block + if dob.is ==:heading \ and dob.ln.to_s=~/^[1-9]/ #% sub-number system, (baby numbering) reset with any change of major number (more obviously should be placed in number titles, but that is conditionally executed, check and move later) number_small,letter_small=0,0 - elsif dob.is =~/para/ + elsif dob.is ==:para if dob.obj =~/^#[ 1]/ \ and dob.obj !~/^#\s+(?:~#)?$/ letter_small=0 number_small=0 if dob.obj =~ /^#1/ number_small+=1 - dob.obj.gsub!(/^#[ 1]/,"#{number_small}. ") #change 2004 + dob.obj=dob.obj.gsub(/^#[ 1]/,"#{number_small}. ") end if dob.obj =~/^_# / - dob.obj.gsub!(/^_# /,"#{letter[letter_small]}. ") #change 2004 + dob.obj=dob.obj.gsub(/^_# /,"#{letter[letter_small]}. ") dob.indent='1' letter_small+=1 end @@ -287,8 +291,8 @@ module SiSU_numbering end ocn_html_seg=[] data.each do |dob| - if dob.is=='heading' \ - and dob.ln \ + if dob.is==:heading \ + && dob.ln \ and dob.ln.to_s =~/^[456]/ if dob.ln==4 \ and not dob.name \ @@ -298,8 +302,8 @@ module SiSU_numbering if dob.name !~/^\S+/ \ and dob.obj =~/^\s*(?:\S+\s+)?([\d.,:-]+)/m #heading starts with a recognised numeric or word followed by a recognised numerical construct, use that as name possible_seg_name=$1 - possible_seg_name.gsub!(/(?:[:,-]|\W)/,'.') - possible_seg_name.gsub!(/\.$/,'') + possible_seg_name=possible_seg_name.gsub(/(?:[:,-]|\W)/,'.'). + gsub(/\.$/,'') if not @md.seg_names.nil? \ and not @md.seg_names.include?(possible_seg_name) dob.name=possible_seg_name @@ -334,18 +338,19 @@ module SiSU_numbering puts "e r r o r -\t#{__FILE__}::#{__LINE__}\n#{dob.inspect}" end end - if dob.is =~/heading/ \ - and dob.ln==4 + if (dob.is ==:heading \ + || dob.is ==:heading_insert) \ + && dob.ln==4 @seg=dob.name end - @tuned_file << if dob.is=='heading' \ - and (@md.pagenew or @md.pagebreak) + @tuned_file << if dob.is==:heading \ + && (@md.pagenew || @md.pagebreak) m=dob.ln.to_s dob_tmp=[] if @md.pagenew.inspect =~/#{m}/ - dob_tmp << SiSU_document_structure::Object_layout.new.break(Hx[:br_page_new]) << dob + dob_tmp << SiSU_DAL_DocumentStructure::ObjectLayout.new.break(Hx[:br_page_new]) << dob elsif @md.pagebreak.inspect =~/#{m}/ - dob_tmp << SiSU_document_structure::Object_layout.new.break(Hx[:br_page]) << dob + dob_tmp << SiSU_DAL_DocumentStructure::ObjectLayout.new.break(Hx[:br_page]) << dob end para_result=unless dob_tmp.length > 0; dob else dob_tmp @@ -354,11 +359,11 @@ module SiSU_numbering end if defined? dob.ocn \ and dob.ocn - @segname=((dob.is=='heading'|| dob.is=='heading_insert') && dob.ln==4 && (defined? dob.name)) \ + @segname=((dob.is==:heading || dob.is==:heading_insert) && dob.ln==4 && (defined? dob.name)) \ ? (dob.name) : @segname tags["#{dob.ocn}"]={ segname: @segname } - ocn_html_seg[dob.ocn]=if dob.is =~/heading/ + ocn_html_seg[dob.ocn]=if (dob.is==:heading || dob.is==:heading_insert) x=if dob.ln =~/[1-3]/ { seg: nil, level: dob.ln } else #elsif dob.ln =~/[4-6]/ @@ -429,7 +434,7 @@ module SiSU_numbering unless @md.set_heading_seg if defined? dob.ln and dob.ln.to_s !~/^[123]/m \ and dob.obj !~/\A\s*\Z/m \ - and dob.is !='layout' + and dob.is !=:layout @md.set_heading_seg=true head=if @md.title.main ; dob.ln,dob.name,dob.obj=4,'seg',@md.title.main else dob.ln,dob.name,dob.obj=4,'seg','[segment]' diff --git a/lib/sisu/v3/dal_substitutions_and_insertions.rb b/lib/sisu/v3/dal_substitutions_and_insertions.rb index 5844071f..2ae365be 100644 --- a/lib/sisu/v3/dal_substitutions_and_insertions.rb +++ b/lib/sisu/v3/dal_substitutions_and_insertions.rb @@ -56,22 +56,22 @@ ** Description: system environment, resource control and configuration details =end -module SiSU_substitute_and_insert +module SiSU_DAL_SubstituteAndInsert class SI def initialize(md,data) @md,@data=md,data - @skin=SiSU_Env::Info_skin.new(@md) + @skin=SiSU_Env::InfoSkin.new(@md) end def substitutions_and_insertions? data=@data data_expand=[] if data[0] =~ /^#!\s*(?:\/usr\/bin\/env sisu|\/usr\/bin\/sisu)/ # remove bang from top #! (however file is stripped, so will be removed provided no content precedes it) - data[0].gsub!(/^#!\s*\/usr\/bin\/sisu/,'') - data[0].gsub!(/^#!\s*\/usr\/bin\/env sisu/,'') + data[0]=data[0].gsub(/^#!\s*\/usr\/bin\/sisu/,''). + gsub(/^#!\s*\/usr\/bin\/env sisu/,'') end if data[0] =~ /^(SiSU\s+[\d.]*|sisu-[\d.]+)$/ # SiSU identifier - data[0].gsub!(/^(SiSU\s*[\d.]*)$/,'% \1') - data[0].gsub!(/^(sisu-[\d.]+)$/,'% \1') + data[0]=data[0].gsub(/^(SiSU\s*[\d.]*)$/,'% \1'). + gsub(/^(sisu-[\d.]+)$/,'% \1') end data.each do |para| if para =~/<:(insert\d+)!?>/ \ @@ -132,22 +132,24 @@ module SiSU_substitute_and_insert para.each {|x| data_expand << x } else data_expand << para end - data_expand.flatten! - data_expand.compact! + data_expand=data_expand.flatten.compact end + data_new=[] data_expand.each do |para| para=if @md.markup_version.determined >= 0.38 - SiSU_document_structure_extract::Structure.new(@md,para).structure_markup_normalize + SiSU_DAL_DocumentStructureExtract::Structure.new(@md,para).structure_markup_normalize else - SiSU_document_structure_extract::Structure.new(@md,para).structure_marks + SiSU_DAL_DocumentStructureExtract::Structure.new(@md,para).structure_marks end - para.gsub!(/^(:?A~)\s*$/,'\1~ @title @author') #conditional header - para.gsub!(/^((?:[1-9]|:?[A-C])~\S*)\s*$/,'\1~ [Note: heading marker::required title missing]~#') #conditional header for incorporated document 2004w12 + para=para.gsub(/^(:?A~)\s*$/,'\1~ @title @author'). #conditional header + gsub(/^((?:[1-9]|:?[A-C])~\S*)\s*$/,'\1~ [Note: heading marker::required title missing]~#') #conditional header for incorporated document 2004w12 if para =~/^@\S+?:/ - para.gsub!(/^@(\S+?):(\s+|$)/,"#{Mx[:meta_o]}\\1#{Mx[:meta_c]}\\2") - para.gsub!(/^@(\S+?):([+-])(\s+|$)/,"#{Mx[:meta_o]}\\1\\2#{Mx[:meta_c]}\\3") + para=para.gsub(/^@(\S+?):(\s+|$)/,"#{Mx[:meta_o]}\\1#{Mx[:meta_c]}\\2"). + gsub(/^@(\S+?):([+-])(\s+|$)/,"#{Mx[:meta_o]}\\1\\2#{Mx[:meta_c]}\\3") end + data_new << para end + data_new end end end diff --git a/lib/sisu/v3/dal_syntax.rb b/lib/sisu/v3/dal_syntax.rb index 2d2a8430..73bb6a64 100644 --- a/lib/sisu/v3/dal_syntax.rb +++ b/lib/sisu/v3/dal_syntax.rb @@ -56,7 +56,7 @@ ** Description: Syntax for markup, input markup syntaxes, determined here =end -module SiSU_Syntax +module SiSU_DAL_Syntax class Words def initialize(line,md,mkp) @line,@md,@mkp=line,md,mkp @@ -65,11 +65,11 @@ module SiSU_Syntax class Markup def initialize(md='',data='') @data,@md=data,md - @vz=SiSU_Env::Get_init.instance.skin + @vz=SiSU_Env::GetInit.instance.skin @data_new=[] - url_and_stub=SiSU_Env::Info_env.new.url + url_and_stub=SiSU_Env::InfoEnv.new.url @output_url="#{url_and_stub.remote}" - @env=SiSU_Env::Info_env.new + @env=SiSU_Env::InfoEnv.new emph_set=if defined? @md.make.emphasis \ and not @md.make.emphasis.nil? @md.make.emphasis @@ -120,7 +120,7 @@ module SiSU_Syntax end end def songsheet - @data.compact! + @data=@data.compact @data.each do |dob| dob=breaks(dob) dob=if @md.sem_tag then sem(dob) else dob end #revisit @@ -132,12 +132,15 @@ module SiSU_Syntax @data_new end def sem(dob) #revisit - dob=SiSU_sem::Tags.new(dob,@md).rm.all + dob=SiSU_Sem::Tags.new(dob,@md).rm.all end def breaks(dob) - if dob.is !~/^(?:meta|comment|code|table)/ - dob.obj.gsub!(/ \\\\(?: |$)/,"#{Mx[:br_line]}") - dob.obj.gsub!(/(?:<:?br>|<br \/>)/,"#{Mx[:br_line]}") # depreciated + if dob.is !=:meta \ + && dob.is !=:comment \ + && dob.is !=:code \ + && dob.is !=:table + dob.obj=dob.obj.gsub(/ \\\\(?: |$)/,"#{Mx[:br_line]}"). + gsub(/(?:<:?br>|<br \/>)/,"#{Mx[:br_line]}") # depreciated end dob end @@ -147,20 +150,23 @@ module SiSU_Syntax and @md.make.italics[:str]) \ or (defined? @vz.markup_make_italic[:str] \ and @vz.markup_make_italic[:str]) - dob.obj=if dob.is !~/^(?:meta|heading|code|comment)/ + dob.obj=if dob.is !=:meta \ + && dob.is !=:heading \ + && dob.is !=:heading_insert \ + && dob.is !=:code \ + && dob.is !=:comment word=dob.obj.scan(@line_scan_ital) - word.flatten! - word.compact! #reinstated + word=word.flatten.compact line_array=[] word.each do |w| unless /#{@manmkp_ital}|#{@http_m}/.match(w) if defined? @md.make.italics[:regx] \ and @md.make.italics[:regx] - w.gsub!(@md.make.italics[:regx], + w=w.gsub(@md.make.italics[:regx], "#{Mx[:fa_italics_o]}\\1#{Mx[:fa_italics_c]}") elsif defined? @vz.markup_make_italic \ and @vz.markup_make_italic - w.gsub!(@vz.markup_make_italic, + w=w.gsub(@vz.markup_make_italic, "#{Mx[:fa_italics_o]}\\1#{Mx[:fa_italics_c]}") else w end @@ -174,28 +180,28 @@ module SiSU_Syntax dob end def embolden(given) - given.gsub!(/^!_\s+((?:\{|#{Mx[:lnk_o]})(?:~^ )?.+?(?:\}|#{Mx[:lnk_o]})https?:\/\/\S+.*?)([#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}])/, - "#{Mx[:fa_bold_o]} \\1 #{Mx[:fa_bold_c]}\\2") - given.gsub!(/^!_\s+((?:\{|#{Mx[:lnk_o]})(?:~^ )?.+?(?:\}|#{Mx[:lnk_o]})https?:\/\/\S+.*)/, - "#{Mx[:fa_bold_o]} \\1 #{Mx[:fa_bold_c]}") - given.gsub!(/(?:^!_|^#{Mx[:lv_o]}[7-9]:\S*?#{Mx[:lv_c]})\s*(.+?)([#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}])/, - "#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}\\2") - given.gsub!(/(?:^!_|^#{Mx[:lv_o]}[7-9]:\S*?#{Mx[:lv_c]})\s*(.+?)\s+((?:[*]~\S+\s*)+)/, - "#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}\\2") - given.gsub!(/(?:^!_|^#{Mx[:lv_o]}[7-9]:\S*?#{Mx[:lv_c]})\s*(.+?)\s*([~-]#)$/, - "#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}\\2") - given.gsub!(/(?:^!_\s+|^#{Mx[:lv_o]}[7-9]:\S*?#{Mx[:lv_c]}\s*)(.*)?\s*$/, - "#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}") + given=given.gsub(/^!_\s+((?:\{|#{Mx[:lnk_o]})(?:~^ )?.+?(?:\}|#{Mx[:lnk_o]})https?:\/\/\S+.*?)([#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}])/, + "#{Mx[:fa_bold_o]} \\1 #{Mx[:fa_bold_c]}\\2"). + gsub(/^!_\s+((?:\{|#{Mx[:lnk_o]})(?:~^ )?.+?(?:\}|#{Mx[:lnk_o]})https?:\/\/\S+.*)/, + "#{Mx[:fa_bold_o]} \\1 #{Mx[:fa_bold_c]}"). + gsub(/(?:^!_|^#{Mx[:lv_o]}[7-9]:\S*?#{Mx[:lv_c]})\s*(.+?)([#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}])/, + "#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}\\2"). + gsub(/(?:^!_|^#{Mx[:lv_o]}[7-9]:\S*?#{Mx[:lv_c]})\s*(.+?)\s+((?:[*]~\S+\s*)+)/, + "#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}\\2"). + gsub(/(?:^!_|^#{Mx[:lv_o]}[7-9]:\S*?#{Mx[:lv_c]})\s*(.+?)\s*([~-]#)$/, + "#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}\\2"). + gsub(/(?:^!_\s+|^#{Mx[:lv_o]}[7-9]:\S*?#{Mx[:lv_c]}\s*)(.*)?\s*$/, + "#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}") end def italicise(given) - given.gsub!(/^\/_\s*(.+?)([#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}])/, - "#{Mx[:fa_italics_o]}\\1#{Mx[:fa_italics_c]}\\2") - given.gsub!(/^\/_\s*(.+?)\s+((?:[*]~\S+\s*)+)/, - "#{Mx[:fa_italics_o]}\\1#{Mx[:fa_italics_c]}\\2") - given.gsub!(/^\/_\s*(.+?)\s*([~-]#)$/, - "#{Mx[:fa_italics_o]}\\1#{Mx[:fa_italics_c]}\\2") - given.gsub!(/^\/_\s+(.*)?\s*$/, - "#{Mx[:fa_italics_o]}\\1#{Mx[:fa_italics_c]}") + given=given.gsub(/^\/_\s*(.+?)([#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}])/, + "#{Mx[:fa_italics_o]}\\1#{Mx[:fa_italics_c]}\\2"). + gsub(/^\/_\s*(.+?)\s+((?:[*]~\S+\s*)+)/, + "#{Mx[:fa_italics_o]}\\1#{Mx[:fa_italics_c]}\\2"). + gsub(/^\/_\s*(.+?)\s*([~-]#)$/, + "#{Mx[:fa_italics_o]}\\1#{Mx[:fa_italics_c]}\\2"). + gsub(/^\/_\s+(.*)?\s*$/, + "#{Mx[:fa_italics_o]}\\1#{Mx[:fa_italics_c]}") end def wordlist_bold(dob) dob=dob.dup @@ -203,22 +209,26 @@ module SiSU_Syntax and @md.make.bold[:str]) \ or (defined? @vz.markup_make_bold[:str] \ and @vz.markup_make_bold[:str]) - dob.obj=if dob.is !~/^(?:meta|heading|code|comment|table)/ + dob.obj=if dob.is !=:meta \ + && dob.is !=:heading \ + && dob.is !=:heading_insert \ + && dob.is !=:code \ + && dob.is !=:comment \ + && dob.is !=:table line_array=[] word=dob.obj.scan(@line_scan_bold) - word.flatten! - word.compact! + word=word.flatten.compact word.each do |w| unless /#{@manmkp_bold}|#{@http_m}/.match(w) if defined? @md.make.bold[:regx] \ and @md.make.bold[:regx] #document header: @bold: [bold word list] - w.gsub!(@md.make.bold[:regx],"#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}") + w=w.gsub(@md.make.bold[:regx],"#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}") elsif defined? @vz.markup_make_bold \ and @vz.markup_make_bold #defaults and skin adjusted bold word list - w.gsub!(@vz.markup_make_bold,"#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}") + w=w.gsub(@vz.markup_make_bold,"#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}") end else - if w =~ /(?:^!_|^#{Mx[:lv_o]}[7-9]:\S*?#{Mx[:lv_c]})\s+/; embolden(w) #bold paragraph/emphasize #may wish to remove think about 7{ 8{ conversion not satisfactory, as information is lost! + w=if w =~ /(?:^!_|^#{Mx[:lv_o]}[7-9]:\S*?#{Mx[:lv_c]})\s+/; embolden(w) #bold paragraph/emphasize #may wish to remove think about 7{ 8{ conversion not satisfactory, as information is lost! elsif w =~/^\/_\s+/; italicise(w) else w end @@ -229,42 +239,46 @@ module SiSU_Syntax else dob.obj end else - if dob.is !~/^(?:heading|comment|meta)/ \ + dob.obj=if (dob.is !=:heading \ + && dob.is !=:heading_insert \ + && dob.is !=:comment \ + && dob.is !=:meta) \ and dob.obj =~ /^!_\s+/ embolden(dob.obj) - elsif dob.is=='heading' \ + elsif dob.is==:heading \ and dob.ln.to_s =~/[7-9]/ embolden(dob.obj) + else dob.obj end if dob.obj =~ /\/_\s+/ - italicise(dob.obj) + dob.obj=italicise(dob.obj) end end dob end def fontface(dob) - dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|#{Mx[:br_line]}|#{Mx[:br_paragraph]}|[\(\[\{]|\>)\*\{(.+?)\}\*/m, - "\\1#{@emph[:o]}\\2#{@emph[:c]}") #emphasis - dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|#{Mx[:br_line]}|#{Mx[:br_paragraph]}|[\(\[\{]|\>)!\{(.+?)\}!/m, - "\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}") #bold - dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|#{Mx[:br_line]}|#{Mx[:br_paragraph]}|[\(\[\{]|\(|\>)\/\{(.+?)\}\//m, - "\\1#{Mx[:fa_italics_o]}\\2#{Mx[:fa_italics_c]}") #italics - dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|#{Mx[:br_line]}|#{Mx[:br_paragraph]}|[\(\[\{]|\>)_\{(.+?)\}_/m, - "\\1#{Mx[:fa_underscore_o]}\\2#{Mx[:fa_underscore_c]}") #underscore - dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|#{Mx[:br_line]}|#{Mx[:br_paragraph]}|[\(\[\{]|\>)#\{(.+?)\}#/m, - "\\1#{Mx[:fa_monospace_o]}\\2#{Mx[:fa_monospace_c]}") #monospace - dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\"\{(.+?)\}\"/m, - "\\1#{Mx[:fa_cite_o]}\\2#{Mx[:fa_c_o]}cite#{Mx[:fa_c]}") #cite /blockquote? - dob.obj.gsub!(/(^|[^\\])\^\{(.+?)\}\^/m, - "\\1#{Mx[:fa_superscript_o]}\\2#{Mx[:fa_superscript_c]}") #superscript - dob.obj.gsub!(/(^|[^\\]),\{(.+?)\},/m, - "\\1#{Mx[:fa_subscript_o]}\\2#{Mx[:fa_subscript_c]}") #subscript - dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\+\{(.+?)\}\+/m, - "\\1#{Mx[:fa_insert_o]}\\2#{Mx[:fa_insert_c]}") #inserted text - dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)-\{(.+?)\}-/m, - "\\1#{Mx[:fa_strike_o]}\\2#{Mx[:fa_strike_c]}") #strikethrough - deleted text - dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>|\d+)\^(\S+?)\^/, - "\\1#{Mx[:fa_superscript_o]}\\2#{Mx[:fa_superscript_c]}") #superscript single word, watch digit added + dob.obj=dob.obj.gsub(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|#{Mx[:br_line]}|#{Mx[:br_paragraph]}|[\(\[\{]|\>)\*\{(.+?)\}\*/m, + "\\1#{@emph[:o]}\\2#{@emph[:c]}"). #emphasis + gsub(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|#{Mx[:br_line]}|#{Mx[:br_paragraph]}|[\(\[\{]|\>)!\{(.+?)\}!/m, + "\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}"). #bold + gsub(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|#{Mx[:br_line]}|#{Mx[:br_paragraph]}|[\(\[\{]|\(|\>)\/\{(.+?)\}\//m, + "\\1#{Mx[:fa_italics_o]}\\2#{Mx[:fa_italics_c]}"). #italics + gsub(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|#{Mx[:br_line]}|#{Mx[:br_paragraph]}|[\(\[\{]|\>)_\{(.+?)\}_/m, + "\\1#{Mx[:fa_underscore_o]}\\2#{Mx[:fa_underscore_c]}"). #underscore + gsub(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|#{Mx[:br_line]}|#{Mx[:br_paragraph]}|[\(\[\{]|\>)#\{(.+?)\}#/m, + "\\1#{Mx[:fa_monospace_o]}\\2#{Mx[:fa_monospace_c]}"). #monospace + gsub(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\"\{(.+?)\}\"/m, + "\\1#{Mx[:fa_cite_o]}\\2#{Mx[:fa_c_o]}cite#{Mx[:fa_c]}"). #cite /blockquote? + gsub(/(^|[^\\])\^\{(.+?)\}\^/m, + "\\1#{Mx[:fa_superscript_o]}\\2#{Mx[:fa_superscript_c]}"). #superscript + gsub(/(^|[^\\]),\{(.+?)\},/m, + "\\1#{Mx[:fa_subscript_o]}\\2#{Mx[:fa_subscript_c]}"). #subscript + gsub(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\+\{(.+?)\}\+/m, + "\\1#{Mx[:fa_insert_o]}\\2#{Mx[:fa_insert_c]}"). #inserted text + gsub(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)-\{(.+?)\}-/m, + "\\1#{Mx[:fa_strike_o]}\\2#{Mx[:fa_strike_c]}"). #strikethrough - deleted text + gsub(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>|\d+)\^(\S+?)\^/, + "\\1#{Mx[:fa_superscript_o]}\\2#{Mx[:fa_superscript_c]}") #superscript single word, watch digit added dob end def bodymarkup(dob) @@ -298,32 +312,34 @@ module SiSU_Syntax # # #numbered (list) level 1 # _# #numbered (list) level 2 dob=dob.dup - if dob.is !~/^(?:meta|comment|code|table)/ + if dob.is !=:meta \ + && dob.is !=:comment \ + && dob.is !=:code \ + && dob.is !=:table line_array=[] word=dob.obj.scan(/\S+|\n/) #unless line =~/^(?:#{Mx[:meta_o]}|%+\s)/ #visit if word word.each do |w| # _ - / # | : ! ^ ~ unless w =~/~\{|\}~|~\[|\]~|^\^~|~\^|\*~\S+|~#|\{t?~|\{table|https?:\/\/\S+/ # do something earlier about table!! - w.gsub!(/\\?~/,"#{Mx[:gl_o]}#126#{Mx[:gl_c]}") #escaped special character + w=w.gsub(/\\?~/,"#{Mx[:gl_o]}#126#{Mx[:gl_c]}") #escaped special character end - w.gsub!(/^\<$/,"#{Mx[:gl_o]}#lt#{Mx[:gl_c]}") #escaped special character - w.gsub!(/^\>$/,"#{Mx[:gl_o]}#gt#{Mx[:gl_c]}") #escaped special character + w=w.gsub(/^\<$/,"#{Mx[:gl_o]}#lt#{Mx[:gl_c]}").gsub(/^\>$/,"#{Mx[:gl_o]}#gt#{Mx[:gl_c]}") #escaped special character line_array << w end dob.obj=line_array.join(' ') dob.obj=dob.obj.strip end - dob.obj.gsub!(/^([*#-.]{1,12})$/,'\1 ~#') #ocn off for these paragraph separators - dob.obj.gsub!(/~\{(.+?)\}~/m,Mx[:en_a_o] + '\1' + Mx[:en_a_c]) - dob.obj.gsub!(/~\[([^*+].+?)\]~/m,Mx[:en_b_o] + '* \1' + Mx[:en_b_c]) #default if markup does not specify - dob.obj.gsub!(/~\[(.+?)\]~/m,Mx[:en_b_o] + '\1' + Mx[:en_b_c]) - if dob.is =='heading' \ + dob.obj=dob.obj.gsub(/^([*#-.]{1,12})$/,'\1 ~#'). #ocn off for these paragraph separators + gsub(/~\{(.+?)\}~/m,Mx[:en_a_o] + '\1' + Mx[:en_a_c]). + gsub(/~\[([^*+].+?)\]~/m,Mx[:en_b_o] + '* \1' + Mx[:en_b_c]). #default if markup does not specify + gsub(/~\[(.+?)\]~/m,Mx[:en_b_o] + '\1' + Mx[:en_b_c]) + if dob.is ==:heading \ and dob.ln ==1 - dob.obj.gsub!(/\s*@title\b/," #{@md.title.full}") - if defined? @md.creator.author \ + dob.obj=dob.obj.gsub(/\s*@title\b/," #{@md.title.full}") + dob.obj=if defined? @md.creator.author \ and @md.creator.author - dob.obj.gsub!(/\s+(?:@creator|@author)/,",#{Mx[:br_line]}#{@md.creator.author}") - else dob.obj.gsub!(/\s+(?:@creator|@author)/,'') + dob.obj.gsub(/\s+(?:@creator|@author)/,",#{Mx[:br_line]}#{@md.creator.author}") + else dob.obj.gsub(/\s+(?:@creator|@author)/,'') end end if defined? @md.title \ @@ -331,114 +347,114 @@ module SiSU_Syntax and defined? @md.title.full \ and defined? @md.creator \ and @md.creator - if dob.is =='heading' - dob.obj.gsub!(/^\s*@title\s*$/,@md.title.full) if dob.lv =~/1/ - if dob.lv =~/[23]/ \ + if dob.is ==:heading + dob.obj=dob.obj.gsub(/^\s*@title\s*$/,@md.title.full) if dob.lv =~/1/ + dob.obj=if dob.lv =~/[23]/ \ and defined? @md.creator.author \ and @md.creator.author - dob.obj.gsub!(/^\s*(?:(by\s+)?(?:@creator|@author))\s*$/,"\\1#{@md.creator.author}") - else dob.obj.gsub!(/^\s*(?:(by\s+)?(?:@creator|@author))\s*$/,'\1') + dob.obj.gsub(/^\s*(?:(by\s+)?(?:@creator|@author))\s*$/,"\\1#{@md.creator.author}") + else dob.obj.gsub(/^\s*(?:(by\s+)?(?:@creator|@author))\s*$/,'\1') end end end - dob.obj.gsub!(/<(https?:\/\/\S+?)>/,'< \1 >') #catch problem markup - dob.obj.gsub!(/<:=(\S+?)>/,'{ c_\1.png 14x14 }image') - dob.obj.gsub!(/<!(\S+)!>/,'<:\1>') #escaped special character - dob.obj.gsub!(/ /,"#{Mx[:nbsp]}") #escaped special character - dob.obj.gsub!(/\\~/,"#{Mx[:gl_o]}#126#{Mx[:gl_c]}") #escaped special character - dob.obj.gsub!(/\\\{/,"#{Mx[:gl_o]}#123#{Mx[:gl_c]}") #escaped special character - dob.obj.gsub!(/\\\}/,"#{Mx[:gl_o]}#125#{Mx[:gl_c]}") #escaped special character - dob.obj.gsub!(/\\\<</,"#{Mx[:gl_o]}#lt#{Mx[:gl_c]}#{Mx[:gl_o]}#lt#{Mx[:gl_c]}") #escaped special character - dob.obj.gsub!(/\\\>>/,"#{Mx[:gl_o]}#gt#{Mx[:gl_c]}#{Mx[:gl_o]}#gt#{Mx[:gl_c]}") #escaped special character - dob.obj.gsub!(/\\\</,"#{Mx[:gl_o]}#lt#{Mx[:gl_c]}") #escaped special character - dob.obj.gsub!(/\\\>/,"#{Mx[:gl_o]}#gt#{Mx[:gl_c]}") #escaped special character - dob.obj.gsub!(/\\\_/,"#{Mx[:gl_o]}#095#{Mx[:gl_c]}") #escaped special character - dob.obj.gsub!(/\\\-/,"#{Mx[:gl_o]}#045#{Mx[:gl_c]}") #escaped special character - dob.obj.gsub!(/\\\+/,"#{Mx[:gl_o]}#043#{Mx[:gl_c]}") #escaped special character - dob.obj.gsub!(/\\\//,"#{Mx[:gl_o]}#047#{Mx[:gl_c]}") #escaped special character - dob.obj.gsub!(/\\\#/,"#{Mx[:gl_o]}#035#{Mx[:gl_c]}") #escaped special character - dob.obj.gsub!(/\\\&/,"#{Mx[:gl_o]}#038#{Mx[:gl_c]}") #& #escaped special character - dob.obj.gsub!(/\\\|/,"#{Mx[:gl_o]}#124#{Mx[:gl_c]}") #not really a sisu special character but made available as possibility - dob.obj.gsub!(/\\\:/,"#{Mx[:gl_o]}#058#{Mx[:gl_c]}") #not really a sisu special character but made available as possibility - dob.obj.gsub!(/\\\!/,"#{Mx[:gl_o]}#033#{Mx[:gl_c]}") #not really a sisu special character but made available as possibility - dob.obj.gsub!(/\\\^/,"#{Mx[:gl_o]}#094#{Mx[:gl_c]}") #not really a sisu special character but made available as possibility - dob.obj.gsub!(/\\\,/,"#{Mx[:gl_o]}#044#{Mx[:gl_c]}") #not really a sisu special character but made available as possibility - dob.obj.gsub!(/\\\\/,"#{Mx[:gl_o]}#092#{Mx[:gl_c]}") #escaped special character - dob.obj.gsub!(/\\\*/,"#{Mx[:gl_o]}#042#{Mx[:gl_c]}") #escaped special character - dob.obj.gsub!(/\\\!/,"#{Mx[:gl_o]}#033#{Mx[:gl_c]}") #escaped special character + dob.obj=dob.obj.gsub(/<(https?:\/\/\S+?)>/,'< \1 >'). #catch problem markup + gsub(/<:=(\S+?)>/,'{ c_\1.png 14x14 }image'). + gsub(/<!(\S+)!>/,'<:\1>'). #escaped special character + gsub(/ /,"#{Mx[:nbsp]}"). #escaped special character + gsub(/\\~/,"#{Mx[:gl_o]}#126#{Mx[:gl_c]}"). #escaped special character + gsub(/\\\{/,"#{Mx[:gl_o]}#123#{Mx[:gl_c]}"). #escaped special character + gsub(/\\\}/,"#{Mx[:gl_o]}#125#{Mx[:gl_c]}"). #escaped special character + gsub(/\\\<</,"#{Mx[:gl_o]}#lt#{Mx[:gl_c]}#{Mx[:gl_o]}#lt#{Mx[:gl_c]}"). #escaped special character + gsub(/\\\>>/,"#{Mx[:gl_o]}#gt#{Mx[:gl_c]}#{Mx[:gl_o]}#gt#{Mx[:gl_c]}"). #escaped special character + gsub(/\\\</,"#{Mx[:gl_o]}#lt#{Mx[:gl_c]}"). #escaped special character + gsub(/\\\>/,"#{Mx[:gl_o]}#gt#{Mx[:gl_c]}"). #escaped special character + gsub(/\\\_/,"#{Mx[:gl_o]}#095#{Mx[:gl_c]}"). #escaped special character + gsub(/\\\-/,"#{Mx[:gl_o]}#045#{Mx[:gl_c]}"). #escaped special character + gsub(/\\\+/,"#{Mx[:gl_o]}#043#{Mx[:gl_c]}"). #escaped special character + gsub(/\\\//,"#{Mx[:gl_o]}#047#{Mx[:gl_c]}"). #escaped special character + gsub(/\\\#/,"#{Mx[:gl_o]}#035#{Mx[:gl_c]}"). #escaped special character + gsub(/\\\&/,"#{Mx[:gl_o]}#038#{Mx[:gl_c]}"). #& #escaped special character + gsub(/\\\|/,"#{Mx[:gl_o]}#124#{Mx[:gl_c]}"). #not really a sisu special character but made available as possibility + gsub(/\\\:/,"#{Mx[:gl_o]}#058#{Mx[:gl_c]}"). #not really a sisu special character but made available as possibility + gsub(/\\\!/,"#{Mx[:gl_o]}#033#{Mx[:gl_c]}"). #not really a sisu special character but made available as possibility + gsub(/\\\^/,"#{Mx[:gl_o]}#094#{Mx[:gl_c]}"). #not really a sisu special character but made available as possibility + gsub(/\\\,/,"#{Mx[:gl_o]}#044#{Mx[:gl_c]}"). #not really a sisu special character but made available as possibility + gsub(/\\\\/,"#{Mx[:gl_o]}#092#{Mx[:gl_c]}"). #escaped special character + gsub(/\\\*/,"#{Mx[:gl_o]}#042#{Mx[:gl_c]}"). #escaped special character + gsub(/\\\!/,"#{Mx[:gl_o]}#033#{Mx[:gl_c]}") #escaped special character if dob.obj=~/(?:https?:|ftp:|\{([^{}]+?)\}(?:#|:|[.]{1,2}\/))\S+/m if dob.obj=~/(?:^|[#{Mx[:gl_c]}#{Mx[:nbsp]} ])\{~\^ (?:.+?)\s*\}(?:(?:https?:|ftp:|:|[.]{1,2}\/)\S+?)\s*#{Mx[:en_a_o]}(.+?)#{Mx[:en_a_c]}/m - dob.obj.gsub!(/(^|[#{Mx[:gl_c]}#{Mx[:nbsp]} ])\{~\^ ([^}]+?)\s*\}((?:https?:|ftp:|:|[.]{1,2}\/)\S+?)\s*#{Mx[:en_a_o]}(.+?)#{Mx[:en_a_c]}/m, + dob.obj=dob.obj.gsub(/(^|[#{Mx[:gl_c]}#{Mx[:nbsp]} ])\{~\^ ([^}]+?)\s*\}((?:https?:|ftp:|:|[.]{1,2}\/)\S+?)\s*#{Mx[:en_a_o]}(.+?)#{Mx[:en_a_c]}/m, "\\1#{Mx[:lnk_o]}\\2#{Mx[:lnk_c]}\\3 #{Mx[:en_a_o]}\\3 \\4#{Mx[:en_a_c]}") # watch end if dob.obj=~/(?:^|[#{Mx[:gl_c]}#{Mx[:nbsp]} ])\{~\^ (?:.+?)\s*\}(?:(?:https?:|ftp:|:|[.]{1,2}\/)\S+?)([;,.]?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m - dob.obj.gsub!(/(^|[#{Mx[:gl_c]}#{Mx[:nbsp]} ])\{~\^ (.+?)\s*\}((?:https?:|ftp:|:|[.]{1,2}\/)\S+?)([;,.]?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m, + dob.obj=dob.obj.gsub(/(^|[#{Mx[:gl_c]}#{Mx[:nbsp]} ])\{~\^ (.+?)\s*\}((?:https?:|ftp:|:|[.]{1,2}\/)\S+?)([;,.]?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m, "\\1#{Mx[:lnk_o]}\\2#{Mx[:lnk_c]}\\3\\4 #{Mx[:en_a_o]}\\3#{Mx[:en_a_c]} ") end - dob.obj.gsub!(/(^|[^#])\{\s*([^{}]+?)\s*\}((?:https?:|:|[.]{2}\/|#)\S+?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}#{Mx[:en_a_o]}#{Mx[:en_b_o]}]|$)/, - "\\1#{Mx[:lnk_o]}\\2#{Mx[:lnk_c]}\\3") #linked (text or image, however text cannot include modified face, e.g. bold, ital, underline) - dob.obj.gsub!(/(^|[#{Mx[:gl_c]}#{Mx[:lnk_c]}#{Mx[:en_a_o]}#{Mx[:en_b_o]}(\s])((?:https?|ftp):\/\/\S+?\.[^>< ]+?)([,.;'"]?)(?=[\s#{Mx[:en_a_c]}#{Mx[:en_b_c]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m, - %{\\1#{Mx[:url_o]}\\2#{Mx[:url_c]}\\3}) - dob.obj.gsub!(/#{Mx[:lnk_c]}#(\S+?[^>< ]+?)([()\[\]]*[,.;:!?'"]{0,2})(?=[\s#{Mx[:en_a_c]}#{Mx[:en_b_c]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m, - %{#{Mx[:lnk_c]}#{Mx[:rel_o]}\\1#{Mx[:rel_c]}\\2}) - dob.obj.gsub!(/#{Mx[:lnk_c]}:(\S+?[^>< ]+?)([()\[\]]*[,.;:!?'"]{0,2})(?=[\s#{Mx[:en_a_c]}#{Mx[:en_b_c]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m, - %{#{Mx[:lnk_c]}#{Mx[:rel_o]}:\\1#{Mx[:rel_c]}\\2}) - dob.obj.gsub!(/#{Mx[:lnk_c]}[.]{2}\/(\S+?[^>< ]+?)([()\[\]]*[,.;:!?'"]{0,2})(?=[\s#{Mx[:en_a_c]}#{Mx[:en_b_c]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m, - %{#{Mx[:lnk_c]}#{Mx[:rel_o]}:\\1#{Mx[:rel_c]}\\2}) + dob.obj=dob.obj.gsub(/(^|[^#])\{\s*([^{}]+?)\s*\}((?:https?:|:|[.]{2}\/|#)\S+?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}#{Mx[:en_a_o]}#{Mx[:en_b_o]}]|$)/, + "\\1#{Mx[:lnk_o]}\\2#{Mx[:lnk_c]}\\3"). #linked (text or image, however text cannot include modified face, e.g. bold, ital, underline) + gsub(/(^|[#{Mx[:gl_c]}#{Mx[:lnk_c]}#{Mx[:en_a_o]}#{Mx[:en_b_o]}(\s])((?:https?|ftp):\/\/\S+?\.[^>< ]+?)([,.;'"]?)(?=[\s#{Mx[:en_a_c]}#{Mx[:en_b_c]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m, + %{\\1#{Mx[:url_o]}\\2#{Mx[:url_c]}\\3}). + gsub(/#{Mx[:lnk_c]}#(\S+?[^>< ]+?)([()\[\]]*[,.;:!?'"]{0,2})(?=[\s#{Mx[:en_a_c]}#{Mx[:en_b_c]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m, + %{#{Mx[:lnk_c]}#{Mx[:rel_o]}\\1#{Mx[:rel_c]}\\2}). + gsub(/#{Mx[:lnk_c]}:(\S+?[^>< ]+?)([()\[\]]*[,.;:!?'"]{0,2})(?=[\s#{Mx[:en_a_c]}#{Mx[:en_b_c]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m, + %{#{Mx[:lnk_c]}#{Mx[:rel_o]}:\\1#{Mx[:rel_c]}\\2}). + gsub(/#{Mx[:lnk_c]}[.]{2}\/(\S+?[^>< ]+?)([()\[\]]*[,.;:!?'"]{0,2})(?=[\s#{Mx[:en_a_c]}#{Mx[:en_b_c]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m, + %{#{Mx[:lnk_c]}#{Mx[:rel_o]}:\\1#{Mx[:rel_c]}\\2}) end if dob.obj=~/_(?:https?|ftp):\S+/m # _http://url #CHECK - dob.obj.gsub!(/(^|[#{Mx[:gl_c]}#{Mx[:lnk_c]}#{Mx[:en_a_o]}#{Mx[:en_b_o]}(\s])(_(?:https?|ftp):\/\/\S+?\.[^>< ]+?)([,.;'"]?)(?=[\s#{Mx[:en_a_c]}#{Mx[:en_b_c]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m, + dob.obj=dob.obj.gsub(/(^|[#{Mx[:gl_c]}#{Mx[:lnk_c]}#{Mx[:en_a_o]}#{Mx[:en_b_o]}(\s])(_(?:https?|ftp):\/\/\S+?\.[^>< ]+?)([,.;'"]?)(?=[\s#{Mx[:en_a_c]}#{Mx[:en_b_c]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m, %{\\1#{Mx[:url_o]}\\2#{Mx[:url_c]}\\3}) end dob=fontface(dob) - dob.obj.gsub!(/<[:e]\s+(.+?)!?>/, - "#{Mx[:en_a_o]}\\1#{Mx[:en_a_c]}") #not tested - dob.obj.gsub!(/^\s*_\*\s*/, - "#{Mx[:gl_bullet]}") #bullets, shortcut - dob.obj.gsub!(/=\{(.+?)\}/, - "#{Mx[:idx_o]}\\1#{Mx[:idx_c]}") - dob.obj.gsub!(/^\s*_([1-9])\*\s*/, - "#{Mx[:pa_o]}:i\\1:\\1#{Mx[:pa_c]}#{Mx[:gl_bullet]}") #bullets, shortcut - dob.obj.gsub!(/^\s*_([1-9])\s+/, - "#{Mx[:pa_o]}:i\\1:\\1#{Mx[:pa_c]}") #indent - dob.obj.gsub!(/^\s*_([1-9])!\s+(.+?)\s*$/, - "#{Mx[:pa_o]}:i\\1:\\1#{Mx[:pa_c]}#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]} ") #indent bold - dob.obj.gsub!(/^\s*__([1-9])\s+/, - "#{Mx[:pa_o]}:i0:\\1#{Mx[:pa_c]}") #hang - dob.obj.gsub!(/^\s*__([1-9])!\s+(.+?)\s*$/, - "#{Mx[:pa_o]}:i0:\\1#{Mx[:pa_c]}#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]} ") #hangdef - dob.obj.gsub!(/^\s*_([0-9])_([0-9])\s+/, - "#{Mx[:pa_o]}:i\\1:\\2#{Mx[:pa_c]}") #hang - dob.obj.gsub!(/^\s*_([0-9])_([0-9])!\s+(.+?)\s*$/, - "#{Mx[:pa_o]}:i\\1:\\2#{Mx[:pa_c]}#{Mx[:fa_bold_o]}\\3#{Mx[:fa_bold_c]} ") #hangdef - dob.obj.gsub!(/<:hi>/,"#{Mx[:fa_hilite_o]}") #'<span style="background-color: rgb(255,240,196)">') # bright yellow rgb(255,255,0) pale yellow rgb(255,255,200) - dob.obj.gsub!(/<:\/hi>/,"#{Mx[:fa_hilite_c]}") #'</span>') - dob.obj.gsub!(/(#{Mx[:gr_o]}verse#{Mx[:gr_c]}.+)/m,"\\1\n") - dob.obj.gsub!(/[ ]+($)/,'\1') - dob.obj.gsub!(/\{\s*(.+?)\s*\}(https?:\S+?)([;,.]?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}#{Mx[:en_a_o]}#{Mx[:en_b_o]}]|$)/, - "#{Mx[:lnk_o]}\\1#{Mx[:lnk_c]}#{Mx[:url_o]}\\2#{Mx[:url_c]}\\3") #any remaining linked text or image - dob.obj.gsub!(/\{\s*(.+?)\s*\}(#{Mx[:url_o]}\S+?#{Mx[:url_c]})/, - "#{Mx[:lnk_o]}\\1#{Mx[:lnk_c]}\\2") #any remaining linked text or image - dob.obj.gsub!(/(^|\s)([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)/,"\\1#{Mx[:url_o]}\\2#{Mx[:url_c]}") - dob.obj.gsub!(/(^|[ ])\{\s*(.+?)\s*\}(\S+?)([;,.]?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}#{Mx[:en_a_o]}#{Mx[:en_b_o]}]|$)/, - "\\1#{Mx[:lnk_o]}\\2#{Mx[:lnk_c]}\\3\\4") #any remaining linked text or image - dob.obj.gsub!(/\{\s*(.+?)\s*\}#([a-zA-Z0-9][a-zA-Z0-9_-]*)([;,.]?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}#{Mx[:en_a_o]}#{Mx[:en_b_o]}]|$)/, - "#{Mx[:lnk_o]}\\1#{Mx[:lnk_c]}#{Mx[:rel_o]}\\2#{Mx[:rel_c]}\\3") #any remaining linked text or image, check need - dob.obj.gsub!(/\{\s*(.+?)\s*\}(#{Mx[:rel_o]}\S+?#{Mx[:rel_c]})/, - "#{Mx[:lnk_o]}\\1#{Mx[:lnk_c]}\\2") #any remaining linked text or image, check need - dob.obj.gsub!(/\{\s*(.+?)\s*\}(image)/, - "#{Mx[:lnk_o]}\\1#{Mx[:lnk_c]}\\2") #linked image - elsif dob.is=='table' + dob.obj=dob.obj.gsub(/<[:e]\s+(.+?)!?>/, + "#{Mx[:en_a_o]}\\1#{Mx[:en_a_c]}"). #not tested + gsub(/^\s*_\*\s*/, + "#{Mx[:gl_bullet]}"). #bullets, shortcut + gsub(/=\{(.+?)\}/, + "#{Mx[:idx_o]}\\1#{Mx[:idx_c]}"). + gsub(/^\s*_([1-9])\*\s*/, + "#{Mx[:pa_o]}:i\\1:\\1#{Mx[:pa_c]}#{Mx[:gl_bullet]}"). #bullets, shortcut + gsub(/^\s*_([1-9])\s+/, + "#{Mx[:pa_o]}:i\\1:\\1#{Mx[:pa_c]}"). #indent + gsub(/^\s*_([1-9])!\s+(.+?)\s*$/, + "#{Mx[:pa_o]}:i\\1:\\1#{Mx[:pa_c]}#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]} "). #indent bold + gsub(/^\s*__([1-9])\s+/, + "#{Mx[:pa_o]}:i0:\\1#{Mx[:pa_c]}"). #hang + gsub(/^\s*__([1-9])!\s+(.+?)\s*$/, + "#{Mx[:pa_o]}:i0:\\1#{Mx[:pa_c]}#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]} "). #hangdef + gsub(/^\s*_([0-9])_([0-9])\s+/, + "#{Mx[:pa_o]}:i\\1:\\2#{Mx[:pa_c]}"). #hang + gsub(/^\s*_([0-9])_([0-9])!\s+(.+?)\s*$/, + "#{Mx[:pa_o]}:i\\1:\\2#{Mx[:pa_c]}#{Mx[:fa_bold_o]}\\3#{Mx[:fa_bold_c]} "). #hangdef + gsub(/<:hi>/,"#{Mx[:fa_hilite_o]}"). #'<span style="background-color: rgb(255,240,196)">') # bright yellow rgb(255,255,0) pale yellow rgb(255,255,200) + gsub(/<:\/hi>/,"#{Mx[:fa_hilite_c]}"). #'</span>') + gsub(/(#{Mx[:gr_o]}verse#{Mx[:gr_c]}.+)/m,"\\1\n"). + gsub(/[ ]+($)/,'\1'). + gsub(/\{\s*(.+?)\s*\}(https?:\S+?)([;,.]?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}#{Mx[:en_a_o]}#{Mx[:en_b_o]}]|$)/, + "#{Mx[:lnk_o]}\\1#{Mx[:lnk_c]}#{Mx[:url_o]}\\2#{Mx[:url_c]}\\3"). #any remaining linked text or image + gsub(/\{\s*(.+?)\s*\}(#{Mx[:url_o]}\S+?#{Mx[:url_c]})/, + "#{Mx[:lnk_o]}\\1#{Mx[:lnk_c]}\\2"). #any remaining linked text or image + gsub(/(^|\s)([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)/,"\\1#{Mx[:url_o]}\\2#{Mx[:url_c]}"). + gsub(/(^|[ ])\{\s*(.+?)\s*\}(\S+?)([;,.]?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}#{Mx[:en_a_o]}#{Mx[:en_b_o]}]|$)/, + "\\1#{Mx[:lnk_o]}\\2#{Mx[:lnk_c]}\\3\\4"). #any remaining linked text or image + gsub(/\{\s*(.+?)\s*\}#([a-zA-Z0-9][a-zA-Z0-9_-]*)([;,.]?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}#{Mx[:en_a_o]}#{Mx[:en_b_o]}]|$)/, + "#{Mx[:lnk_o]}\\1#{Mx[:lnk_c]}#{Mx[:rel_o]}\\2#{Mx[:rel_c]}\\3"). #any remaining linked text or image, check need + gsub(/\{\s*(.+?)\s*\}(#{Mx[:rel_o]}\S+?#{Mx[:rel_c]})/, + "#{Mx[:lnk_o]}\\1#{Mx[:lnk_c]}\\2"). #any remaining linked text or image, check need + gsub(/\{\s*(.+?)\s*\}(image)/, + "#{Mx[:lnk_o]}\\1#{Mx[:lnk_c]}\\2") #linked image + elsif dob.is==:table dob=fontface(dob) - elsif dob.is =='code' - dob.obj.gsub!(/#{Mx[:meta_o]}(\S+?)#{Mx[:meta_c]}\s*/,'@\1: ') - dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s)<(br(?: \/)?)>([\s,.]|$)/,'\1<\2>\3') #convert <br> <br /> back, clumsy + elsif dob.is ==:code + dob.obj=dob.obj.gsub(/#{Mx[:meta_o]}(\S+?)#{Mx[:meta_c]}\s*/,'@\1: '). + gsub(/(^|#{Mx[:gl_c]}|\s)<(br(?: \/)?)>([\s,.]|$)/,'\1<\2>\3') #convert <br> <br /> back, clumsy if dob.number_ codeline=[] ln=1 dob.obj.split(/#{Mx[:gr_o]}codeline#{Mx[:gr_c]}|<br(?: \/)?>|\n/).each_with_index do |cl,i| unless i == 0 - cl.gsub!(Mx[:br_nl],'') + cl=cl.gsub(Mx[:br_nl],'') w=3-ln.to_s.length cl = "#{ln}#{Mx[:nbsp]*w}#{Mx[:vline]}#{cl}#{Mx[:br_nl]}" ln +=1 @@ -448,7 +464,7 @@ module SiSU_Syntax codeline= codeline.join("") dob.obj=codeline else - dob.obj.gsub!(/#{Mx[:gr_o]}codeline#{Mx[:gr_c]}/,"\n") + dob.obj=dob.obj.gsub(/#{Mx[:gr_o]}codeline#{Mx[:gr_c]}/,"\n") end dob else # @\S+?: @@ -474,62 +490,62 @@ module SiSU_Syntax # +2 <!i2!> puts 'tech' @data.each do |line| - line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)e\{(.+?)\}e/, - "\\1#{@emph[:o]}\\2#{@emph[:c]}") #emphasis - line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)b\{(.+?)\}b/, - "\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}") #bold - line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)u\{(.+?)\}u/, - "\\1#{Mx[:fa_underscore_o]}\\2#{Mx[:fa_underscore_c]}") #underscore - line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)c\{(.+?)\}c/, - "\\1#{Mx[:fa_cite_o]}\\2#{Mx[:fa_c_o]}cite#{Mx[:fa_c]}") #cite - line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)i\{(.+?)\}i/, - "\\1#{Mx[:fa_italics_o]}\\2#{Mx[:fa_italics_c]}") #italics - line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)!\{(.+?)\}!/, - "\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}") #bold - line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)\*\{(.+?)\}\*/, - "\\1#{@emph[:o]}\\2#{@emph[:c]}") #emphasis - line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)_\{(.+?)\}_/, - "\\1#{Mx[:fa_underscore_o]}\\2#{Mx[:fa_underscore_c]}") #underscore - line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\(|\>)\/\{(.+?)\}\//, - "\\1#{Mx[:fa_italics_o]}\\2#{Mx[:fa_italics_c]}") #italics - line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\"\{(.+?)\}\"/, - "\\1#{Mx[:fa_cite_o]}\\2#{Mx[:fa_c_o]}cite#{Mx[:fa_c]}") - line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\^\{(.+?)\}\^/, - "\\1#{Mx[:fa_superscript_o]}\\2#{Mx[:fa_superscript_c]}") - line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)9\{(.+?)\}9/, - "\\1#{Mx[:fa_superscript_o]}\\2#{Mx[:fa_superscript_c]}") - line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>),\{(.+?)\},/, - "\\1#{Mx[:fa_subscript_o]}\\2#{Mx[:fa_subscript_c]}") - line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)6\{(.+?)\}6/, - "\\1#{Mx[:fa_subscript_o]}\\2#{Mx[:fa_subscript_c]}") - line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\+\{(.+?)\}\+/, - "\\1#{Mx[:fa_insert_o]}\\2#{Mx[:fa_insert_c]}") - line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)v\{(.+?)\}v/, - "\\1#{Mx[:fa_insert_o]}\\2#{Mx[:fa_insert_c]}") - line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)-\{(.+?)\}-/, - "\\1#{Mx[:fa_strike_o]}\\2#{Mx[:fa_strike_c]}") - line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)x\{(.+?)\}x/, - "\\1#{Mx[:fa_strike_o]}\\2#{Mx[:fa_strike_c]}") - line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\*(\S+?)\*/, - "\\1#{@emph[:o]}\\2#{@emph[:c]}") #emphasise single word, watch - line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\!(\S+?)\!/, - "\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}") #bold single word, watch - line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\/([\(\)a-zA-Z0-9']+?)\/([ ,.;:'"~$]|[^a-zA-Z0-9])/, - "\\1#{Mx[:fa_italics_o]}\\2#{Mx[:fa_italics_c]}\\3") #italics single word, watch - line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)_(\S+?)_/, - "\\1#{Mx[:fa_underscore_o]}\\2#{Mx[:fa_underscore_c]}") #underscore single word, watch - line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\^(\S+?)\^/, - "\\1#{Mx[:fa_superscript_o]}\\2#{Mx[:fa_superscript_c]}") #check #superscript single word, watch digit added - line.gsub!(/^\s*_\([1-9]\)\(\*\+\)\s*/, - "#{Mx[:pa_o]}:i\\1#{Mx[:pa_c]}#{Mx[:fa_o]}\\2#{Mx[:fa_c_o]}") #bullets, shortcut - line.gsub!(/^\s*_\([1-9]\)\s+/, - "#{Mx[:pa_o]}:i\\1#{Mx[:pa_c]}") #watch - line.gsub!(/^\s*__\([1-9]\)\s+/, - "#{Mx[:pa_o]}:h\\1#{Mx[:pa_c]}") #watch - #line.gsub!(/^\s*__\([1-9]\)!\s+/, - # "#{Mx[:pa_o]}:hd\\1#{Mx[:pa_c]}") #watch - line.gsub!(/#{Mx[:br_line]}\s*_[12]\s+/, - "#{Mx[:br_line]} ") #indent used in endnotes, not implemented, replace when ready with: line.gsub!(/(?:<br>|<br \/>)\s*_([12])\s+/,'<br><:i\1> ') + line=line.gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)e\{(.+?)\}e/, + "\\1#{@emph[:o]}\\2#{@emph[:c]}"). #emphasis + gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)b\{(.+?)\}b/, + "\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}"). #bold + gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)u\{(.+?)\}u/, + "\\1#{Mx[:fa_underscore_o]}\\2#{Mx[:fa_underscore_c]}"). #underscore + gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)c\{(.+?)\}c/, + "\\1#{Mx[:fa_cite_o]}\\2#{Mx[:fa_c_o]}cite#{Mx[:fa_c]}"). #cite + gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)i\{(.+?)\}i/, + "\\1#{Mx[:fa_italics_o]}\\2#{Mx[:fa_italics_c]}"). #italics + gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)!\{(.+?)\}!/, + "\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}"). #bold + gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)\*\{(.+?)\}\*/, + "\\1#{@emph[:o]}\\2#{@emph[:c]}"). #emphasis + gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)_\{(.+?)\}_/, + "\\1#{Mx[:fa_underscore_o]}\\2#{Mx[:fa_underscore_c]}"). #underscore + gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\(|\>)\/\{(.+?)\}\//, + "\\1#{Mx[:fa_italics_o]}\\2#{Mx[:fa_italics_c]}"). #italics + gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\"\{(.+?)\}\"/, + "\\1#{Mx[:fa_cite_o]}\\2#{Mx[:fa_c_o]}cite#{Mx[:fa_c]}"). + gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\^\{(.+?)\}\^/, + "\\1#{Mx[:fa_superscript_o]}\\2#{Mx[:fa_superscript_c]}"). + gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)9\{(.+?)\}9/, + "\\1#{Mx[:fa_superscript_o]}\\2#{Mx[:fa_superscript_c]}"). + gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>),\{(.+?)\},/, + "\\1#{Mx[:fa_subscript_o]}\\2#{Mx[:fa_subscript_c]}"). + gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)6\{(.+?)\}6/, + "\\1#{Mx[:fa_subscript_o]}\\2#{Mx[:fa_subscript_c]}"). + gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\+\{(.+?)\}\+/, + "\\1#{Mx[:fa_insert_o]}\\2#{Mx[:fa_insert_c]}"). + gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)v\{(.+?)\}v/, + "\\1#{Mx[:fa_insert_o]}\\2#{Mx[:fa_insert_c]}"). + gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)-\{(.+?)\}-/, + "\\1#{Mx[:fa_strike_o]}\\2#{Mx[:fa_strike_c]}"). + gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)x\{(.+?)\}x/, + "\\1#{Mx[:fa_strike_o]}\\2#{Mx[:fa_strike_c]}"). + gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\*(\S+?)\*/, + "\\1#{@emph[:o]}\\2#{@emph[:c]}"). #emphasise single word, watch + gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\!(\S+?)\!/, + "\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}"). #bold single word, watch + gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\/([\(\)a-zA-Z0-9']+?)\/([ ,.;:'"~$]|[^a-zA-Z0-9])/, + "\\1#{Mx[:fa_italics_o]}\\2#{Mx[:fa_italics_c]}\\3"). #italics single word, watch + gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)_(\S+?)_/, + "\\1#{Mx[:fa_underscore_o]}\\2#{Mx[:fa_underscore_c]}"). #underscore single word, watch + gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\^(\S+?)\^/, + "\\1#{Mx[:fa_superscript_o]}\\2#{Mx[:fa_superscript_c]}"). #check #superscript single word, watch digit added + gsub(/^\s*_\([1-9]\)\(\*\+\)\s*/, + "#{Mx[:pa_o]}:i\\1#{Mx[:pa_c]}#{Mx[:fa_o]}\\2#{Mx[:fa_c_o]}"). #bullets, shortcut + gsub(/^\s*_\([1-9]\)\s+/, + "#{Mx[:pa_o]}:i\\1#{Mx[:pa_c]}"). #watch + gsub(/^\s*__\([1-9]\)\s+/, + "#{Mx[:pa_o]}:h\\1#{Mx[:pa_c]}"). #watch + #line.gsub(/^\s*__\([1-9]\)!\s+/, + # "#{Mx[:pa_o]}:hd\\1#{Mx[:pa_c]}"). #watch + gsub(/#{Mx[:br_line]}\s*_[12]\s+/, + "#{Mx[:br_line]} ") #indent used in endnotes, not implemented, replace when ready with: line.gsub(/(?:<br>|<br \/>)\s*_([12])\s+/,'<br><:i\1> ') end @data end diff --git a/lib/sisu/v3/db_columns.rb b/lib/sisu/v3/db_columns.rb index 10b9635f..cf4ba9c7 100644 --- a/lib/sisu/v3/db_columns.rb +++ b/lib/sisu/v3/db_columns.rb @@ -57,13 +57,13 @@ sqlite =end -module SiSU_DB_columns +module SiSU_DbColumns require_relative 'sysenv' # sysenv.rb require_relative 'db_sqltxt' # db_sqltxt.rb - class Columns < SiSU_DB_text::Prepare + class Columns < SiSU_DbText::Prepare def initialize(md=nil) @md=md - @db=SiSU_Env::Info_db.new #watch + @db=SiSU_Env::InfoDb.new #watch @lang ||=SiSU_i18n::Languages.new if defined? md.opt.mod \ and md.opt.mod.inspect=~/import|update/ \ @@ -109,7 +109,7 @@ module SiSU_DB_columns t=if defined? @md.title.full \ and @md.title.full=~/\S+/ txt=@md.title.full - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -131,7 +131,7 @@ module SiSU_DB_columns t=if defined? @md.title.main \ and @md.title.main=~/\S+/ txt=@md.title.main - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -153,7 +153,7 @@ module SiSU_DB_columns t=if defined? @md.title.sub \ and @md.title.sub=~/\S+/ txt=@md.title.sub - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -175,7 +175,7 @@ module SiSU_DB_columns t=if defined? @md.title.short \ and @md.title.short=~/\S+/ txt=@md.title.short - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -197,7 +197,7 @@ module SiSU_DB_columns t=if defined? @md.title.edition \ and @md.title.edition=~/\S+/ txt=@md.title.edition - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -219,7 +219,7 @@ module SiSU_DB_columns t=if defined? @md.title.note \ and @md.title.note=~/\S+/ txt=@md.title.note - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -240,7 +240,7 @@ module SiSU_DB_columns def tuple t=if @lang.list[@md.opt.lng][:n] txt=@lang.list[@md.opt.lng][:n] - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -262,7 +262,7 @@ module SiSU_DB_columns t=if defined? @md.opt.lng \ and @md.opt.lng=~/\S+/ txt=@md.opt.lng - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -302,8 +302,8 @@ module SiSU_DB_columns @md.creator.author_detail.each do |h| txt=txt + %{#{h[:the]}, #{h[:others]}; } end - txt.gsub!(/[;, ]+\s*$/,'') - special_character_escape(txt) + txt=txt.gsub(/[;, ]+\s*$/,'') + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -325,7 +325,7 @@ module SiSU_DB_columns t=if defined? @md.creator.author_hon \ and @md.creator.author_hon=~/\S+/ txt=@md.creator.author_hon - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -347,7 +347,7 @@ module SiSU_DB_columns t=if defined? @md.creator.author_nationality_detail \ and @md.creator.author_nationality=~/\S+/ txt=@md.creator.author_nationality_detail - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -374,8 +374,8 @@ module SiSU_DB_columns @md.creator.editor_detail.each do |h| txt=txt + %{#{h[:the]}, #{h[:others]}; } end - txt.gsub!(/[;, ]+\s*$/,'') - special_character_escape(txt) + txt=txt.gsub(/[;, ]+\s*$/,'') + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -402,8 +402,8 @@ module SiSU_DB_columns @md.creator.contributor_detail.each do |h| txt=txt + %{#{h[:the]}, #{h[:others]}; } end - txt.gsub!(/[;, ]+\s*$/,'') - special_character_escape(txt) + txt=txt.gsub(/[;, ]+\s*$/,'') + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -430,8 +430,8 @@ module SiSU_DB_columns @md.creator.illustrator_detail.each do |h| txt=txt + %{#{h[:the]}, #{h[:others]}; } end - txt.gsub!(/[;, ]+\s*$/,'') - special_character_escape(txt) + txt=txt.gsub(/[;, ]+\s*$/,'') + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -458,8 +458,8 @@ module SiSU_DB_columns @md.creator.photographer_detail.each do |h| txt=txt + %{#{h[:the]}, #{h[:others]}; } end - txt.gsub!(/[;, ]+\s*$/,'') - special_character_escape(txt) + txt=txt.gsub(/[;, ]+\s*$/,'') + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -485,8 +485,8 @@ module SiSU_DB_columns @md.creator.translator_detail.each do |h| txt=txt + %{#{h[:the]}, #{h[:others]}; } end - txt.gsub!(/[;, ]+\s*$/,'') - special_character_escape(txt) + txt=txt.gsub(/[;, ]+\s*$/,'') + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -513,8 +513,8 @@ module SiSU_DB_columns @md.creator.prepared_by_detail.each do |h| txt=txt + %{#{h[:the]}, #{h[:others]}; } end - txt.gsub!(/[;, ]+\s*$/,'') - special_character_escape(txt) + txt=txt.gsub(/[;, ]+\s*$/,'') + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -541,8 +541,8 @@ module SiSU_DB_columns @md.creator.digitized_by_detail.each do |h| txt=txt + %{#{h[:the]}, #{h[:others]}; } end - txt.gsub!(/[;, ]+\s*$/,'') - special_character_escape(txt) + txt=txt.gsub(/[;, ]+\s*$/,'') + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -569,8 +569,8 @@ module SiSU_DB_columns @md.creator.audio_detail.each do |h| txt=txt + %{#{h[:the]}, #{h[:others]}; } end - txt.gsub!(/[;, ]+\s*$/,'') - special_character_escape(txt) + txt=txt.gsub(/[;, ]+\s*$/,'') + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -596,8 +596,8 @@ module SiSU_DB_columns @md.creator.video_detail.each do |h| txt=txt + %{#{h[:the]}, #{h[:others]}; } end - txt.gsub!(/[;, ]+\s*$/,'') - special_character_escape(txt) + txt=txt.gsub(/[;, ]+\s*$/,'') + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -630,7 +630,7 @@ module SiSU_DB_columns def tuple t=if @lang.list[@md.opt.lng][:n] txt=@lang.list[@md.opt.lng][:n] - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -653,7 +653,7 @@ module SiSU_DB_columns t=if defined? @md.opt.lng \ and @md.opt.lng=~/\S+/ txt=@md.opt.lng - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -675,7 +675,7 @@ module SiSU_DB_columns t=if defined? @md.language.original \ and @md.language.original=~/\S+/ txt=@md.language.original - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -697,7 +697,7 @@ module SiSU_DB_columns t=if defined? @md.language.original_char \ and @md.language.original_char=~/\S+/ txt=@md.language.original_char - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -733,7 +733,7 @@ module SiSU_DB_columns t=if defined? @md.date.added_to_site \ and @md.date.added_to_site=~/\S+/ txt=@md.date.added_to_site - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -755,7 +755,7 @@ module SiSU_DB_columns t=if defined? @md.date.available \ and @md.date.available=~/\S+/ txt=@md.date.available - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -777,7 +777,7 @@ module SiSU_DB_columns t=if defined? @md.date.created \ and @md.date.created=~/\S+/ txt=@md.date.created - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -799,7 +799,7 @@ module SiSU_DB_columns t=if defined? @md.date.issued \ and @md.date.issued=~/\S+/ txt=@md.date.issued - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -821,7 +821,7 @@ module SiSU_DB_columns t=if defined? @md.date.modified \ and @md.date.modified=~/\S+/ txt=@md.date.modified - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -843,7 +843,7 @@ module SiSU_DB_columns t=if defined? @md.date.published \ and @md.date.published=~/\S+/ txt=@md.date.published - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -865,7 +865,7 @@ module SiSU_DB_columns t=if defined? @md.date.valid \ and @md.date.valid=~/\S+/ txt=@md.date.valid - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -887,7 +887,7 @@ module SiSU_DB_columns t=if defined? @md.date.translated \ and @md.date.translated=~/\S+/ txt=@md.date.translated - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -909,7 +909,7 @@ module SiSU_DB_columns t=if defined? @md.date.original_publication \ and @md.date.original_publication=~/\S+/ txt=@md.date.original_publication - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -932,7 +932,7 @@ module SiSU_DB_columns t=if defined? @md.generated \ and @md.generated.to_s=~/\S+/ txt=@md.generated.to_s - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -958,7 +958,7 @@ module SiSU_DB_columns t=if defined? @md.publisher \ and @md.publisher=~/\S+/ txt=@md.publisher - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -980,7 +980,7 @@ module SiSU_DB_columns # t=if defined? @md.current.publisher \ # and @md.current.publisher=~/\S+/ # txt=@md.current.publisher -# special_character_escape(txt) +# txt=special_character_escape(txt) # "'#{txt}', " # end # end @@ -1011,7 +1011,7 @@ module SiSU_DB_columns t=if defined? @md.original.publisher \ and @md.original.publisher=~/\S+/ txt=@md.original.publisher - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1033,7 +1033,7 @@ module SiSU_DB_columns t=if defined? @md.original.language \ and @md.original.language=~/\S+/ txt=@md.original.language - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1055,7 +1055,7 @@ module SiSU_DB_columns t=if defined? @md.original.language_char \ and @md.original.language_char=~/\S+/ txt=@md.original.language_char - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1077,7 +1077,7 @@ module SiSU_DB_columns t=if defined? @md.original.source \ and @md.original.source=~/\S+/ txt=@md.original.source - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1099,7 +1099,7 @@ module SiSU_DB_columns t=if defined? @md.original.institution \ and @md.original.institution=~/\S+/ txt=@md.original.institution - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1121,7 +1121,7 @@ module SiSU_DB_columns t=if defined? @md.original.nationality \ and @md.original.nationality=~/\S+/ txt=@md.original.nationality - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1158,7 +1158,7 @@ module SiSU_DB_columns t=if defined? @md.rights.all \ and @md.rights.all=~/\S+/ txt=@md.rights.all - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1180,7 +1180,7 @@ module SiSU_DB_columns t=if defined? @md.rights.copyright_text \ and @md.rights.copyright_text=~/\S+/ txt=@md.rights.copyright_text - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1202,7 +1202,7 @@ module SiSU_DB_columns t=if defined? @md.rights.copyright_translation \ and @md.rights.copyright_translation=~/\S+/ txt=@md.rights.copyright_translation - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1224,7 +1224,7 @@ module SiSU_DB_columns t=if defined? @md.rights.copyright_illustrations \ and @md.rights.copyright_illustrations=~/\S+/ txt=@md.rights.copyright_illustrations - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1246,7 +1246,7 @@ module SiSU_DB_columns t=if defined? @md.rights.copyright_photographs \ and @md.rights.copyright_photographs=~/\S+/ txt=@md.rights.copyright_photographs - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1268,7 +1268,7 @@ module SiSU_DB_columns t=if defined? @md.rights.copyright_preparation \ and @md.rights.copyright_preparation=~/\S+/ txt=@md.rights.copyright_preparation - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1290,7 +1290,7 @@ module SiSU_DB_columns t=if defined? @md.rights.copyright_digitization \ and @md.rights.copyright_digitization=~/\S+/ txt=@md.rights.copyright_digitization - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1312,7 +1312,7 @@ module SiSU_DB_columns t=if defined? @md.rights.copyright_audio \ and @md.rights.copyright_audio=~/\S+/ txt=@md.rights.copyright_audio - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1334,7 +1334,7 @@ module SiSU_DB_columns t=if defined? @md.rights.copyright_video \ and @md.rights.copyright_video=~/\S+/ txt=@md.rights.copyright_video - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1356,7 +1356,7 @@ module SiSU_DB_columns t=if defined? @md.rights.license \ and @md.rights.license=~/\S+/ txt=@md.rights.license - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1394,7 +1394,7 @@ module SiSU_DB_columns t=if defined? @md.classify.topic_register \ and @md.classify.topic_register=~/\S+/ txt=@md.classify.topic_register - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1416,7 +1416,7 @@ module SiSU_DB_columns t=if defined? @md.classify.subject \ and @md.classify.subject=~/\S+/ txt=@md.classify.subject - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1438,7 +1438,7 @@ module SiSU_DB_columns t=if defined? @md.classify.type \ and @md.classify.type=~/\S+/ txt=@md.classify.type - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1460,7 +1460,7 @@ module SiSU_DB_columns t=if defined? @md.classify.loc \ and @md.classify.loc=~/\S+/ txt=@md.classify.loc - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1482,7 +1482,7 @@ module SiSU_DB_columns t=if defined? @md.classify.dewey \ and @md.classify.dewey=~/\S+/ txt=@md.classify.dewey - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1504,7 +1504,7 @@ module SiSU_DB_columns t=if defined? @md.classify.oclc \ and @md.classify.oclc=~/\S+/ txt=@md.classify.oclc - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1526,7 +1526,7 @@ module SiSU_DB_columns t=if defined? @md.classify.pg \ and @md.classify.pg=~/\S+/ txt=@md.classify.pg - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1548,7 +1548,7 @@ module SiSU_DB_columns t=if defined? @md.classify.isbn \ and @md.classify.isbn=~/\S+/ txt=@md.classify.isbn - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1570,7 +1570,7 @@ module SiSU_DB_columns t=if defined? @md.classify.format \ and @md.classify.format=~/\S+/ txt=@md.classify.format - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1592,7 +1592,7 @@ module SiSU_DB_columns t=if defined? @md.classify.identifier \ and @md.classify.identifier=~/\S+/ txt=@md.classify.identifier - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1614,7 +1614,7 @@ module SiSU_DB_columns t=if defined? @md.classify.relation \ and @md.classify.relation=~/\S+/ txt=@md.classify.relation - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1636,7 +1636,7 @@ module SiSU_DB_columns t=if defined? @md.classify.coverage \ and @md.classify.coverage=~/\S+/ txt=@md.classify.coverage - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1658,7 +1658,7 @@ module SiSU_DB_columns t=if defined? @md.classify.keywords \ and @md.classify.keywords=~/\S+/ txt=@md.classify.keywords - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1692,7 +1692,7 @@ module SiSU_DB_columns t=if defined? @md.notes.abstract \ and @md.notes.abstract=~/\S+/ txt=@md.notes.abstract - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1714,7 +1714,7 @@ module SiSU_DB_columns t=if defined? @md.notes.comment \ and @md.notes.comment=~/\S+/ txt=@md.notes.comment - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1736,7 +1736,7 @@ module SiSU_DB_columns t=if defined? @md.notes.description \ and @md.notes.description=~/\S+/ txt=@md.notes.description - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1758,7 +1758,7 @@ module SiSU_DB_columns t=if defined? @md.notes.history \ and @md.notes.history=~/\S+/ txt=@md.notes.history - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1780,7 +1780,7 @@ module SiSU_DB_columns t=if defined? @md.notes.prefix \ and @md.notes.prefix=~/\S+/ txt=@md.notes.prefix - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1802,7 +1802,7 @@ module SiSU_DB_columns t=if defined? @md.notes.prefix_a \ and @md.notes.prefix_a=~/\S+/ txt=@md.notes.prefix_a - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1824,7 +1824,7 @@ module SiSU_DB_columns t=if defined? @md.notes.prefix_b \ and @md.notes.prefix_b=~/\S+/ txt=@md.notes.prefix_b - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1846,7 +1846,7 @@ module SiSU_DB_columns t=if defined? @md.notes.suffix \ and @md.notes.suffix=~/\S+/ txt=@md.notes.suffix - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1871,7 +1871,7 @@ module SiSU_DB_columns t=if defined? @md.fns \ and @md.fns=~/\S+/ txt=@md.fns - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1916,7 +1916,7 @@ module SiSU_DB_columns t=if defined? @md.filesize \ and @md.filesize=~/\S+/ txt=@md.filesize - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1938,7 +1938,7 @@ module SiSU_DB_columns t=if defined? @md.wc_words \ and @md.wc_words=~/\S+/ txt=@md.wc_words - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -2006,7 +2006,7 @@ module SiSU_DB_columns t=if defined? @md.skin_name \ and @md.skin_name=~/\S+/ txt=@md.skin_name - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -2029,7 +2029,7 @@ module SiSU_DB_columns and @md.dgst_skin.class==Array \ and @md.dgst_skin[1]=~/\S+/ txt=@md.dgst_skin[1] - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -2051,7 +2051,7 @@ module SiSU_DB_columns t=if defined? @md.skin \ and @md.skin=~/\S+/ txt=@md.skin - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -2074,7 +2074,7 @@ module SiSU_DB_columns t=if defined? @md.links \ and @md.links=~/\S+/ txt=@md.links - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -2084,7 +2084,7 @@ module SiSU_DB_columns self end end - class Column_size + class ColumnSize def document_clean # restriction not necessary 60000 end diff --git a/lib/sisu/v3/db_create.rb b/lib/sisu/v3/db_create.rb index 71d0ce09..627f0ea5 100644 --- a/lib/sisu/v3/db_create.rb +++ b/lib/sisu/v3/db_create.rb @@ -57,18 +57,18 @@ sqlite =end -module SiSU_DB_create +module SiSU_DbCreate require_relative 'db_columns' # db_columns.rb - class Create < SiSU_DB_columns::Columns + class Create < SiSU_DbColumns::Columns require_relative 'sysenv' # sysenv.rb @@dl=nil def initialize(opt,conn,file,sql_type='pg') @opt,@conn,@file,@sql_type=opt,conn,file,sql_type @cX=SiSU_Screen::Ansi.new(@opt.cmd).cX @comment=(@sql_type=='pg') \ - ? (Comment.new(@conn,@sql_type)) + ? (SiSU_DbCreate::Comment.new(@conn,@sql_type)) : nil - @@dl ||=SiSU_Env::Info_env.new.digest.length + @@dl ||=SiSU_Env::InfoEnv.new.digest.length end def available DBI.available_drivers.each do |driver| @@ -79,15 +79,15 @@ module SiSU_DB_create end end def create_db - @env=SiSU_Env::Info_env.new(@opt.fns) + @env=SiSU_Env::InfoEnv.new(@opt.fns) tell=(@sql_type=='sqlite') \ - ? SiSU_Screen::Ansi.new(@opt.cmd,'invert','Create Sqlite db tables in:',%{"#{@env.path.output}/sisu_sqlite.db"}) + ? SiSU_Screen::Ansi.new(@opt.cmd,'invert','Create Sqlite db tables in:',%{"#{@file}"}) : SiSU_Screen::Ansi.new(@opt.cmd,'invert','Create PG db tables in:',%{"#{Db[:name_prefix]}#{@env.path.stub_pwd}"}) - tell.colorize if @opt.cmd =~/vVM/ - SiSU_Env::System_call.new.create_pg_db(@env.path.stub_pwd) if @sql_type=='pg' #watch use of path.stub_pwd instead of stub + tell.colorize if @opt.cmd =~/[vVM]/ + SiSU_Env::SystemCall.new.create_pg_db(@env.path.stub_pwd) if @sql_type=='pg' #watch use of path.stub_pwd instead of stub end def output_dir? - dir=SiSU_Env::Info_env.new('') + dir=SiSU_Env::InfoEnv.new('') if @opt.cmd =~/d/ dir.path.webserv_stub_ensure end @@ -345,7 +345,7 @@ module SiSU_DB_create self end end - class Comment < SiSU_DB_columns::Columns + class Comment < SiSU_DbColumns::Columns def initialize(conn,sql_type='pg') @conn=conn if sql_type =~ /pg/; psql diff --git a/lib/sisu/v3/db_dbi.rb b/lib/sisu/v3/db_dbi.rb index c290c9e3..0c19578f 100644 --- a/lib/sisu/v3/db_dbi.rb +++ b/lib/sisu/v3/db_dbi.rb @@ -57,7 +57,7 @@ sqlite =end -module SiSU_DB_DBI +module SiSU_DbDBI require_relative 'db_columns' # db_columns.rb require_relative 'db_tests' # db_tests.rb require_relative 'db_create' # db_create.rb @@ -67,27 +67,27 @@ module SiSU_DB_DBI require_relative 'db_remove' # db_remove.rb require_relative 'db_load_tuple' # db_load_tuple.rb require_relative 'db_import' # db_import.rb - class Column_size < SiSU_DB_columns::Column_size # db_columns.rb + class ColumnSize < SiSU_DbColumns::ColumnSize # db_columns.rb end - class Test < SiSU_DB_tests::Test # db_tests.rb + class Test < SiSU_DbTests::Test # db_tests.rb end - class Create <SiSU_DB_create::Create # db_create.rb + class Create <SiSU_DbCreate::Create # db_create.rb end - class Case <SiSU_DB_select::Case # db_select.rb + class Case <SiSU_DbSelect::Case # db_select.rb end - class Index <SiSU_DB_index::Index # db_indexes.rb + class Index <SiSU_DbIndex::Index # db_indexes.rb end - class Drop <SiSU_DB_drop::Drop # db_drop.rb + class Drop <SiSU_DbDrop::Drop # db_drop.rb end - class Remove <SiSU_DB_remove::Remove # db_remove.rb + class Remove <SiSU_DbRemove::Remove # db_remove.rb end - class Load_documents <SiSU_DB_tuple::Load_documents # db_load_tuple.rb + class LoadDocuments <SiSU_DbTuple::LoadDocuments # db_load_tuple.rb end - class Load_metadata <SiSU_DB_tuple::Load_metadata # db_load_tuple.rb + class LoadMetadata <SiSU_DbTuple::LoadMetadata # db_load_tuple.rb end - class Load_urls <SiSU_DB_tuple::Load_urls # db_update urls + class LoadUrls <SiSU_DbTuple::LoadUrls # db_update urls end - class Import <SiSU_DB_import::Import #<SiSU_DB::Column_size # db_import.rb + class Import <SiSU_DbImport::Import #<SiSU_DB::ColumnSize # db_import.rb end end __END__ diff --git a/lib/sisu/v3/db_drop.rb b/lib/sisu/v3/db_drop.rb index 1baecb73..4b9aba7d 100644 --- a/lib/sisu/v3/db_drop.rb +++ b/lib/sisu/v3/db_drop.rb @@ -57,7 +57,7 @@ sqlite =end -module SiSU_DB_drop +module SiSU_DbDrop class Drop require_relative 'response' # response.rb def initialize(opt,conn,db_info,sql_type='') @@ -90,10 +90,10 @@ module SiSU_DB_drop and File.exist?(@db_info.sqlite.db) @conn.close File.unlink(@db_info.sqlite.db) - db=SiSU_Env::Info_db.new + db=SiSU_Env::InfoDb.new conn=db.sqlite.conn_sqlite3 - sdb=SiSU_DB_DBI::Create.new(@opt,conn,@db_info,@sql_type) - sdb_index=SiSU_DB_DBI::Index.new(@opt,conn,@db_info,@sql_type) + sdb=SiSU_DbDBI::Create.new(@opt,conn,@db_info,@sql_type) + sdb_index=SiSU_DbDBI::Index.new(@opt,conn,@db_info,@sql_type) sdb.output_dir? begin sdb.create_db @@ -104,7 +104,7 @@ module SiSU_DB_drop sdb.create_table.endnotes_plus sdb.create_table.urls sdb_index.create_indexes - rescue; SiSU_Errors::Info_error.new($!,$@,'-D').error; @sdb.output_dir? + rescue; SiSU_Errors::InfoError.new($!,$@,'-D').error; sdb.output_dir? end exit else diff --git a/lib/sisu/v3/db_import.rb b/lib/sisu/v3/db_import.rb index a78a0656..3bb6e210 100644 --- a/lib/sisu/v3/db_import.rb +++ b/lib/sisu/v3/db_import.rb @@ -57,13 +57,13 @@ sqlite =end -module SiSU_DB_import +module SiSU_DbImport require_relative 'db_columns' # db_columns.rb require_relative 'db_load_tuple' # db_load_tuple.rb require_relative 'db_sqltxt' # db_sqltxt.rb require_relative 'shared_html_lite' # shared_html_lite.rb require 'sqlite3' - class Import < SiSU_DB_text::Prepare + class Import < SiSU_DbText::Prepare include SiSU_Param include SiSU_Screen @@dl=nil @@ -72,7 +72,7 @@ module SiSU_DB_import def initialize(opt,conn,file,sql_type='pg') @opt,@conn,@file,@sql_type=opt,conn,file,sql_type @cX=SiSU_Screen::Ansi.new(@opt.cmd).cX - @env=SiSU_Env::Info_env.new(@opt.fns) + @env=SiSU_Env::InfoEnv.new(@opt.fns) @dal="#{@env.processing_path.dal}" if @opt.fns.empty? or @opt.cmd.empty?; @fnb='' else @@ -85,7 +85,7 @@ module SiSU_DB_import @col=Hash.new('') @col[:ocn]='' @counter={} - @db=SiSU_Env::Info_db.new + @db=SiSU_Env::InfoDb.new if @sql_type=='sqlite' @driver_sqlite3=(@conn.inspect.match(/^(.{10})/)[1]==@db.sqlite.conn_sqlite3.inspect.match(/^(.{10})/)[1]) \ ? true @@ -112,8 +112,9 @@ module SiSU_DB_import end @id_n =0 if @col[:lid].nil? or @col[:lid].to_s.empty? @col[:lv1]=@col[:lv2]=@col[:lv3]=@col[:lv4]=@col[:lv5]=@col[:lv6]=0 - @db=SiSU_Env::Info_db.new - @@dl ||=SiSU_Env::Info_env.new.digest.length + @db=SiSU_Env::InfoDb.new + @pdf_fn=SiSU_Env::FileOp.new(@md).base_filename + @@dl ||=SiSU_Env::InfoEnv.new.digest.length end def marshal_load require_relative 'dal' # dal.rb @@ -167,7 +168,7 @@ module SiSU_DB_import puts "Error code: #{e.err}" puts "Error message: #{e.errstr}" puts "Error SQLSTATE: #{e.state}" - SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error + SiSU_Errors::InfoError.new($!,$@,@opt.cmd,@opt.fns).error sqlfn="#{@env.processing_path.sql}/#{@md.fnb}.sql" sql=File.new(sqlfn,'w') t_d.each {|i| sql.puts i} @@ -178,7 +179,7 @@ module SiSU_DB_import puts "#{__FILE__}:#{__LINE__}" end rescue - SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error + SiSU_Errors::InfoError.new($!,$@,@opt.cmd,@opt.fns).error sqlfn="#{@env.processing_path.sql}/#{@md.fnb}.sql" sql=File.new(sqlfn,'w') t_d.each {|i| sql.puts i} @@ -192,7 +193,7 @@ module SiSU_DB_import end else if file_exist - @db=SiSU_Env::Info_db.new + @db=SiSU_Env::InfoDb.new puts "\n#{@cX.grey}file #{@cX.off} #{@cX.blue}#{@opt.fns}#{@cX.off} in language code #{cX.blue}#{@opt.lng}#{cX.off} #{@cX.grey}already exists in database#{@cX.off} #{@cX.blue}#{@db.psql.db}#{@cX.off} #{@cX.brown}update instead?#{@cX.off}" end end @@ -212,7 +213,7 @@ module SiSU_DB_import src=special_character_escape(src) @tp[:sisutxt_f],@tp[:sisutxt_i]='sisutxt, ',"'#{src}', " txt=clean_searchable_text(txt_arr) - #special_character_escape(txt) + #txt=special_character_escape(txt) @tp[:fulltxt_f],@tp[:fulltxt_i]='fulltxt, ',"'#{txt}', " end #% title @@ -237,8 +238,8 @@ module SiSU_DB_import puts %{\n#{@cX.grey}Processing file number#{@cX.off}: #{@cX.green}#{@@id_t}#{@@cX.off}} if @opt.cmd =~/vVM/ end ################ CLEAR ############## - SiSU_DB_DBI::Test.new(self,@opt).verify #% import title names, filenames (tuple) - t=SiSU_DB_tuple::Load_metadata.new(@conn,@@id_t,@md,@file) + SiSU_DbDBI::Test.new(self,@opt).verify #% import title names, filenames (tuple) + t=SiSU_DbTuple::LoadMetadata.new(@conn,@@id_t,@md,@file) tuple=t.tuple tuple end @@ -260,15 +261,19 @@ module SiSU_DB_import data.obj.gsub!(/#{Mx[:gl_o]}(●)#{Mx[:gl_c]}\s*/,'\1 ') data.obj.gsub!(/#{Mx[:tag_o]}\S+?#{Mx[:tag_c]}/,'') #check @col[:seg]=@@seg - if data.of =~/para|heading|block|group/ # regular text what of code-blocks grouped text etc. + if data.of ==:para \ + || :heading \ + || :heading_insert \ + || :block \ + || :group # regular text what of code-blocks grouped text etc. notedata=data.obj.dup - if data.is=='heading' \ - and data.ln.inspect=~/[123]/ + if data.is==:heading \ + && (data.ln.inspect=~/[123]/) @col[:lev],txt,@col[:ocn],@col[:lev_an],@col[:ocnd],@col[:ocns],@col[:t_of],@col[:t_is],@col[:node],@col[:parent],@col[:digest_clean],@col[:digest_all]=data.ln,data.obj,data.ocn,data.lv,data.odv,data.osp,data.of,data.is,data.node,data.parent,'','' @col[:lid]+=1 txt=endnotes(txt).extract_any - @col[:body]=SiSU_Format_Shared::CSS_Format.new(@md,data).lev4_minus - special_character_escape(@col[:body]) + @col[:body]=SiSU_FormatShared::CSS_Format.new(@md,data).lev4_minus + @col[:body]=special_character_escape(@col[:body]) @col[:plaintext]=@col[:body].dup @col[:plaintext]=strip_markup(@col[:plaintext]) @col[:plaintext]=clean_searchable_text(@col[:plaintext]) @@ -278,7 +283,7 @@ module SiSU_DB_import end if @en_pls[0]; @en_a_plus,@en_z_plus=@en_pls[0].first,@en_pls[0].last end - t=SiSU_DB_tuple::Load_documents.new(@conn,@col,@opt,@file) + t=SiSU_DbTuple::LoadDocuments.new(@conn,@col,@opt,@file) @tuple_array << t.tuple case @col[:lev] when /1/; @col[:lv1]+=1 @@ -286,8 +291,8 @@ module SiSU_DB_import when /3/; @col[:lv3]+=1 end @col[:lev]=@col[:plaintext]=@col[:body]='' - elsif data.is=='heading' \ - and data.ln==4 + elsif data.is==:heading \ + && data.ln==4 @@seg,txt,@col[:ocn],@col[:lev_an],@col[:ocnd],@col[:ocns],@col[:t_of],@col[:t_is],@col[:node],@col[:parent],@col[:digest_clean],@col[:digest_all]=data.name,data.obj,data.ocn,data.lv,data.odv,data.osp,data.of,data.is,data.node,data.parent,'','' @col[:seg]=@@seg @col[:lv4]+=1 @@ -298,23 +303,26 @@ module SiSU_DB_import @@hname=@col[:seg].to_s else @@hname end - @env=SiSU_Env::Info_env.new(@md.fns) + @env=SiSU_Env::InfoEnv.new(@md.fns) @base_url="#{@env.url.root}/#{@md.fnb}/#{@hname}.html" txt=endnotes(txt).extract_any - @col[:body]=SiSU_Format_Shared::CSS_Format.new(@md,data).lev4_plus - special_character_escape(@col[:body]) + @col[:body]=SiSU_FormatShared::CSS_Format.new(@md,data).lev4_plus + @col[:body]=special_character_escape(@col[:body]) @col[:plaintext]=@col[:body].dup @col[:plaintext]=strip_markup(@col[:plaintext]) @col[:plaintext]=clean_searchable_text(@col[:plaintext]) @en_a,@en_z=@en[0].first,@en[0].last if @en[0] @en_a_asterisk,@en_z_asterisk=@en_ast[0].first,@en_ast[0].last if @en_ast[0] @en_a_plus,@en_z_plus=@en_pls[0].first,@en_pls[0].last if @en_pls[0] - t=SiSU_DB_tuple::Load_documents.new(@conn,@col,@opt,@file) + t=SiSU_DbTuple::LoadDocuments.new(@conn,@col,@opt,@file) @tuple_array << t.tuple @col[:lev]=@col[:plaintext]=@col[:body]='' - elsif data.is=='heading' and data.ln==5 + elsif data.is==:heading \ + && data.ln==5 txt,@col[:ocn],@col[:lev_an],@col[:ocnd],@col[:ocns],@col[:t_of],@col[:t_is],@col[:node],@col[:parent],@col[:digest_clean],@col[:digest_all]=data.obj,data.ocn,data.lv,data.odv,data.osp,data.of,data.is,data.node,data.parent,'','' - @@seg_full=data.name if data.is=='heading' and data.ln==5 and data.name #check data.name + @@seg_full=data.name if data.is==:heading \ + && data.ln==5 \ + && data.name #check data.name @@seg ||='' #nil # watch @col[:seg]=@@seg @col[:lv5]+=1 @@ -325,23 +333,24 @@ module SiSU_DB_import @@hname=@col[:seg].to_s else @@hname end - @env=SiSU_Env::Info_env.new(@md.fns) + @env=SiSU_Env::InfoEnv.new(@md.fns) @base_url="#{@env.url.root}/#{@md.fnb}/#{@hname}.html" txt=endnotes(txt).extract_any - @col[:body]=SiSU_Format_Shared::CSS_Format.new(@md,data).lev4_plus - special_character_escape(@col[:body]) + @col[:body]=SiSU_FormatShared::CSS_Format.new(@md,data).lev4_plus + @col[:body]=special_character_escape(@col[:body]) @col[:plaintext]=@col[:body].dup @col[:plaintext]=strip_markup(@col[:plaintext]) @col[:plaintext]=clean_searchable_text(@col[:plaintext]) @en_a,@en_z=@en[0].first,@en[0].last if @en[0] @en_a_asterisk,@en_z_asterisk=@en_ast[0].first,@en_ast[0].last if @en_ast[0] @en_a_plus,@en_z_plus=@en_pls[0].first,@en_pls[0].last if @en_pls[0] - t=SiSU_DB_tuple::Load_documents.new(@conn,@col,@opt,@file) + t=SiSU_DbTuple::LoadDocuments.new(@conn,@col,@opt,@file) @tuple_array << t.tuple @col[:lev]=@col[:plaintext]=@col[:body]='' - elsif data.is=='heading' and data.ln==6 + elsif data.is==:heading \ + && data.ln==6 txt,@col[:ocn],@col[:lev_an],@col[:ocnd],@col[:ocns],@col[:t_of],@col[:t_is],@col[:node],@col[:parent],@col[:digest_clean],@col[:digest_all]=data.obj,data.ocn,data.lv,data.odv,data.osp,data.of,data.is,data.node,data.parent,'','' - @@seg_full=data.name if data.is=='heading' and data.ln==6 and data.name #check data.name + @@seg_full=data.name if data.is==:heading && data.ln==6 && data.name #check data.name @@seg ||='' #nil # watch @col[:seg]=@@seg @col[:lv6]+=1 @@ -352,20 +361,24 @@ module SiSU_DB_import @@hname=@col[:seg].to_s else @@hname end - @env=SiSU_Env::Info_env.new(@md.fns) + @env=SiSU_Env::InfoEnv.new(@md.fns) @base_url="#{@env.url.root}/#{@md.fnb}/#{@hname}.html" txt=endnotes(txt).extract_any - @col[:body]=SiSU_Format_Shared::CSS_Format.new(@md,data).lev4_plus - special_character_escape(@col[:body]) + @col[:body]=SiSU_FormatShared::CSS_Format.new(@md,data).lev4_plus + @col[:body]=special_character_escape(@col[:body]) @col[:plaintext]=@col[:body].dup @col[:plaintext]=strip_markup(@col[:plaintext]) @col[:plaintext]=clean_searchable_text(@col[:plaintext]) @en_a,@en_z=@en[0].first,@en[0].last if @en[0] @en_a_asterisk,@en_z_asterisk=@en_ast[0].first,@en_ast[0].last if @en_ast[0] @en_a_plus,@en_z_plus=@en_pls[0].first,@en_pls[0].last if @en_pls[0] - t=SiSU_DB_tuple::Load_documents.new(@conn,@col,@opt,@file) + t=SiSU_DbTuple::LoadDocuments.new(@conn,@col,@opt,@file) @tuple_array << t.tuple @col[:lev]=@col[:plaintext]=@col[:body]='' + elsif data.of==:structure \ + || data.of==:layout \ + || data.of==:comment + #added watch else #% regular text @col[:lid]+=1 txt='' @@ -375,11 +388,11 @@ module SiSU_DB_import @@hname=@col[:seg].to_s else @@hname end - @env=SiSU_Env::Info_env.new(@md.fns) + @env=SiSU_Env::InfoEnv.new(@md.fns) @base_url="#{@env.url.root}/#{@md.fnb}/#{@hname}.html" txt=endnotes(txt).extract_any if @sql_type=~/pg/ \ - and txt.size > (SiSU_DB_columns::Column_size.new.document_clean - 1) #% examine pg build & remove limitation + and txt.size > (SiSU_DbColumns::ColumnSize.new.document_clean - 1) #% examine pg build & remove limitation puts "\n\nTOO LARGE (TXT - see error log)\n\n" open("#{Dir.pwd}/pg_documents_error_log",'a') do |error| error.puts("\n#{@opt.fns}\nTEXT BODY\n#{@col[:body].size} object #{@col[:ocn]} -> #{@col[:body].slice(0..500)}") @@ -389,28 +402,28 @@ module SiSU_DB_import @en_a,@en_z=@en[0].first,@en[0].last if @en[0] @en_a_asterisk,@en_z_asterisk=@en_ast[0].first,@en_ast[0].last if @en_ast[0] @en_a_plus,@en_z_plus=@en_pls[0].first,@en_pls[0].last if @en_pls[0] - @col[:body]=if data.is=='table' - SiSU_Format_Shared::CSS_Format.new(@md,data).html_table - elsif data.is=='code' - SiSU_Format_Shared::CSS_Format.new(@md,data).code + @col[:body]=if data.is==:table + SiSU_FormatShared::CSS_Format.new(@md,data).html_table + elsif data.is==:code + SiSU_FormatShared::CSS_Format.new(@md,data).code elsif defined? data.indent \ and defined? data.hang \ and data.indent =~/[1-9]/ \ and data.indent == data.hang - SiSU_Format_Shared::CSS_Format.new(@md,data).indent(data.indent) + SiSU_FormatShared::CSS_Format.new(@md,data).indent(data.indent) elsif defined? data.indent \ and defined? data.hang \ and data.hang =~/[0-9]/ \ and data.indent != data.hang - SiSU_Format_Shared::CSS_Format.new(@md,data).hang_indent(data.hang,data.indent) + SiSU_FormatShared::CSS_Format.new(@md,data).hang_indent(data.hang,data.indent) else - SiSU_Format_Shared::CSS_Format.new(@md,data).norm + SiSU_FormatShared::CSS_Format.new(@md,data).norm end - special_character_escape(@col[:body]) + @col[:body]=special_character_escape(@col[:body]) @col[:plaintext]=@col[:body].dup @col[:plaintext]=strip_markup(@col[:plaintext]) @col[:plaintext]=clean_searchable_text(@col[:plaintext]) - t=SiSU_DB_tuple::Load_documents.new(@conn,@col,@opt,@file) + t=SiSU_DbTuple::LoadDocuments.new(@conn,@col,@opt,@file) @tuple_array << t.tuple @en,@en_ast,@en_pls=[],[],[] @col[:en_a]=@col[:en_z]=nil @@ -424,10 +437,10 @@ module SiSU_DB_import nr,txt,digest_clean=$1,$2.strip,0 end @id_n+=1 - special_character_escape(txt) - body=SiSU_Format_Shared::CSS_Format.new(@md,data).endnote(nr,txt) - strip_markup(txt) - if txt.size > (SiSU_DB_columns::Column_size.new.endnote_clean - 1) + txt=special_character_escape(txt) + body=SiSU_FormatShared::CSS_Format.new(@md,data).endnote(nr,txt) + txt=strip_markup(txt) + if txt.size > (SiSU_DbColumns::ColumnSize.new.endnote_clean - 1) puts "\n\nTOO LARGE (ENDNOTE - see error log)\n\n" open("#{Dir.pwd}/pg_documents_error_log",'a') do |error| error.puts("\n#{@opt.fns}\nENDNOTE\n#{txt.size} object #{@col[:ocn]},#{@col[:ocnd]},#{@col[:ocns]} -> #{txt.slice(0..500)}") @@ -448,7 +461,7 @@ module SiSU_DB_import id_t: @@id_t, hash: digest_clean } - t=SiSU_DB_tuple::Load_endnotes.new(@conn,en,@opt,@file) + t=SiSU_DbTuple::LoadEndnotes.new(@conn,en,@opt,@file) @tuple_array << t.tuple end end @@ -463,10 +476,10 @@ module SiSU_DB_import nr,txt,digest_clean=$1,$2.strip,0 end @id_n+=1 - special_character_escape(txt) - body=SiSU_Format_Shared::CSS_Format.new(@md,data).endnote(nr,txt) - strip_markup(txt) - if txt.size > (SiSU_DB_columns::Column_size.new.endnote_clean - 1) + txt=special_character_escape(txt) + body=SiSU_FormatShared::CSS_Format.new(@md,data).endnote(nr,txt) + txt=strip_markup(txt) + if txt.size > (SiSU_DbColumns::ColumnSize.new.endnote_clean - 1) puts "\n\nTOO LARGE (ENDNOTE - see error log)\n\n" open("#{Dir.pwd}/pg_documents_error_log",'a') do |error| error.puts("\n#{@opt.fns}\nENDNOTE\n#{txt.size} object #{@col[:ocn]},#{@col[:ocnd]},#{@col[:ocns]} -> #{txt.slice(0..500)}") @@ -487,7 +500,7 @@ module SiSU_DB_import id_t: @@id_t, hash: digest_clean } - t=SiSU_DB_tuple::Load_endnotes.new(@conn,en,@opt,@file) + t=SiSU_DbTuple::LoadEndnotes.new(@conn,en,@opt,@file) @tuple_array << t.tuple end end @@ -502,10 +515,10 @@ module SiSU_DB_import nr,txt,digest_clean=$1,$2.strip,0 end @id_n+=1 - special_character_escape(txt) - body=SiSU_Format_Shared::CSS_Format.new(@md,data).endnote(nr,txt) - strip_markup(txt) - if txt.size > (SiSU_DB_columns::Column_size.new.endnote_clean - 1) + txt=special_character_escape(txt) + body=SiSU_FormatShared::CSS_Format.new(@md,data).endnote(nr,txt) + txt=strip_markup(txt) + if txt.size > (SiSU_DbColumns::ColumnSize.new.endnote_clean - 1) puts "\n\nTOO LARGE (ENDNOTE - see error log)\n\n" open("#{Dir.pwd}/pg_documents_error_log",'a') do |error| error.puts("\n#{@opt.fns}\nENDNOTE\n#{txt.size} object #{@col[:ocn]},#{@col[:ocnd]},#{@col[:ocns]} -> #{txt.slice(0..500)}") @@ -526,7 +539,7 @@ module SiSU_DB_import id_t: @@id_t, hash: digest_clean } - t=SiSU_DB_tuple::Load_endnotes.new(@conn,en,@opt,@file) + t=SiSU_DbTuple::LoadEndnotes.new(@conn,en,@opt,@file) @tuple_array << t.tuple end end @@ -535,7 +548,7 @@ module SiSU_DB_import end end end - rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error + rescue; SiSU_Errors::InfoError.new($!,$@,@opt.cmd,@opt.fns).error ensure end @tuple_array @@ -568,14 +581,14 @@ module SiSU_DB_import : nil end def clean_text(base_url=nil) - if base_url - @txt.gsub!(/#{Mx[:en_a_o]}(\d+).+?#{Mx[:en_a_c]}/,%{<sup><a href="#{base_url}#_\\1" name="-\\1">\\1</a></sup>}) - @txt.gsub!(/#{Mx[:en_b_o]}([*]\d+).+?#{Mx[:en_b_c]}/,%{<sup><a href="#{base_url}#_\\1" name="-\\1">\\1</a></sup>}) - @txt.gsub!(/#{Mx[:en_b_o]}([+]\d+).+?#{Mx[:en_b_c]}/,%{<sup><a href="#{base_url}#_\\1" name="-\\1">\\1</a></sup>}) + @txt=if base_url + @txt.gsub(/#{Mx[:en_a_o]}(\d+).+?#{Mx[:en_a_c]}/,%{<sup><a href="#{base_url}#_\\1" name="-\\1">\\1</a></sup>}). + gsub(/#{Mx[:en_b_o]}([*]\d+).+?#{Mx[:en_b_c]}/,%{<sup><a href="#{base_url}#_\\1" name="-\\1">\\1</a></sup>}). + gsub(/#{Mx[:en_b_o]}([+]\d+).+?#{Mx[:en_b_c]}/,%{<sup><a href="#{base_url}#_\\1" name="-\\1">\\1</a></sup>}) else - @txt.gsub!(/#{Mx[:en_a_o]}(\d+).+?#{Mx[:en_a_c]}/,'<sup>\1</sup>') - @txt.gsub!(/#{Mx[:en_b_o]}([*]\d+).+?#{Mx[:en_b_c]}/,'<sup>\1</sup>') - @txt.gsub!(/#{Mx[:en_b_o]}([+]\d+).+?#{Mx[:en_b_c]}/,'<sup>\1</sup>') + @txt.gsub(/#{Mx[:en_a_o]}(\d+).+?#{Mx[:en_a_c]}/,'<sup>\1</sup>'). + gsub(/#{Mx[:en_b_o]}([*]\d+).+?#{Mx[:en_b_c]}/,'<sup>\1</sup>'). + gsub(/#{Mx[:en_b_o]}([+]\d+).+?#{Mx[:en_b_c]}/,'<sup>\1</sup>') end @txt end @@ -598,7 +611,7 @@ module SiSU_DB_import def db_import_urls(dbi_unit,content) #% import documents OID - populate database begin @fnc=content - @env=SiSU_Env::Info_env.new(@opt.fns) + @env=SiSU_Env::InfoEnv.new(@opt.fns) base=@env.url.root out=@env.path.output f,u={},{} @@ -606,57 +619,68 @@ module SiSU_DB_import or @fnb.nil? p 'file output path error' #remove end - if FileTest.file?("#{out}/#{@fnb}/#{@md.fn[:plain]}")==true - f[:txt],u[:txt]='plaintext,', "'#{base}/#{@fnb}/#{@md.fn[:plain]}'," + if FileTest.file?("#{@md.file.output_path.txt.dir}/#{@md.file.base_filename.txt}")==true + f[:txt],u[:txt]='plaintext,', "'#{@md.file.output_path.txt.url}/#{@md.file.base_filename.txt}'," end - if FileTest.file?("#{out}/#{@fnb}/#{@md.fn[:toc]}")==true - f[:html_toc],u[:html_toc]='html_toc,', "'#{base}/#{@fnb}/#{@md.fn[:toc]}'," + if FileTest.file?("#{@md.file.output_path.html_seg.dir}/#{@md.file.base_filename.html_seg}")==true + f[:html_toc],u[:html_toc]='html_toc,', "'#{@md.file.output_path.html_seg.url}/#{@md.file.base_filename.html_seg}'," end - if FileTest.file?("#{out}/#{@fnb}/#{@md.fn[:doc]}")==true - f[:html_doc],u[:html_doc]='html_doc,', "'#{base}/#{@fnb}/#{@md.fn[:doc]}'," + if FileTest.file?("#{@md.file.output_path.html_scroll.dir}/#{@md.file.base_filename.html_scroll}")==true + f[:html_doc],u[:html_doc]='html_doc,', "'#{@md.file.output_path.html_scroll.url}/#{@md.file.base_filename.html_scroll}'," end - if FileTest.file?("#{out}/#{@fnb}/#{@md.fn[:xhtml]}")==true - f[:xhtml],u[:xhtml]='xhtml,', "'#{base}/#{@fnb}/#{@md.fn[:xhtml]}'," + if FileTest.file?("#{@md.file.output_path.xhtml.dir}/#{@md.file.base_filename.xhtml}")==true + f[:xhtml],u[:xhtml]='xhtml,', "'#{@md.file.output_path.xhtml.url}/#{@md.file.base_filename.xhtml}'," end - if FileTest.file?("#{out}/#{@fnb}/#{@md.fn[:sax]}")==true - f[:xml_sax],u[:xml_sax]='xml_sax,', "'#{base}/#{@fnb}/#{@md.fn[:sax]}'," + if FileTest.file?("#{@md.file.output_path.xml_sax.dir}/#{@md.file.base_filename.xml_sax}")==true + f[:xml_sax],u[:xml_sax]='xml_sax,', "'#{@md.file.output_path.xml_sax.url}/#{@md.file.base_filename.xml_sax}'," end - if FileTest.file?("#{out}/#{@fnb}/#{@md.fn[:dom]}")==true - f[:xml_dom],u[:xml_dom]='xml_dom,', "'#{base}/#{@fnb}/#{@md.fn[:dom]}'," + if FileTest.file?("#{@md.file.output_path.xml_dom.dir}/#{@md.file.base_filename.xml_dom}")==true + f[:xml_dom],u[:xml_dom]='xml_dom,', "'#{@md.file.output_path.xml_dom.url}/#{@md.file.base_filename.xml_dom}'," end - if FileTest.file?("#{out}/#{@fnb}/#{@md.fn[:odf]}")==true - f[:odf],u[:odf]='odf,', "'#{base}/#{@fnb}/#{@md.fn[:odf]}'," + if FileTest.file?("#{@md.file.output_path.epub.dir}/#{@md.file.base_filename.epub}")==true + f[:epub],u[:epub]='epub,', "'#{@md.file.output_path.epub.url}/#{@md.file.base_filename.epub}'," end - if FileTest.file?("#{out}/#{@fnb}/#{@md.fn[:pdf_p]}")==true - f[:pdf_p],u[:pdf_p]='pdf_p,', "'#{base}/#{@fnb}/#{@md.fn[:pdf_p]}'," + if FileTest.file?("#{@md.file.output_path.odt.dir}/#{@md.file.base_filename.odt}")==true + f[:odf],u[:odf]='odf,', "'#{@md.file.output_path.odt.url}/#{@md.file.base_filename.odt}'," end - if FileTest.file?("#{out}/#{@fnb}/#{@md.fn[:pdf_l]}")==true - f[:pdf_l],u[:pdf_l]='pdf_l,', "'#{base}/#{@fnb}/#{@md.fn[:pdf_l]}'," + if FileTest.file?("#{@md.file.output_path.pdf.dir}/#{@pdf_fn.pdf_p_a4}")==true #\ + #or FileTest.file?("#{@md.file.output_path.pdf.dir}/#{@pdf_fn.pdf_p_letter}")==true + f[:pdf_p],u[:pdf_p]='pdf_p,', "'#{@md.file.output_path.pdf.url}/#{@pdf_fn.pdf_p_a4}'," end - if FileTest.file?("#{out}/#{@fnb}/#{@md.fn[:concordance]}")==true - f[:concordance],u[:concordance]='concordance,', "'#{base}/#{@fnb}/#{@md.fn[:concordance]}'," + if FileTest.file?("#{@md.file.output_path.pdf.dir}/#{@pdf_fn.pdf_l_a4}")==true #\ + #or FileTest.file?("#{@md.file.output_path.pdf.dir}/#{@pdf_fn.pdf_l_letter}")==true + f[:pdf_l],u[:pdf_l]='pdf_l,', "'#{@md.file.output_path.pdf.url}/#{@pdf_fn.pdf_l_a4}'," end - if FileTest.file?("#{out}/#{@fnb}/#{@opt.fns}.tex")==true - f[:latex_p],u[:latex_p]='latex_p,', "'#{base}/#{@fnb}/#{@opt.fns}.tex'," + if FileTest.file?("#{@md.file.output_path.html_concordance.dir}/#{@md.file.base_filename.html_concordance}")==true + f[:concordance],u[:concordance]='concordance,', "'#{@md.file.output_path.html_concordance.url}/#{@md.file.base_filename.html_concordance}'," end - if FileTest.file?("#{out}/#{@fnb}/#{@opt.fns}.landscape.tex")==true - f[:latex_l],u[:latex_l]='latex_l,', "'#{base}/#{@fnb}/#{@opt}.fns}.landscape.tex'," + #if FileTest.file?("#{@md.file.output_path.x.dir}/#{@md.file.base_filename.x}")==true + # f[:latex_p],u[:latex_p]='latex_p,', "'#{@md.file.output_path.x.url}/#{@md.file.base_filename.x}'," + #end + ##if FileTest.file?("#{out}/#{@fnb}/#{@opt.fns}.tex")==true + ## f[:latex_p],u[:latex_p]='latex_p,', "'#{base}/#{@fnb}/#{@opt.fns}.tex'," + ##end + #if FileTest.file?("#{@md.file.output_path.x.dir}/#{@md.file.base_filename.x}")==true + # f[:latex_l],u[:latex_l]='latex_l,', "'#{@md.file.output_path.x.url}/#{@md.file.base_filename.x}'," + #end + ##if FileTest.file?("#{out}/#{@fnb}/#{@opt.fns}.landscape.tex")==true + ## f[:latex_l],u[:latex_l]='latex_l,', "'#{base}/#{@fnb}/#{@opt}.fns}.landscape.tex'," + ##end + if FileTest.file?("#{@md.file.output_path.digest.dir}/#{@md.file.base_filename.digest}")==true + f[:digest],u[:digest]='digest,', "'#{@md.file.output_path.digest.url}/#{@md.file.base_filename.digest}'," end - if FileTest.file?("#{out}/#{@fnb}/#{@md.fn[:digest]}")==true - f[:digest],u[:digest]='digest,', "'#{base}/#{@fnb}/#{@md.fn[:digest]}'," + if FileTest.file?("#{@md.file.output_path.manifest.dir}/#{@md.file.base_filename.manifest}")==true #revisit, was to be text, this is html + f[:manifest],u[:manifest]='manifest,', "'#{@md.file.output_path.manifest.url}/#{@md.file.base_filename.manifest}'," end - if FileTest.file?("#{out}/#{@fnb}/#{@md.fn[:manifest]}")==true #revisit, was to be text, this is html - f[:manifest],u[:manifest]='manifest,', "'#{base}/#{@fnb}/#{@md.fn[:manifest]}'," + if FileTest.file?("#{@md.file.output_path.src.dir}/#{@md.file.base_filename.src}")==true + f[:markup],u[:markup]='markup,', "'#{@md.file.output_path.src.url}/#{@md.file.base_filename.src}'," end - if FileTest.file?("#{out}/#{@fnb}/#{@opt.fns}.meta")==true - f[:markup],u[:markup]='markup,', "'#{base}/#{@fnb}/#{@opt.fns}.meta'," + if FileTest.file?("#{@md.file.output_path.sisupod.dir}/#{@md.file.base_filename.sisupod}")==true + f[:sisupod],u[:sisupod]='sisupod,', "'#{@md.file.output_path.sisupod.url}/#{@md.file.base_filename.sisupod}'," end - if FileTest.file?("#{out}/#{@fnb}/#{@opt.fns}.tgz")==true - f[:sisupod],u[:sisupod]='sisupod,', "'#{base}/#{@fnb}/#{@opt.fns}.tgz'," - end - t=SiSU_DB_tuple::Load_urls.new(@conn,f,u,@@id_t,@opt,@file) + t=SiSU_DbTuple::LoadUrls.new(@conn,f,u,@@id_t,@opt,@file) tuple=t.tuple - rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error + rescue; SiSU_Errors::InfoError.new($!,$@,@opt.cmd,@opt.fns).error ensure end tuple diff --git a/lib/sisu/v3/db_indexes.rb b/lib/sisu/v3/db_indexes.rb index 5e387e27..f61c584f 100644 --- a/lib/sisu/v3/db_indexes.rb +++ b/lib/sisu/v3/db_indexes.rb @@ -57,7 +57,7 @@ sqlite =end -module SiSU_DB_index +module SiSU_DbIndex class Index # create documents Indexes def initialize(opt,conn='',sql_type='') def initialize(opt,conn,file,sql_type='') @opt,@conn,@file,@sql_type=opt,conn,file,sql_type diff --git a/lib/sisu/v3/db_load_tuple.rb b/lib/sisu/v3/db_load_tuple.rb index 812e8e5a..c3273ace 100644 --- a/lib/sisu/v3/db_load_tuple.rb +++ b/lib/sisu/v3/db_load_tuple.rb @@ -57,9 +57,9 @@ sqlite =end -module SiSU_DB_tuple +module SiSU_DbTuple require_relative 'db_columns' # db_columns.rb - class Load_documents + class LoadDocuments require_relative 'param' # param.rb include SiSU_Param def initialize(conn,col,opt,file) @@ -114,10 +114,10 @@ module SiSU_DB_tuple sql_entry end end - class Load_metadata #< SiSU_DB_columns::Columns + class LoadMetadata #< SiSU_DbColumns::Columns def initialize(conn,id,md,file) @conn,@id,@md,@file=conn,id,md,file - @tp=SiSU_DB_columns::Columns.new(md) + @tp=SiSU_DbColumns::Columns.new(md) end def tuple sql_entry="INSERT INTO metadata_and_text ( @@ -299,7 +299,7 @@ tid) sql_entry end end - class Load_urls + class LoadUrls def initialize(conn,f,u,id,opt,file) @conn,@f,@u,@id,@opt,@file=conn,f,u,id,opt,file end @@ -314,7 +314,7 @@ tid) sql_entry end end - class Load_endnotes + class LoadEndnotes def initialize(conn,en,opt,file) @conn,@en,@opt,@file=conn,en,opt,file end diff --git a/lib/sisu/v3/db_remove.rb b/lib/sisu/v3/db_remove.rb index 8147cda1..e34a0a93 100644 --- a/lib/sisu/v3/db_remove.rb +++ b/lib/sisu/v3/db_remove.rb @@ -57,13 +57,13 @@ sqlite =end -module SiSU_DB_remove +module SiSU_DbRemove class Remove def initialize(opt,conn,file,sql_type) @opt,@conn,@file,@sql_type=opt,conn,file,sql_type @md=SiSU_Param::Parameters.new(@opt).get @fnb=@md.fnb - @db=SiSU_Env::Info_db.new + @db=SiSU_Env::InfoDb.new end def remove driver_sqlite3=if @sql_type=='sqlite' diff --git a/lib/sisu/v3/db_select.rb b/lib/sisu/v3/db_select.rb index bce2b21c..52fbe8ba 100644 --- a/lib/sisu/v3/db_select.rb +++ b/lib/sisu/v3/db_select.rb @@ -57,20 +57,20 @@ sqlite =end -module SiSU_DB_select +module SiSU_DbSelect class Case def initialize(opt,conn='',sql_type='pg') @opt,@conn,@sql_type=opt,conn,sql_type - @db=SiSU_Env::Info_db.new + @db=SiSU_Env::InfoDb.new @file=sql_maintenance_file - @sdb=SiSU_DB_DBI::Create.new(@opt,@conn,@file,@sql_type) # db_dbi.rb - @sdb_index=SiSU_DB_DBI::Index.new(@opt,@conn,@file,@sql_type) # db_dbi.rb - @sdb_no=SiSU_DB_DBI::Drop.new(@opt,@conn,@db,@sql_type) # db_dbi.rb + @sdb=SiSU_DbDBI::Create.new(@opt,@conn,@file,@sql_type) # db_dbi.rb + @sdb_index=SiSU_DbDBI::Index.new(@opt,@conn,@file,@sql_type) # db_dbi.rb + @sdb_no=SiSU_DbDBI::Drop.new(@opt,@conn,@db,@sql_type) # db_dbi.rb if @opt.mod.inspect =~/update|import/ - @sdb_import=SiSU_DB_DBI::Import.new(@opt,@conn,@file,@sql_type) - @sdb_remove_doc=SiSU_DB_DBI::Remove.new(@opt,@conn,@file,@sql_type) + @sdb_import=SiSU_DbDBI::Import.new(@opt,@conn,@file,@sql_type) + @sdb_remove_doc=SiSU_DbDBI::Remove.new(@opt,@conn,@file,@sql_type) elsif @opt.mod.inspect =~/remove/ - @sdb_remove_doc=SiSU_DB_DBI::Remove.new(@opt,@conn,@file,@sql_type) + @sdb_remove_doc=SiSU_DbDBI::Remove.new(@opt,@conn,@file,@sql_type) end end def db_exist? @@ -90,9 +90,9 @@ module SiSU_DB_select def sql_maintenance_file file=if @opt.inspect =~/M/ x=if @opt.fns and not @opt.fns.empty? - @env=SiSU_Env::Info_env.new(@opt.fns) if @opt.fns + @env=SiSU_Env::InfoEnv.new(@opt.fns) if @opt.fns puts "\n#{@env.processing_path.sqlite}/#{@opt.fns}.sql" if @sql_type =~/sqlite/ and @opt.cmd =~/M/ - @db=SiSU_Env::Info_db.new + @db=SiSU_Env::InfoDb.new @job="sqlite3 #{@db.sqlite.db} < #{@env.processing_path.sqlite}/#{@opt.fns}.sql" File.new("#{@env.processing_path.sqlite}/#{@opt.fns}.sql",'w+') elsif @opt.fns and @opt.fns.inspect =~/create/; nil #sort variations later @@ -108,56 +108,56 @@ module SiSU_DB_select when /^--createdb$/ @sdb.output_dir? begin - @sdb.create_db + @sdb.create_db rescue; @sdb.output_dir? end when /^--(?:init(?:ialize)?|create(?:all)?)$/ @sdb.output_dir? begin - @sdb.create_table.metadata_and_text - @sdb.create_table.doc_objects - @sdb.create_table.endnotes - @sdb.create_table.endnotes_asterisk - @sdb.create_table.endnotes_plus - @sdb.create_table.urls - @sdb_index.create_indexes - rescue; SiSU_Errors::Info_error.new($!,$@,'-D').error; @sdb.output_dir? + @sdb.create_table.metadata_and_text + @sdb.create_table.doc_objects + @sdb.create_table.endnotes + @sdb.create_table.endnotes_asterisk + @sdb.create_table.endnotes_plus + @sdb.create_table.urls + @sdb_index.create_indexes + rescue; SiSU_Errors::InfoError.new($!,$@,'-D').error; @sdb.output_dir? end when /^--createtables?$/ @sdb.output_dir? begin - @sdb.create_table.metadata_and_text - @sdb.create_table.doc_objects - @sdb.create_table.endnotes - @sdb.create_table.endnotes_asterisk - @sdb.create_table.endnotes_plus - @sdb.create_table.urls - @sdb_index.create_indexes + @sdb.create_table.metadata_and_text + @sdb.create_table.doc_objects + @sdb.create_table.endnotes + @sdb.create_table.endnotes_asterisk + @sdb.create_table.endnotes_plus + @sdb.create_table.urls + @sdb_index.create_indexes rescue; @sdb.output_dir? end when /^--recreate$/ @sdb.output_dir? begin - @sdb_no.drop.tables - @sdb.create_table.metadata_and_text - @sdb.create_table.doc_objects - @sdb.create_table.endnotes - @sdb.create_table.endnotes_asterisk - @sdb.create_table.endnotes_plus - @sdb.create_table.urls - @sdb_index.create_indexes + @sdb_no.drop.tables + @sdb.create_table.metadata_and_text + @sdb.create_table.doc_objects + @sdb.create_table.endnotes + @sdb.create_table.endnotes_asterisk + @sdb.create_table.endnotes_plus + @sdb.create_table.urls + @sdb_index.create_indexes rescue; @sdb.output_dir? end when /^--cr(eate)?lex$/ @sdb.output_dir? begin - @sdb.create_table.doc_objects + @sdb.create_table.doc_objects rescue; @sdb.output_dir? end when /^--cr(eate)?metadata$/ @sdb.output_dir? begin - @sdb.create_table.metadata_and_text + @sdb.create_table.metadata_and_text rescue; @sdb.output_dir? end when /^--import$/ @@ -196,6 +196,7 @@ module SiSU_DB_select db_exist? @sdb_no.drop.tables when /^--(?:db=)?(?:(?:sq)?lite|pg(?:sql)?|my(?:sql)?)$/ + when /^--(?:v\d+|dev)$/ else help=SiSU_Help::Help.new help.summary diff --git a/lib/sisu/v3/db_sqltxt.rb b/lib/sisu/v3/db_sqltxt.rb index d1705c2b..e65a8521 100644 --- a/lib/sisu/v3/db_sqltxt.rb +++ b/lib/sisu/v3/db_sqltxt.rb @@ -56,49 +56,48 @@ ** Description: system environment, resource control and configuration details =end -module SiSU_DB_text +module SiSU_DbText class Prepare def special_character_escape(str) - str.gsub!(/'/,"''") #string.gsub!(/'/,"\047") #string.gsub!(/'/,"\\'") - str.gsub!(/(\\)/m,'\1\1') #ok but with warnings, double backslash on sqlite #str.gsub!(/[\\]/m,'\\x5C') #ok but with warnings, but not for sqlite #str.gsub!(/(\\)/m,'\1') #ok for sqlite not for pgsql - str.gsub!(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,"<br />\n") - str.gsub!(/#{Mx[:tag_o]}\S+?#{Mx[:tag_c]}/,'') #check - str.gsub!(/#{Mx[:lnk_o]}\s*(\S+?\.(?:png|jpg))(?:\s+\d+x\d+)?(.+?)#{Mx[:lnk_c]}\S+/,'[image: \1] \2') - str.gsub!(/#{Mx[:lnk_o]}\s*(.+?)\s*#{Mx[:lnk_c]}(?:file|ftp):\/\/\S+?([.,!?]?(?:\s|$))/,'\1\2') - str.gsub!(/#{Mx[:lnk_o]}\s*(.+?)\s*#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/,'\1') - str + str=str.gsub(/'/,"''"). #string.gsub!(/'/,"\047") #string.gsub!(/'/,"\\'") + gsub(/(\\)/m,'\1\1'). #ok but with warnings, double backslash on sqlite #str.gsub!(/[\\]/m,'\\x5C') #ok but with warnings, but not for sqlite #str.gsub!(/(\\)/m,'\1') #ok for sqlite not for pgsql + gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,"<br />\n"). + gsub(/#{Mx[:tag_o]}\S+?#{Mx[:tag_c]}/,''). #check + gsub(/#{Mx[:lnk_o]}\s*(\S+?\.(?:png|jpg))(?:\s+\d+x\d+)?(.+?)#{Mx[:lnk_c]}\S+/,'[image: \1] \2'). + gsub(/#{Mx[:lnk_o]}\s*(.+?)\s*#{Mx[:lnk_c]}(?:file|ftp):\/\/\S+?([.,!?]?(?:\s|$))/,'\1\2'). + gsub(/#{Mx[:lnk_o]}\s*(.+?)\s*#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/,'\1') end def clean_searchable_text(arr) #produce clean, searchable, plaintext from document source txt_arr,en=[],[] arr=arr.class==String ? arr.split(/\n+/m) : arr arr.each do |s| - s.gsub!(/([*\/_-])\{(.+?)\}\1/m,'\2') - s.gsub!(/^(?:block|group|poem|code)\{/m,''); s.gsub!(/^\}(?:block|group|poem|code)/m,'') - s.gsub!(/\A(?:@\S+:\s+.+)\Z/m,'') + s=s.gsub(/([*\/_-])\{(.+?)\}\1/m,'\2'). + gsub(/^(?:block|group|poem|code)\{/m,'').gsub(/^\}(?:block|group|poem|code)/m,''). + gsub(/\A(?:@\S+:\s+.+)\Z/m,'') if s =~/^:A~/ if defined? @md.creator \ and defined? @md.creator.author \ and not @md.creator.author.empty? - s.gsub!(/@author/,@md.creator.author) + s=s.gsub(/@author/,@md.creator.author) else SiSU_Screen::Ansi.new('v','WARNING Document Author information missing; provide @creator: :author:',@md.fnb).warn unless @md.opt.cmd.inspect =~/q/ end if defined? @md.title \ and defined? @md.title.full \ and not @md.title.full.empty? - s.gsub!(/@title/,@md.title.full) + s=s.gsub(/@title/,@md.title.full) else SiSU_Screen::Ansi.new('v','WARNING Document Title missing; provide @title:',@md.fnb).warn unless @md.opt.cmd.inspect =~/q/ end end - s.gsub!(/^(?:_[1-9]\*?|_\*)\s+/m,'') - s.gsub!(/^(?:[1-9]\~(\S+)?)\s+/m,'') - s.gsub!(/^(?::?[A-C]\~(\S+)?)\s+/m,'') - s.gsub!(/^%{1,3} .+/m,'') #removed even if contained in code block - s.gsub!(/<br>/m,' ') + s=s.gsub(/^(?:_[1-9]\*?|_\*)\s+/m,''). + gsub(/^(?:[1-9]\~(\S+)?)\s+/m,''). + gsub(/^(?::?[A-C]\~(\S+)?)\s+/m,''). + gsub(/^%{1,3} .+/m,''). #removed even if contained in code block + gsub(/<br>/m,' ') en << s.scan(/~\{\s*(.+?)\s*\}~/m) - s.gsub!(/~\{.+?\}~/m,'') - s.gsub!(/ \s+/m,' ') + s=s.gsub(/~\{.+?\}~/m,''). + gsub(/ \s+/m,' ') #special_character_escape(s) s end @@ -109,17 +108,16 @@ module SiSU_DB_text txt end def strip_markup(str) #define rules, make same as in dal clean - str.gsub!(/#{Mx[:fa_superscript_o]}(\d+)#{Mx[:fa_superscript_c]}/,'[\1]') - str.gsub!(/(?: \\;|#{Mx[:nbsp]})+/,' ') - str.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}\d+(.+)#{Mx[:tc_c]}/u,'\1') #tables - str.gsub!(/#{Mx[:tc_p]}#{Mx[:tc_p]}\d+#{Mx[:tc_p]}/u,' ') #tables - str.gsub!(/#{Mx[:tc_p]}/u,' ') #tables tidy later - str.gsub!(/<.+?>/,'') - str.gsub!(/#{Mx[:lnk_o]}.+?\.(?:png|jpg|gif).+?#{Mx[:lnk_c]}(?:file|ftp)\/\/:\S+ /,' [image] ') # else image names found in search - str.gsub!(/#{Mx[:lnk_o]}.+?\.(?:png|jpg|gif).+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/,' [image]') # else image names found in search - str.gsub!(/\s\s+/,' ') - str.strip! - str + str=str.gsub(/#{Mx[:fa_superscript_o]}(\d+)#{Mx[:fa_superscript_c]}/,'[\1]'). + gsub(/(?: \\;|#{Mx[:nbsp]})+/,' '). + gsub(/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}\d+(.+)#{Mx[:tc_c]}/u,'\1'). #tables + gsub(/#{Mx[:tc_p]}#{Mx[:tc_p]}\d+#{Mx[:tc_p]}/u,' '). #tables + gsub(/#{Mx[:tc_p]}/u,' '). #tables tidy later + gsub(/<.+?>/,''). + gsub(/#{Mx[:lnk_o]}.+?\.(?:png|jpg|gif).+?#{Mx[:lnk_c]}(?:file|ftp)\/\/:\S+ /,' [image] '). # else image names found in search + gsub(/#{Mx[:lnk_o]}.+?\.(?:png|jpg|gif).+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/,' [image]'). # else image names found in search + gsub(/\s\s+/,' '). + strip end def unique_words(str) a=str.scan(/[a-zA-Z0-9\\\/_-]{2,}/) #a=str.scan(/\S+{2,}/) diff --git a/lib/sisu/v3/db_tests.rb b/lib/sisu/v3/db_tests.rb index 0fe1370b..3bef2f5f 100644 --- a/lib/sisu/v3/db_tests.rb +++ b/lib/sisu/v3/db_tests.rb @@ -57,7 +57,7 @@ sqlite =end -module SiSU_DB_tests +module SiSU_DbTests class Test def initialize(info,opt) @ck,@opt=info,opt diff --git a/lib/sisu/v3/dbi.rb b/lib/sisu/v3/dbi.rb index 008ac5d4..f11d9e81 100644 --- a/lib/sisu/v3/dbi.rb +++ b/lib/sisu/v3/dbi.rb @@ -63,15 +63,15 @@ module SiSU_DBI require_relative 'param' # param.rb include SiSU_Param require_relative 'db_dbi' # db_dbi.rb - include SiSU_DB_DBI + include SiSU_DbDBI require_relative 'shared_html_lite' # shared_html_lite.rb - include SiSU_Format_Shared - class SiSU_SQL + include SiSU_FormatShared + class SQL def initialize(opt) SiSU_Env::Load.new('dbi',true).prog @opt=opt - @db=SiSU_Env::Info_db.new - if @opt.cmd =~/d/i \ + @db=SiSU_Env::InfoDb.new + if @opt.cmd =~/[Dd]/ \ or @opt.mod.inspect =~/--(pg(?:sql)?|(?:sq)?lite)/ @sql_type=if @opt.cmd=~/D/ \ or @opt.mod.inspect =~/--pg(?:sql)?/ @@ -108,7 +108,7 @@ module SiSU_DBI puts %{manually create the database: "#{@db.db}" if it does not yet exist} #sudo su -p postgres; createdb #{@db.db}; #[createuser?] end - SiSU_DB_DBI::Case.new(@opt,@conn,@sql_type).cases + SiSU_DbDBI::Case.new(@opt,@conn,@sql_type).cases @conn=DBI.connect(@db.dbi,@db.user,@db.db) ensure end @@ -128,9 +128,9 @@ module SiSU_DBI end SiSU_Screen::Ansi.new(@opt.cmd,"DBI (#{@sql_type}) #{@opt.mod}",@opt.fns).dbi_title unless @opt.cmd =~/q/ begin - SiSU_DB_DBI::Case.new(@opt,@conn,@sql_type).cases + SiSU_DbDBI::Case.new(@opt,@conn,@sql_type).cases rescue - SiSU_Errors::Info_error.new($!,$@,@cf,@opt.fns).error + SiSU_Errors::InfoError.new($!,$@,@cf,@opt.fns).error ensure end begin diff --git a/lib/sisu/v3/dbi_discreet.rb b/lib/sisu/v3/dbi_discreet.rb new file mode 100644 index 00000000..d9ecd8e7 --- /dev/null +++ b/lib/sisu/v3/dbi_discreet.rb @@ -0,0 +1,158 @@ +# encoding: utf-8 +=begin + + * Name: SiSU + + * Description: a framework for document structuring, publishing and search + + * Author: Ralph Amissah + + * Copyright: (C) 1997 - 2012, Ralph Amissah, All Rights Reserved. + + * License: GPL 3 or later: + + SiSU, a framework for document structuring, publishing and search + + Copyright (C) Ralph Amissah + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program. If not, see <http://www.gnu.org/licenses/>. + + If you have Internet connection, the latest version of the GPL should be + available at these locations: + <http://www.fsf.org/licensing/licenses/gpl.html> + <http://www.gnu.org/licenses/gpl.html> + + <http://www.jus.uio.no/sisu/gpl.fsf/toc.html> + <http://www.jus.uio.no/sisu/gpl.fsf/doc.html> + <http://www.jus.uio.no/sisu/gpl.fsf/plain.txt> + + * SiSU uses: + * Standard SiSU markup syntax, + * Standard SiSU meta-markup syntax, and the + * Standard SiSU object citation numbering and system + + * Hompages: + <http://www.jus.uio.no/sisu> + <http://www.sisudoc.org> + + * Download: + <http://www.jus.uio.no/sisu/SiSU/download.html> + + * Ralph Amissah + <ralph@amissah.com> + <ralph.amissah@gmail.com> + + ** Description: postgresql module, dbi import frame + +=end +module SiSU_DBI_Discreet #% database building + require_relative 'help' # help.rb + require_relative 'sysenv' # sysenv.rb + include SiSU_Env; include SiSU_Screen + require_relative 'param' # param.rb + include SiSU_Param + require_relative 'db_dbi' # db_dbi.rb + include SiSU_DbDBI + require_relative 'shared_html_lite' # shared_html_lite.rb + include SiSU_FormatShared + require 'fileutils' + include FileUtils::Verbose + class SQL + def initialize(opt) + SiSU_Env::Load.new('dbi',true).prog + @opt=opt + @particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt) + @md=@particulars.md + if @opt.cmd =~/[d]/ \ + or @opt.mod.inspect =~/--((?:sq)?lite)/ + @sql_type='sqlite' + maintenance_check(@opt,__FILE__,__LINE__) if @opt.cmd.inspect =~/M/ + end + @output_path=@md.file.output_path.sqlite_discreet.dir + @filename=@md.file.base_filename.sqlite_discreet + @file="#{@output_path}/#{@filename}" + end + def build + prepare + create_and_populate + end + def maintenance_check(opt,file,line) + p opt.mod + p opt.cmd + p "at #{file} #{line}" + end + def prepare + if not FileTest.directory?(@output_path) + FileUtils::mkdir_p(@output_path) + elsif @file + FileUtils::rm_rf(@file) + end + end + def db_exist?(db,conn) + msg=%{no connection with sqlite database established, createdb "#{db.sqlite.db}"?} + if (not (FileTest.file?(db.sqlite.db)) \ + or FileTest.zero?(db.sqlite.db)) + puts msg + exit + end + if conn.class==NilClass + puts msg + exit + end + end + def create_and_populate + db=SiSU_Env::DbOp.new(@md) + conn=db.sqlite_discreet.conn_sqlite3 + sdb=SiSU_DbDBI::Create.new(@opt,conn,@file,'sqlite') + sdb_index=SiSU_DbDBI::Index.new(@opt,conn,@file,'sqlite') + sdb.output_dir? + begin + sdb.create_db + sdb.create_table.metadata_and_text + sdb.create_table.doc_objects + sdb.create_table.endnotes + sdb.create_table.endnotes_asterisk + sdb.create_table.endnotes_plus + sdb.create_table.urls + sdb_index.create_indexes + db_exist?(db,conn) + sdb_import=SiSU_DbDBI::Import.new(@opt,conn,@file,'sqlite') + sdb_import.marshal_load + tell=SiSU_Screen::Ansi.new(@opt.cmd,"sqlite3 #{db.sqlite.db} database?") + tell.puts_grey if @opt.cmd =~/v/ + rescue; SiSU_Errors::InfoError.new($!,$@,'-d').error; sdb.output_dir? + end + end + def read_sqlite + begin + @conn=@db.sqlite.conn_sqlite3 + rescue + ensure + end + end + def connect + begin + sql_type='sqlite' + SiSU_Screen::Ansi.new(@opt.cmd,"DBI (#{@sql_type}) #{@opt.mod}",@opt.fns).dbi_title unless @opt.cmd =~/q/ + @db.sqlite_discreet.conn_sqlite3 + rescue + SiSU_Errors::InfoError.new($!,$@,@cf,@opt.fns).error + ensure + end + end + def populate + end + end +end +__END__ diff --git a/lib/sisu/v3/defaults.rb b/lib/sisu/v3/defaults.rb index 7278c5f9..e74ff83c 100644 --- a/lib/sisu/v3/defaults.rb +++ b/lib/sisu/v3/defaults.rb @@ -66,9 +66,9 @@ module SiSU_Viz class Skin def initialize @fonts='verdana, arial, georgia, tahoma, sans-serif, helvetica, times, roman' # 'verdana, arial, georgia, tahoma, sans-serif, helvetica, "times new roman", times, roman' - @dir=SiSU_Env::Info_env.new - @date=SiSU_Env::Info_date.new #{@date.year} - @v=SiSU_Env::Info_version.instance.get_version + @dir=SiSU_Env::InfoEnv.new + @date=SiSU_Env::InfoDate.new #{@date.year} + @v=SiSU_Env::InfoVersion.instance.get_version end #% glyph def glyph_bullet # • @@ -735,8 +735,8 @@ module SiSU_Viz when /\/i$/; 'i' else '' end - r.gsub!(/^\/(.+?)\/i?/,'\1') - r.gsub!(/\(/,'(?:') # avoid need to escape use of brackets within regex provided + r=r.gsub(/^\/(.+?)\/i?/,'\1'). + gsub(/\(/,'(?:') # avoid need to escape use of brackets within regex provided m='\b(' + r + ')\b' make[:str] make[:regx]=if x =~/i/; /#{m}/i @@ -756,8 +756,8 @@ module SiSU_Viz when /\/i$/; 'i' else '' end - r.gsub!(/^\/(.+?)\/i?/,'\1') - r.gsub!(/\(/,'(?:') # avoid need to escape use of brackets within regex provided + r.gsub(/^\/(.+?)\/i?/,'\1'). + gsub(/\(/,'(?:') # avoid need to escape use of brackets within regex provided m='\b(' + r + ')\b' make[:str] make[:regx]=if x =~/i/; /#{m}/i @@ -957,7 +957,7 @@ module SiSU_Viz </a>} end def png_hp - dir=SiSU_Env::Info_env.new #(@fns) + dir=SiSU_Env::InfoEnv.new #(@fns) %{ <a href="#{url.site}"> <img border="0" width="160" height="60" src="#{@dir.url.images_local}/#{icon_home_banner}" alt="#{txt_home}" /> </a>} @@ -1029,7 +1029,7 @@ module SiSU_Viz %{<img border="0" height="15" width="15" src="#{url_path_image_sys}/#{icon_external_toc}" alt="lateral hop" />} end def png_home - #dir=SiSU_Env::Info_env.new #(@fns) + #dir=SiSU_Env::InfoEnv.new #(@fns) %{<img border="0" src="#{url_path_image_base}/#{icon_home_button}" alt="#{txt_home} -->" />} #%{<img border="0" src="#{dir.url.images_local}/#{icon_home_button}" alt="#{txt_home} -->" />} end @@ -1040,7 +1040,7 @@ module SiSU_Viz def png_book %{<img border="2" height="15" width="15" src="#{url_path_image_sys}/#{icon_book}" alt="Cameron May Books" />} end - #% png_nav + #% png_nav #not currently used def png_nav_home end def png_nav_toc @@ -1724,9 +1724,9 @@ WOK end class Home < Skin def initialize - @v=SiSU_Env::Info_version.instance.get_version - @dir=SiSU_Env::Info_env.new - @date=SiSU_Env::Info_date.new #{@date.year} + @v=SiSU_Env::InfoVersion.instance.get_version + @dir=SiSU_Env::InfoEnv.new + @date=SiSU_Env::InfoDate.new #{@date.year} end def redirect <<WOK @@ -1890,7 +1890,7 @@ outputs include: plaintext, html, XHTML, XML, ODF (OpenDocument), EPUB, LaTeX, P --- </p> <p class="small"> - License, SiSU is licensed under + License, SiSU is licensed under <a href="http://www.gnu.org/licenses/gpl.html" target="_top"> GPLv3 or later </a> @@ -2032,7 +2032,7 @@ as a developers tool it is flexible and extensible </p> <br /> <p class="small"> -<a href="http://www.sisudoc.org"><b>SiSU</b></a> at <a href="http://www.sisudoc.org"><www.sisudoc.org></a> or <a href="http://www.jus.uio.no/sisu/"><www.jus.uio.no/sisu/></a></p> +<a href="http://www.sisudoc.org"><b>SiSU</b></a> at <a href="http://www.sisudoc.org"><www.sisudoc.org></a> or <a href="http://www.jus.uio.no/sisu/"><www.jus.uio.no/sisu/></a></p> </div> <div id="column_right"> <p class="tiny"> diff --git a/lib/sisu/v3/digests.rb b/lib/sisu/v3/digests.rb index 4062b029..bc4a37e5 100644 --- a/lib/sisu/v3/digests.rb +++ b/lib/sisu/v3/digests.rb @@ -56,7 +56,7 @@ ** Description: document digests (md5|sha256) and structure processing =end -module SiSU_Digest_view +module SiSU_DigestView require_relative 'particulars' # particulars.rb require_relative 'prog_text_translation' # prog_text_translation.rb require_relative 'shared_markup_alt.rb' # shared_markup_alt.rb @@ -68,8 +68,8 @@ module SiSU_Digest_view @fnb=@opt.fnb @@endnotes_para=[] @@dg=nil - @dg=@@dg ||=SiSU_Env::Info_env.new.digest.type - @particulars=SiSU_Particulars::Combined_singleton.instance.get_all(opt) + @dg=@@dg ||=SiSU_Env::InfoEnv.new.digest.type + @particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt) end def read begin @@ -83,9 +83,9 @@ module SiSU_Digest_view : SiSU_Screen::Ansi.new(@opt.cmd,"Document #{@dg} Digests",tool).green_title_hi SiSU_Screen::Ansi.new(@opt.cmd,@opt.fns,"file://#{@md.file.output_path.hash_digest.dir}/#{@md.file.base_filename.hash_digest}").flow if @opt.cmd =~/[MV]/ end - SiSU_Digest_view::Source::Scroll.new(@particulars).songsheet - SiSU_Env::Info_skin.new(@md).select - rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error + SiSU_DigestView::Source::Scroll.new(@particulars).songsheet + SiSU_Env::InfoSkin.new(@md).select + rescue; SiSU_Errors::InfoError.new($!,$@,@opt.cmd,@opt.fns).error ensure end end @@ -97,11 +97,11 @@ module SiSU_Digest_view def initialize(particulars) #data='',md='') @particulars=particulars @data,@env,@md=@particulars.dal_array,@particulars.env,@particulars.md - SiSU_Env::SiSU_file.new(@md).mkdir + SiSU_Env::FileOp.new(@md).mkdir @@dg ||=@env.digest.type @@dl ||=@env.digest.length @dg,@dl=@@dg,@@dl - l=SiSU_Env::Standardise_language.new(@md.opt.lng).language + l=SiSU_Env::StandardiseLanguage.new(@md.opt.lng).language @language=l[:n] @tr=SiSU_Translate::Source.new(@md,@language) @sp=' ' @@ -134,7 +134,7 @@ module SiSU_Digest_view @@sc_info << f << e end def output - file=SiSU_Env::SiSU_file.new(@md) + file=SiSU_Env::FileOp.new(@md) filename_digest=file.write_file.hash_digest filename_digest << @@description.join << @@ds[:digests].join << @@ds[:tree].join << @@ds[:summary].join << @@sc_info.join end @@ -143,7 +143,7 @@ module SiSU_Digest_view end def message_digest data=@data - sys=SiSU_Env::System_call.new + sys=SiSU_Env::SystemCall.new l=Hash.new(0) @p=[] @g,@v,@r='','','' @@ -153,9 +153,9 @@ module SiSU_Digest_view if para =~/#{Mx[:id_o]}~(\d+);((?:\w|[0-6]:)\d+);(\w\d+)#{Mx[:id_c]}#{Mx[:id_o]}([0-9a-f]{#{@dl}}):([0-9a-f]{#{@dl}})#{Mx[:id_c]}/ ocn,h1,h2,d_clean,d_all=$1,$2,$3,$4,$5 @ocn=ocn unless ocn.to_i==0 - para.gsub!(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'<b>\1</b>') - para.gsub!(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'<i>\1</i>') - para.gsub!(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'<u>\1</u>') + para=para.gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'<b>\1</b>'). + gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'<i>\1</i>'). + gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'<u>\1</u>') if para=~/#{Mx[:en_a_o]}[\d*+]+.+?#{Mx[:id_o]}[0-9a-f]{#{@dl}}#{Mx[:id_c]}#{Mx[:en_a_c]}/ para_endnotes << para.scan(/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]})([\d*+]+).+?#{Mx[:id_o]}([0-9a-f]{#{@dl}})#{Mx[:id_c]}(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/) end @@ -298,11 +298,11 @@ module SiSU_Digest_view data=@data endnotes=nil data.each do |t_o| - dgst=SiSU_text_representation::Modified_text_plus_Hash_digest.new(@md,t_o).composite.dgst + dgst=SiSU_TextRepresentation::ModifiedTextPlusHashDigest.new(@md,t_o).composite.dgst if dgst - if t_o.is=='heading' + if t_o.is==:heading digests("#{@sp*0}#{dgst[:ocn]}#{@sp*(8-dgst[:ocn].to_s.length)}#{dgst[:dgst_stripped_txt]} #{dgst[:dgst_markedup_txt]} #{dgst[:is]} #{t_o.lv}") - elsif t_o.is=='heading_insert' + elsif t_o.is==:heading_insert digests("#{@sp*0}[#{dgst[:ocn]}]#{@sp*(6-dgst[:ocn].to_s.length)}#{dgst[:dgst_stripped_txt]} #{dgst[:dgst_markedup_txt]} #{dgst[:is]} #{t_o.lv}") else digests("#{@sp*0}#{dgst[:ocn]}#{@sp*(8-dgst[:ocn].to_s.length)}#{dgst[:dgst_stripped_txt]} #{dgst[:dgst_markedup_txt]} #{dgst[:is]}") @@ -325,7 +325,7 @@ module SiSU_Digest_view dal_structure_tree("------------\n") dal_structure_tree("document structure[*]\n") data.each do |t_o| - if t_o.is=='heading' + if t_o.is==:heading x=case t_o.ln when 1; l[1] +=1 #fix Mx[:lv_o] ' '*0 +':A' @@ -342,7 +342,7 @@ module SiSU_Digest_view else nil end end - ocn=t_o.ocn if defined? t_o.ocn and t_o.is !='heading_insert' + ocn=t_o.ocn if defined? t_o.ocn and t_o.is !=:heading_insert dal_structure_tree("#{x}\n") if x and not x.empty? end dal_structure_tree(" [*] heading levels\n") diff --git a/lib/sisu/v3/embedded.rb b/lib/sisu/v3/embedded.rb index 1dcc4fac..0c73e9e3 100644 --- a/lib/sisu/v3/embedded.rb +++ b/lib/sisu/v3/embedded.rb @@ -65,10 +65,10 @@ module SiSU_Embedded def initialize(opt) @opt=opt @md=SiSU_Param::Parameters.new(@opt).get - @env=SiSU_Env::Info_env.new(@md.fns) - @rhost=SiSU_Env::Info_remote.new(@opt).remote_host_base + @env=SiSU_Env::InfoEnv.new(@md.fns) + @rhost=SiSU_Env::InfoRemote.new(@opt).remote_host_base @base_src_dir=@opt.f_pth[:pth].sub(/\/#{@opt.f_pth[:lng]}$/,'') - @f=SiSU_Env::SiSU_file.new(@md) + @f=SiSU_Env::FileOp.new(@md) end def read songsheet @@ -78,7 +78,7 @@ module SiSU_Embedded audio multimedia begin - rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error + rescue; SiSU_Errors::InfoError.new($!,$@,@opt.cmd,@opt.fns).error ensure end end @@ -95,9 +95,9 @@ module SiSU_Embedded FileUtils::mkdir_p(img_dir) unless FileTest.directory?(img_dir) src_ec=@f.place_file.images.rel + '/' + @md.ec[:image].join(" #{@f.output_path.images.rel}/") unless @opt.fns =~/\.-sst$/ - SiSU_Env::System_call.new(src_ec,ldest,'q').rsync('--relative',@opt.base_path) + SiSU_Env::SystemCall.new(src_ec,ldest,'q').rsync('--relative',@opt.base_path) #if @md.opt.cmd.inspect =~/R/ #rsync to remote image directory - # SiSU_Env::System_call.new(src_ec,remote_rel,'q').rsync('--relative') + # SiSU_Env::SystemCall.new(src_ec,remote_rel,'q').rsync('--relative') #end end end @@ -113,9 +113,9 @@ module SiSU_Embedded and FileTest.directory?(src) FileUtils::mkdir_p(ldest) unless FileTest.directory?(ldest) src_ec="#{src}/" + @md.ec[:audio].join(" #{src}/") - SiSU_Env::System_call.new(src_ec,"#{ldest}/.",'q').rsync + SiSU_Env::SystemCall.new(src_ec,"#{ldest}/.",'q').rsync if @md.opt.cmd.inspect =~/R/ #rsync to remote audio directory - SiSU_Env::System_call.new(src_ec,"#{rdest}/.",'q').rsync + SiSU_Env::SystemCall.new(src_ec,"#{rdest}/.",'q').rsync end end end @@ -130,9 +130,9 @@ module SiSU_Embedded and FileTest.directory?(src) FileUtils::mkdir_p(ldest) unless FileTest.directory?(ldest) src_ec="#{src}/" + @md.ec[:multimedia].join(" #{src}/") - SiSU_Env::System_call.new(src_ec,"#{ldest}/.",'q').rsync + SiSU_Env::SystemCall.new(src_ec,"#{ldest}/.",'q').rsync if @md.opt.cmd.inspect =~/R/ #rsync to remote video directory - SiSU_Env::System_call.new(src_ec,"#{rdest}/.",'q').rsync + SiSU_Env::SystemCall.new(src_ec,"#{rdest}/.",'q').rsync end end end diff --git a/lib/sisu/v3/epub.rb b/lib/sisu/v3/epub.rb index e0a1d219..e9aeb4de 100644 --- a/lib/sisu/v3/epub.rb +++ b/lib/sisu/v3/epub.rb @@ -66,14 +66,14 @@ module SiSU_EPUB require_relative 'epub_format' # epub_format.rb include SiSU_EPUB_Format require_relative 'epub_segments' # epub_segments.rb - include SiSU_EPUB_seg + include SiSU_EPUB_Seg require_relative 'epub_tune' # epub_tune.rb include SiSU_EPUB_Tune require_relative 'epub_concordance' # epub_concordance.rb class Source def initialize(opt) @opt=opt - @particulars=SiSU_Particulars::Combined_singleton.instance.get_all(opt) + @particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt) end def read songsheet @@ -96,18 +96,18 @@ module SiSU_EPUB @env.processing_path.epub_bld #(@md) @env.processing_path.epub_cp_images(@md) dir_epub=@env.processing_path.epub - SiSU_Env::Info_skin.new(@md).select + SiSU_Env::InfoSkin.new(@md).select data=nil - SiSU_Env::SiSU_file.new(@md).mkdir.output.epub - @tuned_file_array=SiSU_EPUB::Source::XHtml_environment.new(@particulars).tuned_file_instructions + SiSU_Env::FileOp.new(@md).mkdir.output.epub + @tuned_file_array=SiSU_EPUB::Source::XHTML_Environment.new(@particulars).tuned_file_instructions data=@tuned_file_array scr_endnotes=SiSU_EPUB::Source::Endnotes.new(@md,data).scroll toc=SiSU_EPUB::Source::Toc.new(@md,data).songsheet data=@tuned_file_array - scr_toc=SiSU_EPUB::Source::Scroll_head_and_segtoc.new(@md,toc).in_common #watch + scr_toc=SiSU_EPUB::Source::ScrollHeadAndSegToc.new(@md,toc).in_common #watch SiSU_EPUB::Source::Seg.new(@md,data).songsheet - SiSU_EPUB::Source::Epub_output.new(@md).songsheet - rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error + SiSU_EPUB::Source::Output.new(@md).songsheet + rescue; SiSU_Errors::InfoError.new($!,$@,@opt.cmd,@opt.fns).error ensure unless @opt.cmd =~/[MV]/ #check maintenance flag texfiles=Dir["#{@env.processing_path.tune}/#{@opt.fns}*"] @@ -126,19 +126,19 @@ module SiSU_EPUB end end private - class XHtml_environment + class XHTML_Environment def initialize(particulars) @particulars=particulars @md,@env=particulars.md,particulars.env - @vz=SiSU_Env::Get_init.instance.skin - @env,@css,@symlnk=particulars.env,SiSU_Style::CSS.new,SiSU_Env::Create_system_link.new #home + @vz=SiSU_Env::GetInit.instance.skin + @env,@css,@symlnk=particulars.env,SiSU_Style::CSS.new,SiSU_Env::CreateSystemLink.new #home end def link_images @symlnk.images end def directories title=File.basename(@md.fns,'.rb') - SiSU_Env::SiSU_file.new(@md).mkdir.output.epub + SiSU_Env::FileOp.new(@md).mkdir.output.epub end def tuned_file_instructions @tell=SiSU_Screen::Ansi.new(@md.opt.cmd) @@ -157,10 +157,10 @@ module SiSU_EPUB end def scroll @scr_endnotes=[] - format_head_scroll=SiSU_EPUB_Format::Head_scroll.new(@md) + format_head_scroll=SiSU_EPUB_Format::HeadScroll.new(@md) @data.each do |dob| pg=dob.dup - unless pg.is =~/^code/ + unless pg.is ==:code if pg.obj =~/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]})[\d*+]+ / endnote_array=[] if pg.obj=~/#{Mx[:en_a_o]}[\d*+].+?#{Mx[:en_a_c]}/m @@ -174,7 +174,7 @@ module SiSU_EPUB end endnote_array.flatten.each do |note| txt_obj={ txt: note } - format_scroll=SiSU_EPUB_Format::Format_scroll.new(@md,txt_obj) + format_scroll=SiSU_EPUB_Format::FormatScroll.new(@md,txt_obj) @scr_endnotes << format_scroll.endnote_body end end @@ -189,9 +189,10 @@ module SiSU_EPUB @@firstseg=nil def initialize(md=nil,data='') @md,@data=md,data - @vz=SiSU_Env::Get_init.instance.skin - @epub=SiSU_EPUB_Format::Head_information.new(@md) + @vz=SiSU_Env::GetInit.instance.skin + @epub=SiSU_EPUB_Format::HeadInformation.new(@md) @tell=SiSU_Screen::Ansi.new(@md.opt.cmd) if @md + @make=SiSU_Env::ProcessingSettings.new(@md) end def songsheet #extracts toc for scroll & seg SiSU_Screen::Ansi.new(@md.opt.cmd,'Toc').txt_grey if @md.opt.cmd =~/[MVv]/ @@ -211,15 +212,17 @@ module SiSU_EPUB @@toc[:seg] << %{<div class="content">\n<div class="substance">} @@toc[:scr] << %{<div class="content">\n<div class="substance">} md_opf_a_content << @epub.metadata_opf.manifest_content_sisu_toc - md_opf_a_spine << @epub.metadata_opf.spine_sisu_toc - md_opf_a_guide << @epub.metadata_opf.guide_sisu_toc + if @make.build.toc? + md_opf_a_spine << @epub.metadata_opf.spine_sisu_toc + md_opf_a_guide << @epub.metadata_opf.guide_sisu_toc + end @ncxo=[nil,false,false,false,false,false,false] @dob_toc2,@dob_toc3=nil,nil @ncx_cls=[] @level_a_first_occurrence=true @data.each do |dob| - if dob.is=='heading' \ - or dob.is=='heading_insert' + if dob.is==:heading \ + || dob.is==:heading_insert dob_toc=dob.dup toc=case dob_toc.ln when 1 @@ -234,7 +237,8 @@ module SiSU_EPUB @ncxo[1],@ncxo[2],@ncxo[3],@ncxo[4]=true,false,false,false @epub.sections(dob_toc,name_s_a) @@toc[:ncx] << @epub.toc_ncx.navpoint(dob_toc,@nav_no,name_s_a) if dob_toc - if @level_a_first_occurrence + if @level_a_first_occurrence \ + && @make.build.toc? @nav_no+=1 @@toc[:ncx] << @epub.toc_ncx.navmap_sisu_toc(@nav_no) #epub ncx navmap, toc @level_a_first_occurrence=false @@ -242,7 +246,7 @@ module SiSU_EPUB md_opf_a_content << @epub.metadata_opf.manifest_content(dob_toc,name_s_a) md_opf_a_spine << @epub.metadata_opf.spine(dob_toc,name_s_a) md_opf_a_guide << @epub.metadata_opf.guide(dob_toc,name_s_a) - Toc.new(@md,dob_toc).level_1 + SiSU_EPUB::Source::Toc.new(@md,dob_toc).level_1 when 2 @s_b_no +=1 name_s_b='section_b' + @s_b_no.to_s @@ -257,7 +261,7 @@ module SiSU_EPUB md_opf_a_content << @epub.metadata_opf.manifest_content(dob_toc,name_s_b) md_opf_a_spine << @epub.metadata_opf.spine(dob_toc,name_s_b) md_opf_a_guide << @epub.metadata_opf.guide(dob_toc,name_s_b) - Toc.new(@md,dob_toc).level_2 + SiSU_EPUB::Source::Toc.new(@md,dob_toc).level_2 when 3 @s_c_no +=1 name_s_c='section_c' + @s_c_no.to_s @@ -271,7 +275,7 @@ module SiSU_EPUB md_opf_a_content << @epub.metadata_opf.manifest_content(dob_toc,name_s_c) md_opf_a_spine << @epub.metadata_opf.spine(dob_toc,name_s_c) md_opf_a_guide << @epub.metadata_opf.guide(dob_toc,name_s_c) - Toc.new(@md,dob_toc).level_3 + SiSU_EPUB::Source::Toc.new(@md,dob_toc).level_3 when 4 @ncx_cls=[] @nav_no+=1 @@ -281,9 +285,9 @@ module SiSU_EPUB md_opf_a_content << @epub.metadata_opf.manifest_content(dob_toc) md_opf_a_spine << @epub.metadata_opf.spine(dob_toc) md_opf_a_guide << @epub.metadata_opf.guide(dob_toc) - Toc.new(@md,dob_toc).level_4 - when 5; Toc.new(@md,dob_toc).level_5 - when 6; Toc.new(@md,dob_toc).level_6 + SiSU_EPUB::Source::Toc.new(@md,dob_toc).level_4 + when 5; SiSU_EPUB::Source::Toc.new(@md,dob_toc).level_5 + when 6; SiSU_EPUB::Source::Toc.new(@md,dob_toc).level_6 else nil end toc.each do |k,d| @@ -298,8 +302,7 @@ module SiSU_EPUB begin @@toc[:seg] << toc[:seg] @@toc[:scr] << toc[:seg] - @@toc[:seg_mini] << toc[:seg_mini] if toc[:seg_mini] - rescue; SiSU_Errors::Info_error.new($!,$@,@md.opt.cmd,@md.fns).error + rescue; SiSU_Errors::InfoError.new($!,$@,@md.opt.cmd,@md.fns).error end end end @@ -318,22 +321,18 @@ module SiSU_EPUB @@toc[:opf] << @epub.metadata_opf.guide_open << md_opf_a_guide << @epub.metadata_opf.guide_close @@toc[:opf] << @epub.metadata_opf.package_close @@toc[:opf]=@@toc[:opf].flatten - Epub_output.new(@md,@@toc[:opf]).epub_metadata_opf - Epub_output.new(@md,@@toc[:ncx]).epub_toc_ncx + SiSU_EPUB::Source::Output.new(@md,@@toc[:opf]).epub_metadata_opf + SiSU_EPUB::Source::Output.new(@md,@@toc[:ncx]).epub_toc_ncx @md.firstseg=@@firstseg @@toc end - def minitoc - minitoc=@@toc[:seg_mini].join("\n") - '<div class="toc">' + minitoc + '</div>' - end protected def level_1 dob=@data linkname,link=dob.obj.strip,dob.ocn if link \ and link !~/#/ #% keep eye on link - p_num=SiSU_EPUB_Format::Paragraph_number.new(@md,link) + p_num=SiSU_EPUB_Format::ParagraphNumber.new(@md,link) end title=if dob.obj !~/Document Information/; linkname else @@ -342,20 +341,12 @@ module SiSU_EPUB end toc={} txt_obj={ txt: title } - format_toc=SiSU_EPUB_Format::Format_toc.new(@md,txt_obj) + format_toc=SiSU_EPUB_Format::FormatToc.new(@md,txt_obj) toc[:seg]=if dob.name =~/^meta/ \ and dob.obj =~/Document Information/ #check format_toc.lev0 else format_toc.lev1 end - toc[:seg_mini]=if dob.name =~/^meta/ \ - and dob.obj =~/Document Information/ #check - x=if @md.concord_make - format_toc.mini_concord_tail - else format_toc.mini_tail - end - else format_toc.mini_lev1 - end title=if dob.ocn ==0 if dob.name =~/^meta/ \ and dob.obj =~/Document Information/ @@ -370,7 +361,7 @@ module SiSU_EPUB %{<b><a href="##{link}">#{linkname}</a></b>} end txt_obj={ txt: title } - format_toc=SiSU_EPUB_Format::Format_toc.new(@md,txt_obj) + format_toc=SiSU_EPUB_Format::FormatToc.new(@md,txt_obj) toc[:scr]=if dob.name =~/^meta/ \ and dob.obj =~/Document Information/ format_toc.lev0 @@ -383,17 +374,16 @@ module SiSU_EPUB linkname,ocn=dob.obj.strip,dob.ocn if ocn \ and ocn !~/#/ - p_num=SiSU_EPUB_Format::Paragraph_number.new(@md,ocn) + p_num=SiSU_EPUB_Format::ParagraphNumber.new(@md,ocn) end txt_obj={ txt: linkname } - format_toc=SiSU_EPUB_Format::Format_toc.new(@md,txt_obj) + format_toc=SiSU_EPUB_Format::FormatToc.new(@md,txt_obj) toc={} toc[:seg]=format_toc.lev2 - toc[:seg_mini]=format_toc.mini_lev2 if p_num title=%{#{p_num.goto}#{linkname}</a>} txt_obj={ txt: title } - format_toc=SiSU_EPUB_Format::Format_toc.new(@md,txt_obj) + format_toc=SiSU_EPUB_Format::FormatToc.new(@md,txt_obj) toc[:scr]=format_toc.lev2 end toc @@ -403,17 +393,16 @@ module SiSU_EPUB linkname,ocn=dob.obj.strip,dob.ocn if ocn \ and ocn !~/#/ - p_num=SiSU_EPUB_Format::Paragraph_number.new(@md,ocn) + p_num=SiSU_EPUB_Format::ParagraphNumber.new(@md,ocn) end txt_obj={ txt: linkname } - format_toc=SiSU_EPUB_Format::Format_toc.new(@md,txt_obj) + format_toc=SiSU_EPUB_Format::FormatToc.new(@md,txt_obj) toc={} toc[:seg]=format_toc.lev3 - toc[:seg_mini]=format_toc.mini_lev3 if p_num title=%{#{p_num.goto}#{linkname}</a>} txt_obj={ txt: title } - format_toc=SiSU_EPUB_Format::Format_toc.new(@md,txt_obj) + format_toc=SiSU_EPUB_Format::FormatToc.new(@md,txt_obj) toc[:scr]=format_toc.lev3 end toc @@ -421,7 +410,7 @@ module SiSU_EPUB def level_4 dob=@data linkname,ocn=dob.obj.strip,dob.ocn - p_num=SiSU_EPUB_Format::Paragraph_number.new(@md,ocn) if ocn + p_num=SiSU_EPUB_Format::ParagraphNumber.new(@md,ocn) if ocn if dob.ln==4 seg_link=%{ <a href="#{dob.name}#{Sfx[:epub_xhtml]}"> #{dob.obj} @@ -432,15 +421,14 @@ module SiSU_EPUB %{<a href="\\1#{Sfx[:epub_xhtml]}">} + %{\\1 \\2</a> }) end - p_num=SiSU_EPUB_Format::Paragraph_number.new(@md,ocn) if ocn + p_num=SiSU_EPUB_Format::ParagraphNumber.new(@md,ocn) if ocn txt_obj={ txt: seg_link } - format_toc=SiSU_EPUB_Format::Format_toc.new(@md,txt_obj) + format_toc=SiSU_EPUB_Format::FormatToc.new(@md,txt_obj) toc={} toc[:seg]=format_toc.lev4 - toc[:seg_mini]=format_toc.mini_lev4 title=%{#{p_num.goto}#{linkname}</a>} if p_num txt_obj={ txt: title } - format_toc=SiSU_EPUB_Format::Format_toc.new(@md,txt_obj) + format_toc=SiSU_EPUB_Format::FormatToc.new(@md,txt_obj) toc[:scr]=format_toc.lev4 toc end @@ -450,17 +438,16 @@ module SiSU_EPUB toc={} if ocn \ and ocn !~/#/ - p_num=SiSU_EPUB_Format::Paragraph_number.new(@md,ocn) + p_num=SiSU_EPUB_Format::ParagraphNumber.new(@md,ocn) lnk_n_txt=%{ <a href="#{@@seg_url}#{Sfx[:epub_xhtml]}#o#{ocn}"> #{linkname} </a>} txt_obj={ txt: lnk_n_txt } - format_toc=SiSU_EPUB_Format::Format_toc.new(@md,txt_obj) + format_toc=SiSU_EPUB_Format::FormatToc.new(@md,txt_obj) toc[:seg]=format_toc.lev5 - toc[:seg_mini]=format_toc.mini_lev5 title=%{#{p_num.goto}#{linkname}</a>} txt_obj={ txt: title } - format_toc=SiSU_EPUB_Format::Format_toc.new(@md,txt_obj) + format_toc=SiSU_EPUB_Format::FormatToc.new(@md,txt_obj) toc[:scr]=format_toc.lev5 end toc @@ -471,72 +458,48 @@ module SiSU_EPUB toc={} if ocn \ and ocn !~/#/ - p_num=SiSU_EPUB_Format::Paragraph_number.new(@md,ocn) + p_num=SiSU_EPUB_Format::ParagraphNumber.new(@md,ocn) lnk_n_txt=%{ <a href="#{@@seg_url}#{Sfx[:epub_xhtml]}#o#{ocn}"> #{linkname} </a>} txt_obj={ txt: lnk_n_txt } - format_toc=SiSU_EPUB_Format::Format_toc.new(@md,txt_obj) + format_toc=SiSU_EPUB_Format::FormatToc.new(@md,txt_obj) toc[:seg]=format_toc.lev6 - toc[:seg_mini]=format_toc.mini_lev6 title=%{#{p_num.goto}#{linkname}</a>} txt_obj={ txt: title } - format_toc=SiSU_EPUB_Format::Format_toc.new(@md,txt_obj) + format_toc=SiSU_EPUB_Format::FormatToc.new(@md,txt_obj) toc[:scr]=format_toc.lev6 end toc end - def level_crosslink - dob=@data - if dob !~/^4~!/ - dob.gsub!(/^4~!\s+(\S+)\s+(.+)/, - %{<table><tr><td width =\"80\"></td> - <td><a href="http://\\1"> - #{@png.crosslink_ext} - \\2 - <\/a> - </td></tr></table> -}) - else - dob.gsub!(/^4~!\s+(\S+)\s+(.+)/, - %{<table><tr><td width ="80"> - </td><td> - <a href="\\1"> - #{@png.crosslink} - \\2 - <\/a> - </td></tr></table> -}) - end - end end - class Scroll_head_and_segtoc < Toc + class ScrollHeadAndSegToc < Toc def initialize(md='',toc='',links_guide_toc='') @md,@toc,@links_guide_toc=md,toc,links_guide_toc - @vz=SiSU_Env::Get_init.instance.skin + @vz=SiSU_Env::GetInit.instance.skin end def in_common toc_shared=[] segtoc=[] SiSU_Screen::Ansi.new(@md.opt.cmd,'Scroll & Segtoc').txt_grey if @md.opt.cmd =~/[MVv]/ - format_head_toc=SiSU_EPUB_Format::Head_toc.new(@md) + format_head_toc=SiSU_EPUB_Format::HeadToc.new(@md) dochead=format_head_toc.head - dochead.gsub!(/toc\.(html)/,'doc.\1') #kludge + dochead=dochead.gsub(/toc\.(html)/,'doc.\1') #kludge toc_shared << dochead #<< ads.div.major segtoc << format_head_toc.head #<< ads.div.major - if SiSU_EPUB_Format::Head_toc.method_defined? :toc_head_escript + if SiSU_EPUB_Format::HeadToc.method_defined? :toc_head_escript toc_shared << format_head_toc.toc_head_escript segtoc << format_head_toc.toc_head_escript end if defined? @md.rights.all \ and @md.rights.all rights=format_head_toc.rights.all - rights=SiSU_EPUB_Tune::Clean_xhtml.new(rights).clean + rights=SiSU_EPUB_Tune::CleanXHTML.new(rights).clean end if defined? @md.notes.prefix_b \ and @md.notes.prefix_b prefix_b=format_head_toc.prefix_b - prefix_b=SiSU_EPUB_Tune::Clean_xhtml.new(prefix_b).clean + prefix_b=SiSU_EPUB_Tune::CleanXHTML.new(prefix_b).clean end seg_toc_band=format_head_toc.seg_head_navigation_band seg_toc_band_bottom=format_head_toc.seg_head_navigation_band_bottom @@ -544,7 +507,7 @@ module SiSU_EPUB doc_title_endnote=@md.title.full.gsub(/(\*+)/,'<sup><a href="#endnotes">\1</a></sup>') tmp_head=doc_title_endnote + "\n" txt_obj={ txt: tmp_head } - format_txt_obj=SiSU_EPUB_Format::Format_text_object.new(@md,txt_obj) + format_txt_obj=SiSU_EPUB_Format::FormatTextObject.new(@md,txt_obj) toc_shared << format_txt_obj.center_bold segtoc << format_txt_obj.center_bold if defined? @md.creator.author \ @@ -552,7 +515,7 @@ module SiSU_EPUB creator_endnote=@md.creator.author.gsub(/(\*+)/,%{ <sup><a href="#notes">\\1</a></sup>}) tmp_head=creator_endnote + "\n" txt_obj={ txt: tmp_head } - format_txt_obj=SiSU_EPUB_Format::Format_text_object.new(@md,txt_obj) + format_txt_obj=SiSU_EPUB_Format::FormatTextObject.new(@md,txt_obj) toc_shared << format_txt_obj.center_bold segtoc << format_txt_obj.center_bold end @@ -589,23 +552,24 @@ module SiSU_EPUB #Segtoc tail added here segtoc << seg_toc_band_bottom segtoc << format_head_toc.xhtml_close - segtoc.flatten!.compact! - Epub_output.new(@md,segtoc).segtoc + segtoc=segtoc.flatten.compact #watch + SiSU_EPUB::Source::Output.new(@md,segtoc).segtoc segtoc=[] @toc[:scr],@toc[:seg]=[],[] toc_shared end end - class Table < SiSU_XHTML_table::Table_xhtml + class Table < SiSU_XHTML_Table::TableXHTML end - class Seg < SiSU_EPUB_seg::Seg + class Seg < SiSU_EPUB_Seg::Seg end - class Epub_output + class Output def initialize(md,output='') @md,@output=md,output @epub_doc="#{@md.fnb}.epub" - @epub_header=SiSU_EPUB_Format::Head_information.new(@md) - @make=SiSU_Env::Create_file.new(@md.fns) + @epub_header=SiSU_EPUB_Format::HeadInformation.new(@md) + @make=SiSU_Env::ProcessingSettings.new(@md) + @make_file=SiSU_Env::CreateFile.new(@md.fns) end def songsheet mimetype @@ -616,42 +580,42 @@ module SiSU_EPUB output_zip end def mimetype - out=@make.epub.mimetype + out=@make_file.epub.mimetype out<<@epub_header.mimetype out.close end def metainf_container #container.xml file in META-INF directory - out=@make.epub.metainf_cont + out=@make_file.epub.metainf_cont out<<@epub_header.metainf_container out.close end def css - out=@make.epub.xhtml_css - out << SiSU_EPUB_Format::Css.new.css_epub_xhtml + out=@make_file.epub.xhtml_css + out << SiSU_EPUB_Format::CSS.new.css_epub_xhtml out.close end def epub_toc_ncx begin - out=@make.epub.toc_ncx + out=@make_file.epub.toc_ncx @output.each do |para| unless para =~/\A\s*\Z/ out.puts para end end out.close - rescue; SiSU_Errors::Info_error.new($!,$@,@md.opt.cmd,@md.fns).error + rescue; SiSU_Errors::InfoError.new($!,$@,@md.opt.cmd,@md.fns).error end end def epub_metadata_opf begin - out=@make.epub.metadata + out=@make_file.epub.metadata @output.each do |para| unless para =~/\A\s*\Z/ out.puts para end end out.close - rescue; SiSU_Errors::Info_error.new($!,$@,@md.opt.cmd,@md.fns).error + rescue; SiSU_Errors::InfoError.new($!,$@,@md.opt.cmd,@md.fns).error end end def images @@ -686,18 +650,17 @@ module SiSU_EPUB end def segtoc begin - filename_html_segtoc=@make.epub.xhtml_segtoc - filename_html_index=@make.epub.xhtml_index - @output.each do |para| - para.strip! - unless para =~/\A\s*\Z/ - filename_html_segtoc.puts para,"\n" - filename_html_index.puts para,"\n" + if @make.build.toc? + filename_html_index=@make_file.epub.xhtml_index + @output.each do |para| + para=para.strip + unless para =~/\A\s*\Z/ + filename_html_index.puts para,"\n" + end end + filename_html_index.close end - filename_html_segtoc.close - filename_html_index.close - rescue; SiSU_Errors::Info_error.new($!,$@,@md.opt.cmd,@md.fns).error + rescue; SiSU_Errors::InfoError.new($!,$@,@md.opt.cmd,@md.fns).error end end end diff --git a/lib/sisu/v3/epub_concordance.rb b/lib/sisu/v3/epub_concordance.rb index c2a289a2..e2e5bb5c 100644 --- a/lib/sisu/v3/epub_concordance.rb +++ b/lib/sisu/v3/epub_concordance.rb @@ -69,7 +69,7 @@ module SiSU_EPUB_Concordance class Source def initialize(opt) @opt=opt - @particulars=SiSU_Particulars::Combined_singleton.instance.get_all(opt) + @particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt) end def read begin @@ -85,21 +85,21 @@ module SiSU_EPUB_Concordance SiSU_Screen::Ansi.new(@md.opt.cmd,"wc (word count) is off, concordance will be processed for all files including those over the max set size of: #{wordmax} words").warn unless @md.opt.cmd =~/q/ SiSU_EPUB_Concordance::Source::Words.new(@particulars).songsheet end - rescue; SiSU_Errors::Info_error.new($!,$@,@md.opt.cmd,@md.fns).error + rescue; SiSU_Errors::InfoError.new($!,$@,@md.opt.cmd,@md.fns).error ensure end end private - class Doc_title + class DocTitle include SiSU_Viz #revisit, both requires (html & shared_xml) needed for stand alone operation (sisu -w [filename]) require_relative 'epub' # epub.rb def initialize(particulars) @particulars,@md=particulars,particulars.md - @data=SiSU_EPUB::Source::XHtml_environment.new(particulars).tuned_file_instructions - @vz=SiSU_Env::Get_init.instance.skin + @data=SiSU_EPUB::Source::XHTML_Environment.new(particulars).tuned_file_instructions + @vz=SiSU_Env::GetInit.instance.skin txt_path=%{#{@md.dir_out}} - SiSU_Env::Info_skin.new(@md).select + SiSU_Env::InfoSkin.new(@md).select @fnb=@md.fnb @lex_button=%{<a href="http://www.jus.uio.no/sisu/" target="_top"><img border="0" height="44" width="144" valign="center" src="../_sisu/image/sisu.png" alt="SiSU home -->"></a>} @doc_details =<<WOK @@ -107,8 +107,8 @@ module SiSU_EPUB_Concordance WOK end def create - @css=SiSU_Env::CSS_stylesheet.new(@particulars.md) - format_head_toc=SiSU_EPUB_Format::Head_toc.new(@md) + @css=SiSU_Env::CSS_Stylesheet.new(@particulars.md) + format_head_toc=SiSU_EPUB_Format::HeadToc.new(@md) dochead=format_head_toc.head <<WOK #{dochead} @@ -151,7 +151,7 @@ WOK def initialize(particulars) @particulars=particulars begin - @vz=SiSU_Env::Get_init.instance.skin + @vz=SiSU_Env::GetInit.instance.skin @env,@md,@dal_array=particulars.env,particulars.md,particulars.dal_array @path="#{@env.processing_path.epub}" @freq=Hash.new(0) @@ -167,14 +167,18 @@ WOK @rxp_excluded0=/^(?:#{Mx[:fa_bold_o]}|#{Mx[:fa_italics_o]})?(?:to\d+|\d+| |#{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?|[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_splitlist=%r{[—.,;:-]+|#{Mx[:nbsp]}+}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]}|#{Mx[:url_o]}https?://\S+?#{Mx[:url_c]}|file://\S+|<\S+?>|\w+|[a-zA-Z]+}mi - rescue; SiSU_Errors::Info_error.new($!,$@,@md.opt.cmd,@md.fns).error + rescue; SiSU_Errors::InfoError.new($!,$@,@md.opt.cmd,@md.fns).error end end def songsheet begin + #fix to use + p __LINE__.to_s + ':' + __FILE__ + p "#{@path}/content/#{@md.fn[:epub_concord]}" + p "#{@md.file.output_path.epub.dir}/#{@md.file.base_filename.epub}" @file_concordance=File.open("#{@path}/content/#{@md.fn[:epub_concord]}",'w') map_para - rescue; SiSU_Errors::Info_error.new($!,$@,@md.opt.cmd,@md.fns).error + rescue; SiSU_Errors::InfoError.new($!,$@,@md.opt.cmd,@md.fns).error ensure @file_concordance.close end @@ -202,7 +206,10 @@ WOK @word_map={} @dal_array.each do |line| if defined? line.ocn - if line.is =~/heading/ and line.ln==4; @seg=line.name + if (line.is ==:heading \ + || line.is ==:heading_insert) \ + && line.ln==4 + @seg=line.name end if line.ocn.to_s =~/\d+/; toy=line.ocn.to_s end @@ -210,46 +217,46 @@ WOK and toy !~/^0$/ line.obj=line.obj.split(@rgx_splitlist).join(' ') #%take in word or other match for word in line.obj.scan(@rgx_scanlist) #%take in word or other match - word.gsub!(/#{Mx[:lnk_o]}|#{Mx[:lnk_c]}|#{Mx[:url_o]}|#{Mx[:url_c]}/,'') - word.gsub!(/#{Mx[:fa_o]}\S+?#{Mx[:fa_o_c]}/,'') - word.gsub!(/#{Mx[:fa_c_o]}\S+?#{Mx[:fa_c]}/,'') - word.gsub!(/#{Mx[:gl_o]}#[a-z]+#{Mx[:gl_c]}/,'') - word.gsub!(/#{Mx[:gl_o]}#[0-9]+#{Mx[:gl_c]}/,'') - word.gsub!(/^\S$/,'') + word=word.gsub(/#{Mx[:lnk_o]}|#{Mx[:lnk_c]}|#{Mx[:url_o]}|#{Mx[:url_c]}/,''). + gsub(/#{Mx[:fa_o]}\S+?#{Mx[:fa_o_c]}/,''). + gsub(/#{Mx[:fa_c_o]}\S+?#{Mx[:fa_c]}/,''). + gsub(/#{Mx[:gl_o]}#[a-z]+#{Mx[:gl_c]}/,''). + gsub(/#{Mx[:gl_o]}#[0-9]+#{Mx[:gl_c]}/,''). + gsub(/^\S$/,'') word=nil if word.empty? word=nil if word =~@rxp_excluded0 #watch word=nil if word =~@rxp_excluded1 #watch word=nil if word =~/^\S$/ if word - word.gsub!(/#{Mx[:br_nl]}|#{Mx[:br_line]}/,' ') - word.gsub!(/#{Mx[:fa_o]}[a-z]{1,7}#{Mx[:fa_o_c]}|#{Mx[:fa_c_o]}[a-z]{1,7}#{Mx[:fa_c]}/,'') - word.gsub!(/#{Mx[:mk_o]}(?:[0-9a-f]{32}:[0-9a-f]{32}|[0-9a-f]{64}:[0-9a-f]{64})#{Mx[:mk_c]}/,'') - word.gsub!(/#{Mx[:mk_o]}(?:[0-9a-f]{32}|[0-9a-f]{64})#{Mx[:mk_c]}/,'') - word.gsub!(/#{Mx[:en_a_o]}(?:\d|[*+])*|#{Mx[:en_b_o]}(?:\d|[*+])*|#{Mx[:en_a_c]}|#{Mx[:en_b_c]}/mi,'') - word.gsub!(/#{Mx[:fa_o]}\S+?#{Mx[:fa_o_c]}/,''); word.gsub!(/#{Mx[:fa_c_o]}\S+?#{Mx[:fa_c]}/,'') - word.gsub!(/<\/?\S+?>/,'') - word.gsub!(/^\@+/,'') - word.strip! - word.gsub!(/#{Mx[:tc_p]}.+/,'') - word.gsub!(/[\.,;:"]$/,'') - word.gsub!(/["]/,'') - word.gsub!(/^\s*[\(]/,'') - word.gsub!(/[\(]\s*$/,'') - word.gsub!(/^(?:See|e\.?g\.?).+/,'') - word.gsub!(/^\s*[.,;:]\s*/,'') - word.strip! - word.gsub!(/^\(?[a-zA-Z]\)$/,'') - word.gsub!(/^\d+(st|nd|rd|th)$/,'') - word.gsub!(/^(\d+\.?)+$/, '') - word.gsub!(/#{Mx[:mk_o]}|#{Mx[:mk_c]}/,'') - word.gsub!(/:name#\S+/,'') - word.gsub!(/^\S$/,'') + word=word.gsub(/#{Mx[:br_nl]}|#{Mx[:br_line]}/,' '). + gsub(/#{Mx[:fa_o]}[a-z]{1,7}#{Mx[:fa_o_c]}|#{Mx[:fa_c_o]}[a-z]{1,7}#{Mx[:fa_c]}/,''). + gsub(/#{Mx[:mk_o]}(?:[0-9a-f]{32}:[0-9a-f]{32}|[0-9a-f]{64}:[0-9a-f]{64})#{Mx[:mk_c]}/,''). + gsub(/#{Mx[:mk_o]}(?:[0-9a-f]{32}|[0-9a-f]{64})#{Mx[:mk_c]}/,''). + gsub(/#{Mx[:en_a_o]}(?:\d|[*+])*|#{Mx[:en_b_o]}(?:\d|[*+])*|#{Mx[:en_a_c]}|#{Mx[:en_b_c]}/mi,''). + gsub(/#{Mx[:fa_o]}\S+?#{Mx[:fa_o_c]}/,'').gsub(/#{Mx[:fa_c_o]}\S+?#{Mx[:fa_c]}/,''). + gsub(/<\/?\S+?>/,''). + gsub(/^\@+/,''). + strip. + gsub(/#{Mx[:tc_p]}.+/,''). + gsub(/[\.,;:"]$/,''). + gsub(/["]/,''). + gsub(/^\s*[\(]/,''). + gsub(/[\(]\s*$/,''). + gsub(/^(?:See|e\.?g\.?).+/,''). + gsub(/^\s*[.,;:]\s*/,''). + strip. + gsub(/^\(?[a-zA-Z]\)$/,''). + gsub(/^\d+(st|nd|rd|th)$/,''). + gsub(/^(\d+\.?)+$/, ''). + gsub(/#{Mx[:mk_o]}|#{Mx[:mk_c]}/,''). + gsub(/:name#\S+/,''). + gsub(/^\S$/,'') word=nil if word =~/^\S$/ word=nil if word =~/^\s*$/ #watch if word unless word =~/[A-Z][A-Z]/ \ or word =~/\w+\s\w+/ - word.capitalize! + word=word.capitalize end @freq[word] +=1 @word_map[word] ||= [] @@ -272,7 +279,7 @@ WOK end scr='<font size="1" color="#777777" face=times new roman><img border="0" height="15" width="15" src="../_sisu/image/b_doc.png" alt="Full Text"> scroll: </font><font size="1" color="#222222" face=times new roman>doc# </font> ' seg='' - @file_concordance << SiSU_EPUB_Concordance::Source::Doc_title.new(@particulars).create + @file_concordance << SiSU_EPUB_Concordance::Source::DocTitle.new(@particulars).create alph=%W[A B C D E F G H I J K L M N O P Q R S T U V W X Y Z] @file_concordance << '<p>' alph.each {|x| @file_concordance << %{<a href="##{x}">#{x}</a>, }} diff --git a/lib/sisu/v3/epub_format.rb b/lib/sisu/v3/epub_format.rb index 31bae51b..e11f5d3d 100644 --- a/lib/sisu/v3/epub_format.rb +++ b/lib/sisu/v3/epub_format.rb @@ -58,31 +58,27 @@ =end module SiSU_EPUB_Format include SiSU_Viz - class Paragraph_number + class ParagraphNumber def initialize(md,ocn) @md,@ocn=md,ocn.to_s @ocn ||='' - vz=SiSU_Env::Get_init.instance.skin - @skin_no_ocn=if defined? vz.ocn_display_off \ - and vz.ocn_display_off==true - true - else false - end + vz=SiSU_Env::GetInit.instance.skin end def ocn_display - if @md.markup.inspect =~/no_ocn/ \ - or @md.opt.mod.inspect =~/--no-ocn/ \ - or @skin_no_ocn - ocn_class='ocn_off' - @ocn.gsub(/^(\d+|)$/, - %{<label class="#{ocn_class}"> </label>}) - elsif @ocn.to_i==0 - @ocn.gsub(/^(\d+|)$/, - %{<label class="#{ocn_class}"> </label>}) - else + @make=SiSU_Env::ProcessingSettings.new(@md) + if @make.build.ocn? ocn_class='ocn' + if @ocn.to_i==0 + @ocn.gsub(/^(\d+|)$/, + %{<label class="#{ocn_class}"> </label>}) + else + @ocn.gsub(/^(\d+|)$/, + %{<label class="#{ocn_class}"><a href="#o\\1" class="lnk#{ocn_class}">\\1</a></label>}) + end + else + ocn_class='ocn_off' @ocn.gsub(/^(\d+|)$/, - %{<label class="#{ocn_class}"><a href="#o\\1" class="lnk#{ocn_class}">\\1</a></label>}) + %{<label class="#{ocn_class}"> </label>}) end end def name @@ -95,7 +91,7 @@ module SiSU_EPUB_Format %{<a href="##{@ocn}">} end end - class Css + class CSS def css_epub_xhtml <<WOK /* SiSU epub css default stylesheet */ @@ -1198,36 +1194,6 @@ module SiSU_EPUB_Format background-color: #f9f9aa; } - .minitoc { - font-weight: normal; - margin-top: 2px; - margin-bottom: 2px; - } - h1.minitoc, h2.minitoc, h3.minitoc { - margin-left: 0em; - font-weight: bold; - text-align: left; - font-size: 90%; - margin-top: 4px; - margin-bottom: 4px; - } - h4.minitoc { - margin-left: 0em; - font-size: 90%; - } - h5.minitoc { - margin-left: 1em; - font-size: 85%; - } - h6.minitoc { - margin-left: 2em; - font-size: 85%; - } - h0.minitoc { - margin-left: 0em; - font-size: 90%; - } - h1.c, h2.c, h3.c, h4.c, h5.c, h6.c, p.c { text-align: center } @@ -1252,14 +1218,14 @@ module SiSU_EPUB_Format WOK end end - class Head_information + class HeadInformation include SiSU_Viz attr_reader :md,:rdf,:vz def initialize(md) @md=md # DublinCore 1 - title - @vz=SiSU_Env::Get_init.instance.skin - @css=SiSU_Env::CSS_stylesheet.new(md) + @vz=SiSU_Env::GetInit.instance.skin + @css=SiSU_Env::CSS_Stylesheet.new(md) @seg_name_xhtml=(SiSU_EPUB::Source::Seg.new.seg_name_xhtml || []) @seg_name_xhtml_tracker=(SiSU_EPUB::Source::Seg.new.seg_name_xhtml_tracker || []) @index='index' @@ -1493,12 +1459,12 @@ WOK m=(m.empty?) \ ? (surname + other_names) : (m + '; ' + surname + ', ' + other_names) - m.gsub!(/</,'<'); m.gsub!(/>/,'>') - m.gsub!(/<br(?: \/)?>/,';') + m=m.gsub(/</,'<').gsub(/>/,'>'). + gsub(/<br(?: \/)?>/,';') end x=@md.creator.author.dup - x.gsub!(/</,'<'); x.gsub!(/>/,'>') - x.gsub!(/<br(?: \/)?>/,'<br />') + x=x.gsub(/</,'<').gsub(/>/,'>'). + gsub(/<br(?: \/)?>/,'<br />') %{\n <dc:creator opf:file-as="#{m}" opf:role="aut">#{x}</dc:creator>} else '' end @@ -1515,12 +1481,12 @@ WOK m=(m.empty?) \ ? (surname + other_names) : (m + '; ' + surname + ', ' + other_names) - m.gsub!(/</,'<'); m.gsub!(/>/,'>') - m.gsub!(/<br(?: \/)?>/,';') + m=m.gsub(/</,'<').gsub(/>/,'>'). + gsub(/<br(?: \/)?>/,';') end x=@md.creator.editor.dup - x.gsub!(/</,'<'); x.gsub!(/>/,'>') - x.gsub!(/<br(?: \/)?>/,'<br />') + x=x.gsub(/</,'<').gsub(/>/,'>'). + gsub(/<br(?: \/)?>/,'<br />') %{\n <dc:creator opf:file-as="#{m}" opf:role="edt">#{x}</dc:creator>} else '' end @@ -1537,12 +1503,12 @@ WOK m=(m.empty?) \ ? (surname + other_names) : (m + '; ' + surname + ', ' + other_names) - m.gsub!(/</,'<'); m.gsub!(/>/,'>') - m.gsub!(/<br(?: \/)?>/,';') + m=m.gsub(/</,'<').gsub(/>/,'>'). + gsub(/<br(?: \/)?>/,';') end x=@md.creator.translator.dup - x.gsub!(/</,'<'); x.gsub!(/>/,'>') - x.gsub!(/<br(?: \/)?>/,'<br />') + x=x.gsub(/</,'<').gsub(/>/,'>'). + gsub(/<br(?: \/)?>/,'<br />') %{\n <dc:creator opf:file-as="#{m}" opf:role="trl">#{x}</dc:creator>} else '' end @@ -1559,28 +1525,28 @@ WOK m=(m.empty?) \ ? (surname + other_names) : (m + '; ' + surname + ', ' + other_names) - m.gsub!(/</,'<'); m.gsub!(/>/,'>') - m.gsub!(/<br(?: \/)?>/,';') + m=m.gsub(/</,'<').gsub(/>/,'>'). + gsub(/<br(?: \/)?>/,';') end x=@md.creator.illustrator.dup - x.gsub!(/</,'<'); x.gsub!(/>/,'>') - x.gsub!(/<br(?: \/)?>/,'<br />') + x=x.gsub(/</,'<').gsub(/>/,'>'). + gsub(/<br(?: \/)?>/,'<br />') %{\n <dc:creator opf:file-as="#{m}" opf:role="ill">#{x}</dc:creator>} else '' end date_published=if defined? @md.date.published \ and @md.date.published =~/\S+/ x=@md.date.published.dup - x.gsub!(/</,'<'); x.gsub!(/>/,'>') - x.gsub!(/<br(?: \/)?>/,'<br />') + x=x.gsub(/</,'<').gsub(/>/,'>'). + gsub(/<br(?: \/)?>/,'<br />') %{\n <dc:date opf:event="published">#{x}</dc:date>} else '' end subject=if defined? @md.classify.subject \ and @md.classify.subject =~/\S+/ x=@md.classify.subject.dup - x.gsub!(/</,'<'); x.gsub!(/>/,'>') - x.gsub!(/<br(?: \/)?>/,'<br />') + x=x.gsub(/</,'<').gsub(/>/,'>'). + gsub(/<br(?: \/)?>/,'<br />') %{\n <dc:subject>#{x}</dc:subject>} else '' end @@ -1596,7 +1562,7 @@ WOK %{\n <dc:rights>#{rights}</dc:rights>} else '' end - f=SiSU_Env::SiSU_file.new(@md) + f=SiSU_Env::FileOp.new(@md) <<WOK <metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf" @@ -1718,7 +1684,7 @@ WOK </html>} end end - class Head_toc < Head_information + class HeadToc < HeadInformation def initialize(md) super(md) @md=md @@ -1743,7 +1709,7 @@ WOK def manifest_link(text) %{ <a href="#{@md.file.output_path.manifest.url}/#{@md.file.base_filename.manifest}" target="_top" #{@vz.js_manifest}>#{text}</a>} end - def concordance_link(text) #watch fix removed font size 2 + def concordance_link(text) if @md.concord_make %{<a href="#{@md.file.base_filename.html_concordance}" target="_top" #{@vz.js_concordance}> #{text} @@ -1829,7 +1795,7 @@ WOK #{@vz.table_close}} end end - class Head_seg < Head_information + class HeadSeg < HeadInformation def initialize(md) super(md) end @@ -1850,10 +1816,8 @@ WOK <hr class="endnote" /> } end - def title_banner(title,subtitle,creator) - end end - class Head_scroll < Head_toc + class HeadScroll < HeadToc def initialize(md) super(md) end @@ -1870,8 +1834,8 @@ WOK #{@vz.table_close}} end end - class Format_text_object - @vz=SiSU_Env::Get_init.instance.skin + class FormatTextObject + @vz=SiSU_Env::GetInit.instance.skin 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 @@ -1903,7 +1867,7 @@ WOK @named=nametags_seg(@dob) @txt=((defined? t_o.obj) ? t_o.obj : nil) @ocn=((defined? t_o.ocn) ? t_o.ocn.to_s : nil) - @headname=((t_o.is=='heading' and defined? t_o.name) ? t_o.name : nil) + @headname=((t_o.is==:heading and defined? t_o.name) ? t_o.name : nil) else if @md.opt.cmd =~/M/ p __FILE__ +':'+ __LINE__.to_s @@ -1912,10 +1876,10 @@ WOK end end if @txt and not @txt.empty? - @txt.gsub!(/#{Mx[:mk_o]}[-~]##{Mx[:mk_c]}/,'') + @txt=@txt.gsub(/#{Mx[:mk_o]}[-~]##{Mx[:mk_c]}/,'') end - @p_num=Paragraph_number.new(@md,@ocn) - @vz=SiSU_Env::Get_init.instance.skin + @p_num=ParagraphNumber.new(@md,@ocn) + @vz=SiSU_Env::GetInit.instance.skin end def nametags_seg(dob) #FIX tags='' @@ -1951,60 +1915,60 @@ WOK </div> } end - def para_form_css(tag,attrib) # regular paragraphs shaped here + def para_form_css(tag,attrib,txt) # regular paragraphs shaped here ul=ulc='' ul,ulc="<ul>\n ","\n </ul>" if @tag =~/li/ %{ <div class="substance"> #{@p_num.ocn_display} #{ul}<#{tag} class="#{attrib}" #{@p_num.id}> - #{@named}#{@txt} + #{@named}#{txt} </#{tag}>#{ulc} </div> } end def para - para_form_css('p','norm') + para_form_css('p','norm',@txt) end def group - para_form_css('p','group') + para_form_css('p','group',@txt) end def block - para_form_css('p','block') + para_form_css('p','block',@txt) end def alt - para_form_css('p','alt') + para_form_css('p','alt',@txt) end def verse - para_form_css('p','verse') + para_form_css('p','verse',@txt) end def code - para_form_css('p','code') + para_form_css('p','code',@txt) end def center - para_form_css('p','center') + para_form_css('p','center',@txt) end def bold - para_form_css('p','bold') + para_form_css('p','bold',@txt) end def bullet - para_form_css('li','bullet') + para_form_css('li','bullet',@txt) end def table @txt=if @t_o.obj !~/^<table\s/ - table=SiSU_XHTML_shared::Table_xhtml.new(@t_o) #move, make happen earlier - @txt=table.table.obj + table=SiSU_XHTML_Shared::TableXHTML.new(@t_o) #move, make happen earlier + table.table.obj else @txt end - para_form_css('p','norm') + para_form_css('p','norm',@txt) end def break - @txt.gsub!(/#{Mx[:br_page_new]}|#{Mx[:br_page]}/,'<hr /><br />') - @txt.gsub!(/#{Mx[:br_obj]}/,'<hr style="width:30%" /><br />') - para_form_css('p','norm') + @txt=@txt.gsub(/#{Mx[:br_page_new]}|#{Mx[:br_page]}/,'<hr /><br />'). + gsub(/#{Mx[:br_obj]}/,'<hr style="width:30%" /><br />') + para_form_css('p','norm',@txt) end def format(tag,attrib) - para_form_css(tag,attrib) + para_form_css(tag,attrib,@txt) end def title_heading(tag,attrib) %{ @@ -2033,8 +1997,8 @@ WOK def title_heading4 '' end - def seg_heading_sub(tag,attrib) - @txt.gsub!(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ') + def seg_heading_sub(tag,attrib,txt) + txt=txt.gsub(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ') %{ <div class="substance"> #{@p_num.ocn_display} @@ -2055,10 +2019,10 @@ WOK } end def seg_heading5 - seg_heading_sub('p','bold') + seg_heading_sub('p','bold',@txt) end def seg_heading6 - seg_heading_sub('p','bold') + seg_heading_sub('p','bold',@txt) end def dl #check :trailer "<dl><b>#{@txt}</b> #{@trailer}</dl>" @@ -2068,18 +2032,19 @@ WOK </p> </div>' end - def gsub_body - case @txt + def gsub_body #unused + @txt=case @txt when /^(?:#{Mx[:pa_o]}i[1-9]#{Mx[:pa_c]}\s*)?\((i+|iv|v|vi+|ix|x|xi+)\)/ - @txt.gsub!(/^\((i+|iv|v|vi+|ix|x|xi+)\)/,'<b>(\1)</b>') - @txt.gsub!(/^(#{Mx[:pa_o]}i[1-9]#{Mx[:pa_c]})\s*\((i+|iv|v|vi+|ix|x|xi+)\)/,'\1<b>(\2)</b>') + @txt.gsub(/^\((i+|iv|v|vi+|ix|x|xi+)\)/,'<b>(\1)</b>'). + gsub(/^(#{Mx[:pa_o]}i[1-9]#{Mx[:pa_c]})\s*\((i+|iv|v|vi+|ix|x|xi+)\)/,'\1<b>(\2)</b>') when /^(?:#{Mx[:pa_o]}i[1-9]#{Mx[:pa_c]}\s*)?\(?(\d|[a-z])+\)/ - @txt.gsub!(/^\((\d+|[a-z])+\)/,'<b>(\1)</b>') - @txt.gsub!(/^(#{Mx[:pa_o]}i[1-9]#{Mx[:pa_c]})\s*\((\d+|[a-z])+\)/,'\1<b>(\2)</b>') + @txt.gsub(/^\((\d+|[a-z])+\)/,'<b>(\1)</b>'). + gsub(/^(#{Mx[:pa_o]}i[1-9]#{Mx[:pa_c]})\s*\((\d+|[a-z])+\)/,'\1<b>(\2)</b>') when /^\s*\d{1,3}\.\s/ - @txt.gsub!(/^\s*(\d+\.)/,'<b>\1</b>') + @txt.gsub(/^\s*(\d+\.)/,'<b>\1</b>') when /^\s*[A-Z]\.\s/ - @txt.gsub!(/^\s*([A-Z]\.)/,'<b>\1</b>') + @txt.gsub(/^\s*([A-Z]\.)/,'<b>\1</b>') + else @txt end end def bold_para @@ -2091,9 +2056,9 @@ WOK #{@vz.table_close}} end - def bold_heading - @txt.gsub!(/[1-9]~\S+/,'') - @txt.gsub!(/[1-9]~/,'') + def bold_heading #unused + @txt=@txt.gsub(/[1-9]~\S+/,''). + gsub(/[1-9]~/,'') %{<p class="bold"> #{@txt} </p> @@ -2114,62 +2079,16 @@ WOK %{<p class="centerbold">#{@txt}</p>\n} end end - class Format_scroll < Format_text_object + class FormatScroll < FormatTextObject def initialize(md,txt) super(md,txt) - @vz=SiSU_Env::Get_init.instance.skin + @vz=SiSU_Env::GetInit.instance.skin end end - class Format_seg < Format_text_object + class FormatSeg < FormatTextObject def initialize(md,txt) super(md,txt) end - def navigation_toc_lev1_advert - %{#{@banner.home_button}\n -<p class="center"> -#{@txt} -#{@two} -</a></p>} - end - def navigation_toc_lev1 - %{#{@banner.nav_toc}} - end - def navigation_toc_lev2 #change bold use css - %{<table summary="navigation segment level 2"> -<tr><td width ="20"> -</td> -<td> - <font size="3" #{@vz.font_face}> - <b>#{@txt}</b> - </font> - </p> -#{@vz.table_close}} - end - def navigation_toc_lev3 #change bold use css - %{<table summary="navigation segment level 3"> -<tr><td width ="20"> -</td> -<td> - <font size="3" #{@vz.font_face}> - <b>#{@txt}</b> - </font> - </p> -#{@vz.table_close}} - end - def navigation_toc_lev4 - %{<table summary="navigation segment level 4"> -<tr><td width ="80"> -</td> -<td> -<p> - #{@txt} -</p> -#{@vz.table_close}} - end - def navigation_toc_lev5 - end - def navigation_toc_lev6 - end def endnote_seg_body(fn='') #FIX #url construction keep within single line... BUG WATCH 200408 fn='doc' if fn.to_s.empty? #you may wish to reconsider, sends to 'doc' where no segment info %{ @@ -2179,9 +2098,8 @@ WOK } end def clean(txt) - txt.gsub!(/#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}/,'') - txt.gsub!(/#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]}/,'') - txt + txt=txt.gsub(/#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}/,''). + gsub(/#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]}/,'') end def subtoc_lev(tag,attrib) @txt=clean(@txt) @@ -2193,10 +2111,10 @@ 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.gsub!(/[\n\s]+/m,' ') - txt.gsub!(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ') - txt.gsub!(/<a[\n\s]+"[\n\s]+href="#note_ref\d+"> <sup id="note\d+">\d+<\/sup> /m,'') - txt.gsub!(/<a[\n\s]+"[\n\s]+href="#note_ref\d+">#{Mx[:nbsp]}<sup id="note\d+">\d+<\/sup>#{Mx[:nbsp]}/m,'') #remove + note=note.gsub(/[\n\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+"> <sup id="note\d+">\d+<\/sup> /m,''). + gsub(/<a[\n\s]+"[\n\s]+href="#note_ref\d+">#{Mx[:nbsp]}<sup id="note\d+">\d+<\/sup>#{Mx[:nbsp]}/m,'') #remove end %{<#{tag} class="#{attrib}"> <a href="#o#{@ocn}"><i>#{txt}</i></a> #{note} @@ -2208,8 +2126,8 @@ WOK def subtoc_lev6 subtoc_lev('h6','subtoc') if @txt end - def heading_sub(tag,attrib) - @txt.gsub!(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ') + def heading_sub(tag,attrib,txt) + txt=txt.gsub(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ') %{ <div class="substance"> #{@p_num.ocn_display} @@ -2231,10 +2149,10 @@ WOK } end def heading5 - heading_sub('p','bold') + heading_sub('p','bold',@txt) end def heading6 - heading_sub('p','bold') + heading_sub('p','bold',@txt) end def navigation_heading4 %{<table summary="navigation segment heading 4" width=100% bgcolor="#08163f" border="0"> @@ -2258,7 +2176,7 @@ WOK %{<p class="centerbold">#{@txt}</p>} end end - class Format_toc < Format_text_object + class FormatToc < FormatTextObject def initialize(md,txt) super(md,txt) end @@ -2300,44 +2218,6 @@ WOK def lev0 #docinfo lev('h0','toc') end - def mini_lev1 - lev('h1','minitoc') - end - def mini_lev2 - lev('h2','minitoc') - end - def mini_lev3 - lev('h3','minitoc') - end - def mini_lev4 - lev('h4','minitoc') - end - def mini_lev5 - lev('h5','minitoc') - end - def mini_lev6 - lev('h6','minitoc') - end - def mini_lev0 #docinfo - lev('h0','minitoc') - end - def mini_tail - %{ - <h4 class="minitoc"> - <a href="sisu_manifest.html">Manifest (alternative outputs)</a> - </h4> -} - end - def mini_concord_tail - %{ - <h4 class="minitoc"> - <a href="concordance.html">Concordance (wordlist)</a> - </h4> - <h4 class="minitoc"> - <a href="sisu_manifest.html">Manifest (alternative outputs)</a> - </h4> -} - end end end __END__ diff --git a/lib/sisu/v3/epub_segments.rb b/lib/sisu/v3/epub_segments.rb index 5e08968a..262fde3c 100644 --- a/lib/sisu/v3/epub_segments.rb +++ b/lib/sisu/v3/epub_segments.rb @@ -56,41 +56,38 @@ ** Description: epub segment generation, processing =end -module SiSU_EPUB_seg +module SiSU_EPUB_Seg require_relative 'shared_xhtml' # shared_xhtml.rb require_relative 'epub' # epub.rb require_relative 'shared_metadata' # shared_metadata.rb - class Seg_output - def initialize(md,outputfile,seg,minitoc,type='') - @md,@output_epub_cont_seg,@seg,@minitoc,@type=md,outputfile,seg,minitoc,type + class Output + def initialize(md,outputfile,seg,type='') + @md,@output_epub_cont_seg,@seg,@type=md,outputfile,seg,type end def output #CONSIDER if @seg[:title] =~/\S/ filename_seg=[] filename_seg << @seg[:title] << @seg[:nav] if @type=='endnotes' - @seg[:headings]=[] + @seg[:headings]=[] #watch txt_obj={ txt: 'Endnotes', ocn_display: ''} - format_seg=SiSU_EPUB_Format::Format_seg.new(@md,txt_obj) + format_seg=SiSU_EPUB_Format::FormatSeg.new(@md,txt_obj) @seg[:headings] << format_seg.title_heading1 filename_seg << @seg[:heading_endnotes] << @seg[:headings] << %{\n<div class="content">\n} << @seg[:endnote_all] << '</div>' elsif @type=='idx' @seg[:headings]=[] - format_head_seg=SiSU_EPUB_Format::Head_seg.new(@md) - format_seg=SiSU_EPUB_Format::Format_seg.new(@md,txt_obj) + format_seg=SiSU_EPUB_Format::FormatSeg.new(@md,txt_obj) @seg[:headings] << format_seg.title_heading1 filename_seg << @seg[:heading_idx] << @seg[:headings] << %{\n<div class="content">\n} << @seg[:idx] << '</div>' elsif @type=='metadata' - metadata=Metadata::Summary.new(@md).xhtml_display.metadata + metadata=SiSU_Metadata::Summary.new(@md).xhtml_display.metadata @seg[:headings]=[] - format_head_seg=SiSU_EPUB_Format::Head_seg.new(@md) - @seg[:headings] << format_head_seg.title_banner(@md.title.main,@md.title.sub,@author) txt_obj={ txt: 'Metadata', ocn_display: ''} - format_seg=SiSU_EPUB_Format::Format_seg.new(@md,txt_obj) + format_seg=SiSU_EPUB_Format::FormatSeg.new(@md,txt_obj) @seg[:headings] << format_seg.title_heading1 filename_seg << @seg[:heading_idx] << @seg[:headings] << %{\n<div class="content">\n} << metadata << '</div>' elsif @type=='sisu_manifest' - env=SiSU_Env::Info_env.new(@md.fns) + env=SiSU_Env::InfoEnv.new(@md.fns) path_and_name,url_and_name="#{env.path.output}/#{@md.fnb}/sisu_manifest.html","#{env.url.root}/#{@md.fnb}/sisu_manifest.html" manifest=if FileTest.file?("#{path_and_name}")==true <<WOK @@ -100,21 +97,18 @@ WOK else '' end @seg[:headings]=[] - format_head_seg=SiSU_EPUB_Format::Head_seg.new(@md) - @seg[:headings] << format_head_seg.title_banner(@md.title.main,@md.title.sub,@author) txt_obj={ txt: 'Manifest', ocn_display: ''} - format_seg=SiSU_EPUB_Format::Format_seg.new(@md,txt_obj) + format_seg=SiSU_EPUB_Format::FormatSeg.new(@md,txt_obj) @seg[:headings] << format_seg.title_heading1 filename_seg << @seg[:heading_idx] << @seg[:headings] << %{\n<div class="content">\n} << manifest << '</div>' else filename_seg << @seg[:headings] << @seg[:main] << "\n</div>\n" end filename_seg << @seg[:tail] << @seg[:nav] << @seg[:close] - filename_seg.flatten!.compact! + filename_seg=filename_seg.flatten.compact #watch filename_seg.each do |str| unless str =~/\A\s*\Z/ - str.strip! - @output_epub_cont_seg << str + @output_epub_cont_seg << str.strip end end @output_epub_cont_seg.close @@ -128,25 +122,25 @@ WOK @@loop_count=@@seg_total=@@tracker=0 @@is4=@@is3=@@is2=@@is1=0 @@heading1=@@heading2=@@heading3=@@heading4=0 - @@seg[:title],@@seg[:headings],@@seg[:main],@@seg[:idx],@@seg[:tail],@@seg_subtoc_array,@@seg_endnotes_array,@@seg[:endnote_all]=Array.new(8){[]} + @@seg[:headings],@@seg[:main],@@seg[:idx],@@seg[:tail],@@seg_subtoc_array,@@seg_endnotes_array,@@seg[:endnote_all]=Array.new(7){[]} @@seg[:heading_endnotes]='' @@tablehead,@@number_of_cols=0,0 @@fns_previous='' attr_reader :seg_name_xhtml,:seg_name_xhtml_tracker def initialize(md='',data='') @md,@data=md,data - @vz=SiSU_Env::Get_init.instance.skin + @vz=SiSU_Env::GetInit.instance.skin @seg_name_xhtml=@@seg_name_xhtml || nil @seg_name_xhtml_tracker=@@tracker || nil + @make=SiSU_Env::ProcessingSettings.new(@md) if @md end def songsheet begin - @minitoc=SiSU_EPUB::Source::Toc.new(@md,@data).minitoc data=get_subtoc_endnotes(@data) data=articles(data) - Seg.new.cleanup # (((( added )))) + SiSU_EPUB_Seg::Seg.new.cleanup # (((( added )))) #### (((( END )))) #### - rescue; SiSU_Errors::Info_error.new($!,$@,@md.opt.cmd,@md.fns).error + rescue; SiSU_Errors::InfoError.new($!,$@,@md.opt.cmd,@md.fns).error ensure @@seg_name=[] end @@ -158,13 +152,13 @@ WOK printed_endnote_seg='n' idx_xhtml=nil if @md.book_idx - idx_xhtml=SiSU_Particulars::Combined_singleton.instance.get_idx_xhtml(@md).xhtml_idx + idx_xhtml=SiSU_Particulars::CombinedSingleton.instance.get_idx_xhtml(@md).xhtml_idx idx_xhtml.each {|x| @@seg[:idx] << x } @@seg[:heading_idx]='' end data.each do |dob| - if (dob.is=='heading' \ - || dob.is=='heading_insert') \ + if (dob.is==:heading \ + || dob.is==:heading_insert) \ and dob.ln==4 @@seg_name << dob.name seg_name=dob.name @@ -174,7 +168,7 @@ WOK @@seg_total=@@seg_name.length testforartnum=@@seg_name_xhtml SiSU_Screen::Ansi.new(@md.opt.cmd,@@seg_name.length) if @md.opt.cmd =~/[MVv]/ - map_nametags=SiSU_Particulars::Combined_singleton.instance.get_map_nametags(@md).nametags_map #p map_nametags + map_nametags=SiSU_Particulars::CombinedSingleton.instance.get_map_nametags(@md).nametags_map #p map_nametags data.each do |dob| #if defined? dob.obj \ #and dob.obj =~/href="#{Xx[:segment]}#+\S+?"/ @@ -182,15 +176,15 @@ WOK # #while dob.obj =~/href="#{Xx[:segment]}#+(\S+?)"/ # # m=$1 # # if map_nametags[m][:segname] - # # dob.obj.sub!(/href="#{Xx[:segment]}#+(\S+?)"/,%{href="#{map_nametags[m][:segname]}#{Sfx[:html]}#\\1"}) + # # dob.obj=dob.obj.sub(/href="#{Xx[:segment]}#+(\S+?)"/,%{href="#{map_nametags[m][:segname]}#{Sfx[:html]}#\\1"}) # # else # # p "NOT FOUND name_tags: #{m}" - # # dob.obj.sub!(/href="#{Xx[:segment]}#+(\S+?)"/,%{href="#\\1"}) # not satisfactory + # # dob.obj=dob.obj.sub(/href="#{Xx[:segment]}#+(\S+?)"/,%{href="#\\1"}) # not satisfactory # # end # #end #end - if (dob.is=='heading' \ - || dob.is=='heading_insert') \ + if (dob.is==:heading \ + || dob.is==:heading_insert) \ and dob.ln==4 if dob.ocn==0 @@heading4=dob.obj @@ -198,27 +192,27 @@ WOK end @@is4=newfile=1 end - if (dob.is=='heading' \ - || dob.is=='heading_insert') \ + if (dob.is==:heading \ + || dob.is==:heading_insert) \ and dob.ln==3 @@heading3=dob.obj @@is4,@@is3=0,1 end - if (dob.is=='heading' \ - || dob.is=='heading_insert') \ + if (dob.is==:heading \ + || dob.is==:heading_insert) \ and dob.ln==2 @@heading2=dob.obj @@is4,@@is3,@@is2=0,0,1 end - if (dob.is=='heading' \ - || dob.is=='heading_insert') \ + if (dob.is==:heading \ + || dob.is==:heading_insert) \ and dob.ln==1 @@heading1=dob.obj @@is4,@@is3,@@is2,@@is1=0,0,0,1 end if (@@is1 && !@@is2 && !@@is3 && !@@is4) - if not (dob.is=='heading' \ - || dob.is=='heading_insert') \ + if not (dob.is==:heading \ + || dob.is==:heading_insert) \ and dob.ln==1 head1=$_ #; check end @@ -228,36 +222,36 @@ WOK if newfile==1 \ or dob.obj =~/^#{Mx[:br_endnotes]}|^#{Mx[:br_eof]}/ newfile=0 - if (dob.is=='heading' \ - || dob.is=='heading_insert') \ + if (dob.is==:heading \ + || dob.is==:heading_insert) \ and dob.ln==4 if tracking != 0 - Seg.new(@md).tail + SiSU_EPUB_Seg::Seg.new(@md).tail segfilename="#{dir_epub_cont}/#{@@seg_name_xhtml[tracking-1]}#{Sfx[:epub_xhtml]}" output_epub_cont_seg=File.new(segfilename,'w') if @@seg_name_xhtml[tracking-1] - if dob.is=='heading' \ + if dob.is==:heading \ or @@seg_name_xhtml[tracking-1] !~/endnotes|book_index|metadata/ - Seg_output.new(@md,output_epub_cont_seg,@@seg,@minitoc).output - elsif dob.is=='heading_insert' + SiSU_EPUB_Seg::Output.new(@md,output_epub_cont_seg,@@seg).output + elsif dob.is==:heading_insert if @@seg_name_xhtml[tracking-1]=='endnotes' - Seg_output.new(@md,output_epub_cont_seg,@@seg,@minitoc,'endnotes').output + SiSU_EPUB_Seg::Output.new(@md,output_epub_cont_seg,@@seg,'endnotes').output elsif @@seg_name_xhtml[tracking-1]=='book_index' - Seg_output.new(@md,output_epub_cont_seg,@@seg,@minitoc,'idx').output + SiSU_EPUB_Seg::Output.new(@md,output_epub_cont_seg,@@seg,'idx').output @@seg[:idx]=[] elsif @@seg_name_xhtml[tracking-1]=='metadata' # navigation bug FIX - Seg_output.new(@md,output_epub_cont_seg,@@seg,@minitoc,'metadata').output + SiSU_EPUB_Seg::Output.new(@md,output_epub_cont_seg,@@seg,'metadata').output else puts "#{__FILE__}::#{__LINE__}" end else puts "#{__FILE__}::#{__LINE__}" end - Seg.new.reinitialise + SiSU_EPUB_Seg::Seg.new.reinitialise heading_art(dob) head(dob) - if @@seg_name_xhtml[tracking]=='sisu_manifest' # this is for manifest, includes navigation bug + if @@seg_name_xhtml[tracking] =='metadata' segfilename="#{dir_epub_cont}/#{@@seg_name_xhtml[tracking]}#{Sfx[:epub_xhtml]}" output_epub_cont_seg=File.new(segfilename,'w') - Seg_output.new(@md,output_epub_cont_seg,@@seg,@minitoc,'sisu_manifest').output - Seg.new.reinitialise #BUG navigation bug with items following metadata, and occurring before manifest, this becomes a bug ... work area for book index, FIX + SiSU_EPUB_Seg::Output.new(@md,output_epub_cont_seg,@@seg,'metadata').output + SiSU_EPUB_Seg::Seg.new.reinitialise #BUG navigation bug with items following metadata, and occurring before manifest, this becomes a bug ... work area for book index, FIX end #@output_epub_cont_seg.close #%(((( EOF )))) --> end @@ -268,8 +262,8 @@ WOK end tracking=tracking+1 end - if (dob.is=='heading' \ - || dob.is=='heading_insert') \ + if (dob.is==:heading \ + || dob.is==:heading_insert) \ and dob.ln==4 \ and dob.name @@get_hash_to=dob.name @@ -292,8 +286,7 @@ WOK data end def heading_art(dob) - format_head_seg=SiSU_EPUB_Format::Head_seg.new(@md) - @@seg[:title]=format_head_seg.head + @@seg[:title]=SiSU_EPUB_Format::HeadSeg.new(@md).head end def head(dob) clean=/<!.*?!>|<:.*?>$/ @@ -306,65 +299,67 @@ WOK ocn=if @@heading1[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/]; $1 #fix else '' end - @p_num=SiSU_EPUB_Format::Paragraph_number.new(@md,ocn) + @p_num=SiSU_EPUB_Format::ParagraphNumber.new(@md,ocn) txt_obj={ txt: @@heading1, ocn_display: @p_num.ocn_display } - format_seg=SiSU_EPUB_Format::Format_seg.new(@md,txt_obj) + format_seg=SiSU_EPUB_Format::FormatSeg.new(@md,txt_obj) @@seg[:headings] << format_seg.title_heading1.gsub(clean,'') - @@heading1.gsub!(/ <a name="-[\d*+]+" href="#_[\d*+]+"> <sup>[\d*+]+<\/sup> <\/a>/,'') + @@heading1=@@heading1.gsub(/ <a name="-[\d*+]+" href="#_[\d*+]+"> <sup>[\d*+]+<\/sup> <\/a>/,'') end if @@is2==1 heading2=@@heading2 ocn=if heading2[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/]; $1 #fix else '' end - @p_num=SiSU_EPUB_Format::Paragraph_number.new(@md,ocn) + @p_num=SiSU_EPUB_Format::ParagraphNumber.new(@md,ocn) txt_obj={ txt: heading2, ocn_display: @p_num.ocn_display } - format_seg=SiSU_EPUB_Format::Format_seg.new(@md,txt_obj) + format_seg=SiSU_EPUB_Format::FormatSeg.new(@md,txt_obj) @@seg[:headings] << format_seg.title_heading2.gsub(clean,'') - @@heading2.gsub!(/ <a name="-[\d*+]+" href="#_[\d*+]+"> <sup>[\d*+]+<\/sup> <\/a>/,'') + @@heading2=@@heading2.gsub(/ <a name="-[\d*+]+" href="#_[\d*+]+"> <sup>[\d*+]+<\/sup> <\/a>/,'') end if @@is3==1 heading3=@@heading3 ocn=if heading3[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/]; $1 #fix else '' end - @p_num=SiSU_EPUB_Format::Paragraph_number.new(@md,ocn) + @p_num=SiSU_EPUB_Format::ParagraphNumber.new(@md,ocn) txt_obj={ txt: heading3, ocn_display: @p_num.ocn_display } - format_seg=SiSU_EPUB_Format::Format_seg.new(@md,txt_obj) + format_seg=SiSU_EPUB_Format::FormatSeg.new(@md,txt_obj) @@seg[:headings] << format_seg.title_heading3.gsub(clean,'') - @@heading3.gsub!(/ <a name="-[\d*+]+" href="#_[\d*+]+"> <sup>[\d*+]+<\/sup> <\/a>/,'') + @@heading3=@@heading3.gsub(/ <a name="-[\d*+]+" href="#_[\d*+]+"> <sup>[\d*+]+<\/sup> <\/a>/,'') end if @@is4==1 heading4=@@heading4 ocn=if heading4[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/]; $1 #fix else '' end - @p_num=SiSU_EPUB_Format::Paragraph_number.new(@md,ocn) + @p_num=SiSU_EPUB_Format::ParagraphNumber.new(@md,ocn) txt_obj={ txt: heading4, ocn_display: @p_num.ocn_display } - format_seg=SiSU_EPUB_Format::Format_seg.new(@md,txt_obj) + format_seg=SiSU_EPUB_Format::FormatSeg.new(@md,txt_obj) @@seg[:headings] << format_seg.title_heading4.gsub(clean,'') end @@tracker=@@tracker+1 end def markup(dob) @debug=[] - format_head_seg=SiSU_EPUB_Format::Head_seg.new(@md) - if dob.is =~/(?:heading|para)/ #extend as necessary FIX - @p_num=SiSU_EPUB_Format::Paragraph_number.new(@md,dob.ocn) + if dob.is ==:heading \ + || dob.is ==:heading_insert \ + || dob.is ==:para + #extend as necessary FIX + @p_num=SiSU_EPUB_Format::ParagraphNumber.new(@md,dob.ocn) end - sto=SiSU_EPUB_Format::Format_text_object.new(@md,dob) - dob_xhtml=if dob.is=='heading' \ - or dob.is=='heading_insert' \ - or dob.is=='para' - dob_xhtml=if dob.is=='heading' \ - or dob.is=='heading_insert' + sto=SiSU_EPUB_Format::FormatTextObject.new(@md,dob) + dob_xhtml=if dob.is==:heading \ + || dob.is==:heading_insert \ + || dob.is==:para + dob_xhtml=if dob.is==:heading \ + or dob.is==:heading_insert if dob.ln==4 - sto.seg_heading4 # work on see Split_text_object + sto.seg_heading4 # work on see SplitTextObject elsif dob.ln==5 sto.seg_heading5 elsif dob.ln==6; sto.seg_heading6 end - elsif dob.is=='para' + elsif dob.is==:para if dob.indent \ and dob.hang \ and dob.indent =~/[0-9]/ \ @@ -382,43 +377,49 @@ WOK else sto.para end end - elsif dob.is =~/^(?:block|group|alt)$/ + elsif dob.is ==:block \ + || dob.is ==:group \ + || dob.is ==:alt sto.para #fix this should be block type specific #FIX - elsif dob.is=='verse' + elsif dob.is==:verse sto.verse - elsif dob.is=='code' + elsif dob.is==:code sto.code - elsif dob.is=='table' + elsif dob.is==:table sto.table - elsif dob.is=='break' + elsif dob.is==:break sto.break end if @md.flag_separate_endnotes # may need to revisit, check - 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="#note_ref(\d+)">/,%{" href=\"endnotes#{Sfx[:epub_xhtml]}#note_ref\\1">}) #endnote- twice #removed file type end - if dob.is =~/heading|para/ \ - and (not dob.ocn or dob.ocn.to_s.empty?) - format_seg=SiSU_EPUB_Format::Format_seg.new(@md,dob) + if (dob.is ==:heading \ + || dob.is==:heading_insert \ + || dob.is==:para) \ + && (not dob.ocn or dob.ocn.to_s.empty?) + format_seg=SiSU_EPUB_Format::FormatSeg.new(@md,dob) end - if (dob.is=='heading' \ - || dob.is=='heading_insert' \ - || dob.is=='para') \ + if (dob.is==:heading \ + || dob.is==:heading_insert \ + || dob.is==:para) \ and dob.note_ #dob.obj =~/<a href="#note_ref\d+"> <sup id=/ #endnote- note- - format_seg=SiSU_EPUB_Format::Format_seg.new(@md,dob) + format_seg=SiSU_EPUB_Format::FormatSeg.new(@md,dob) dob.obj=format_seg.no_paranum end - if (dob.is=='heading' \ - || dob.is=='heading_insert') \ + if (dob.is==:heading \ + || dob.is==:heading_insert) \ and dob.ln==4 @@seg[:main] << %{\n<div class="content">\n} @@seg[:main] << dob_xhtml - @@seg[:main] << @@seg_subtoc[@@get_hash_fn] #% insertion of sub-toc + if @make.build.segsubtoc? + @@seg[:main] << @@seg_subtoc[@@get_hash_fn] #% insertion of sub-toc + end else @@seg[:main] << dob_xhtml end end def tail - format_head_seg=SiSU_EPUB_Format::Head_seg.new(@md) + format_head_seg=SiSU_EPUB_Format::HeadSeg.new(@md) if @md.flag_auto_endnotes \ and @@seg_endnotes[@@get_hash_fn] @@seg[:tail] << %{\n<div class="content">\n<div class="endnote">\n} @@ -433,7 +434,7 @@ WOK @@seg[:close] << format_head_seg.xhtml_close end def reinitialise - @@seg[:title],@@seg[:headings],@@seg[:main],@@seg[:tail],@@seg[:credits]=Array.new(5){[]} + @@seg[:headings],@@seg[:main],@@seg[:tail],@@seg[:credits]=Array.new(4){[]} end def cleanup reinitialise @@ -444,10 +445,10 @@ WOK end def get_subtoc_endnotes(data) #get endnotes & sub-table of contents subtoc data.each do |dob| - dob.obj.gsub!(/<a name=\"h\d.*?\">(.+?)<\/a>/mi,'\1') + dob.obj=dob.obj.gsub(/<a name=\"h\d.*?\">(.+?)<\/a>/mi,'\1') if @md.flag_auto_endnotes - if (dob.is=='heading' \ - || dob.is=='heading_insert') \ + if (dob.is==:heading \ + || dob.is==:heading_insert) \ and dob.ln.to_s =~/^[1234]/ \ and not @@fn.to_s.empty? @@seg_endnotes[@@fn]=[] @@ -455,8 +456,8 @@ WOK @@seg_endnotes_array=[] if dob.ln==4 @@fns_previous=@md.fns if dob.ln==4 and dob.name =~/^meta/ end - if (dob.is=='heading' \ - || dob.is=='heading_insert') \ + if (dob.is==:heading \ + || dob.is==:heading_insert) \ and dob.ln==4 #% EXTRACTION OF SUB-TOCs & SEGMENT NAME, after EXTRACTION OF ENDNOTES & SUB-TOCs @@seg_subtoc[@@fn]=@@seg_subtoc_array @@seg_subtoc_array=[] @@ -470,14 +471,14 @@ WOK end end end - if dob.is=='heading' \ + if dob.is==:heading \ and dob.ln.to_s =~/^[56]/ case dob.ln when 5 - format_seg=SiSU_EPUB_Format::Format_seg.new(@md,dob) + format_seg=SiSU_EPUB_Format::FormatSeg.new(@md,dob) subtoc=format_seg.subtoc_lev5 #keep and make available, this is the subtoc when 6 - format_seg=SiSU_EPUB_Format::Format_seg.new(@md,dob) + format_seg=SiSU_EPUB_Format::FormatSeg.new(@md,dob) subtoc=format_seg.subtoc_lev6 #keep and make available, this is the subtoc end @@seg_subtoc_array << subtoc @@ -485,7 +486,7 @@ WOK if @md.flag_auto_endnotes ast,pls='*','+' if dob.obj =~/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]})(?:\d|#{ast}|#{pls})+ / \ - and dob.is !~/^code/ # endnote- + and dob.is !=:code # endnote- endnote_array=[] if dob.obj=~/#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}/m endnote_array << dob.obj.scan(/#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}/m) @@ -496,7 +497,7 @@ WOK if dob.obj=~/#{Mx[:en_b_o]}#{pls}\d+\s.+?#{Mx[:en_b_c]}/m endnote_array << dob.obj.scan(/#{Mx[:en_b_o]}#{pls}\d+\s.+?#{Mx[:en_b_c]}/m) end - endnote_array.flatten! #.compact! #check compacting + endnote_array=endnote_array.flatten #.compact #check compacting endnote_array.each do |note| note_match=note.dup note_match_seg=note.dup @@ -504,7 +505,7 @@ WOK try=e_n.split(/<br \/>/) try.each do |e| txt_obj={ txt: e } - format_seg=SiSU_EPUB_Format::Format_seg.new(@md,txt_obj) + format_seg=SiSU_EPUB_Format::FormatSeg.new(@md,txt_obj) note_match=if e =~/#{Mx[:pa_o]}i[1-9]#{Mx[:pa_c]}/ format_seg.endnote_body_indent else format_seg.endnote_body @@ -517,11 +518,11 @@ WOK 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 } - format_seg=SiSU_EPUB_Format::Format_seg.new(@md,txt_obj) + format_seg=SiSU_EPUB_Format::FormatSeg.new(@md,txt_obj) note_match_all_seg=format_seg.endnote_seg_body(@@fn) #BUG WATCH 200408 @@seg[:endnote_all] << note_match_all_seg end - dob.obj.gsub!(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ') + dob.obj=dob.obj.gsub(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ') end end end diff --git a/lib/sisu/v3/epub_tune.rb b/lib/sisu/v3/epub_tune.rb index b348a7bf..34466926 100644 --- a/lib/sisu/v3/epub_tune.rb +++ b/lib/sisu/v3/epub_tune.rb @@ -76,7 +76,7 @@ module SiSU_EPUB_Tune class Output def initialize(data,md) @data,@md=data,md - @file=SiSU_Env::SiSU_file.new(@md) + @file=SiSU_Env::FileOp.new(@md) @cX=SiSU_Screen::Ansi.new(@md.opt.cmd).cX end def hard_output @@ -91,7 +91,7 @@ module SiSU_EPUB_Tune File.open(@file.marshal.html_tune,'w') {|f| Marshal.dump(@data.to_a,f)} end end - class Clean_xhtml + class CleanXHTML def initialize(html='') @html=html end @@ -101,160 +101,151 @@ module SiSU_EPUB_Tune html else html.obj end - str.gsub!(/#{Mx[:gl_o]}(#[0-9]{3})#{Mx[:gl_c]}/u,'&\1;') - str.gsub!(/#{Mx[:gl_o]}#([a-z]{2,4})#{Mx[:gl_c]}/u,'&\1;') - str.gsub!(/\*/u,'*') # * - str.gsub!(/\+/u,'+') # + - str.gsub!(/¢/u,'¢') # ¢ - str.gsub!(/£/u,'£') # £ - str.gsub!(/¥/u,'¥') # ¥ - str.gsub!(/§/u,'§') # § - str.gsub!(/©/u,'©') # © - str.gsub!(/ª/u,'ª') # ª - str.gsub!(/«/u,'«') # « - str.gsub!(/®/u,'®') # ® - str.gsub!(/°/u,'°') # ° - str.gsub!(/±/u,'±') # ± - str.gsub!(/²/u,'²') # ² - str.gsub!(/³/u,'³') # ³ - str.gsub!(/µ/u,'µ') # µ - str.gsub!(/¶/u,'¶') # ¶ - str.gsub!(/¹/u,'¹') # ¹ - str.gsub!(/º/u,'º') # º - str.gsub!(/»/u,'»') # » - str.gsub!(/¼/u,'¼') # ¼ - str.gsub!(/½/u,'½') # ½ - str.gsub!(/¾/u,'¾') # ¾ - str.gsub!(/×/u,'×') # × - str.gsub!(/÷/u,'÷') # ÷ - str.gsub!(/¿/u,'¿') # ¿ - str.gsub!(/À/u,'À') # À - str.gsub!(/Á/u,'Á') # Á - str.gsub!(/Â/u,'Â') #  - str.gsub!(/Ã/u,'Ã') # à - str.gsub!(/Ä/u,'Ä') # Ä - str.gsub!(/Å/u,'Å') # Å - str.gsub!(/Æ/u,'Æ') # Æ - str.gsub!(/Ç/u,'Ç') # Ç - str.gsub!(/È/u,'È') # È - str.gsub!(/É/u,'É') # É - str.gsub!(/Ê/u,'Ê') # Ê - str.gsub!(/Ë/u,'Ë') # Ë - str.gsub!(/Ì/u,'Ì') # Ì - str.gsub!(/Í/u,'Í') # Í - str.gsub!(/Î/u,'Î') # Î - str.gsub!(/Ï/u,'Ï') # Ï - str.gsub!(/Ð/u,'Ð') # Ð - str.gsub!(/Ñ/u,'Ñ') # Ñ - str.gsub!(/Ò/u,'Ò') # Ò - str.gsub!(/Ó/u,'Ó') # Ó - str.gsub!(/Ô/u,'Ô') # Ô - str.gsub!(/Õ/u,'Õ') # Õ - str.gsub!(/Ö/u,'Ö') # Ö - str.gsub!(/Ø/u,'Ø') # Ø - str.gsub!(/Ù/u,'Ù') # Ù - str.gsub!(/Ú/u,'Ú') # Ú - str.gsub!(/Û/u,'Û') # Û - str.gsub!(/Ü/u,'Ü') # Ü - str.gsub!(/Ý/u,'Ý') # Ý - str.gsub!(/Þ/u,'Þ') # Þ - str.gsub!(/ß/u,'ß') # ß - str.gsub!(/à/u,'à') # à - str.gsub!(/á/u,'á') # á - str.gsub!(/â/u,'â') # â - str.gsub!(/ã/u,'ã') # ã - str.gsub!(/ä/u,'ä') # ä - str.gsub!(/å/u,'å') # å - str.gsub!(/æ/u,'æ') # æ - str.gsub!(/ç/u,'ç') # ç - str.gsub!(/è/u,'è') # è - str.gsub!(/é/u,'é') # é - str.gsub!(/ê/u,'ê') # ê - str.gsub!(/ë/u,'ë') # ë - str.gsub!(/ì/u,'ì') # ì - str.gsub!(/í/u,'í') # í - str.gsub!(/î/u,'î') # î - str.gsub!(/ï/u,'ï') # ï - str.gsub!(/ð/u,'ð') # ð - str.gsub!(/ñ/u,'ñ') # ñ - str.gsub!(/ò/u,'ò') # ò - str.gsub!(/ó/u,'ó') # ó - str.gsub!(/ô/u,'ô') # ô - str.gsub!(/õ/u,'õ') # õ - str.gsub!(/ö/u,'ö') # ö - str.gsub!(/ø/u,'ø') # ø - str.gsub!(/ù/u,'ù') # ú - str.gsub!(/ú/u,'ú') # û - str.gsub!(/û/u,'û') # ü - str.gsub!(/ü/u,'ü') # ý - str.gsub!(/þ/u,'þ') # þ - str.gsub!(/ÿ/u,'ÿ') # ÿ - str.gsub!(/ý/u,'ý') - str.gsub!(/<br>/u,'<br />') - str.gsub(/#{Mx[:nbsp]}/u,' ') - str + 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(/\*/u,'*'). # * + gsub(/\+/u,'+'). # + + gsub(/¢/u,'¢'). # ¢ + gsub(/£/u,'£'). # £ + gsub(/¥/u,'¥'). # ¥ + gsub(/§/u,'§'). # § + gsub(/©/u,'©'). # © + gsub(/ª/u,'ª'). # ª + gsub(/«/u,'«'). # « + gsub(/®/u,'®'). # ® + gsub(/°/u,'°'). # ° + gsub(/±/u,'±'). # ± + gsub(/²/u,'²'). # ² + gsub(/³/u,'³'). # ³ + gsub(/µ/u,'µ'). # µ + gsub(/¶/u,'¶'). # ¶ + gsub(/¹/u,'¹'). # ¹ + gsub(/º/u,'º'). # º + gsub(/»/u,'»'). # » + gsub(/¼/u,'¼'). # ¼ + gsub(/½/u,'½'). # ½ + gsub(/¾/u,'¾'). # ¾ + gsub(/×/u,'×'). # × + gsub(/÷/u,'÷'). # ÷ + gsub(/¿/u,'¿'). # ¿ + gsub(/À/u,'À'). # À + gsub(/Á/u,'Á'). # Á + gsub(/Â/u,'Â'). #  + gsub(/Ã/u,'Ã'). # à + gsub(/Ä/u,'Ä'). # Ä + gsub(/Å/u,'Å'). # Å + gsub(/Æ/u,'Æ'). # Æ + gsub(/Ç/u,'Ç'). # Ç + gsub(/È/u,'È'). # È + gsub(/É/u,'É'). # É + gsub(/Ê/u,'Ê'). # Ê + gsub(/Ë/u,'Ë'). # Ë + gsub(/Ì/u,'Ì'). # Ì + gsub(/Í/u,'Í'). # Í + gsub(/Î/u,'Î'). # Î + gsub(/Ï/u,'Ï'). # Ï + gsub(/Ð/u,'Ð'). # Ð + gsub(/Ñ/u,'Ñ'). # Ñ + gsub(/Ò/u,'Ò'). # Ò + gsub(/Ó/u,'Ó'). # Ó + gsub(/Ô/u,'Ô'). # Ô + gsub(/Õ/u,'Õ'). # Õ + gsub(/Ö/u,'Ö'). # Ö + gsub(/Ø/u,'Ø'). # Ø + gsub(/Ù/u,'Ù'). # Ù + gsub(/Ú/u,'Ú'). # Ú + gsub(/Û/u,'Û'). # Û + gsub(/Ü/u,'Ü'). # Ü + gsub(/Ý/u,'Ý'). # Ý + gsub(/Þ/u,'Þ'). # Þ + gsub(/ß/u,'ß'). # ß + gsub(/à/u,'à'). # à + gsub(/á/u,'á'). # á + gsub(/â/u,'â'). # â + gsub(/ã/u,'ã'). # ã + gsub(/ä/u,'ä'). # ä + gsub(/å/u,'å'). # å + gsub(/æ/u,'æ'). # æ + gsub(/ç/u,'ç'). # ç + gsub(/è/u,'è'). # è + gsub(/é/u,'é'). # é + gsub(/ê/u,'ê'). # ê + gsub(/ë/u,'ë'). # ë + gsub(/ì/u,'ì'). # ì + gsub(/í/u,'í'). # í + gsub(/î/u,'î'). # î + gsub(/ï/u,'ï'). # ï + gsub(/ð/u,'ð'). # ð + gsub(/ñ/u,'ñ'). # ñ + gsub(/ò/u,'ò'). # ò + gsub(/ó/u,'ó'). # ó + gsub(/ô/u,'ô'). # ô + gsub(/õ/u,'õ'). # õ + gsub(/ö/u,'ö'). # ö + gsub(/ø/u,'ø'). # ø + gsub(/ù/u,'ù'). # ú + gsub(/ú/u,'ú'). # û + gsub(/û/u,'û'). # ü + gsub(/ü/u,'ü'). # ý + gsub(/þ/u,'þ'). # þ + gsub(/ÿ/u,'ÿ'). # ÿ + gsub(/ý/u,'ý'). + gsub(/<br>/u,'<br />'). + gsub(/#{Mx[:nbsp]}/u,' ') end end class Tune def initialize(data,md) @data,@md=data,md - @vz=SiSU_Env::Get_init.instance.skin - @env=SiSU_Env::Info_env.new(@md.fns) - @sys=SiSU_Env::System_call.new - @env=SiSU_Env::Info_env.new(@md.fns) + @vz=SiSU_Env::GetInit.instance.skin + @env=SiSU_Env::InfoEnv.new(@md.fns) + @sys=SiSU_Env::SystemCall.new + @env=SiSU_Env::InfoEnv.new(@md.fns) @brace_url=SiSU_Viz::Skin.new.url_decoration end def songsheet begin @cX=SiSU_Screen::Ansi.new(@md.opt.cmd).cX SiSU_Screen::Ansi.new(@md.opt.cmd,'Tune').txt_grey if @md.opt.cmd =~/[MVv]/ - data=Tune.new(@data,@md).amp_html - data=Tune.new(data,@md).endnotes_html - data=Tune.new(data,@md).url_markup - data=Tune.new(data,@md).markup + data=SiSU_EPUB_Tune::Tune.new(@data,@md).amp_html + data=SiSU_EPUB_Tune::Tune.new(data,@md).endnotes_html + data=SiSU_EPUB_Tune::Tune.new(data,@md).url_markup + data=SiSU_EPUB_Tune::Tune.new(data,@md).markup if @md.opt.cmd =~/M/ #Hard Output Tune Optional on/off here - data=Output.new(data,@md).hard_output - Output.new(data,@md).marshal + data=SiSU_EPUB_Tune::Output.new(data,@md).hard_output + SiSU_EPUB_Tune::Output.new(data,@md).marshal end - tuned=Tune.new(@data,@md).output - rescue; SiSU_Errors::Info_error.new($!,$@,@md.opt.cmd,@md.fns).error + tuned=SiSU_EPUB_Tune::Tune.new(@data,@md).output + rescue; SiSU_Errors::InfoError.new($!,$@,@md.opt.cmd,@md.fns).error ensure end end - def para_numbers - data=@data - @tuned_file=[] - data.each do |dob| - dob.gsub!(/#{Mx[:lv_o]}\d:(\S?)#{Mx[:lv_c]}/,'\0#\1. ') #fix Mx[:lv_o] - @tuned_file << dob - end - end def markup @tuned_file=[] @data.each do |dob| - dob.obj.gsub!(/#{Mx[:mk_o]}#([a-zA-Z]+)#{Mx[:mk_c]}/,'&\1;') - dob.obj.gsub!(/#{Mx[:mk_o]}(#[0-9]+)#{Mx[:mk_c]}/,'&\1;') - dob.obj.gsub!(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,'<br />') unless dob.is=='table' - dob.obj.gsub!(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'<b>\1</b>') - dob.obj.gsub!(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'<i>\1</i>') - dob.obj.gsub!(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'<u>\1</u>') - dob.obj.gsub!(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,'<sup>\1</sup>') - dob.obj.gsub!(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,'<sub>\1</sub>') - dob.obj.gsub!(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'<ins>\1</ins>') - dob.obj.gsub!(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'<cite>\1</cite>') - dob.obj.gsub!(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'<del>\1</del>') - dob.obj.gsub!(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/,'<tt>\1</tt>') # tt, kbd - dob.obj.gsub!(/#{Mx[:mk_o]}:name#(\S+?)#{Mx[:mk_c]}/,'') - dob.obj.gsub!(/^#{Mx[:gl_bullet]}/m,'● ') - dob.obj.gsub!(/#{Mx[:nbsp]}/,' ') - dob.obj.gsub!(/<(p|br)>/,'<\1 />') - dob=SiSU_EPUB_Tune::Clean_xhtml.new(dob).clean + dob.obj=dob.obj.gsub(/#{Mx[:mk_o]}#([a-zA-Z]+)#{Mx[:mk_c]}/,'&\1;'). + gsub(/#{Mx[:mk_o]}(#[0-9]+)#{Mx[:mk_c]}/,'&\1;') + dob.obj=dob.obj.gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,'<br />') unless dob.is==:table + dob.obj=dob.obj.gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'<b>\1</b>'). + gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'<i>\1</i>'). + gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'<u>\1</u>'). + gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,'<sup>\1</sup>'). + gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,'<sub>\1</sub>'). + gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'<ins>\1</ins>'). + gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'<cite>\1</cite>'). + gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'<del>\1</del>'). + gsub(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/,'<tt>\1</tt>'). # tt, kbd + gsub(/#{Mx[:mk_o]}:name#(\S+?)#{Mx[:mk_c]}/,''). + gsub(/^#{Mx[:gl_bullet]}/m,'● '). + gsub(/#{Mx[:nbsp]}/,' '). + gsub(/<(p|br)>/,'<\1 />') + dob.obj=SiSU_EPUB_Tune::CleanXHTML.new(dob.obj).clean @tuned_file << dob end end def urls(data) @words=[] - map_nametags=SiSU_Particulars::Combined_singleton.instance.get_map_nametags(@md).nametags_map #p map_nametags + map_nametags=SiSU_Particulars::CombinedSingleton.instance.get_map_nametags(@md).nametags_map #p map_nametags data.each do |word| @words << if word=~/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}|image)/ http_=true @@ -280,29 +271,32 @@ module SiSU_EPUB_Tune %{<a href="#{u}"><img src="#{image_path}/#{png}" #{w} #{h} naturalsizeflag="0" align="bottom" border="0" /></a>#{caption}} else %{<img src="#{image_path}/#{png}" #{w} #{h} naturalsizeflag="0" align="bottom" border="0" />#{caption}} end - word.gsub!(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/,ins) + word=word.gsub(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/,ins) else link=m[/(.+)/m] png=m.scan(/\S+/)[0].strip link=link.strip - u.sub!(/^#*/,'') #make neater + u=u.sub(/^#*/,'') #make neater if map_nametags[u] \ and map_nametags[u][:segname] - if u=~/^\d+$/ - u.gsub!(/^(\d+)$/,"#{map_nametags[u][:segname]}#{Sfx[:xhtml]}#o\\1") if u !~/\// unless http_ - else - u.gsub!(/(\S+)/,"#{map_nametags[u][:segname]}#{Sfx[:xhtml]}#\\1") if u !~/\// unless http_ + u=unless http_ + u=if u=~/^\d+$/ + u.gsub(/^(\d+)$/,"#{map_nametags[u][:segname]}#{Sfx[:xhtml]}#o\\1") if u !~/\// + else + u.gsub(/(\S+)/,"#{map_nametags[u][:segname]}#{Sfx[:xhtml]}#\\1") if u !~/\// + end + else u end elsif u =~/^:/ - u.gsub!(/^:/,"#{@env.url.root}/") + u=u.gsub(/^:/,"#{@env.url.root}/") elsif u =~/^\.\.\// - u.gsub!(/^\.\.\//,"#{@env.url.root}/") + u=u.gsub(/^\.\.\//,"#{@env.url.root}/") elsif u =~/https?:\/\// else p "NOT FOUND name_tags: #{u}" end ins=%{<a href="#{u}">#{link}</a>} - word.gsub!(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/,ins) - word.gsub!(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/,ins) + word=word.gsub(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/,ins). + gsub(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/,ins) end word else word @@ -315,58 +309,59 @@ module SiSU_EPUB_Tune data=@data @tuned_file=[] data.each do |dob| - unless dob.is=='code' + unless dob.is==:code if dob.obj =~/<::\s+/ #watch - dob.obj.gsub!(/<::\s+(\S+?)\s+!>/, + dob.obj=dob.obj.gsub(/<::\s+(\S+?)\s+!>/, %{<img src="#{@env.url.images_epub}/c_\\1.png" alt="\\1" width="14" height="14" align="bottom" border="0" />}) end if dob.obj =~/<:image\s+/ - dob.obj.gsub!(/<:image\s+(http\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+>/, - %{<a href="\\1"><img src="#{@env.url.images_epub}/\\2" \\3 \\4 naturalsizeflag="0" align="bottom" border="0" /></a>}) - dob.obj.gsub!(/<:image\s+(http\S+)\s+(\S+)\s+>/, - %{<a href="\\1"><img src="#{@env.url.images_epub}/\\2" naturalsizeflag="0" align="bottom" border="0" /></a>}) - dob.obj.gsub!(/<:image\s+(\S+)\s+(\S+)\s+(\S+)\s+>/, - %{<img src="#{@env.url.images_epub}/\\1" \\2 \\3 naturalsizeflag="0" align="bottom" border="0" />}) - dob.obj.gsub!(/<:image\s+(\S+)\s+>/, - %{<img src="#{@env.url.images_epub}/\\1" naturalsizeflag="0" align="bottom" border="0" />}) + dob.obj=dob.obj.gsub(/<:image\s+(http\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+>/, + %{<a href="\\1"><img src="#{@env.url.images_epub}/\\2" \\3 \\4 naturalsizeflag="0" align="bottom" border="0" /></a>}). + gsub(/<:image\s+(http\S+)\s+(\S+)\s+>/, + %{<a href="\\1"><img src="#{@env.url.images_epub}/\\2" naturalsizeflag="0" align="bottom" border="0" /></a>}). + gsub(/<:image\s+(\S+)\s+(\S+)\s+(\S+)\s+>/, + %{<img src="#{@env.url.images_epub}/\\1" \\2 \\3 naturalsizeflag="0" align="bottom" border="0" />}). + gsub(/<:image\s+(\S+)\s+>/, + %{<img src="#{@env.url.images_epub}/\\1" naturalsizeflag="0" align="bottom" border="0" />}) end if dob.obj =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}|image)/ @word_mode=dob.obj.scan(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}|image)[()\[\]]*[,.;:!?'"]{0,2}|(?:#{Mx[:gl_o]}\S+?#{Mx[:gl_c]})+|[^#{Mx[:lnk_o]}#{Mx[:lnk_c]}]+/mu) words=urls(@word_mode) - dob.obj.gsub!(/.+/m,words) + dob.obj=dob.obj.gsub(/.+/m,words) end - dob.obj.gsub!(/\\copyright/i,%{<sup>©</sup>}) - if (dob.obj !~/\<:ad\s+\.\.\//) - dob.obj.gsub!(/\<:ad\s+(\S+)?\s+(\S+\.png)\s+(.+)?\;\s+(.+)?\;\s*!\>/, + dob.obj=dob.obj.gsub(/\\copyright/i,%{<sup>©</sup>}) + dob.obj=if (dob.obj !~/\<:ad\s+\.\.\//) + dob.obj.gsub(/\<:ad\s+(\S+)?\s+(\S+\.png)\s+(.+)?\;\s+(.+)?\;\s*!\>/, %{\n<center><a href="http:\/\/\\1" target="external"><img src="#{@env.url.images_epub}/\\2" alt="\\3" /></a></center>\n}) else - dob.obj.gsub!(/\<:ad\s+(\S+)?\s+(\S+\.png)\s+(.+)?\;\s+(.+)?\;\s*\>/, + dob.obj.gsub(/\<:ad\s+(\S+)?\s+(\S+\.png)\s+(.+)?\;\s+(.+)?\;\s*\>/, %{\n<center><a href="\\1" target="_top"><img src="#{@env.url.images_epub}/\\2" alt="\\3" /></a></center>\n}) end - dob.obj.gsub!(/!pick/,%{<img border="0" height="15" width="15" src="#{@env.url.images_epub}/#{@vz.icon_choice}" alt="stellar" />}) - dob.obj.gsub!(/!new/,%{ <img border="0" height="15" width="15" src="#{@env.url.images_epub}/#{@vz.icon_new}" alt="new" />}) - dob.obj.gsub!(/<:h(.{1,7}?)>/,'<a href="#h\1">\1</a>') - dob.obj.gsub!(/<:to(\d{1,7}?)>/,'<a href="#to\1">to { \1 }</a> ') - dob.obj.gsub!(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'<a href="\1" target="_top">\1</a>') #http ftp matches escaped, no decoration - dob.obj.gsub!(/#{Mx[:url_o]}([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)#{Mx[:url_c]}/,%{#{@brace_url.xml_open}<a href="mailto:\\1">\\1</a>#{@brace_url.xml_close}}) - dob.obj.gsub!(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,%{#{@brace_url.xml_open}<a href="\\1" target="_top">\\1</a>#{@brace_url.xml_close}}) #http ftp matches with decoration + dob.obj=dob.obj.gsub(/!pick/,%{<img border="0" height="15" width="15" src="#{@env.url.images_epub}/#{@vz.icon_choice}" alt="stellar" />}). + gsub(/!new/,%{ <img border="0" height="15" width="15" src="#{@env.url.images_epub}/#{@vz.icon_new}" alt="new" />}). + gsub(/<:h(.{1,7}?)>/,'<a href="#h\1">\1</a>'). + gsub(/<:to(\d{1,7}?)>/,'<a href="#to\1">to { \1 }</a> '). + gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'<a href="\1" target="_top">\1</a>'). #http ftp matches escaped, no decoration + gsub(/#{Mx[:url_o]}([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)#{Mx[:url_c]}/,%{#{@brace_url.xml_open}<a href="mailto:\\1">\\1</a>#{@brace_url.xml_close}}). + gsub(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,%{#{@brace_url.xml_open}<a href="\\1" target="_top">\\1</a>#{@brace_url.xml_close}}) #http ftp matches with decoration if dob.obj =~/..\/\S+/ \ and dob.obj !~/(\"..\/\S+?\"|>\s*..\/\S+<)/ - dob.obj.gsub!(/(\.\.\/\S+)/,'<a href="\1">\1</a>') + dob.obj=dob.obj.gsub(/(\.\.\/\S+)/,'<a href="\1">\1</a>') end - dob.obj.gsub!(/<a href="\.\.\//,%{<a href="#{@vz.url_site}/}) + dob.obj=dob.obj.gsub(/<a href="\.\.\//,%{<a href="#{@vz.url_site}/}) else - dob.obj.gsub!(/</m,'<'); dob.obj.gsub!(/>/m,'>') + dob.obj=dob.obj.gsub(/</m,'<').gsub(/>/m,'>') end @tuned_file << dob end end def amp_html - data=@data + data,data_new=@data,[] data.each do |dob| - dob.obj.gsub!(/&/u,'&') + dob.obj=dob.obj.gsub(/&/u,'&') + data_new << dob end - data + data_new end def endnotes_html data=@data @@ -374,24 +369,24 @@ module SiSU_EPUB_Tune a,s='_a','_s' ast,pls='*','+' data.each do |dob| - unless dob.is =~/^code/ - 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) - dob.obj.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) - dob.obj.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 + 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) + 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) + 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 if dob.obj =~/#{Mx[:en_a_o]}([*+]+)\s+.+?#{Mx[:en_a_c]}/ m=$1.length.to_i - 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) - dob.obj.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) + 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) + 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) end end @tuned_file << dob @@ -401,8 +396,7 @@ module SiSU_EPUB_Tune data=@data @tuned_file=[] data.each do |dob| - dob.obj.strip! - dob.obj.chomp! + dob.obj=dob.obj.strip.chomp @tuned_file << dob end @tuned_file << "\n<EOF>" if (@md.fns =~/\.sst0/) #remove diff --git a/lib/sisu/v3/errors.rb b/lib/sisu/v3/errors.rb index 70ab4666..25ef688c 100644 --- a/lib/sisu/v3/errors.rb +++ b/lib/sisu/v3/errors.rb @@ -59,7 +59,7 @@ module SiSU_Errors require_relative 'sysenv' # sysenv.rb include SiSU_Env; include SiSU_Screen - class Info_error <Create_file + class InfoError <CreateFile def initialize(error,errorlist,cmd,fns='') @fns,@cmd,@error,@errorlist=fns,cmd,error,errorlist @cmd=if cmd and cmd =~/c/; 'Vc' @@ -67,7 +67,7 @@ module SiSU_Errors end end def error #creates file errorlog.sisu in pwd of last error reported - file=if @fns; SiSU_Env::Create_file.new(@fns).file_error + file=if @fns; SiSU_Env::CreateFile.new(@fns).file_error else File.new('/tmp/errorlog.sisu','w+') end file << @fns << "\n" << @error << "\n" << @errorlist diff --git a/lib/sisu/v3/git.rb b/lib/sisu/v3/git.rb index 148b35fc..82700d9c 100644 --- a/lib/sisu/v3/git.rb +++ b/lib/sisu/v3/git.rb @@ -63,10 +63,10 @@ module SiSU_Git class Source def initialize(opt) @opt=opt - @env=SiSU_Env::Info_env.new + @env=SiSU_Env::InfoEnv.new @md=SiSU_Param::Parameters.new(@opt).get - @file=SiSU_Env::SiSU_file.new(@md) - l=SiSU_Env::Standardise_language.new(@md.opt.lng).language + @file=SiSU_Env::FileOp.new(@md) + l=SiSU_Env::StandardiseLanguage.new(@md.opt.lng).language unless @opt.lng==l[:c] # @md.i18n[0]==l[:c] p "using: #{@opt.lng} (@make: :language:); filename #{@md.fns} filename language: #{l[:c]}, mismatch" end @@ -197,7 +197,7 @@ module SiSU_Git end end def locate_skin - SiSU_Env::Info_skin.new(@md).select + SiSU_Env::InfoSkin.new(@md).select end def read_composite #print __FILE__ + ':' diff --git a/lib/sisu/v3/harvest.rb b/lib/sisu/v3/harvest.rb index b8b82524..71adb0f0 100644 --- a/lib/sisu/v3/harvest.rb +++ b/lib/sisu/v3/harvest.rb @@ -68,7 +68,7 @@ module SiSU_Harvest include SiSU_Env def initialize(opt) @opt=opt - @env=SiSU_Env::Info_env.new + @env=SiSU_Env::InfoEnv.new end def read harvest_pth="#{@env.path.webserv}/#{@opt.base_stub}" @@ -78,13 +78,13 @@ module SiSU_Harvest def help puts <<WOK harvest --harvest extracts document index metadata - + WOK end def css(opt) require_relative 'css' # css.rb css=SiSU_Style::CSS.new - fn_css=SiSU_Env::CSS_default.new + fn_css=SiSU_Env::CSS_Default.new style=File.new("#{@env.path.pwd}/#{fn_css.harvest}",'w') style << css.harvest style.close @@ -93,8 +93,8 @@ WOK case opt.mod.inspect when/--harvest/i css(opt) if opt.cmd.inspect =~/M/ - HARVEST_authors::Songsheet.new(opt,env).songsheet - HARVEST_topics::Songsheet.new(opt,env).songsheet + SiSU_Harvest_Authors::Songsheet.new(opt,env).songsheet + SiSU_Harvest_Topics::Songsheet.new(opt,env).songsheet if opt.cmd.inspect =~/R/ require_relative 'remote' # remote.rb SiSU_Remote::Put.new(opt).rsync_harvest diff --git a/lib/sisu/v3/harvest_authors.rb b/lib/sisu/v3/harvest_authors.rb index 996b748c..5bb702be 100644 --- a/lib/sisu/v3/harvest_authors.rb +++ b/lib/sisu/v3/harvest_authors.rb @@ -57,7 +57,7 @@ ** Description: simple xml representation (sax style) =end -module HARVEST_authors +module SiSU_Harvest_Authors require_relative 'author_format' # author_format.rb class Songsheet @@the_idx_authors={} @@ -70,8 +70,8 @@ module HARVEST_authors idx_array={} @opt.f_pths.each do |y| lang_hash_file_array={} - name=y[:f] - filename=y[:pth] + '/' + y[:f] + name=y[:f] + filename=y[:pth] + '/' + y[:f] File.open(filename,'r') do |file| file.each_line("\n\n") do |line| if line =~/^@(?:title|creator|date):(?:\s|$)/m @@ -85,11 +85,11 @@ module HARVEST_authors end lang_hash_file_array.each_pair do |lang,a| idx_array[lang] ||= [] - idx_array=HARVEST_authors::Harvest.new(@opt,@env,a,filename,name,idx_array,lang).extract_harvest + idx_array=SiSU_Harvest_Authors::Harvest.new(@opt,@env,a,filename,name,idx_array,lang).extract_harvest end end - the_idx=HARVEST_authors::Index.new(idx_array,@@the_idx_authors).construct_book_author_index - HARVEST_authors::Output_index.new(@opt,the_idx).html_print.html_songsheet + the_idx=SiSU_Harvest_Authors::Index.new(idx_array,@@the_idx_authors).construct_book_author_index + SiSU_Harvest_Authors::OutputIndex.new(@opt,the_idx).html_print.html_songsheet end end class Harvest @@ -123,7 +123,7 @@ module HARVEST_authors @fulltitle=@subtitle ? (@title + ' - ' + @subtitle) : @title if @title \ and @author_format - creator=FORMAT::Author.new(@author_format.strip).author_details + creator=SiSU_FormatAuthor::Author.new(@author_format.strip).author_details @authors,@authorship=creator[:authors],creator[:authorship] file=if name=~/~[a-z]{2,3}\.ss[mt]$/ name.sub(/~[a-z]{2,3}\.ss[mt]$/,'') @@ -139,7 +139,7 @@ module HARVEST_authors else #p "missing author field: #{@filename} title: #{@title}; author: #{@author_format}" end - idx_array[lang].flatten! + idx_array[lang]=idx_array[lang].flatten idx_array end end @@ -157,7 +157,7 @@ module HARVEST_authors @@the_idx_authors[lang] ||= {} idx_array.each do |idx| idx[:author][:last_first_format_a].each do |author| - author.strip! + author=author.strip if @@the_idx_authors[lang][author].class==NilClass @@the_idx_authors[lang][author]={ md: [] } end @@ -168,15 +168,15 @@ module HARVEST_authors @the_idx=@@the_idx_authors end end - class Output_index + class OutputIndex require_relative 'i18n' # i18n.rb def initialize(opt,the_idx) @opt,@the_idx=opt,the_idx - @env=SiSU_Env::Info_env.new - @rc=SiSU_Env::Get_init.instance.sisu_yaml.rc + @env=SiSU_Env::InfoEnv.new + @rc=SiSU_Env::GetInit.instance.sisu_yaml.rc @alph=%W[9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z] @letter=@alph.shift - @vz=SiSU_Env::Get_init.instance.skin + @vz=SiSU_Env::GetInit.instance.skin end def html_file_open @the_idx.keys.each do |lng| @@ -241,7 +241,7 @@ module HARVEST_authors l=ln[lng][:t] harvest_languages += %{<a href="#{file}">#{l}</a> } end - sv=SiSU_Env::Info_version.instance.get_version + sv=SiSU_Env::InfoVersion.instance.get_version <<WOK <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> diff --git a/lib/sisu/v3/harvest_topics.rb b/lib/sisu/v3/harvest_topics.rb index de03b615..dd7ec8c2 100644 --- a/lib/sisu/v3/harvest_topics.rb +++ b/lib/sisu/v3/harvest_topics.rb @@ -58,7 +58,7 @@ ** Description: simple xml representation (sax style) =end -module HARVEST_topics +module SiSU_Harvest_Topics require_relative 'author_format' # author_format.rb include SiSU_Viz class Songsheet @@ -72,8 +72,8 @@ module HARVEST_topics idx_array={} @opt.f_pths.each do |y| lang_hash_file_array={} - name=y[:f] - filename=y[:pth] + '/' + y[:f] + name=y[:f] + filename=y[:pth] + '/' + y[:f] File.open(filename,'r') do |file| file.each_line("\n\n") do |line| if line =~/^@(?:title|creator|classify):(?:\s|$)/m @@ -87,11 +87,11 @@ module HARVEST_topics end lang_hash_file_array.each_pair do |lang,a| idx_array[lang] ||= [] - idx_array=HARVEST_topics::Harvest.new(@opt,@env,a,filename,name,idx_array,lang).extract_harvest + idx_array=SiSU_Harvest_Topics::Harvest.new(@opt,@env,a,filename,name,idx_array,lang).extract_harvest end end - the_idx=HARVEST_topics::Index.new(@opt,@env,idx_array,@@the_idx_topics).construct_book_topic_index - HARVEST_topics::Output_index.new(@opt,the_idx).html_print.html_songsheet + the_idx=SiSU_Harvest_Topics::Index.new(@opt,@env,idx_array,@@the_idx_topics).construct_book_topic_index + SiSU_Harvest_Topics::OutputIndex.new(@opt,the_idx).html_print.html_songsheet end end class Harvest @@ -125,7 +125,7 @@ module HARVEST_topics if @title \ and @author_format \ and @idx_list - creator=FORMAT::Author.new(@author_format.strip).author_details + creator=SiSU_FormatAuthor::Author.new(@author_format.strip).author_details @authors,@authorship=creator[:authors],creator[:authorship] file=if name=~/~[a-z]{2,3}\.ss[mt]$/ name.sub(/~[a-z]{2,3}\.ss[mt]$/,'') @@ -144,7 +144,7 @@ module HARVEST_topics g=@idx_list.scan(/[^;]+/) idxl=[] g.each do |i| - i.strip! + i=i.strip idxl << { filename: filename, file: file, rough_idx: i, title: @fulltitle, author: creator, page: page, lang: lang } end idxl @@ -153,7 +153,7 @@ module HARVEST_topics else p "missing required field in #{@filename} - [title]: <<#{@title}>>; [author]: <<#{@author_format}>>; [idx]: <<#{@idx_list}>>" if @opt.cmd.inspect =~/[VM]/ end - idx_array[lang].flatten! + idx_array[lang]=idx_array[lang].flatten idx_array end end @@ -259,15 +259,15 @@ module HARVEST_topics @the_idx end end - class Output_index + class OutputIndex require_relative 'i18n' # i18n.rb def initialize(opt,the_idx) @opt,@the_idx=opt,the_idx - @env=SiSU_Env::Info_env.new - @rc=SiSU_Env::Get_init.instance.sisu_yaml.rc + @env=SiSU_Env::InfoEnv.new + @rc=SiSU_Env::GetInit.instance.sisu_yaml.rc @alph=%W[9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z] @letter=@alph.shift - @vz=SiSU_Env::Get_init.instance.skin + @vz=SiSU_Env::GetInit.instance.skin end def html_file_open @the_idx.keys.each do |lng| @@ -335,7 +335,7 @@ module HARVEST_topics l=ln[lng][:t] harvest_languages += %{<a href="#{file}">#{l}</a> } end - sv=SiSU_Env::Info_version.instance.get_version + sv=SiSU_Env::InfoVersion.instance.get_version <<WOK <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> diff --git a/lib/sisu/v3/help.rb b/lib/sisu/v3/help.rb index 9dc26aec..35a96170 100644 --- a/lib/sisu/v3/help.rb +++ b/lib/sisu/v3/help.rb @@ -68,8 +68,8 @@ module SiSU_Help else @cX=SiSU_Screen::Ansi.new('yes').cX end fns='help_example_dummy_file_name.sst' - @env=SiSU_Env::Info_env.new(fns) - @db=SiSU_Env::Info_db.new + @env=SiSU_Env::InfoEnv.new(fns) + @db=SiSU_Env::InfoDb.new m=/.+\/(?:src\/)?(\S+)/im # m=/.+?\/(?:src\/)?([^\/]+)$/im # m=/.+\/(\S+)/m @output_stub=Dir.pwd[m,1] end @@ -337,7 +337,7 @@ WOK WOK end def shortcuts - cf_defaults=SiSU_Env::Info_processing_flag.new + cf_defaults=SiSU_Env::InfoProcessingFlag.new print <<WOK #{@cX.ruby}Shorthand for multiple flags#{@cX.off} @@ -898,14 +898,14 @@ WOK end def program_found?(program) if program - rc=if SiSU_Env::Info_settings.new.program?(program) - SiSU_Env::Info_settings.new.program?(program) + rc=if SiSU_Env::InfoSettings.new.program?(program) + SiSU_Env::InfoSettings.new.program?(program) else '' end if program =='rmagick'; program='identify' #rmagick is ruby lib uses imagemagick's identify end - bin=if SiSU_Env::System_call.new.program_found?(program) - SiSU_Env::System_call.new.program_found?(program) + bin=if SiSU_Env::SystemCall.new.program_found?(program) + SiSU_Env::SystemCall.new.program_found?(program) else 'false' end else bin,rc='false','false' @@ -915,8 +915,8 @@ WOK end end def sisu_version - version=SiSU_Env::Info_version.instance.get_version - rb_ver=SiSU_Env::Info_version.instance.rbversion + version=SiSU_Env::InfoVersion.instance.get_version + rb_ver=SiSU_Env::InfoVersion.instance.rbversion if version[:version] SiSU_Screen::Ansi.new('-v',version[:project],version[:version],version[:date_stamp],version[:date],rb_ver).version else puts 'SiSU version information not available' @@ -924,7 +924,7 @@ WOK end def rhost @ls=leading_spaces=' '*49 - @rhost=SiSU_Env::Info_remote_host.new.rhost + @rhost=SiSU_Env::InfoRemoteHost.new.rhost def r1 if @rhost.r1; @rhost.r1 + "\n" else '' @@ -964,7 +964,7 @@ WOK self end def environment - cf_defaults=SiSU_Env::Info_processing_flag.new + cf_defaults=SiSU_Env::InfoProcessingFlag.new sisu_version x =<<WOK #{@cX.green}current and output directories#{@cX.off} @@ -1023,8 +1023,8 @@ WOK sisu -5 #{@cX.blue}#{cf_defaults.cf_5}#{@cX.off} (defaults may be changed in active sisurc.yml file under flag:) #{@cX.green}special powers, risky operations set:#{@cX.off} - zap (delete output directories) #{@cX.blue}#{SiSU_Env::Info_settings.new.permission?('zap')}#{@cX.off} - css copy (copy over css files) #{@cX.blue}#{SiSU_Env::Info_settings.new.permission?('css_modify')}#{@cX.off} + zap (delete output directories) #{@cX.blue}#{SiSU_Env::InfoSettings.new.permission?('zap')}#{@cX.off} + css copy (copy over css files) #{@cX.blue}#{SiSU_Env::InfoSettings.new.permission?('css_modify')}#{@cX.off} (true/false defaults may be changed in active sisurc.yml file under permissions_set:) NOTE: for HELP type 'sisu --help', 'sisu --help [help request]', 'man sisu', (or see the system or online documentation) diff --git a/lib/sisu/v3/html.rb b/lib/sisu/v3/html.rb index 85c1d602..fee51f2c 100644 --- a/lib/sisu/v3/html.rb +++ b/lib/sisu/v3/html.rb @@ -66,16 +66,16 @@ module SiSU_HTML require_relative 'html_format' # html_format.rb include SiSU_HTML_Format require_relative 'html_segments' # html_segments.rb - include SiSU_HTML_seg + include SiSU_HTML_Seg require_relative 'html_scroll' # html_scroll.rb require_relative 'html_promo' # html_promo.rb - include SiSU_HTML_promo + include SiSU_HTML_Promo require_relative 'html_tune' # html_tune.rb include SiSU_HTML_Tune class Source def initialize(opt) @opt=opt - @particulars=SiSU_Particulars::Combined_singleton.instance.get_all(opt) + @particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt) end def read songsheet @@ -95,21 +95,21 @@ module SiSU_HTML : SiSU_Screen::Ansi.new(@opt.cmd,'HTML',tool).green_title_hi SiSU_Screen::Ansi.new(@opt.cmd,@opt.fns,"file://#{@md.file.output_path.html_seg.dir}/#{@md.file.base_filename.html_segtoc}").flow if @opt.cmd =~/[MV]/ end - SiSU_Env::Info_skin.new(@md).select + SiSU_Env::InfoSkin.new(@md).select data=nil - @tuned_file_array=SiSU_HTML::Source::Html_environment.new(@particulars).tuned_file_instructions + @tuned_file_array=SiSU_HTML::Source::HTML_Environment.new(@particulars).tuned_file_instructions data=@tuned_file_array scr_endnotes=SiSU_HTML::Source::Endnotes.new(data,@md).scroll toc=SiSU_HTML::Source::Toc.new(@md,data).songsheet - links_guide=SiSU_HTML::Source::Links_guide.new(data,@md).toc + links_guide=SiSU_HTML::Source::LinksGuide.new(data,@md).toc data=@tuned_file_array - scr_toc=SiSU_HTML::Source::Scroll_head_and_segtoc.new(@md,toc,links_guide).in_common #watch + scr_toc=SiSU_HTML::Source::ScrollHeadAndSegToc.new(@md,toc,links_guide).in_common #watch SiSU_HTML::Source::Seg.new(@md,data).songsheet data=@tuned_file_array scr=SiSU_HTML::Source::Scroll.new(@md,data,scr_endnotes).songsheet - scroll=SiSU_HTML::Source::Scroll_output.new(scr_toc,scr[:body],scr[:metadata],scr[:owner_details],scr[:tails],@md).publish + scroll=SiSU_HTML::Source::ScrollOutput.new(scr_toc,scr[:body],scr[:metadata],scr[:owner_details],scr[:tails],@md).publish SiSU_HTML::Source::Output.new(scroll,@md).scroll - rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error + rescue; SiSU_Errors::InfoError.new($!,$@,@opt.cmd,@opt.fns).error ensure unless @opt.cmd =~/[MV]/ #check maintenance flag texfiles=Dir["#{@env.processing_path.tune}/#{@opt.fns}*"] @@ -128,40 +128,36 @@ module SiSU_HTML end end private - class Html_environment + class HTML_Environment def initialize(particulars) @particulars=particulars @md,@env=particulars.md,particulars.env - @vz=SiSU_Env::Get_init.instance.skin - @env,@css,@symlnk=particulars.env,SiSU_Style::CSS.new,SiSU_Env::Create_system_link.new #home + @vz=SiSU_Env::GetInit.instance.skin + @env,@css,@symlnk=particulars.env,SiSU_Style::CSS.new,SiSU_Env::CreateSystemLink.new #home end def link_images @symlnk.images end - def directories - title=File.basename(@md.fns,'.rb') - end def tuned_file_instructions @tell=SiSU_Screen::Ansi.new(@md.opt.cmd) @md.opt.cmd=@md.opt.cmd.gsub(/H/,'h') - @md.file_type='html' if @md.opt.cmd =~/[hon]/ - directories + @md.file_type='html' if @md.opt.cmd =~/[hw]/ newfilename=%{#{@md.file.output_path.html_scroll.dir}/#{@md.file.base_filename.html_segtoc}} if @md.file_type =~/html/ dal_array=@particulars.dal_array # dal file drawn here @tuned_file_array=SiSU_HTML_Tune::Tune.new(dal_array,@md).songsheet @tuned_file_array end end - class Links_guide + class LinksGuide @links_guide_toc=[] def initialize(data,md) @data,@md=data,md - @links_guide_=SiSU_Env::Create_site.new(@md.opt.cmd).html_quick_ref? + @links_guide_=SiSU_Env::CreateSite.new(@md.opt.cmd).html_quick_ref? end def toc @links_guide_toc=[] if @links_guide_ - format_head_toc=SiSU_HTML_Format::Head_toc.new(@md) + format_head_toc=SiSU_HTML_Format::HeadToc.new(@md) guide_type='horzontal' #values: horizontal or vertical @links_guide_toc << format_head_toc.links_guide_open(guide_type) if defined? @md.lnk \ @@ -173,12 +169,12 @@ module SiSU_HTML end s_lnk_url,s_lnk_lnk=l[:url],l[:say] txt_obj={ lnk_url: s_lnk_url, lnk_txt: s_lnk_lnk, target: target } - lev_dob_ocn=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) + lev_dob_ocn=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) @links_guide_toc << lev_dob_ocn.links_guide if s_lnk_lnk end end end - format_head_toc=SiSU_HTML_Format::Head_toc.new(@md) + format_head_toc=SiSU_HTML_Format::HeadToc.new(@md) @links_guide_toc << format_head_toc.links_guide_close #(guide_type) @links_guide_toc else '' @@ -192,10 +188,10 @@ module SiSU_HTML end def scroll @scr_endnotes=[] - format_head_scroll=SiSU_HTML_Format::Head_scroll.new(@md) + format_head_scroll=SiSU_HTML_Format::HeadScroll.new(@md) @data.each do |dob| pg=dob.dup - unless pg.is =~/^code/ + unless pg.is ==:code if pg.obj =~/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]})[\d*+]+ / endnote_array=[] if pg.obj=~/#{Mx[:en_a_o]}[\d*+].+?#{Mx[:en_a_c]}/m @@ -209,7 +205,7 @@ module SiSU_HTML end endnote_array.flatten.each do |note| txt_obj={ txt: note } - format_scroll=SiSU_HTML_Format::Format_scroll.new(@md,txt_obj) + format_scroll=SiSU_HTML_Format::FormatScroll.new(@md,txt_obj) @scr_endnotes << format_scroll.endnote_body end end @@ -218,13 +214,13 @@ module SiSU_HTML @scr_endnotes end end - class Toc <Links_guide + class Toc <LinksGuide @@toc={ seg: [], seg_mini: [], scr: [] } @@seg_url='' @@firstseg=nil def initialize(md=nil,data='') @data,@md=data,md - @vz=SiSU_Env::Get_init.instance.skin + @vz=SiSU_Env::GetInit.instance.skin @tell=SiSU_Screen::Ansi.new(@md.opt.cmd) if @md end def songsheet #extracts toc for scroll & seg @@ -233,18 +229,18 @@ module SiSU_HTML @@firstseg=nil @@toc={ seg: [], seg_mini: [], scr: [] } @data.each do |dob| - if dob.is=='heading' \ - or dob.is=='heading_insert' + if dob.is==:heading \ + || dob.is==:heading_insert dob_toc=dob.dup - toc=if dob_toc.is =='heading' \ - or dob.is=='heading_insert' + toc=if dob_toc.is ==:heading \ + || dob.is==:heading_insert toc=case dob_toc.ln - when 1; Toc.new(@md,dob_toc).level_1 - when 2; Toc.new(@md,dob_toc).level_2 - when 3; Toc.new(@md,dob_toc).level_3 - when 4; Toc.new(@md,dob_toc).level_4 - when 5; Toc.new(@md,dob_toc).level_5 - when 6; Toc.new(@md,dob_toc).level_6 + when 1; SiSU_HTML::Source::Toc.new(@md,dob_toc).level_1 + when 2; SiSU_HTML::Source::Toc.new(@md,dob_toc).level_2 + when 3; SiSU_HTML::Source::Toc.new(@md,dob_toc).level_3 + when 4; SiSU_HTML::Source::Toc.new(@md,dob_toc).level_4 + when 5; SiSU_HTML::Source::Toc.new(@md,dob_toc).level_5 + when 6; SiSU_HTML::Source::Toc.new(@md,dob_toc).level_6 else nil end end @@ -261,7 +257,7 @@ module SiSU_HTML @@toc[:seg] << toc[:seg] if toc[:seg] @@toc[:seg_mini] << toc[:seg_mini] if toc[:seg_mini] @@toc[:scr] << toc[:scr] if toc[:scr] - rescue; SiSU_Errors::Info_error.new($!,$@,@md.opt.cmd,@md.fns).error + rescue; SiSU_Errors::InfoError.new($!,$@,@md.opt.cmd,@md.fns).error end end end @@ -291,22 +287,22 @@ WOK #not used --> def level_endnotes if @md.flag_endnotes - format_head_scroll=SiSU_HTML_Format::Head_scroll.new(@md) + format_head_scroll=SiSU_HTML_Format::HeadScroll.new(@md) @@toc[:scr] << format_head_scroll.toc_endnote end end def level_concordance - format_head_toc=SiSU_HTML_Format::Head_toc.new(@md) + format_head_toc=SiSU_HTML_Format::HeadToc.new(@md) @@toc[:seg_mini] << format_head_toc.mini_seg_concordance end def level_metadata - format_head_toc=SiSU_HTML_Format::Head_toc.new(@md) + format_head_toc=SiSU_HTML_Format::HeadToc.new(@md) @@toc[:scr] << format_head_toc.metadata @@toc[:seg] << format_head_toc.seg_metadata @@toc[:seg_mini] << format_head_toc.mini_seg_metadata end def level_word_index - format_head_toc=SiSU_HTML_Format::Head_toc.new(@d0c) + format_head_toc=SiSU_HTML_Format::HeadToc.new(@d0c) @@toc[:scr] << format_head_toc.concordance @@toc[:seg] << format_head_toc.concordance @@toc[:seg_mini] << format_head_toc.mini_concordance @@ -317,7 +313,7 @@ WOK linkname,link=dob.obj.strip,dob.ocn if link \ and link !~/#/ #% keep eye on link - p_num=SiSU_HTML_Format::Paragraph_number.new(@md,link) + p_num=SiSU_HTML_Format::ParagraphNumber.new(@md,link) end title=if dob.obj !~/Metadata/; linkname else @@ -326,7 +322,7 @@ WOK end toc={} txt_obj={ txt: title } - format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) + format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) toc[:seg]=if dob.name =~/^meta/ \ and dob.obj =~/Document Information/ format_toc.lev0 @@ -354,7 +350,7 @@ WOK %{<b><a href="##{link}">#{linkname}</a></b>} end txt_obj={ txt: title } - format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) + format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) toc[:scr]=if dob.name =~/^meta/ \ and dob.obj =~/Document Information/ format_toc.lev0 @@ -367,18 +363,18 @@ WOK linkname,ocn=dob.obj.strip,dob.ocn p_num=if ocn \ and ocn !~/#/ - SiSU_HTML_Format::Paragraph_number.new(@md,ocn) + SiSU_HTML_Format::ParagraphNumber.new(@md,ocn) else nil end txt_obj={ txt: linkname } - format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) + format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) toc={} toc[:seg]=format_toc.lev2 toc[:seg_mini]=format_toc.mini_lev2 if p_num title=%{#{p_num.goto}#{linkname}</a>} txt_obj={ txt: title } - format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) + format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) toc[:scr]=format_toc.lev2 end toc @@ -388,18 +384,18 @@ WOK linkname,ocn=dob.obj.strip,dob.ocn p_num=if ocn \ and ocn !~/#/ - SiSU_HTML_Format::Paragraph_number.new(@md,ocn) + SiSU_HTML_Format::ParagraphNumber.new(@md,ocn) else nil end txt_obj={ txt: linkname } - format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) + format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) toc={} toc[:seg]=format_toc.lev3 toc[:seg_mini]=format_toc.mini_lev3 if p_num title=%{#{p_num.goto}#{linkname}</a>} txt_obj={ txt: title } - format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) + format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) toc[:scr]=format_toc.lev3 end toc @@ -407,7 +403,7 @@ WOK def level_4 dob=@data linkname,ocn=dob.obj.strip,dob.ocn - p_num=SiSU_HTML_Format::Paragraph_number.new(@md,ocn) if ocn + p_num=SiSU_HTML_Format::ParagraphNumber.new(@md,ocn) if ocn if dob.ln ==4 seg_link=%{ <a href="#{dob.name}#{@md.lang_code_insert}#{Sfx[:html]}" target="_top"> #{dob.obj} @@ -418,8 +414,8 @@ WOK %{<a href="\\1#{@md.lang_code_insert}#{Sfx[:html]}" } + %{target="_top">\\1 \\2</a> }) end - p_num=SiSU_HTML_Format::Paragraph_number.new(@md,ocn) if ocn - @file=SiSU_Env::SiSU_file.new(@md) if @md + p_num=SiSU_HTML_Format::ParagraphNumber.new(@md,ocn) if ocn + @file=SiSU_Env::FileOp.new(@md) if @md txt_obj=if seg_link=~/sisu_manifest\.html/ man_link=if @file.output_dir_structure.by_language_code? \ or @file.output_dir_structure.by_filetype? @@ -429,7 +425,7 @@ WOK { txt: man_link } else { txt: seg_link } end - format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) + format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) toc={} toc[:seg]=format_toc.lev4 toc[:seg_mini]=format_toc.mini_lev4 @@ -439,7 +435,7 @@ WOK { txt: man_link } else { txt: title } end - format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) + format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) toc[:scr]=format_toc.lev4 toc #end @@ -450,17 +446,17 @@ WOK toc={} if ocn \ and ocn !~/#/ - p_num=SiSU_HTML_Format::Paragraph_number.new(@md,ocn) + p_num=SiSU_HTML_Format::ParagraphNumber.new(@md,ocn) lnk_n_txt=%{ <a href="#{@@seg_url}#{@md.lang_code_insert}#{Sfx[:html]}##{ocn}"> #{linkname} </a>} txt_obj={ txt: lnk_n_txt } - format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) + format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) toc[:seg]=format_toc.lev5 toc[:seg_mini]=format_toc.mini_lev5 title=%{#{p_num.goto}#{linkname}</a>} txt_obj={ txt: title } - format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) + format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) toc[:scr]=format_toc.lev5 end toc @@ -471,25 +467,25 @@ WOK toc={} if ocn \ and ocn !~/#/ - p_num=SiSU_HTML_Format::Paragraph_number.new(@md,ocn) + p_num=SiSU_HTML_Format::ParagraphNumber.new(@md,ocn) lnk_n_txt=%{ <a href="#{@@seg_url}#{@md.lang_code_insert}#{Sfx[:html]}##{ocn}"> #{linkname} </a>} txt_obj={ txt: lnk_n_txt } - format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) + format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) toc[:seg]=format_toc.lev6 toc[:seg_mini]=format_toc.mini_lev6 title=%{#{p_num.goto}#{linkname}</a>} txt_obj={ txt: title } - format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) + format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) toc[:scr]=format_toc.lev6 end toc end def level_crosslink dob=@data - if dob !~/^4~!/ - dob.gsub!(/^4~!\s+(\S+)\s+(.+)/, + dob=if dob !~/^4~!/ + dob.gsub(/^4~!\s+(\S+)\s+(.+)/, %{<table><tr><td width =\"80\"></td> <td><a href="http://\\1" target="_top"> #{@png.crosslink_ext} @@ -498,7 +494,7 @@ WOK </td></tr></table> }) else - dob.gsub!(/^4~!\s+(\S+)\s+(.+)/, + dob.gsub(/^4~!\s+(\S+)\s+(.+)/, %{<table><tr><td width ="80"> </td><td> <a href="\\1" target="_top"> @@ -510,31 +506,32 @@ WOK end end end - class Scroll_head_and_segtoc < Toc + class ScrollHeadAndSegToc < Toc def initialize(md='',toc='',links_guide_toc='') @md,@toc,@links_guide_toc=md,toc,links_guide_toc - @vz=SiSU_Env::Get_init.instance.skin + @vz=SiSU_Env::GetInit.instance.skin + @make=SiSU_Env::ProcessingSettings.new(@md) end def in_common toc_shared=[] @segtoc=[] SiSU_Screen::Ansi.new(@md.opt.cmd,'Scroll & Segtoc').txt_grey if @md.opt.cmd =~/[MVv]/ - format_head_toc=SiSU_HTML_Format::Head_toc.new(@md) + format_head_toc=SiSU_HTML_Format::HeadToc.new(@md) dochead=format_head_toc.head - dochead.gsub!(/toc\.(html)/,'doc.\1') #kludge - ads=SiSU_HTML_promo::Ad.new(@md) + dochead=dochead.gsub(/toc\.(html)/,'doc.\1') #kludge + ads=SiSU_HTML_Promo::Ad.new(@md) toc_shared << dochead << ads.div.major @segtoc << format_head_toc.head << ads.div.major - toc_shared << format_head_toc.toc_head_escript if SiSU_HTML_Format::Head_toc.method_defined? :toc_head_escript - @segtoc << format_head_toc.toc_head_escript if SiSU_HTML_Format::Head_toc.method_defined? :toc_head_escript + toc_shared << format_head_toc.toc_head_escript if SiSU_HTML_Format::HeadToc.method_defined? :toc_head_escript + @segtoc << format_head_toc.toc_head_escript if SiSU_HTML_Format::HeadToc.method_defined? :toc_head_escript toc_shared << format_head_toc.scroll_head_navigation_band if defined? @md.rights.all rights=format_head_toc.rights.all - rights=SiSU_HTML_Tune::Clean_html.new(rights).clean + rights=SiSU_HTML_Tune::CleanHTML.new(rights).clean end if @md.prefix_b prefix_b=format_head_toc.notes.prefix_b - prefix_b=SiSU_HTML_Tune::Clean_html.new(prefix_b).clean + prefix_b=SiSU_HTML_Tune::CleanHTML.new(prefix_b).clean end @segtoc << format_head_toc.seg_head_navigation_band toc_shared << format_head_toc.scroll_head_title_banner_open @@ -543,14 +540,14 @@ WOK doc_title_endnote=@md.title.full.gsub(/(\*+)/,'<sup><a href="#endnotes">\1</a></sup>') tmp_head=doc_title_endnote + "\n" txt_obj={ txt: tmp_head } - format_txt_obj=SiSU_HTML_Format::Format_text_object.new(@md,txt_obj) + format_txt_obj=SiSU_HTML_Format::FormatTextObject.new(@md,txt_obj) toc_shared << format_txt_obj.center_bold @segtoc << format_txt_obj.center_bold if defined? @md.creator.author creator_endnote=@md.creator.author.gsub(/(\*+)/,%{ <sup><a href="#notes">\\1</a></sup>}) tmp_head=creator_endnote + "\n" txt_obj={ txt: tmp_head } - format_txt_obj=SiSU_HTML_Format::Format_text_object.new(@md,txt_obj) + format_txt_obj=SiSU_HTML_Format::FormatTextObject.new(@md,txt_obj) toc_shared << format_txt_obj.center_bold @segtoc << format_txt_obj.center_bold end @@ -570,8 +567,9 @@ WOK if defined? @md.prefix_b toc_shared << prefix_b end - #Table of Contents added/appended here - toc_shared << @toc[:scr] + scr_toc=if @make.build.toc? #Table of Contents added/appended here + toc_shared << @toc[:scr] + end @segtoc << @links_guide_toc @segtoc << @toc[:seg] if defined? @md.rights.all \ @@ -582,20 +580,20 @@ WOK #Segtoc tail added here @segtoc << "</p>\n" #bugfix sort later DEBUGNOW @segtoc << @seg_toc_band_bottom - ads=SiSU_HTML_promo::Ad.new(@md) + ads=SiSU_HTML_Promo::Ad.new(@md) @segtoc << format_head_toc.seg_navigation_tail << ads.div.close << ads.display << format_head_toc.html_close - @segtoc.flatten!.compact! - Output.new(@segtoc,@md).segtoc + @segtoc=@segtoc.flatten.compact #watch + SiSU_HTML::Source::Output.new(@segtoc,@md).segtoc @segtoc=[] @toc[:scr],@toc[:seg]=[],[] toc_shared end end - class Table < SiSU_HTML_table::Table_html + class Table < SiSU_HTML_Table::TableHTML end - class Scroll < SiSU_HTML_scroll::Scroll + class Scroll < SiSU_HTML_Scroll::Scroll end - class Scroll_output + class ScrollOutput def initialize(scr_toc,scr_body,scr_metadata,scr_owner_details,scr_tails,md) @scr_toc,@scr_body,@scr_metadata,@scr_owner_details,@scr_tails,@md=scr_toc,scr_body,scr_metadata,scr_owner_details,scr_tails,md end @@ -603,31 +601,32 @@ WOK scroll=[] hr='<center><hr width=90% /></center>' scroll << @scr_toc << '<div class="scroll">' << hr << @scr_body << @scr_endnotes << hr << @scr_owner_details << '</div>' << @scr_tails - scroll.flatten!.compact! + scroll=scroll.flatten.compact #watch end end - class Seg < SiSU_HTML_seg::Seg + class Seg < SiSU_HTML_Seg::Seg end class Output def initialize(data='',md='') @data,@md=data,md - @file=SiSU_Env::SiSU_file.new(@md) + @file=SiSU_Env::FileOp.new(md) + @o_str ||=SiSU_Env::ProcessingSettings.new(md).output_dir_structure end def scroll begin @filename_html_scroll=@file.write_file.html_scroll @data.each do |para| - para.strip! - para.gsub!(/<:.+?>/,'') - para.gsub!(Xx[:html_relative2],@file.path_rel_links.html_scroll_2) - para.gsub!(Xx[:html_relative1],@file.path_rel_links.html_scroll_1) - #para.gsub!(/#{Xx[:html_relative]}/,@file.path_rel_links.html_scroll) - para.gsub!(/#{Rx[:mx_fa_clean]}/,'') + para=para.strip. + gsub(/<:.+?>/,''). + gsub(Xx[:html_relative2],@file.path_rel_links.html_scroll_2). + gsub(Xx[:html_relative1],@file.path_rel_links.html_scroll_1). + #gsub(/#{Xx[:html_relative]}/,@file.path_rel_links.html_scroll). + gsub(/#{Rx[:mx_fa_clean]}/,'') unless para =~/\A\s*\Z/ @filename_html_scroll.puts para,"\n" end end - rescue; SiSU_Errors::Info_error.new($!,$@,@md.opt.cmd,@md.fns).error + rescue; SiSU_Errors::InfoError.new($!,$@,@md.opt.cmd,@md.fns).error ensure; @filename_html_scroll.close end end @@ -635,26 +634,28 @@ WOK begin @filename_html_segtoc=@file.write_file.html_segtoc @data.each do |para| - para.strip! - para.gsub!(/<!.+?!>/,'') - para.gsub!(Xx[:html_relative2],@file.path_rel_links.html_seg_2) - para.gsub!(Xx[:html_relative1],@file.path_rel_links.html_seg_1) + para=para.strip. + gsub(/<!.+?!>/,''). + gsub(Xx[:html_relative2],@file.path_rel_links.html_seg_2). + gsub(Xx[:html_relative1],@file.path_rel_links.html_seg_1) unless para =~/\A\s*\Z/ @filename_html_segtoc.puts para,"\n" end end - rescue; SiSU_Errors::Info_error.new($!,$@,@md.opt.cmd,@md.fns).error + rescue; SiSU_Errors::InfoError.new($!,$@,@md.opt.cmd,@md.fns).error ensure @filename_html_segtoc.close - unless FileTest.file?("#{@file.output_path.html_seg.dir}/#{@md.file.base_filename.html_seg_index}") - pwd_set=Dir.pwd - idx_lnk=@file.base_filename.html_segtoc - mlnk=@file.base_filename.html_seg_index - Dir.chdir(@file.output_path.html_seg.dir) - FileUtils::rm_f(mlnk) - FileUtils::ln_s(idx_lnk, mlnk) - Dir.chdir(pwd_set) + pwd_set=Dir.pwd + idx_lnk=if @o_str.dump_or_redirect? + @file.base_filename.manifest + else + @file.base_filename.html_segtoc end + mlnk=@file.base_filename.html_seg_index + Dir.chdir(@file.output_path.html_seg.dir) + FileUtils::rm_f(mlnk) + FileUtils::ln_s(idx_lnk,mlnk) + Dir.chdir(pwd_set) end end end diff --git a/lib/sisu/v3/html_format.rb b/lib/sisu/v3/html_format.rb index 3dd0cecc..56360455 100644 --- a/lib/sisu/v3/html_format.rb +++ b/lib/sisu/v3/html_format.rb @@ -58,31 +58,26 @@ =end module SiSU_HTML_Format include SiSU_Viz - class Paragraph_number + class ParagraphNumber def initialize(md,ocn) @md,@ocn=md,ocn.to_s @ocn ||='' - vz=SiSU_Env::Get_init.instance.skin - @skin_no_ocn=if defined? vz.ocn_display_off \ - and vz.ocn_display_off==true - true - else false - end end def ocn_display - if @md.markup.inspect =~/no_ocn/ \ - or @md.opt.mod.inspect =~/--no-ocn/ \ - or @skin_no_ocn - ocn_class='ocn_off' - @ocn.gsub(/^(\d+|)$/, - %{<label class="#{ocn_class}"> </label>}) - elsif @ocn.to_i==0 - @ocn.gsub(/^(\d+|)$/, - %{<label class="#{ocn_class}"><a name="#{@ocn}"> </a></label>}) - else + @make=SiSU_Env::ProcessingSettings.new(@md) + if @make.build.ocn? ocn_class='ocn' + if @ocn.to_i==0 + @ocn.gsub(/^(\d+|)$/, + %{<label class="#{ocn_class}"><a name="#{@ocn}"> </a></label>}) + else + @ocn.gsub(/^(\d+|)$/, + %{<label class="#{ocn_class}"><a name="#{@ocn}" href="##{@ocn}" class="lnk#{ocn_class}">\\1</a></label>}) + end + else + ocn_class='ocn_off' @ocn.gsub(/^(\d+|)$/, - %{<label class="#{ocn_class}"><a name="#{@ocn}" href="##{@ocn}" class="lnk#{ocn_class}">\\1</a></label>}) + %{<label class="#{ocn_class}"> </label>}) end end def name @@ -95,24 +90,74 @@ module SiSU_HTML_Format %{<a href="##{@ocn}">} end end - class Head_information + class HeadInformation + require_relative 'css' # css.rb require_relative 'shared_xml' # shared_xml.rb include SiSU_Viz attr_reader :md,:rdf,:vz def initialize(md) @md=md # DublinCore 1 - title - @vz=SiSU_Env::Get_init.instance.skin - @css=SiSU_Env::CSS_stylesheet.new(md) + @vz=SiSU_Env::GetInit.instance.skin @seg_name_html=(SiSU_HTML::Source::Seg.new.seg_name_html || []) @seg_name_html_tracker=(SiSU_HTML::Source::Seg.new.seg_name_html_tracker || []) - @toc,@index='toc','index' @metalink='#metadata' @tocband_scroll,@tocband_segtoc=nil,nil + @stylesheet=SiSU_Style::CSS_HeadInfo.new(md).stylesheet + @o_str ||=SiSU_Env::ProcessingSettings.new(md).output_dir_structure + @index='index' + @toc="#{@md.file.output_path.html_seg.dir}/#{@md.file.base_filename.html_segtoc}" + end + def url_path_image_sys + (@o_str.dump_or_redirect?) \ + ? './image' + : "#{Xx[:html_relative2]}_sisu/image_sys" + end + def icon + def up + 'arrow_up_red.png' + end + def next + 'arrow_next_red.png' + end + def previous + 'arrow_prev_red.png' + end + def dot_clear + 'dot_clear.png' + end + def dot_white + 'dot_white.png' + end + def dot + dot_white + end + self + end + def png_nav + def toc + %{<img border="0" width="22" height="22" src="#{url_path_image_sys}/#{icon.up}" alt="TOC" />} + end + def pre + %{<img border="0" width="22" height="22" src="#{url_path_image_sys}/#{icon.previous}" alt="<< previous" />} + end + def nxt + %{<img border="0" width="22" height="22" src="#{url_path_image_sys}/#{icon.next}" alt="next >>" />} + end + def dot_toc + %{<img border="0" width="100%" height="20" src="#{url_path_image_sys}/#{icon.dot}" alt="^" />} + end + def dot_pre + %{<img border="0" width="100%" height="20" src="#{url_path_image_sys}/#{icon.dot}" alt="<" />} + end + def dot_nxt + %{<img border="0" width="100%" height="20" src="#{url_path_image_sys}/#{icon.dot}" alt=">" />} + end + self end def doc_types #used in toc & seg_nav_band scroll=seg='' - wgt=Widget.new(@md) + wgt=SiSU_HTML_Format::Widget.new(@md) %{ <table summary="segment navigation available documents types: toc,doc,pdf,concordance" border="0" cellpadding="3" cellspacing="0"> <tr> @@ -122,7 +167,7 @@ module SiSU_HTML_Format </tr></table>} end def rdf - SiSU_XML_tags::RDF.new(md) + SiSU_XML_Tags::RDF.new(md) end def doc_type %{<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" @@ -149,13 +194,15 @@ module SiSU_HTML_Format </html>} end end - class Widget < Head_information + class Widget < HeadInformation def initialize(md) super(md) @md=md - @cf_defaults=SiSU_Env::Info_processing_flag.new - @env=SiSU_Env::Info_env.new(@md.fns) - @file=SiSU_Env::SiSU_file.new(@md) + @cf_defaults=SiSU_Env::InfoProcessingFlag.new + @env=SiSU_Env::InfoEnv.new(md.fns) + @file=SiSU_Env::FileOp.new(md) + @o_str ||=SiSU_Env::ProcessingSettings.new(md).output_dir_structure + @make=SiSU_Env::ProcessingSettings.new(@md) end def home %{<td align="center" bgcolor=#{@vz.color_band2}> @@ -183,20 +230,27 @@ module SiSU_HTML_Format } end def search - env=SiSU_Env::Info_env.new(@md.fns,@md) - env.widget.search_form('sisusearch',nil,nil,true) + if @make.build.html_search_form? + env=SiSU_Env::InfoEnv.new(@md.fns,@md) + env.widget.search_form('sisusearch',nil,nil,true) + else '' + end end def manifest - manifest_lnk=if @file.output_dir_structure.by_language_code? \ - or @file.output_dir_structure.by_filetype? - "#{Xx[:html_relative1]}manifest/#{@file.base_filename.manifest}" - else @file.base_filename.manifest - end + if @make.build.links_to_manifest? \ + and not @o_str.dump_or_redirect? + manifest_lnk=if @file.output_dir_structure.by_language_code? \ + or @file.output_dir_structure.by_filetype? + "#{Xx[:html_relative1]}manifest/#{@file.base_filename.manifest}" + else @file.base_filename.manifest + end %{<td align="center" bgcolor=#{@vz.color_band2}> <a href="#{manifest_lnk}" target="_top" #{@vz.js_manifest}> #{@vz.nav_txt_manifest} </a> </td>} + else '' + end end def pdf #retired 2.7.9 pdf=if @md.programs[:pdf] \ @@ -263,44 +317,49 @@ module SiSU_HTML_Format end class XML end - class Head_toc < Head_information + class HeadToc < HeadInformation def initialize(md) super(md) @md=md + @o_str ||=SiSU_Env::ProcessingSettings.new(md).output_dir_structure + @make=SiSU_Env::ProcessingSettings.new(@md) end def scroll_head_navigation_band - pdf=if @md.programs[:pdf] - <<WOK + if @make.build.html_top_band? + search_and_manifest=<<WOK <td align="center" width="60%"> - #{make_seg_scroll_pdf} + #{make_scroll_search_form_and_manifest_link} </td> WOK - else '' - end - %{<table summary="table of contents scroll navigation band" id="toc" width="100%" bgcolor=#{@vz.color_band1}> + %{<table summary="table of contents scroll navigation band" id="toc" width="100%" bgcolor=#{@vz.color_band1}> <tr><td width="20%"> #{@vz.banner_band} -</td>#{pdf} +</td>#{search_and_manifest} <td width="20%"> #{@vz.table_close} <p />} + else '' + end end def concordance_navigation_band(type='') - %{<table summary="concordance navigation band" id="toc" width="100%" bgcolor=#{@vz.color_band1}> + if @make.build.html_top_band? + %{<table summary="concordance navigation band" id="toc" width="100%" bgcolor=#{@vz.color_band1}> <tr><td width="20%"> #{@vz.banner_band} </td> <td width="20%" align="right"> <a href="toc.html" target="_top" alt="->"> - #{@vz.png_nav_toc} + #{png_nav.toc} </a> #{@vz.table_close} <p />} + else '' + end end def seg_head_navigation_band(type='') firstseg=%{<a href="#{@md.firstseg}#{@md.lang_code_insert}#{Sfx[:html]}" target="_top" alt="->"> - #{@vz.png_nav_nxt} + #{png_nav.nxt} </a>} if @md.firstseg =~/\S+/ %{<table summary="table of contents segment navigation band" id="toc" width="100%" bgcolor=#{@vz.color_band1}> <tr><td width="20%"> @@ -314,27 +373,8 @@ WOK #{@vz.table_close} <p />} end - def seg_head_navigation_band_bottom(type='') #retired 2.7.9 - if type=~/pdf/ - @tocband_segtoc=make_scroll_seg_pdf - end - firstseg=%{<a href="#{@md.firstseg}#{@md.lang_code_insert}#{Sfx[:html]}" target="_top" alt="->"> - #{@vz.png_nav_nxt} - </a>} if @md.firstseg =~/\S+/ - %{<table summary="table of contents segment navigation band" id="toc" width="100%" bgcolor=#{@vz.color_band1}> -<tr><td width="20%"> - -</td> -<td width="75%" align="center"> - #{@tocband_segtoc} -</td> -<td width="5%" align="right"> - #{firstseg} -#{@vz.table_close} -<p />} - end def manifest_link(text) -# @file=SiSU_Env::SiSU_file.new(@md) if @md +# @file=SiSU_Env::FileOp.new(@md) if @md %{<font size=2> <a href="#{@md.file.base_filename.manifest}" target="_top" #{@vz.js_manifest}>#{text}</a> </font>} @@ -349,8 +389,8 @@ WOK else '' end end - def make_seg_scroll_pdf - wgt=Widget.new(@md) + def make_scroll_search_form_and_manifest_link + wgt=SiSU_HTML_Format::Widget.new(@md) scroll=%{<td align="center" bgcolor=#{@vz.color_band2}> #{@vz.nav_txt_doc_link} </td> @@ -363,7 +403,7 @@ WOK end def make_scroll_seg_pdf manifest=scroll=seg='' - wgt=Widget.new(@md) + wgt=SiSU_HTML_Format::Widget.new(@md) seg=%{<td align="center" bgcolor=#{@vz.color_band2}> #{@vz.nav_txt_toc_link} </td> @@ -377,7 +417,7 @@ WOK end def make_concordance manifest=scroll=seg='' - wgt=Widget.new(@md) + wgt=SiSU_HTML_Format::Widget.new(@md) %{<table summary="toc scroll and segment with pdf" border="0" cellpadding="3" cellspacing="0"> <tr> <td align="center" bgcolor=#{@vz.color_band2}> @@ -386,7 +426,7 @@ WOK </tr></table>} end def head - rdf=SiSU_XML_tags::RDF.new(@md) + rdf=SiSU_XML_Tags::RDF.new(@md) %{#{doc_type} <head> <title> @@ -394,7 +434,7 @@ WOK </title> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> #{rdf.metatag_html} -#{@css.html}#{@css.html_seg} +#{@stylesheet.css_head} </head> #{@vz.color_body} <a name="top" id="top"></a> @@ -417,7 +457,7 @@ WOK end end def links_guide_vertical_open -# @file=SiSU_Env::SiSU_file.new(@md) if @md +# @file=SiSU_Env::FileOp.new(@md) if @md url=((defined? @vz.url_hp) && @vz.url_hp =~/^https?:\/\/\S+$/ ? @vz.url_hp : @vz.url_home) %{ <div id="vertical_links"> @@ -438,7 +478,7 @@ WOK <!- quick ref -!>} end def links_guide_horizontal_open -# @file=SiSU_Env::SiSU_file.new(@md) if @md +# @file=SiSU_Env::FileOp.new(@md) if @md url=((defined? @vz.url_hp) && @vz.url_hp =~/^https?:\/\/\S+$/ ? @vz.url_hp : @vz.url_home) %{ <div id="horizontal_links"> @@ -529,12 +569,15 @@ WOK #{@vz.table_close}} end def manifest #check structure - manifest=manifest_link(@vz.nav_txt_manifest) - %{#{@vz.margin_txt_3} + if not @o_str.dump_or_redirect? + manifest=manifest_link(@vz.nav_txt_manifest) + %{#{@vz.margin_txt_3} #{@vz.paragraph_font_small} #{manifest} </font> #{@vz.table_close}} + else '' + end end def concordance #check structure concord=concordance_link(@vz.nav_txt_concordance) @@ -617,83 +660,83 @@ WOK } end end - class Head_seg < Head_information - def initialize(md) #(md='') + class HeadSeg < HeadInformation + 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}#{@md.lang_code_insert}#{Sfx[:html]}" + up=@toc nxt="#{@seg_name_html[@seg_name_html_tracker+1]}#{@md.lang_code_insert}#{Sfx[:html]}" if nxt=~/sisu_manifest\.html/ - @file=SiSU_Env::SiSU_file.new(@md) if @md + @file=SiSU_Env::FileOp.new(@md) if @md if @file.output_dir_structure.by_language_code? \ or @file.output_dir_structure.by_filetype? - nxt.gsub!(/sisu_manifest\.html/,"../../manifest/#{@file.base_filename.manifest}") + nxt=nxt.gsub(/sisu_manifest\.html/,"../../manifest/#{@file.base_filename.manifest}") end end %{<table summary="segment hidden control pre and next" width="100%" border="0" cellpadding="0" bgcolor=#{@vz.color_grey_pale} align="center"> <tr><td align="left"> <a href="#{pre}" target="_top" #{@vz.js_prev}> - #{@vz.png_nav_dot_pre} + #{png_nav.dot_pre} </a> </td> <td align="center"> <a href="#{up}" target="_top" #{@vz.js_toc}> - #{@vz.png_nav_dot_toc} + #{png_nav.dot_toc} </a> </td> <td align="right"> <a href="#{nxt}" target="_top" #{@vz.js_next}> - #{@vz.png_nav_dot_nxt} + #{png_nav.dot_nxt} </a> #{@vz.table_close}} end def dot_control_pre pre="#{@seg_name_html[@seg_name_html_tracker-2]}#{@md.lang_code_insert}#{Sfx[:html]}" - up="#{@toc}#{@md.lang_code_insert}#{Sfx[:html]}" + up=@toc nxt="#{@md.file.base_filename.html_segtoc}" %{<table summary="segment hidden control pre" width="100%" border="0" cellpadding="0" bgcolor=#{@vz.color_grey_pale} align="center"> <tr><td align="left"> <a href="#{pre}" target="_top" #{@vz.js_prev}> - #{@vz.png_nav_dot_pre} + #{png_nav.dot_pre} </a> </td> <td align="center"> <a href="#{up}" target="_top" #{@vz.js_toc}> - #{@vz.png_nav_dot_toc} + #{png_nav.dot_toc} </a> </td> <td align="right"> <a href="#{nxt}" target="_top" #{@vz.js_next}> - #{@vz.png_nav_dot_nxt} + #{png_nav.dot_nxt} </a> #{@vz.table_close}} end def toc_nav(f_pre=false,f_nxt=false,use=1) pre=nxt='' toc=%{<td align="center" bgcolor=#{@vz.color_band1}> - <a href="#{@toc}#{@md.lang_code_insert}#{Sfx[:html]}" target="_top" #{@vz.js_toc}> - #{@vz.png_nav_toc} + <a href="#{@toc}" target="_top" #{@vz.js_toc}> + #{png_nav.toc} </a> </td>} pre=%{<td align="center" bgcolor=#{@vz.color_band1}> <a href="#{@seg_name_html[@seg_name_html_tracker-use]}#{@md.lang_code_insert}#{Sfx[:html]}" target="_top" #{@vz.js_prev}> - #{@vz.png_nav_pre} + #{png_nav.pre} </a> </td>} if f_pre==true nxt=%{<td align="center" bgcolor=#{@vz.color_band1}> <a href="#{@seg_name_html[@seg_name_html_tracker+1]}#{@md.lang_code_insert}#{Sfx[:html]}" target="_top" #{@vz.js_next}> - #{@vz.png_nav_nxt} + #{png_nav.nxt} </a> </td>} if f_nxt==true if nxt =~/sisu_manifest.html/ - @file=SiSU_Env::SiSU_file.new(@md) if @md + @file=SiSU_Env::FileOp.new(@md) if @md if @file.output_dir_structure.by_language_code? \ or @file.output_dir_structure.by_filetype? - nxt.gsub!(/sisu_manifest\.html/,"../../manifest/#{@file.base_filename.manifest}") + nxt=nxt.gsub(/sisu_manifest\.html/,"../../manifest/#{@file.base_filename.manifest}") end end %{<table summary="segment navigation pre/next" border="0" cellpadding="3" cellspacing="0"> @@ -749,7 +792,7 @@ WOK <font size="2">} end def heading_advert_local_1 - dir=SiSU_Env::Info_env.new(@fns) + dir=SiSU_Env::InfoEnv.new(@fns) %{ <center> <table summary="image" border="0" cellpadding="3" cellspacing="0" align="center"> <tr><td align="center" bgcolor="white"> @@ -761,7 +804,7 @@ WOK </center>} end def heading_advert_local_2 - dir=SiSU_Env::Info_env.new(@fns) + dir=SiSU_Env::InfoEnv.new(@fns) %{ <center> <table summary="image" border="0" cellpadding="3" cellspacing="0" align="center"> <tr><td align="center" bgcolor="white"> @@ -773,7 +816,7 @@ WOK </center>} end def heading_advert_external - dir=SiSU_Env::Info_env.new(@fns) + dir=SiSU_Env::InfoEnv.new(@fns) %{ <center> <table summary="image" border="0" cellpadding="3" cellspacing="0" align="center"> <tr><td align="center" bgcolor="white"> @@ -844,7 +887,7 @@ WOK } #revisit end def head_seg - rdf=SiSU_XML_tags::RDF.new(@md) + rdf=SiSU_XML_Tags::RDF.new(@md) %{#{doc_type} <head> <title> @@ -853,7 +896,7 @@ WOK </title> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> #{rdf.metatag_html} -#{@css.html_seg} +#{@stylesheet.css_head_seg} </head> #{@vz.color_body} <a name="top" id="top"></a> @@ -883,7 +926,7 @@ WOK } end end - class Head_scroll < Head_toc + class HeadScroll < HeadToc def initialize(md) super(md) end @@ -900,8 +943,8 @@ WOK #{@vz.table_close}} end end - class Format_text_object - @vz=SiSU_Env::Get_init.instance.skin + class FormatTextObject + @vz=SiSU_Env::GetInit.instance.skin 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 @@ -916,12 +959,12 @@ WOK @lnk_url =t_o[:lnk_url] || nil @lnk_txt =t_o[:lnk_txt] || nil @format =t_o[:format] || nil - elsif t_o.class.inspect =~/^(?:#<)?SiSU_document_structure/ + elsif t_o.class.inspect =~/^(?:#<)?SiSU_DAL_DocumentStructure/ @dob=t_o if defined? t_o.is @named=nametags_seg(@dob) @txt=((defined? t_o.obj) ? t_o.obj : nil) @ocn=((defined? t_o.ocn) ? t_o.ocn.to_s : nil) - @headname=((t_o.is=='heading' and defined? t_o.name) ? t_o.name : nil) + @headname=((t_o.is==:heading and defined? t_o.name) ? t_o.name : nil) else if @md.opt.cmd =~/M/ p t_o.class @@ -930,10 +973,11 @@ WOK end @headnamed= (@headname ? %{<a name="h#{@headname}" id="h#{@headname}"></a>} : nil) if @txt and not @txt.empty? - @txt.gsub!(/#{Mx[:mk_o]}[-~]##{Mx[:mk_c]}/,'') + @txt=@txt.gsub(/#{Mx[:mk_o]}[-~]##{Mx[:mk_c]}/,'') end - @p_num=Paragraph_number.new(@md,@ocn) - @vz=SiSU_Env::Get_init.instance.skin + @p_num=ParagraphNumber.new(@md,@ocn) + @vz=SiSU_Env::GetInit.instance.skin + @make=SiSU_Env::ProcessingSettings.new(@md) end def nametags_scroll(dob) tags='' @@ -956,9 +1000,9 @@ WOK tags end def headname #check whether used - hn=if @t_o.is =='heading' \ + hn=if @t_o.is ==:heading \ and not @t_o.name.empty? #determine use - hn=if @t_o.is =='heading'; %{<a name="h#{@t_o.name}" id="h#{@t_o.name}"></a>} + hn=if @t_o.is ==:heading; %{<a name="h#{@t_o.name}" id="h#{@t_o.name}"></a>} else %{<a name="#{@t_o.name}" id="#{@t_o.name}"></a>} end else nil @@ -1030,15 +1074,15 @@ WOK end def table @txt=if @t_o.obj !~/^<table\s/ - table=SiSU_HTML_shared::Table_html.new(@t_o) #move, make happen earlier + table=SiSU_HTML_Shared::TableHTML.new(@t_o) #move, make happen earlier @txt=table.table.obj else @txt end para_form_css('p','norm') end def break - @txt.gsub!(/#{Mx[:br_page_new]}|#{Mx[:br_page]}/,'<hr /><br />') - @txt.gsub!(/#{Mx[:br_obj]}/,'<hr style="width:30%" /><br />') + @txt=@txt.gsub(/#{Mx[:br_page_new]}|#{Mx[:br_page]}/,'<hr /><br />'). + gsub(/#{Mx[:br_obj]}/,'<hr style="width:30%" /><br />') para_form_css('p','norm') end def format(tag,attrib) @@ -1076,8 +1120,11 @@ WOK heading_normal('h6','norm') end def title_heading(tag,attrib) + cl=(@make.build.html_minitoc?) \ + ? 'content' + : 'content0' %{ -<div class="content"> +<div class="#{cl}"> <#{tag} class="#{attrib}"> #{@named}#{@txt} </#{tag}> @@ -1097,7 +1144,7 @@ WOK '' end def seg_heading_sub(tag,attrib) - @txt.gsub!(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ') + @txt=@txt.gsub(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ') %{ <div class="substance"> #{@p_num.ocn_display} @@ -1132,15 +1179,16 @@ WOK </div>' end def gsub_body #fix - case @txt + @txt=case @txt when /^\((i+|iv|v|vi+|ix|x|xi+)\)/ - @txt.gsub!(/^\((i+|iv|v|vi+|ix|x|xi+)\)/,'<b>(\1)</b>') + @txt.gsub(/^\((i+|iv|v|vi+|ix|x|xi+)\)/,'<b>(\1)</b>') when /^\(?(\d|[a-z])+\)/ - @txt.gsub!(/^\((\d+|[a-z])+\)/,'<b>(\1)</b>') + @txt.gsub(/^\((\d+|[a-z])+\)/,'<b>(\1)</b>') when /^\s*\d{1,3}\.\s/ - @txt.gsub!(/^\s*(\d+\.)/,'<b>\1</b>') + @txt.gsub(/^\s*(\d+\.)/,'<b>\1</b>') when /^\s*[A-Z]\.\s/ - @txt.gsub!(/^\s*([A-Z]\.)/,'<b>\1</b>') + @txt.gsub(/^\s*([A-Z]\.)/,'<b>\1</b>') + else @txt end end def bold_para @@ -1153,8 +1201,8 @@ WOK #{@vz.table_close}} end def bold_heading - @txt.gsub!(/[1-9]~(\S+)/,'<a name="\1"></a>') - @txt.gsub!(/[1-9]~/,'') + @txt=@txt.gsub(/[1-9]~(\S+)/,'<a name="\1"></a>'). + gsub(/[1-9]~/,'') %{<p class="bold"> #{@txt} </p> @@ -1175,13 +1223,13 @@ WOK %{<p class="centerbold">#{@txt}</p>\n} end end - class Format_scroll < Format_text_object + class FormatScroll < FormatTextObject def initialize(md,txt) super(md,txt) - @vz=SiSU_Env::Get_init.instance.skin + @vz=SiSU_Env::GetInit.instance.skin end end - class Format_seg < Format_text_object + class FormatSeg < FormatTextObject def initialize(md,txt) super(md,txt) end @@ -1242,8 +1290,8 @@ WOK } end def clean(txt) - txt.gsub!(/#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}/,'') - txt.gsub!(/#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]}/,'') + txt=txt.gsub(/#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}/,''). + gsub(/#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]}/,'') txt end def subtoc_lev(tag,attrib) @@ -1256,9 +1304,9 @@ 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.gsub!(/[\n\s]+/m,' ') - txt.gsub!(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ') - txt.gsub!(/<a[\n\s]+name="-\d+"[\n\s]+href="#_\d+"> <sup>\d+<\/sup> /m,'') + note=note.gsub(/[\n\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,'') end %{<#{tag} class="#{attrib}"> <a href="##{@ocn}"><i>#{txt}</i></a> #{note} @@ -1271,7 +1319,7 @@ WOK subtoc_lev('h6','subtoc') if @txt end def heading_sub(tag,attrib) - @txt.gsub!(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ') + @txt=@txt.gsub(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ') %{ <div class="substance"> #{@p_num.ocn_display} @@ -1320,7 +1368,7 @@ WOK "<center>#{@txt}</center>" end end - class Format_toc < Format_text_object + class FormatToc < FormatTextObject def initialize(md,txt) super(md,txt) end @@ -1363,7 +1411,7 @@ WOK lev('h0','toc') end def strip_endnotes(txt) - txt.gsub!(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ') + txt=txt.gsub(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ') txt end def mini_lev1 @@ -1411,7 +1459,7 @@ WOK } end end - class Format_str + class FormatStr def initialize(md,str) @str=str end diff --git a/lib/sisu/v3/html_minitoc.rb b/lib/sisu/v3/html_minitoc.rb index fef0bb3f..729eee50 100644 --- a/lib/sisu/v3/html_minitoc.rb +++ b/lib/sisu/v3/html_minitoc.rb @@ -57,10 +57,10 @@ ** Description: system environment, resource control and configuration details =end - module SiSU_HTML_minitoc + module SiSU_HTML_MiniToc require_relative 'html_tune' # html_tune.rb include SiSU_HTML_Tune - class Toc_mini + class TocMini @@seg_mini=nil @@seg_url='' @@firstseg=nil @@ -74,18 +74,19 @@ toc=nil @toc=[] @data.each do |txt| - if (txt.is =='heading' or txt.is =='heading_insert') - txt.obj.gsub!(/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]}).+?(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/m,'') #remove endnotes from toc - txt.obj.gsub!(/<a name="-\d+" href="#_\d+"> <sup>\d+<\/sup> <\/a>/,'') - txt.obj.gsub!(@pat_strip_heading_name,'\1') - txt.obj.gsub(/(.*?)<a name="(\d+)"><\/a>(.*)/,'\1') #2002w42 altered gsub! - problematic? - suspect + if txt.is ==:heading \ + || txt.is ==:heading_insert + txt.obj=txt.obj.gsub(/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]}).+?(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/m,''). #remove endnotes from toc + gsub(/<a name="-\d+" href="#_\d+"> <sup>\d+<\/sup> <\/a>/,''). + gsub(@pat_strip_heading_name,'\1') + #gsub(/(.*?)<a name="(\d+)"><\/a>(.*)/,'\1') #2002w42 altered gsub - problematic? - suspect toc=case txt.ln - when 1; Toc_mini.new(@md,txt).level_1 - when 2; Toc_mini.new(@md,txt).level_2 - when 3; Toc_mini.new(@md,txt).level_3 - when 4; Toc_mini.new(@md,txt).level_4 - when 5; Toc_mini.new(@md,txt).level_5 - when 6; Toc_mini.new(@md,txt).level_6 + when 1; SiSU_HTML_MiniToc::TocMini.new(@md,txt).level_1 + when 2; SiSU_HTML_MiniToc::TocMini.new(@md,txt).level_2 + when 3; SiSU_HTML_MiniToc::TocMini.new(@md,txt).level_3 + when 4; SiSU_HTML_MiniToc::TocMini.new(@md,txt).level_4 + when 5; SiSU_HTML_MiniToc::TocMini.new(@md,txt).level_5 + when 6; SiSU_HTML_MiniToc::TocMini.new(@md,txt).level_6 else end @toc << toc @@ -95,22 +96,23 @@ end protected def level_concordance - format_head_toc=SiSU_HTML_Format::Head_toc.new(@md) + format_head_toc=SiSU_HTML_Format::HeadToc.new(@md) @@seg_mini << format_head_toc.mini_seg_concordance end def level_metadata - format_head_toc=SiSU_HTML_Format::Head_toc.new(@md) + format_head_toc=SiSU_HTML_Format::HeadToc.new(@md) @@seg_mini << format_head_toc.mini_seg_metadata end def level_word_index - format_head_toc=SiSU_HTML_Format::Head_toc.new(@d0c) + format_head_toc=SiSU_HTML_Format::HeadToc.new(@d0c) @@seg_mini << format_head_toc.mini_concordance end def level_1 txt=@data - if (txt.is =='heading' or txt.is =='heading_insert') \ - and txt.ocn !=0 - txt.obj.gsub!(@pat_strip_heading_name,'\1') + if (txt.is ==:heading \ + || txt.is ==:heading_insert) \ + && txt.ocn !=0 + txt.obj=txt.obj.gsub(@pat_strip_heading_name,'\1') end title=unless txt.obj =~/Document Information/; txt.obj else @@ -119,7 +121,7 @@ end toc={} txt_obj={ txt: title } - format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) + format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) toc_mini=if txt.name =~/^meta/ and txt.obj=~/Document Information/ format_toc.mini_tail else format_toc.mini_lev1 @@ -128,19 +130,20 @@ end def level_2 txt=@data - if (txt.is =='heading' or txt.is =='heading_insert') \ - and txt.ocn !=0 - txt.obj.gsub!(@pat_strip_heading_name,'\1') + if (txt.is ==:heading \ + || txt.is ==:heading_insert) \ + && txt.ocn !=0 + txt.obj=txt.obj.gsub(@pat_strip_heading_name,'\1') end txt_obj={ txt: txt.obj } - format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) + format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) toc_mini=format_toc.mini_lev2 toc_mini end def level_3 txt=@data txt_obj={ txt: txt.obj } - format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) + format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) toc_mini=format_toc.mini_lev3 toc_mini end @@ -158,38 +161,40 @@ %{target="_top">\\1 \\2</a> }) end txt_obj={ txt: seg_link } - format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) + format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) toc_mini=format_toc.mini_lev4 toc_mini end end def level_5 txt=@data - if (txt.is =='heading' or txt.is =='heading_insert') \ - and txt.ocn !=0 - txt.obj.gsub!(@pat_strip_heading_name,'\1') + if (txt.is ==:heading \ + || txt.is ==:heading_insert) \ + && txt.ocn !=0 + txt.obj=txt.obj.gsub(@pat_strip_heading_name,'\1') end toc={} lnk_n_txt=%{ <a href="#{@@seg_url}#{@md.lang_code_insert}#{Sfx[:html]}##{txt.ocn}"> #{txt.obj} </a>} txt_obj={ txt: lnk_n_txt } - format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) + format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) toc_mini=format_toc.mini_lev5 toc_mini end def level_6 txt=@data - if (txt.is =='heading' or txt.is =='heading_insert') \ - and txt.ocn !=0 - txt.obj.gsub!(@pat_strip_heading_name,'\1') + if (txt.is ==:heading \ + || txt.is ==:heading_insert) \ + && txt.ocn !=0 + txt.obj=txt.obj.gsub(@pat_strip_heading_name,'\1') end toc={} lnk_n_txt=%{ <a href="#{@@seg_url}#{@md.lang_code_insert}#{Sfx[:html]}##{txt.ocn}"> #{txt.obj} </a>} txt_obj={ txt: lnk_n_txt } - format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) + format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) toc_mini=format_toc.mini_lev6 toc_mini end diff --git a/lib/sisu/v3/html_promo.rb b/lib/sisu/v3/html_promo.rb index acc924b6..f53211e9 100644 --- a/lib/sisu/v3/html_promo.rb +++ b/lib/sisu/v3/html_promo.rb @@ -56,33 +56,44 @@ ** Description: html advertising component, build here, mockup =end -module SiSU_HTML_promo +module SiSU_HTML_Promo require_relative 'sysenv' # sysenv.rb include SiSU_Env class Ad def initialize(md) @md=md - @env=SiSU_Env::Info_env.new(@md.fns,@md) - @rc=SiSU_Env::Get_init.instance.sisu_yaml.rc - @ad=SiSU_Env::Get_init.instance.ads - @vz=SiSU_Env::Get_init.instance.skin + @env=SiSU_Env::InfoEnv.new(@md.fns,@md) + @rc=SiSU_Env::GetInit.instance.sisu_yaml.rc + @ad=SiSU_Env::GetInit.instance.ads + @vz=SiSU_Env::GetInit.instance.skin @flag=@env.widget.promo? + @make=SiSU_Env::ProcessingSettings.new(@md) end def div def major - @flag[:ad] ? '<div id="pane_major">' : '' + (@make.build.html_right_pane? \ + && @flag[:ad]) \ + ? '<div id="pane_major">' + : '' end def minor - @flag[:ad] ? '<div id="pane_minor">' : '' + (@make.build.html_right_pane? \ + && @flag[:ad]) \ + ? '<div id="pane_minor">' + : '' end def close - @flag[:ad] ? '</div>' : '' + (@make.build.html_right_pane? \ + && @flag[:ad]) \ + ? '</div>' + : '' end self end - def display #(type=nil,id=nil) + def display ads_array,promo_array=[],[] - if @flag[:ad] + if @make.build.html_right_pane? \ + && @flag[:ad] ads=if @md.promo && @md.promo.length > 0 #promo set in document promo_array=@md.promo elsif @flag[:sk] #promo set in associated skin diff --git a/lib/sisu/v3/html_scroll.rb b/lib/sisu/v3/html_scroll.rb index c09ae68f..a4d2089e 100644 --- a/lib/sisu/v3/html_scroll.rb +++ b/lib/sisu/v3/html_scroll.rb @@ -56,7 +56,7 @@ ** Description: html scroll generation, processing =end -module SiSU_HTML_scroll +module SiSU_HTML_Scroll require_relative 'shared_html' # shared_html.rb require_relative 'html' # html.rb require_relative 'shared_metadata' # shared_metadata.rb @@ -64,14 +64,14 @@ module SiSU_HTML_scroll class Scroll def initialize(md='',data='',endnotes='') @md,@data,@endnotes=md,data,endnotes - @vz=SiSU_Env::Get_init.instance.skin + @vz=SiSU_Env::GetInit.instance.skin end def songsheet begin - scr=Scroll.new(@md,@data,@endnotes).markup - scr[:tails]=Scroll.new(@md).tails + scr=SiSU_HTML_Scroll::Scroll.new(@md,@data,@endnotes).markup + scr[:tails]=SiSU_HTML_Scroll::Scroll.new(@md).tails scr - rescue; SiSU_Errors::Info_error.new($!,$@,@md.opt.cmd,@md.fns).error + rescue; SiSU_Errors::InfoError.new($!,$@,@md.opt.cmd,@md.fns).error ensure end end @@ -81,14 +81,14 @@ module SiSU_HTML_scroll @rcdc=false @scr={ body: [], metadata: [], owner_details: [] } data.each do |dob| - dob.obj.gsub!(/#{@md.file.output_path.html_seg.rel_image}/m,@md.file.output_path.html_scroll.rel_image) + dob.obj=dob.obj.gsub(/#{@md.file.output_path.html_seg.rel_image}/m,@md.file.output_path.html_scroll.rel_image) if defined? dob.name and dob.name =~/^meta/ \ and dob.obj =~/Document Information/ - dob.obj.gsub!(/(Document Information(?: \(metadata\))?)/,'\1<a name="docinfo"></a>') + dob.obj=dob.obj.gsub(/(Document Information(?: \(metadata\))?)/,'\1<a name="docinfo"></a>') end if dob.obj =~/^Metadata$/ \ and dob.lv =='B' - dob.obj.gsub!(/Metadata/,'') + dob.obj=dob.obj.gsub(/Metadata/,'') end if defined? dob.name \ and dob.name =~/^metadata/ \ @@ -96,17 +96,18 @@ module SiSU_HTML_scroll and dob.obj =~/SiSU Metadata, document information/ @rcdc=true end - dob.obj.gsub!(/href="[a-z0-9._-]+(#\S+?")/m,'href="\1') # internal document links - dob.obj.gsub!(/href="#{Xx[:segment]}/m,'href="') - dob.obj.gsub!(/(?:\s*#{Mx[:br_page]}\s*|\s*#{Mx[:br_page_new]}\s*)+/m,'<p><hr width=90% /></p>') + dob.obj=dob.obj.gsub(/href="[a-z0-9._-]+(#\S+?")/m,'href="\1'). # internal document links + gsub(/href="#{Xx[:segment]}/m,'href="'). + gsub(/(?:\s*#{Mx[:br_page]}\s*|\s*#{Mx[:br_page_new]}\s*)+/m,'<p><hr width=90% /></p>') if dob.obj !~/(^#{Rx[:meta]}|#{Mx[:br_eof]})/ - unless dob.is =~/^code/; dob.obj.gsub!(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ') + unless dob.is ==:code + dob.obj=dob.obj.gsub(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ') end if defined? dob.ocn - @p_num=SiSU_HTML_Format::Paragraph_number.new(@md,dob.ocn) + @p_num=SiSU_HTML_Format::ParagraphNumber.new(@md,dob.ocn) end - sto=SiSU_HTML_Format::Format_text_object.new(@md,dob) - para_html=if dob.is=='heading' + sto=SiSU_HTML_Format::FormatTextObject.new(@md,dob) + para_html=if dob.is==:heading x=if dob.ln==1 sto.heading_body1 elsif dob.ln==2 @@ -120,7 +121,7 @@ module SiSU_HTML_scroll elsif dob.ln==6 sto.heading_body6 end - elsif dob.is=='heading_insert' + elsif dob.is==:heading_insert x=if dob.ln==1 sto.heading_body1 elsif dob.ln==2 @@ -137,22 +138,22 @@ module SiSU_HTML_scroll elsif dob.ln==4 \ and dob.obj=='Index' sto.heading_body4 - book_idx=SiSU_Particulars::Combined_singleton.instance.get_idx_html(@md.opt).html_idx + book_idx=SiSU_Particulars::CombinedSingleton.instance.get_idx_html(@md.opt).html_idx book_idx.each do |x| #takes book index prepared for segments and strips segment identifying info - x.gsub!(/<a href="\S+?\.html#(\d+)">(\1(?:-\d+)?)<\/a>/,'<a href="#\1">\2</a>') + x=x.gsub(/<a href="\S+?\.html#(\d+)">(\1(?:-\d+)?)<\/a>/,'<a href="#\1">\2</a>') end book_idx.join("\n") #elsif dob.ln==4 \ #and dob.obj=~/Meta/ #p __LINE__ ##and dob.obj=='Metadata' - #metadata=Metadata::Summary.new(@md).xhtml.metadata + #metadata=SiSU_Metadata::Summary.new(@md).xhtml.metadata elsif dob.ln==5 sto.heading_body5 elsif dob.ln==6 sto.heading_body6 end - elsif dob.is=='para' + elsif dob.is==:para if dob.indent \ and dob.hang \ and dob.indent =~/[0-9]/ \ @@ -171,19 +172,19 @@ module SiSU_HTML_scroll end else sto.para end - elsif dob.is=='block' + elsif dob.is==:block sto.block - elsif dob.is=='group' + elsif dob.is==:group sto.group - elsif dob.is=='alt' + elsif dob.is==:alt sto.alt - elsif dob.is=='verse' + elsif dob.is==:verse sto.verse - elsif dob.is=='code' + elsif dob.is==:code sto.code - elsif dob.is=='table' + elsif dob.is==:table sto.table - elsif dob.is=='break' + elsif dob.is==:break sto.break end if dob =~/<a name="n\d+">/ \ @@ -199,8 +200,8 @@ module SiSU_HTML_scroll end def tails scr_tail=[] - format_head_scroll=SiSU_HTML_Format::Head_toc.new(@md) - ads=SiSU_HTML_promo::Ad.new(@md) + format_head_scroll=SiSU_HTML_Format::HeadToc.new(@md) + ads=SiSU_HTML_Promo::Ad.new(@md) scr_tail << format_head_scroll.scroll_tail << ads.div.close << ads.display << format_head_scroll.html_close scr_tail end diff --git a/lib/sisu/v3/html_segments.rb b/lib/sisu/v3/html_segments.rb index a7e37227..b1dbf73f 100644 --- a/lib/sisu/v3/html_segments.rb +++ b/lib/sisu/v3/html_segments.rb @@ -56,62 +56,78 @@ ** Description: html segment generation, processing =end -module SiSU_HTML_seg +module SiSU_HTML_Seg require_relative 'shared_html' # shared_html.rb require_relative 'html' # html.rb require_relative 'html_promo' # html_promo.rb require_relative 'shared_metadata' # shared_metadata.rb - class Seg_output + class Output def initialize(md,outputfile,seg,minitoc,type='') @md,@output_seg_file,@seg,@minitoc,@type=md,outputfile,seg,minitoc,type - @title_banner_=SiSU_Env::Create_site.new(@md.opt.cmd).html_seg_title_banner? - @file=SiSU_Env::SiSU_file.new(@md) + @title_banner_=SiSU_Env::CreateSite.new(@md.opt.cmd).html_seg_title_banner? + @file=SiSU_Env::FileOp.new(@md) + @make=SiSU_Env::ProcessingSettings.new(@md) + @cl=(@make.build.html_minitoc?) \ + ? 'content' + : 'content0' end def output if @seg[:title] =~/\S/ filename_seg=[] - filename_seg << @seg[:title] << @seg[:tocband_banner] + if @make.build.html_top_band? + filename_seg << @seg[:title] << @seg[:tocband_banner] + else + filename_seg << @seg[:title] + end if @type=='endnotes' @seg[:headings]=[] - format_head_seg=SiSU_HTML_Format::Head_seg.new(@md) + format_head_seg=SiSU_HTML_Format::HeadSeg.new(@md) if @title_banner_ @seg[:headings] << format_head_seg.title_banner(@md.title.main,@md.title.sub,@author) end txt_obj={ txt: 'Endnotes', ocn_display: '' } - format_seg=SiSU_HTML_Format::Format_seg.new(@md,txt_obj) + format_seg=SiSU_HTML_Format::FormatSeg.new(@md,txt_obj) @seg[:headings] << format_seg.title_heading1 - filename_seg << @seg[:heading_endnotes] << @minitoc << @seg[:headings] << %{\n<div class="content">\n} << @seg[:endnote_all] << '</div>' # << '</div>' + filename_seg << @seg[:heading_endnotes] << @minitoc << @seg[:headings] << %{\n<div class="#{@cl}">\n} << @seg[:endnote_all] << '</div>' # << '</div>' elsif @type=='idx' @seg[:headings]=[] - format_head_seg=SiSU_HTML_Format::Head_seg.new(@md) + format_head_seg=SiSU_HTML_Format::HeadSeg.new(@md) if @title_banner_ @seg[:headings] << format_head_seg.title_banner(@md.title.main,@md.title.sub,@author) end txt_obj={ txt: 'Index', ocn_display: '' } - format_seg=SiSU_HTML_Format::Format_seg.new(@md,txt_obj) + format_seg=SiSU_HTML_Format::FormatSeg.new(@md,txt_obj) @seg[:headings] << format_seg.title_heading1 - filename_seg << @seg[:heading_idx] << @minitoc << @seg[:headings] << %{\n<div class="content">\n} << @seg[:idx] << '</div>' # << '</div>' + filename_seg << @seg[:heading_idx] << @minitoc << @seg[:headings] << %{\n<div class="#{@cl}">\n} << @seg[:idx] << '</div>' # << '</div>' elsif @type=='metadata' - metadata=Metadata::Summary.new(@md).xhtml_display.metadata + metadata=SiSU_Metadata::Summary.new(@md).xhtml_display.metadata @seg[:headings]=[] - format_head_seg=SiSU_HTML_Format::Head_seg.new(@md) + format_head_seg=SiSU_HTML_Format::HeadSeg.new(@md) if @title_banner_ @seg[:headings] << format_head_seg.title_banner(@md.title.main,@md.title.sub,@author) end txt_obj={ txt: 'Metadata', ocn_display: '' } - format_seg=SiSU_HTML_Format::Format_seg.new(@md,txt_obj) + format_seg=SiSU_HTML_Format::FormatSeg.new(@md,txt_obj) @seg[:headings] << format_seg.title_heading1 - filename_seg << @seg[:heading_idx] << @minitoc << @seg[:headings] << %{\n<div class="content">\n} << metadata << '</div>' # << '</div>' + filename_seg << @seg[:heading_idx] << @minitoc << @seg[:headings] << %{\n<div class="#{@cl}">\n} << metadata << '</div>' # << '</div>' + else + if @make.build.html_top_band? + filename_seg << @minitoc << @seg[:headings] << @seg[:main] << "\n</div>\n" + else + filename_seg << @minitoc << @seg[:main] << "\n</div>\n" + end + end + filename_seg <<=if @make.build.html_top_band? + @seg[:tail] << @seg[:tocband_bannerless] << @seg[:credits] else - filename_seg << @minitoc << @seg[:headings] << @seg[:main] << "\n</div>\n" + @seg[:tail] << @seg[:credits] end - filename_seg << @seg[:tail] << @seg[:tocband_bannerless] << @seg[:credits] - filename_seg.flatten!.compact! + filename_seg=filename_seg.flatten.compact #watch filename_seg.each do |str| unless str =~/\A\s*\Z/ - str.strip! - str.gsub!(Xx[:html_relative2],@file.path_rel_links.html_seg_2) - str.gsub!(Xx[:html_relative1],@file.path_rel_links.html_seg_1) + str=str.strip. + gsub(Xx[:html_relative2],@file.path_rel_links.html_seg_2). + gsub(Xx[:html_relative1],@file.path_rel_links.html_seg_1) @output_seg_file << str end end @@ -134,12 +150,19 @@ module SiSU_HTML_seg attr_reader :seg_name_html,:seg_name_html_tracker def initialize(md=nil,data='') @md,@data=md,data - @vz=SiSU_Env::Get_init.instance.skin + @vz=SiSU_Env::GetInit.instance.skin @seg_name_html=@@seg_name_html || nil @seg_name_html_tracker=@@tracker || nil - @env=SiSU_Env::Info_env.new(@md.fns) if @md + @env=SiSU_Env::InfoEnv.new(@md.fns) if @md if @md - @title_banner_=SiSU_Env::Create_site.new(@md.opt.cmd).html_seg_title_banner? + @make=SiSU_Env::ProcessingSettings.new(@md) + @cl=(@make.build.html_minitoc?) \ + ? 'content' + : 'content0' + else @cl='content' + end + if @md + @title_banner_=SiSU_Env::CreateSite.new(@md.opt.cmd).html_seg_title_banner? end end def songsheet @@ -147,9 +170,9 @@ module SiSU_HTML_seg @minitoc=SiSU_HTML::Source::Toc.new(@md,@data).minitoc data=get_subtoc_endnotes(@data) data=articles(data) - Seg.new.cleanup # (((( added )))) + SiSU_HTML_Seg::Seg.new.cleanup # (((( added )))) #### (((( END )))) #### - rescue; SiSU_Errors::Info_error.new($!,$@,@md.opt.cmd,@md.fns).error + rescue; SiSU_Errors::InfoError.new($!,$@,@md.opt.cmd,@md.fns).error ensure @@seg_name=[] end @@ -161,14 +184,15 @@ module SiSU_HTML_seg printed_endnote_seg='n' idx_html=nil if @md.book_idx - #my_make_source_file=SiSU_Env::Create_file.new(@md.fns) - idx_html=SiSU_Particulars::Combined_singleton.instance.get_idx_html(@md.opt).html_idx + #my_make_source_file=SiSU_Env::CreateFile.new(@md.fns) + idx_html=SiSU_Particulars::CombinedSingleton.instance.get_idx_html(@md.opt).html_idx idx_html.each {|x| @@seg[:idx] << x } @@seg[:heading_idx]='' end data.each do |dob| - if (dob.is=='heading' or dob.is=='heading_insert') \ - and dob.ln==4 + if (dob.is == :heading \ + || dob.is == :heading_insert) \ + && dob.ln == 4 @@seg_name << dob.name seg_name=dob.name end @@ -177,7 +201,7 @@ module SiSU_HTML_seg @@seg_total=@@seg_name.length testforartnum=@@seg_name_html SiSU_Screen::Ansi.new(@md.opt.cmd,@@seg_name.length).segmented if @md.opt.cmd =~/[MVv]/ - map_nametags=SiSU_Particulars::Combined_singleton.instance.get_map_nametags(@md).nametags_map #p map_nametags + map_nametags=SiSU_Particulars::CombinedSingleton.instance.get_map_nametags(@md).nametags_map #p map_nametags data.each do |dob| if defined? dob.obj \ and dob.obj =~/href="#{Xx[:segment]}#+\S+?"/ @@ -192,32 +216,37 @@ module SiSU_HTML_seg end end end - if (dob.is=='heading' or dob.is=='heading_insert') \ - and dob.ln==4 + if (dob.is==:heading \ + || dob.is==:heading_insert) \ + && dob.ln==4 if dob.ocn==0 @@heading4=dob.obj else @@heading4=dob.obj end @@is4=newfile=1 end - if (dob.is=='heading' or dob.is=='heading_insert') \ - and dob.ln==3 + if (dob.is==:heading \ + || dob.is==:heading_insert) \ + && dob.ln==3 @@heading3=dob.obj @@is4,@@is3=0,1 end - if (dob.is=='heading' or dob.is=='heading_insert') \ - and dob.ln==2 + if (dob.is==:heading \ + || dob.is==:heading_insert) \ + && dob.ln==2 @@heading2=dob.obj @@is4,@@is3,@@is2=0,0,1 end - if (dob.is=='heading' or dob.is=='heading_insert') \ - and dob.ln==1 + if (dob.is==:heading \ + || dob.is==:heading_insert) \ + && dob.ln==1 @@heading1=dob.obj @@is4,@@is3,@@is2,@@is1=0,0,0,1 end if (@@is1 && !@@is2 && !@@is3 && !@@is4) - if not (dob.is=='heading' or dob.is=='heading_insert') \ - and dob.ln==1 + if not (dob.is==:heading \ + || dob.is==:heading_insert) \ + && dob.ln==1 head1=$_ #; check end end @@ -225,46 +254,47 @@ module SiSU_HTML_seg if newfile==1 \ or dob.obj =~/^#{Mx[:br_endnotes]}|^#{Mx[:br_eof]}/ newfile=0 - if (dob.is=='heading' or dob.is=='heading_insert') \ - and dob.ln==4 + if (dob.is==:heading \ + || dob.is==:heading_insert) \ + && dob.ln==4 if tracking != 0 - dirout=SiSU_Env::Info_env.new(@md.fns) + dirout=SiSU_Env::InfoEnv.new(@md.fns) dir_sisu=dirout.path.output - @file=SiSU_Env::SiSU_file.new(@md) + @file=SiSU_Env::FileOp.new(@md) unless FileTest.directory?(@file.output_path.html_seg.dir) FileUtils::mkdir_p(@file.output_path.html_seg.dir) if File.writable?("#{@file.output_path.base.dir}/.") end - Seg.new(@md).tail + SiSU_HTML_Seg::Seg.new(@md).tail segfilename="#{@file.output_path.html_seg.dir}/#{@@seg_name_html[tracking-1]}#{@md.lang_code_insert}#{Sfx[:html]}" output_seg_file=File.new(segfilename,'w') if @@seg_name_html[tracking-1] - minitoc=(@env.html_minitoc?) \ + minitoc=(@make.build.html_minitoc?) \ ? @minitoc : '' - if dob.is=='heading' \ - or @@seg_name_html[tracking-1] !~/endnotes|book_index|metadata/ - Seg_output.new(@md,output_seg_file,@@seg,minitoc).output - elsif dob.is=='heading_insert' + if dob.is==:heading \ + || (@@seg_name_html[tracking-1] !~/endnotes|book_index|metadata/) + SiSU_HTML_Seg::Output.new(@md,output_seg_file,@@seg,minitoc).output + elsif dob.is==:heading_insert if @@seg_name_html[tracking-1]=='endnotes' - Seg_output.new(@md,output_seg_file,@@seg,minitoc,'endnotes').output + SiSU_HTML_Seg::Output.new(@md,output_seg_file,@@seg,minitoc,'endnotes').output elsif @@seg_name_html[tracking-1]=='book_index' - Seg_output.new(@md,output_seg_file,@@seg,minitoc,'idx').output + SiSU_HTML_Seg::Output.new(@md,output_seg_file,@@seg,minitoc,'idx').output @@seg[:idx]=[] elsif @@seg_name_html[tracking-1]=='metadata' - Seg_output.new(@md,output_seg_file,@@seg,minitoc,'metadata').output + SiSU_HTML_Seg::Output.new(@md,output_seg_file,@@seg,minitoc,'metadata').output else puts "#{__FILE__}::#{__LINE__}" end else puts "#{__FILE__}::#{__LINE__}" end - Seg.new.reinitialise + SiSU_HTML_Seg::Seg.new.reinitialise heading_art(dob) head(dob) #keep use for last segment, eg if metadata is last segment - #if @@seg_name_html[tracking] =~/metadata/ # this is for metadata - # segfilename="#{@md.dir_out}/#{@md.fnl[:pre]}#{@@seg_name_html[tracking]}#{@md.fnl[:mid]}#{Sfx[:html]}#{@md.fnl[:post]}" - # output_seg_file=File.new(segfilename,'w') - # Seg_output.new(@md,output_seg_file,@@seg,minitoc,'metadata').output - # Seg.new.reinitialise - #end + if @@seg_name_html[tracking] =='metadata' # this is for metadata + segfilename="#{@file.output_path.html_seg.dir}/#{@@seg_name_html[tracking]}#{@md.lang_code_insert}#{Sfx[:html]}" + output_seg_file=File.new(segfilename,'w') + SiSU_HTML_Seg::Output.new(@md,output_seg_file,@@seg,minitoc,'metadata').output + Seg.new.reinitialise + end end if tracking==0 heading_art(dob) @@ -273,8 +303,13 @@ module SiSU_HTML_seg end tracking=tracking+1 end - @@get_hash_to=dob.name if (dob.is=='heading' or dob.is=='heading_insert') and dob.ln==4 and dob.name - @@get_hash_fn=dob.name if (dob.is=='heading' or dob.is=='heading_insert') and dob.ln==4 and dob.name + if (dob.is==:heading \ + || dob.is==:heading_insert) \ + && dob.ln==4 \ + && dob.name + @@get_hash_to=dob.name + @@get_hash_fn=dob.name + end if dob.obj.class==String markup(dob) elsif dob.obj.class==Array @@ -292,19 +327,27 @@ module SiSU_HTML_seg data end def heading_art(dob) - format_head_seg=SiSU_HTML_Format::Head_seg.new(@md) - if (dob.is=='heading' or dob.is=='heading_insert') \ - and dob.ln.to_s =~/^[1-6]/ - if @@tracker < @@seg_total-1; @@seg[:dot_nav]=format_head_seg.dot_control_pre_next - else @@seg[:dot_nav]=format_head_seg.dot_control_pre + format_head_seg=SiSU_HTML_Format::HeadSeg.new(@md) + @@seg[:dot_nav]=if (@make.build.html_navigation?) \ + && (@make.build.html_navigation_bar?) + x=if (dob.is==:heading \ + || dob.is==:heading_insert) \ + && (dob.ln.to_s =~/^[1-6]/) + x=if @@tracker < @@seg_total-1 + format_head_seg.dot_control_pre_next + else + format_head_seg.dot_control_pre + end + else @@seg[:dot_nav] end + else @@seg[:dot_nav]='' end - ads=SiSU_HTML_promo::Ad.new(@md) + ads=SiSU_HTML_Promo::Ad.new(@md) @@seg[:title]=format_head_seg.head_seg << ads.div.major end def head(dob) clean=/<!.*?!>|<:.*?>/ - format_head_seg=SiSU_HTML_Format::Head_seg.new(@md) + format_head_seg=SiSU_HTML_Format::HeadSeg.new(@md) if @@tracker < @@seg_total-1 if @@tracker==0; @@segtocband=format_head_seg.toc_next2 #if format_head_seg.toc_next2 else @@segtocband=format_head_seg.toc_pre_next2 #if format_head_seg.toc_pre_next2 @@ -320,64 +363,68 @@ module SiSU_HTML_seg else '' end @@seg[:tocband_bannerless] << '<br />' << conditional_div_close << format_head_seg.navigation_band_bottom(@@segtocband,@@seg[:dot_nav]) - @@seg[:headings] << format_head_seg.seg_head_escript if SiSU_HTML_Format::Head_seg.method_defined? :seg_head_escript #debug PHP move up in text #bug + @@seg[:headings] << format_head_seg.seg_head_escript if SiSU_HTML_Format::HeadSeg.method_defined? :seg_head_escript #debug PHP move up in text #bug if @title_banner_ @@seg[:headings] << format_head_seg.title_banner(@md.title.main,@md.title.sub,@author).gsub(clean,'') end ocn=if @@heading1[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/]; $1 #fix else '' end - @p_num=SiSU_HTML_Format::Paragraph_number.new(@md,ocn) + @p_num=SiSU_HTML_Format::ParagraphNumber.new(@md,ocn) txt_obj={ txt: @@heading1, ocn_display: @p_num.ocn_display } - format_seg=SiSU_HTML_Format::Format_seg.new(@md,txt_obj) + format_seg=SiSU_HTML_Format::FormatSeg.new(@md,txt_obj) @@seg[:headings] << format_seg.title_heading1.gsub(clean,'') - @@heading1.gsub!(/ <a name="-[\d*+]+" href="#_[\d*+]+"> <sup>[\d*+]+<\/sup> <\/a>/,'') + @@heading1=@@heading1.gsub(/ <a name="-[\d*+]+" href="#_[\d*+]+"> <sup>[\d*+]+<\/sup> <\/a>/,'') end if @@is2==1 heading2=@@heading2 ocn=if heading2[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/]; $1 #fix else '' end - @p_num=SiSU_HTML_Format::Paragraph_number.new(@md,ocn) + @p_num=SiSU_HTML_Format::ParagraphNumber.new(@md,ocn) txt_obj={ txt: heading2, ocn_display: @p_num.ocn_display } - format_seg=SiSU_HTML_Format::Format_seg.new(@md,txt_obj) + format_seg=SiSU_HTML_Format::FormatSeg.new(@md,txt_obj) @@seg[:headings] << format_seg.title_heading2.gsub(clean,'') - @@heading2.gsub!(/ <a name="-[\d*+]+" href="#_[\d*+]+"> <sup>[\d*+]+<\/sup> <\/a>/,'') + @@heading2=@@heading2.gsub(/ <a name="-[\d*+]+" href="#_[\d*+]+"> <sup>[\d*+]+<\/sup> <\/a>/,'') end if @@is3==1 heading3=@@heading3 ocn=if heading3[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/]; $1 #fix else '' end - @p_num=SiSU_HTML_Format::Paragraph_number.new(@md,ocn) + @p_num=SiSU_HTML_Format::ParagraphNumber.new(@md,ocn) txt_obj={ txt: heading3, ocn_display: @p_num.ocn_display } - format_seg=SiSU_HTML_Format::Format_seg.new(@md,txt_obj) + format_seg=SiSU_HTML_Format::FormatSeg.new(@md,txt_obj) @@seg[:headings] << format_seg.title_heading3.gsub(clean,'') - @@heading3.gsub!(/ <a name="-[\d*+]+" href="#_[\d*+]+"> <sup>[\d*+]+<\/sup> <\/a>/,'') + @@heading3=@@heading3.gsub(/ <a name="-[\d*+]+" href="#_[\d*+]+"> <sup>[\d*+]+<\/sup> <\/a>/,'') end if @@is4==1 heading4=@@heading4 ocn=if heading4[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/]; $1 #fix else '' end - @p_num=SiSU_HTML_Format::Paragraph_number.new(@md,ocn) + @p_num=SiSU_HTML_Format::ParagraphNumber.new(@md,ocn) txt_obj={ txt: heading4, ocn_display: @p_num.ocn_display } - format_seg=SiSU_HTML_Format::Format_seg.new(@md,txt_obj) + format_seg=SiSU_HTML_Format::FormatSeg.new(@md,txt_obj) @@seg[:headings] << format_seg.title_heading4.gsub(clean,'') end @@tracker=@@tracker+1 end def markup(dob) @debug=[] - format_head_seg=SiSU_HTML_Format::Head_seg.new(@md) - if dob.is !~/meta/ - if dob.is =~/(?:heading|para)/ #extend as necessary FIX - @p_num=SiSU_HTML_Format::Paragraph_number.new(@md,dob.ocn) + format_head_seg=SiSU_HTML_Format::HeadSeg.new(@md) + if dob.is !=:meta + if dob.is==:heading \ + || dob.is==:heading_insert \ + || dob.is == :para + @p_num=SiSU_HTML_Format::ParagraphNumber.new(@md,dob.ocn) end - sto=SiSU_HTML_Format::Format_text_object.new(@md,dob) - dob_html=if dob.is =~/heading|para/ - dob_html=if (dob.is=='heading' \ - or dob.is=='heading_insert') + sto=SiSU_HTML_Format::FormatTextObject.new(@md,dob) + dob_html=if dob.is == :heading \ + || dob.is==:heading_insert \ + || dob.is==:para + dob_html=if dob.is==:heading \ + || dob.is==:heading_insert x=if dob.ln==4 sto.seg_heading4 elsif dob.ln==5 @@ -385,7 +432,7 @@ module SiSU_HTML_seg elsif dob.ln==6 sto.seg_heading6 end - elsif dob.is=='para' + elsif dob.is==:para if dob.indent \ and dob.hang \ and dob.indent =~/[0-9]/ \ @@ -405,49 +452,55 @@ module SiSU_HTML_seg else sto.para end end - elsif dob.is=='block' + elsif dob.is==:block sto.block - elsif dob.is=='group' + elsif dob.is==:group sto.group - elsif dob.is=='alt' + elsif dob.is==:alt sto.alt - elsif dob.is=='verse' + elsif dob.is==:verse sto.verse - elsif dob.is=='code' + elsif dob.is==:code sto.code - elsif dob.is=='table' + elsif dob.is==:table sto.table - elsif dob.is=='break' + elsif dob.is==:break sto.break end if @md.flag_separate_endnotes - dob.obj.gsub!(/"\s+href="#_(\d+)">/,%{" href=\"endnotes#{Sfx[:html]}#_\\1">}) #endnote- twice #removed file type + dob.obj=dob.obj.gsub(/"\s+href="#_(\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|para/ and (not dob.ocn or dob.ocn.to_s.empty?) - format_seg=SiSU_HTML_Format::Format_seg.new(@md,dob) + if (dob.is==:heading \ + || dob.is==:heading_insert \ + || dob.is==:para) \ + && (not dob.ocn \ + || (dob.ocn.to_s.empty?)) + format_seg=SiSU_HTML_Format::FormatSeg.new(@md,dob) end - dob.obj.gsub!(/\s*(-\{{2}~\d+|<:e[:_]\d+>).*/,'') #potentially dagerous - removes all paragraphs with <!e_!> #?? workpoint + dob.obj=dob.obj.gsub(/\s*(-\{{2}~\d+|<:e[:_]\d+>).*/,'') #potentially dagerous - removes all paragraphs with <!e_!> #?? workpoint if dob.obj =~/<a name="_\d+" href="#-\d+"> <sup>/ #endnote- note- - format_seg=SiSU_HTML_Format::Format_seg.new(@md,dob) + format_seg=SiSU_HTML_Format::FormatSeg.new(@md,dob) dob=format_seg.no_paranum end end - if (dob.is=='heading' \ - || dob.is=='heading_insert') \ - and dob.ln==4 - @@seg[:main] << %{\n<div class="content">\n} + if (dob.is==:heading \ + || dob.is==:heading_insert) \ + && dob.ln==4 + @@seg[:main] << %{\n<div class="#{@cl}">\n} @@seg[:main] << dob_html - @@seg[:main] << @@seg_subtoc[@@get_hash_fn] #% insertion of sub-toc + if @make.build.segsubtoc? + @@seg[:main] << @@seg_subtoc[@@get_hash_fn] #% insertion of sub-toc + end else @@seg[:main] << dob_html #unless @@flag_alt==true end end end def tail - format_head_seg=SiSU_HTML_Format::Head_seg.new(@md) + format_head_seg=SiSU_HTML_Format::HeadSeg.new(@md) if @md.flag_auto_endnotes and @@seg_endnotes[@@get_hash_fn] - @@seg[:tail] << %{\n<div class="content">\n<div class="endnote">\n} + @@seg[:tail] << %{\n<div class="#{@cl}">\n<div class="endnote">\n} if @@seg_endnotes[@@get_hash_fn].flatten.length > 0 @@seg[:tail] << format_head_seg.endnote_mark @@seg[:tail] << @@seg_endnotes[@@get_hash_fn].flatten #endnotes deposited at end of individual segments ||@|EXTRACTION OF ENDNOTES| @@ -455,7 +508,7 @@ module SiSU_HTML_seg @@seg[:tail] << '</div>' @@seg[:tail] << '</div>' #this div closes div class content end - ads=SiSU_HTML_promo::Ad.new(@md) + 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 reinitialise @@ -471,18 +524,20 @@ module SiSU_HTML_seg end def get_subtoc_endnotes(data) #get endnotes & sub-table of contents subtoc data.each do |dob| - dob.obj.gsub!(/<a name=\"h\d.*?\">(.+?)<\/a>/mi,'\1') + dob.obj=dob.obj.gsub(/<a name=\"h\d.*?\">(.+?)<\/a>/mi,'\1') if @md.flag_auto_endnotes - if (dob.is=='heading' or dob.is=='heading_insert') \ - and dob.ln.to_s =~/^[1234]/ \ + if (dob.is==:heading \ + || dob.is==:heading_insert) \ + && (dob.ln.to_s =~/^[1234]/) \ and not @@fn.to_s.empty? @@seg_endnotes[@@fn]=[] @@seg_endnotes[@@fn] << @@seg_endnotes_array @@seg_endnotes_array=[] if dob.ln==4 @@fns_previous=@md.fns if dob.ln==4 and dob.name =~/^meta/ end - if (dob.is=='heading' or dob.is=='heading_insert') \ - and dob.ln==4 #% EXTRACTION OF SUB-TOCs & SEGMENT NAME, after EXTRACTION OF ENDNOTES & SUB-TOCs + if (dob.is==:heading \ + || dob.is==:heading_insert) \ + && dob.ln==4 #% EXTRACTION OF SUB-TOCs & SEGMENT NAME, after EXTRACTION OF ENDNOTES & SUB-TOCs @@seg_subtoc[@@fn]=@@seg_subtoc_array @@seg_subtoc_array=[] if dob.name \ @@ -496,23 +551,23 @@ module SiSU_HTML_seg end end end - if dob.is=='heading' \ - and dob.ln.to_s =~/^[56]/ + if dob.is==:heading \ + && (dob.ln.to_s =~/^[56]/) case dob.ln when 5 txt_obj={ txt: dob.obj.strip, ocn: dob.ocn } - format_seg=SiSU_HTML_Format::Format_seg.new(@md,txt_obj) + format_seg=SiSU_HTML_Format::FormatSeg.new(@md,txt_obj) subtoc=format_seg.subtoc_lev5 #keep and make available, this is the subtoc when 6 txt_obj={ txt: dob.obj.strip, ocn: dob.ocn } - format_seg=SiSU_HTML_Format::Format_seg.new(@md,txt_obj) + format_seg=SiSU_HTML_Format::FormatSeg.new(@md,txt_obj) subtoc=format_seg.subtoc_lev6 #keep and make available, this is the subtoc end @@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*+]+"/ \ - and dob.is !~/^code/ # endnote- + if (dob.obj =~/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]})[\d*+]+ <a name="_[\d*+]+"/) \ + && dob.is !=:code # endnote- endnote_array=[] if dob.obj=~/#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}/m endnote_array << dob.obj.scan(/#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}/m) @@ -523,7 +578,7 @@ module SiSU_HTML_seg if dob.obj=~/#{Mx[:en_b_o]}[+]\d+\s.+?#{Mx[:en_b_c]}/m endnote_array << dob.obj.scan(/#{Mx[:en_b_o]}[+]\d+\s.+?#{Mx[:en_b_c]}/m) end - endnote_array.flatten!.compact! #check compacting + endnote_array=endnote_array.flatten.compact #watch, check compacting endnote_array.each do |note| note_match=note.dup note_match_seg=note.dup @@ -531,7 +586,7 @@ module SiSU_HTML_seg try=e_n.split(/<br \/>/) try.each do |e| txt_obj={ txt: e } - format_seg=SiSU_HTML_Format::Format_seg.new(@md,txt_obj) + format_seg=SiSU_HTML_Format::FormatSeg.new(@md,txt_obj) note_match=if e =~/#{Mx[:pa_o]}i[1-9]#{Mx[:pa_c]}/ format_seg.endnote_body_indent else format_seg.endnote_body @@ -544,11 +599,11 @@ module SiSU_HTML_seg 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 } - format_seg=SiSU_HTML_Format::Format_seg.new(@md,txt_obj) + format_seg=SiSU_HTML_Format::FormatSeg.new(@md,txt_obj) note_match_all_seg=format_seg.endnote_seg_body(@@fn) #BUG WATCH 200408 @@seg[:endnote_all] << note_match_all_seg end - dob.obj.gsub!(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ') + dob.obj=dob.obj.gsub(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ') end end end diff --git a/lib/sisu/v3/html_table.rb b/lib/sisu/v3/html_table.rb index ca944dea..87a4c4b6 100644 --- a/lib/sisu/v3/html_table.rb +++ b/lib/sisu/v3/html_table.rb @@ -56,10 +56,10 @@ ** Description: shared html parts =end -module SiSU_HTML_table +module SiSU_HTML_Table require_relative 'defaults' # defaults.rb require_relative 'xhtml_table.rb' # xhtml_table.rb - class Table_html <SiSU_XHTML_table::Table_xhtml + class TableHTML <SiSU_XHTML_Table::TableXHTML end end __END__ diff --git a/lib/sisu/v3/html_tune.rb b/lib/sisu/v3/html_tune.rb index e8c12d6a..e4ac08ee 100644 --- a/lib/sisu/v3/html_tune.rb +++ b/lib/sisu/v3/html_tune.rb @@ -76,7 +76,7 @@ module SiSU_HTML_Tune class Output def initialize(data,md) @data,@md=data,md - @file=SiSU_Env::Info_file.new(@md.fns) + @file=SiSU_Env::InfoFile.new(@md.fns) @cX=SiSU_Screen::Ansi.new(@md.opt.cmd).cX end def hard_output @@ -84,7 +84,7 @@ module SiSU_HTML_Tune data=[] @data.each do |x| unless x.obj.empty? - x.obj.strip! + x.obj=x.obj.strip data << x end end @@ -96,7 +96,7 @@ module SiSU_HTML_Tune File.open(@file.marshal.html_tune,'w') {|f| Marshal.dump(@data.to_a,f)} end end - class Clean_html + class CleanHTML def initialize(html='') @html=html end @@ -106,103 +106,102 @@ module SiSU_HTML_Tune html else html.obj end - str.gsub!(/#{Mx[:gl_o]}(#[0-9]{3})#{Mx[:gl_c]}/u,'&\1;') - str.gsub!(/#{Mx[:gl_o]}#([a-z]{2,4})#{Mx[:gl_c]}/u,'&\1;') - str.gsub!(/¢/u,'¢') # ¢ - str.gsub!(/£/u,'£') # £ - str.gsub!(/¥/u,'¥') # ¥ - str.gsub!(/§/u,'§') # § - str.gsub!(/©/u,'©') # © - str.gsub!(/ª/u,'ª') # ª - str.gsub!(/«/u,'«') # « - str.gsub!(/®/u,'®') # ® - str.gsub!(/°/u,'°') # ° - str.gsub!(/±/u,'±') # ± - str.gsub!(/²/u,'²') # ² - str.gsub!(/³/u,'³') # ³ - str.gsub!(/µ/u,'µ') # µ - str.gsub!(/¶/u,'¶') # ¶ - str.gsub!(/¹/u,'¹') # ¹ - str.gsub!(/º/u,'º') # º - str.gsub!(/»/u,'»') # » - str.gsub!(/¼/u,'¼') # ¼ - str.gsub!(/½/u,'½') # ½ - str.gsub!(/¾/u,'¾') # ¾ - str.gsub!(/×/u,'×') # × - str.gsub!(/÷/u,'÷') # ÷ - str.gsub!(/¿/u,'¿') # ¿ - str.gsub!(/À/u,'À') # À - str.gsub!(/Á/u,'Á') # Á - str.gsub!(/Â/u,'Â') #  - str.gsub!(/Ã/u,'Ã') # à - str.gsub!(/Ä/u,'Ä') # Ä - str.gsub!(/Å/u,'Å') # Å - str.gsub!(/Æ/u,'Æ') # Æ - str.gsub!(/Ç/u,'Ç') # Ç - str.gsub!(/È/u,'È') # È - str.gsub!(/É/u,'É') # É - str.gsub!(/Ê/u,'Ê') # Ê - str.gsub!(/Ë/u,'Ë') # Ë - str.gsub!(/Ì/u,'Ì') # Ì - str.gsub!(/Í/u,'Í') # Í - str.gsub!(/Î/u,'Î') # Î - str.gsub!(/Ï/u,'Ï') # Ï - str.gsub!(/Ð/u,'Ð') # Ð - str.gsub!(/Ñ/u,'Ñ') # Ñ - str.gsub!(/Ò/u,'Ò') # Ò - str.gsub!(/Ó/u,'Ó') # Ó - str.gsub!(/Ô/u,'Ô') # Ô - str.gsub!(/Õ/u,'Õ') # Õ - str.gsub!(/Ö/u,'Ö') # Ö - str.gsub!(/Ø/u,'Ø') # Ø - str.gsub!(/Ù/u,'Ù') # Ù - str.gsub!(/Ú/u,'Ú') # Ú - str.gsub!(/Û/u,'Û') # Û - str.gsub!(/Ü/u,'Ü') # Ü - str.gsub!(/Ý/u,'Ý') # Ý - str.gsub!(/Þ/u,'Þ') # Þ - str.gsub!(/ß/u,'ß') # ß - str.gsub!(/à/u,'à') # à - str.gsub!(/á/u,'á') # á - str.gsub!(/â/u,'â') # â - str.gsub!(/ã/u,'ã') # ã - str.gsub!(/ä/u,'ä') # ä - str.gsub!(/å/u,'å') # å - str.gsub!(/æ/u,'æ') # æ - str.gsub!(/ç/u,'ç') # ç - str.gsub!(/è/u,'è') # è - str.gsub!(/é/u,'é') # é - str.gsub!(/ê/u,'ê') # ê - str.gsub!(/ë/u,'ë') # ë - str.gsub!(/ì/u,'ì') # ì - str.gsub!(/í/u,'í') # í - str.gsub!(/î/u,'î') # î - str.gsub!(/ï/u,'ï') # ï - str.gsub!(/ð/u,'ð') # ð - str.gsub!(/ñ/u,'ñ') # ñ - str.gsub!(/ò/u,'ò') # ò - str.gsub!(/ó/u,'ó') # ó - str.gsub!(/ô/u,'ô') # ô - str.gsub!(/õ/u,'õ') # õ - str.gsub!(/ö/u,'ö') # ö - str.gsub!(/ø/u,'ø') # ø - str.gsub!(/ù/u,'ù') # ú - str.gsub!(/ú/u,'ú') # û - str.gsub!(/û/u,'û') # ü - str.gsub!(/ü/u,'ü') # ý - str.gsub!(/þ/u,'þ') # þ - str.gsub!(/ÿ/u,'ÿ') # ÿ - str.gsub!(/ý/u,'ý') - str + 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(/¢/u,'¢'). # ¢ + gsub(/£/u,'£'). # £ + gsub(/¥/u,'¥'). # ¥ + gsub(/§/u,'§'). # § + gsub(/©/u,'©'). # © + gsub(/ª/u,'ª'). # ª + gsub(/«/u,'«'). # « + gsub(/®/u,'®'). # ® + gsub(/°/u,'°'). # ° + gsub(/±/u,'±'). # ± + gsub(/²/u,'²'). # ² + gsub(/³/u,'³'). # ³ + gsub(/µ/u,'µ'). # µ + gsub(/¶/u,'¶'). # ¶ + gsub(/¹/u,'¹'). # ¹ + gsub(/º/u,'º'). # º + gsub(/»/u,'»'). # » + gsub(/¼/u,'¼'). # ¼ + gsub(/½/u,'½'). # ½ + gsub(/¾/u,'¾'). # ¾ + gsub(/×/u,'×'). # × + gsub(/÷/u,'÷'). # ÷ + gsub(/¿/u,'¿'). # ¿ + gsub(/À/u,'À'). # À + gsub(/Á/u,'Á'). # Á + gsub(/Â/u,'Â'). #  + gsub(/Ã/u,'Ã'). # à + gsub(/Ä/u,'Ä'). # Ä + gsub(/Å/u,'Å'). # Å + gsub(/Æ/u,'Æ'). # Æ + gsub(/Ç/u,'Ç'). # Ç + gsub(/È/u,'È'). # È + gsub(/É/u,'É'). # É + gsub(/Ê/u,'Ê'). # Ê + gsub(/Ë/u,'Ë'). # Ë + gsub(/Ì/u,'Ì'). # Ì + gsub(/Í/u,'Í'). # Í + gsub(/Î/u,'Î'). # Î + gsub(/Ï/u,'Ï'). # Ï + gsub(/Ð/u,'Ð'). # Ð + gsub(/Ñ/u,'Ñ'). # Ñ + gsub(/Ò/u,'Ò'). # Ò + gsub(/Ó/u,'Ó'). # Ó + gsub(/Ô/u,'Ô'). # Ô + gsub(/Õ/u,'Õ'). # Õ + gsub(/Ö/u,'Ö'). # Ö + gsub(/Ø/u,'Ø'). # Ø + gsub(/Ù/u,'Ù'). # Ù + gsub(/Ú/u,'Ú'). # Ú + gsub(/Û/u,'Û'). # Û + gsub(/Ü/u,'Ü'). # Ü + gsub(/Ý/u,'Ý'). # Ý + gsub(/Þ/u,'Þ'). # Þ + gsub(/ß/u,'ß'). # ß + gsub(/à/u,'à'). # à + gsub(/á/u,'á'). # á + gsub(/â/u,'â'). # â + gsub(/ã/u,'ã'). # ã + gsub(/ä/u,'ä'). # ä + gsub(/å/u,'å'). # å + gsub(/æ/u,'æ'). # æ + gsub(/ç/u,'ç'). # ç + gsub(/è/u,'è'). # è + gsub(/é/u,'é'). # é + gsub(/ê/u,'ê'). # ê + gsub(/ë/u,'ë'). # ë + gsub(/ì/u,'ì'). # ì + gsub(/í/u,'í'). # í + gsub(/î/u,'î'). # î + gsub(/ï/u,'ï'). # ï + gsub(/ð/u,'ð'). # ð + gsub(/ñ/u,'ñ'). # ñ + gsub(/ò/u,'ò'). # ò + gsub(/ó/u,'ó'). # ó + gsub(/ô/u,'ô'). # ô + gsub(/õ/u,'õ'). # õ + gsub(/ö/u,'ö'). # ö + gsub(/ø/u,'ø'). # ø + gsub(/ù/u,'ù'). # ú + gsub(/ú/u,'ú'). # û + gsub(/û/u,'û'). # ü + gsub(/ü/u,'ü'). # ý + gsub(/þ/u,'þ'). # þ + gsub(/ÿ/u,'ÿ'). # ÿ + gsub(/ý/u,'ý') end end class Tune def initialize(data,md) @data,@md=data,md - @vz=SiSU_Env::Get_init.instance.skin - @env=SiSU_Env::Info_env.new(@md.fns) - @sys=SiSU_Env::System_call.new - @env=SiSU_Env::Info_env.new(@md.fns) + @vz=SiSU_Env::GetInit.instance.skin + @env=SiSU_Env::InfoEnv.new(@md.fns) + @sys=SiSU_Env::SystemCall.new + @env=SiSU_Env::InfoEnv.new(@md.fns) @brace_url=SiSU_Viz::Skin.new.url_decoration end def songsheet @@ -212,11 +211,11 @@ module SiSU_HTML_Tune songsheet_array(@data) #data=songsheet_array(@data) if @md.opt.cmd =~/M/ #Hard Output Tune Optional on/off here - data=Output.new(@data,@md).hard_output - Output.new(@data,@md).marshal + data=SiSU_HTML_Tune::Output.new(@data,@md).hard_output + SiSU_HTML_Tune::Output.new(@data,@md).marshal end - tuned=Tune.new(@data,@md).output - rescue; SiSU_Errors::Info_error.new($!,$@,@md.opt.cmd,@md.fns).error + tuned=SiSU_HTML_Tune::Tune.new(@data,@md).output + rescue; SiSU_Errors::InfoError.new($!,$@,@md.opt.cmd,@md.fns).error ensure end end @@ -266,15 +265,15 @@ module SiSU_HTML_Tune %{<a href="#{u}"><img src="#{image_path}/#{png}" #{w} #{h} naturalsizeflag="0" align="bottom" border="0"></a>#{caption}} else %{<img src="#{image_path}/#{png}" #{w} #{h} naturalsizeflag="0" align="bottom" border="0">#{caption}} end - word.gsub!(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/,ins) + word=word.gsub(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/,ins) else link=m[/(.+)/m] png=m.scan(/\S+/)[0].strip link=link.strip - u.gsub!(/(\S+)/,"#{Xx[:segment]}#\\1") if u !~/\// unless http_ #marker: in scroll remove; in seg replace + u=u.gsub(/(\S+)/,"#{Xx[:segment]}#\\1") if u !~/\// unless http_ #marker: in scroll remove; in seg replace ins=%{<a href="#{u}">#{link}</a>} - word.gsub!(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/,ins) - word.gsub!(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/,ins) + word=word.gsub(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/,ins). + gsub(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/,ins) end word else word @@ -284,95 +283,86 @@ module SiSU_HTML_Tune @words=@words.join(' ') end def url_markup(dob) - unless dob.is=='code' + unless dob.is==:code if dob.obj =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}|image)/ @word_mode=dob.obj.scan(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}|image)[()\[\]]*[,.;:!?'"]{0,2}|(?:#{Mx[:gl_o]}\S+?#{Mx[:gl_c]})+|[^#{Mx[:lnk_o]}#{Mx[:lnk_c]}]+/mu) words=urls(@word_mode) - dob.obj.gsub!(/.+/m,words) + dob.obj=dob.obj.gsub(/.+/m,words) end #consider change, do a while loop - dob.obj.gsub!(/\\copyright/i,%{<sup>©</sup>}) + dob.obj=dob.obj.gsub(/\\copyright/i,%{<sup>©</sup>}) if (dob.obj !~/\<:ad\s+\.\.\//) - dob.obj.gsub!(/\<:ad\s+(\S+)?\s+(\S+\.png)\s+(.+)?\;\s+(.+)?\;\s*!\>/, + dob.obj=dob.obj.gsub(/\<:ad\s+(\S+)?\s+(\S+\.png)\s+(.+)?\;\s+(.+)?\;\s*!\>/, %{\n<center><a href="http:\/\/\\1" target="external"><img src="#{@env.url.images_local}/\\2" alt="\\3"></a></center>\n}) else - dob.obj.gsub!(/\<:ad\s+(\S+)?\s+(\S+\.png)\s+(.+)?\;\s+(.+)?\;\s*\>/, + dob.obj=dob.obj.gsub(/\<:ad\s+(\S+)?\s+(\S+\.png)\s+(.+)?\;\s+(.+)?\;\s*\>/, %{\n<center><a href="\\1" target="_top"><img src="#{@env.url.images_local}/\\2" alt="\\3"></a></center>\n}) end - dob.obj.gsub!(/!pick/,%{<img border="0" height="15" width="15" src="#{@env.url.images}/#{@vz.icon_choice}" alt="stellar">}) - dob.obj.gsub!(/!new/,%{ <img border="0" height="15" width="15" src="#{@env.url.images}/#{@vz.icon_new}" alt="new">}) - dob.obj.gsub!(/<:h(.{1,7}?)>/,'<a href="#h\1">\1</a>') - dob.obj.gsub!(/<:to(\d{1,7}?)>/,'<a href="#to\1">to { \1 }</a> ') - dob.obj.gsub!(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'<a href="\1" target="_top">\1</a>') #http ftp matches escaped, no decoration - dob.obj.gsub!(/#{Mx[:url_o]}([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)#{Mx[:url_c]}/,%{#{@brace_url.xml_open}<a href="mailto:\\1">\\1</a>#{@brace_url.xml_close}}) - dob.obj.gsub!(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,%{#{@brace_url.xml_open}<a href="\\1" target="_top">\\1</a>#{@brace_url.xml_close}}) #http ftp matches with decoration + dob.obj=dob.obj.gsub(/!pick/,%{<img border="0" height="15" width="15" src="#{@env.url.images}/#{@vz.icon_choice}" alt="stellar">}). + gsub(/!new/,%{ <img border="0" height="15" width="15" src="#{@env.url.images}/#{@vz.icon_new}" alt="new">}). + gsub(/<:h(.{1,7}?)>/,'<a href="#h\1">\1</a>'). + gsub(/<:to(\d{1,7}?)>/,'<a href="#to\1">to { \1 }</a> '). + gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'<a href="\1" target="_top">\1</a>'). #http ftp matches escaped, no decoration + gsub(/#{Mx[:url_o]}([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)#{Mx[:url_c]}/,%{#{@brace_url.xml_open}<a href="mailto:\\1">\\1</a>#{@brace_url.xml_close}}). + gsub(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,%{#{@brace_url.xml_open}<a href="\\1" target="_top">\\1</a>#{@brace_url.xml_close}}) #http ftp matches with decoration if dob.obj =~/#{Xx[:html_relative2]}\/\S+/ \ and dob.obj !~/(\"#{Xx[:html_relative2]}\/\S+?\"|>\s*#{Xx[:html_relative2]}\/\S+<)/ - dob.obj.gsub!(/(#{Xx[:html_relative2]}\/\S+)/,'<a href="\1">\1</a>') + dob.obj=dob.obj.gsub(/(#{Xx[:html_relative2]}\/\S+)/,'<a href="\1">\1</a>') end if dob.obj =~/..\/\S+/ \ and dob.obj !~/(\"..\/\S+?\"|>\s*..\/\S+<)/ - dob.obj.gsub!(/\.\.(\/\S+)/,%{<a href="#{Xx[:html_relative2]}\1">\1</a>}) + dob.obj=dob.obj.gsub(/\.\.(\/\S+)/,%{<a href="#{Xx[:html_relative2]}\1">\1</a>}) end - dob.obj.gsub!(/<a href=":/,%{<a href="#{@vz.url_site}/}) - dob.obj.gsub!(/<a href="\.\.\//,%{<a href="#{@vz.url_site}/}) - dob.obj.gsub!(/<a href="#{Xx[:html_relative2]}\//,%{<a href="#{@vz.url_site}/}) + dob.obj=dob.obj.gsub(/<a href=":/,%{<a href="#{@vz.url_site}/}). + gsub(/<a href="\.\.\//,%{<a href="#{@vz.url_site}/}). + gsub(/<a href="#{Xx[:html_relative2]}\//,%{<a href="#{@vz.url_site}/}) else - dob.obj.gsub!(/</m,'<'); dob.obj.gsub!(/>/m,'>') + dob.obj=dob.obj.gsub(/</m,'<').gsub(/>/m,'>') end dob end - def para_numbers - data=@data - @tuned_file=[] - data.each do |dob| - dob.gsub!(/#{Mx[:lv_o]}\d:(\S?)#{Mx[:lv_c]}/,'\0<a name="H#\1">#\1.</a> ') #fix Mx[:lv_o] - @tuned_file << dob - end - end def angle_brackets(dob) - dob.obj.gsub!(/<([a-z:\/]+)>/,"#{Dx[:lt_xml]}\\1#{Dx[:gt_xml]}") + dob.obj=dob.obj.gsub(/<([a-z:\/]+)>/,"#{Dx[:lt_xml]}\\1#{Dx[:gt_xml]}") dob end def endnotes_html(dob) - unless dob.is =~/^code/ - 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) - dob.obj.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) - dob.obj.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) + 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) + 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) + 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) end dob end def markup(dob) - dob.obj.gsub!(/#{Mx[:mk_o]}#([a-zA-Z]+)#{Mx[:mk_c]}/,'&\1;') - dob.obj.gsub!(/#{Mx[:mk_o]}(#[0-9]+)#{Mx[:mk_c]}/,'&\1;') - dob.obj.gsub!(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,'<br />') unless dob.is=='table' - dob.obj.gsub!(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'<b>\1</b>') - dob.obj.gsub!(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'<i>\1</i>') - dob.obj.gsub!(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'<u>\1</u>') - dob.obj.gsub!(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,'<sup>\1</sup>') - dob.obj.gsub!(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,'<sub>\1</sub>') - dob.obj.gsub!(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'<ins>\1</ins>') - dob.obj.gsub!(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'<cite>\1</cite>') - dob.obj.gsub!(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'<del>\1</del>') - dob.obj.gsub!(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/,'<tt>\1</tt>') # tt, kbd - dob.obj.gsub!(/#{Mx[:mk_o]}:name#(\S+?)#{Mx[:mk_c]}/,'<a name="\1"></a>') - dob.obj.gsub!(/^#{Mx[:gl_bullet]}/m,'● ') - dob.obj.gsub!(/#{Mx[:nbsp]}/,' ') - dob.obj.gsub!(/<(p|br)>/,'<\1 />') - dob=SiSU_HTML_Tune::Clean_html.new(dob).clean + dob.obj=dob.obj.gsub(/#{Mx[:mk_o]}#([a-zA-Z]+)#{Mx[:mk_c]}/,'&\1;'). + gsub(/#{Mx[:mk_o]}(#[0-9]+)#{Mx[:mk_c]}/,'&\1;') + dob.obj=dob.obj.gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,'<br />') unless dob.is==:table + dob.obj=dob.obj.gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'<b>\1</b>'). + gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'<i>\1</i>'). + gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'<u>\1</u>'). + gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,'<sup>\1</sup>'). + gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,'<sub>\1</sub>'). + gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'<ins>\1</ins>'). + gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'<cite>\1</cite>'). + gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'<del>\1</del>'). + gsub(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/,'<tt>\1</tt>'). # tt, kbd + gsub(/#{Mx[:mk_o]}:name#(\S+?)#{Mx[:mk_c]}/,'<a name="\1"></a>'). + gsub(/^#{Mx[:gl_bullet]}/m,'● '). + gsub(/#{Mx[:nbsp]}/,' '). + gsub(/<(p|br)>/,'<\1 />') + dob=SiSU_HTML_Tune::CleanHTML.new(dob).clean dob end def output data=@data @tuned_file=[] data.each do |dob| - dob.obj.strip! - dob.obj.chomp! + dob.obj=dob.obj.strip.chomp @tuned_file << dob end @tuned_file << "\n<EOF>" if (@md.fns =~/\.sst0/) #remove diff --git a/lib/sisu/v3/hub.rb b/lib/sisu/v3/hub.rb index 149a5727..5f256314 100644 --- a/lib/sisu/v3/hub.rb +++ b/lib/sisu/v3/hub.rb @@ -63,7 +63,7 @@ module SiSU include SiSU_Screen @@pwd_the=Dir.pwd class Op - @@env=SiSU_Env::Info_env.new + @@env=SiSU_Env::InfoEnv.new def initialize(opt,req,message) @opt,@req,@message=opt,req,message @n_do=0 @@ -129,11 +129,11 @@ module SiSU end if not @opt.files.empty? @opt.files.each_with_index do |fns,i| - env=SiSU_Env::Info_env.new(fns) + env=SiSU_Env::InfoEnv.new(fns) if fns =~ /sisupod(?:\.txz)?|\S+?(?:\.ss[mt]\.txz|\.ssp)$/ require_relative 'remote' # remote.rb #check pod_name=if fns =~ /http:\/\/\S+?(?:\.ss[mt]\.txz|\.ssp)$/ - SiSU_Remote::Remote_download.new(fns).pod.name + SiSU_Remote::RemoteDownload.new(fns).pod.name else re_p=/(\S+?\.ss[mt](?:\.txz)?)$/ re_p.match(fns).captures.join @@ -145,7 +145,7 @@ module SiSU elsif fns =~ /sisupod(?:\.zip)?|\S+?(?:\.ss[mt]\.zip|\.ssp)$/ require_relative 'remote' # remote.rb #check pod_name=if fns =~ /http:\/\/\S+?(?:\.ss[mt]\.zip|\.ssp)$/ - SiSU_Remote::Remote_download.new(fns).pod.name + SiSU_Remote::RemoteDownload.new(fns).pod.name else re_p=/(\S+?\.ss[mt](?:\.zip)?)$/ re_p.match(fns).captures.join @@ -171,12 +171,12 @@ module SiSU @@pwd=@opt.pth end Dir.chdir(@opt.pth) #watch - env=SiSU_Env::Info_env.new(fns) + env=SiSU_Env::InfoEnv.new(fns) if @req !~/(?:urls|remote)$/ if @opt.cmd.inspect =~/-P/\ and @req =~ /^po4a$/ require_relative 'composite' # composite.rb #pre-processing - SiSU_po4a::Source.new(@opt).read # -P po4a.rb + SiSU_Po4a::Source.new(@opt).read # -P po4a.rb elsif @req=~/^dal$/ \ and FileTest.file?(@opt.fns) \ and @opt.fns =~ /\.(?:(?:-|ssm\.)?sst|ssm)$/ @@ -201,14 +201,14 @@ module SiSU when /^concordance$/; SiSU_Concordance::Source.new(@opt).read # -w concordance.rb when /^share_src$/; SiSU_Markup::Source.new(@opt).read # -s share_src.rb when /^sisupod_make$/; SiSU_Doc::Source.new(@opt).read # -S sisupod_make.rb -# when /^source_kdissert$/; SiSU_Kdi_source::Source.new(@opt).read # -S share_src_kdissert.rb - when /^digests$/; SiSU_Digest_view::Source.new(@opt).read # -N digests.rb +# when /^source_kdissert$/; SiSU_KdiSource::Source.new(@opt).read # -S share_src_kdissert.rb + when /^digests$/; SiSU_DigestView::Source.new(@opt).read # -N digests.rb when /^plaintext$/; SiSU_Plaintext::Source.new(@opt).read # -t -a plaintext.rb - when /^po4a$/; SiSU_po4a::Source.new(@opt).read # -P po4a.rb + when /^po4a$/; SiSU_Po4a::Source.new(@opt).read # -P po4a.rb #when /^wikispeak$/; SiSU_Wikispeak::Source.new(@opt).read # -g when /^epub$/; SiSU_EPUB::Source.new(@opt).read # -e epub.rb when /^odf$/; SiSU_ODF::Source.new(@opt).read # -o odf.rb - when /^xml_md_oai_pmh_dc$/; SiSU_XML_metadata::OAI_PMH.new(@opt).read # -O + when /^xml_md_oai_pmh_dc$/; SiSU_XML_Metadata::OAI_PMH.new(@opt).read # -O when /^texpdf$/; SiSU_TeX::Source.new(@opt).read # -p texpdf.rb when /^manpage$/; SiSU_Manpage::Source.new(@opt).read # -i manpage.rb when /^texinfo$/; SiSU_TexInfo::Source.new(@opt).read # -I texinfo.rb @@ -216,14 +216,16 @@ module SiSU when /^xhtml$/; SiSU_XHTML::Source.new(@opt).read # -b xhtml.rb when /^xml$/; SiSU_XML_SAX::Source.new(@opt).read # -x xml.rb when /^xml_dom$/; SiSU_XML_DOM::Source.new(@opt).read # -X xml_dom.rb + when /^shared_images$/; SiSU_Images::Source.new(@opt).read # -j shared_images.rb #when /^xml_fictionbook$/; SiSU_XML_Fictionbook::Source.new(@opt).read # -f - when /^xml_scaffold$/; SiSU_XML_scaffold::Source.new(@opt).read # -k xml_scaffold.rb + when /^xml_scaffold$/; SiSU_XML_Scaffold::Source.new(@opt).read # -k xml_scaffold.rb when /^embedded$/; SiSU_Embedded::Source.new(@opt).read # -m embedded.rb (image and other content) #check when /^manifest$/; SiSU_Manifest::Source.new(@opt).read # -y manifest.rb when /^qrcode$/; SiSU_QRcode::Source.new(@opt).read # -Q qrcode.rb when /^sitemaps$/; SiSU_Sitemaps::Source.new(@opt).read # -Y sitemaps.rb when /^zap$/; SiSU_Zap::Source.new(@opt).read # -Z zap.rb - when /^dbi$/; SiSU_DBI::SiSU_SQL.new(@opt).connect # -D -d dbi.rb + when /^dbi$/; SiSU_DBI::SQL.new(@opt).connect # -D -d dbi.rb + when /^dbi_discreet$/; SiSU_DBI_Discreet::SQL.new(@opt).build # -d dbi_discreet.rb end @n_do=@n_do+1 SiSU_Screen::Ansi.new(@opt.cmd,@n_do,"#{@req.upcase} processed").files_processed if @opt.cmd =~/[MVv]/ @@ -233,13 +235,13 @@ module SiSU else if @req !~/^conf$/ \ and @opt.fns !~/http:\/\// - Operations.new(@opt).not_found + SiSU::Operations.new(@opt).not_found end end elsif FileTest.file?(put) if @opt.mod.inspect !~/harvest/ #decide whether should permit harvest in single operation case @req - when /^urls$/; SiSU_urls::Source.new(@opt).read # -u -v -V -M + when /^urls$/; SiSU_Urls::Source.new(@opt).read # -u -v -V -M when /^remote$/ case @message when /scp/; SiSU_Remote::Put.new(@opt).scp # -r @@ -250,14 +252,14 @@ module SiSU @n_do=@n_do+1 SiSU_Screen::Ansi.new(@opt.cmd,@n_do,"#{@req.upcase} processed").files_processed if @opt.cmd =~/[MVv]/ end - else Operations.new(@opt).not_found + else SiSU::Operations.new(@opt).not_found end end end - elsif @req =~/^dbi$/; SiSU_DBI::SiSU_SQL.new(@opt).connect # -D -d + elsif @req =~/^dbi$/; SiSU_DBI::SQL.new(@opt).connect # -D -d elsif @req=~/^sisupod_make$/; SiSU_Doc::Source.new(@opt).read # -S end - Operations.new.counter + SiSU::Operations.new.counter end end class Operations @@ -291,11 +293,11 @@ p "here #{__FILE__} #{__LINE__}" if @opt =~/M/ end def cgi # -F require_relative 'cgi' # cgi.rb - SiSU_CGI::SiSU_search.new(@opt).read + SiSU_CGI::SearchSQL.new(@opt).read end def encoding # -K build character encoding db (uses KirbyBase) require_relative 'character_encoding' # character_encoding.rb - SiSU_character_encode::Create.new.db + SiSU_CharacterEncode::Create.new.db end def termsheet # -t system("sisu_termsheet #{@opt.cmd} #{@opt.fns}\n") @@ -338,7 +340,7 @@ p "here #{__FILE__} #{__LINE__}" if @opt =~/M/ class Processing require 'fileutils' include FileUtils - @@env=SiSU_Env::Info_env.new + @@env=SiSU_Env::InfoEnv.new attr_accessor :op def initialize(opt) @opt=opt @@ -346,7 +348,7 @@ p "here #{__FILE__} #{__LINE__}" if @opt =~/M/ @tell=lambda { SiSU_Screen::Ansi.new(@opt.cmd,@msg,"#{@msgs.inspect if @msgs}") } end def op(req,msg) - Op.new(@opt,req,msg).select if req and msg + SiSU::Op.new(@opt,req,msg).select if req and msg end def actions if @opt.cmd =~/E/ # re-assign character @@ -357,15 +359,15 @@ p "here #{__FILE__} #{__LINE__}" if @opt =~/M/ SiSU_Harvest::Source.new(@opt).read # -h -H html.rb elsif @opt.mod.inspect =~/--convert|--to|--from/ require_relative 'sst_convert_markup' # sst_convert_markup.rb - elsif @opt.cmd =~/([abCcDdeFGgHhIikLMmNnoPpQqRrSsTtUuVvWwXxYyZ_0-9])/ \ + elsif @opt.cmd =~/([abCcDdeFGgHhIjikLMmNnoPpQqRrSsTtUuVvWwXxYyZ_0-9])/ \ and @opt.cmd =~/^-/ \ and @opt.mod.inspect !~/--(?:sitemaps|query|identify)/ \ or @opt.mod.inspect =~/--(?:(?:sq)?lite|pg(?:sql)?)/ @cX=SiSU_Screen::Ansi.new(@opt.cmd).cX - flag=SiSU_Env::Info_processing_flag.new + flag=SiSU_Env::InfoProcessingFlag.new if @opt.cmd =~/[vVM]/ #% version information - if @opt.cmd =~/V/ \ - and @opt.files.empty? #% environment + if (@opt.cmd =~/V/) \ + && (@opt.files.empty?) #% environment SiSU_Help::Help.new('env',@opt).environment else SiSU_Help::Help.new('env',@opt).sisu_version end @@ -407,22 +409,22 @@ p "here #{__FILE__} #{__LINE__}" if @opt =~/M/ if @opt.cmd =~/R/ if @opt.mod.inspect =~/--init(?:ialize)?=site/ \ and @opt.cmd =~/RZ/ - Operations.new(@opt).remote_put_base_site_rsync_match - else Operations.new(@opt).remote_put_base_site_rsync + SiSU::Operations.new(@opt).remote_put_base_site_rsync_match + else SiSU::Operations.new(@opt).remote_put_base_site_rsync end elsif @opt.cmd =~/r/ if @opt.mod.inspect =~/--init(?:ialize)?=site/ \ and @opt.cmd =~/CCr/ - Operations.new(@opt).remote_put_base_site_all - else Operations.new(@opt).remote_put_base_site + SiSU::Operations.new(@opt).remote_put_base_site_all + else SiSU::Operations.new(@opt).remote_put_base_site end end end if @opt.act[:sample_search_form][:bool] #% --sample-search-form, -F cgi sample search form - Operations.new(@opt).cgi + SiSU::Operations.new(@opt).cgi end if @opt.act[:webrick][:bool] #% --webrick, -W webrick - Operations.new(@opt).webrick + SiSU::Operations.new(@opt).webrick end if @opt.cmd =~/Z/ #% -Z wipe previous output clean op('zap','Zap, deletions') @@ -463,14 +465,14 @@ p "here #{__FILE__} #{__LINE__}" if @opt =~/M/ if @get_s.length > 0 #% remote markup file .sst require_relative 'remote' # remote.rb SiSU_Remote::Get.new(@opt,@get_s).fns - Operations.new.counter + SiSU::Operations.new.counter end if @get_p.length > 0 #% remote sisupod require_relative 'remote' # remote.rb SiSU_Remote::Get.new(@opt,@get_p).sisupod end rescue - SiSU_Errors::Info_error.new($!,$@,@opt,@fns).error #ok + SiSU_Errors::InfoError.new($!,$@,@opt,@fns).error #ok @retry_count +=1 retry unless @retry_count > 1 ensure @@ -518,6 +520,9 @@ p "here #{__FILE__} #{__LINE__}" if @opt =~/M/ if @opt.act[:xhtml][:bool] #% --xhtml, -b xhtml op('xhtml','xhtml sax') end + if @opt.act[:images][:bool] #% --images, -j + op('shared_images','images') + end if @opt.act[:concordance][:bool] #% --concordance, -w op('concordance','Concordance') end @@ -536,13 +541,14 @@ p "here #{__FILE__} #{__LINE__}" if @opt =~/M/ if FileTest.file?(fns) @opt.fns=fns case @opt.fns - when /\.(termsheet.rb)$/; Operations.new(@opt).termsheet + when /\.(termsheet.rb)$/ + SiSU::Operations.new(@opt).termsheet else #print "not processed --> ", fns, "\n" end - else Operations.new(@opt).not_found + else SiSU::Operations.new(@opt).not_found end end - Operations.new.counter + SiSU::Operations.new.counter end if @opt.cmd =~/k/ #% -T temporary tests op('xml_scaffold','XML scaffold') @@ -559,6 +565,9 @@ p "here #{__FILE__} #{__LINE__}" if @opt =~/M/ if @opt.act[:psql][:bool] #% --pg, -D DB postgresql op('dbi','postgresql') end + if @opt.act[:sqlite_discreet][:bool] #% --sqlite, -d DB sqlite + op('dbi_discreet','sqlite') + end if @opt.act[:sqlite][:bool] #% --sqlite, -d DB sqlite op('dbi','sqlite') end @@ -593,10 +602,10 @@ p "here #{__FILE__} #{__LINE__}" if @opt =~/M/ end elsif @opt.mod.inspect =~/--query/ require_relative 'sst_identify_markup' # sst_identify_markup.rb - puts SiSU_Markup::Markup_history.new(@opt).query + puts SiSU_Markup::MarkupHistory.new(@opt).query elsif @opt.mod.inspect =~/--identify/ require_relative 'sst_identify_markup' # sst_identify_markup.rb - markup_version=SiSU_Markup::Markup_identify.new(@opt).markup_version? + markup_version=SiSU_Markup::MarkupIdentify.new(@opt).markup_version? elsif @opt.mod.inspect =~/--about/ #% help instructions if @opt.mod.inspect =~/--about/ \ and not @opt.what.empty? @@ -632,7 +641,7 @@ p "here #{__FILE__} #{__LINE__}" if @opt =~/M/ and @opt.mod.inspect =~/--(?:(?:convert(?:-from)?|from)[=-])?(?:xml2sst|sxml)/ elsif @opt.fns=~/\.ssi$/ \ and @opt.mod.inspect =~/--identify/ - else Operations.new(@opt).not_recognised + else SiSU::Operations.new(@opt).not_recognised end end if @opt.fns =~/\.ssm\.sst$/ \ @@ -641,7 +650,7 @@ p "here #{__FILE__} #{__LINE__}" if @opt =~/M/ @tell.call.warn unless @opt.cmd =~/V/ File.unlink(@opt.fns) if File.exist?(@opt.fns) #CONSIDER end - else #Operations.new(fns,'html').not_found + else #SiSU::Operations.new(fns,'html').not_found end end end @@ -664,8 +673,8 @@ p "here #{__FILE__} #{__LINE__}" if @opt =~/M/ require 'uri' home=ENV['HOME'] argv=$* - @opt=SiSU_commandline::Options.new(argv) - Processing.new(@opt).actions + @opt=SiSU_Commandline::Options.new(argv) + SiSU::Processing.new(@opt).actions rescue; STDERR.puts SiSU_Screen::Ansi.new(@opt,$!,$@,nil).rescue #fix ensure Dir.chdir(@@pwd_the) diff --git a/lib/sisu/v3/i18n.rb b/lib/sisu/v3/i18n.rb index 63ef6c11..a440b7d6 100644 --- a/lib/sisu/v3/i18n.rb +++ b/lib/sisu/v3/i18n.rb @@ -242,7 +242,7 @@ also note ISO_639-2 Px[:lng_lst] # constants.rb -module SiSU_text_translation +module SiSU_TextTranslation class Language def initialize(md) @md=md diff --git a/lib/sisu/v3/manifest.rb b/lib/sisu/v3/manifest.rb index 694ba943..0eb580b3 100644 --- a/lib/sisu/v3/manifest.rb +++ b/lib/sisu/v3/manifest.rb @@ -72,15 +72,15 @@ module SiSU_Manifest class Source def initialize(opt) @opt=opt - @particulars=SiSU_Particulars::Combined_singleton.instance.get_all(opt) - l=SiSU_Env::Standardise_language.new(@opt.lng).language + @particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt) + l=SiSU_Env::StandardiseLanguage.new(@opt.lng).language @doc_language=l[:n] end def read begin - @env=SiSU_Env::Info_env.new(@opt.fns) + @env=SiSU_Env::InfoEnv.new(@opt.fns) @md=SiSU_Param::Parameters.new(@opt).get - SiSU_Env::Info_skin.new(@md).select + SiSU_Env::InfoSkin.new(@md).select xbrowser=@env.program.web_browser browser=@env.program.console_web_browser # webserv_url=@env.path.url.output_tell #fix in sysenv @@ -91,51 +91,68 @@ module SiSU_Manifest : SiSU_Screen::Ansi.new(@opt.cmd,'Manifest',"[#{@opt.f_pth[:lng_is]}] #{@opt.fns}").green_title_hi SiSU_Screen::Ansi.new(@opt.cmd,"#{browser} #{url_html}").grey_tab if @opt.cmd =~/v/i end - data=SiSU_HTML::Source::Html_environment.new(@particulars).tuned_file_instructions - Output_Info.new(@md).check_output(data) - rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error + data=SiSU_HTML::Source::HTML_Environment.new(@particulars).tuned_file_instructions + SiSU_Manifest::Source::Output.new(@md).check_output(data) + rescue; SiSU_Errors::InfoError.new($!,$@,@opt.cmd,@opt.fns).error ensure end end private - class Output_Info <Source + class Output <Source def initialize(md) @manifest={ txt: [], html: [] } @md,@fns=md,md.fns - @env=SiSU_Env::Info_env.new(@md.fns) + @env=SiSU_Env::InfoEnv.new(@md.fns) + @make=SiSU_Env::ProcessingSettings.new(@md) @fnb=@md.fnb @base_url="#{@env.url.root}/#{@fnb}" - @f=SiSU_Env::SiSU_file.new(@md) + @f=SiSU_Env::FileOp.new(@md) + @o_str=SiSU_Env::ProcessingSettings.new(md).output_dir_structure + @image_path=if @o_str.dump_or_redirect? + %{./image} + else + %{#{@f.path_rel_links.html_scroll_2}_sisu/image_sys} + end @base_path=@f.output_path.manifest.dir - @@dg ||=SiSU_Env::Info_env.new.digest.type + @@dg ||=SiSU_Env::InfoEnv.new.digest.type @dg=@@dg - l=SiSU_Env::Standardise_language.new(@md.opt.lng).language + l=SiSU_Env::StandardiseLanguage.new(@md.opt.lng).language @language=l[:n] @translate=SiSU_Translate::Source.new(@md,@language) @brace_url=SiSU_Viz::Skin.new.url_decoration + @stylesheet=SiSU_Style::CSS_HeadInfo.new(md).stylesheet end def output manifest=@f.write_file.manifest @manifest[:html].each do |x| - x.gsub!(Xx[:html_relative2],@f.path_rel_links.html_scroll_2) - x.gsub!(Xx[:html_relative1],@f.path_rel_links.html_scroll_1) + x=x.gsub(Xx[:html_relative2],@f.path_rel_links.html_scroll_2). + gsub(Xx[:html_relative1],@f.path_rel_links.html_scroll_1) manifest << x end end + def url_make(url,file,src=nil) + if @o_str.dump_or_redirect? + '' + elsif :src + %{<br />#{@brace_url.xml_open}<a href="#{url}/#{file}">#{url}/#{file}</a>#{@brace_url.xml_close}} + else + %{<p class="tiny">#{@brace_url.xml_open}<a href="#{url}/#{file}">#{url}/#{file}</a>#{@brace_url.xml_close}</p>} + end + end def summarize(id,file,pth='',rel='',url='',img='● ') size=(File.size("#{pth}/#{file}")/1024.00).to_s kb=/([0-9]+\.[0-9]{0,1})/m.match(size)[1] @manifest[:txt] << "#{file} #{id} #{kb}\n" - @manifest[:html] << %{<tr><th class="left"><p class="norm"><a href="#{rel}/#{file}">#{img}#{id}</a></p></th><td><p class="small"><a href="#{rel}/#{file}">#{file}</a></p><p class="tiny">#{@brace_url.xml_open}<a href="#{url}/#{file}">#{url}/#{file}</a>#{@brace_url.xml_close}</p></td><td class="right"><p class="right">#{kb}</p></td></tr>\n} + @manifest[:html] << %{<tr><th class="left"><p class="norm"><a href="#{rel}/#{file}">#{img}#{id}</a></p></th><td><p class="small"><a href="#{rel}/#{file}">#{file}</a></p>#{url_make(url,file)}</td><td class="right"><p class="right">#{kb}</p></td></tr>\n} end def summarize_html_seg(id,file,pth='',rel='',url='',img='● ') size=(File.size("#{pth}/#{file}")/1024.00).to_s kb=/([0-9]+\.[0-9]{0,1})/m.match(size)[1] @manifest[:txt] << "#{file} #{id} #{kb}\n" - @manifest[:html] << %{<tr><th class="left"><p class="norm"><a href="#{rel}/#{file}">#{img}#{id}</a></p></th><td><p class="small"><a href="#{rel}/#{file}">#{file}</a></p><p class="tiny">#{@brace_url.xml_open}<a href="#{url}/#{file}">#{url}/#{file}</a>#{@brace_url.xml_close}</p></td><td class="right"><p class="right">#{kb}</p></td></tr>\n} + @manifest[:html] << %{<tr><th class="left"><p class="norm"><a href="#{rel}/#{file}">#{img}#{id}</a></p></th><td><p class="small"><a href="#{rel}/#{file}">#{file}</a></p>#{url_make(url,file)}</td><td class="right"><p class="right">#{kb}</p></td></tr>\n} end def summarize_sources(id,file,pth,rel,url) - sys=SiSU_Env::System_call.new + sys=SiSU_Env::SystemCall.new dgst =if @dg =~/^sha(?:2|256)$/; sys.sha256("#{pth}/#{file}") else sys.md5("#{pth}/#{file}") end @@ -143,17 +160,23 @@ module SiSU_Manifest size=(File.size("#{pth}/#{file}")/1024.00).to_s kb=/([0-9]+\.[0-9]{0,1})/m.match(size)[1] @manifest[:txt] << "#{file} #{id} #{kb}\n" - @manifest[:html] << %{<tr><th class="left"><p class="norm"><a href="#{rel}/#{file}">#{id}</a></p></th><td class="right"><p class="tiny"><a href="#{rel}/#{file}">#{file}</a> #{dgst[1]}<br />#{@brace_url.xml_open}<a href="#{url}/#{file}">#{url}/#{file}</a>#{@brace_url.xml_close}</p></td><td class="right"><p class="right">#{kb}</p></td></tr>\n} if kb and kb =~/\d+/ + @manifest[:html] << %{<tr><th class="left"><p class="norm"><a href="#{rel}/#{file}">#{id}</a></p></th><td class="right"><p class="tiny"><a href="#{rel}/#{file}">#{file}</a> #{dgst[1]}#{url_make(url,file,:src)}</p></td><td class="right"><p class="right">#{kb}</p></td></tr>\n} if kb and kb =~/\d+/ end def published_manifests? - @f=SiSU_Env::SiSU_file.new(@md) #.base_filename + @f=SiSU_Env::FileOp.new(@md) #.base_filename @m=[] url=@f.output_path.base.url manifests={} mp,mn,mt,mr=nil,nil,nil,nil ln=SiSU_i18n::Languages.new.language.list Px[:lng_lst].each do |lc| - if @env.output_dir_structure.by_language_code? + if @o_str.dump_or_redirect? #does not work for --redirect or --dump + mp="#{@f.output_path.base.dir}" + mn="#{@md.fnb}.html" + mt="#{mp}/#{mn}" + mr="../../#{lc}/manifest/#{mn}" + mu="#{url}/#{mn}" + elsif @env.output_dir_structure.by_language_code? mp="#{@f.output_path.base.dir}/#{lc}/manifest" mn="#{@md.fnb}.html" mt="#{mp}/#{mn}" @@ -180,8 +203,7 @@ module SiSU_Manifest end end manifests - @m.uniq! - @m + @m=@m.uniq end def languages(id,file) flv=published_manifests? @@ -201,7 +223,7 @@ module SiSU_Manifest end end def metadata(id,info) - info.to_s.gsub!(/#{Mx[:br_line]}/,'<br />') + info=info.to_s.gsub(/#{Mx[:br_line]}/,'<br />') @manifest[:html] << %{<tr><th class="left"><p class="bold_left">#{id}:</p></th><td><p class="left">#{info}</p></td></tr>\n} end def links(url,lnk,target) @@ -213,7 +235,7 @@ module SiSU_Manifest end def output_tests if FileTest.file?(@f.place_file.html_segtoc.dir)==true - img=%{<img border="0" height="18" width="15" src="#{@f.path_rel_links.html_scroll_2}_sisu/image_sys/b_toc.png" alt="TOC linked" /> } + img=%{<img border="0" height="18" width="15" src="#{@image_path}/b_toc.png" alt="TOC linked" /> } pth=@f.output_path.html_seg.dir rel=@f.output_path.html_seg.rel_sm url=@f.output_path.html_seg.url @@ -221,7 +243,7 @@ module SiSU_Manifest summarize_html_seg(id,file,pth,rel,url,img) end if FileTest.file?(@f.place_file.html_scroll.dir)==true - img=%{<img border="0" height="15" width="15" src="#{@f.path_rel_links.html_scroll_2}_sisu/image_sys/b_doc.png" alt="Full Text" /> } + img=%{<img border="0" height="15" width="15" src="#{@image_path}/b_doc.png" alt="Full Text" /> } pth=@f.output_path.html_scroll.dir rel=@f.output_path.html_scroll.rel_sm url=@f.output_path.html_scroll.url @@ -243,7 +265,7 @@ module SiSU_Manifest summarize(id,file,pth,rel,url) end if FileTest.file?(@f.place_file.epub.dir)==true - img=%{<img border="0" height="18" width="18" src="#{@f.path_rel_links.html_scroll_2}_sisu/image_sys/b_epub.png" alt="EPUB" /> } + img=%{<img border="0" height="18" width="18" src="#{@image_path}/b_epub.png" alt="EPUB" /> } id,file='EPUB (Electronic Publication, e-book standard)',@f.base_filename.epub pth=@f.output_path.epub.dir rel=@f.output_path.epub.rel_sm @@ -251,7 +273,7 @@ module SiSU_Manifest summarize(id,file,pth,rel,url,img) end if FileTest.file?("#{@f.output_path.pdf.dir}/#{@f.base_filename.pdf_p_letter}")==true - img=%{<img border="0" height="18" width="15" src="#{@f.path_rel_links.html_scroll_2}_sisu/image_sys/b_pdf.png" alt="PDF portrait" /> } + img=%{<img border="0" height="18" width="15" src="#{@image_path}/b_pdf.png" alt="PDF portrait" /> } pth=@f.output_path.pdf.dir rel=@f.output_path.pdf.rel_sm url=@f.output_path.pdf.url @@ -259,7 +281,7 @@ module SiSU_Manifest summarize(id,file,pth,rel,url,img) end if FileTest.file?("#{@f.output_path.pdf.dir}/#{@f.base_filename.pdf_l_letter}")==true - img=%{<img border="0" height="15" width="18" src="#{@f.path_rel_links.html_scroll_2}_sisu/image_sys/b_pdf.png" alt="PDF landscape" /> } + img=%{<img border="0" height="15" width="18" src="#{@image_path}/b_pdf.png" alt="PDF landscape" /> } pth=@f.output_path.pdf.dir rel=@f.output_path.pdf.rel_sm url=@f.output_path.pdf.url @@ -267,7 +289,7 @@ module SiSU_Manifest summarize(id,file,pth,rel,url,img) end if FileTest.file?("#{@f.output_path.pdf.dir}/#{@f.base_filename.pdf_p_a4}")==true - img=%{<img border="0" height="18" width="15" src="#{@f.path_rel_links.html_scroll_2}_sisu/image_sys/b_pdf.png" alt="PDF portrait" /> } + img=%{<img border="0" height="18" width="15" src="#{@image_path}/b_pdf.png" alt="PDF portrait" /> } pth=@f.output_path.pdf.dir rel=@f.output_path.pdf.rel_sm url=@f.output_path.pdf.url @@ -275,7 +297,7 @@ module SiSU_Manifest summarize(id,file,pth,rel,url,img) end if FileTest.file?("#{@f.output_path.pdf.dir}/#{@f.base_filename.pdf_l_a4}")==true - img=%{<img border="0" height="15" width="18" src="#{@f.path_rel_links.html_scroll_2}_sisu/image_sys/b_pdf.png" alt="PDF landscape" /> } + img=%{<img border="0" height="15" width="18" src="#{@image_path}/b_pdf.png" alt="PDF landscape" /> } pth=@f.output_path.pdf.dir rel=@f.output_path.pdf.rel_sm url=@f.output_path.pdf.url @@ -283,7 +305,7 @@ module SiSU_Manifest summarize(id,file,pth,rel,url,img) end if FileTest.file?("#{@f.output_path.pdf.dir}/#{@f.base_filename.pdf_p_a5}")==true - img=%{<img border="0" height="18" width="15" src="#{@f.path_rel_links.html_scroll_2}_sisu/image_sys/b_pdf.png" alt="PDF portrait" /> } + img=%{<img border="0" height="18" width="15" src="#{@image_path}/b_pdf.png" alt="PDF portrait" /> } pth=@f.output_path.pdf.dir rel=@f.output_path.pdf.rel_sm url=@f.output_path.pdf.url @@ -291,7 +313,7 @@ module SiSU_Manifest summarize(id,file,pth,rel,url,img) end if FileTest.file?("#{@f.output_path.pdf.dir}/#{@f.base_filename.pdf_l_a5}")==true - img=%{<img border="0" height="15" width="18" src="#{@f.path_rel_links.html_scroll_2}_sisu/image_sys/b_pdf.png" alt="PDF landscape" /> } + img=%{<img border="0" height="15" width="18" src="#{@image_path}/b_pdf.png" alt="PDF landscape" /> } pth=@f.output_path.pdf.dir rel=@f.output_path.pdf.rel_sm url=@f.output_path.pdf.url @@ -299,7 +321,7 @@ module SiSU_Manifest summarize(id,file,pth,rel,url,img) end if FileTest.file?("#{@f.output_path.pdf.dir}/#{@f.base_filename.pdf_p_b5}")==true - img=%{<img border="0" height="18" width="15" src="#{@f.path_rel_links.html_scroll_2}_sisu/image_sys/b_pdf.png" alt="PDF portrait" /> } + img=%{<img border="0" height="18" width="15" src="#{@image_path}/b_pdf.png" alt="PDF portrait" /> } pth=@f.output_path.pdf.dir rel=@f.output_path.pdf.rel_sm url=@f.output_path.pdf.url @@ -307,7 +329,7 @@ module SiSU_Manifest summarize(id,file,pth,rel,url,img) end if FileTest.file?("#{@f.output_path.pdf.dir}/#{@f.base_filename.pdf_l_b5}")==true - img=%{<img border="0" height="15" width="18" src="#{@f.path_rel_links.html_scroll_2}_sisu/image_sys/b_pdf.png" alt="PDF landscape" /> } + img=%{<img border="0" height="15" width="18" src="#{@image_path}/b_pdf.png" alt="PDF landscape" /> } pth=@f.output_path.pdf.dir rel=@f.output_path.pdf.rel_sm url=@f.output_path.pdf.url @@ -315,7 +337,7 @@ module SiSU_Manifest summarize(id,file,pth,rel,url,img) end if FileTest.file?("#{@f.output_path.pdf.dir}/#{@f.base_filename.pdf_p_legal}")==true - img=%{<img border="0" height="18" width="15" src="#{@f.path_rel_links.html_scroll_2}_sisu/image_sys/b_pdf.png" alt="PDF portrait" /> } + img=%{<img border="0" height="18" width="15" src="#{@image_path}/b_pdf.png" alt="PDF portrait" /> } pth=@f.output_path.pdf.dir rel=@f.output_path.pdf.rel_sm url=@f.output_path.pdf.url @@ -323,7 +345,7 @@ module SiSU_Manifest summarize(id,file,pth,rel,url,img) end if FileTest.file?("#{@f.output_path.pdf.dir}/#{@f.base_filename.pdf_l_legal}")==true - img=%{<img border="0" height="15" width="18" src="#{@f.path_rel_links.html_scroll_2}_sisu/image_sys/b_pdf.png" alt="PDF landscape" /> } + img=%{<img border="0" height="15" width="18" src="#{@image_path}/b_pdf.png" alt="PDF landscape" /> } pth=@f.output_path.pdf.dir rel=@f.output_path.pdf.rel_sm url=@f.output_path.pdf.url @@ -331,7 +353,7 @@ module SiSU_Manifest summarize(id,file,pth,rel,url,img) end if FileTest.file?(@f.place_file.odt.dir)==true - img=%{<img border="0" height="18" width="18" src="#{@f.path_rel_links.html_scroll_2}_sisu/image_sys/b_odf.png" alt="ODF/ODT" /> } + img=%{<img border="0" height="18" width="18" src="#{@image_path}/b_odf.png" alt="ODF/ODT" /> } pth=@f.output_path.odt.dir rel=@f.output_path.odt.rel_sm url=@f.output_path.odt.url @@ -374,6 +396,13 @@ module SiSU_Manifest id,file='Manpage',@f.base_filename.manpage summarize(id,file,pth,rel,url) end + if FileTest.file?(@f.place_file.sqlite_discreet.dir)==true + id,file='SQLite3 file',@f.base_filename.sqlite_discreet + pth=@f.output_path.sqlite_discreet.dir + rel=@f.output_path.sqlite_discreet.rel_sm + url=@f.output_path.sqlite_discreet.url + summarize(id,file,pth,rel,url) + end if FileTest.file?(@f.place_file.txt.dir)==true if @md.opt.cmd =~/a/; id='Plaintext (Unix (UTF-8) with footnotes)' elsif @md.opt.cmd =~/e/; id='Plaintext (Unix (UTF-8) with endnotes)' @@ -417,8 +446,11 @@ module SiSU_Manifest end def qrc_image fn=@md.fnb - img_md="qrcode/#{fn}.md.png" - img_title="qrcode/#{fn}.title.png" + pth=(@o_str.dump_or_redirect?) \ + ? '.' + : 'qrcode' + img_md="#{pth}/#{fn}.md.png" + img_title="#{pth}/#{fn}.title.png" if FileTest.file?(@f.place_file.qrcode_md.dir)==true @manifest[:html] <<<<WOK <tr><td class="left"> @@ -731,16 +763,20 @@ WOK end def check_output(data) begin - minitoc=SiSU_HTML_minitoc::Toc_mini.new(@md,data).songsheet.join("\n") + minitoc=SiSU_HTML_MiniToc::TocMini.new(@md,data).songsheet.join("\n") id,file='','' - vz=SiSU_Env::Get_init.instance.skin + vz=SiSU_Env::GetInit.instance.skin + search_form=if @make.build.search_form? + "<td>#{@env.widget_static.search_form}</td>" + else '' + end banner_table=if vz.banner_home_button_only !~ /http:\/\/www\.jus\.uio\.no\/sisu/ \ and vz.banner_home_button_only !~ /sisu\.home\.png/ <<WOK <table summary="band" border="0" cellpadding="3" cellspacing="0"> <tr><td align="left" width="15%" bgcolor="#ffffff">#{vz.banner_band}</td> <td width="70%"><p class="tiny">#{@brace_url.xml_open}<a href="#{@base_url}/#{file}">#{@base_url}/#{file}</a>#{@brace_url.xml_close}</p></td> -<td>#{@env.widget_static.search_form}</td></tr> +#{search_form}</tr> </table> WOK else @@ -748,7 +784,7 @@ WOK <table summary="band" border="0" cellpadding="3" cellspacing="0"> <tr><td align="left" bgcolor="#ffffff"><a href="http://www.jus.uio.no/sisu/" target="_top"><img border="0" src="#{vz.url_path_image_sys}/sisu.png" alt="SiSU -->" /></a></td> <td><p class="tiny">#{@brace_url.xml_open}<a href="#{@base_url}/#{file}">#{@base_url}/#{file}</a>#{@brace_url.xml_close}</p></td> -<td>#{@env.widget_static.search_form}</td></tr> +#{search_form}</tr> </table> WOK end @@ -764,16 +800,17 @@ SiSU manifest: #{@md.title.full} <meta name="sourcefile" content="#{@md.fns}" /> <link rel="generator" href="http://www.jus.uio.no/sisu" /> <link rel="shortcut icon" href="#{@f.path_rel_links.html_scroll_css}_sisu/image_sys/rb7.ico" /> -<link rel="stylesheet" href="#{@f.path_rel_links.html_scroll_css}_sisu/css/html.css" type="text/css" /> +#{@stylesheet.css_head} </head> <body bgcolor="#ffffff" text="#000000" link="#003090" lang="en" xml:lang="en"> #{banner_table} WOK - if @env.manifest_minitoc? - if @env.output_dir_structure.by_language_code? \ + if @make.build.manifest_minitoc? + if @o_str.dump_or_redirect? + elsif @env.output_dir_structure.by_language_code? \ or @env.output_dir_structure.by_filetype? - minitoc.gsub!(/<a href="(\S+?)"/m,%{<a href="../html/#{@md.fnb}/\\1"}) - minitoc.gsub!(/<a href="\.\.\/html\/#{@md.fnb}\/(?:sisu_manifest\.html|#{@f.base_filename.manifest})"/m, + minitoc=minitoc.gsub(/<a href="(\S+?)"/m,%{<a href="../html/#{@md.fnb}/\\1"}). + gsub(/<a href="\.\.\/html\/#{@md.fnb}\/(?:sisu_manifest\.html|#{@f.base_filename.manifest})"/m, %{<a href="#{@f.base_filename.manifest}"}) end @manifest[:html] <<<<WOK @@ -853,7 +890,7 @@ WOK </html> WOK output - rescue; SiSU_Errors::Info_error.new($!,$@,@md.opt.cmd,@md.fns).error + rescue; SiSU_Errors::InfoError.new($!,$@,@md.opt.cmd,@md.fns).error ensure end end diff --git a/lib/sisu/v3/manpage.rb b/lib/sisu/v3/manpage.rb index 8cbdb47c..0571a0e6 100644 --- a/lib/sisu/v3/manpage.rb +++ b/lib/sisu/v3/manpage.rb @@ -64,7 +64,7 @@ module SiSU_Manpage include SiSU_Param include SiSU_Viz require_relative 'manpage_format' # manpage_format.rb - include SiSU_Manpage_format + include SiSU_ManpageFormat require_relative 'shared_metadata' # shared_metadata.rb require_relative 'shared_txt' # shared_txt.rb pwd=Dir.pwd @@ -81,7 +81,7 @@ module SiSU_Manpage def read begin @md=SiSU_Param::Parameters.new(@opt).get - @env=SiSU_Env::Info_env.new(@opt.fns) + @env=SiSU_Env::InfoEnv.new(@opt.fns) path=@env.path.output_tell tool=(@opt.cmd =~/[MVv]/) \ ? "#{@env.program.text_editor} #{@md.file.output_path.manpage.dir}/#{@md.file.base_filename.manpage}" @@ -93,8 +93,8 @@ module SiSU_Manpage SiSU_Screen::Ansi.new(@opt.cmd,@opt.fns,"#{@md.file.output_path.manpage.dir}/#{@md.file.base_filename.manpage}").flow if @opt.cmd =~/[MV]/ @dal_array=SiSU_DAL::Source.new(@opt).get # dal file drawn here SiSU_Manpage::Source::Scroll.new(@md,@dal_array).songsheet - SiSU_Env::Info_skin.new(@md).select #watch - rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error + SiSU_Env::InfoSkin.new(@md).select #watch + rescue; SiSU_Errors::InfoError.new($!,$@,@opt.cmd,@opt.fns).error ensure end end @@ -102,12 +102,12 @@ module SiSU_Manpage class Scroll <Source require_relative 'defaults' # defaults.rb require_relative 'shared_txt' # shared_txt.rb - include SiSU_text_utils + include SiSU_TextUtils @@endnotes={ para: [], end: [] } def initialize(md,data) @md,@data=md,data @brace_url=SiSU_Viz::Skin.new.url_decoration - @vz=SiSU_Env::Get_init.instance.skin + @vz=SiSU_Env::GetInit.instance.skin @tab="\t" @br="\n" @@dostype='unix endnotes' @@ -134,21 +134,21 @@ module SiSU_Manpage end notes=@n.flatten notes.each do |e| - util=if e.to_s =~/^\[[\d*+]+\]:/; SiSU_text_utils::Wrap.new(e.to_s,78,4,1) - else SiSU_text_utils::Wrap.new(e.to_s,78,0,1) + util=if e.to_s =~/^\[[\d*+]+\]:/; SiSU_TextUtils::Wrap.new(e.to_s,78,4,1) + else SiSU_TextUtils::Wrap.new(e.to_s,78,0,1) end wrap=util.line_wrap - if wrap =~ /^\s*[\d*+]+\s+.+?\s*\Z/m - wrap.gsub!(/(^| |#{Mx[:nbsp]}|\s|\*)\\\*/,'\1\\\\\*') #man page requires - wrap.gsub!(/\s\.(\S+)/,' \\.\1') - wrap.gsub!(/^\s*([\d*+]+)\s+(.+?)\s*\Z/m, <<GSUB + wrap=if wrap =~ /^\s*[\d*+]+\s+.+?\s*\Z/m + wrap.gsub(/(^| |#{Mx[:nbsp]}|\s|\*)\\\*/,'\1\\\\\*'). #man page requires + gsub(/\s\.(\S+)/,' \\.\1'). + gsub(/^\s*([\d*+]+)\s+(.+?)\s*\Z/m, <<GSUB .TP .BI \\1. \\2 GSUB ) else - wrap.gsub!(/^\s*(.+)\Z/m, <<GSUB + wrap.gsub(/^\s*(.+)\Z/m, <<GSUB \\1 GSUB ) @@ -159,11 +159,11 @@ GSUB end end def manpage_metadata - @manpage[:metadata]=Metadata::Summary.new(@md).manpage.metadata + @manpage[:metadata]=SiSU_Metadata::Summary.new(@md).manpage.metadata end def manpage_tail - SiSU_Env::Info_skin.new(@md).select - vz=SiSU_Env::Get_init.instance.skin + SiSU_Env::InfoSkin.new(@md).select + vz=SiSU_Env::GetInit.instance.skin generator="Generated by: #{@md.sisu_version[:project]} #{@md.sisu_version[:version]} of #{@md.sisu_version[:date_stamp]} (#{@md.sisu_version[:date]})" if @md.sisu_version[:version] lastdone="Last Generated on: #{Time.now}" rubyv="Ruby version: #{@md.ruby_version}" @@ -192,35 +192,35 @@ at: <#{vz.url_site}> WOK end def manpage_structure(dob='',hname='') #% Used to extract the structure of a document - if dob.is=='heading' + if dob.is==:heading lv=dob.ln n=dob.ln - 1 n3=dob.ln + 2 else lv=nil end - wrapped=if dob.is=='para' \ - or dob.is=='heading' + wrapped=if dob.is==:para \ + || dob.is==:heading paragraph=dob.obj - if dob.is=='para' + if dob.is==:para if dob.indent =~/[1-9]/ \ and dob.indent == dob.hang util=if dob.bullet_ - SiSU_text_utils::Wrap.new("* #{paragraph}",78,dob.indent.to_i*2) - else SiSU_text_utils::Wrap.new(paragraph,78,dob.indent.to_i*2) + SiSU_TextUtils::Wrap.new("* #{paragraph}",78,dob.indent.to_i*2) + else SiSU_TextUtils::Wrap.new(paragraph,78,dob.indent.to_i*2) end elsif dob.hang =~/[0-9]/ \ and dob.indent != dob.hang # NOT yet implemented - util=SiSU_text_utils::Wrap.new(paragraph,78,dob.indent.to_i*2) + util=SiSU_TextUtils::Wrap.new(paragraph,78,dob.indent.to_i*2) else util=if dob.bullet_ - SiSU_text_utils::Wrap.new("* #{paragraph}",78,0) - else SiSU_text_utils::Wrap.new(paragraph,78,0) + SiSU_TextUtils::Wrap.new("* #{paragraph}",78,0) + else SiSU_TextUtils::Wrap.new(paragraph,78,0) end end - else util=SiSU_text_utils::Wrap.new(paragraph,78,0) + else util=SiSU_TextUtils::Wrap.new(paragraph,78,0) end w=util.line_wrap - w.gsub!(/^(\\\.)/,' \1') + w=w.gsub(/^(\\\.)/,' \1') w end if lv @@ -234,7 +234,7 @@ WOK end else @manpage[:body] << if wrapped =~/^\.BI\s/ # main text, contents, body KEEP - '.TP' << @br << wrapped.gsub!(/^\.BI\s/,'.B ') # sleight ... simpler output + '.TP' << @br << wrapped.gsub(/^\.BI\s/,'.B ') # sleight ... simpler output (check gsub!) else '.br' << @br << wrapped end @@ -250,7 +250,7 @@ WOK @@endnotes[:para]=[] end def markup(data) # Used for major markup instructions - dir=SiSU_Env::Info_env.new(@md.fns) + dir=SiSU_Env::InfoEnv.new(@md.fns) @data_mod,@endnotes,@level,@cont,@copen,@manpage_contents_close=Array.new(6){[]} (0..6).each { |x| @cont[x]=@level[x]=false } (4..6).each { |x| @manpage_contents_close[x]='' } @@ -259,88 +259,88 @@ WOK fix=[] manpage_metadata data.each do |dob| - if dob.is=='comment' \ - or dob.is=='heading_insert' + if dob.is==:comment \ + || dob.is==:heading_insert dob.obj='' end - dob.obj.gsub!(/.+?<-#>/,'') # remove dummy headings (used by html) #check - dob.obj.gsub!(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,'^\1^') - dob.obj.gsub!(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,'[\1]') - dob.obj.gsub!(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'++\1++') - dob.obj.gsub!(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'--\1--') - dob.obj.gsub!(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'"\1"') - dob.obj.gsub!(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/,'\1') - dob.obj.gsub!(/\A\s*#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}#{Mx[:br_line]}([,.:!?](?: |$))?/m,"#{Mx[:br_line]}.I \\1\\2#{Mx[:br_line]}") - dob.obj.gsub!(/\s*#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}([,.:!?](?: |$))?/m,"#{Mx[:br_line]}.I \\1\\2#{Mx[:br_line]}") - dob.obj.gsub!(/\A\s*#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}([,.:!?](?: |$))?#{Mx[:br_line]}/m,"#{Mx[:br_line]}.BI \\1\\2#{Mx[:br_line]}") - dob.obj.gsub!(/\s*#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}([,.:!?](?: |$))?/,"#{Mx[:br_line]}.B \\1\\2#{Mx[:br_line]}") - dob.obj.gsub!(/\s*#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}([,.:!?](?: |$))?/,"#{Mx[:br_line]}.I \\1\\2#{Mx[:br_line]}") - unless dob.is=='code' - dob.obj.gsub!(/(?:^|\s)#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}([,.:!?](?: |$))?/,"\\1 #{@brace_url.txt_open}\\2#{@brace_url.txt_close}\\3") - dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s)#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}([,.:!?](?: |$))?/,"\\1#{@brace_url.txt_open}\\2#{@brace_url.txt_close}\\3") + dob.obj=dob.obj.gsub(/.+?<-#>/,''). # remove dummy headings (used by html) #check + gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,'^\1^'). + gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,'[\1]'). + gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'++\1++'). + gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'--\1--'). + gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'"\1"'). + gsub(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/,'\1'). + gsub(/\A\s*#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}#{Mx[:br_line]}([,.:!?](?: |$))?/m,"#{Mx[:br_line]}.I \\1\\2#{Mx[:br_line]}"). + gsub(/\s*#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}([,.:!?](?: |$))?/m,"#{Mx[:br_line]}.I \\1\\2#{Mx[:br_line]}"). + gsub(/\A\s*#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}([,.:!?](?: |$))?#{Mx[:br_line]}/m,"#{Mx[:br_line]}.BI \\1\\2#{Mx[:br_line]}"). + gsub(/\s*#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}([,.:!?](?: |$))?/,"#{Mx[:br_line]}.B \\1\\2#{Mx[:br_line]}"). + gsub(/\s*#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}([,.:!?](?: |$))?/,"#{Mx[:br_line]}.I \\1\\2#{Mx[:br_line]}") + unless dob.is==:code + dob.obj=dob.obj.gsub(/(?:^|\s)#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}([,.:!?](?: |$))?/,"\\1 #{@brace_url.txt_open}\\2#{@brace_url.txt_close}\\3"). + gsub(/(^|#{Mx[:gl_c]}|\s)#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}([,.:!?](?: |$))?/,"\\1#{@brace_url.txt_open}\\2#{@brace_url.txt_close}\\3") @manpage[:endnotes]=extract_endnotes(dob.obj) - dob.obj.gsub!(/#{Mx[:en_a_o]}([\d*+]+)\s*(?:.+?)#{Mx[:en_a_c]}/m,'[^\1]') # endnote marker marked up - dob.obj.gsub!(/#{Mx[:en_b_o]}([\d*+]+)\s*(?:.+?)#{Mx[:en_b_c]}/m,'[^\1]') # endnote marker marked up - dob.obj.gsub!(/#{Mx[:gl_o]}#amp#{Mx[:gl_c]}/,'&') ##{Mx[:gl_o]}#095#{Mx[:gl_c]} - dob.obj.gsub!(/#{Mx[:gl_o]}#033#{Mx[:gl_c]}/,'!') - dob.obj.gsub!(/#{Mx[:gl_o]}#035#{Mx[:gl_c]}/,'#') - dob.obj.gsub!(/#{Mx[:gl_o]}#042#{Mx[:gl_c]}/,'*') - dob.obj.gsub!(/#{Mx[:gl_o]}#045#{Mx[:gl_c]}/,'-') - dob.obj.gsub!(/#{Mx[:gl_o]}#092#{Mx[:gl_c]}/,'\e') - dob.obj.gsub!(/#{Mx[:gl_o]}#047#{Mx[:gl_c]}/,'/') - dob.obj.gsub!(/#{Mx[:gl_o]}#095#{Mx[:gl_c]}/,'_') - dob.obj.gsub!(/#{Mx[:gl_o]}#123#{Mx[:gl_c]}/,'{') - dob.obj.gsub!(/#{Mx[:gl_o]}#125#{Mx[:gl_c]}/,'}') - dob.obj.gsub!(/#{Mx[:gl_o]}#126#{Mx[:gl_c]}/,'~') - dob.obj.gsub!(/#{Mx[:gl_o]}#169#{Mx[:gl_c]}/,'©') + dob.obj=dob.obj.gsub(/#{Mx[:en_a_o]}([\d*+]+)\s*(?:.+?)#{Mx[:en_a_c]}/m,'[^\1]'). # endnote marker marked up + gsub(/#{Mx[:en_b_o]}([\d*+]+)\s*(?:.+?)#{Mx[:en_b_c]}/m,'[^\1]'). # endnote marker marked up + gsub(/#{Mx[:gl_o]}#amp#{Mx[:gl_c]}/,'&'). ##{Mx[:gl_o]}#095#{Mx[:gl_c]} + gsub(/#{Mx[:gl_o]}#033#{Mx[:gl_c]}/,'!'). + gsub(/#{Mx[:gl_o]}#035#{Mx[:gl_c]}/,'#'). + gsub(/#{Mx[:gl_o]}#042#{Mx[:gl_c]}/,'*'). + gsub(/#{Mx[:gl_o]}#045#{Mx[:gl_c]}/,'-'). + gsub(/#{Mx[:gl_o]}#092#{Mx[:gl_c]}/,'\e'). + gsub(/#{Mx[:gl_o]}#047#{Mx[:gl_c]}/,'/'). + gsub(/#{Mx[:gl_o]}#095#{Mx[:gl_c]}/,'_'). + gsub(/#{Mx[:gl_o]}#123#{Mx[:gl_c]}/,'{'). + gsub(/#{Mx[:gl_o]}#125#{Mx[:gl_c]}/,'}'). + gsub(/#{Mx[:gl_o]}#126#{Mx[:gl_c]}/,'~'). + gsub(/#{Mx[:gl_o]}#169#{Mx[:gl_c]}/,'©') else - dob.obj.gsub!(/\\/,'\e') - dob.obj.gsub!(/(?:#{Mx[:br_line]}|#{Mx[:br_nl]})\s*/,"\n\n") # watch + dob.obj=dob.obj.gsub(/\\/,'\e'). + gsub(/(?:#{Mx[:br_line]}|#{Mx[:br_nl]})\s*/,"\n\n") # watch #dob.obj.gsub!(/(?:#{Mx[:br_line]}|#{Mx[:br_nl]})+\s*/,"\n") # watch end - dob.obj.gsub!(/(^| |#{Mx[:nbsp]}|\s|\*)\\\*/,'\1\\\\\*') #man page requires - dob.obj.gsub!(/┆/,'|') - dob.obj.gsub!(/\s\.(\S+)/,' \\.\1') - dob.obj.gsub!(/(\n\.)(\S\S\S+)/m,'\1\\.\2') - dob.obj.gsub!(/-/,'\-') #manpages use this - dob.obj.gsub!(/~/,'~') if dob.obj #manpages use this + dob.obj=dob.obj.gsub(/(^| |#{Mx[:nbsp]}|\s|\*)\\\*/,'\1\\\\\*'). #man page requires + gsub(/┆/,'|'). + gsub(/\s\.(\S+)/,' \\.\1'). + gsub(/(\n\.)(\S\S\S+)/m,'\1\\.\2'). + gsub(/-/,'\-') #manpages use this + dob.obj=dob.obj.gsub(/~/,'~') if dob.obj #manpages use this if dob.is =~/block|group|verse|alt|code/ - if dob.is =='code' - dob.obj.gsub!(/(^|[^}])_([<>])/m,'\1\2') # _> _< - dob.obj.gsub!(/(^|[^}])_([<>])/m,'\1\2') # _<_< - dob.obj.gsub!(/\A(.+)?\Z/m,".nf\n\n\\1\n\n.fi") + if dob.is ==:code + dob.obj=dob.obj.gsub(/(^|[^}])_([<>])/m,'\1\2'). # _> _< + gsub(/(^|[^}])_([<>])/m,'\1\2'). # _<_< + gsub(/\A(.+)?\Z/m,".nf\n\n\\1\n\n.fi") end end #dob.obj.gsub!(/(?:#{Mx[:br_line]}|#{Mx[:br_nl]})+\s*/m,"\n.br\n") # watch - dob.obj.gsub!(/(?:#{Mx[:br_line]}|#{Mx[:br_nl]})+\s*/m,"\n\n") # watch + dob.obj=dob.obj.gsub(/(?:#{Mx[:br_line]}|#{Mx[:br_nl]})+\s*/m,"\n\n") # watch blit=dob.obj.scan(/\[[^\]]+\]|[^\[]+/) blit_array=[] blit.each do |x| - if x =~/^\[/ - x.gsub!(/\s+/,' \ ') #manpages use this + x=if x =~/^\[/ + x.gsub(/\s+/,' \ ') #manpages use this else x end blit_array << x end dob.obj=blit_array.join - dob.obj.gsub!(/#{Mx[:gl_o]}:name#\S+?#{Mx[:gl_c]}/mi,'') #added - #dob.obj.gsub!(/\s\\\s+(#{Mx[:br_line]}|#{Mx[:br_nl]})/,'\1') #a messy solution - dob.obj.gsub!(/#{Mx[:br_page]}\s*|#{Mx[:br_page_new]}/,'') # remove page breaks - dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s)#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'\1\2') - dob.obj.gsub!(/<a href=".+?">(.+?)<\/a>/m,'\1') - dob.obj.gsub!(/#{Mx[:mk_o]}name#\S+?#{Mx[:mk_c]}/,'') # remove name links - dob.obj.gsub!(/ |#{Mx[:nbsp]}/,' ') # decide on - dob.obj.gsub!(/(?:^|[^_\\])#{Mx[:lnk_o]}\s*(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/,' [ \1 ]') #"[ #{dir.url.images_local}\/\\1 ]") - dob.obj.gsub!(/(?:^|[^_\\])#{Mx[:lnk_o]}\s*(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}image/,' [ \1 ]') #"[ #{dir.url.images_local}\/\\1 ]") - dob.obj.gsub!(/^(?:^|[^_\\])#{Mx[:lnk_o]}\s*\S+?\.(?:png|jpg|gif)\s+.+?"(.*?)"\s*#{Mx[:lnk_c]}\S+/,'[image: "\1"]') + dob.obj=dob.obj.gsub(/#{Mx[:gl_o]}:name#\S+?#{Mx[:gl_c]}/mi,''). #added + #gsub(/\s\\\s+(#{Mx[:br_line]}|#{Mx[:br_nl]})/,'\1'). #a messy solution + gsub(/#{Mx[:br_page]}\s*|#{Mx[:br_page_new]}/,''). # remove page breaks + gsub(/(^|#{Mx[:gl_c]}|\s)#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'\1\2'). + gsub(/<a href=".+?">(.+?)<\/a>/m,'\1'). + gsub(/#{Mx[:mk_o]}name#\S+?#{Mx[:mk_c]}/,''). # remove name links + gsub(/ |#{Mx[:nbsp]}/,' '). # decide on + gsub(/(?:^|[^_\\])#{Mx[:lnk_o]}\s*(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/,' [ \1 ]'). #"[ #{dir.url.images_local}\/\\1 ]") + gsub(/(?:^|[^_\\])#{Mx[:lnk_o]}\s*(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}image/,' [ \1 ]'). #"[ #{dir.url.images_local}\/\\1 ]") + gsub(/^(?:^|[^_\\])#{Mx[:lnk_o]}\s*\S+?\.(?:png|jpg|gif)\s+.+?"(.*?)"\s*#{Mx[:lnk_c]}\S+/,'[image: "\1"]') wordlist=dob.obj.scan(/\S+/) if dob.obj !~/(^#{Rx[:meta]}|#{Mx[:br_eof]}|#{Mx[:br_endnotes]})/ if dob.obj =~@regx #/.+?<~\d+;\w\d+;\w\d+>.*/ #watch change paranum=dob.obj[@regx,3] - @p_num=SiSU_Manpage_format::Paragraph_number.new(paranum) + @p_num=SiSU_ManpageFormat::ParagraphNumber.new(paranum) end - x=SiSU_Manpage_format::Format_text_object.new(@md,dob) - if dob.is=='heading' + x=SiSU_ManpageFormat::FormatTextObject.new(@md,dob) + if dob.is==:heading manpage_structure(dob) dob.obj=case dob.ln when 1; x.heading_body1 @@ -350,7 +350,7 @@ WOK when 5; x.heading_body5 when 6; x.heading_body6 end - elsif dob.is=='para' + elsif dob.is==:para manpage_structure(dob) else if dob.obj =~/#{table_message}/ @@ -362,14 +362,14 @@ WOK dob.obj='' end if dob.obj - dob.obj.gsub!(/\s(\[)/m,' \ \1') - dob.obj.gsub!(/(?:#{Mx[:br_line]}|#{Mx[:br_nl]})\s*/,"\n\n") # watch - dob.obj.gsub!(/#{Mx[:gl_o]}#126#{Mx[:gl_c]}/,'~') - dob.obj.gsub!(/#{Mx[:gl_o]}#123#{Mx[:gl_c]}/,'{') - dob.obj.gsub!(/#{Mx[:pa_o]}\S+#{Mx[:pa_c]}/,' ') - unless dob.is =='code' - dob.obj.gsub!(/<!.+!>/,' ') - dob.obj.gsub!(/<:\S+>/,' ') + dob.obj=dob.obj.gsub(/\s(\[)/m,' \ \1'). + gsub(/(?:#{Mx[:br_line]}|#{Mx[:br_nl]})\s*/,"\n\n"). # watch + gsub(/#{Mx[:gl_o]}#126#{Mx[:gl_c]}/,'~'). + gsub(/#{Mx[:gl_o]}#123#{Mx[:gl_c]}/,'{'). + gsub(/#{Mx[:pa_o]}\S+#{Mx[:pa_c]}/,' ') + unless dob.is ==:code + dob.obj=dob.obj.gsub(/<!.+!>/,' '). + gsub(/<:\S+>/,' ') end end dob @@ -386,11 +386,11 @@ WOK elsif defined? @md.date.published \ and @md.date.published @md.date.published - else SiSU_Env::Info_date.new.year #date missing decide on action + else SiSU_Env::InfoDate.new.year #date missing decide on action end manpage_name,manpage_synopsis='','' manpg={} - proj=SiSU_Env::Info_version.instance.get_version + proj=SiSU_Env::InfoVersion.instance.get_version manpage[:open] = %{.TH "#{@md.fnb}" "#{@md.make.manpage['section']}" "#{date}" "#{proj[:version]}" "#{@md.title.main}"#{@md.make.manpage['name']}#{@md.make.manpage['synopsis']}} content << manpage[:open] content << manpage[:head] @@ -409,14 +409,14 @@ WOK @md,@content=md,content end def manpage #%manpage output - SiSU_Env::SiSU_file.new(@md).mkdir - filename_manpage=SiSU_Env::SiSU_file.new(@md).write_file.manpage + SiSU_Env::FileOp.new(@md).mkdir + filename_manpage=SiSU_Env::FileOp.new(@md).write_file.manpage @sisu=[] @content.each do |para| # this is a hack if para.class==Array \ and para.length > 0 para.each do |line| - line.gsub!(/\s+$/m,'') + line=line.gsub(/\s+$/m,'') filename_manpage.puts line #unix manpage end else filename_manpage.puts para #unix manpage # /^([*=-]|\.){5}/ diff --git a/lib/sisu/v3/manpage_format.rb b/lib/sisu/v3/manpage_format.rb index 979e0a65..7f5b5dad 100644 --- a/lib/sisu/v3/manpage_format.rb +++ b/lib/sisu/v3/manpage_format.rb @@ -56,11 +56,11 @@ ** Description: manpage formatting template =end -module SiSU_Manpage_format +module SiSU_ManpageFormat require_relative 'param' # param.rb include SiSU_Param include SiSU_Viz - class Paragraph_number + class ParagraphNumber def initialize(paranum) @paranum=/(\d+)/m.match(paranum)[1] end @@ -74,7 +74,7 @@ module SiSU_Manpage_format @paranum.gsub(/(\d+)/,'<a href="#\1">') end end - class Format_text_object + class FormatTextObject def initialize(md,dob) @md,@dob=md,dob if @dob.class==Hash @@ -84,7 +84,7 @@ elsif @dob.class==String end rgx=/#{Mx[:en_a_o]}[\d*+]+\s+(.+?)#{Mx[:en_a_c]}/ @dob.obj.gsub!(rgx,'\1') if @dob.obj =~rgx - @vz=SiSU_Env::Get_init.instance.skin + @vz=SiSU_Env::GetInit.instance.skin end def scr_endnote_body "<endnote>#{@dob.obj}</endnote> " diff --git a/lib/sisu/v3/odf.rb b/lib/sisu/v3/odf.rb index 6cdbd57b..68aa6e40 100644 --- a/lib/sisu/v3/odf.rb +++ b/lib/sisu/v3/odf.rb @@ -64,7 +64,7 @@ module SiSU_ODF include SiSU_Env include SiSU_Viz require_relative 'odf_format' # odf_format.rb - include SiSU_ODF_format + include SiSU_ODF_Format require_relative 'shared_metadata' # shared_metadata.rb require_relative 'shared_txt' # shared_txt.rb @@alt_id_count,@@alt_id_count,@@tablehead,@@number_of_cols=0,0,0,0 @@ -73,7 +73,7 @@ module SiSU_ODF require 'find' def initialize(opt) @opt=opt - @particulars=SiSU_Particulars::Combined_singleton.instance.get_all(opt) + @particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt) @@endnotes_para=[] end def read @@ -89,8 +89,8 @@ module SiSU_ODF SiSU_Screen::Ansi.new(@opt.cmd,@opt.fns,"file://#{@md.file.output_path.odt.dir}/#{@md.file.base_filename.odt}").flow if @opt.cmd =~/[MV]/ end SiSU_ODF::Source::Scroll.new(@particulars).songsheet - SiSU_Env::Info_skin.new(@md).select - rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error + SiSU_Env::InfoSkin.new(@md).select + rescue; SiSU_Errors::InfoError.new($!,$@,@opt.cmd,@opt.fns).error ensure end end @@ -104,7 +104,7 @@ module SiSU_ODF @@fns=nil def initialize(particulars) @md,@env,@dal_array=particulars.md,particulars.env,particulars.dal_array - @vz=SiSU_Env::Get_init.instance.skin + @vz=SiSU_Env::GetInit.instance.skin @tab="\t" @brace_url=SiSU_Viz::Skin.new.url_decoration @br=(@md.opt.cmd =~/M/) ? '' : '' @@ -143,7 +143,7 @@ module SiSU_ODF end end def odf_metadata - @@odf[:metadata]=Metadata::Summary.new(@md).odf.metadata + @@odf[:metadata]=SiSU_Metadata::Summary.new(@md).odf.metadata end def odf_tail generator="Generated by: #{@md.sisu_version[:project]} #{@md.sisu_version[:version]} of #{@md.sisu_version[:date_stamp]} (#{@md.sisu_version[:date]})" if @md.sisu_version[:version] @@ -161,7 +161,7 @@ module SiSU_ODF @@odf[:tail] << "\n</office:text></office:body></office:document-content>" end def heading(dob,p_num='') - dob.obj.gsub!(/#{Mx[:tag_o]}\S+?#{Mx[:tag_c]}/,'') #check + dob.obj=dob.obj.gsub(/#{Mx[:tag_o]}\S+?#{Mx[:tag_c]}/,'') #check m=/#{$1}/ breakpage='' if @md.fns \ @@ -232,29 +232,29 @@ module SiSU_ODF end if m; m.each do |i| cont,url=i[1],i[2] - cont.gsub!(/([)(\]\[])/,"\\\\\\1") - cont.gsub!(/([+?])/,"\\\\\\1") # incorrect handling of + - url.gsub!(/([+?])/,"\\\\\\1") - dob.obj.sub!(/#{Mx[:lnk_o]}[ ]*#{cont}[ ]*#{Mx[:lnk_c]}image/m,image_odf(i)) - dob.obj.sub!(/#{Mx[:lnk_o]}[ ]*#{cont}[ ]*#{Mx[:lnk_c]}#{Mx[:url_o]}#{url}#{Mx[:url_c]}/m,image_odf(i)) - dob.obj.gsub!(/\\([)(\]\[?])/,'\1') #clumsy fix + cont=cont.gsub(/([)(\]\[])/,"\\\\\\1"). + gsub(/([+?])/,"\\\\\\1") # incorrect handling of + + url=url.gsub(/([+?])/,"\\\\\\1") + dob.obj=dob.obj.sub(/#{Mx[:lnk_o]}[ ]*#{cont}[ ]*#{Mx[:lnk_c]}image/m,image_odf(i)). + sub(/#{Mx[:lnk_o]}[ ]*#{cont}[ ]*#{Mx[:lnk_c]}#{Mx[:url_o]}#{url}#{Mx[:url_c]}/m,image_odf(i)). + sub(/\\([)(\]\[?])/,'\1') #clumsy fix end m=nil end dob end def text_link_odf(txt,url,trail) - txt.gsub!(/(\\\+)/,'+') #this is convoluted, and risky :-( - url.gsub!(/(\\\+)/,'+') #this is convoluted, and risky :-( - map_nametags=SiSU_Particulars::Combined_singleton.instance.get_map_nametags(@md).nametags_map + txt=txt.gsub(/(\\\+)/,'+') #this is convoluted, and risky :-( + url=url.gsub(/(\\\+)/,'+') #this is convoluted, and risky :-( + map_nametags=SiSU_Particulars::CombinedSingleton.instance.get_map_nametags(@md).nametags_map t=case url when /^https?:/ %{<text:a xlink:type="simple" xlink:href="#{url}">#{txt.strip}</text:a>#{trail}} when /^:/ # site same document collection html link - url.gsub!(/^:/,"#{@env.url.root}/") + url=url.gsub(/^:/,"#{@env.url.root}/") %{<text:a xlink:type="simple" xlink:href="#{url}">#{txt.strip}</text:a>#{trail}} when /^\.\.\// # site same document collection html link - url.gsub!(/^\.\.\//,"#{@env.url.root}/") + url=url.gsub(/^\.\.\//,"#{@env.url.root}/") %{<text:a xlink:type="simple" xlink:href="#{url}">#{txt.strip}</text:a>#{trail}} else # document internal link if map_nametags[url] \ @@ -273,11 +273,11 @@ module SiSU_ODF if m m.each do |i| txt,url,trail=i[1],i[2] - txt.gsub!(/([)(\]\[])/,"\\\\\\1") - txt.gsub!(/([+?*])/,"\\\\\\1") # problems with + - url.gsub!(/([+?])/,"\\\\\\1") # problems with + - dob.obj.gsub!(/#{Mx[:lnk_o]}[ ]*#{txt}#{Mx[:lnk_c]}#{Mx[:url_o]}#{url}#{Mx[:url_c]}/m,text_link_odf(txt,url,trail)) #make sure trailing ']' are not caught in url - dob.obj.gsub!(/\\([)(\]\[?])/,'\1') #clumsy fix + txt=txt.gsub(/([)(\]\[])/,"\\\\\\1"). + gsub(/([+?*])/,"\\\\\\1") # problems with + + url=url.gsub(/([+?])/,"\\\\\\1") # problems with + + dob.obj=dob.obj.gsub(/#{Mx[:lnk_o]}[ ]*#{txt}#{Mx[:lnk_c]}#{Mx[:url_o]}#{url}#{Mx[:url_c]}/m,text_link_odf(txt,url,trail)). #make sure trailing ']' are not caught in url + gsub(/\\([)(\]\[?])/,'\1') #clumsy fix end m=nil end @@ -288,28 +288,28 @@ module SiSU_ODF if m m.each do |i| txt,url,trail=i[1],i[2] - txt.gsub!(/([)(\]\[])/,"\\\\\\1") - txt.gsub!(/([+?*])/,"\\\\\\1") # problems with + - url.gsub!(/([+?])/,"\\\\\\1") # problems with + - dob.obj.gsub!(/#{Mx[:lnk_o]}[ ]*#{txt}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{url}#{Mx[:rel_c]}/m,text_link_odf(txt,url,trail)) #make sure trailing ']' are not caught in url - dob.obj.gsub!(/\\([)(\]\[?])/,'\1') #clumsy fix + txt=txt.gsub(/([)(\]\[])/,"\\\\\\1"). + gsub(/([+?*])/,"\\\\\\1") # problems with + + url=url.gsub(/([+?])/,"\\\\\\1") # problems with + + dob.obj=dob.obj.gsub(/#{Mx[:lnk_o]}[ ]*#{txt}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{url}#{Mx[:rel_c]}/m,text_link_odf(txt,url,trail)). #make sure trailing ']' are not caught in url + gsub(/\\([)(\]\[?])/,'\1') #clumsy fix end m=nil end dob end def normal(dob,p_num='') #P1 - P3 - dob.obj.gsub!(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/, - '<text:a xlink:type="simple" xlink:href="\1">\1</text:a>') #http ftp matches escaped, no decoration - dob.obj.gsub!(/#{Mx[:url_o]}([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)#{Mx[:url_c]}/, - %{#{@brace_url.xml_open}<text:a xlink:type="simple" xlink:href="mailto:\\1">\\1</text:a>#{@brace_url.xml_close}}) - dob.obj.gsub!(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/, - %{#{@brace_url.xml_open}<text:a xlink:type="simple" xlink:href="\\1">\\1</text:a>#{@brace_url.xml_close}}) #http ftp matches with decoration - dob.obj= if dob.is=='para' \ + dob.obj=dob.obj.gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/, + '<text:a xlink:type="simple" xlink:href="\1">\1</text:a>'). #http ftp matches escaped, no decoration + gsub(/#{Mx[:url_o]}([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)#{Mx[:url_c]}/, + %{#{@brace_url.xml_open}<text:a xlink:type="simple" xlink:href="mailto:\\1">\\1</text:a>#{@brace_url.xml_close}}). + gsub(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/, + %{#{@brace_url.xml_open}<text:a xlink:type="simple" xlink:href="\\1">\\1</text:a>#{@brace_url.xml_close}}) #http ftp matches with decoration + dob.obj= if dob.is==:para \ and dob.indent.to_s =~/[0-9]/ \ and dob.indent == dob.hang %{<text:p text:style-name="P_indent_#{dob.indent}">#{dob.obj}#{p_num}</text:p>} - elsif dob.is=='para' \ + elsif dob.is==:para \ and dob.hang.to_s =~/[0-9]/ \ and dob.indent != dob.hang %{<text:p text:style-name="P_h#{dob.hang}_i#{dob.indent}">#{dob.obj}#{p_num}</text:p>} @@ -320,7 +320,7 @@ module SiSU_ODF def fontface(dob) end def footnote_urls(str) - str.gsub!(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/, + str=str.gsub(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/, %{#{@brace_url.xml_open}<text:a xlink:type="simple" xlink:href="\\1">\\1</text:a>#{@brace_url.xml_close}}) str=text_link(str) if str =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/ str=text_link_relative(str) if str =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/ @@ -334,11 +334,11 @@ module SiSU_ODF @astx||=10000 @astxs||=20000 if str =~/#{Mx[:en_a_o]}\d+\s+/ - str.gsub!(/#{Mx[:en_a_o]}(\d+)\s+(.+?)#{Mx[:en_a_c]}/,'<text:note text:id="ftn\1" text:note-class="footnote"><text:note-citation>\1</text:note-citation><text:note-body><text:p text:style-name="Footnote"> \2</text:p><text:p text:style-name="Footnote"/></text:note-body></text:note>') + str=str.gsub(/#{Mx[:en_a_o]}(\d+)\s+(.+?)#{Mx[:en_a_c]}/,'<text:note text:id="ftn\1" text:note-class="footnote"><text:note-citation>\1</text:note-citation><text:note-body><text:p text:style-name="Footnote"> \2</text:p><text:p text:style-name="Footnote"/></text:note-body></text:note>') end if str =~/#{Mx[:en_a_o]}([*]+)\s+/ a=$1.gsub(/([*])/,"\\\\\\1") - str.gsub!(/#{Mx[:en_a_o]}([*]+)\s+(.+?)#{Mx[:en_a_c]}/,%{<text:note text:id="ftn#{@astx.to_s}" text:note-class="footnote"><text:note-citation text:label="\\1">\\1</text:note-citation><text:note-body><text:p text:style-name="Footnote"> \\2</text:p><text:p text:style-name="Footnote"/></text:note-body></text:note>}) + str=str.gsub(/#{Mx[:en_a_o]}([*]+)\s+(.+?)#{Mx[:en_a_c]}/,%{<text:note text:id="ftn#{@astx.to_s}" text:note-class="footnote"><text:note-citation text:label="\\1">\\1</text:note-citation><text:note-body><text:p text:style-name="Footnote"> \\2</text:p><text:p text:style-name="Footnote"/></text:note-body></text:note>}) @astxs+=1 end if str=~/#{Mx[:en_a_o]}[*+]+\s/ @@ -347,7 +347,7 @@ module SiSU_ODF a=x[0].gsub(/([*+])/,"\\\\\\1") str=group_clean(str) str=footnote_urls(str) - str.gsub!(/#{Mx[:en_a_o]}(#{a})\s+(.+?)#{Mx[:en_a_c]}/,%{<text:note text:id="ftn#{@astx.to_s}" text:note-class="footnote"><text:note-citation text:label="\\1">\\1</text:note-citation><text:note-body><text:p text:style-name="Footnote"> \\2</text:p><text:p text:style-name="Footnote"/></text:note-body></text:note>}) + str=str.gsub(/#{Mx[:en_a_o]}(#{a})\s+(.+?)#{Mx[:en_a_c]}/,%{<text:note text:id="ftn#{@astx.to_s}" text:note-class="footnote"><text:note-citation text:label="\\1">\\1</text:note-citation><text:note-body><text:p text:style-name="Footnote"> \\2</text:p><text:p text:style-name="Footnote"/></text:note-body></text:note>}) @astx+=1 end end @@ -357,7 +357,7 @@ module SiSU_ODF a=x[0].gsub(/([*+])/,"\\\\\\1") str=group_clean(str) str=footnote_urls(str) - str.gsub!(/#{Mx[:en_b_o]}(#{a})\s+(.+?)#{Mx[:en_b_c]}/,%{<text:note text:id="ftn#{@astx.to_s}" text:note-class="footnote"><text:note-citation text:label="\\1">\\1</text:note-citation><text:note-body><text:p text:style-name="Footnote"> \\2</text:p><text:p text:style-name="Footnote"/></text:note-body></text:note>}) + str=str.gsub(/#{Mx[:en_b_o]}(#{a})\s+(.+?)#{Mx[:en_b_c]}/,%{<text:note text:id="ftn#{@astx.to_s}" text:note-class="footnote"><text:note-citation text:label="\\1">\\1</text:note-citation><text:note-body><text:p text:style-name="Footnote"> \\2</text:p><text:p text:style-name="Footnote"/></text:note-body></text:note>}) @astx+=1 end end @@ -368,12 +368,11 @@ module SiSU_ODF t_o end def group_clean(str) - str.gsub!(/&nbsp;| |#{Mx[:nbsp]}/,' ') - str.gsub!(/</,'<'); str.gsub!(/>/,'>') - str.gsub!(/<(text:span text:style-name="Span_\S+?"|\/text:span)>/,'<\1>') #works, not ideal - str.gsub!(/#{Mx[:br_line]}/,'<br />') - str.gsub!(/<br(?:\s+\/)?>/,'<br />') - str + str=str.gsub(/&nbsp;| |#{Mx[:nbsp]}/,' '). + gsub(/</,'<').gsub(/>/,'>'). + gsub(/<(text:span text:style-name="Span_\S+?"|\/text:span)>/,'<\1>'). #works, not ideal + gsub(/#{Mx[:br_line]}/,'<br />'). + gsub(/<br(?:\s+\/)?>/,'<br />') end def poem(dob,p_num) #P4 #same as group parray=[] @@ -388,19 +387,19 @@ module SiSU_ODF end def group(dob,p_num) #P4 #same as verse parray=[] - dob.obj.gsub!(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/, - '<text:a xlink:type="simple" xlink:href="\1">\1</text:a>') #http ftp matches escaped, no decoration - dob.obj.gsub!(/#{Mx[:url_o]}([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)#{Mx[:url_c]}/, - %{#{@brace_url.xml_open}<text:a xlink:type="simple" xlink:href="mailto:\\1">\\1</text:a>#{@brace_url.xml_close}}) - dob.obj.gsub!(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/, - %{#{@brace_url.xml_open}<text:a xlink:type="simple" xlink:href="\\1">\\1</text:a>#{@brace_url.xml_close}}) #http ftp matches with decoration + dob.obj=dob.obj.gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/, + '<text:a xlink:type="simple" xlink:href="\1">\1</text:a>'). #http ftp matches escaped, no decoration + gsub(/#{Mx[:url_o]}([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)#{Mx[:url_c]}/, + %{#{@brace_url.xml_open}<text:a xlink:type="simple" xlink:href="mailto:\\1">\\1</text:a>#{@brace_url.xml_close}}). + gsub(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/, + %{#{@brace_url.xml_open}<text:a xlink:type="simple" xlink:href="\\1">\\1</text:a>#{@brace_url.xml_close}}) #http ftp matches with decoration dob.obj.split(/#{Mx[:br_line]}|#{Mx[:br_nl]}/).each do |parablock| parablock=group_clean(parablock) - parablock.gsub!(/<text:a xlink:type="simple" xlink:href="(.+?)">/m,'<text:a xlink:type="simple" xlink:href="\1">') - parablock.gsub!(/<(\/text:a)>/,'<\1>') - parablock.gsub!(/<(text:note text:id=.+?)>/,'<\1>') - parablock.gsub!(/<(text:p text:style-name="Footnote")>/,'<\1>') - parablock.gsub!(/<(\/?text:(?:note-citation|note-body|note|p))>/,'<\1>') + parablock=parablock.gsub(/<text:a xlink:type="simple" xlink:href="(.+?)">/m,'<text:a xlink:type="simple" xlink:href="\1">'). + gsub(/<(\/text:a)>/,'<\1>'). + gsub(/<(text:note text:id=.+?)>/,'<\1>'). + gsub(/<(text:p text:style-name="Footnote")>/,'<\1>'). + gsub(/<(\/?text:(?:note-citation|note-body|note|p))>/,'<\1>') parablock=footnote(parablock) parray << %{<text:p text:style-name="P_group">#{parablock}</text:p>} if parablock =~/\S+/ end @@ -411,19 +410,19 @@ module SiSU_ODF end def block(dob,p_num) #P4 #same as verse parray=[] - dob.obj.gsub!(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/, - '<text:a xlink:type="simple" xlink:href="\1">\1</text:a>') #http ftp matches escaped, no decoration - dob.obj.gsub!(/#{Mx[:url_o]}([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)#{Mx[:url_c]}/, - %{#{@brace_url.xml_open}<text:a xlink:type="simple" xlink:href="mailto:\\1">\\1</text:a>#{@brace_url.xml_close}}) - dob.obj.gsub!(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/, - %{#{@brace_url.xml_open}<text:a xlink:type="simple" xlink:href="\\1">\\1</text:a>#{@brace_url.xml_close}}) #http ftp matches with decoration + dob.obj=dob.obj.gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/, + '<text:a xlink:type="simple" xlink:href="\1">\1</text:a>'). #http ftp matches escaped, no decoration + gsub(/#{Mx[:url_o]}([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)#{Mx[:url_c]}/, + %{#{@brace_url.xml_open}<text:a xlink:type="simple" xlink:href="mailto:\\1">\\1</text:a>#{@brace_url.xml_close}}). + gsub(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/, + %{#{@brace_url.xml_open}<text:a xlink:type="simple" xlink:href="\\1">\\1</text:a>#{@brace_url.xml_close}}) #http ftp matches with decoration dob.obj.split(/#{Mx[:br_line]}|#{Mx[:br_nl]}/).each do |parablock| parablock=group_clean(parablock) - parablock.gsub!(/<text:a xlink:type="simple" xlink:href="(.+?)">/m,'<text:a xlink:type="simple" xlink:href="\1">') - parablock.gsub!(/<(\/text:a)>/,'<\1>') - parablock.gsub!(/<(text:note text:id=.+?)>/,'<\1>') - parablock.gsub!(/<(text:p text:style-name="Footnote")>/,'<\1>') - parablock.gsub!(/<(\/?text:(?:note-citation|note-body|note|p))>/,'<\1>') + parablock=parablock.gsub(/<text:a xlink:type="simple" xlink:href="(.+?)">/m,'<text:a xlink:type="simple" xlink:href="\1">'). + gsub(/<(\/text:a)>/,'<\1>'). + gsub(/<(text:note text:id=.+?)>/,'<\1>'). + gsub(/<(text:p text:style-name="Footnote")>/,'<\1>'). + gsub(/<(\/?text:(?:note-citation|note-body|note|p))>/,'<\1>') parablock=footnote(parablock) parray << %{<text:p text:style-name="P_group">#{parablock}</text:p>} if parablock =~/\S+/ end @@ -433,14 +432,14 @@ module SiSU_ODF dob end def code(dob,p_num) #P5 - if dob.is=='code' - dob.obj.gsub!(/\s\s/,'  ') + if dob.is==:code + dob.obj=dob.obj.gsub(/\s\s/,'  ') parray=[] dob.obj.split(/#{Mx[:br_line]}|#{Mx[:br_nl]}/).each do |parablock| parablock=group_clean(parablock) - parablock.gsub!(/^\s*$/,'<br />') - parablock.gsub!(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/, - '<text:a xlink:type="simple" xlink:href="\1">\1</text:a>') #http ftp matches escaped, no decoration + parablock=parablock.gsub(/^\s*$/,'<br />'). + gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/, + '<text:a xlink:type="simple" xlink:href="\1">\1</text:a>') #http ftp matches escaped, no decoration parray << %{<text:p text:style-name="P_code">#{parablock}</text:p>} if parablock =~/\S+/ end dob.obj=parray.join \ @@ -450,15 +449,15 @@ module SiSU_ODF dob end def table(dob,p_num) # - if dob.is =='table' - table=SiSU_ODF_format::Table.new(@md,dob,p_num) + if dob.is ==:table + table=SiSU_ODF_Format::Table.new(@md,dob,p_num) dob=table.table end dob end def obj_break(dob) - if dob.is =='break' - br=SiSU_ODF_format::Format_obj_break.new(@md,dob) + if dob.is ==:break + br=SiSU_ODF_Format::FormatObjBreak.new(@md,dob) if dob.obj==Mx[:br_page] \ or dob.obj==Mx[:br_page_new] dob=br.br_page @@ -470,7 +469,7 @@ module SiSU_ODF end def odf_structure(md,dob) @md,@dob=md,dob - dob=if dob.is !='code' + dob=if dob.is !=:code dob=image(dob) if dob.obj =~/#{Mx[:lnk_o]}[ ]*\S+?\.(?:png|jpg|gif)\s.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/ dob=text_link(dob) if dob.obj =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/ dob=text_link_relative(dob) if dob.obj =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/ @@ -482,24 +481,24 @@ module SiSU_ODF if dob.is !~/(^#{Rx[:meta]}|#{Mx[:br_eof]}|#{Mx[:br_endnotes]})/ if defined? dob.ocn \ and not dob.ocn.nil? - p_num=SiSU_ODF_format::Paragraph_number.new(dob.ocn).display + p_num=SiSU_ODF_Format::ParagraphNumber.new(dob.ocn).display end end end dob=footnote(dob) - if dob.is=='heading' + if dob.is==:heading @@odf[:body] << heading(dob,p_num).obj << @br*2 - elsif dob.is =='verse' + elsif dob.is ==:verse @@odf[:body] << poem(dob,p_num).obj << @br*2 - elsif dob.is=='group' + elsif dob.is==:group @@odf[:body] << group(dob,p_num).obj << @br*2 - elsif dob.is=='block' + elsif dob.is==:block @@odf[:body] << block(dob,p_num).obj << @br*2 - elsif dob.is=='code' + elsif dob.is==:code @@odf[:body] << code(dob,p_num).obj << @br*2 - elsif dob.is=='table' #elsif dob.obj =~ /<!Th?¡/u + elsif dob.is==:table #elsif dob.obj =~ /<!Th?¡/u @@odf[:body] << table(dob,p_num).obj << @br*2 - elsif dob.is=='break' + elsif dob.is==:break @@odf[:body] << obj_break(dob).obj << @br*2 else @@odf[:body] << normal(dob,p_num).obj << @br*2 # main text, contents, body KEEP @@ -511,7 +510,7 @@ module SiSU_ODF end def markup(data) # Used for major markup instructions safe_characters=/[^a-zA-Z0-9}{\/?,."';:)(><\-_&!@%~#\]\[*=$| \n+`#{Mx[:tc_p]}]/u - dir=SiSU_Env::Info_env.new(@md.fns) + dir=SiSU_Env::InfoEnv.new(@md.fns) dir.path.odt_bld @data_mod,@endnotes,@level,@cont,@copen,@odf_contents_close=Array.new(6){[]} @rcdc=false @@ -528,18 +527,18 @@ module SiSU_ODF #p dob.obj if dob.obj =~safe_characters and @md.opt.cmd =~/V/ #KEEP dob.obj='' if dob.obj =~/#{Mx[:lv_o]}\d+:.*?#{Mx[:lv_c]}.+?#{Mx[:pa_non_object_dummy_heading]}/ #fix Mx[:lv_o] para_array=[] - dob.obj.gsub!(/</,'<'); dob.obj.gsub!(/>/,'>') + dob.obj=dob.obj.gsub(/</,'<').gsub(/>/,'>') word=dob.obj.scan(/\S+|\n/) if word word.each do |w| # _ - / # | : ! ^ ~ unless dob =~/^(?:#{Rx[:meta]}|%+ )/m - w.gsub!(/&#(?:126|152);/,'~') #126 usual - w.gsub!(/ /,' ') + w=w.gsub(/&#(?:126|152);/,'~'). #126 usual + gsub(/ /,' ') if w !~/(?:&\S{2,7}?;)+/ - w.gsub!(/&/,'&') + w=w.gsub(/&/,'&') end if w !~/&\S{1,7}?;(?:&\S{1,7}?;)+/ #imperfect - w.gsub!(/(&\S{1,7};)+&/,'\1&') + w=w.gsub(/(&\S{1,7};)+&/,'\1&') end end para_array << w @@ -547,65 +546,73 @@ module SiSU_ODF dob.obj=para_array.join(' ') dob.obj=dob.obj.strip end - if dob.is=='code' #{Mx[:gr_o]}code#{Mx[:gr_c]}/ #fix #code-block: angle brackets special characters #fix - dob.obj.gsub!(/(^|[^}])_(?:<|<)/m,'\1<'); dob.obj.gsub!(/(^|[^}])_(?:>|>)/m,'\1>') - dob.obj.gsub!(/(^|[^}])_(?:<|<)/m,'\1<'); dob.obj.gsub!(/(^|[^}])_(?:>|>)/m,'\1>') + if dob.is==:code #{Mx[:gr_o]}code#{Mx[:gr_c]}/ #fix #code-block: angle brackets special characters #fix + dob.obj=dob.obj.gsub(/(^|[^}])_(?:<|<)/m,'\1<').gsub(/(^|[^}])_(?:>|>)/m,'\1>'). + gsub(/(^|[^}])_(?:<|<)/m,'\1<').gsub(/(^|[^}])_(?:>|>)/m,'\1>') end - if dob.of=='block' - dob.obj.gsub!(/#{Mx[:gl_bullet]}/,'● ') + if dob.of==:block + dob.obj=dob.obj.gsub(/#{Mx[:gl_bullet]}/,'● ') end - dob.obj.gsub!(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'<del>\1</del>') - dob.obj.gsub!(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'<ins>\1</ins>') - dob.obj.gsub!(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'<cite>\1</cite>') - dob.obj.gsub!(/#{Mx[:tag_o]}\S+?#{Mx[:tag_c]}/,'') #check - dob.obj.gsub!(/#{Mx[:mk_o]}#([a-zA-Z]+)#{Mx[:mk_c]}/,'&\1;') - dob.obj.gsub!(/#{Mx[:mk_o]}(#[0-9]+)#{Mx[:mk_c]}/,'&\1;') - dob.obj.gsub!(/#{Mx[:mk_o]}[~-]##{Mx[:mk_c]}/,'') - if dob.is=='para' \ + dob.obj=dob.obj.gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'<del>\1</del>'). + gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'<ins>\1</ins>'). + gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'<cite>\1</cite>'). + gsub(/#{Mx[:tag_o]}\S+?#{Mx[:tag_c]}/,''). #check + gsub(/#{Mx[:mk_o]}#([a-zA-Z]+)#{Mx[:mk_c]}/,'&\1;'). + gsub(/#{Mx[:mk_o]}(#[0-9]+)#{Mx[:mk_c]}/,'&\1;'). + gsub(/#{Mx[:mk_o]}[~-]##{Mx[:mk_c]}/,'') + if dob.is==:para \ and dob.bullet_ dob.obj='<draw:frame draw:style-name="gr1" text:anchor-type="as-char" svg:width="0.22cm" svg:height="0.22cm" draw:z-index="2"><draw:image xlink:href="Pictures/bullet_09.png" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/></draw:frame> ' + dob.obj end - dob.obj.gsub!(/#{Mx[:br_line]}/,'<br />') - dob.obj.gsub!(/©/,'©') #too arbitrary - dob.obj.gsub!(/.+?<-#>/,'') # remove dummy headings (used by html) #check - dob.obj.gsub!(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/, - '<text:span text:style-name="Span_bold">\1</text:span>') - dob.obj.gsub!(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/, - '<text:span text:style-name="Span_italic">\1</text:span>') - dob.obj.gsub!(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/, - '<text:span text:style-name="Span_underscore">\1</text:span>') - dob.obj.gsub!(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/, - '<text:span text:style-name="Span_superscript">\1</text:span>') - dob.obj.gsub!(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/, - '<text:span text:style-name="Span_subscript">\1</text:span>') - dob.obj.gsub!(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/, - '<text:span text:style-name="Span_monospace">\1</text:span>') - dob.obj.gsub!(//u,'-') - dob.obj.gsub!(/ /u, ' ') # space identify - dob.obj.gsub!(/ /u, ' ') # space identify - dob.obj.gsub!(/·/u,'*') - dob.obj.gsub!(/[–—]/u,'-') #— – chk - dob.obj.gsub!(/ < /i,'<') - dob.obj.gsub!(/\\copy(?:right)?\b/,'©') - dob.obj.gsub!(/\\trademark\b|\\tm\b/,'®') - dob.obj.gsub!(/\44/,'$') #$ watch - dob.obj.gsub!(/<a href=".+?">(.+?)<\/a>/,'\1') - dob.obj.gsub!(/#{Mx[:mk_o]}name#\S+?#{Mx[:mk_c]}/,'') # remove name links + dob.obj=dob.obj.gsub(/#{Mx[:br_line]}/,'<br />'). + gsub(/©/,'©'). #too arbitrary + gsub(/.+?<-#>/,''). # remove dummy headings (used by html) #check + gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/, + '<text:span text:style-name="Span_bold">\1</text:span>'). + gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/, + '<text:span text:style-name="Span_italic">\1</text:span>'). + gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/, + '<text:span text:style-name="Span_underscore">\1</text:span>'). + gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/, + '<text:span text:style-name="Span_superscript">\1</text:span>'). + gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/, + '<text:span text:style-name="Span_subscript">\1</text:span>'). + gsub(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/, + '<text:span text:style-name="Span_monospace">\1</text:span>'). + gsub(//u,'-'). + gsub(/ /u, ' '). # space identify + gsub(/ /u, ' '). # space identify + gsub(/·/u,'*'). + gsub(/[–—]/u,'-'). #— – chk + gsub(/ < /i,'<'). + gsub(/\\copy(?:right)?\b/,'©'). + gsub(/\\trademark\b|\\tm\b/,'®'). + gsub(/\44/,'$'). #$ watch + gsub(/<a href=".+?">(.+?)<\/a>/,'\1'). + gsub(/#{Mx[:mk_o]}name#\S+?#{Mx[:mk_c]}/,'') # remove name links wordlist=dob.obj.scan(/\S+/) dob.obj=tidywords(wordlist).join(' ').strip @rcdc=true if @rcdc==false \ 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]})/ + if dob.is !~/(^#{Rx[:meta]}|#{Mx[:br_eof]}|#{Mx[:br_endnotes]})/ #check if defined? dob.ocn and dob.ocn =~/\d+/ - @p_num=SiSU_ODF_format::Paragraph_number.new(dob.ocn) + @p_num=SiSU_ODF_Format::ParagraphNumber.new(dob.ocn) end - if dob.is=~/heading|para|group|verse|code|table|break/ # extend, include other types + if dob.is ==:heading \ + || dob.is ==:para \ + || dob.is ==:group \ + || dob.is ==:verse \ + || dob.is ==:code \ + || dob.is ==:table \ + || dob.is ==:break odf_structure(@md,dob) end - dob.obj.gsub!(/<!.+!>/,' ') if dob.obj ## Clean Prepared Text - dob.obj.gsub!(/#{Mx[:tc_o]}.+?#{Mx[:tc_c]}/,' ') if dob.obj ## CHECK Clean Prepared Text - dob.obj.gsub!(/<:\S+>/,' ') if dob.obj ## Clean Prepared Text + if dob.obj ## Clean Prepared Text + dob.obj=dob.obj.gsub(/<!.+!>/,' '). + gsub(/#{Mx[:tc_o]}.+?#{Mx[:tc_c]}/,' '). + gsub(/<:\S+>/,' ') + end end end end @@ -637,8 +644,8 @@ module SiSU_ODF <style:style style:name="Table2.M" style:family="table-column"><style:table-column-properties style:column-width="1.307" style:rel-column-width="5041*"/></style:style> <style:style style:name="Table2.N" style:family="table-column"><style:table-column-properties style:column-width="1.214cm" style:rel-column-width="4681*"/></style:style> WOK - x.strip! - x.gsub!(/\n+/m,'') unless @md.opt.cmd=~/M/ + x=x.strip + x=x.gsub(/\n+/m,'') unless @md.opt.cmd=~/M/ x else '' end @@ -660,8 +667,8 @@ WOK <office:forms form:automatic-focus="false" form:apply-design-mode="false"/> <text:sequence-decls><text:sequence-decl text:display-outline-level="0" text:name="Illustration"/><text:sequence-decl text:display-outline-level="0" text:name="Table"/><text:sequence-decl text:display-outline-level="0" text:name="Text"/><text:sequence-decl text:display-outline-level="0" text:name="Drawing"/></text:sequence-decls> WOK - x.strip! - x.gsub!(/\n+/m,'') unless @md.opt.cmd=~/M/ + x=x.strip + x=x.gsub(/\n+/m,'') unless @md.opt.cmd=~/M/ @@odf[:head] << x end def post @@ -675,7 +682,7 @@ WOK content << @@odf[:body] content << @@odf[:metadata] content << @@odf[:tail] - Output.new(content,@md,@env).odf + SiSU_ODF::Source::Output.new(content,@md,@env).odf @@odf[:head],@@odf[:body],@@odf[:tail],@@odf[:metadata]=[],[],[],[] end end @@ -684,9 +691,9 @@ WOK @content,@md,@env=content,md,env end def odf #%odf output - env=SiSU_Env::SiSU_file.new(@md) + env=SiSU_Env::FileOp.new(@md) env.mkdir - header=SiSU_ODF_format::ODT_head_1_2.new(@md) + header=SiSU_ODF_Format::ODT_Head_1_2.new(@md) filename="#{@env.processing_path.odt}/manifest.rdf" od=File.new(filename,'w+') od << header.manifest_rdf diff --git a/lib/sisu/v3/odf_format.rb b/lib/sisu/v3/odf_format.rb index bf44613b..c6d4b504 100644 --- a/lib/sisu/v3/odf_format.rb +++ b/lib/sisu/v3/odf_format.rb @@ -56,11 +56,11 @@ ** Description: opendocument formatting, default opendocument template =end -module SiSU_ODF_format +module SiSU_ODF_Format require_relative 'param' # param.rb include SiSU_Param include SiSU_Viz - class Paragraph_number + class ParagraphNumber def initialize(paranum) @paranum=/(\d+)/m.match(paranum.to_s)[1] end @@ -74,7 +74,7 @@ module SiSU_ODF_format @paranum.gsub(/(\d+)/,'<a href="#\1">') end end - class Format_text_object + class FormatTextObject def initialize(md,t_o) @md,@t_o=md,t_o if t_o.class==Hash @@ -84,8 +84,8 @@ module SiSU_ODF_format p caller end rgx=/#{Mx[:en_a_o]}\d+\s+(.+?)#{Mx[:en_a_c]}/ - @txt.gsub!(rgx,'\1') if @txt =~rgx - @vz=SiSU_Env::Get_init.instance.skin + @txt=@txt.gsub(rgx,'\1') if @txt =~rgx + @vz=SiSU_Env::GetInit.instance.skin end def scr_endnote_body "<endnote>#{@txt}</endnote> " @@ -110,7 +110,7 @@ module SiSU_ODF_format def initialize(md,dob,p_num) @md,@dob,@p_num=md,dob,p_num @txt=dob.obj - @vz=SiSU_Env::Get_init.instance.skin + @vz=SiSU_Env::GetInit.instance.skin if @md.fns != @@fns @@table_counter=0 @@fns=@md.fns @@ -150,7 +150,7 @@ module SiSU_ODF_format 'Table_Heading' else 'P_table_cell' end - str.gsub!(/^~$/,'') # tilde / empty cell + str=str.gsub(/^~$/,'') # tilde / empty cell %{<table:table-cell office:value-type="string">#{@br}} + %{<text:p text:style-name="#{txt_name_cell}">#{@br}} + %{#{str}} + @@ -180,7 +180,7 @@ module SiSU_ODF_format row='' if row =~/^<!$/ m=row[/<!f(.+?)!>/,1] @@tablefoot << m if m - row.gsub!(/<!f.+?!>/,'') + row=row.gsub(/<!f.+?!>/,'') @cells=[] row.split(/\s*#{Mx[:tc_p]}/).each do |cell| @cells << table_tag_cell(cell,i) @@ -200,7 +200,7 @@ module SiSU_ODF_format @dob end end - class ODT_head_1_2 + class ODT_Head_1_2 def initialize(md) @md=md @generator="#{@md.sisu_version[:project]} #{@md.sisu_version[:version]} #{@md.sisu_version[:date_stamp]} (#{@md.sisu_version[:date]})" @@ -226,8 +226,8 @@ module SiSU_ODF_format </rdf:Description> </rdf:RDF> WOK - x.strip! - x.gsub!(/\n+/m,'') unless @md.opt.cmd=~/M/ + x=x.strip + x=x.gsub(/\n+/m,'') unless @md.opt.cmd=~/M/ x end def meta_inf_manifest_xml(md) @@ -256,8 +256,8 @@ WOK <manifest:file-entry manifest:media-type="application/vnd.sun.xml.ui.configuration" manifest:full-path="Configurations2/"/> </manifest:manifest> WOK - x.strip! - x.gsub!(/\n+/m,'') unless @md.opt.cmd=~/M/ + x=x.strip + x=x.gsub(/\n+/m,'') unless @md.opt.cmd=~/M/ x end def meta_xml @@ -272,8 +272,8 @@ WOK </office:meta> </office:document-meta> WOK - x.strip! - x.gsub!(/\n+/m,'') unless @md.opt.cmd=~/M/ + x=x.strip + x=x.gsub(/\n+/m,'') unless @md.opt.cmd=~/M/ x end def settings_xml @@ -375,8 +375,8 @@ WOK </office:settings> </office:document-settings> WOK - x.strip! - x.gsub!(/\n+/m,'') unless @md.opt.cmd=~/M/ + x=x.strip + x=x.gsub(/\n+/m,'') unless @md.opt.cmd=~/M/ x end def styles_xml @@ -576,18 +576,18 @@ WOK </office:master-styles> </office:document-styles> WOK - x.strip! - x.gsub!(/\n+/m,'') unless @md.opt.cmd=~/M/ + x=x.strip + x=x.gsub(/\n+/m,'') unless @md.opt.cmd=~/M/ x end def mimetype x=<<WOK application/vnd.oasis.opendocument.text WOK - x.strip! + x=x.strip end end - class Format_obj_break + class FormatObjBreak def initialize(md,t_o) @md,@t_o=md,t_o end diff --git a/lib/sisu/v3/options.rb b/lib/sisu/v3/options.rb index c594aac4..11d03e1d 100644 --- a/lib/sisu/v3/options.rb +++ b/lib/sisu/v3/options.rb @@ -57,7 +57,7 @@ parsing =end -module SiSU_commandline +module SiSU_Commandline require "pathname" require_relative 'sysenv' # sysenv.rb @@base_path=nil @@ -66,9 +66,9 @@ module SiSU_commandline def initialize(a) @cmd,@f_pth,@pth,@fns,@fnb,@fnc,@fncb,@what,@lng,@lng_base,@base_path,@base_stub,@sub_location='','','','','','','','','','','','','' @f_pths,@files,@paths,@mod,@act=Array.new(5){[]} - @env=SiSU_Env::Info_env.new + @env=SiSU_Env::InfoEnv.new @lng_base=@env.language_default_set - @dir_structure_by=SiSU_Env::Env_call.new.output_dir_structure.by? + @dir_structure_by=SiSU_Env::EnvCall.new.output_dir_structure.by? @@base_path ||=Dir.pwd @base_path=@@base_path r=Px[:lng_lst].join('|') @@ -87,7 +87,8 @@ module SiSU_commandline x << Dir.glob("#{d}/*.ss[tm]") end end - opt + x.flatten! + x=x.flatten + opt + x end end def find_select(find_flag,opt) @@ -112,8 +113,8 @@ module SiSU_commandline end end end - x.flatten! - end + x.flatten + end end def sisu_glob_rules(a) a=if a.inspect =~/"-[A-Za-z0-9]*[fG]/ \ @@ -140,7 +141,7 @@ module SiSU_commandline end end r=Px[:lng_lst].join('|') - r.gsub!(/\|#{@lng_base}\|/,'|') + r=r.gsub(/\|#{@lng_base}\|/,'|') @lang_regx=%r{(?:#{r})} z=if find_flag (f.length > 0) \ @@ -182,13 +183,13 @@ module SiSU_commandline if @files.length > 0 \ and @cmd.empty? \ and @mod.length==0 #% if no other action called on filename given, default is sisu --v3 -0 [filename(s)] configured as flag default - shortcut=SiSU_Env::Info_processing_flag.new + shortcut=SiSU_Env::InfoProcessingFlag.new @mod=['--v3'] @cmd=shortcut.cf_0 + 'm' end SiSU_Screen::Ansi.new(@cmd,"\tsisu " + @cmd + ' ' + @mod.join(' ') + ' ' + @files.join(' ') + "\n").print_brown if @cmd =~/[vVM]/ end -# @files.uniq! +# @files=@files.uniq @act=opt_act @files self @@ -229,7 +230,7 @@ module SiSU_commandline fn = (y[r_f,1]) \ ? y[r_f,1] : y - fn.gsub!(/\.((?:ssm\.)?sst)/,'.-\1') + fn=fn.gsub(/\.((?:ssm\.)?sst)/,'.-\1') fullname=Dir.pwd + '/' + fn pt=Pathname.new(fullname) pth << Dir.pwd @@ -304,7 +305,7 @@ module SiSU_commandline { cmd: c, mod: m, what: w, paths: pth, files: f, f_pths: f_pths, lng: lng, lngs: lngs } end def expand_numeric_shortcuts(a) - shortcut=SiSU_Env::Info_processing_flag.new + shortcut=SiSU_Env::InfoProcessingFlag.new s='' a.each do |x| y=case x @@ -361,6 +362,7 @@ module SiSU_commandline when /^--(?:xhtml)$/; c=c+'b' when /^--(?:xml-sax)$/; c=c+'x' when /^--(?:xml-dom)$/; c=c+'X' + when /^--(?:images)$/; c=c+'j' when /^--(?:hash-digests)$/; c=c+'N' when /^--(?:po4a|pot?)$/; c=c+'P' when /^--(?:termsheet)$/; c=c+'T' @@ -388,7 +390,7 @@ module SiSU_commandline end ca=[] unless c.empty? - c.gsub!(/-/,'') + c=c.gsub(/-/,'') c.scan(/CC|\S/) {|x| ca << x} cmd= '-' + ca.uniq.join end @@ -405,6 +407,13 @@ module SiSU_commandline else '' end end + if cmd !~/j/ + extra+=if cmd =~/[bHhwXxyz]/ \ + and cmd !~/[j]/ + 'j' #% copy images + else '' + end + end if cmd !~/y/ extra+=if cmd =~/[abeHhIiNopsSstwXxz]/ \ and cmd !~/y/ @@ -426,31 +435,47 @@ module SiSU_commandline act={} act[:license]=(cmd =~/L/ \ || mod.inspect =~/"--license/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:site_init]=(cmd =~/C/ \ || mod.inspect =~/"--init-site/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:rc]=if mod.inspect =~/"--rc=/ x=Dir.pwd + '/' + mod.join.gsub(/--rc=/,'') - { bool: true, inst: x } + { bool: true, set: :on, inst: x } + else + { bool: false, set: :na, inst: '' } + end + act[:dump]=if mod.inspect =~/"--dump=/ + base_pth=mod.join(';').gsub(/^.*--dump=['"]?(.+?)(?:['"]?;.+)?$/,'\1') + { bool: true, set: :on, inst: base_pth } + elsif mod.inspect =~/"--dump/ + { bool: true, set: :on, inst: @base_path } else - { bool: false, inst: '' } + { bool: false, set: :na, inst: nil } + end + act[:redirect]=if mod.inspect =~/"--redirect=/ + base_pth=mod.join(';').gsub(/^.*--redirect=['"]?(.+?)(?:['"]?;.+)?$/,'\1') + { bool: true, set: :on, inst: base_pth } + elsif mod.inspect =~/"--redirect/ + { bool: true, set: :on, inst: @base_path } + else + { bool: false, set: :na, inst: nil } end act[:verbose]=(cmd =~/v/ \ || mod.inspect =~/"--verbose"/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:quiet]=(cmd =~/q/ \ || mod.inspect =~/"--quiet"/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:color_state]=if mod.inspect =~/"--color-on"|"--color"/ - { bool: true } + { bool: true, set: :on } elsif mod.inspect =~/"--color-off"/ - { bool: false } - else { bool: true } #fix default color + { bool: false, set: :off } + else { bool: true, set: :na } #fix default color end # act[:color_toggle]=if cmd =~/c/ \ # or mod.inspect =~/"--color-toggle"/ @@ -459,138 +484,259 @@ module SiSU_commandline # end act[:maintenance]=(cmd =~/M/ \ || mod.inspect =~/"--maintenance|--keep-processing-files"/) \ - ? { bool: true } - : { bool: false } - act[:ocn]=if mod.inspect =~/"--no-ocn"/ - { bool: false } - else { bool: true } + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:switch]=if mod.inspect =~/"--switch-off=/ + off_list=mod.join(';').gsub(/^.*--switch-off=['"]?(.+?)(?:['"];.+)?$/,'\1') + off_list=off_list.scan(/[^,;\s]+/) + { bool: false, set: :off, off: off_list} + else { bool: true, set: :na, off: [] } + end + act[:ocn]= + if mod.inspect =~/"--inc-ocn"/ + { bool: true, set: :on } + elsif mod.inspect =~/"--(?:exc|no)-ocn"/ \ + || act[:switch][:off].inspect =~/"ocn"/ + { bool: false, set: :off } + else { bool: true, set: :na } + end + act[:toc]=if mod.inspect =~/"--inc-toc"/ + { bool: true, set: :on } + elsif mod.inspect =~/"--(?:exc|no)-toc"/ \ + || act[:switch][:off].inspect =~/"toc"/ + { bool: false, set: :off } + else { bool: true, set: :na } + end + act[:minitoc]=if mod.inspect =~/"--inc-minitoc"/ + { bool: true, set: :on } + elsif mod.inspect =~/"--(?:exc|no)-minitoc"/ \ + || act[:switch][:off].inspect =~/"minitoc"/ + { bool: false, set: :off } + else { bool: true, set: :na } + end + act[:manifest]=if mod.inspect =~/"--inc-manifest"/ + { bool: true, set: :on } + elsif mod.inspect =~/"--(?:exc|no)-manifest"/ \ + || act[:switch][:off].inspect =~/"manifest"/ + { bool: false, set: :off } + else { bool: true, set: :na } + end + act[:links_to_manifest]=if mod.inspect =~/"--inc-links-to-manifest"|"--inc-manifest-links"/ + { bool: true, set: :on } + elsif mod.inspect =~/"--(?:exc|no)-links-to-manifest"|"--(?:exc|no)-manifest-links"/ \ + || act[:switch][:off].inspect =~/"links_to_manifest"|"manifest_links"/ \ + || mod.inspect =~/"--(?:redirect|dump)/ + { bool: false, set: :off } + else { bool: true, set: :na } + end + act[:manifest_minitoc]=if mod.inspect =~/"--inc-manifest-minitoc"|"--inc-minitoc"/ + { bool: true, set: :on } + elsif mod.inspect =~/"--(?:exc|no)-manifest-minitoc"|"--(?:exc|no)-minitoc"/ \ + || act[:switch][:off].inspect =~/"manifest_minitoc"|"minitoc"/ + #|| mod.inspect =~/"--(?:redirect|dump)/ + { bool: false, set: :off } + else { bool: true, set: :na } + end + act[:metadata]=if mod.inspect =~/"--inc-metadata"/ + { bool: true, set: :on } + elsif mod.inspect =~/"--(?:exc|no)-metadata"/ \ + || act[:switch][:off].inspect =~/"metadata"/ + { bool: false, set: :off } + else { bool: true, set: :na } + end + act[:html_minitoc]=if mod.inspect =~/"--inc-html-minitoc"|"--inc-minitoc"/ + { bool: true, set: :on } + elsif mod.inspect =~/"--(?:exc|no)-html-minitoc"|"--(?:exc|no)-minitoc"/ \ + || act[:switch][:off].inspect =~/"html_minitoc"|"minitoc"/ + { bool: false, set: :off } + else { bool: true, set: :na } + end + act[:html_navigation]=if mod.inspect =~/"--inc-html-navigation"|"--inc-navigation"/ + { bool: true, set: :on } + elsif mod.inspect =~/"--(?:exc|no)-html-navigation"|"--(?:exc|no)-navigation"/ \ + || act[:switch][:off].inspect =~/"html_navigation"|"nav"/ + { bool: false, set: :off } + else { bool: true, set: :na } + end + act[:html_navigation_bar]=if mod.inspect =~/"--inc-html-navigation-bar"|"--inc-navigation-bar"/ + { bool: true, set: :on } + elsif mod.inspect =~/"--(?:exc|no)-html-navigation-bar"|"--(?:exc|no)-navigation-bar"/ \ + || act[:switch][:off].inspect =~/"html_navigation_bar"|"navbar"/ + { bool: false, set: :off } + else { bool: true, set: :na } + end + act[:segsubtoc]=if mod.inspect =~/"--inc-segsubtoc"/ + { bool: true, set: :on } + elsif mod.inspect =~/"--(?:exc|no)-segsubtoc"/ \ + || act[:switch][:off].inspect =~/"segsubtoc"/ + { bool: false, set: :off } + else { bool: true, set: :na } + end + act[:search_form]=if mod.inspect =~/"--inc-search-form"/ + { bool: true, set: :on } + elsif mod.inspect =~/"--(?:exc|no)-search-form"/ \ + || act[:switch][:off].inspect =~/"search_form"|"search"/ + { bool: false, set: :off } + else { bool: true, set: :na } + end + act[:html_search_form]=if mod.inspect =~/"--inc-html-search-form"|"--inc-search-form"/ + { bool: true, set: :on } + elsif mod.inspect =~/"--(?:exc|no)-html-search-form"|"--(?:exc|no)-search-form"/ \ + || act[:switch][:off].inspect =~/"html_search_form"|"search_form"|"search"/ + { bool: false, set: :off } + else { bool: true, set: :na } + end + act[:html_right_pane]=if mod.inspect =~/"--inc-html-right-pane"|"--inc-right-pane"|"--inc-html-right-column"|"--inc-right-column"/ + { bool: true, set: :on } + elsif mod.inspect =~/"--(?:exc|no)-html-right-pane"|"--(?:exc|no)-right-pane"|"--(?:exc|no)-html-right-column"|"--(?:exc|no)-right-column"/ \ + || act[:switch][:off].inspect =~/"html_right_pane"|"html_right_column"|"promo"/ + { bool: false, set: :off } + else { bool: true, set: :na } + end + act[:html_top_band]=if mod.inspect =~/"--inc-html-top-band"|"--inc-top-band"/ + { bool: true, set: :on } + elsif mod.inspect =~/"--(?:exc|no)-html-top-band"|"--(?:exc|no)-top-band"/ \ + || act[:switch][:off].inspect =~/"html-top-band"|"top-band"/ + { bool: false, set: :off } + else { bool: true, set: :na } end act[:dal]=(cmd =~/m/ \ || mod.inspect =~/"--dal"/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:html]=(cmd =~/h/ \ || mod.inspect =~/"--html"/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:concordance]=(cmd =~/w/ \ || mod.inspect =~/"--concordance"/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:images]=(cmd =~/j/ \ + || mod.inspect =~/"--images"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:pdf]=(cmd =~/p/ \ || mod.inspect =~/"--pdf"/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:epub]=(cmd =~/e/ \ || mod.inspect =~/"--epub"/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:odt]=(cmd =~/o/ \ || mod.inspect =~/"--odf"/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:xml_sax]=(cmd =~/x/ \ || mod.inspect =~/"--xml-sax"/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:xml_dom]=(cmd =~/X/ \ || mod.inspect =~/"--xml-dom"/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:xhtml]=(cmd =~/b/ \ || mod.inspect =~/"--xhtml"/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:txt]=(cmd =~/[at]/ \ || mod.inspect =~/"--txt"/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:manpage]=(cmd =~/i/ \ || mod.inspect =~/"--manpage"/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:texinfo]=(cmd =~/I/ \ || mod.inspect =~/"--texinfo"/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:fictionbook]=(cmd =~/f/ \ || mod.inspect =~/"--fictionbook"/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:psql]=(cmd =~/D/ \ || mod.inspect =~/"--pg"|"--pgsql"/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:sqlite]=(cmd =~/d/ \ || mod.inspect =~/"--sqlite"/) \ - ? { bool: true } - : { bool: false } + && (mod.inspect =~/"--createdb"|"--create"|"--recreate"|"--dropall"|"--recreate"|"--import"|"--update"|"--remove"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:sqlite_discreet]=(cmd =~/d/ \ + || mod.inspect =~/"--sql"|"--sqlite"/) \ + && (mod.inspect =~/"--both"/ \ + || mod.inspect !~/"--createdb"|"--create"|"--recreate"|"--dropall"|"--recreate"|"--import"|"--update"|"--remove"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:harvest]=(mod.inspect =~/"--harvest"/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:po4a]=(cmd =~/P/ \ || mod.inspect =~/"--po4a"|"--pot?"/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:git]=(cmd =~/g/ \ || mod.inspect =~/"--git"/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:hash_digests]=(cmd =~/N/ \ || mod.inspect =~/"--hash-digests"/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:sample_search_form]=(cmd =~/F/ \ || mod.inspect =~/"--sample-search-form"/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:webrick]=(cmd =~/W/ \ || mod.inspect =~/"--webrick"/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:share_source]=(cmd =~/s/ \ || mod.inspect =~/"--source"/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:sisupod]=(cmd =~/S/ \ || mod.inspect =~/"--sisupod"/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:scp]=(cmd =~/r/ \ || mod.inspect =~/"--scp"/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:rsync]=(cmd =~/R/ \ || mod.inspect =~/"--rsync"/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:delete_output]=(cmd =~/z/ \ || mod.inspect =~/"--delete"|"--zap"/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:urls_all]=(cmd =~/U/ \ || mod.inspect =~/"--urls-all"/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:urls_seleted]=(cmd =~/u/ \ || mod.inspect =~/"--urls"/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:sitemap]=(cmd =~/Y/ \ || mod.inspect =~/"--sitemap"/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:qrcode]=(cmd =~/Q/ \ || mod.inspect =~/"--qrcode"/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:manifest]=(cmd =~/y/ \ || mod.inspect =~/"--manifest"/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:help]=(mod.inspect =~/"--help/) \ - ? { bool: true } - : { bool: false } + ? { bool: true, set: :on } + : { bool: false, set: :na } @act=act end def cmd diff --git a/lib/sisu/v3/param.rb b/lib/sisu/v3/param.rb index 91f77410..5563f780 100644 --- a/lib/sisu/v3/param.rb +++ b/lib/sisu/v3/param.rb @@ -64,7 +64,7 @@ module SiSU_Param require_relative 'param_identify_markup' # param_identify_markup.rb require_relative 'help' # help.rb include SiSU_Help - @@date=SiSU_Env::Info_date.new + @@date=SiSU_Env::InfoDate.new @@proc=@@filename_txt=@@filename_texinfo=@@filename_lout_portrait=@@filename_lout_landscape=@@filename_html_scroll=@@filename_html_index=@@filename_html_segtoc=@@filename_semantic=@@filename_rss=@@newfile=@@drr=nil @doc={ initialise: nil, markup: '', lnks: '', stmp: '', req: {} } @@yaml=@@yamladdr=nil @@ -82,8 +82,8 @@ module SiSU_Param opt.fns else opt.fns.gsub(/\.ssm$/,'.ssm.sst') end - Instantiate.new.param_instantiate - @env=SiSU_Env::Info_env.new(@fns) + SiSU_Param::Instantiate.new.param_instantiate + @env=SiSU_Env::InfoEnv.new(@fns) @pstorefile="#{@env.processing_path.dal}/#{@fns}.pstore" end def get @@ -113,8 +113,8 @@ module SiSU_Param else param_msg='Parameters extracted' fns_array=@env.read_source_file(@opt.fns) - md=Instructions.new(fns_array,@opt) - @md=Instructions.new(fns_array,@opt).extract + md=SiSU_Param::Parameters::Instructions.new(fns_array,@opt) + @md=SiSU_Param::Parameters::Instructions.new(fns_array,@opt).extract @md end if defined? @md.title.main # on removal check problems with -U @@ -126,7 +126,7 @@ module SiSU_Param @@md.opt=@opt @@md end - class Md_default + class MdDefault def rights(author,date) @author,@date=author,date def all @@ -179,7 +179,7 @@ module SiSU_Param end def name_format(name) if name - name.strip! + name=name.strip @name_a_h=[] authors=name.scan(/[^;]+/) authors.each_with_index do |a,i| @@ -776,27 +776,25 @@ module SiSU_Param m=@h['bold'] i=(m=~/\/i$/)? 'i' : '' z=if m - x=m.gsub(/^\/(.+?)\/i?/,'\1') - x.gsub!(/\((?:\?:)?/,'(?:') # avoid need to escape use of brackets within regex provided + x=m.gsub(/^\/(.+?)\/i?/,'\1'). + gsub(/\((?:\?:)?/,'(?:') # avoid need to escape use of brackets within regex provided rgx='\b(' + x + ')\b' y=((i =~/i/) ? (/#{rgx}/i) : (/#{rgx}/)) { str: '\b(?:' + x + ')\b', regx: y, i: i } else nil end - z end def italics m=@h['italics'] i=((m=~/\/i$/) ? 'i' : '') z=if m - x=m.gsub(/^\/(.+?)\/i?/,'\1') - x.gsub!(/\((?:\?:)?/,'(?:') # avoid need to escape use of brackets within regex provided + x=m.gsub(/^\/(.+?)\/i?/,'\1'). + gsub(/\((?:\?:)?/,'(?:') # avoid need to escape use of brackets within regex provided rgx='\b(' + x + ')\b' y=((i =~/i/) ? (/#{rgx}/i) : (/#{rgx}/)) { str: '\b(?:' + x + ')\b', regx: y, i: i } else nil end - z end def emphasis if @h['emphasis'] =~/bold/; 'bold' @@ -813,6 +811,89 @@ module SiSU_Param else nil end end + def omit + m=@h['omit'] + @m=m ? (m.split(/,\s+/)) : nil + def list + @m + end + self + end + def ocn? + (omit.list.inspect =~/"ocn"/) \ + ? :off + : :na + end + def toc? + (omit.list.inspect =~/"toc"/) \ + ? :off + : :na + end + def manifest? + (omit.list.inspect =~/"manifest"/) \ + ? :off + : :na + end + def links_to_manifest? + (omit.list.inspect =~/"manifest_links"|"links_to_manifest"/) \ + ? :off + : :na + end + def metadata? + (omit.list.inspect =~/"metadata"/) \ + ? :off + : :na + end + def minitoc? + (omit.list.inspect =~/"minitoc"/) \ + ? :off + : :na + end + def html_minitoc? + (omit.list.inspect =~/"html_minitoc"/) \ + ? :off + : :na + end + def html_top_band? + (omit.list.inspect =~/"html_top_band"/) \ + ? :off + : :na + end + def html_navigation? + (omit.list.inspect =~/"html_navigation"/) \ + ? :off + : :na + end + def html_navigation_bar? + (omit.list.inspect =~/"html_navigation_bar"/) \ + ? :off + : :na + end + def segsubtoc? + (omit.list.inspect =~/"segsubtoc"/) \ + ? :off + : :na + end + def search_form? + (omit.list.inspect =~/"search_form"/) \ + ? :off + : :na + end + def html_search_form? + (omit.list.inspect =~/"html_search_form"/) \ + ? :off + : :na + end + def html_right_pane? + (omit.list.inspect =~/"html_right_column"|"html_right_pane"/) \ + ? :off + : :na + end + def manifest_minitoc? + (omit.list.inspect =~/"manifest_minitoc"/) \ + ? :off + : :na + end def texpdf_font def main @h['texpdf_font'] \ @@ -863,16 +944,16 @@ module SiSU_Param end end if manpage['name'] - manpage['name']=manpage['name'].join("\n.br\n") - manpage['name'].gsub!(/(-)/m,"\\\\\\1") - manpage['name'].gsub!(/\A/,"\n.br\n.SH NAME\n.br\n") + manpage['name']=manpage['name'].join("\n.br\n"). + gsub(/(-)/m,"\\\\\\1"). + gsub(/\A/,"\n.br\n.SH NAME\n.br\n") else manpage['name']='man page "name/whatis" information not provided, set in header @man: name=[whatis information]' end if manpage['synopsis'] - manpage['synopsis']=manpage['synopsis'].join("\n\n.br\n") - manpage['synopsis'].gsub!(/(-)/m,"\\\\\\1") - manpage['synopsis'].gsub!(/\A/,"\n.br\n.SH SYNOPSIS\n.br\n") + manpage['synopsis']=manpage['synopsis'].join("\n\n.br\n"). + gsub(/(-)/m,"\\\\\\1"). + gsub(/\A/,"\n.br\n.SH SYNOPSIS\n.br\n") else manpage['synopsis']='' end @@ -963,14 +1044,14 @@ module SiSU_Param @flv,@lang,@seg_names,@tags,@tag_array,@tag_a,@ec[:image],@ec[:audio],@ec[:multimedia]=Array.new(9){[]} @authors,@topic_register_array,@papersize_array=[],[],[] @lvs=[nil,0,0,0,0,0,0] - @lang_code_insert=(@opt.dir_structure_by =~/language/) \ + @lang_code_insert=(@opt.dir_structure_by ==:language) \ ? '' : ".#{@opt.lng}" @rgx_image=/(?:^|[^_\\])\{(?:\s*|\~\^\s+)(\S+?\.(?:png|jpg|gif)\b)/m @rgx_audio=/\{\s*(\S+?\.(?:mp3|ogg))/ @rgx_mm=/\{\s*(\S+?\.(?:ogg|mpeg))/ #expand and distinguish ogg begin - rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@fns).error + rescue; SiSU_Errors::InfoError.new($!,$@,@opt.cmd,@fns).error ensure end end @@ -989,9 +1070,9 @@ module SiSU_Param @user,@home,@hostname,@pwd=ENV['USER'],ENV['HOME'],ENV['HOSTNAME'],ENV['PWD'] @programs,@wc,@language,@language_original={},{},{},{} @en={ sum: 0, mark: 0, note: 0, mismatch: 0 } - @prog=SiSU_Env::Info_settings.new - @sys=SiSU_Env::System_call.new - @env=SiSU_Env::Info_env.new(@fns) #watch + @prog=SiSU_Env::InfoSettings.new + @sys=SiSU_Env::SystemCall.new + @env=SiSU_Env::InfoEnv.new(@fns) #watch puts 'system locale: ' + @sys.locale if @opt.cmd =~/[MV]/ if @prog.wc \ and @sys.wc @@ -1009,7 +1090,7 @@ module SiSU_Param @locale=@sys.locale @file_encoding=@sys.file_encoding(fns,@opt.cmd) # programs set here for things that affect output appearance only - @programs[:pdf]=SiSU_Env::System_call.new.program_found?('pdflatex') + @programs[:pdf]=SiSU_Env::SystemCall.new.program_found?('pdflatex') if @opt.cmd =~/P/ #if @env.multilingual? m=/((.+?)(?:\~\w\w(?:_\w\w)?)?)\.((?:-|ssm\.)?sst|ssm|ssi)$/ #watch added match for sss @fnn,@fnb,@fnt=@fns[m,1],@fns[m,2],@fns[m,3] @@ -1036,13 +1117,13 @@ module SiSU_Param @flag_endnotes,@flag_auto_endnotes,@flag_separate_endnotes=false,false,false @flag_separate_endnotes_make=true regx_date=/^\d{4}(?:-(?:[0][0-9]|1[0-2])(-(?:[0-2][0-9]|3[01]))?)?$/ - ver=SiSU_Env::Info_version.instance + ver=SiSU_Env::InfoVersion.instance @sisu_version=ver.get_version @ruby_version=ver.rbversion @generated=Time.now fns_array=@data.dup skip unless fns_array # consider - @markup_version=SiSU_Markup_type::Markup_identify.new(fns_array,@opt).markup_version? #% determine markup version + @markup_version=SiSU_MarkupType::MarkupIdentify.new(fns_array,@opt).markup_version? #% determine markup version if fns_array[0] =~ /^(?:%\s+)?(?:SiSU\s+(?:master\s+)?[\d.]*|sisu-[\d.]+)$/ #check markup and markup version if fns_array[0] =~ /^(?:%\s+)?(?:SiSU\s+(?:master\s+)?|sisu-)(?:(?:[0-9]+?)(?:\.[0-9]+?)(?:\.[0-9]+))?$/ #check markup and markup version @markup_version_declared=fns_array[0].match(/^(?:%\s+)?(?:SiSU\s+(?:master\s+)?|sisu-)([\d.]+)$/)[1] @@ -1096,27 +1177,27 @@ module SiSU_Param and not @code_flag #or para=~/^(?:1|:?A)~/ case para when /^@title:(.+)/m #% * header metadata - title - @title=Md.new($1.strip,@opt,@env).title + @title=SiSU_Param::Parameters::Md.new($1.strip,@opt,@env).title when /^@creator:(.+)/m #% * header metadata - creator - @creator=Md.new($1.strip,@opt,@env).creator + @creator=SiSU_Param::Parameters::Md.new($1.strip,@opt,@env).creator @authorship=@author=@creator.author @authors=@creator.author_detail when /^@date:(.+)/m #% * header metadata - date - @date=Md.new($1.strip,@opt,@env).date + @date=SiSU_Param::Parameters::Md.new($1.strip,@opt,@env).date when /^@publisher:\s+(.+)/m #% * header metadata - publisher - @publisher=Md.new($1.strip,@opt,@env).current_publisher + @publisher=SiSU_Param::Parameters::Md.new($1.strip,@opt,@env).current_publisher @current_publisher=@publisher when /^@rights:(.+)/m; #% * header metadata - rights - @rights=Md.new($1.strip,@opt,@env).rights + @rights=SiSU_Param::Parameters::Md.new($1.strip,@opt,@env).rights when /^@classify:(.+)/m; classify=$1 #% * header metadata - classify - @classify=Md.new($1.strip,@opt,@env).classify + @classify=SiSU_Param::Parameters::Md.new($1.strip,@opt,@env).classify when /^@original:(.+)/m #% * header metadata - original (document) - @original=Md.new($1.strip,@opt,@env).original + @original=SiSU_Param::Parameters::Md.new($1.strip,@opt,@env).original @source=@original.source when /^@notes?:\s(.+)\Z/m #% * header metadata - notes - @notes=Md.new($1.strip,@opt,@env).notes + @notes=SiSU_Param::Parameters::Md.new($1.strip,@opt,@env).notes when /^@links:\s+(.+?)\Z/m #% * header metadata - links - doc_links=Md.new($1.strip,@opt,@env).links + doc_links=SiSU_Param::Parameters::Md.new($1.strip,@opt,@env).links count=1 @links=[] doc_links.each do |doc_link| @@ -1128,7 +1209,7 @@ module SiSU_Param end @lnk=@links when /^@make:(.+)/m #% * header processing - make - @make=Md.new($1.strip,@opt,@env).make + @make=SiSU_Param::Parameters::Md.new($1.strip,@opt,@env).make if defined? @make.breaks \ and @make.breaks[:page_new] #clearpage @pagenew=@make.breaks[:page_new] @@ -1223,7 +1304,7 @@ module SiSU_Param if not defined? @title.full.nil? tf=para[/^:A~\S*(.+)$/m,1] tf="@title: #{tf}" - @title=Md.new(tf.strip,@opt,@env).title + @title=SiSU_Param::Parameters::Md.new(tf.strip,@opt,@env).title end @html_title=@title.full.gsub(/(<p>|<p \/>|<br>|<br \/>)/,'') SiSU_Screen::Ansi.new(@opt.cmd,'Parameters',@html_title).txt_grey if @opt.cmd =~/v/ @@ -1272,7 +1353,7 @@ module SiSU_Param end end end - para.gsub!(/<:=(\S+?)>/,'{ c_\1.png 14x14 }image') # embedded symbol (image) + para=para.gsub(/<:=(\S+?)>/,'{ c_\1.png 14x14 }image') # embedded symbol (image) if para !~/^%+\s/ \ and para =~@rgx_image @ec[:image] << para.scan(@rgx_image).uniq @@ -1284,22 +1365,21 @@ module SiSU_Param end end #% here endeth the document loop if @ec[:image].length > 0 - @ec[:image].flatten! - @ec[:image].uniq! + @ec[:image]=@ec[:image].flatten.uniq @ec[:image].delete_if {|x| x =~/https?:\/\// } - @ec[:image].sort! + @ec[:image]=@ec[:image].sort end - @ec[:audio].uniq!; @ec[:audio].flatten!; @ec[:audio].sort! - @ec[:multimedia].uniq!; @ec[:multimedia].flatten!; @ec[:multimedia].sort! + @ec[:audio]=@ec[:audio].uniq.flatten.sort + @ec[:multimedia]=@ec[:multimedia].uniq.flatten.sort unless @rights if defined? @creator.author \ and @creator.author \ and defined? @date.published \ and @date.published - @rights=Md_default.new.rights(@creator.author,@date.published) + @rights=SiSU_Param::Parameters::MdDefault.new.rights(@creator.author,@date.published) elsif defined? @creator.author \ and @creator.author - @rights=Md_default.new.rights("[#{@creator.author}]",'') + @rights=SiSU_Param::Parameters::MdDefault.new.rights("[#{@creator.author}]",'') end end if defined? @classify.topic_register \ @@ -1315,10 +1395,10 @@ module SiSU_Param m[-1]=m[-1].scan(/[^|]+/) if m[-1] =~/[|]/ @topic_register_array << m end - @topic_register_array.sort! + @topic_register_array=@topic_register_array.sort end if @i18n - @i18n.uniq! + @i18n=@i18n.uniq @i18n << 'en' unless @i18n.find_index("en") else @i18n=[ 'en' ] @@ -1335,6 +1415,13 @@ module SiSU_Param translate.gsub!(/:?C/,'3') translate.gsub!(/:?B/,'2') translate.gsub!(/:?A/,'1') + # looks like an ok substituion for the above but is not, causes problems, check why + #translate=translate.gsub(/3/,'6'). + # gsub(/2/,'5'). + # gsub(/1/,'4'). + # gsub(/:?C/,'3'). + # gsub(/:?B/,'2'). + # gsub(/:?A/,'1') translate=if translate =~/^\d+$/; translate.to_i else translate end @@ -1342,10 +1429,10 @@ module SiSU_Param end end @pagenew,@pagebreak,@num_top,@toc_lev_limit=translated - @markup.gsub!(/page_new\s*=\s*([\dA-C])/,"page_new=#{@pagenew}") - @markup.gsub!(/page_break\s*=\s*([\dA-C])/,"page_break=#{@pagebreak}") - @markup.gsub!(/num_top\s*=\s*([\dA-C])/,"num_top=#{@num_top}") - @markup.gsub!(/toc_lev_limit\s*=\s*([\dA-C])/,"toc_lev_limit=#{@toc_lev_limit}") + @markup=@markup.gsub(/page_new\s*=\s*([\dA-C])/,"page_new=#{@pagenew}"). + gsub(/page_break\s*=\s*([\dA-C])/,"page_break=#{@pagebreak}"). + gsub(/num_top\s*=\s*([\dA-C])/,"num_top=#{@num_top}"). + gsub(/toc_lev_limit\s*=\s*([\dA-C])/,"toc_lev_limit=#{@toc_lev_limit}") end if @opt.mod.inspect =~/--papersize[=-]\S+|--pdf[=-]\S+/ \ or @opt.mod.inspect =~/--(?:a4|letter|legal|book|a5|b5)\b/i #command line config/header override @@ -1356,8 +1443,8 @@ module SiSU_Param @filesize=(File.size(fn)).to_s if @sys.openssl !=false skin=@doc_skin \ - ? (SiSU_Env::Info_skin.new(@opt,@doc_skin).select) - : SiSU_Env::Info_skin.new(@opt).select + ? (SiSU_Env::InfoSkin.new(@opt,@doc_skin).select) + : SiSU_Env::InfoSkin.new(@opt).select @dgst,@dgst_skin=[],[] if @env.digest.type =~/sha256/ dgst=@sys.sha256(@env.source_file_with_path) @@ -1372,7 +1459,7 @@ module SiSU_Param end end @publisher ||= "#@@publisher (this copy)" - fn_set_lang=SiSU_Env::Standardise_language.new(@opt.lng).language + fn_set_lang=SiSU_Env::StandardiseLanguage.new(@opt.lng).language unless @language[:code] \ and @language[:name] lang=@env.i18n.language #default language settings for directory by name, or in sysrc.yml @@ -1386,7 +1473,7 @@ module SiSU_Param @fnl=@env.i18n.lang_filename(fn_set_lang[:c]) #fix # @flv.each do |l| -# lang=SiSU_Env::Standardise_language.new.file_to_language(l) +# lang=SiSU_Env::StandardiseLanguage.new.file_to_language(l) # c={ a: '', b: '', c: '' } # if @fnl[:pre] =~/\S/; c[:a]="#{lang[:c]}." # elsif @fnl[:mid] =~/\S/; c[:b]=".#{lang[:c]}" @@ -1394,8 +1481,8 @@ module SiSU_Param # end # @lang << [lang[:n],"#{c[:a]}sisu_manifest#{c[:b]}.html#{c[:c]}"] # end if @flv - @lang.uniq! - @fn=SiSU_Env::Env_call.new(@fns).lang(fn_set_lang[:c]) + @lang=@lang.uniq + @fn=SiSU_Env::EnvCall.new(@fns).lang(fn_set_lang[:c]) @identifier="#{@env.url.root}/#{@fnb}/#{@fn[:toc]}" #DC note constructed dc identifier if @en[:note] > 0 \ and @en[:sum] > 0 @@ -1423,7 +1510,7 @@ module SiSU_Param if @author !~/[\S]/ if @fns =~/\.ssm$/ \ and @opt.inspect =~/P/ - #@creator=Md.new('Text Insert',@opt,@env).creator + #@creator=SiSU_Param::Md.new('Text Insert',@opt,@env).creator else SiSU_Screen::Ansi.new(@opt.cmd,'Warning Document Author missing','please provide @creator: :author:').warn unless @opt.cmd =~/q/ end @@ -1495,7 +1582,7 @@ module SiSU_Param SiSU_Screen::Ansi.new(@opt.cmd,"doc_skin <- #{@doc_skin}").txt_grey if @opt.cmd =~/v/ end @data=nil #else whole file's contents are stored in md pstore & is not required to be... big waste actually - @file=SiSU_Env::SiSU_file.new(self) #watch + @file=SiSU_Env::FileOp.new(self) #watch Store.new(self,@env).store #% pstore self end @@ -1520,7 +1607,7 @@ module SiSU_Param end class Instantiate def param_instantiate - @@date=SiSU_Env::Info_date.new + @@date=SiSU_Env::InfoDate.new @@proc=@@filename_txt=@@filename_texinfo=@@filename_lout_portrait=@@filename_lout_landscape=@@filename_html_scroll=@@filename_html_index=@@filename_html_segtoc=@@filename_semantic=@@filename_rss=@@newfile=@@drr=nil @doc={ initialise: nil, diff --git a/lib/sisu/v3/param_identify_markup.rb b/lib/sisu/v3/param_identify_markup.rb index e0245098..c8c1fe8b 100644 --- a/lib/sisu/v3/param_identify_markup.rb +++ b/lib/sisu/v3/param_identify_markup.rb @@ -58,8 +58,8 @@ altering SiSU markup =end -module SiSU_Markup_type - class Markup_identify +module SiSU_MarkupType + class MarkupIdentify @@version={} @@fns,@@version[:determined],@@version[:declared],@@declared_doc_type='','','','[text?]' attr_accessor :version,:declared_doc_type diff --git a/lib/sisu/v3/particulars.rb b/lib/sisu/v3/particulars.rb index a0006dc6..7c599624 100644 --- a/lib/sisu/v3/particulars.rb +++ b/lib/sisu/v3/particulars.rb @@ -64,7 +64,7 @@ module SiSU_Particulars require_relative 'param' # param.rb include SiSU_Param require_relative 'dal' # dal.rb - class Combined_singleton + class CombinedSingleton include Singleton def get_all(opt) @opt=opt @@ -132,23 +132,23 @@ module SiSU_Particulars begin @md=SiSU_Param::Parameters.new(@opt).get self - rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error + rescue; SiSU_Errors::InfoError.new($!,$@,@opt.cmd,@opt.fns).error end end attr_accessor :opt,:env,:file def set_env begin - @env=SiSU_Env::Info_env.new(@opt.fns) + @env=SiSU_Env::InfoEnv.new(@opt.fns) self - rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error + rescue; SiSU_Errors::InfoError.new($!,$@,@opt.cmd,@opt.fns).error end end def set_file begin set_md unless @md - @file=SiSU_Env::SiSU_file.new(@md) + @file=SiSU_Env::FileOp.new(@md) self - rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error + rescue; SiSU_Errors::InfoError.new($!,$@,@opt.cmd,@opt.fns).error end end attr_accessor :opt,:dal_array @@ -156,35 +156,35 @@ module SiSU_Particulars begin @dal_array=@dal_array=SiSU_DAL::Source.new(@md).get self - rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error + rescue; SiSU_Errors::InfoError.new($!,$@,@opt.cmd,@opt.fns).error end end def set_sst_idx begin @sst_idx=SiSU_DAL::Source.new(@md).get_idx_sst self - rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error + rescue; SiSU_Errors::InfoError.new($!,$@,@opt.cmd,@opt.fns).error end end def set_tex_idx begin @tex_idx=SiSU_DAL::Source.new(@md).get_idx_tex self - rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error + rescue; SiSU_Errors::InfoError.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 + rescue; SiSU_Errors::InfoError.new($!,$@,@opt.cmd,@opt.fns).error end end def set_xhtml_idx begin @xhtml_idx=SiSU_DAL::Source.new(@md).get_idx_xhtml self - rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error + rescue; SiSU_Errors::InfoError.new($!,$@,@opt.cmd,@opt.fns).error end end attr_accessor :nametags_map @@ -193,7 +193,7 @@ module SiSU_Particulars opt=@md ? @md : @opt @nametags_map=SiSU_DAL::Source.new(opt).get_map_nametags self - rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error + rescue; SiSU_Errors::InfoError.new($!,$@,@opt.cmd,@opt.fns).error end end attr_accessor :ocn_htmlseg_map @@ -201,7 +201,7 @@ module SiSU_Particulars begin @ocn_htmlseg_map=SiSU_DAL::Source.new(@md).get_map_ocn_htmlseg self - rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error + rescue; SiSU_Errors::InfoError.new($!,$@,@opt.cmd,@opt.fns).error end end end diff --git a/lib/sisu/v3/plaintext.rb b/lib/sisu/v3/plaintext.rb index f9a2a235..557c5f1b 100644 --- a/lib/sisu/v3/plaintext.rb +++ b/lib/sisu/v3/plaintext.rb @@ -62,7 +62,7 @@ module SiSU_Plaintext require_relative 'sysenv' # sysenv.rb include SiSU_Env require_relative 'plaintext_format' # plaintext_format.rb - include SiSU_Plaintext_format + include SiSU_PlaintextFormat require_relative 'shared_metadata' # shared_metadata.rb require_relative 'shared_txt' # shared_txt.rb include SiSU_Param @@ -80,7 +80,7 @@ module SiSU_Plaintext def read begin md=SiSU_Param::Parameters.new(@opt).get - env=SiSU_Env::Info_env.new(@opt.fns) + env=SiSU_Env::InfoEnv.new(@opt.fns) unless @opt.cmd =~/q/ path=env.path.output_tell tool=(@opt.cmd =~/[MVv]/) \ @@ -102,8 +102,8 @@ module SiSU_Plaintext end #wrap_width=(defined? md.make.plaintext_wrap) ? md.make.plaintext_wrap : 78 SiSU_Plaintext::Source::Scroll.new(dal_array,md,wrap_width).songsheet - SiSU_Env::Info_skin.new(md).select #watch - rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error + SiSU_Env::InfoSkin.new(md).select #watch + rescue; SiSU_Errors::InfoError.new($!,$@,@opt.cmd,@opt.fns).error ensure end end @@ -111,11 +111,11 @@ module SiSU_Plaintext class Scroll <Source require_relative 'defaults' # defaults.rb require_relative 'shared_txt' # shared_txt.rb - include SiSU_text_utils + include SiSU_TextUtils @@endnotes={ para: [], end: [] } def initialize(data,md,wrap_width) @data,@md,@wrap_width=data,md,wrap_width - @env=SiSU_Env::Info_env.new(@md.fns) + @env=SiSU_Env::InfoEnv.new(@md.fns) @brace_url=SiSU_Viz::Skin.new.url_decoration @tab="\t" @@endnotes_=case md.opt.mod.inspect @@ -152,16 +152,16 @@ module SiSU_Plaintext notes=@n.flatten notes.each do |e| util=(e.to_s =~/^\[[\d*+]+\]:/) \ - ? (SiSU_text_utils::Wrap.new(e.to_s,@wrap_width,4,1)) - : (SiSU_text_utils::Wrap.new(e.to_s,@wrap_width,1,1)) + ? (SiSU_TextUtils::Wrap.new(e.to_s,@wrap_width,4,1)) + : (SiSU_TextUtils::Wrap.new(e.to_s,@wrap_width,1,1)) wrap=util.line_wrap - if wrap =~ /^\s*[\d*+]+\s+.+?\s*\Z/m - wrap.gsub!(/^(\s*)([\d*+]+)\s+(.+?)\s*\Z/m, <<GSUB + wrap=if wrap =~ /^\s*[\d*+]+\s+.+?\s*\Z/m + wrap.gsub(/^(\s*)([\d*+]+)\s+(.+?)\s*\Z/m, <<GSUB \\1[\\2]: \\3 GSUB ) else - wrap.gsub!(/^(.+)\Z/m, <<GSUB + wrap.gsub(/^(.+)\Z/m, <<GSUB \\1 GSUB ) @@ -172,11 +172,11 @@ GSUB @@endnotes end def plaintext_metadata - array=Metadata::Summary.new(@md).plaintext.metadata + array=SiSU_Metadata::Summary.new(@md).plaintext.metadata array.each do |meta| tag,inf=meta.scan(/^.+?:\s|.+/) if tag and inf - util=SiSU_text_utils::Wrap.new(inf,@wrap_width,15,1) + util=SiSU_TextUtils::Wrap.new(inf,@wrap_width,15,1) txt=util.line_wrap @plaintext[:metadata] <<<<WOK @@ -186,9 +186,9 @@ WOK end end def plaintext_tail - SiSU_Env::Info_skin.new(@md).select -# env=SiSU_Env::Info_env.new(@md.fns) - vz=SiSU_Env::Get_init.instance.skin + SiSU_Env::InfoSkin.new(@md).select +# env=SiSU_Env::InfoEnv.new(@md.fns) + vz=SiSU_Env::GetInit.instance.skin base_url="#{@env.url.root}/#{@md.fnb}" generator="Generated by: #{@md.sisu_version[:project]} #{@md.sisu_version[:version]} of #{@md.sisu_version[:date_stamp]} (#{@md.sisu_version[:date]})" if @md.sisu_version[:version] lastdone="Last Generated on: #{Time.now}" @@ -216,32 +216,32 @@ WOK end def plaintext_structure(dob='',p_num='') #% Used to extract the structure of a document lv=n=n3=nil - if dob.is=='heading' + if dob.is==:heading lv=dob.ln n=lv - 1 n3=lv + 2 end util=nil - wrapped=if dob.is =='para' \ - or dob.is=='heading' - if dob.is=='para' + wrapped=if dob.is ==:para \ + or dob.is==:heading + if dob.is==:para if dob.hang \ and dob.hang =~/[0-9]/ \ and dob.indent != dob.hang - util=SiSU_text_utils::Wrap.new(dob.obj,@wrap_width,dob.indent.to_i*2,dob.hang.to_i*2) - #util=SiSU_text_utils::Wrap.new(dob.obj,@wrap_width,dob.hang.to_i*2,0) + util=SiSU_TextUtils::Wrap.new(dob.obj,@wrap_width,dob.indent.to_i*2,dob.hang.to_i*2) + #util=SiSU_TextUtils::Wrap.new(dob.obj,@wrap_width,dob.hang.to_i*2,0) elsif dob.indent =~/[1-9]/ util=if dob.bullet_ - SiSU_text_utils::Wrap.new("* #{dob.obj}",@wrap_width,dob.indent.to_i*2) - else SiSU_text_utils::Wrap.new(dob.obj,@wrap_width,dob.indent.to_i*2) + SiSU_TextUtils::Wrap.new("* #{dob.obj}",@wrap_width,dob.indent.to_i*2) + else SiSU_TextUtils::Wrap.new(dob.obj,@wrap_width,dob.indent.to_i*2) end else util=if dob.bullet_ - SiSU_text_utils::Wrap.new("* #{dob.obj}",@wrap_width,0) - else SiSU_text_utils::Wrap.new(dob.obj,@wrap_width,0) + SiSU_TextUtils::Wrap.new("* #{dob.obj}",@wrap_width,0) + else SiSU_TextUtils::Wrap.new(dob.obj,@wrap_width,0) end end - else util=SiSU_text_utils::Wrap.new(dob.obj,@wrap_width,0) + else util=SiSU_TextUtils::Wrap.new(dob.obj,@wrap_width,0) end util.line_wrap end @@ -270,7 +270,7 @@ WOK @@endnotes[:para]=[] end def markup(data) # Used for major markup instructions - dir=SiSU_Env::Info_env.new(@md.fns) + dir=SiSU_Env::InfoEnv.new(@md.fns) @data_mod,@endnotes,@level,@cont,@copen,@plaintext_contents_close=Array.new(6){[]} (0..6).each { |x| @cont[x]=@level[x]=false } (4..6).each { |x| @plaintext_contents_close[x]='' } @@ -279,89 +279,89 @@ WOK table_message='[table omitted, see other document formats]' fix=[] data.each do |dob| - dob.obj.gsub!(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}.+/um,"#{@br}#{table_message}") #fix - dob.obj.gsub!(/.+?#{Mx[:gl_o]}-##{Mx[:gl_c]}/,'') # remove dummy headings (used by html) #check also [~-]# - dob.obj.gsub!(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/, - "#{Px[:bold_o]}\\1#{Px[:bold_c]}") - dob.obj.gsub!(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/, - "#{Px[:italics_o]}\\1#{Px[:italics_c]}") - dob.obj.gsub!(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/, - "#{Px[:underscore_o]}\\1#{Px[:underscore_c]}") - dob.obj.gsub!(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/, - "#{Px[:subscript_o]}\\1#{Px[:subscript_c]}") - dob.obj.gsub!(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/, - "#{Px[:superscript_o]}\\1#{Px[:superscript_c]}") - dob.obj.gsub!(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/, - "#{Px[:insert_o]}\\1#{Px[:insert_c]}") - dob.obj.gsub!(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/, - "#{Px[:cite_o]}\\1#{Px[:cite_c]}") - dob.obj.gsub!(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/, - "#{Px[:strike_o]}\\1#{Px[:strike_c]}") - dob.obj.gsub!(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/, - "#{Px[:monospace_o]}\\1#{Px[:monospace_c]}") - unless dob.is=='code' - dob.obj.gsub!(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/,'\1') - dob.obj.gsub!(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'\1') - dob.obj.gsub!(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,'\1 [link: <\2>]') - dob.obj.gsub!(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}image/,'\1 [link: local image]') - dob.obj.gsub!(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,"#{@brace_url.txt_open}\\1#{@brace_url.txt_close}") + dob.obj=dob.obj.gsub(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}.+/um,"#{@br}#{table_message}"). #fix + gsub(/.+?#{Mx[:gl_o]}-##{Mx[:gl_c]}/,''). # remove dummy headings (used by html) #check also [~-]# + gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/, + "#{Px[:bold_o]}\\1#{Px[:bold_c]}"). + gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/, + "#{Px[:italics_o]}\\1#{Px[:italics_c]}"). + gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/, + "#{Px[:underscore_o]}\\1#{Px[:underscore_c]}"). + gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/, + "#{Px[:subscript_o]}\\1#{Px[:subscript_c]}"). + gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/, + "#{Px[:superscript_o]}\\1#{Px[:superscript_c]}"). + gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/, + "#{Px[:insert_o]}\\1#{Px[:insert_c]}"). + gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/, + "#{Px[:cite_o]}\\1#{Px[:cite_c]}"). + gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/, + "#{Px[:strike_o]}\\1#{Px[:strike_c]}"). + gsub(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/, + "#{Px[:monospace_o]}\\1#{Px[:monospace_c]}") + unless dob.is==:code + dob.obj=dob.obj.gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/,'\1'). + gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'\1'). + gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,'\1 [link: <\2>]'). + gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}image/,'\1 [link: local image]'). + gsub(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,"#{@brace_url.txt_open}\\1#{@brace_url.txt_close}") extract_endnotes(dob) - dob.obj.gsub!(/#{Mx[:en_a_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_a_c]}/,'[^\1]') # endnote marker marked up - dob.obj.gsub!(/#{Mx[:en_b_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_b_c]}/,'[^\1]') # endnote marker marked up - dob.obj.gsub!(/#{Mx[:gl_o]}(?:#lt|#060)#{Mx[:gl_c]}/,'<') - dob.obj.gsub!(/#{Mx[:gl_o]}(?:#gt|#062)#{Mx[:gl_c]}/,'>') - dob.obj.gsub!(/#{Mx[:gl_o]}#(?:038|amp)#{Mx[:gl_c]}/,'&') - dob.obj.gsub!(/#{Mx[:gl_o]}#033#{Mx[:gl_c]}/,'!') - dob.obj.gsub!(/#{Mx[:gl_o]}#035#{Mx[:gl_c]}/,'#') - dob.obj.gsub!(/#{Mx[:gl_o]}#042#{Mx[:gl_c]}/,'*') - dob.obj.gsub!(/#{Mx[:gl_o]}#045#{Mx[:gl_c]}/,'-') - dob.obj.gsub!(/#{Mx[:gl_o]}#047#{Mx[:gl_c]}/,'/') - dob.obj.gsub!(/#{Mx[:gl_o]}#095#{Mx[:gl_c]}/,'_') - dob.obj.gsub!(/#{Mx[:gl_o]}#123#{Mx[:gl_c]}/,'{') - dob.obj.gsub!(/#{Mx[:gl_o]}#125#{Mx[:gl_c]}/,'}') - dob.obj.gsub!(/#{Mx[:gl_o]}#126#{Mx[:gl_c]}/,'~') - dob.obj.gsub!(/#{Mx[:gl_o]}#169#{Mx[:gl_c]}/,'©') - dob.obj.gsub!(/#{Mx[:gl_o]}#092#{Mx[:gl_c]}/,'\\') + dob.obj=dob.obj.gsub(/#{Mx[:en_a_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_a_c]}/,'[^\1]'). # endnote marker marked up + gsub(/#{Mx[:en_b_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_b_c]}/,'[^\1]'). # endnote marker marked up + gsub(/#{Mx[:gl_o]}(?:#lt|#060)#{Mx[:gl_c]}/,'<'). + gsub(/#{Mx[:gl_o]}(?:#gt|#062)#{Mx[:gl_c]}/,'>'). + gsub(/#{Mx[:gl_o]}#(?:038|amp)#{Mx[:gl_c]}/,'&'). + gsub(/#{Mx[:gl_o]}#033#{Mx[:gl_c]}/,'!'). + gsub(/#{Mx[:gl_o]}#035#{Mx[:gl_c]}/,'#'). + gsub(/#{Mx[:gl_o]}#042#{Mx[:gl_c]}/,'*'). + gsub(/#{Mx[:gl_o]}#045#{Mx[:gl_c]}/,'-'). + gsub(/#{Mx[:gl_o]}#047#{Mx[:gl_c]}/,'/'). + gsub(/#{Mx[:gl_o]}#095#{Mx[:gl_c]}/,'_'). + gsub(/#{Mx[:gl_o]}#123#{Mx[:gl_c]}/,'{'). + gsub(/#{Mx[:gl_o]}#125#{Mx[:gl_c]}/,'}'). + gsub(/#{Mx[:gl_o]}#126#{Mx[:gl_c]}/,'~'). + gsub(/#{Mx[:gl_o]}#169#{Mx[:gl_c]}/,'©'). + gsub(/#{Mx[:gl_o]}#092#{Mx[:gl_c]}/,'\\') end - if dob.of=='block' # watch - dob.obj.gsub!(/#{Mx[:gl_o]}●#{Mx[:gl_c]}/,"* ") - dob.obj.gsub!(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,"\n") - else dob.obj.gsub!(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,"\n\n") + dob.obj=if dob.of==:block # watch + dob.obj.gsub(/#{Mx[:gl_o]}●#{Mx[:gl_c]}/,"* "). + gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,"\n") + else dob.obj.gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,"\n\n") end - if dob.is=='code' - dob.obj.gsub!(/(^|[^}])_([<>])/m,'\1\2') # _> _< - dob.obj.gsub!(/(^|[^}])_([<>])/m,'\1\2') # _<_< + if dob.is==:code + dob.obj=dob.obj.gsub(/(^|[^}])_([<>])/m,'\1\2'). # _> _< + gsub(/(^|[^}])_([<>])/m,'\1\2') # _<_< end - dob.obj.gsub!(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'\1') - dob.obj.gsub!(/<a href=".+?">(.+?)<\/a>/m,'\1') - dob.obj.gsub!(/#{Mx[:mk_o]}:name#(\S+?)#{Mx[:mk_c]}/,'') # remove name links - dob.obj.gsub!(/ |#{Mx[:nbsp]}/,' ') # decide on - dob.obj.gsub!(/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/,' [ \1 ]') #"[ #{dir.url.images_local}\/\\1 ]") - dob.obj.gsub!(/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}image/,' [ \1 ]') - dob.obj.gsub!(/(?:^|[^_\\])\{\s*\S+?\.(?:png|jpg|gif)\s+.+?"(.*?)"\s*\}\S+/,'[image: "\1"]') + dob.obj=dob.obj.gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'\1'). + gsub(/<a href=".+?">(.+?)<\/a>/m,'\1'). + gsub(/#{Mx[:mk_o]}:name#(\S+?)#{Mx[:mk_c]}/,''). # remove name links + gsub(/ |#{Mx[:nbsp]}/,' '). # decide on + gsub(/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/,' [ \1 ]'). #"[ #{dir.url.images_local}\/\\1 ]") + gsub(/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}image/,' [ \1 ]'). + gsub(/(?:^|[^_\\])\{\s*\S+?\.(?:png|jpg|gif)\s+.+?"(.*?)"\s*\}\S+/,'[image: "\1"]') wordlist=dob.obj.scan(/\S+/) if dob.obj !~/(^#{Rx[:meta]}|#{Mx[:br_eof]}|#{Mx[:br_endnotes]})/ #if defined? dob.ocn and dob.ocn.to_s =~/\d+/ # paranum=dob.ocn.to_s - # @p_num=SiSU_Plaintext_format::Paragraph_number.new(paranum) + # @p_num=SiSU_PlaintextFormat::ParagraphNumber.new(paranum) #end p_num='' if @env.plaintext_ocn? if defined? dob.ocn \ and not dob.ocn.nil? - p_num=SiSU_Plaintext_format::Paragraph_number.new(dob.ocn).display + p_num=SiSU_PlaintextFormat::ParagraphNumber.new(dob.ocn).display end end - if dob.is=='heading' \ - or dob.is=='para' + if dob.is==:heading \ + or dob.is==:para plaintext_structure(dob,p_num) - elsif dob.is=='group' \ - or dob.is=='block' \ - or dob.is=='verse' \ - or dob.is=='code' \ - or dob.is=='table' + elsif dob.is==:group \ + or dob.is==:block \ + or dob.is==:verse \ + or dob.is==:code \ + or dob.is==:table @plaintext[:body] << dob.obj + p_num << @br - elsif dob.is=='break' + elsif dob.is==:break sp=' ' ln='-' @plaintext[:body] <<=if dob.obj==Mx[:br_page] \ @@ -372,9 +372,11 @@ WOK end # following empty line (@br) missing, fix end dob='' if (dob.obj =~/<a name="n\d+">/ \ - and dob.obj =~/^(-\{{2}~\d+|<!e[:_]\d+!>)/) # -endnote - dob.obj.gsub!(/<!.+!>/,' ') if dob ## Clean Prepared Text - dob.obj.gsub!(/<:\S+>/,' ') if dob ## Clean Prepared Text + and dob.obj =~/^(-\{{2}~\d+|<!e[:_]\d+!>)/) # -endnote + if dob ## Clean Prepared Text + dob.obj=dob.obj.gsub(/<!.+!>/,' '). + gsub(/<:\S+>/,' ') + end end end @plaintext @@ -401,7 +403,7 @@ WOK @content,@md=content,md end def plaintext #%plaintext output - file_plaintext=SiSU_Env::SiSU_file.new(@md).write_file.txt + file_plaintext=SiSU_Env::FileOp.new(@md).write_file.txt @sisu=[] emptyline=0 @content.each do |para| # this is a hack diff --git a/lib/sisu/v3/plaintext_format.rb b/lib/sisu/v3/plaintext_format.rb index 5e64c03a..f7956070 100644 --- a/lib/sisu/v3/plaintext_format.rb +++ b/lib/sisu/v3/plaintext_format.rb @@ -56,11 +56,11 @@ ** Description: plaintext formatting template =end -module SiSU_Plaintext_format +module SiSU_PlaintextFormat require_relative 'param' # param.rb include SiSU_Param include SiSU_Viz - class Paragraph_number + class ParagraphNumber def initialize(paranum) @paranum=/(\d+)/m.match(paranum.to_s)[1] end @@ -74,7 +74,7 @@ module SiSU_Plaintext_format @paranum.gsub(/(\d+)/,'"#\1"') end end - class Format_text_object + class FormatTextObject def initialize(md,t_o) @md,@t_o=md,t_o if t_o.class==Hash @@ -86,10 +86,10 @@ module SiSU_Plaintext_format p caller end rgx=/^#{Rx[:lv]}/ - @txt.gsub!(rgx,'') if @txt =~rgx + @txt=@txt.gsub(rgx,'') if @txt =~rgx rgx=/#{Mx[:en_a_o]}[\d*+]+\s+(.+?)#{Mx[:en_a_c]}/ - @txt.gsub!(rgx,'\1') if @txt =~rgx - @vz=SiSU_Env::Get_init.instance.skin + @txt=@txt.gsub(rgx,'\1') if @txt =~rgx + @vz=SiSU_Env::GetInit.instance.skin end def scr_endnote_body "<endnote>#{@txt}</endnote> " diff --git a/lib/sisu/v3/po4a.rb b/lib/sisu/v3/po4a.rb index 0a5886ff..adb977c2 100644 --- a/lib/sisu/v3/po4a.rb +++ b/lib/sisu/v3/po4a.rb @@ -57,7 +57,7 @@ linefeed) =end -module SiSU_po4a +module SiSU_Po4a require_relative 'dal' # dal.rb require_relative 'sysenv' # sysenv.rb include SiSU_Env @@ -74,7 +74,7 @@ module SiSU_po4a # puts "#{@opt.fns} not a processed file type" #end r=Px[:lng_lst].join('|') - r.gsub!(/\|en\|/,'|') + r=r.gsub(/\|en\|/,'|') @lang_regx=%r{(?:#{r})} if opt.fns =~/\S+?~#{@lang_regx}\.ss[mti]/ \ and opt.f_pth[:lng]!=opt.lng_base @@ -93,14 +93,14 @@ module SiSU_po4a src[:pth]=@opt.f_pth[:pth] src[:files]=if @opt.fns =~ /\.(?:(?:-|ssm\.)sst|ssm)$/ @opt.fns=@opt.fns.gsub(/\.ssm\.sst$/,'.ssm') - SiSU_Assemble::Composite_file_list.new(@opt).read + SiSU_Assemble::CompositeFileList.new(@opt).read else [@opt.fns] end md=SiSU_Param::Parameters.new(@opt).get src[:files].each do |fn| SiSU_DAL::Source.new(@opt,fn).read # -m - env=SiSU_Env::Info_env.new(@opt.fns) + env=SiSU_Env::InfoEnv.new(@opt.fns) m=/((.+?)(?:\~\w\w(?:_\w\w)?)?)\.((?:-|ssm\.)?sst|ssm|ssi)$/ #watch added match for sss @fnn,@fnb,@fnt=fn[m,1],fn[m,2],fn[m,3] unless @opt.cmd =~/q/ @@ -149,10 +149,10 @@ module SiSU_po4a env.plaintext_wrap else 78 end - SiSU_po4a::Source::Scroll.new(fn,@dal_array_lang_src,@dal_array_lang_translation,@@md_src,@@md_trn,wrap_width).songsheet - SiSU_Env::Info_skin.new(md).select #watch + SiSU_Po4a::Source::Scroll.new(fn,@dal_array_lang_src,@dal_array_lang_translation,@@md_src,@@md_trn,wrap_width).songsheet + SiSU_Env::InfoSkin.new(md).select #watch end - rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error + rescue; SiSU_Errors::InfoError.new($!,$@,@opt.cmd,@opt.fns).error ensure end end @@ -160,7 +160,7 @@ module SiSU_po4a class Scroll <Source require_relative 'defaults' # defaults.rb require_relative 'po4a_set' # po4a_set.rb - include SiSU_po4a_utils + include SiSU_Po4aUtils @@endnotes={ para: [], end: [] } def initialize(fn,data_src,data_trn,md_src,md_trn,wrap_width) @fn,@data_src,@data_trn,@md_src,@md_trn,@wrap_width=fn,data_src,data_trn,md_src,md_trn,wrap_width @@ -168,7 +168,7 @@ module SiSU_po4a ? md_src : md_trn @brace_url=SiSU_Viz::Skin.new.url_decoration - @vz=SiSU_Env::Get_init.instance.skin + @vz=SiSU_Env::GetInit.instance.skin @tab="\t" @@endnotes_=(@md.opt.mod.inspect =~/--endnote/) ? true : false # --footnote @br=(@md.opt.mod.inspect =~/--dos/) ? "\r\n" : "\n" # --unix @@ -187,9 +187,9 @@ module SiSU_po4a @n=[] notes_a.flatten.each do |n| #high cost to deal with <br> appropriately within plaintext, consider n=n.dup.to_s - n.gsub!(/^([\d]+)\s+/,'^~\1 ') - #n.gsub!(/^([\d*+]+)\s+/,'^~\1 ') - n.gsub!(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,'<br>') + n=n.gsub(/^([\d]+)\s+/,'^~\1 '). + #gsub(/^([\d*+]+)\s+/,'^~\1 '). + gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,'<br>') @n << n end notes_a=@n.flatten @@ -219,13 +219,13 @@ module SiSU_po4a end util=pot_structure(desc,orig,trans) wrap=util.line_wrap - if wrap =~ /^\s*\^~[\d*+]+\s+.+?\s*\Z/m - wrap.gsub!(/^\s*(\^~[\d*+]+)\s+(.+?)\s*\Z/m, <<GSUB + wrap=if wrap =~ /^\s*\^~[\d*+]+\s+.+?\s*\Z/m + wrap.gsub(/^\s*(\^~[\d*+]+)\s+(.+?)\s*\Z/m, <<GSUB \\1 \\2 GSUB ) else - wrap.gsub!(/^(.+)\Z/m, <<GSUB + wrap.gsub(/^(.+)\Z/m, <<GSUB \\1 GSUB ) @@ -239,11 +239,11 @@ GSUB end def pot_metadata_src @po4a_identify_type='type: SiSU doc' #'type: Plain text' - meta_src=Metadata::Summary.new(@md_src) + meta_src=SiSU_Metadata::Summary.new(@md_src) w=[] w << [ "#. #{@po4a_identify_type} - metadata: title", - "#: en/#{@md.fns}:#{SiSU_po4a_utils::Pot_number.new.num}", + "#: en/#{@md.fns}:#{SiSU_Po4aUtils::PotNumber.new.num}", 'msgid ""', meta_src.metadata_tags.title.main, meta_src.metadata_tags.title.sub, @@ -256,7 +256,7 @@ GSUB ] w << [ "#. #{@po4a_identify_type} - metadata: creator", - "#: en/#{@md.fns}:#{SiSU_po4a_utils::Pot_number.new.num}", + "#: en/#{@md.fns}:#{SiSU_Po4aUtils::PotNumber.new.num}", 'msgid ""', meta_src.metadata_tags.creator.head, meta_src.metadata_tags.creator.author, @@ -271,7 +271,7 @@ GSUB ] w << [ "#. #{@po4a_identify_type} - metadata: rights", - "#: en/#{@md.fns}:#{SiSU_po4a_utils::Pot_number.new.num}", + "#: en/#{@md.fns}:#{SiSU_Po4aUtils::PotNumber.new.num}", 'msgid ""', meta_src.metadata_tags.rights.head, meta_src.metadata_tags.rights.copyright.text, @@ -285,7 +285,7 @@ GSUB ] w << [ "#. #{@po4a_identify_type} - metadata: classify", - "#: en/#{@md.fns}:#{SiSU_po4a_utils::Pot_number.new.num}", + "#: en/#{@md.fns}:#{SiSU_Po4aUtils::PotNumber.new.num}", 'msgid ""', meta_src.metadata_tags.classify.head, meta_src.metadata_tags.classify.relation, @@ -301,7 +301,7 @@ GSUB ] w << [ "#. #{@po4a_identify_type} - metadata: date", - "#: en/#{@md.fns}:#{SiSU_po4a_utils::Pot_number.new.num}", + "#: en/#{@md.fns}:#{SiSU_Po4aUtils::PotNumber.new.num}", 'msgid ""', meta_src.metadata_tags.date.head, meta_src.metadata_tags.date.added_to_site, @@ -315,7 +315,7 @@ GSUB ] w << [ "#. #{@po4a_identify_type} - processing, make instruction", - "#: en/#{@md.fns}:#{SiSU_po4a_utils::Pot_number.new.num}", + "#: en/#{@md.fns}:#{SiSU_Po4aUtils::PotNumber.new.num}", 'msgid ""', meta_src.processing_tags.make.language, meta_src.processing_tags.make.headings, @@ -344,12 +344,12 @@ GSUB def pot_metadata_src_trn @po4a_identify_type='type: SiSU doc' #@po4a_identify_type='type: Plain text' - meta_src=Metadata::Summary.new(@md_src) - meta_trn=Metadata::Summary.new(@md_trn) + meta_src=SiSU_Metadata::Summary.new(@md_src) + meta_trn=SiSU_Metadata::Summary.new(@md_trn) w=[] w << [ "#. #{@po4a_identify_type} - metadata: title", - "#: en/#{@md.fns}:#{SiSU_po4a_utils::Pot_number.new.num}", + "#: en/#{@md.fns}:#{SiSU_Po4aUtils::PotNumber.new.num}", 'msgid ""', meta_src.metadata_tags.title.main, meta_src.metadata_tags.title.sub, @@ -369,7 +369,7 @@ GSUB ] w << [ "#. #{@po4a_identify_type} - metadata: creator", - "#: en/#{@md.fns}:#{SiSU_po4a_utils::Pot_number.new.num}", + "#: en/#{@md.fns}:#{SiSU_Po4aUtils::PotNumber.new.num}", 'msgid ""', meta_src.metadata_tags.creator.head, meta_src.metadata_tags.creator.author, @@ -393,7 +393,7 @@ GSUB ] w << [ "#. #{@po4a_identify_type} - metadata: rights", - "#: en/#{@md.fns}:#{SiSU_po4a_utils::Pot_number.new.num}", + "#: en/#{@md.fns}:#{SiSU_Po4aUtils::PotNumber.new.num}", 'msgid ""', meta_src.metadata_tags.rights.head, meta_src.metadata_tags.rights.copyright.text, @@ -415,7 +415,7 @@ GSUB ] w << [ "#. #{@po4a_identify_type} - metadata: classify", - "#: en/#{@md.fns}:#{SiSU_po4a_utils::Pot_number.new.num}", + "#: en/#{@md.fns}:#{SiSU_Po4aUtils::PotNumber.new.num}", 'msgid ""', meta_src.metadata_tags.classify.head, meta_src.metadata_tags.classify.relation, @@ -441,7 +441,7 @@ GSUB ] w << [ "#. #{@po4a_identify_type} - metadata: date", - "#: en/#{@md.fns}:#{SiSU_po4a_utils::Pot_number.new.num}", + "#: en/#{@md.fns}:#{SiSU_Po4aUtils::PotNumber.new.num}", 'msgid ""', meta_src.metadata_tags.date.head, meta_src.metadata_tags.date.added_to_site, @@ -463,7 +463,7 @@ GSUB ] w << [ "#. #{@po4a_identify_type} - processing, make instruction", - "#: en/#{@md.fns}:#{SiSU_po4a_utils::Pot_number.new.num}", + "#: en/#{@md.fns}:#{SiSU_Po4aUtils::PotNumber.new.num}", 'msgid ""', meta_src.processing_tags.make.language, meta_src.processing_tags.make.headings, @@ -499,7 +499,7 @@ GSUB end end def pot_structure(desc,orig,trans,indent=0,hang=0) - SiSU_po4a_utils::Wrap.new(@md,orig,trans,desc,@wrap_width,indent,hang) + SiSU_Po4aUtils::Wrap.new(@md,orig,trans,desc,@wrap_width,indent,hang) end def pot_structure_heading(dob_src='',notes_s='',dob_trn='',notes_t='') #% Used to extract the structure of a document lv=n=n3=nil @@ -509,7 +509,7 @@ GSUB util=nil fn=(dob_src.name=~/[a-z\d]/i) ? dob_src.name : '' mark="#{dob_src.lv}~#{fn} " - d="#{dob_src.is} (level #{dob_src.lv})" + d="#{dob_src.is.to_s} (level #{dob_src.lv})" instruct=s_mark='' if @md.opt.cmd=~/M/ instruct=%{\n# markup for headings is marker at the start of the line/object, indicating the heading level, and if provided an associated name tag, this heading is "#{mark}"} @@ -538,7 +538,7 @@ GSUB s_mark=desc=orig=trans='' if dob_src.bullet_ mark="_#{dob_src.indent}* " - d="#{dob_src.is}: indent #{dob_src.indent}, bullet" + d="#{dob_src.is.to_s}: indent #{dob_src.indent}, bullet" instruct=s_mark='' if @md.opt.cmd=~/M/ instruct=%{\n# markup for indented bullet text is at the start of the line/object, an underscore followed by the indent level and an asterisk "#{mark}"} @@ -547,7 +547,7 @@ GSUB desc="#{d}#{s_mark}#{instruct}" else mark="_#{dob_src.indent} " - d="#{dob_src.is}: indent #{dob_src.indent}" + d="#{dob_src.is.to_s}: indent #{dob_src.indent}" instruct=s_mark='' if @md.opt.cmd=~/M/ instruct=%{\n# markup for indented text is at the start of the line/object, an underscore followed by the indent level "#{mark}"} @@ -562,7 +562,7 @@ GSUB and dob_src.indent != dob_src.hang s_mark=desc=orig=trans='' mark="_#{dob_src.hang}_#{dob_src.indent} " - d="#{dob_src.is}: hang #{dob_src.hang} indent #{dob_src.indent}" + d="#{dob_src.is.to_s}: hang #{dob_src.hang} indent #{dob_src.indent}" instruct=s_mark='' if @md.opt.cmd=~/M/ instruct=%{\n# markup for indented text with a first line indented to a different level from the rest of the paragraph, is at the start of the line/object, an underscore and the first indent level a second underscore and the indent level for the rest of the paragraph, "#{mark1}"} @@ -576,7 +576,7 @@ GSUB s_mark=desc=orig=trans='' if dob_src.bullet_ mark='_* ' - d="#{dob_src.is}: bullet" + d="#{dob_src.is.to_s}: bullet" instruct=s_mark='' if @md.opt.cmd=~/M/ instruct=%{\n# markup for indented text is at the start of the line/object, an underscore followed by an asterisk "#{mark}"} @@ -587,7 +587,7 @@ GSUB trans=(dob_trn=='') ? '' : "#{s_mark}#{dob_trn.obj}" else mark='' - d=dob_src.is + d=dob_src.is.to_s instruct=%{\n# regular paragraph, no special markup} if @md.opt.cmd=~/M/ instruct="\n# " @@ -613,7 +613,7 @@ GSUB end def pot_structure_block(dob_src='',notes_s='',dob_trn='',notes_t='') #% Used to extract the structure of a document mark="block{\\n\\n...\\n\\n}block" - d=dob_src.is + d=dob_src.is.to_s instruct=s_mark='' if @md.opt.cmd=~/M/ instruct="\n# block text is a text block with an opening and closing marker, the content of which may be wrapped" @@ -628,7 +628,7 @@ GSUB end def pot_structure_group(dob_src='',notes_s='',dob_trn='',notes_t='') #% Used to extract the structure of a document mark="group{\\n\\n...\\n\\n}group" - d=dob_src.is + d=dob_src.is.to_s instruct=s_mark='' if @md.opt.cmd=~/M/ instruct="\n# group text is a text block with an opening and closing marker, the content of which may be wrapped" @@ -643,7 +643,7 @@ GSUB end def pot_structure_verse(dob_src='',notes_s='',dob_trn='',notes_t='') #% Used to extract the structure of a document mark="poem{\n\nverse\n\nverse\n\n...\n\n}poem" - d=dob_src.is + d=dob_src.is.to_s instruct=s_mark='' if @md.opt.cmd=~/M/ instruct="\n# verse are part of the text block described as a poem, the first verse is preceeded by an opening marker, and the last verse by a closing marker, the content of which should remain unwrapped" @@ -658,7 +658,7 @@ GSUB end def pot_structure_code(dob_src='',notes_s='',dob_trn='',notes_t='') #% Used to extract the structure of a document mark="code{\\n\\n...\\n\\n}code" - d=dob_src.is + d=dob_src.is.to_s instruct=s_mark='' if @md.opt.cmd=~/M/ instruct="\n# codeblocks are a text block with an opening and closing marker, the content of which should remain unwrapped" @@ -673,7 +673,7 @@ GSUB end def pot_structure_table(dob_src='',notes_s='',dob_trn='',notes_t='') #% Used to extract the structure of a document mark="table{\\n\\n...\\n\\n}table" - d=dob_src.is + d=dob_src.is.to_s instruct=s_mark='' if @md.opt.cmd=~/M/ instruct="\n# tables are a text block with an opening and closing marker, the content of which should remain unwrapped" @@ -681,9 +681,9 @@ GSUB end desc="#{d}#{s_mark}#{instruct}" orig=dob_src.obj - orig.gsub!(/#{Mx[:tc_c]}/,"\n") + orig=orig.gsub(/#{Mx[:tc_c]}/,"\n") trans=(dob_trn=='') ? '' : dob_trn.obj - trans.gsub!(/#{Mx[:tc_c]}/,"\n") + trans=trans.gsub(/#{Mx[:tc_c]}/,"\n") util=pot_structure(desc,orig,trans) unwrapped=util.no_line_wrap_block @pot[:body] << unwrapped << @br @@ -729,22 +729,22 @@ GSUB and data_trn[t] break end - if data_src[s].of == 'comment' \ - and data_trn[t].of == 'comment' \ + if data_src[s].of == :comment \ + and data_trn[t].of == :comment \ and (data_src[s].is == data_trn[t].is) s+=1;t+=1 next end - if (data_src[s].is == 'comment' or data_trn[t].is == 'comment') \ + if (data_src[s].is == :comment or data_trn[t].is == :comment) \ and (data_src[s].is != data_trn[t].is) - if data_src[s].is == 'comment' + if data_src[s].is == :comment puts "src (comment):\n\t" + data_src[s].obj if @md.opt.cmd =~/M/ s+=1 - #next if data_src[s].is == 'comment' - elsif data_trn[t].is == 'comment' + #next if data_src[s].is == :comment + elsif data_trn[t].is == :comment puts "trans (comment):\n\t" + data_trn[t].obj if @md.opt.cmd =~/M/ t+=1 - #next if data_trn[t].is == 'comment' + #next if data_trn[t].is == :comment end end if (defined? data_src[s].ocn and data_src[s].ocn.class == Fixnum) \ @@ -811,16 +811,16 @@ GSUB if defined? dob_src.ocn \ and dob_src.ocn.to_s =~/\d+/ paranum=dob_src.ocn.to_s - @p_num=SiSU_po4a_utils::Paragraph_number.new(paranum) + @p_num=SiSU_Po4aUtils::ParagraphNumber.new(paranum) end case dob_src.is - when 'heading'; pot_structure_heading(dob_src,notes_s,dob_trn,notes_t) - when 'para'; pot_structure_para(dob_src,notes_s,dob_trn,notes_t) - when 'group'; pot_structure_group(dob_src,notes_s,dob_trn,notes_t) - when 'block'; pot_structure_block(dob_src,notes_s,dob_trn,notes_t) - when 'verse'; pot_structure_verse(dob_src,notes_s,dob_trn,notes_t) - when 'code'; pot_structure_code(dob_src,notes_s,dob_trn,notes_t) - when 'table'; pot_structure_table(dob_src,notes_s,dob_trn,notes_t) + when :heading; pot_structure_heading(dob_src,notes_s,dob_trn,notes_t) + when :para; pot_structure_para(dob_src,notes_s,dob_trn,notes_t) + when :group; pot_structure_group(dob_src,notes_s,dob_trn,notes_t) + when :block; pot_structure_block(dob_src,notes_s,dob_trn,notes_t) + when :verse; pot_structure_verse(dob_src,notes_s,dob_trn,notes_t) + when :code; pot_structure_code(dob_src,notes_s,dob_trn,notes_t) + when :table; pot_structure_table(dob_src,notes_s,dob_trn,notes_t) end if defined? dob_src.idx \ and not dob_src.idx.nil? \ @@ -829,79 +829,81 @@ GSUB end dob_src='' if (dob_src.obj =~/<a name="n\d+">/ \ and dob_src.obj =~/^(-\{{2}~\d+|<!e[:_]\d+!>)/) # -endnote - dob_src.obj.gsub!(/<!.+!>/,' ') if dob_src ## Clean Prepared Text - dob_src.obj.gsub!(/<:\S+>/,' ') if dob_src ## Clean Prepared Text + if dob_src ## Clean Prepared Text + dob_src.obj=dob_src.obj.gsub(/<!.+!>/,' '). + gsub(/<:\S+>/,' ') if dob_src ## Clean Prepared Text + end end #[dob_src,dob_trn] end def markup(dob) # Used for major markup instructions - dir=SiSU_Env::Info_env.new(@md.fns) + dir=SiSU_Env::InfoEnv.new(@md.fns) fix=[] - dob.obj.gsub!(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/, - "#{Px[:po_bold_o]}\\1#{Px[:po_bold_c]}") - dob.obj.gsub!(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/, - "#{Px[:po_italics_o]}\\1#{Px[:po_italics_c]}") - dob.obj.gsub!(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/, - "#{Px[:po_underscore_o]}\\1#{Px[:po_underscore_c]}") - dob.obj.gsub!(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/, - "#{Px[:po_subscript_o]}\\1#{Px[:po_subscript_c]}") - dob.obj.gsub!(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/, - "#{Px[:po_superscript_o]}\\1#{Px[:po_superscript_c]}") - dob.obj.gsub!(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/, - "#{Px[:po_insert_o]}\\1#{Px[:po_insert_c]}") - dob.obj.gsub!(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/, - "#{Px[:po_cite_o]}\\1#{Px[:po_cite_c]}") - dob.obj.gsub!(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/, - "#{Px[:po_strike_o]}\\1#{Px[:po_strike_c]}") - dob.obj.gsub!(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/, - "#{Px[:po_monospace_o]}\\1#{Px[:po_monospace_c]}") + dob.obj=dob.obj.gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/, + "#{Px[:po_bold_o]}\\1#{Px[:po_bold_c]}"). + gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/, + "#{Px[:po_italics_o]}\\1#{Px[:po_italics_c]}"). + gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/, + "#{Px[:po_underscore_o]}\\1#{Px[:po_underscore_c]}"). + gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/, + "#{Px[:po_subscript_o]}\\1#{Px[:po_subscript_c]}"). + gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/, + "#{Px[:po_superscript_o]}\\1#{Px[:po_superscript_c]}"). + gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/, + "#{Px[:po_insert_o]}\\1#{Px[:po_insert_c]}"). + gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/, + "#{Px[:po_cite_o]}\\1#{Px[:po_cite_c]}"). + gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/, + "#{Px[:po_strike_o]}\\1#{Px[:po_strike_c]}"). + gsub(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/, + "#{Px[:po_monospace_o]}\\1#{Px[:po_monospace_c]}") notes='' - unless dob.is=='code' - dob.obj.gsub!(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/,'\1') - dob.obj.gsub!(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'\1') - dob.obj.gsub!(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,'\1 [link: <\2>]') - dob.obj.gsub!(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}image/,'\1 [link: local image]') - dob.obj.gsub!(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,'\1') + unless dob.is==:code + dob.obj=dob.obj.gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/,'\1'). + gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'\1'). + gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,'\1 [link: <\2>]'). + gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}image/,'\1 [link: local image]'). + gsub(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,'\1') #dob.obj.gsub!(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,"#{@brace_url.txt_open}\\1#{@brace_url.txt_close}") notes=extract_endnotes(dob) #% ### footnotes current state - extracted - dob.obj.gsub!(/#{Mx[:en_a_o]}([\d]+)\s+(?:.+?)#{Mx[:en_a_c]}/,'~^') # endnote marker marked up + dob.obj=dob.obj.gsub(/#{Mx[:en_a_o]}([\d]+)\s+(?:.+?)#{Mx[:en_a_c]}/,'~^'). # endnote marker marked up #% ### footnotes current state - keep inline #dob.obj.gsub!(/#{Mx[:en_a_o]}[\d]+\s+(.+?)#{Mx[:en_a_c]}/,'~{ \1 }~') # inline endnote with marker marked up - dob.obj.gsub!(/#{Mx[:en_b_o]}[\d]+\s+(.+?)#{Mx[:en_b_c]}/,'~[ \1 ]~') # inline endnote with marker marked up - dob.obj.gsub!(/#{Mx[:en_a_o]}([*+]+)\s+(.+?)#{Mx[:en_a_c]}/,'~{\1 \2 }~') # inline endnote with marker marked up - dob.obj.gsub!(/#{Mx[:en_b_o]}([*+]+)\s+(.+?)#{Mx[:en_b_c]}/,'~[\1 \2 ]~') # inline endnote with marker marked up - dob.obj.gsub!(/#{Mx[:gl_o]}(?:#lt|#060)#{Mx[:gl_c]}/,'<') - dob.obj.gsub!(/#{Mx[:gl_o]}(?:#gt|#062)#{Mx[:gl_c]}/,'>') - dob.obj.gsub!(/#{Mx[:gl_o]}#(?:038|amp)#{Mx[:gl_c]}/,'&') - dob.obj.gsub!(/#{Mx[:gl_o]}#033#{Mx[:gl_c]}/,'!') - dob.obj.gsub!(/#{Mx[:gl_o]}#035#{Mx[:gl_c]}/,'#') - dob.obj.gsub!(/#{Mx[:gl_o]}#042#{Mx[:gl_c]}/,'*') - dob.obj.gsub!(/#{Mx[:gl_o]}#045#{Mx[:gl_c]}/,'-') - dob.obj.gsub!(/#{Mx[:gl_o]}#047#{Mx[:gl_c]}/,'/') - dob.obj.gsub!(/#{Mx[:gl_o]}#095#{Mx[:gl_c]}/,'_') - dob.obj.gsub!(/#{Mx[:gl_o]}#123#{Mx[:gl_c]}/,'{') - dob.obj.gsub!(/#{Mx[:gl_o]}#125#{Mx[:gl_c]}/,'}') - dob.obj.gsub!(/#{Mx[:gl_o]}#126#{Mx[:gl_c]}/,'~') - dob.obj.gsub!(/#{Mx[:gl_o]}#169#{Mx[:gl_c]}/,'©') + gsub(/#{Mx[:en_b_o]}[\d]+\s+(.+?)#{Mx[:en_b_c]}/,'~[ \1 ]~'). # inline endnote with marker marked up + gsub(/#{Mx[:en_a_o]}([*+]+)\s+(.+?)#{Mx[:en_a_c]}/,'~{\1 \2 }~'). # inline endnote with marker marked up + gsub(/#{Mx[:en_b_o]}([*+]+)\s+(.+?)#{Mx[:en_b_c]}/,'~[\1 \2 ]~'). # inline endnote with marker marked up + gsub(/#{Mx[:gl_o]}(?:#lt|#060)#{Mx[:gl_c]}/,'<'). + gsub(/#{Mx[:gl_o]}(?:#gt|#062)#{Mx[:gl_c]}/,'>'). + gsub(/#{Mx[:gl_o]}#(?:038|amp)#{Mx[:gl_c]}/,'&'). + gsub(/#{Mx[:gl_o]}#033#{Mx[:gl_c]}/,'!'). + gsub(/#{Mx[:gl_o]}#035#{Mx[:gl_c]}/,'#'). + gsub(/#{Mx[:gl_o]}#042#{Mx[:gl_c]}/,'*'). + gsub(/#{Mx[:gl_o]}#045#{Mx[:gl_c]}/,'-'). + gsub(/#{Mx[:gl_o]}#047#{Mx[:gl_c]}/,'/'). + gsub(/#{Mx[:gl_o]}#095#{Mx[:gl_c]}/,'_'). + gsub(/#{Mx[:gl_o]}#123#{Mx[:gl_c]}/,'{'). + gsub(/#{Mx[:gl_o]}#125#{Mx[:gl_c]}/,'}'). + gsub(/#{Mx[:gl_o]}#126#{Mx[:gl_c]}/,'~'). + gsub(/#{Mx[:gl_o]}#169#{Mx[:gl_c]}/,'©') end - if dob.of=='block' # watch - dob.obj.gsub!(/#{Mx[:gl_o]}●#{Mx[:gl_c]}/,"* ") - dob.obj.gsub!(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,"\n") - else dob.obj.gsub!(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,"\n\n") + dob.obj=if dob.of==:block # watch + dob.obj.gsub(/#{Mx[:gl_o]}●#{Mx[:gl_c]}/,"* "). + gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,"\n") + else dob.obj.gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,"\n\n") end - if dob.is=='code' - dob.obj.gsub!(/(^|[^}])_([<>])/m,'\1\2') # _> _< - dob.obj.gsub!(/(^|[^}])_([<>])/m,'\1\2') # _<_< + if dob.is==:code + dob.obj=dob.obj.gsub(/(^|[^}])_([<>])/m,'\1\2'). # _> _< + gsub(/(^|[^}])_([<>])/m,'\1\2') # _<_< end - dob.obj.gsub!(/#{Mx[:br_page]}\s*|#{Mx[:br_page_new]}/,'') # remove page breaks - dob.obj.gsub!(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'\1') - dob.obj.gsub!(/<a href=".+?">(.+?)<\/a>/m,'\1') - dob.obj.gsub!(/#{Mx[:mk_o]}:name#(\S+?)#{Mx[:mk_c]}/,'') # remove name links - dob.obj.gsub!(/ |#{Mx[:nbsp]}/,' ') # decide on - dob.obj.gsub!(/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/,' [ \1 ]') #"[ #{dir.url.images_local}\/\\1 ]") - dob.obj.gsub!(/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}image/,' [ \1 ]') #"[ #{dir.url.images_local}\/\\1 ]") - dob.obj.gsub!(/(?:^|[^_\\])\{\s*\S+?\.(?:png|jpg|gif)\s+.+?"(.*?)"\s*\}\S+/,'[image: "\1"]') + dob.obj=dob.obj.gsub(/#{Mx[:br_page]}\s*|#{Mx[:br_page_new]}/,''). # remove page breaks + gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'\1'). + gsub(/<a href=".+?">(.+?)<\/a>/m,'\1'). + gsub(/#{Mx[:mk_o]}:name#(\S+?)#{Mx[:mk_c]}/,''). # remove name links + gsub(/ |#{Mx[:nbsp]}/,' '). # decide on + gsub(/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/,' [ \1 ]'). #"[ #{dir.url.images_local}\/\\1 ]") + gsub(/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}image/,' [ \1 ]'). #"[ #{dir.url.images_local}\/\\1 ]") + gsub(/(?:^|[^_\\])\{\s*\S+?\.(?:png|jpg|gif)\s+.+?"(.*?)"\s*\}\S+/,'[image: "\1"]') [dob,notes] end def publish(fn,pot) @@ -921,7 +923,7 @@ GSUB include SiSU_Env def initialize(fn,content,md) @fn,@content,@md=fn,content,md - @file=SiSU_Env::SiSU_file.new(md,fn) + @file=SiSU_Env::FileOp.new(md,fn) end def po4a #%pot output file_pot=(@md.opt.f_pth[:lng] ==opt.lng_base) \ @@ -934,8 +936,8 @@ GSUB and para.length > 0 para.each do |line| if line - line.gsub!(/\s+$/m,'') - line.gsub!(/^\A[ ]*\Z/m,'') + line=line.gsub(/\s+$/m,''). + gsub(/^\A[ ]*\Z/m,'') if line=~/^\A[ ]*\Z/m emptyline+=1 else emptyline=0 @@ -947,7 +949,7 @@ GSUB end end file_pot.close - SiSU_po4a_utils::Pot_number.new.reset + SiSU_Po4aUtils::PotNumber.new.reset po4a_git end def po4a_git diff --git a/lib/sisu/v3/po4a_set.rb b/lib/sisu/v3/po4a_set.rb index 1e0f90c4..6335fb8c 100644 --- a/lib/sisu/v3/po4a_set.rb +++ b/lib/sisu/v3/po4a_set.rb @@ -56,7 +56,7 @@ ** Description: modules shared by flatfile output generators =end -module SiSU_po4a_utils +module SiSU_Po4aUtils class Wrap def initialize(md,orig='',trans='',is_desc='',n_char_max=76,n_indent=0,n_hang=nil) @md,@orig,@trans,@is_desc,@n_char_max,@n_indent=md,orig,trans,is_desc,n_char_max,n_indent @@ -76,8 +76,8 @@ module SiSU_po4a_utils out=[] out[line]='' @oldword='' #REMOVE @oldword - pa.gsub!(/<br>/,' <br> ') - pa.gsub!(/#{Mx[:br_nl]}/,"\n\n") + pa=pa.gsub(/<br>/,' <br> '). + gsub(/#{Mx[:br_nl]}/,"\n\n") words=pa.scan(/\n\n|<br>|\S+/m) while words != '' word=words.shift @@ -109,7 +109,7 @@ module SiSU_po4a_utils x=out.join(spaces_indent).gsub(/\A\n+/m,'').insert(0,spaces_hang) z=[] x.split(/\n/).each do |y| - y.gsub!(/"/,'\"') + y=y.gsub(/"/,'\"') y=%{"#{y}"} z << y end @@ -120,7 +120,7 @@ module SiSU_po4a_utils trans=(pot.length == 2) ? pot[1] : '' po_str=<<WOK #. #{@po4a_identify_type} - #{@is_desc} -#: en/#{@md.fns}:#{Pot_number.new.num} +#: en/#{@md.fns}:#{PotNumber.new.num} msgid "" #{pot[0]} msgstr "" @@ -134,7 +134,7 @@ WOK pot_array.each do |pa| z=[] pa.split(/\n\n/).each do |y| - y.gsub!(/"/,'\"') + y=y.gsub(/"/,'\"') y=%{"#{y}"} z << y if not y.empty? end @@ -145,7 +145,7 @@ WOK trans=(pot.length == 2) ? pot[1] : '' po_str=<<WOK #. #{@po4a_identify_type} - #{@is_desc} -#: en/#{@md.fns}:#{Pot_number.new.num} +#: en/#{@md.fns}:#{PotNumber.new.num} #, no-wrap msgid "" #{pot[0]} @@ -166,13 +166,13 @@ WOK if @orig.class==Array @arr=[] @orig.each do |line| - @arr << SiSU_text_utils::Wrap.new(line,@n_char_max,@n_indent,@n_hang).line_wrap + @arr << SiSU_TextUtils::Wrap.new(line,@n_char_max,@n_indent,@n_hang).line_wrap end end @arr end end - class Header_scan + class HeaderScan def initialize(md,para) @md,@p=md,para end @@ -276,7 +276,7 @@ WOK end end end - class Paragraph_number + class ParagraphNumber def initialize(paranum) @paranum=/(\d+)/m.match(paranum)[1] end @@ -284,7 +284,7 @@ WOK @paranum.gsub(/(\d+)/,'#\1') end end - class Pot_number + class PotNumber @@n=0 def initialize @@n +=2 diff --git a/lib/sisu/v3/qrcode.rb b/lib/sisu/v3/qrcode.rb index 2dd621e7..d2b16753 100644 --- a/lib/sisu/v3/qrcode.rb +++ b/lib/sisu/v3/qrcode.rb @@ -70,15 +70,15 @@ module SiSU_QRcode class Source def initialize(opt) @opt=opt - @particulars=SiSU_Particulars::Combined_singleton.instance.get_all(opt) - l=SiSU_Env::Standardise_language.new(@opt.lng).language + @particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt) + l=SiSU_Env::StandardiseLanguage.new(@opt.lng).language @doc_language=l[:n] end def read begin - @env=SiSU_Env::Info_env.new(@opt.fns) + @env=SiSU_Env::InfoEnv.new(@opt.fns) @md=SiSU_Param::Parameters.new(@opt).get - SiSU_Env::Info_skin.new(@md).select + SiSU_Env::InfoSkin.new(@md).select xbrowser=@env.program.web_browser browser=@env.program.console_web_browser unless @opt.cmd =~/q/ @@ -88,25 +88,25 @@ module SiSU_QRcode : SiSU_Screen::Ansi.new(@opt.cmd,'QR code',"[#{@opt.f_pth[:lng_is]}] #{@opt.fns}").green_title_hi SiSU_Screen::Ansi.new(@opt.cmd,"#{browser} #{url_html}").grey_tab if @opt.cmd =~/v/i end - data=SiSU_HTML::Source::Html_environment.new(@particulars).tuned_file_instructions - Output_Info.new(@md).check_output(data) - rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error + data=SiSU_HTML::Source::HTML_Environment.new(@particulars).tuned_file_instructions + OutputInfo.new(@md).check_output(data) + rescue; SiSU_Errors::InfoError.new($!,$@,@opt.cmd,@opt.fns).error ensure end end private - class Output_Info <Source + class OutputInfo <Source def initialize(md) @manifest={ txt: [], txt_title: [] } @md,@fns=md,md.fns - @env=SiSU_Env::Info_env.new(@md.fns) + @env=SiSU_Env::InfoEnv.new(@md.fns) @fnb=@md.fnb @base_url="#{@env.url.root}/#{@fnb}" - @f=SiSU_Env::SiSU_file.new(@md) + @f=SiSU_Env::FileOp.new(@md) @base_path=@f.output_path.manifest.dir - @@dg ||=SiSU_Env::Info_env.new.digest.type + @@dg ||=SiSU_Env::InfoEnv.new.digest.type @dg=@@dg - l=SiSU_Env::Standardise_language.new(@md.opt.lng).language + l=SiSU_Env::StandardiseLanguage.new(@md.opt.lng).language @language=l[:n] @translate=SiSU_Translate::Source.new(@md,@language) @brace_url=SiSU_Viz::Skin.new.url_decoration @@ -128,7 +128,7 @@ module SiSU_QRcode #system(%{ # cat #{pt}/#{fn} | qrencode -s 3 -o qrcm.autonomy_markup0.png #}) - cmd=SiSU_Env::System_call.new(mn,@f.place_file.qrcode_md.dir,@md.opt.cmd) + cmd=SiSU_Env::SystemCall.new(mn,@f.place_file.qrcode_md.dir,@md.opt.cmd) cmd.qrencode #system(%{ # echo "#{mn}" | qrencode -s 3 -o #{@dest}/qrc_md.#{fn}.png @@ -140,7 +140,7 @@ module SiSU_QRcode @manifest[:txt_title].each do |x| mn += x end - cmd=SiSU_Env::System_call.new(mn,@f.place_file.qrcode_title.dir,@md.opt.cmd) + cmd=SiSU_Env::SystemCall.new(mn,@f.place_file.qrcode_title.dir,@md.opt.cmd) cmd.qrencode #system(%{ # echo "#{mn}" | qrencode -s 3 -o #{@dest}/qrc_title.#{fn}.png @@ -149,7 +149,7 @@ module SiSU_QRcode def summarize(id,file,pth='',rel='',url='',img='● ') size=(File.size("#{pth}/#{file}")/1024.00).to_s kb=/([0-9]+\.[0-9]{0,1})/m.match(size)[1] - @manifest[:txt] <<<<WOK + @manifest[:txt] <<<<WOK #{id} #{kb} #{@brace_url.txt_open}#{url}/#{file}#{@brace_url.txt_close} WOK @@ -163,7 +163,7 @@ WOK WOK end def summarize_sources(id,file,pth,rel,url) - sys=SiSU_Env::System_call.new + sys=SiSU_Env::SystemCall.new dgst =if @dg =~/^sha(?:2|256)$/; sys.sha256("#{pth}/#{file}") else sys.md5("#{pth}/#{file}") end @@ -176,7 +176,7 @@ WOK WOK end def published_manifests? - @f=SiSU_Env::SiSU_file.new(@md) #.base_filename + @f=SiSU_Env::FileOp.new(@md) #.base_filename @m=[] url=@f.output_path.base.url manifests={} @@ -215,7 +215,7 @@ WOK # "#{url}/sisu_manifest.#{lc}.html" #end manifests - @m.uniq! + @m=@m.uniq @m end def languages(id,file) @@ -232,11 +232,11 @@ WOK end end def metadata(id,info) - info.to_s.gsub!(/#{Mx[:br_line]}/,"\n") + info=info.to_s.gsub(/#{Mx[:br_line]}/,"\n") @manifest[:txt] << %{#{id}: #{info}\n} end def md_title_info(id,info) - info.to_s.gsub!(/#{Mx[:br_line]}/,"\n") + info=info.to_s.gsub(/#{Mx[:br_line]}/,"\n") @manifest[:txt_title] << %{#{info}\n} end def links(url,lnk,target) @@ -703,8 +703,8 @@ WOK def check_output(data) begin id,file='','' - vz=SiSU_Env::Get_init.instance.skin - @f=SiSU_Env::SiSU_file.new(@md) #.base_filename + vz=SiSU_Env::GetInit.instance.skin + @f=SiSU_Env::FileOp.new(@md) #.base_filename url=@f.output_path.base.url @en_manifest=if @env.output_dir_structure.by_language_code? "#{url}/en/manifest/#{@md.fnb}.html" @@ -728,7 +728,7 @@ WOK language_versions output_metadata output_metadata_short - rescue; SiSU_Errors::Info_error.new($!,$@,@md.opt.cmd,@md.fns).error + rescue; SiSU_Errors::InfoError.new($!,$@,@md.opt.cmd,@md.fns).error ensure end end diff --git a/lib/sisu/v3/relaxng.rb b/lib/sisu/v3/relaxng.rb index 92f06c82..77aa36cc 100644 --- a/lib/sisu/v3/relaxng.rb +++ b/lib/sisu/v3/relaxng.rb @@ -56,7 +56,7 @@ ** Description: relaxng flow/logic =end -module SiSU_relaxng +module SiSU_Relaxng require_relative 'sysenv' # sysenv.rb class RelaxNG def gpl3_or_later diff --git a/lib/sisu/v3/remote.rb b/lib/sisu/v3/remote.rb index 8da87e42..4004e5f8 100644 --- a/lib/sisu/v3/remote.rb +++ b/lib/sisu/v3/remote.rb @@ -63,11 +63,11 @@ module SiSU_Remote class Put def initialize(opt) @opt=opt - @dir=SiSU_Env::Info_env.new(@opt.fns) + @dir=SiSU_Env::InfoEnv.new(@opt.fns) @put=(@opt.fns =~/\.ssm\.sst$/) \ ? @opt.fns.gsub(/(.+)?\.ssm\.sst$/,'\1.ssm') : @opt.fns - @remote=SiSU_Env::Info_remote.new(@opt) + @remote=SiSU_Env::InfoRemote.new(@opt) end def rsync SiSU_Screen::Ansi.new(@opt.cmd,'Remote placement ->',@put).dark_grey_title_hi unless @opt.cmd =~/q/ @@ -124,9 +124,9 @@ module SiSU_Remote imagedir=base_uri + '/_sisu/image' #check on doc_skin_dir = /((?:https?|file):\/\/\S+?)\/[^\/]+?\.sst$/.match(url).captures.join + '/_sisu/skin/doc' downloaded_file=File.new("#{fnb}.-sst",'w+') - image_download_url=SiSU_Assemble::Remote_image.new.image(imagedir) + image_download_url=SiSU_Assemble::RemoteImage.new.image(imagedir) images=[] - skin=SiSU_Assemble::Remote_image.new.image(doc_skin_dir) + skin=SiSU_Assemble::RemoteImage.new.image(doc_skin_dir) f.collect.each do |r| # work area unless r =~/^%+\s/ skin << r.scan(@rgx_skin).uniq if r =~@rgx_skin @@ -139,19 +139,18 @@ module SiSU_Remote end if skin \ and skin.length > 0 - SiSU_Assemble::Remote_image.new.download_doc_skin(skin) + SiSU_Assemble::RemoteImage.new.download_doc_skin(skin) end if images \ and images.length > 1 - images.flatten! - images.uniq! + images=images.flatten.uniq images.delete_if {|x| x =~/https?:\/\// } - images.sort! + images=images.sort @msg,@msgs='downloading images:', [ images.join(',') ] @tell.call.warn unless @opt.cmd =~/q/ image_info=image_download_url + images - SiSU_Assemble::Remote_image.new.download_images(image_info) - #SiSU_Assemble::Remote_image.new.download_images(image_download_url,images) + SiSU_Assemble::RemoteImage.new.download_images(image_info) + #SiSU_Assemble::RemoteImage.new.download_images(image_download_url,images) @msg,@msgs='downloading done',nil @tell.call.warn unless @opt.cmd =~/q/ end @@ -166,7 +165,7 @@ module SiSU_Remote if get_p.length > 0 #% remote sisupod require 'net/http' for requested_pod in get_p - pod_info=Remote_download.new(requested_pod) + pod_info=RemoteDownload.new(requested_pod) Net::HTTP.start(pod_info.pod.site) do |http| resp=http.get("#{pod_info.pod.path}/#{pod_info.pod.name_source}") open(pod_info.pod.name,'wb') do |file| @@ -177,7 +176,7 @@ module SiSU_Remote end end end - class Remote_download + class RemoteDownload def initialize(requested_file) @requested_file=requested_file end diff --git a/lib/sisu/v3/rexml.rb b/lib/sisu/v3/rexml.rb index 01f9a1fd..d4692b76 100644 --- a/lib/sisu/v3/rexml.rb +++ b/lib/sisu/v3/rexml.rb @@ -68,8 +68,8 @@ module SiSU_Rexml require 'rexml/document' if FileTest.directory?("#{Config::CONFIG['rubylibdir']}/rexml") #Config::CONFIG['sitedir'] def initialize(md,fno) @md,@fno=md,fno - @env=SiSU_Env::Info_env.new(@md.fns) - @prog=SiSU_Env::Info_program.new #(md.fns) #if md + @env=SiSU_Env::InfoEnv.new(@md.fns) + @prog=SiSU_Env::InfoProgram.new #(md.fns) #if md if File.file?(@fno) @fnap=@fno #index.xml causes problems with index.html in server config end @@ -102,7 +102,7 @@ module SiSU_Rexml SiSU_Screen::Ansi.new(@md.opt.cmd,'fuschia',"File Not Found #{xmlfile}",'requested XML processing skipped').colorize unless @md.opt.cmd =~/q/ exit end - rescue; SiSU_Errors::Info_error.new($!,$@,@md.opt.cmd,@md.fns).error + rescue; SiSU_Errors::InfoError.new($!,$@,@md.opt.cmd,@md.fns).error ensure end end diff --git a/lib/sisu/v3/screen_text_color.rb b/lib/sisu/v3/screen_text_color.rb index 8fc356ac..c3fd0b29 100644 --- a/lib/sisu/v3/screen_text_color.rb +++ b/lib/sisu/v3/screen_text_color.rb @@ -68,7 +68,7 @@ module SiSU_Screen def initialize(cmd,*txt) @cmd,@txt=cmd,txt @color_instruct=txt[0] - flag=SiSU_Env::Info_processing_flag.new + flag=SiSU_Env::InfoProcessingFlag.new if @cmd if flag.color #set default colors on or off -c acts as toggle against this default, if default is off -c turns on, if default is on -c turns off @use_color=if @cmd =~/c/; false diff --git a/lib/sisu/v3/share_src.rb b/lib/sisu/v3/share_src.rb index 82fffca0..93552b49 100644 --- a/lib/sisu/v3/share_src.rb +++ b/lib/sisu/v3/share_src.rb @@ -63,9 +63,9 @@ module SiSU_Markup class Source def initialize(opt) @opt=opt - @env=SiSU_Env::Info_env.new(@opt.fns) + @env=SiSU_Env::InfoEnv.new(@opt.fns) md=SiSU_Param::Parameters.new(@opt).get - @file=SiSU_Env::SiSU_file.new(md) + @file=SiSU_Env::FileOp.new(md) stub=@opt.fnb.gsub(/~[a-z]+$/,'') end def read diff --git a/lib/sisu/v3/share_src_kdissert.rb b/lib/sisu/v3/share_src_kdissert.rb index 3cd7bb1e..336d421c 100644 --- a/lib/sisu/v3/share_src_kdissert.rb +++ b/lib/sisu/v3/share_src_kdissert.rb @@ -56,7 +56,7 @@ ** Description: share sisu source markup file, copy it to output directory! =end -module SiSU_Kdi_source +module SiSU_KdiSource require_relative 'sysenv' # sysenv.rb include SiSU_Env pwd=Dir.pwd @@ -65,7 +65,7 @@ module SiSU_Kdi_source include FileUtils def initialize(opt) @opt=opt - @env=SiSU_Env::Info_env.new(@opt.fns) + @env=SiSU_Env::InfoEnv.new(@opt.fns) @output_path="#{@env.path.output}/#{@opt.fnb}" end def read diff --git a/lib/sisu/v3/shared_html.rb b/lib/sisu/v3/shared_html.rb index ec0f1c8f..0b17ba21 100644 --- a/lib/sisu/v3/shared_html.rb +++ b/lib/sisu/v3/shared_html.rb @@ -56,10 +56,10 @@ ** Description: shared html parts =end -module SiSU_HTML_shared +module SiSU_HTML_Shared require_relative 'defaults' # defaults.rb require_relative 'html_table' # html_table.rb - class Table_html < SiSU_HTML_table::Table_html + class TableHTML < SiSU_HTML_Table::TableHTML end end __END__ diff --git a/lib/sisu/v3/shared_html_lite.rb b/lib/sisu/v3/shared_html_lite.rb index 85b1b40e..27a228eb 100644 --- a/lib/sisu/v3/shared_html_lite.rb +++ b/lib/sisu/v3/shared_html_lite.rb @@ -57,7 +57,7 @@ xml/xhtml/html formatting =end -module SiSU_Format_Shared +module SiSU_FormatShared require_relative 'defaults' # defaults.rb include SiSU_Viz class CSS_Format @@ -68,7 +68,7 @@ module SiSU_Format_Shared @md,@t_o=md,t_o @txt=@t_o.obj @id=@ocn=@t_o.ocn if defined? @t_o.ocn - @lv=@t_o.lv.to_s if @t_o.is=='heading' + @lv=@t_o.lv.to_s if @t_o.is==:heading if @md.fns != @@fns @@fns,@@hname=@md.fns,'' end @@ -80,13 +80,13 @@ module SiSU_Format_Shared @tab="\t" @brace_url=SiSU_Viz::Skin.new.url_decoration @@tablehead,@@tablefoot=[],[] - @vz=SiSU_Env::Get_init.instance.skin - @env=SiSU_Env::Info_env.new(@md.fns) + @vz=SiSU_Env::GetInit.instance.skin + @env=SiSU_Env::InfoEnv.new(@md.fns) @base_url="#{@env.url.root}/#{@md.fnb}/#{@hname}.html" end def urls(data) @words=[] - map_nametags=SiSU_Particulars::Combined_singleton.instance.get_map_nametags(@md).nametags_map + map_nametags=SiSU_Particulars::CombinedSingleton.instance.get_map_nametags(@md).nametags_map data.each do |word| @words << if word=~/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}(#{Mx[:url_o]}\S+?#{Mx[:url_c]}|#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}|image)/ if word =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/ @@ -109,16 +109,16 @@ module SiSU_Format_Shared %{<a href="#{u}">[#{png}]</a>#{caption}} else %{[#{png}] #{caption}} end - word.gsub!(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/,ins) + word=word.gsub(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/,ins) else u=case u when /^https?:\/\// u when /^:/ - u.gsub!(/^:/,'') + u=u.gsub(/^:/,'') "#{@env.url.root}/#{u}" when /^\.\.\// # can remove - u.gsub!(/^\.\.\//,'') + u=u.gsub(/^\.\.\//,'') "#{@env.url.root}/#{u}" else "#{@env.url.root}/#{@md.fnb}/#{map_nametags[u][:segname]}#{Sfx[:html]}##{u}" @@ -127,8 +127,8 @@ module SiSU_Format_Shared png=m.scan(/\S+/)[0].strip link=link.strip ins=%{<a href="#{u}">#{link}</a>} - word.gsub!(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/,ins) - word.gsub!(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/,ins) + word=word.gsub(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/,ins). + gsub(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/,ins) word end word @@ -139,33 +139,33 @@ module SiSU_Format_Shared @words=@words.join(' ') end def markup_generic(s) - s=s.gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'<b>\1</b>') - s=s.gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'<i>\1</i>') - s=s.gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'<u>\1</u>') - s=s.gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'"\1"') - s=s.gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'+{\1}+') - s=s.gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strke_c]}/,'-{\1}-') - s=s.gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,'<sup>\1</sup>') - s=s.gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,'<sub>\1</sub>') - s=s.gsub(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/,'<tt>\1</tt>') # tt, kbd - s=s.gsub(/#{Mx[:gl_o]}#(?:126|152)#{Mx[:gl_c]}/i,'~') + s=s.gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'<b>\1</b>'). + gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'<i>\1</i>'). + gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'<u>\1</u>'). + gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'"\1"'). + gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'+{\1}+'). + gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strke_c]}/,'-{\1}-'). + gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,'<sup>\1</sup>'). + gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,'<sub>\1</sub>'). + gsub(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/,'<tt>\1</tt>'). # tt, kbd + gsub(/#{Mx[:gl_o]}#(?:126|152)#{Mx[:gl_c]}/i,'~') end def markup_object(t_o) s=t_o.obj - if t_o.is !='code' + s=if t_o.is !=:code s=markup_generic(s) if s =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}|image)/ wm=s.scan(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}|image)|\S+/) words=urls(wm) - s.gsub!(/.+/m,words) + s=s.gsub(/.+/m,words) end - s.gsub!(/#{Mx[:gl_o]}(#[0-9]{3})#{Mx[:gl_c]}/u,'&\1;') - s.gsub!(/#{Mx[:gl_o]}#([a-z]{2,4})#{Mx[:gl_c]}/u,'&\1;') - s.gsub!(/#{Mx[:url_o]}[_\\](\S+?)#{Mx[:url_c]}/,'<a href="\1" target="_top">\1</a>') #http ftp matches escaped, no decoration - s.gsub!(/(#{Mx[:lnk_c]})#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,'\1<a href="\2" target="_top">\2</a>') #special case \{ e.g. \}http://url - s.gsub!(/(^|#{Mx[:gl_c]}|\s)#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,%{\\1#{@brace_url.xml_open}<a href="\\2" target="_top">\\2</a>#{@brace_url.xml_close}\\3}) #http ftp matches with decoration + s.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[:url_o]}[_\\](\S+?)#{Mx[:url_c]}/,'<a href="\1" target="_top">\1</a>'). #http ftp matches escaped, no decoration + gsub(/(#{Mx[:lnk_c]})#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,'\1<a href="\2" target="_top">\2</a>'). #special case \{ e.g. \}http://url + gsub(/(^|#{Mx[:gl_c]}|\s)#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,%{\\1#{@brace_url.xml_open}<a href="\\2" target="_top">\\2</a>#{@brace_url.xml_close}\\3}) #http ftp matches with decoration else - s.gsub!(/</m,'<'); s.gsub!(/>/m,'>') + s.gsub(/</m,'<'); s.gsub!(/>/m,'>') end s end @@ -176,11 +176,11 @@ module SiSU_Format_Shared words=urls(wm) s=s.gsub(/.+/m,words) end - s=s.gsub(/#{Mx[:gl_o]}(#[0-9]{3})#{Mx[:gl_c]}/u,'&\1;') - s=s.gsub(/#{Mx[:gl_o]}#([a-z]{2,4})#{Mx[:gl_c]}/u,'&\1;') - s=s.gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'<a href="\1" target="_top">\1</a>\2') #http ftp matches escaped, no decoration - s=s.gsub(/(#{Mx[:lnk_c]})#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,'\1<a href="\2" target="_top">\2</a>') #special case \{ e.g. \}http://url - s=s.gsub(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,%{#{@brace_url.xml_open}<a href="\\1" target="_top">\\1</a>#{@brace_url.xml_close}}) #http ftp matches with decoration + s=s.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[:url_o]}_(\S+?)#{Mx[:url_c]}/,'<a href="\1" target="_top">\1</a>\2'). #http ftp matches escaped, no decoration + gsub(/(#{Mx[:lnk_c]})#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,'\1<a href="\2" target="_top">\2</a>'). #special case \{ e.g. \}http://url + gsub(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,%{#{@brace_url.xml_open}<a href="\\1" target="_top">\\1</a>#{@brace_url.xml_close}}) #http ftp matches with decoration end def paragraph %{<p class="h#{@lv}" type="substantive" header="#{@hname}">#{@txt}</p>\n} # << "\n" @@ -252,39 +252,39 @@ GSUB @txt.split(/\n/).each do |parablock| m=parablock[/<!f(.+?)!>/,1] @@tablefoot << m if m - parablock.gsub!(/<!f.+?!>/,'') + parablock=parablock.gsub(/<!f.+?!>/,'') @@tablehead=1 if parablock =~/#{Mx[:gr_o]}Th#{Mx[:tc_p]}/u - parablock.gsub!(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}.+?#{Mx[:tc_p]}~(\d+)#{Mx[:gr_c]}/, - %{<table summary="normal text css" width="100%" border="0" bgcolor="white" cellpadding="2" align="center">}) + parablock=parablock.gsub(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}.+?#{Mx[:tc_p]}~(\d+)#{Mx[:gr_c]}/, + %{<table summary="normal text css" width="100%" border="0" bgcolor="white" cellpadding="2" align="center">}) if parablock =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/ tablefoot=[] @@tablefoot.each {|x| tablefoot << %{<p align="center"><font size=2><i>#{x}</i></font></p>\n}} @@tablefoot=[] - parablock.gsub!(/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/, + parablock=parablock.gsub(/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/, %{#{@vz.table_close}\n}) # + end if @@tablehead==1 if parablock =~/#{Mx[:tc_p]}#{Mx[:tc_p]}/u - parablock.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u, - %{\n<tr>} + - %{\n<td width="\\1%" valign="top">} + - %{#{para_table}<b>}) - parablock.gsub!(/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u, - %{</b></td><td width="\\1%" valign="top">} + - %{#{para_table}<b>}) - parablock.gsub!(/#{Mx[:tc_c]}/, '</b></td></tr>') + parablock=parablock.gsub(/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u, + %{\n<tr>} + + %{\n<td width="\\1%" valign="top">} + + %{#{para_table}<b>}). + gsub(/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u, + %{</b></td><td width="\\1%" valign="top">} + + %{#{para_table}<b>}). + gsub(/#{Mx[:tc_c]}/, '</b></td></tr>') @@tablehead=0 end parablock else - parablock.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u, - %{\n<tr>} + - %{\n<td width="\\1%" valign="top">} + - %{#{para_table}}) - parablock.gsub!(/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u, - %{</td><td width="\\1%" valign="top">} + - %{#{para_table}}) - parablock.gsub!(/#{Mx[:tc_c]}/, '</td></tr>') + parablock=parablock.gsub(/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u, + %{\n<tr>} + + %{\n<td width="\\1%" valign="top">} + + %{#{para_table}}). + gsub(/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u, + %{</td><td width="\\1%" valign="top">} + + %{#{para_table}}). + gsub(/#{Mx[:tc_c]}/, '</td></tr>') parablock end @new_content << parablock @@ -292,7 +292,7 @@ GSUB @new_content.join end end - class CSS_Format_generic #does CSS_Format in one definition, needs to be told about attrib, despite brevity of generic, easier to see structure with CSS_Format + class CSS_FormatGeneric #does CSS_Format in one definition, needs to be told about attrib, despite brevity of generic, easier to see structure with CSS_Format def initialize(attrib='',txt='',id=nil,ocnd=nil,ocns=nil,lv='',hname=nil) @tab="\t" @attrib=attrib diff --git a/lib/sisu/v3/shared_images.rb b/lib/sisu/v3/shared_images.rb new file mode 100644 index 00000000..1d398213 --- /dev/null +++ b/lib/sisu/v3/shared_images.rb @@ -0,0 +1,126 @@ +# encoding: utf-8 +=begin + + * Name: SiSU + + * Description: a framework for document structuring, publishing and search + + * Author: Ralph Amissah + + * Copyright: (C) 1997 - 2012, Ralph Amissah, All Rights Reserved. + + * License: GPL 3 or later: + + SiSU, a framework for document structuring, publishing and search + + Copyright (C) Ralph Amissah + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program. If not, see <http://www.gnu.org/licenses/>. + + If you have Internet connection, the latest version of the GPL should be + available at these locations: + <http://www.fsf.org/licensing/licenses/gpl.html> + <http://www.gnu.org/licenses/gpl.html> + + <http://www.jus.uio.no/sisu/gpl.fsf/toc.html> + <http://www.jus.uio.no/sisu/gpl.fsf/doc.html> + <http://www.jus.uio.no/sisu/gpl.fsf/plain.txt> + + * SiSU uses: + * Standard SiSU markup syntax, + * Standard SiSU meta-markup syntax, and the + * Standard SiSU object citation numbering and system + + * Hompages: + <http://www.jus.uio.no/sisu> + <http://www.sisudoc.org> + + * Download: + <http://www.jus.uio.no/sisu/SiSU/download.html> + + * Ralph Amissah + <ralph@amissah.com> + <ralph.amissah@gmail.com> + + ** Description: common file for xml generation +=end +module SiSU_Images + require_relative 'particulars' # particulars.rb + class Source + def initialize(opt) + @particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt) + end + def read + SiSU_Images::Source::Place.new(@particulars).songsheet + end + class Place + def initialize(particulars) + @particulars=particulars + @md=@particulars.md + @env=@particulars.env + @o_str ||=SiSU_Env::ProcessingSettings.new(@md).output_dir_structure + end + def songsheet + images_set.select_sisu_base + images_set.select_with_document + end + def images_set + @pwd=ENV['PWD'] + def copy(src_path,dest_path,images=nil) + if FileTest.directory?(src_path) + FileUtils::cd(src_path) + unless images + images=Dir.glob("*.{png,jpg,gif,ico}") + end + FileUtils::mkdir_p(dest_path) unless FileTest.directory?(dest_path) + FileUtils::chmod(0755,dest_path) + if images.length > 0 + images.each do |i| + FileUtils::cp_r(i,"#{dest_path}/#{i}") + FileUtils::chmod(0644,"#{dest_path}/#{i}") + end + end + FileUtils::cd(@pwd) + else puts "\tWARN, did not find - #{src_path}" + end + end + def dest_path(image_type) + pth=if image_type==:image_sys + pth=(@o_str.dump_or_redirect?) \ + ? "#{@md.file.output_path.html.dir}/image" + : "#{@env.path.webserv}/_sisu/image_sys" + elsif image_type==:image + pth=(@o_str.dump_or_redirect?) \ + ? "#{@md.file.output_path.html.dir}/image" + : "#{@env.path.webserv}/_sisu/image" + end + end + def select_with_document + images=@md.ec[:image] + src_path="#{@pwd}/_sisu/image" + dest=dest_path(:image) + copy(src_path,dest,images) + end + def select_sisu_base + images=%w[arrow_next_red.png arrow_prev_red.png arrow_up_red.png dot_clear.png dot_white.png b_doc.png b_epub.png b_odf.png b_pdf.png b_toc.png] + src_path="#{@env.path.share}/image" + dest=dest_path(:image_sys) + copy(src_path,dest,images) + end + self + end + end + end +end +__END__ diff --git a/lib/sisu/v3/shared_markup_alt.rb b/lib/sisu/v3/shared_markup_alt.rb index 12cb8393..dabb765e 100644 --- a/lib/sisu/v3/shared_markup_alt.rb +++ b/lib/sisu/v3/shared_markup_alt.rb @@ -56,7 +56,7 @@ ** Description: system environment, resource control and configuration details =end -module SiSU_text_representation +module SiSU_TextRepresentation class Alter def initialize(x) if x.class==String @@ -68,68 +68,69 @@ module SiSU_text_representation def strip_clean_of_extra_spaces # dal output tuned @s=@s.dup @s=@s.gsub(/[ ]+([,.;:?](?:$|\s))/,'\1') unless @s =~/#{Mx[:en_a_o]}|#{Mx[:en_b_o]}/ - @s=@s.gsub(/ [ ]+/,' ') - @s=@s.gsub(/^ [ ]+/,'') - @s=@s.gsub(/ [ ]+$/,'') - @s=@s.gsub(/((?:#{Mx[:fa_bold_c]}|#{Mx[:fa_italics_c]})')[ ]+(s )/,'\1\2') - @s=@s.gsub(/((?:#{Mx[:fa_bold_c]}|#{Mx[:fa_italics_c]})')[ ]+(s )/,'\1\2') + @s=@s.gsub(/ [ ]+/,' '). + gsub(/^ [ ]+/,''). + gsub(/ [ ]+$/,''). + gsub(/((?:#{Mx[:fa_bold_c]}|#{Mx[:fa_italics_c]})')[ ]+(s )/,'\1\2'). + gsub(/((?:#{Mx[:fa_bold_c]}|#{Mx[:fa_italics_c]})')[ ]+(s )/,'\1\2') end def strip_clean_of_markup # text form used in sql db search, used for digest, define rules, make same as in db clean @s=@s.dup #% same as db clean --> - @s=@s.gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'\1') - @s=@s.gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'\1') - @s=@s.gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'\1') - @s=@s.gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'\1') - @s=@s.gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'\1') - @s=@s.gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strke_c]}/,'\1') - @s=@s.gsub(/#{Mx[:fa_superscript_o]}(\d+)#{Mx[:fa_superscript_c]}/,'[\1]') - @s=@s.gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,'\1') - @s=@s.gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,'\1') - @s=@s.gsub(/#{Mx[:fa_hilite_o]}(.+?)#{Mx[:fa_hilite_c]}/,'\1') - @s=@s.gsub(/#{Mx[:gl_o]}#(?:126|152)#{Mx[:gl_c]}/i,'~') - @s=@s.gsub(/#{Mx[:en_a_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_a_c]}/,'') # endnote removed - @s=@s.gsub(/#{Mx[:en_b_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_b_c]}/,'') # endnote removed - @s=@s.gsub(/(?:#{Mx[:nbsp]})+/,' ') - @s=@s.gsub(/(?:#{Mx[:br_nl]})+/,"\n") - @s=@s.gsub(/(?:#{Mx[:br_paragraph]})+/,"\n") - @s=@s.gsub(/(?:#{Mx[:br_line]})+/,"\n") - @s=@s.gsub(/#{Mx[:gl_o]}(?:#lt|#060)#{Mx[:gl_c]}/,'<') - @s=@s.gsub(/#{Mx[:gl_o]}(?:#gt|#062)#{Mx[:gl_c]}/,'>') - @s=@s.gsub(/#{Mx[:gl_o]}#(?:038|amp)#{Mx[:gl_c]}/,'&') - @s=@s.gsub(/#{Mx[:gl_o]}#033#{Mx[:gl_c]}/,'!') - @s=@s.gsub(/#{Mx[:gl_o]}#035#{Mx[:gl_c]}/,'#') - @s=@s.gsub(/#{Mx[:gl_o]}#042#{Mx[:gl_c]}/,'*') - @s=@s.gsub(/#{Mx[:gl_o]}#045#{Mx[:gl_c]}/,'-') - @s=@s.gsub(/#{Mx[:gl_o]}#047#{Mx[:gl_c]}/,'/') - @s=@s.gsub(/#{Mx[:gl_o]}#095#{Mx[:gl_c]}/,'_') - @s=@s.gsub(/#{Mx[:gl_o]}#123#{Mx[:gl_c]}/,'{') - @s=@s.gsub(/#{Mx[:gl_o]}#125#{Mx[:gl_c]}/,'}') - @s=@s.gsub(/#{Mx[:gl_o]}#126#{Mx[:gl_c]}/,'~') - @s=@s.gsub(/#{Mx[:gl_o]}#169#{Mx[:gl_c]}/,'©') - @s=@s.gsub(/\s\s+/,' ') - @s=@s.gsub(/\s\s+/,' ') - @s=@s.strip + @s=@s.gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'\1'). + gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'\1'). + gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'\1'). + gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'\1'). + gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'\1'). + gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strke_c]}/,'\1'). + gsub(/#{Mx[:fa_superscript_o]}(\d+)#{Mx[:fa_superscript_c]}/,'[\1]'). + gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,'\1'). + gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,'\1'). + gsub(/#{Mx[:fa_hilite_o]}(.+?)#{Mx[:fa_hilite_c]}/,'\1'). + gsub(/#{Mx[:gl_o]}#(?:126|152)#{Mx[:gl_c]}/i,'~'). + gsub(/#{Mx[:en_a_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_a_c]}/,''). # endnote removed + gsub(/#{Mx[:en_b_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_b_c]}/,''). # endnote removed + gsub(/(?:#{Mx[:nbsp]})+/,' '). + gsub(/(?:#{Mx[:br_nl]})+/,"\n"). + gsub(/(?:#{Mx[:br_paragraph]})+/,"\n"). + gsub(/(?:#{Mx[:br_line]})+/,"\n"). + gsub(/#{Mx[:gl_o]}(?:#lt|#060)#{Mx[:gl_c]}/,'<'). + gsub(/#{Mx[:gl_o]}(?:#gt|#062)#{Mx[:gl_c]}/,'>'). + gsub(/#{Mx[:gl_o]}#(?:038|amp)#{Mx[:gl_c]}/,'&'). + gsub(/#{Mx[:gl_o]}#033#{Mx[:gl_c]}/,'!'). + gsub(/#{Mx[:gl_o]}#035#{Mx[:gl_c]}/,'#'). + gsub(/#{Mx[:gl_o]}#042#{Mx[:gl_c]}/,'*'). + gsub(/#{Mx[:gl_o]}#045#{Mx[:gl_c]}/,'-'). + gsub(/#{Mx[:gl_o]}#047#{Mx[:gl_c]}/,'/'). + gsub(/#{Mx[:gl_o]}#095#{Mx[:gl_c]}/,'_'). + gsub(/#{Mx[:gl_o]}#123#{Mx[:gl_c]}/,'{'). + gsub(/#{Mx[:gl_o]}#125#{Mx[:gl_c]}/,'}'). + gsub(/#{Mx[:gl_o]}#126#{Mx[:gl_c]}/,'~'). + gsub(/#{Mx[:gl_o]}#169#{Mx[:gl_c]}/,'©'). + gsub(/\s\s+/,' '). + gsub(/\s\s+/,' '). + strip end def semi_revert_markup # used for digest, define rules, make same as in db clean if @t_o - @s=@s.gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'*{\1}*') - @s=@s.gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'/{\1}/') - @s=@s.gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'_{\1}_') - @s=@s.gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'"{\1}"') - @s=@s.gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'+{\1}+') - @s=@s.gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strke_c]}/,'-{\1}-') - @s=@s.gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,'^{\1}^') - @s=@s.gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,',{\1},') - @s=@s.gsub(/#{Mx[:gl_o]}#(?:126|152)#{Mx[:gl_c]}/i,'~') - @s=@s.gsub(/#{Mx[:en_a_o]}([\d*+]+\s+.+?)#{Mx[:en_a_c]}/,'~{\1}~') # endnote marker marked up - @s=@s.gsub(/#{Mx[:en_b_o]}([\d*+]+\s+.+?)#{Mx[:en_b_c]}/,'~[\1]~') # endnote marker marked up - if @t_o.is=='heading' or @t_o.is=='para' + @s=@s.gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'*{\1}*'). + gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'/{\1}/'). + gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'_{\1}_'). + gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'"{\1}"'). + gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'+{\1}+'). + gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strke_c]}/,'-{\1}-'). + gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,'^{\1}^'). + gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,',{\1},'). + gsub(/#{Mx[:gl_o]}#(?:126|152)#{Mx[:gl_c]}/i,'~'). + gsub(/#{Mx[:en_a_o]}([\d*+]+\s+.+?)#{Mx[:en_a_c]}/,'~{\1}~'). # endnote marker marked up + gsub(/#{Mx[:en_b_o]}([\d*+]+\s+.+?)#{Mx[:en_b_c]}/,'~[\1]~') # endnote marker marked up + if @t_o.is==:heading \ + || @t_o.is==:para @s=@s.gsub(/ [ ]+/,' ') @s=@s.gsub(/(?:#{Mx[:nbsp]})+/,' ') - if @t_o.is=='heading' + if @t_o.is==:heading @s=@t_o.lv + '~ ' + @s end - if @t_o.is=='para' + if @t_o.is==:para if @t_o.bullet_ @s='_* ' + @s end @@ -139,11 +140,11 @@ module SiSU_text_representation end end end - if @t_o.is=='block' \ - or @t_o.is=='group' \ - or @t_o.is=='code' + if @t_o.is==:block \ + || @t_o.is==:group \ + || @t_o.is==:code @s=@s.gsub(/#{Mx[:nbsp]}/,' ') - @s="#{@t_o.is}{\n\n#{@s}\n\n}#{@t_o.is}" + @s="#{@t_o.is.to_s}{\n\n#{@s}\n\n}#{@t_o.is.to_s}" @s=@s.gsub(/(?:#{Mx[:br_nl]}|\n)+/m,"\n\n") end #dealing with poem and verse calls for change in dal, where start and end verse of poem are marked as such @@ -151,32 +152,32 @@ module SiSU_text_representation end @s end - def html_lite #test whether eventually can be used in db_import replacing shared_html_lite (search for SiSU_Format_Shared) + def html_lite #test whether eventually can be used in db_import replacing shared_html_lite (search for SiSU_FormatShared) if @t_o - @s=@s.gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'<b>\1</b>') - @s=@s.gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'<i>\1</i>') - @s=@s.gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'<u>\1</u>') - @s=@s.gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'"\1"') - @s=@s.gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'+{\1}+') - @s=@s.gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strke_c]}/,'-{\1}-') - @s=@s.gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,'<sup>\1</sup>') - @s=@s.gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,'<sub>\1</sub>') - @s=@s.gsub(/#{Mx[:gl_o]}#(?:126|152)#{Mx[:gl_c]}/i,'~') - if @t_o.is !='code' + @s=@s.gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'<b>\1</b>'). + gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'<i>\1</i>'). + gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'<u>\1</u>'). + gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'"\1"'). + gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'+{\1}+'). + gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strke_c]}/,'-{\1}-'). + gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,'<sup>\1</sup>'). + gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,'<sub>\1</sub>'). + gsub(/#{Mx[:gl_o]}#(?:126|152)#{Mx[:gl_c]}/i,'~') + if @t_o.is !=:code if @s =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/ wm=@s.scan(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)|\S+/) words=urls(wm) @s=@s.gsub(/.+/m,words) end - @s=@s.gsub(/#{Mx[:gl_o]}(#[0-9]{3})#{Mx[:gl_c]}/u,'&\1;') - @s=@s.gsub(/#{Mx[:gl_o]}#([a-z]{2,4})#{Mx[:gl_c]}/u,'&\1;') - @s=@s.gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'<a href="\1" target="_top">\1</a>') #http ftp matches escaped, no decoration - @s=@s.gsub(/(#{Mx[:lnk_c]})#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,'\1<a href="\2" target="_top">\2</a>\3') #special case \{ e.g. \}http://url - @s=@s.gsub(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,%{#{@url_brace.xml_open}<a href="\\1" target="_top">\\1</a>#{@url_brace.xml_close}}) #http ftp matches with decoration + @s=@s.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[:url_o]}_(\S+?)#{Mx[:url_c]}/,'<a href="\1" target="_top">\1</a>'). #http ftp matches escaped, no decoration + gsub(/(#{Mx[:lnk_c]})#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,'\1<a href="\2" target="_top">\2</a>\3'). #special case \{ e.g. \}http://url + gsub(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,%{#{@url_brace.xml_open}<a href="\\1" target="_top">\\1</a>#{@url_brace.xml_close}}) #http ftp matches with decoration else - @s=@s.gsub(/</m,'<'); @s.gsub(/>/m,'>') + @s=@s.gsub(/</m,'<').gsub(/>/m,'>') end - if @t_o.is=='paragraph' + if @t_o.is==:paragraph if @t_o.bullet_ @s=@s end @@ -184,7 +185,7 @@ module SiSU_text_representation @s=@s end end - if @t_o.is=='heading' + if @t_o.is==:heading @s=@s end else @@ -193,7 +194,7 @@ module SiSU_text_representation @s end end - class Modified_text_plus_Hash_digest + class ModifiedTextPlusHashDigest def initialize(md,x) @md=md if x.class==String @@ -201,7 +202,7 @@ module SiSU_text_representation else @t_o,@s=x,x.obj.dup end - @env ||=SiSU_Env::Info_env.new(@md.fns) + @env ||=SiSU_Env::InfoEnv.new(@md.fns) @sha_ =((@env.digest.type =='sha256') ? true : false) @sha_ ? (require 'digest/sha2') : (require 'digest/md5') end @@ -220,7 +221,7 @@ module SiSU_text_representation end def strip_clean_of_markup def txt - SiSU_text_representation::Alter.new(@s).strip_clean_of_markup + SiSU_TextRepresentation::Alter.new(@s).strip_clean_of_markup end def dgst en_dgst,img_dgst={},{} @@ -231,7 +232,7 @@ module SiSU_text_representation end def semi_revert_markup def txt - SiSU_text_representation::Alter.new(@s).semi_revert_markup + SiSU_TextRepresentation::Alter.new(@s).semi_revert_markup end def dgst txt_dgst=digest(txt) @@ -241,13 +242,13 @@ module SiSU_text_representation end def composite def stripped_clean(txt) - SiSU_text_representation::Alter.new(txt).strip_clean_of_markup + SiSU_TextRepresentation::Alter.new(txt).strip_clean_of_markup end def markup_reverted(txt) - SiSU_text_representation::Alter.new(txt).semi_revert_markup + SiSU_TextRepresentation::Alter.new(txt).semi_revert_markup end def images(imgs) - sys=SiSU_Env::System_call.new + sys=SiSU_Env::SystemCall.new line_image=[] img_dgst={} if imgs and imgs.length > 0 @@ -291,7 +292,9 @@ module SiSU_text_representation en_dgst end def dgst - if @t_o.of !='comment' and @t_o.of !='structure' and @t_o.of !='layout' + if @t_o.of !=:comment \ + && @t_o.of !=:structure \ + && @t_o.of !=:layout en_dgst,img_dgst={},{} txt_stripped_dgst=digest(stripped_clean(@t_o)) txt_markup_reverted_dgst=digest(markup_reverted(@t_o)) @@ -300,7 +303,8 @@ module SiSU_text_representation notes=@t_o.obj.scan(rgx_notes) endnotes_dgst=endnotes(notes) rgx_image=/#{Mx[:lnk_o]}(\S+\.(?:png|jpg|gif))\s.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/ - imgs=if (@t_o.is=='para' or @t_o.is=='image') \ + imgs=if (@t_o.is==:para \ + || @t_o.is==:image) \ and @t_o.obj =~rgx_image imgs=@t_o.obj.scan(rgx_image).flatten line_image=images(imgs) diff --git a/lib/sisu/v3/shared_metadata.rb b/lib/sisu/v3/shared_metadata.rb index ca81998b..14cc885a 100644 --- a/lib/sisu/v3/shared_metadata.rb +++ b/lib/sisu/v3/shared_metadata.rb @@ -56,7 +56,7 @@ ** Description: system environment, resource control and configuration details =end -module Metadata +module SiSU_Metadata class Summary attr_accessor :tag,:inf,:class,:attrib def initialize(md,display_heading=false) @@ -65,9 +65,9 @@ module Metadata end def metadata_base meta,tag=[],[] - dir=SiSU_Env::Info_env.new(@md.fns) + dir=SiSU_Env::InfoEnv.new(@md.fns) base_html="#{dir.url.root}/#{@md.fnb}" - l=SiSU_Env::Standardise_language.new(@md.opt.lng).language + l=SiSU_Env::StandardiseLanguage.new(@md.opt.lng).language language=l[:n] tr=SiSU_Translate::Source.new(@md,language) @attrib='md' @@ -434,7 +434,7 @@ module Metadata @md.creator.author_detail.each do |n| x += "#{n[:the]}, #{n[:others]}; " end - x.gsub!(/;\s*$/,'') + x=x.gsub(/;\s*$/,'') ' :author: ' + x else nil end @@ -446,7 +446,7 @@ module Metadata @md.creator.contributor_detail.each do |n| x += "#{n[:the]}, #{n[:others]}; " end - x.gsub!(/;\s*$/,'') + x=x.gsub(/;\s*$/,'') ' :contributor: ' + x else nil end @@ -458,7 +458,7 @@ module Metadata @md.creator.illustrator_detail.each do |n| x += "#{n[:the]}, #{n[:others]}; " end - x.gsub!(/;\s*$/,'') + x=x.gsub(/;\s*$/,'') ' :illustrator: ' + x else nil end @@ -470,7 +470,7 @@ module Metadata @md.creator.photographer_detail.each do |n| x += "#{n[:the]}, #{n[:others]}; " end - x.gsub!(/;\s*$/,'') + x=x.gsub(/;\s*$/,'') ' :photographer: ' + x else nil end @@ -482,7 +482,7 @@ module Metadata @md.creator.translator_detail.each do |n| x += "#{n[:the]}, #{n[:others]}; " end - x.gsub!(/;\s*$/,'') + x=x.gsub(/;\s*$/,'') ' :translator: ' + x else nil end @@ -494,7 +494,7 @@ module Metadata @md.creator.audio_detail.each do |n| x += "#{n[:the]}, #{n[:others]}; " end - x.gsub!(/;\s*$/,'') + x=x.gsub(/;\s*$/,'') ' :audio: ' + x else nil end @@ -506,7 +506,7 @@ module Metadata @md.creator.digitized_by_detail.each do |n| x += "#{n[:the]}, #{n[:others]}; " end - x.gsub!(/;\s*$/,'') + x=x.gsub(/;\s*$/,'') ' :digitized_by: ' + x else nil end @@ -518,7 +518,7 @@ module Metadata @md.creator.prepared_by_detail.each do |n| x += "#{n[:the]}, #{n[:others]}; " end - x.gsub!(/;\s*$/,'') + x=x.gsub(/;\s*$/,'') ' :prepared_by: ' + x else nil end @@ -736,107 +736,107 @@ module Metadata def utf8 if @s \ and @s.class==String - @s.gsub!(/<br(?: \/)?>/u,Mx[:br_paragraph]) - @s.gsub!(/</um,'<') # '<' # < - @s.gsub!(/</um,'<') # '<' # < - @s.gsub!(/>/um,'>') # '>' # > - @s.gsub!(/¢/um,'¢') # '¢' # ¢ - @s.gsub!(/£/um,'£') # '£' # £ - @s.gsub!(/¥/um,'¥') # '¥' # ¥ - @s.gsub!(/§/um,'§') # '§' # § - @s.gsub!(/©/um,'©') # '©' # © - @s.gsub!(/ª/um,'ª') # 'ª' # ª - @s.gsub!(/«/um,'«') # '«' # « - @s.gsub!(/®/um,'®') # '®' # ® - @s.gsub!(/°/um,'°') # '°' # ° - @s.gsub!(/±/um,'±') # '±' # ± - @s.gsub!(/²/um,'²') # '²' # ² - @s.gsub!(/³/um,'³') # '³' # ³ - @s.gsub!(/µ/um,'µ') # 'µ' # µ - @s.gsub!(/¶/um,'¶') # '¶' # ¶ - @s.gsub!(/¹/um,'¹') # '¹' # ¹ - @s.gsub!(/º/um,'º') # 'º' # º - @s.gsub!(/»/um,'»') # '»' # » - @s.gsub!(/¼/um,'¼') # '¼' # ¼ - @s.gsub!(/½/um,'½') # '½' # ½ - @s.gsub!(/¾/um,'¾') # '¾' # ¾ - @s.gsub!(/×/um,'×') # '×' # × - @s.gsub!(/÷/um,'÷') # '÷' # ÷ - @s.gsub!(/¿/um,'¿') # '¿' # ¿ - @s.gsub!(/À/um,'À') # 'À' # À - @s.gsub!(/Á/um,'Á') # 'Á' # Á - @s.gsub!(/Â/um,'Â') # 'Â' #  - @s.gsub!(/Ã/um,'Ã') # 'Ã' # à - @s.gsub!(/Ä/um,'Ä') # 'Ä' # Ä - @s.gsub!(/Å/um,'Å') # 'Å' # Å - @s.gsub!(/Æ/um,'Æ') # 'Æ' # Æ - @s.gsub!(/Ç/um,'Ç') # 'Ç' # Ç - @s.gsub!(/È/um,'È') # 'È' # È - @s.gsub!(/É/um,'É') # 'É' # É - @s.gsub!(/Ê/um,'Ê') # 'Ê' # Ê - @s.gsub!(/Ë/um,'Ë') # 'Ë' # Ë - @s.gsub!(/Ì/um,'Ì') # 'Ì' # Ì - @s.gsub!(/Í/um,'Í') # 'Í' # Í - @s.gsub!(/Î/um,'Î') # 'Î' # Î - @s.gsub!(/Ï/um,'Ï') # 'Ï' # Ï - @s.gsub!(/Ð/um,'Ð') # 'Ð' # Ð - @s.gsub!(/Ñ/um,'Ñ') # 'Ñ' # Ñ - @s.gsub!(/Ò/um,'Ò') # 'Ò' # Ò - @s.gsub!(/Ó/um,'Ó') # 'Ó' # Ó - @s.gsub!(/Ô/um,'Ô') # 'Ô' # Ô - @s.gsub!(/Õ/um,'Õ') # 'Õ' # Õ - @s.gsub!(/Ö/um,'Ö') # 'Ö' # Ö - @s.gsub!(/Ø/um,'Ø') # 'Ø' # Ø - @s.gsub!(/Ù/um,'Ù') # 'Ù' # Ù - @s.gsub!(/Ú/um,'Ú') # 'Ú' # Ú - @s.gsub!(/Û/um,'Û') # 'Û' # Û - @s.gsub!(/Ü/um,'Ü') # 'Ü' # Ü - @s.gsub!(/Ý/um,'Ý') # 'Ý' # Ý - @s.gsub!(/Þ/um,'Þ') # 'Þ' # Þ - @s.gsub!(/ß/um,'ß') # 'ß' # ß - @s.gsub!(/à/um,'à') # 'à' # à - @s.gsub!(/á/um,'á') # 'á' # á - @s.gsub!(/â/um,'â') # 'â' # â - @s.gsub!(/ã/um,'ã') # 'ã' # ã - @s.gsub!(/ä/um,'ä') # 'ä' # ä - @s.gsub!(/å/um,'å') # 'å' # å - @s.gsub!(/æ/um,'æ') # 'æ' # æ - @s.gsub!(/ç/um,'ç') # 'ç' # ç - @s.gsub!(/è/um,'è') # 'è' # è - @s.gsub!(/é/um,'é') # '´' # é - @s.gsub!(/ê/um,'ê') # 'ˆ' # ê - @s.gsub!(/ë/um,'ë') # 'ë' # ë - @s.gsub!(/ì/um,'ì') # 'ì' # ì - @s.gsub!(/í/um,'í') # '´' # í - @s.gsub!(/î/um,'î') # 'î' # î - @s.gsub!(/ï/um,'ï') # 'ï' # ï - @s.gsub!(/ð/um,'ð') # 'ð' # ð - @s.gsub!(/ñ/um,'ñ') # 'ñ' # ñ - @s.gsub!(/ò/um,'ò') # 'ò' # ò - @s.gsub!(/ó/um,'ó') # 'ó' # ó - @s.gsub!(/ô/um,'ô') # 'ô' # ô - @s.gsub!(/õ/um,'õ') # 'õ' # õ - @s.gsub!(/ö/um,'ö') # 'ö' # ö - @s.gsub!(/ø/um,'ø') # 'ø' # ø - @s.gsub!(/ù/um,'ú') # 'ù' # ú - @s.gsub!(/ú/um,'û') # 'ú' # û - @s.gsub!(/û/um,'ü') # 'û' # ü - @s.gsub!(/ü/um,'ý') # 'ü' # ý - @s.gsub!(/þ/um,'þ') # 'þ' # þ - @s.gsub!(/ÿ/um,'ÿ') # 'ÿ' # ÿ - @s.gsub!(/‘/um,'‘') # '‘' # ‘ - @s.gsub!(/’/um,'’') # '’' # ’ - @s.gsub!(/“/um,'“') # “ # “ - @s.gsub!(/”/um,'”') # ” # ” - @s.gsub!(/–/um,'–') # – # – - @s.gsub!(/—/um,'—') # — # — - @s.gsub!(/∝/um,'∝') # ∝ # ∝ - @s.gsub!(/∞/um,'∞') # ∞ # ∞ - @s.gsub!(/™/um,'™') # ™ # ™ - @s.gsub!(/✠/um,'✠') # ✗ # ✠ - @s.gsub!(/ /um,' ') # space identify - @s.gsub!(/ /um,' ') # space identify - @s.gsub!(/#{Mx[:br_paragraph]}/u,'<br />') + @s=@s.gsub(/<br(?: \/)?>/u,Mx[:br_paragraph]). + gsub(/</um,'<'). # '<' # < + gsub(/</um,'<'). # '<' # < + gsub(/>/um,'>'). # '>' # > + gsub(/¢/um,'¢'). # '¢' # ¢ + gsub(/£/um,'£'). # '£' # £ + gsub(/¥/um,'¥'). # '¥' # ¥ + gsub(/§/um,'§'). # '§' # § + gsub(/©/um,'©'). # '©' # © + gsub(/ª/um,'ª'). # 'ª' # ª + gsub(/«/um,'«'). # '«' # « + gsub(/®/um,'®'). # '®' # ® + gsub(/°/um,'°'). # '°' # ° + gsub(/±/um,'±'). # '±' # ± + gsub(/²/um,'²'). # '²' # ² + gsub(/³/um,'³'). # '³' # ³ + gsub(/µ/um,'µ'). # 'µ' # µ + gsub(/¶/um,'¶'). # '¶' # ¶ + gsub(/¹/um,'¹'). # '¹' # ¹ + gsub(/º/um,'º'). # 'º' # º + gsub(/»/um,'»'). # '»' # » + gsub(/¼/um,'¼'). # '¼' # ¼ + gsub(/½/um,'½'). # '½' # ½ + gsub(/¾/um,'¾'). # '¾' # ¾ + gsub(/×/um,'×'). # '×' # × + gsub(/÷/um,'÷'). # '÷' # ÷ + gsub(/¿/um,'¿'). # '¿' # ¿ + gsub(/À/um,'À'). # 'À' # À + gsub(/Á/um,'Á'). # 'Á' # Á + gsub(/Â/um,'Â'). # 'Â' #  + gsub(/Ã/um,'Ã'). # 'Ã' # à + gsub(/Ä/um,'Ä'). # 'Ä' # Ä + gsub(/Å/um,'Å'). # 'Å' # Å + gsub(/Æ/um,'Æ'). # 'Æ' # Æ + gsub(/Ç/um,'Ç'). # 'Ç' # Ç + gsub(/È/um,'È'). # 'È' # È + gsub(/É/um,'É'). # 'É' # É + gsub(/Ê/um,'Ê'). # 'Ê' # Ê + gsub(/Ë/um,'Ë'). # 'Ë' # Ë + gsub(/Ì/um,'Ì'). # 'Ì' # Ì + gsub(/Í/um,'Í'). # 'Í' # Í + gsub(/Î/um,'Î'). # 'Î' # Î + gsub(/Ï/um,'Ï'). # 'Ï' # Ï + gsub(/Ð/um,'Ð'). # 'Ð' # Ð + gsub(/Ñ/um,'Ñ'). # 'Ñ' # Ñ + gsub(/Ò/um,'Ò'). # 'Ò' # Ò + gsub(/Ó/um,'Ó'). # 'Ó' # Ó + gsub(/Ô/um,'Ô'). # 'Ô' # Ô + gsub(/Õ/um,'Õ'). # 'Õ' # Õ + gsub(/Ö/um,'Ö'). # 'Ö' # Ö + gsub(/Ø/um,'Ø'). # 'Ø' # Ø + gsub(/Ù/um,'Ù'). # 'Ù' # Ù + gsub(/Ú/um,'Ú'). # 'Ú' # Ú + gsub(/Û/um,'Û'). # 'Û' # Û + gsub(/Ü/um,'Ü'). # 'Ü' # Ü + gsub(/Ý/um,'Ý'). # 'Ý' # Ý + gsub(/Þ/um,'Þ'). # 'Þ' # Þ + gsub(/ß/um,'ß'). # 'ß' # ß + gsub(/à/um,'à'). # 'à' # à + gsub(/á/um,'á'). # 'á' # á + gsub(/â/um,'â'). # 'â' # â + gsub(/ã/um,'ã'). # 'ã' # ã + gsub(/ä/um,'ä'). # 'ä' # ä + gsub(/å/um,'å'). # 'å' # å + gsub(/æ/um,'æ'). # 'æ' # æ + gsub(/ç/um,'ç'). # 'ç' # ç + gsub(/è/um,'è'). # 'è' # è + gsub(/é/um,'é'). # '´' # é + gsub(/ê/um,'ê'). # 'ˆ' # ê + gsub(/ë/um,'ë'). # 'ë' # ë + gsub(/ì/um,'ì'). # 'ì' # ì + gsub(/í/um,'í'). # '´' # í + gsub(/î/um,'î'). # 'î' # î + gsub(/ï/um,'ï'). # 'ï' # ï + gsub(/ð/um,'ð'). # 'ð' # ð + gsub(/ñ/um,'ñ'). # 'ñ' # ñ + gsub(/ò/um,'ò'). # 'ò' # ò + gsub(/ó/um,'ó'). # 'ó' # ó + gsub(/ô/um,'ô'). # 'ô' # ô + gsub(/õ/um,'õ'). # 'õ' # õ + gsub(/ö/um,'ö'). # 'ö' # ö + gsub(/ø/um,'ø'). # 'ø' # ø + gsub(/ù/um,'ú'). # 'ù' # ú + gsub(/ú/um,'û'). # 'ú' # û + gsub(/û/um,'ü'). # 'û' # ü + gsub(/ü/um,'ý'). # 'ü' # ý + gsub(/þ/um,'þ'). # 'þ' # þ + gsub(/ÿ/um,'ÿ'). # 'ÿ' # ÿ + gsub(/‘/um,'‘'). # '‘' # ‘ + gsub(/’/um,'’'). # '’' # ’ + gsub(/“/um,'“'). # “ # “ + gsub(/”/um,'”'). # ” # ” + gsub(/–/um,'–'). # – # – + gsub(/—/um,'—'). # — # — + gsub(/∝/um,'∝'). # ∝ # ∝ + gsub(/∞/um,'∞'). # ∞ # ∞ + gsub(/™/um,'™'). # ™ # ™ + gsub(/✠/um,'✠'). # ✗ # ✠ + gsub(/ /um,' '). # space identify + gsub(/ /um,' '). # space identify + gsub(/#{Mx[:br_paragraph]}/u,'<br />') end @s end @@ -855,7 +855,7 @@ module Metadata WOK end def metadata - Metadata::Summary.new(@md).metadata_base + SiSU_Metadata::Summary.new(@md).metadata_base end self end @@ -872,7 +872,7 @@ WOK WOK end def metadata - Metadata::Summary.new(@md).metadata_base + SiSU_Metadata::Summary.new(@md).metadata_base end self end @@ -890,7 +890,7 @@ WOK WOK end def metadata - Metadata::Summary.new(@md).metadata_base + SiSU_Metadata::Summary.new(@md).metadata_base end self end @@ -902,7 +902,7 @@ WOK </p>} end def metadata - Metadata::Summary.new(@md,true).metadata_base + SiSU_Metadata::Summary.new(@md,true).metadata_base end self end @@ -910,32 +910,32 @@ WOK def meta_para url_brace=SiSU_Viz::Skin.new.url_decoration if @inf.class==String - @inf.gsub!(/</,'<'); @inf.gsub!(/>/,'>') - @inf.gsub!(/<br(?: \/)?>/,'<br />') + @inf=@inf.gsub(/</,'<').gsub(/>/,'>'). + gsub(/<br(?: \/)?>/,'<br />') if @inf =~/&/ inf_array=[] word=@inf.scan(/\S+|\n/) word.each do |w| # _ - / # | : ! ^ ~ - w.gsub!(/ /,' ') + w=w.gsub(/ /,' ') if w !~/&\S{2,7}?;/ - w.gsub!(/&/,'&') + w=w.gsub(/&/,'&') end inf_array << w end @inf=inf_array.join(' ') end - @inf.gsub!(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/, - '<text:a xlink:type="simple" xlink:href="\1">\1</text:a>') #http ftp matches escaped, no decoration - @inf.gsub!(/(#{Mx[:lnk_c]})#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/, - '\1<text:a xlink:type="simple" xlink:href="\2">\2</text:a>') #special case \{ e.g. \}http://url - if @inf =~/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/ - @inf.gsub!(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/, + @inf=@inf.gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/, + '<text:a xlink:type="simple" xlink:href="\1">\1</text:a>'). #http ftp matches escaped, no decoration + gsub(/(#{Mx[:lnk_c]})#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/, + '\1<text:a xlink:type="simple" xlink:href="\2">\2</text:a>') #special case \{ e.g. \}http://url + @inf=if @inf =~/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/ + @inf.gsub(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/, %{#{url_brace.xml_open}<text:a xlink:type="simple" xlink:href="\\1">\\1</text:a>#{url_brace.xml_close}}) #http ftp matches with decoration else - @inf.gsub!(/(https?:\/\/[^<>()'"\s]+)/, + @inf.gsub(/(https?:\/\/[^<>()'"\s]+)/, %{#{url_brace.xml_open}<text:a xlink:type="simple" xlink:href="\\1">\\1</text:a>#{url_brace.xml_close}}) #http ftp matches with decoration end - @inf.gsub!(/([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+)/, + @inf=@inf.gsub(/([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+)/, %{#{url_brace.xml_open}<text:a xlink:type="simple" xlink:href="mailto:\\1">\\1</text:a>#{url_brace.xml_close}}) if @inf !~/http:\/\// # improve upon, document crash where url contains '@' symbol end <<WOK @@ -943,7 +943,7 @@ WOK WOK end def metadata - Metadata::Summary.new(@md).metadata_base + SiSU_Metadata::Summary.new(@md).metadata_base end self end @@ -955,7 +955,7 @@ WOK WOK end def metadata - Metadata::Summary.new(@md).metadata_base + SiSU_Metadata::Summary.new(@md).metadata_base end self end @@ -969,12 +969,12 @@ WOK WOK end def metadata - Metadata::Summary.new(@md).metadata_base + SiSU_Metadata::Summary.new(@md).metadata_base end self end end - class TeX_metadata + class TeX_Metadata def initialize(md) @md=md @br="\\\\\n" @@ -985,19 +985,19 @@ WOK } end def spec_char(inf) - SiSU_TeX_Pdf::Special_characters.new(@md,inf).special_characters + SiSU_TeX_Pdf::SpecialCharacters.new(@md,inf).special_characters end def word_break_points(inf) - SiSU_TeX_Pdf::Special_characters.new(@md,inf).special_word_break_points + SiSU_TeX_Pdf::SpecialCharacters.new(@md,inf).special_word_break_points end def number_break_points(inf) - SiSU_TeX_Pdf::Special_characters.new(@md,inf).special_number_break_points + SiSU_TeX_Pdf::SpecialCharacters.new(@md,inf).special_number_break_points end def metadata_tex meta=[] - dir=SiSU_Env::Info_env.new(@md.fns) + dir=SiSU_Env::InfoEnv.new(@md.fns) base_html="#{dir.url.root}/#{@md.fnb}" - l=SiSU_Env::Standardise_language.new(@md.opt.lng).language + l=SiSU_Env::StandardiseLanguage.new(@md.opt.lng).language language=l[:n] tr=SiSU_Translate::Source.new(@md,language) tag="Document Manifest @" diff --git a/lib/sisu/v3/shared_sem.rb b/lib/sisu/v3/shared_sem.rb index c61ccd3e..5a6adb20 100644 --- a/lib/sisu/v3/shared_sem.rb +++ b/lib/sisu/v3/shared_sem.rb @@ -57,7 +57,7 @@ ** Description: system environment, resource control and configuration details =end -module SiSU_sem +module SiSU_Sem require_relative 'param' # param.rb class Tags def initialize(para,md) diff --git a/lib/sisu/v3/shared_txt.rb b/lib/sisu/v3/shared_txt.rb index fbb8e1ac..4afddc05 100644 --- a/lib/sisu/v3/shared_txt.rb +++ b/lib/sisu/v3/shared_txt.rb @@ -56,7 +56,7 @@ ** Description: modules shared by flatfile output generators =end -module SiSU_text_utils +module SiSU_TextUtils class Wrap def initialize(para='',n_char_max=76,n_indent=0,n_hang=nil) @para,@n_char_max,@n_indent=para,n_char_max,n_indent @@ -70,8 +70,8 @@ module SiSU_text_utils line=0 out=[] out[line]='' - @para.gsub!(/<br>/,' <br> ') - @para.gsub!(/#{Mx[:br_nl]}/,"\n\n") + @para=@para.gsub(/<br>/,' <br> '). + gsub(/#{Mx[:br_nl]}/,"\n\n") words=@para.scan(/\n\n|<br>|\S+/m) while words != '' word=words.shift @@ -118,13 +118,13 @@ module SiSU_text_utils if @para.class==Array @arr=[] @para.each do |line| - @arr << SiSU_text_utils::Wrap.new(line,@n_char_max,@n_indent,@n_hang).line_wrap + @arr << SiSU_TextUtils::Wrap.new(line,@n_char_max,@n_indent,@n_hang).line_wrap end end @arr end end - class Header_scan + class HeaderScan def initialize(md,para) @md,@p=md,para end diff --git a/lib/sisu/v3/shared_xhtml.rb b/lib/sisu/v3/shared_xhtml.rb index 16cb9b14..f135aa6a 100644 --- a/lib/sisu/v3/shared_xhtml.rb +++ b/lib/sisu/v3/shared_xhtml.rb @@ -56,10 +56,10 @@ ** Description: shared html parts =end -module SiSU_XHTML_shared +module SiSU_XHTML_Shared require_relative 'defaults' # defaults.rb require_relative 'xhtml_table' # xhtml_table.rb - class Table_xhtml < SiSU_XHTML_table::Table_xhtml + class TableXHTML < SiSU_XHTML_Table::TableXHTML end end __END__ diff --git a/lib/sisu/v3/shared_xml.rb b/lib/sisu/v3/shared_xml.rb index 40ee2550..6b85d756 100644 --- a/lib/sisu/v3/shared_xml.rb +++ b/lib/sisu/v3/shared_xml.rb @@ -55,13 +55,13 @@ ** Description: common file for xml generation =end -module SiSU_XML_munge +module SiSU_XML_Munge class Trans require_relative 'defaults' # defaults.rb def initialize(md) @md=md - @sys=SiSU_Env::System_call.new - @dir=SiSU_Env::Info_env.new(@md.fns) + @sys=SiSU_Env::SystemCall.new + @dir=SiSU_Env::InfoEnv.new(@md.fns) @brace_url=SiSU_Viz::Skin.new.url_decoration if @md.sem_tag @ab ||=semantic_tags.default @@ -116,405 +116,410 @@ module SiSU_XML_munge if str #¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûü #¢£¥§©ª«®°±²³µ¶¹º»¼½¾×÷ - str.gsub!(/</um,'<') # '<' # < - str.gsub!(/>/um,'>') # '>' # > - str.gsub!(/¢/um,'¢') # '¢' # ¢ - str.gsub!(/£/um,'£') # '£' # £ - str.gsub!(/¥/um,'¥') # '¥' # ¥ - str.gsub!(/§/um,'§') # '§' # § - str.gsub!(/©/um,'©') # '©' # © - str.gsub!(/ª/um,'ª') # 'ª' # ª - str.gsub!(/«/um,'«') # '«' # « - str.gsub!(/®/um,'®') # '®' # ® - str.gsub!(/°/um,'°') # '°' # ° - str.gsub!(/±/um,'±') # '±' # ± - str.gsub!(/²/um,'²') # '²' # ² - str.gsub!(/³/um,'³') # '³' # ³ - str.gsub!(/µ/um,'µ') # 'µ' # µ - str.gsub!(/¶/um,'¶') # '¶' # ¶ - str.gsub!(/¹/um,'¹') # '¹' # ¹ - str.gsub!(/º/um,'º') # 'º' # º - str.gsub!(/»/um,'»') # '»' # » - str.gsub!(/¼/um,'¼') # '¼' # ¼ - str.gsub!(/½/um,'½') # '½' # ½ - str.gsub!(/¾/um,'¾') # '¾' # ¾ - str.gsub!(/×/um,'×') # '×' # × - str.gsub!(/÷/um,'÷') # '÷' # ÷ - str.gsub!(/¿/um,'¿') # '¿' # ¿ - str.gsub!(/À/um,'À') # 'À' # À - str.gsub!(/Á/um,'Á') # 'Á' # Á - str.gsub!(/Â/um,'Â') # 'Â' #  - str.gsub!(/Ã/um,'Ã') # 'Ã' # à - str.gsub!(/Ä/um,'Ä') # 'Ä' # Ä - str.gsub!(/Å/um,'Å') # 'Å' # Å - str.gsub!(/Æ/um,'Æ') # 'Æ' # Æ - str.gsub!(/Ç/um,'Ç') # 'Ç' # Ç - str.gsub!(/È/um,'È') # 'È' # È - str.gsub!(/É/um,'É') # 'É' # É - str.gsub!(/Ê/um,'Ê') # 'Ê' # Ê - str.gsub!(/Ë/um,'Ë') # 'Ë' # Ë - str.gsub!(/Ì/um,'Ì') # 'Ì' # Ì - str.gsub!(/Í/um,'Í') # 'Í' # Í - str.gsub!(/Î/um,'Î') # 'Î' # Î - str.gsub!(/Ï/um,'Ï') # 'Ï' # Ï - str.gsub!(/Ð/um,'Ð') # 'Ð' # Ð - str.gsub!(/Ñ/um,'Ñ') # 'Ñ' # Ñ - str.gsub!(/Ò/um,'Ò') # 'Ò' # Ò - str.gsub!(/Ó/um,'Ó') # 'Ó' # Ó - str.gsub!(/Ô/um,'Ô') # 'Ô' # Ô - str.gsub!(/Õ/um,'Õ') # 'Õ' # Õ - str.gsub!(/Ö/um,'Ö') # 'Ö' # Ö - str.gsub!(/Ø/um,'Ø') # 'Ø' # Ø - str.gsub!(/Ù/um,'Ù') # 'Ù' # Ù - str.gsub!(/Ú/um,'Ú') # 'Ú' # Ú - str.gsub!(/Û/um,'Û') # 'Û' # Û - str.gsub!(/Ü/um,'Ü') # 'Ü' # Ü - str.gsub!(/Ý/um,'Ý') # 'Ý' # Ý - str.gsub!(/Þ/um,'Þ') # 'Þ' # Þ - str.gsub!(/ß/um,'ß') # 'ß' # ß - str.gsub!(/à/um,'à') # 'à' # à - str.gsub!(/á/um,'á') # 'á' # á - str.gsub!(/â/um,'â') # 'â' # â - str.gsub!(/ã/um,'ã') # 'ã' # ã - str.gsub!(/ä/um,'ä') # 'ä' # ä - str.gsub!(/å/um,'å') # 'å' # å - str.gsub!(/æ/um,'æ') # 'æ' # æ - str.gsub!(/ç/um,'ç') # 'ç' # ç - str.gsub!(/è/um,'è') # 'è' # è - str.gsub!(/é/um,'é') # '´' # é - str.gsub!(/ê/um,'ê') # 'ˆ' # ê - str.gsub!(/ë/um,'ë') # 'ë' # ë - str.gsub!(/ì/um,'ì') # 'ì' # ì - str.gsub!(/í/um,'í') # '´' # í - str.gsub!(/î/um,'î') # 'î' # î - str.gsub!(/ï/um,'ï') # 'ï' # ï - str.gsub!(/ð/um,'ð') # 'ð' # ð - str.gsub!(/ñ/um,'ñ') # 'ñ' # ñ - str.gsub!(/ò/um,'ò') # 'ò' # ò - str.gsub!(/ó/um,'ó') # 'ó' # ó - str.gsub!(/ô/um,'ô') # 'ô' # ô - str.gsub!(/õ/um,'õ') # 'õ' # õ - str.gsub!(/ö/um,'ö') # 'ö' # ö - str.gsub!(/ø/um,'ø') # 'ø' # ø - str.gsub!(/ù/um,'ú') # 'ù' # ú - str.gsub!(/ú/um,'û') # 'ú' # û - str.gsub!(/û/um,'ü') # 'û' # ü - str.gsub!(/ü/um,'ý') # 'ü' # ý - str.gsub!(/þ/um,'þ') # 'þ' # þ - str.gsub!(/ÿ/um,'ÿ') # 'ÿ' # ÿ - str.gsub!(/‘/um,'‘') # '‘' # ‘ - str.gsub!(/’/um,'’') # '’' # ’ - str.gsub!(/“/um,'“') # “ # “ - str.gsub!(/”/um,'”') # ” # ” - str.gsub!(/–/um,'–') # – # – - str.gsub!(/—/um,'—') # — # — - str.gsub!(/∝/um,'∝') # ∝ # ∝ - str.gsub!(/∞/um,'∞') # ∞ # ∞ - str.gsub!(/™/um,'™') # ™ # ™ - str.gsub!(/✠/um,'✠') # ✗ # ✠ - str.gsub!(/ /um,' ') # space identify - str.gsub!(/ /um,' ') # space identify + str=str.gsub(/</um,'<'). # '<' # < + gsub(/>/um,'>'). # '>' # > + gsub(/¢/um,'¢'). # '¢' # ¢ + gsub(/£/um,'£'). # '£' # £ + gsub(/¥/um,'¥'). # '¥' # ¥ + gsub(/§/um,'§'). # '§' # § + gsub(/©/um,'©'). # '©' # © + gsub(/ª/um,'ª'). # 'ª' # ª + gsub(/«/um,'«'). # '«' # « + gsub(/®/um,'®'). # '®' # ® + gsub(/°/um,'°'). # '°' # ° + gsub(/±/um,'±'). # '±' # ± + gsub(/²/um,'²'). # '²' # ² + gsub(/³/um,'³'). # '³' # ³ + gsub(/µ/um,'µ'). # 'µ' # µ + gsub(/¶/um,'¶'). # '¶' # ¶ + gsub(/¹/um,'¹'). # '¹' # ¹ + gsub(/º/um,'º'). # 'º' # º + gsub(/»/um,'»'). # '»' # » + gsub(/¼/um,'¼'). # '¼' # ¼ + gsub(/½/um,'½'). # '½' # ½ + gsub(/¾/um,'¾'). # '¾' # ¾ + gsub(/×/um,'×'). # '×' # × + gsub(/÷/um,'÷'). # '÷' # ÷ + gsub(/¿/um,'¿'). # '¿' # ¿ + gsub(/À/um,'À'). # 'À' # À + gsub(/Á/um,'Á'). # 'Á' # Á + gsub(/Â/um,'Â'). # 'Â' #  + gsub(/Ã/um,'Ã'). # 'Ã' # à + gsub(/Ä/um,'Ä'). # 'Ä' # Ä + gsub(/Å/um,'Å'). # 'Å' # Å + gsub(/Æ/um,'Æ'). # 'Æ' # Æ + gsub(/Ç/um,'Ç'). # 'Ç' # Ç + gsub(/È/um,'È'). # 'È' # È + gsub(/É/um,'É'). # 'É' # É + gsub(/Ê/um,'Ê'). # 'Ê' # Ê + gsub(/Ë/um,'Ë'). # 'Ë' # Ë + gsub(/Ì/um,'Ì'). # 'Ì' # Ì + gsub(/Í/um,'Í'). # 'Í' # Í + gsub(/Î/um,'Î'). # 'Î' # Î + gsub(/Ï/um,'Ï'). # 'Ï' # Ï + gsub(/Ð/um,'Ð'). # 'Ð' # Ð + gsub(/Ñ/um,'Ñ'). # 'Ñ' # Ñ + gsub(/Ò/um,'Ò'). # 'Ò' # Ò + gsub(/Ó/um,'Ó'). # 'Ó' # Ó + gsub(/Ô/um,'Ô'). # 'Ô' # Ô + gsub(/Õ/um,'Õ'). # 'Õ' # Õ + gsub(/Ö/um,'Ö'). # 'Ö' # Ö + gsub(/Ø/um,'Ø'). # 'Ø' # Ø + gsub(/Ù/um,'Ù'). # 'Ù' # Ù + gsub(/Ú/um,'Ú'). # 'Ú' # Ú + gsub(/Û/um,'Û'). # 'Û' # Û + gsub(/Ü/um,'Ü'). # 'Ü' # Ü + gsub(/Ý/um,'Ý'). # 'Ý' # Ý + gsub(/Þ/um,'Þ'). # 'Þ' # Þ + gsub(/ß/um,'ß'). # 'ß' # ß + gsub(/à/um,'à'). # 'à' # à + gsub(/á/um,'á'). # 'á' # á + gsub(/â/um,'â'). # 'â' # â + gsub(/ã/um,'ã'). # 'ã' # ã + gsub(/ä/um,'ä'). # 'ä' # ä + gsub(/å/um,'å'). # 'å' # å + gsub(/æ/um,'æ'). # 'æ' # æ + gsub(/ç/um,'ç'). # 'ç' # ç + gsub(/è/um,'è'). # 'è' # è + gsub(/é/um,'é'). # '´' # é + gsub(/ê/um,'ê'). # 'ˆ' # ê + gsub(/ë/um,'ë'). # 'ë' # ë + gsub(/ì/um,'ì'). # 'ì' # ì + gsub(/í/um,'í'). # '´' # í + gsub(/î/um,'î'). # 'î' # î + gsub(/ï/um,'ï'). # 'ï' # ï + gsub(/ð/um,'ð'). # 'ð' # ð + gsub(/ñ/um,'ñ'). # 'ñ' # ñ + gsub(/ò/um,'ò'). # 'ò' # ò + gsub(/ó/um,'ó'). # 'ó' # ó + gsub(/ô/um,'ô'). # 'ô' # ô + gsub(/õ/um,'õ'). # 'õ' # õ + gsub(/ö/um,'ö'). # 'ö' # ö + gsub(/ø/um,'ø'). # 'ø' # ø + gsub(/ù/um,'ú'). # 'ù' # ú + gsub(/ú/um,'û'). # 'ú' # û + gsub(/û/um,'ü'). # 'û' # ü + gsub(/ü/um,'ý'). # 'ü' # ý + gsub(/þ/um,'þ'). # 'þ' # þ + gsub(/ÿ/um,'ÿ'). # 'ÿ' # ÿ + gsub(/‘/um,'‘'). # '‘' # ‘ + gsub(/’/um,'’'). # '’' # ’ + gsub(/“/um,'“'). # “ # “ + gsub(/”/um,'”'). # ” # ” + gsub(/–/um,'–'). # – # – + gsub(/—/um,'—'). # — # — + gsub(/∝/um,'∝'). # ∝ # ∝ + gsub(/∞/um,'∞'). # ∞ # ∞ + gsub(/™/um,'™'). # ™ # ™ + gsub(/✠/um,'✠'). # ✗ # ✠ + gsub(/ /um,' '). # space identify + gsub(/ /um,' ') # space identify end dob=if defined? dob.obj dob.obj=str dob - elsif dob.class==String; dob + elsif dob.class==String + str end dob end end def html(dob='') if @sys.locale =~/utf-?8/i # instead ucs for utf8 # String#encode Iñtërnâtiônàlizætiøn - dob.obj.gsub!(/ /u,' ') # space identify - dob.obj.gsub!(/ /u,' ') # space identify + dob.obj=dob.obj.gsub(/ /u,' '). # space identify + gsub(/ /u,' ') # space identify else - dob.obj.gsub!(/¢/u,'¢') # ¢ - dob.obj.gsub!(/£/u,'£') # £ - dob.obj.gsub!(/¥/u,'¥') # ¥ - dob.obj.gsub!(/§/u,'§') # § - dob.obj.gsub!(/©/u,'©') # © - dob.obj.gsub!(/ª/u,'ª') # ª - dob.obj.gsub!(/«/u,'«') # « - dob.obj.gsub!(/®/u,'®') # ® - dob.obj.gsub!(/°/u,'°') # ° - dob.obj.gsub!(/±/u,'±') # ± - dob.obj.gsub!(/²/u,'²') # ² - dob.obj.gsub!(/³/u,'³') # ³ - dob.obj.gsub!(/µ/u,'µ') # µ - dob.obj.gsub!(/¶/u,'¶') # ¶ - dob.obj.gsub!(/¹/u,'¹') # ¹ - dob.obj.gsub!(/º/u,'º') # º - dob.obj.gsub!(/»/u,'»') # » - dob.obj.gsub!(/¼/u,'¼') # ¼ - dob.obj.gsub!(/½/u,'½') # ½ - dob.obj.gsub!(/¾/u,'¾') # ¾ - dob.obj.gsub!(/×/u,'×') # × - dob.obj.gsub!(/÷/u,'÷') # ÷ - dob.obj.gsub!(/¿/u,'¿') # ¿ - dob.obj.gsub!(/À/u,'À') # À - dob.obj.gsub!(/Á/u,'Á') # Á - dob.obj.gsub!(/Â/u,'Â') #  - dob.obj.gsub!(/Ã/u,'Ã') # à - dob.obj.gsub!(/Ä/u,'Ä') # Ä - dob.obj.gsub!(/Å/u,'Å') # Å - dob.obj.gsub!(/Æ/u,'Æ') # Æ - dob.obj.gsub!(/Ç/u,'Ç') # Ç - dob.obj.gsub!(/È/u,'È') # È - dob.obj.gsub!(/É/u,'É') # É - dob.obj.gsub!(/Ê/u,'Ê') # Ê - dob.obj.gsub!(/Ë/u,'Ë') # Ë - dob.obj.gsub!(/Ì/u,'Ì') # Ì - dob.obj.gsub!(/Í/u,'Í') # Í - dob.obj.gsub!(/Î/u,'Î') # Î - dob.obj.gsub!(/Ï/u,'Ï') # Ï - dob.obj.gsub!(/Ð/u,'Ð') # Ð - dob.obj.gsub!(/Ñ/u,'Ñ') # Ñ - dob.obj.gsub!(/Ò/u,'Ò') # Ò - dob.obj.gsub!(/Ó/u,'Ó') # Ó - dob.obj.gsub!(/Ô/u,'Ô') # Ô - dob.obj.gsub!(/Õ/u,'Õ') # Õ - dob.obj.gsub!(/Ö/u,'Ö') # Ö - dob.obj.gsub!(/Ø/u,'Ø') # Ø - dob.obj.gsub!(/Ù/u,'Ù') # Ù - dob.obj.gsub!(/Ú/u,'Ú') # Ú - dob.obj.gsub!(/Û/u,'Û') # Û - dob.obj.gsub!(/Ü/u,'Ü') # Ü - dob.obj.gsub!(/Ý/u,'Ý') # Ý - dob.obj.gsub!(/Þ/u,'Þ') # Þ - dob.obj.gsub!(/ß/u,'ß') # ß - dob.obj.gsub!(/à/u,'à') # à - dob.obj.gsub!(/á/u,'á') # á - dob.obj.gsub!(/â/u,'â') # â - dob.obj.gsub!(/ã/u,'ã') # ã - dob.obj.gsub!(/ä/u,'ä') # ä - dob.obj.gsub!(/å/u,'å') # å - dob.obj.gsub!(/æ/u,'æ') # æ - dob.obj.gsub!(/ç/u,'ç') # ç - dob.obj.gsub!(/è/u,'è') # è - dob.obj.gsub!(/é/u,'´') # é - dob.obj.gsub!(/ê/u,'ˆ') # ê - dob.obj.gsub!(/ë/u,'ë') # ë - dob.obj.gsub!(/ì/u,'ì') # ì - dob.obj.gsub!(/í/u,'´') # í - dob.obj.gsub!(/î/u,'î') # î - dob.obj.gsub!(/ï/u,'ï') # ï - dob.obj.gsub!(/ð/u,'ð') # ð - dob.obj.gsub!(/ñ/u,'ñ') # ñ - dob.obj.gsub!(/ò/u,'ò') # ò - dob.obj.gsub!(/ó/u,'ó') # ó - dob.obj.gsub!(/ô/u,'ô') # ô - dob.obj.gsub!(/õ/u,'õ') # õ - dob.obj.gsub!(/ö/u,'ö') # ö - dob.obj.gsub!(/ø/u,'ø') # ø - dob.obj.gsub!(/ù/u,'ù') # ú - dob.obj.gsub!(/ú/u,'ú') # û - dob.obj.gsub!(/û/u,'û') # ü - dob.obj.gsub!(/ü/u,'ü') # ý - dob.obj.gsub!(/þ/u,'þ') # þ - dob.obj.gsub!(/ÿ/u,'ÿ') # ÿ - dob.obj.gsub!(/‘/u,'&#lsquo;') # ‘ # ‘ - dob.obj.gsub!(/’/u,'&#rsquo;') # ’ # ’ - dob.obj.gsub!(/“/u,'“') # “ # “ - dob.obj.gsub!(/”/u,'”') # ” # ” - dob.obj.gsub!(/–/u,'–') # – # – - dob.obj.gsub!(/—/u,'—') # — # — - dob.obj.gsub!(/∝/u,'∝') # ∝ # ∝ - dob.obj.gsub!(/∞/u,'∞') # ∞ # ∞ - dob.obj.gsub!(/™/u,'™') # ™ # ™ - dob.obj.gsub!(/✠/u,'✠') # ✠ - #par.obja.gsub!(/✠/u '†') # † # † incorrect replacement † - dob.obj.gsub!(/ /u,' ') # space identify - dob.obj.gsub!(/ /u,' ') # space identify + dob.obj=dob.obj.gsub(/¢/u,'¢'). # ¢ + gsub(/£/u,'£'). # £ + gsub(/¥/u,'¥'). # ¥ + gsub(/§/u,'§'). # § + gsub(/©/u,'©'). # © + gsub(/ª/u,'ª'). # ª + gsub(/«/u,'«'). # « + gsub(/®/u,'®'). # ® + gsub(/°/u,'°'). # ° + gsub(/±/u,'±'). # ± + gsub(/²/u,'²'). # ² + gsub(/³/u,'³'). # ³ + gsub(/µ/u,'µ'). # µ + gsub(/¶/u,'¶'). # ¶ + gsub(/¹/u,'¹'). # ¹ + gsub(/º/u,'º'). # º + gsub(/»/u,'»'). # » + gsub(/¼/u,'¼'). # ¼ + gsub(/½/u,'½'). # ½ + gsub(/¾/u,'¾'). # ¾ + gsub(/×/u,'×'). # × + gsub(/÷/u,'÷'). # ÷ + gsub(/¿/u,'¿'). # ¿ + gsub(/À/u,'À'). # À + gsub(/Á/u,'Á'). # Á + gsub(/Â/u,'Â'). #  + gsub(/Ã/u,'Ã'). # à + gsub(/Ä/u,'Ä'). # Ä + gsub(/Å/u,'Å'). # Å + gsub(/Æ/u,'Æ'). # Æ + gsub(/Ç/u,'Ç'). # Ç + gsub(/È/u,'È'). # È + gsub(/É/u,'É'). # É + gsub(/Ê/u,'Ê'). # Ê + gsub(/Ë/u,'Ë'). # Ë + gsub(/Ì/u,'Ì'). # Ì + gsub(/Í/u,'Í'). # Í + gsub(/Î/u,'Î'). # Î + gsub(/Ï/u,'Ï'). # Ï + gsub(/Ð/u,'Ð'). # Ð + gsub(/Ñ/u,'Ñ'). # Ñ + gsub(/Ò/u,'Ò'). # Ò + gsub(/Ó/u,'Ó'). # Ó + gsub(/Ô/u,'Ô'). # Ô + gsub(/Õ/u,'Õ'). # Õ + gsub(/Ö/u,'Ö'). # Ö + gsub(/Ø/u,'Ø'). # Ø + gsub(/Ù/u,'Ù'). # Ù + gsub(/Ú/u,'Ú'). # Ú + gsub(/Û/u,'Û'). # Û + gsub(/Ü/u,'Ü'). # Ü + gsub(/Ý/u,'Ý'). # Ý + gsub(/Þ/u,'Þ'). # Þ + gsub(/ß/u,'ß'). # ß + gsub(/à/u,'à'). # à + gsub(/á/u,'á'). # á + gsub(/â/u,'â'). # â + gsub(/ã/u,'ã'). # ã + gsub(/ä/u,'ä'). # ä + gsub(/å/u,'å'). # å + gsub(/æ/u,'æ'). # æ + gsub(/ç/u,'ç'). # ç + gsub(/è/u,'è'). # è + gsub(/é/u,'´'). # é + gsub(/ê/u,'ˆ'). # ê + gsub(/ë/u,'ë'). # ë + gsub(/ì/u,'ì'). # ì + gsub(/í/u,'´'). # í + gsub(/î/u,'î'). # î + gsub(/ï/u,'ï'). # ï + gsub(/ð/u,'ð'). # ð + gsub(/ñ/u,'ñ'). # ñ + gsub(/ò/u,'ò'). # ò + gsub(/ó/u,'ó'). # ó + gsub(/ô/u,'ô'). # ô + gsub(/õ/u,'õ'). # õ + gsub(/ö/u,'ö'). # ö + gsub(/ø/u,'ø'). # ø + gsub(/ù/u,'ù'). # ú + gsub(/ú/u,'ú'). # û + gsub(/û/u,'û'). # ü + gsub(/ü/u,'ü'). # ý + gsub(/þ/u,'þ'). # þ + gsub(/ÿ/u,'ÿ'). # ÿ + gsub(/‘/u,'&#lsquo;'). # ‘ # ‘ + gsub(/’/u,'&#rsquo;'). # ’ # ’ + gsub(/“/u,'“'). # “ # “ + gsub(/”/u,'”'). # ” # ” + gsub(/–/u,'–'). # – # – + gsub(/—/u,'—'). # — # — + gsub(/∝/u,'∝'). # ∝ # ∝ + gsub(/∞/u,'∞'). # ∞ # ∞ + gsub(/™/u,'™'). # ™ # ™ + gsub(/✠/u,'✠'). # ✠ + #gsub(/✠/u '†'). # † # † incorrect replacement † + gsub(/ /u,' '). # space identify + gsub(/ /u,' ') # space identify end end self end def tidywords(wordlist) + wordlist_new=[] wordlist.each do |x| #imperfect solution will not catch all possible cases - x.gsub!(/&/,'&') unless x =~/&\S+;/ - x.gsub!(/&([A-Z])/,'&\1') + x=x.gsub(/&/,'&') unless x =~/&\S+;/ + x=x.gsub(/&([A-Z])/,'&\1') + wordlist_new << x end + wordlist_new end def markup(dob='') wordlist=dob.obj.scan(/&[#0-9a-z]+;|\S+|\n/) #\n needed for tables, check though added 2005w17 dob.obj=tidywords(wordlist).join(' ').strip - unless dob.is=='table' - dob.obj.gsub!(/#{Mx[:br_line]}/u,'<br />') - dob.obj.gsub!(/#{Mx[:br_paragraph]}/u,'<br />') - dob.obj.gsub!(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,'<br />') - end - dob.obj.gsub!(/#{Mx[:mk_o]}:name#\S+?#{Mx[:mk_c]}/,'') - dob.obj.gsub!(/#{Mx[:mk_o]}#([a-zA-Z]+)#{Mx[:mk_c]}/,'&\1;') - dob.obj.gsub!(/#{Mx[:mk_o]}(#[0-9]+)#{Mx[:mk_c]}/,'&\1;') - dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s+)<\s+/,'\1< '); dob.obj.gsub!(/\s+>(\s+|$)/,' >\1') - #dob.obj.gsub!(/#{Mx[:fa_emphasis_o]}(.+?)#{Mx[:fa_emphasis_c]}/,'<em>\1</em>') #reinstate - dob.obj.gsub!(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/m,'<b>\1</b>') - dob.obj.gsub!(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/m,'<i>\1</i>') - dob.obj.gsub!(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'<u>\1</u>') - dob.obj.gsub!(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,'<sup>\1</sup>') - dob.obj.gsub!(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,'<sub>\1</sub>') - dob.obj.gsub!(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'<ins>\1</ins>') - dob.obj.gsub!(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'<cite>\1</cite>') - dob.obj.gsub!(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'<del>\1</del>') - dob.obj.gsub!(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/,'<tt>\1</tt>') - dob.obj.gsub!(/<:pb>\s*/,'') #Fix - dob.obj.gsub!(/<+[-~]#>+/,'') - if dob.is !~/^code/ + unless dob.is==:table + dob.obj=dob.obj.gsub(/#{Mx[:br_line]}/u,'<br />'). + gsub(/#{Mx[:br_paragraph]}/u,'<br />'). + gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,'<br />') + end + dob.obj=dob.obj.gsub(/#{Mx[:mk_o]}:name#\S+?#{Mx[:mk_c]}/,''). + gsub(/#{Mx[:mk_o]}#([a-zA-Z]+)#{Mx[:mk_c]}/,'&\1;'). + gsub(/#{Mx[:mk_o]}(#[0-9]+)#{Mx[:mk_c]}/,'&\1;'). + gsub(/(^|#{Mx[:gl_c]}|\s+)<\s+/,'\1< ').gsub(/\s+>(\s+|$)/,' >\1'). + #gsub(/#{Mx[:fa_emphasis_o]}(.+?)#{Mx[:fa_emphasis_c]}/,'<em>\1</em>'). #reinstate + gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/m,'<b>\1</b>'). + gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/m,'<i>\1</i>'). + gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'<u>\1</u>'). + gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,'<sup>\1</sup>'). + gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,'<sub>\1</sub>'). + gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'<ins>\1</ins>'). + gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'<cite>\1</cite>'). + gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'<del>\1</del>'). + gsub(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/,'<tt>\1</tt>'). + gsub(/<:pb>\s*/,''). #Fix + gsub(/<+[-~]#>+/,'') + if dob.is !=:code #embeds a red-bullet image --> - dob.obj.gsub!(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'<b>\1</b>') - dob.obj.gsub!(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'<i>\1</i>') - dob.obj.gsub!(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'<u>\1</u>') - dob.obj.gsub!(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'<del>\1</del>') - dob.obj.gsub!(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,'<br />') unless dob.is=='table' - dob.obj.gsub!(/#{Mx[:br_page]}\s*/,'') - dob.obj.gsub!(/#{Mx[:br_page_new]}\s*/,'') - dob.obj.gsub!(/#{Mx[:pa_non_object_no_heading]}|#{Mx[:pa_non_object_dummy_heading]}/,''); dob.obj.gsub!(/<[-~]#>/,'') - dob.obj.gsub!(/href="#{Xx[:segment]}/m,'href="') - dob.obj.gsub!(/#{Mx[:lnk_o]}([^#{Mx[:lnk_o]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{Mx[:rel_c]}]+?)#{Mx[:lnk_c]}#{Mx[:rel_o]}(\.\.\/\S+?)#{Mx[:rel_c]}/, - '<link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="\2">\1</link>') - dob.obj.gsub!(/#{Mx[:lnk_o]}([^#{Mx[:lnk_o]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{Mx[:rel_c]}]+?)#{Mx[:lnk_c]}#{Mx[:rel_o]}:(\S+?)#{Mx[:rel_c]}/, - '<link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="../\2">\1</link>') - dob.obj.gsub!(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:rel_o]}(\S+?)#{Mx[:rel_c]}/, - '<link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="#\2">\1</link>') - dob.obj.gsub!(/(?:^|[^_\\])#{Mx[:lnk_o]}[ ]*(\S+?\.(?:jpg|png|gif))[ ]+(\d+)x(\d+)(\s+[^}]+)?#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/, - %{<image xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:actuate="onLoad" xlink:show="embed" xlink:href="#{@md.file.output_path.xml.rel_image}/\\1" width="\\2" height="\\3" />[\\1] \\4}) - dob.obj.gsub!(/(?:^|[^_\\])#{Mx[:lnk_o]}[ ]*(\S+?\.(?:jpg|png|gif))([ ]+[^}]+)?#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/, - %{<image xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:actuate="onLoad" xlink:show="embed" xlink:href="#{@md.file.output_path.xml.rel_image}/\\1"/>\\1}) - dob.obj.gsub!(/(?:^|[^_\\])#{Mx[:lnk_o]}[ ]*(\S+?\.(?:jpg|png|gif))[ ]+(\d+)x(\d+)(\s+[^}]+)?#{Mx[:lnk_c]}image/, - %{<image xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:actuate="onLoad" xlink:show="embed" xlink:href="#{@md.file.output_path.xml.rel_image}/\\1" width="\\2" height="\\3" />[\\1] \\4}) - dob.obj.gsub!(/(?:^|[^_\\])#{Mx[:lnk_o]}[ ]*(\S+?\.(?:jpg|png|gif))([ ]+[^}]+)?#{Mx[:lnk_c]}image/, - %{<image xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:actuate="onLoad" xlink:show="embed" xlink:href="#{@md.file.output_path.xml.rel_image}/\\1"/>\\1}) - dob.obj.gsub!(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/, - '<link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="\2">\1</link>') #watch, compare html_tune - dob.obj.gsub!(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/, - %{#{@brace_url.xml_open}<link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="\\1">\\1</link>#{@brace_url.xml_close}}) - dob.obj.gsub!(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/, - '<link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="\1">\1</link>') #escaped urls not linked, deal with later + dob.obj=dob.obj.gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'<b>\1</b>'). + gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'<i>\1</i>'). + gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'<u>\1</u>'). + gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'<del>\1</del>') + dob.obj=dob.obj.gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,'<br />') unless dob.is==:table + dob.obj=dob.obj.gsub(/#{Mx[:br_page]}\s*/,''). + gsub(/#{Mx[:br_page_new]}\s*/,''). + gsub(/#{Mx[:pa_non_object_no_heading]}|#{Mx[:pa_non_object_dummy_heading]}/,''). + gsub(/<[-~]#>/,''). + gsub(/href="#{Xx[:segment]}/m,'href="'). + gsub(/#{Mx[:lnk_o]}([^#{Mx[:lnk_o]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{Mx[:rel_c]}]+?)#{Mx[:lnk_c]}#{Mx[:rel_o]}(\.\.\/\S+?)#{Mx[:rel_c]}/, + '<link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="\2">\1</link>'). + gsub(/#{Mx[:lnk_o]}([^#{Mx[:lnk_o]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{Mx[:rel_c]}]+?)#{Mx[:lnk_c]}#{Mx[:rel_o]}:(\S+?)#{Mx[:rel_c]}/, + '<link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="../\2">\1</link>'). + gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:rel_o]}(\S+?)#{Mx[:rel_c]}/, + '<link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="#\2">\1</link>'). + gsub(/(?:^|[^_\\])#{Mx[:lnk_o]}[ ]*(\S+?\.(?:jpg|png|gif))[ ]+(\d+)x(\d+)(\s+[^}]+)?#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/, + %{<image xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:actuate="onLoad" xlink:show="embed" xlink:href="#{@md.file.output_path.xml.rel_image}/\\1" width="\\2" height="\\3" />[\\1] \\4}). + gsub(/(?:^|[^_\\])#{Mx[:lnk_o]}[ ]*(\S+?\.(?:jpg|png|gif))([ ]+[^}]+)?#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/, + %{<image xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:actuate="onLoad" xlink:show="embed" xlink:href="#{@md.file.output_path.xml.rel_image}/\\1"/>\\1}). + gsub(/(?:^|[^_\\])#{Mx[:lnk_o]}[ ]*(\S+?\.(?:jpg|png|gif))[ ]+(\d+)x(\d+)(\s+[^}]+)?#{Mx[:lnk_c]}image/, + %{<image xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:actuate="onLoad" xlink:show="embed" xlink:href="#{@md.file.output_path.xml.rel_image}/\\1" width="\\2" height="\\3" />[\\1] \\4}). + gsub(/(?:^|[^_\\])#{Mx[:lnk_o]}[ ]*(\S+?\.(?:jpg|png|gif))([ ]+[^}]+)?#{Mx[:lnk_c]}image/, + %{<image xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:actuate="onLoad" xlink:show="embed" xlink:href="#{@md.file.output_path.xml.rel_image}/\\1"/>\\1}). + gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/, + '<link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="\2">\1</link>'). #watch, compare html_tune + gsub(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/, + %{#{@brace_url.xml_open}<link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="\\1">\\1</link>#{@brace_url.xml_close}}). + gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/, + '<link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="\1">\1</link>') #escaped urls not linked, deal with later else - dob.obj.gsub!(/</m,'<'); dob.obj.gsub!(/>/m,'>') + dob.obj=dob.obj.gsub(/</m,'<').gsub(/>/m,'>') end - if dob.of=='block' - dob.obj.gsub!(/#{Mx[:gl_bullet]}/,'● ') + if dob.of==:block + dob.obj=dob.obj.gsub(/#{Mx[:gl_bullet]}/,'● ') end - dob.obj.gsub!(/#{Mx[:url_o]}([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)#{Mx[:url_c]}/, - %{#{@brace_url.xml_open}\\1#{@brace_url.xml_close}}) - dob.obj.gsub!(/#{Dx[:url_o]}/,"#{Dx[:url_o_xml]}") - dob.obj.gsub!(/#{Dx[:url_c]}/,"#{Dx[:url_c_xml]}") - dob.obj.gsub!(/ |#{Mx[:nbsp]}/m,' ') + dob.obj=dob.obj.gsub(/#{Mx[:url_o]}([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)#{Mx[:url_c]}/, + %{#{@brace_url.xml_open}\\1#{@brace_url.xml_close}}). + gsub(/#{Dx[:url_o]}/,"#{Dx[:url_o_xml]}"). + gsub(/#{Dx[:url_c]}/,"#{Dx[:url_c_xml]}"). + gsub(/ |#{Mx[:nbsp]}/m,' ') dob end def markup_light(dob='') - dob.obj.gsub!(/\/\{(.+?)\}\//,'<i>\1</i>') - dob.obj.gsub!(/[*!]\{(.+?)\}[*!]/,'<b>\1</b>') - dob.obj.gsub!(/_\{(.+?)\}_/,'<u>\1</u>') - dob.obj.gsub!(/-\{(.+?)\}-/,'<del>\1</del>') - dob.obj.gsub!(/<br(\s*\/)?>/,'<br />') - dob.obj.gsub!(/<:pb>\s*/,'') - dob.obj.gsub!(/<[-~]#>/,'') - dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s)&\s+/,'\1& ') #sort - dob.obj.gsub!(/&([^;]{1,5})/,'&\1') #sort, rough estimate, revisit #WATCH found in node not sax - dob.obj.gsub!(/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif))[ ]+.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/, - "<image.path>#{@md.file.output_path.xml.rel_image}\/\\1</image.path>") - dob.obj.gsub!(/ |#{Mx[:nbsp]}/,' ') + dob.obj=dob.obj.gsub(/\/\{(.+?)\}\//,'<i>\1</i>'). + gsub(/[*!]\{(.+?)\}[*!]/,'<b>\1</b>'). + gsub(/_\{(.+?)\}_/,'<u>\1</u>'). + gsub(/-\{(.+?)\}-/,'<del>\1</del>'). + gsub(/<br(\s*\/)?>/,'<br />'). + gsub(/<:pb>\s*/,''). + gsub(/<[-~]#>/,''). + gsub(/(^|#{Mx[:gl_c]}|\s)&\s+/,'\1& '). #sort + gsub(/&([^;]{1,5})/,'&\1'). #sort, rough estimate, revisit #WATCH found in node not sax + gsub(/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif))[ ]+.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/, + "<image.path>#{@md.file.output_path.xml.rel_image}\/\\1</image.path>"). + gsub(/ |#{Mx[:nbsp]}/,' ') wordlist=dob.obj.scan(/&[#0-9a-z]+;|\S+|\n/) #\n needed for tables, check though added 2005w17 dob.obj=tidywords(wordlist).join(' ').strip dob end def markup_fictionbook(dob='') - dob.obj.gsub!(/~\{([\d*+]+).+?\}~/,'[\1]') - dob.obj.gsub!(/\/\{(.+?)\}\//,'<i>\1</i>') - dob.obj.gsub!(/[*!]\{(.+?)\}[*!]/,'<b>\1</b>') - dob.obj.gsub!(/_\{(.+?)\}_/,'<u>\1</u>') - dob.obj.gsub!(/-\{(.+?)\}-/,'<del>\1</del>') - dob.obj.gsub!(/<br(?:\s*\/)?>/,'<br />') - dob.obj.gsub!(/<:pb>\s*/,'') - dob.obj.gsub!(/<[-~]#>/,'') - #temporary --> - dob.obj.gsub!(/<:\S+?>/,'') - #<-- temporary - dob.obj.gsub!(/<[-~]#>/,'') - dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s)&\s+/,'\1& ') #sort - dob.obj.gsub!(/&([^;]{1,5})/,'&\1') #sort, rough estimate, revisit #WATCH found in node not sax - dob.obj.gsub!(/(#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif))[ ]+.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/, - "<image.path>#{@md.file.output_path.xml.rel_image}\/\\1</image.path>") - dob.obj.gsub!(/ |#{Mx[:nbsp]}/,' ') + dob.obj.gsub(/~\{([\d*+]+).+?\}~/,'[\1]'). + gsub(/\/\{(.+?)\}\//,'<i>\1</i>'). + gsub(/[*!]\{(.+?)\}[*!]/,'<b>\1</b>'). + gsub(/_\{(.+?)\}_/,'<u>\1</u>'). + gsub(/-\{(.+?)\}-/,'<del>\1</del>'). + gsub(/<br(?:\s*\/)?>/,'<br />'). + gsub(/<:pb>\s*/,''). + gsub(/<[-~]#>/,''). + #temporary --> + gsub(/<:\S+?>/,''). + #<-- temporary + gsub(/<[-~]#>/,''). + gsub(/(^|#{Mx[:gl_c]}|\s)&\s+/,'\1& '). #sort + gsub(/&([^;]{1,5})/,'&\1') #sort, rough estimate, revisit #WATCH found in node not sax + gsub(/(#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif))[ ]+.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/, + "<image.path>#{@md.file.output_path.xml.rel_image}\/\\1</image.path>"). + gsub(/ |#{Mx[:nbsp]}/,' ') wordlist=dob.obj.scan(/&[#0-9a-z]+;|\S+|\n/) #\n needed for tables, check though added 2005w17 dob.obj=tidywords(wordlist).join(' ').strip dob end def markup_group(dob='') - dob.obj.gsub!(/</,'<'); dob.obj.gsub!(/>/,'>') - dob.obj.gsub!(/<:?br(?:\s+\/)?>/,'<br />') - dob.obj.gsub!(/<(link xmlns:xlink=".+?")>/,'<\1>') - dob.obj.gsub!(/<(\/link)>/,'<\1>') - dob.obj.gsub!(/<(\/?en)>/,'<\1>') + dob.obj=dob.obj.gsub(/</,'<').gsub(/>/,'>'). + gsub(/<:?br(?:\s+\/)?>/,'<br />'). + gsub(/<(link xmlns:xlink=".+?")>/,'<\1>'). + gsub(/<(\/link)>/,'<\1>'). + gsub(/<(\/?en)>/,'<\1>') dob end def markup_block(dob='') - dob.obj.gsub!(/</,'<'); dob.obj.gsub!(/>/,'>') - dob.obj.gsub!(/<:?br(?:\s+\/)?>/,'<br />') - dob.obj.gsub!(/<(link xmlns:xlink=".+?")>/,'<\1>') - dob.obj.gsub!(/<(\/link)>/,'<\1>') - dob.obj.gsub!(/<(\/?en)>/,'<\1>') + dob.obj=dob.obj.gsub(/</,'<').gsub(/>/,'>'). + gsub(/<:?br(?:\s+\/)?>/,'<br />'). + gsub(/<(link xmlns:xlink=".+?")>/,'<\1>'). + gsub(/<(\/link)>/,'<\1>'). + gsub(/<(\/?en)>/,'<\1>') dob end def xml_sem_block_paired(matched) # colon depth: many, recurs - matched.gsub!(/\b(au):\{(.+?)\}:\1\b/m, %{<sem:#{@ab[:au]} depth="many">\\2</sem:#{@ab[:au]}>}) - matched.gsub!(/\b(vol):\{(.+?)\}:\1\b/m, %{<sem:#{@ab[:vol]} depth="many">\\2</sem:#{@ab[:vol]}>}) - matched.gsub!(/\b(pub):\{(.+?)\}:\1\b/m, %{<sem:#{@ab[:pub]} depth="many">\\2</sem:#{@ab[:pub]}>}) - matched.gsub!(/\b(ref):\{(.+?)\}:\1\b/m, %{<sem:#{@ab[:ref]} depth="many">\\2</sem:#{@ab[:ref]}>}) - matched.gsub!(/\b(desc):\{(.+?)\}:\1\b/m,%{<sem:#{@ab[:desc]} depth="many">\\2</sem:#{@ab[:desc]}>}) - matched.gsub!(/\b(conv):\{(.+?)\}:\1\b/m,%{<sem:#{@ab[:conv]} depth="many">\\2</sem:#{@ab[:conv]}>}) - matched.gsub!(/\b(ct):\{(.+?)\}:\1\b/m, %{<sem:#{@ab[:ct]} depth="many">\\2</sem:#{@ab[:ct]}>}) - matched.gsub!(/\b(cty):\{(.+?)\}:\1\b/m, %{<sem:#{@ab[:cty]} depth="many">\\2</sem:#{@ab[:cty]}>}) - matched.gsub!(/\b(org):\{(.+?)\}:\1\b/m, %{<sem:#{@ab[:org]} depth="many">\\2</sem:#{@ab[:org]}>}) - matched.gsub!(/\b(dt):\{(.+?)\}:\1\b/m, %{<sem:#{@ab[:dt]} depth="many">\\2</sem:#{@ab[:dt]}>}) - matched.gsub!(/\b(n):\{(.+?)\}:\1\b/m, %{<sem:#{@ab[:n]} depth="many">\\2</sem:#{@ab[:n]}>}) - matched.gsub!(/([a-z]+(?:[_:.][a-z]+)*)(?::\{(.+?)\}:\1)/m,'<sem:\1 depth="many">\2</sem:\1>') + matched=matched.gsub(/\b(au):\{(.+?)\}:\1\b/m, %{<sem:#{@ab[:au]} depth="many">\\2</sem:#{@ab[:au]}>}). + gsub(/\b(vol):\{(.+?)\}:\1\b/m, %{<sem:#{@ab[:vol]} depth="many">\\2</sem:#{@ab[:vol]}>}). + gsub(/\b(pub):\{(.+?)\}:\1\b/m, %{<sem:#{@ab[:pub]} depth="many">\\2</sem:#{@ab[:pub]}>}). + gsub(/\b(ref):\{(.+?)\}:\1\b/m, %{<sem:#{@ab[:ref]} depth="many">\\2</sem:#{@ab[:ref]}>}). + gsub(/\b(desc):\{(.+?)\}:\1\b/m,%{<sem:#{@ab[:desc]} depth="many">\\2</sem:#{@ab[:desc]}>}). + gsub(/\b(conv):\{(.+?)\}:\1\b/m,%{<sem:#{@ab[:conv]} depth="many">\\2</sem:#{@ab[:conv]}>}). + gsub(/\b(ct):\{(.+?)\}:\1\b/m, %{<sem:#{@ab[:ct]} depth="many">\\2</sem:#{@ab[:ct]}>}). + gsub(/\b(cty):\{(.+?)\}:\1\b/m, %{<sem:#{@ab[:cty]} depth="many">\\2</sem:#{@ab[:cty]}>}). + gsub(/\b(org):\{(.+?)\}:\1\b/m, %{<sem:#{@ab[:org]} depth="many">\\2</sem:#{@ab[:org]}>}). + gsub(/\b(dt):\{(.+?)\}:\1\b/m, %{<sem:#{@ab[:dt]} depth="many">\\2</sem:#{@ab[:dt]}>}). + gsub(/\b(n):\{(.+?)\}:\1\b/m, %{<sem:#{@ab[:n]} depth="many">\\2</sem:#{@ab[:n]}>}). + gsub(/([a-z]+(?:[_:.][a-z]+)*)(?::\{(.+?)\}:\1)/m,'<sem:\1 depth="many">\2</sem:\1>') end def xml_semantic_tags(dob) if @md.sem_tag dob.obj.gsub!(/([a-z]+(?:[_:.][a-z]+)*)(?::\{(.+?)\}:\1)/m) {|c| xml_sem_block_paired(c) } dob.obj.gsub!(/([a-z]+(?:[_:.][a-z]+)*)(?::\{(.+?)\}:\1)/m) {|c| xml_sem_block_paired(c) } dob.obj.gsub!(/([a-z]+(?:[_:.][a-z]+)*)(?::\{(.+?)\}:\1)/m) {|c| xml_sem_block_paired(c) } - dob.obj.gsub!(/:\{(.+?)\}:au\b/m, %{<sem:#{@ab[:au]} depth="one">\\1</sem:#{@ab[:au]}>}) - dob.obj.gsub!(/:\{(.+?)\}:n\b/m, %{<sem:#{@ab[:n]} depth="one">\\1</sem:#{@ab[:n]}>}) - dob.obj.gsub!(/:\{(.+?)\}:ti\b/m, %{<sem:#{@ab[:ti]} depth="one">\\1</sem:#{@ab[:ti]}>}) - dob.obj.gsub!(/:\{(.+?)\}:ref\b/m, %{<sem:#{@ab[:ref]} depth="one">\\1</sem:#{@ab[:ref]}>}) - dob.obj.gsub!(/:\{(.+?)\}:desc\b/m, %{<sem:#{@ab[:desc]} depth="one">\\1</sem:#{@ab[:desc]}>}) - dob.obj.gsub!(/:\{(.+?)\}:cty\b/m, %{<sem:#{@ab[:cty]} depth="one">\\1</sem:#{@ab[:cty]}>}) - dob.obj.gsub!(/:\{(.+?)\}:org\b/m, %{<sem:#{@ab[:org]} depth="one">\\1</sem:#{@ab[:org]}>}) - dob.obj.gsub!(/:\{(.+?)\}:([a-z]+(?:[_:.][a-z]+)*)/m,'<sem:\2 depth="one">\1</sem:\2>') - dob.obj.gsub!(/;\{([^}]+(?![;]))\};ti\b/m, %{<sem:#{@ab[:ti]} depth="zero">\\1</sem:#{@ab[:ti]}>}) - dob.obj.gsub!(/;\{([^}]+(?![;]))\};qt\b/m, %{<sem:#{@ab[:qt]} depth="zero">\\1</sem:#{@ab[:qt]}>}) - dob.obj.gsub!(/;\{([^}]+(?![;]))\};ref\b/m, %{<sem:#{@ab[:ref]} depth="zero">\\1</sem:#{@ab[:ref]}>}) - dob.obj.gsub!(/;\{([^}]+(?![;]))\};ed\b/m, %{<sem:#{@ab[:ed]} depth="zero">\\1</sem:#{@ab[:ed]}>}) - dob.obj.gsub!(/;\{([^}]+(?![;]))\};v\b/m, %{<sem:#{@ab[:v]} depth="zero">\\1</sem:#{@ab[:v]}>}) - dob.obj.gsub!(/;\{([^}]+(?![;]))\};desc\b/m, %{<sem:#{@ab[:desc]} depth="zero">\\1</sem:#{@ab[:desc]}>}) - dob.obj.gsub!(/;\{([^}]+(?![;]))\};def\b/m, %{<sem:#{@ab[:def]} depth="zero">\\1</sem:#{@ab[:def]}>}) - dob.obj.gsub!(/;\{([^}]+(?![;]))\};trans\b/m, %{<sem:#{@ab[:trans]} depth="zero">\\1</sem:#{@ab[:trans]}>}) - dob.obj.gsub!(/;\{([^}]+(?![;]))\};y\b/m, %{<sem:#{@ab[:y]} depth="zero">\\1</sem:#{@ab[:y]}>}) - dob.obj.gsub!(/;\{([^}]+(?![;]))\};ab\b/m, %{<sem:#{@ab[:ab]} depth="zero">\\1</sem:#{@ab[:ab]}>}) - dob.obj.gsub!(/;\{([^}]+(?![;]))\};pg\b/m, %{<sem:#{@ab[:pg]} depth="zero">\\1</sem:#{@ab[:pg]}>}) - dob.obj.gsub!(/;\{([^}]+(?![;]))\};fn?\b/m, %{<sem:#{@ab[:fn]} depth="zero">\\1</sem:#{@ab[:fn]}>}) - dob.obj.gsub!(/;\{([^}]+(?![;]))\};mn?\b/m, %{<sem:#{@ab[:mn]} depth="zero">\\1</sem:#{@ab[:mn]}>}) - dob.obj.gsub!(/;\{([^}]+(?![;]))\};ln?\b/m, %{<sem:#{@ab[:ln]} depth="zero">\\1</sem:#{@ab[:ln]}>}) - dob.obj.gsub!(/;\{([^}]+(?![;]))\};in\b/m, %{<sem:#{@ab[:in]} depth="zero">\\1</sem:#{@ab[:in]}>}) - dob.obj.gsub!(/;\{([^}]+(?![;]))\};uni\b/m, %{<sem:#{@ab[:uni]} depth="zero">\\1</sem:#{@ab[:uni]}>}) - dob.obj.gsub!(/;\{([^}]+(?![;]))\};fac\b/m, %{<sem:#{@ab[:fac]} depth="zero">\\1</sem:#{@ab[:fac]}>}) - dob.obj.gsub!(/;\{([^}]+(?![;]))\};inst\b/m, %{<sem:#{@ab[:inst]} depth="zero">\\1</sem:#{@ab[:inst]}>}) - dob.obj.gsub!(/;\{([^}]+(?![;]))\};dept\b/m, %{<sem:#{@ab[:dpt]} depth="zero">\\1</sem:#{@ab[:dept]}>}) - dob.obj.gsub!(/;\{([^}]+(?![;]))\};org\b/m, %{<sem:#{@ab[:org]} depth="zero">\\1</sem:#{@ab[:org]}>}) - dob.obj.gsub!(/;\{([^}]+(?![;]))\};com?\b/m, %{<sem:#{@ab[:com]} depth="zero">\\1</sem:#{@ab[:com]}>}) - dob.obj.gsub!(/;\{([^}]+(?![;]))\};cty\b/m, %{<sem:#{@ab[:cty]} depth="zero">\\1</sem:#{@ab[:cty]}>}) - dob.obj.gsub!(/;\{([^}]+(?![;]))\};([a-z]+(?:[_:.][a-z]+)*)/m,'<sem:\2 depth="zero">\1</sem:\2>') + dob.obj=dob.obj.gsub(/:\{(.+?)\}:au\b/m, %{<sem:#{@ab[:au]} depth="one">\\1</sem:#{@ab[:au]}>}). + gsub(/:\{(.+?)\}:n\b/m, %{<sem:#{@ab[:n]} depth="one">\\1</sem:#{@ab[:n]}>}). + gsub(/:\{(.+?)\}:ti\b/m, %{<sem:#{@ab[:ti]} depth="one">\\1</sem:#{@ab[:ti]}>}). + gsub(/:\{(.+?)\}:ref\b/m, %{<sem:#{@ab[:ref]} depth="one">\\1</sem:#{@ab[:ref]}>}). + gsub(/:\{(.+?)\}:desc\b/m, %{<sem:#{@ab[:desc]} depth="one">\\1</sem:#{@ab[:desc]}>}). + gsub(/:\{(.+?)\}:cty\b/m, %{<sem:#{@ab[:cty]} depth="one">\\1</sem:#{@ab[:cty]}>}). + gsub(/:\{(.+?)\}:org\b/m, %{<sem:#{@ab[:org]} depth="one">\\1</sem:#{@ab[:org]}>}). + gsub(/:\{(.+?)\}:([a-z]+(?:[_:.][a-z]+)*)/m,'<sem:\2 depth="one">\1</sem:\2>'). + gsub(/;\{([^}]+(?![;]))\};ti\b/m, %{<sem:#{@ab[:ti]} depth="zero">\\1</sem:#{@ab[:ti]}>}). + gsub(/;\{([^}]+(?![;]))\};qt\b/m, %{<sem:#{@ab[:qt]} depth="zero">\\1</sem:#{@ab[:qt]}>}). + gsub(/;\{([^}]+(?![;]))\};ref\b/m, %{<sem:#{@ab[:ref]} depth="zero">\\1</sem:#{@ab[:ref]}>}). + gsub(/;\{([^}]+(?![;]))\};ed\b/m, %{<sem:#{@ab[:ed]} depth="zero">\\1</sem:#{@ab[:ed]}>}). + gsub(/;\{([^}]+(?![;]))\};v\b/m, %{<sem:#{@ab[:v]} depth="zero">\\1</sem:#{@ab[:v]}>}). + gsub(/;\{([^}]+(?![;]))\};desc\b/m, %{<sem:#{@ab[:desc]} depth="zero">\\1</sem:#{@ab[:desc]}>}). + gsub(/;\{([^}]+(?![;]))\};def\b/m, %{<sem:#{@ab[:def]} depth="zero">\\1</sem:#{@ab[:def]}>}). + gsub(/;\{([^}]+(?![;]))\};trans\b/m, %{<sem:#{@ab[:trans]} depth="zero">\\1</sem:#{@ab[:trans]}>}). + gsub(/;\{([^}]+(?![;]))\};y\b/m, %{<sem:#{@ab[:y]} depth="zero">\\1</sem:#{@ab[:y]}>}). + gsub(/;\{([^}]+(?![;]))\};ab\b/m, %{<sem:#{@ab[:ab]} depth="zero">\\1</sem:#{@ab[:ab]}>}). + gsub(/;\{([^}]+(?![;]))\};pg\b/m, %{<sem:#{@ab[:pg]} depth="zero">\\1</sem:#{@ab[:pg]}>}). + gsub(/;\{([^}]+(?![;]))\};fn?\b/m, %{<sem:#{@ab[:fn]} depth="zero">\\1</sem:#{@ab[:fn]}>}). + gsub(/;\{([^}]+(?![;]))\};mn?\b/m, %{<sem:#{@ab[:mn]} depth="zero">\\1</sem:#{@ab[:mn]}>}). + gsub(/;\{([^}]+(?![;]))\};ln?\b/m, %{<sem:#{@ab[:ln]} depth="zero">\\1</sem:#{@ab[:ln]}>}). + gsub(/;\{([^}]+(?![;]))\};in\b/m, %{<sem:#{@ab[:in]} depth="zero">\\1</sem:#{@ab[:in]}>}). + gsub(/;\{([^}]+(?![;]))\};uni\b/m, %{<sem:#{@ab[:uni]} depth="zero">\\1</sem:#{@ab[:uni]}>}). + gsub(/;\{([^}]+(?![;]))\};fac\b/m, %{<sem:#{@ab[:fac]} depth="zero">\\1</sem:#{@ab[:fac]}>}). + gsub(/;\{([^}]+(?![;]))\};inst\b/m, %{<sem:#{@ab[:inst]} depth="zero">\\1</sem:#{@ab[:inst]}>}). + gsub(/;\{([^}]+(?![;]))\};dept\b/m, %{<sem:#{@ab[:dpt]} depth="zero">\\1</sem:#{@ab[:dept]}>}). + gsub(/;\{([^}]+(?![;]))\};org\b/m, %{<sem:#{@ab[:org]} depth="zero">\\1</sem:#{@ab[:org]}>}). + gsub(/;\{([^}]+(?![;]))\};com?\b/m, %{<sem:#{@ab[:com]} depth="zero">\\1</sem:#{@ab[:com]}>}). + gsub(/;\{([^}]+(?![;]))\};cty\b/m, %{<sem:#{@ab[:cty]} depth="zero">\\1</sem:#{@ab[:cty]}>}). + gsub(/;\{([^}]+(?![;]))\};([a-z]+(?:[_:.][a-z]+)*)/m,'<sem:\2 depth="zero">\1</sem:\2>') end dob end end end -module SiSU_XML_tags #Format +module SiSU_XML_Tags #Format require_relative 'param' # param.rb include SiSU_Param include SiSU_Viz @@ -642,13 +647,13 @@ module SiSU_XML_tags #Format end content=meta_content_clean(@md.keywords) @keywords=%{ <meta name="keywords" content="#{content}" />\n} if @md.keywords - @vz=SiSU_Env::Get_init.instance.skin + @vz=SiSU_Env::GetInit.instance.skin end def meta_content_clean(content='') content unless content.nil? - content.tr!('"',"'") - content=SiSU_XML_munge::Trans.new(@md).char_enc.utf8(content) + content=content.tr('"',"'") + content=SiSU_XML_Munge::Trans.new(@md).char_enc.utf8(content) end content end diff --git a/lib/sisu/v3/sisupod_make.rb b/lib/sisu/v3/sisupod_make.rb index 7a3b4727..ac584925 100644 --- a/lib/sisu/v3/sisupod_make.rb +++ b/lib/sisu/v3/sisupod_make.rb @@ -65,13 +65,13 @@ module SiSU_Doc def initialize(opt) @opt=opt m=/.+\/(?:src\/)?(\S+)/im - @date=SiSU_Env::Info_date.new.dt - @env=SiSU_Env::Info_env.new(@opt.fns) - @ver=SiSU_Env::Info_version.instance.get_version + @date=SiSU_Env::InfoDate.new.dt + @env=SiSU_Env::InfoEnv.new(@opt.fns) + @ver=SiSU_Env::InfoVersion.instance.get_version @ans=SiSU_Response::Response.new pod_path="#{@env.processing_path.processing}/sisupod" @v=(@opt.cmd =~/[VM]/) ? 'v' : '' - @particulars=SiSU_Particulars::Combined_singleton.instance.get_all(opt) + @particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt) @file=@particulars.file @local_path="#{@file.output_path.sisupod.dir}" @zipfile=(@opt.fns =~/\.ssm\.sst$/) \ @@ -132,7 +132,7 @@ module SiSU_Doc end end def directories - SiSU_Env::Info_env.new.sisupod_v3(@opt) + SiSU_Env::InfoEnv.new.sisupod_v3(@opt) end def select_skin(skin='') #skin loading logic here load "#{SiSU_lib}/defaults.rb" @@ -183,7 +183,7 @@ module SiSU_Doc file_array.each do |f| #% work area if f !~/^%+\s/ skin << f.scan(@rgx_skin).uniq.flatten if f =~@rgx_skin - f.gsub!(/<:=(\S+?)>/,'{ c_\1.png 14x14 }image') # embedded symbol (image) + f=f.gsub(/<:=(\S+?)>/,'{ c_\1.png 14x14 }image') # embedded symbol (image) if f !~/^%+\s/ \ and f =~@rgx_image images=images_extract(f,images) @@ -238,10 +238,9 @@ module SiSU_Doc #2. need images used by skin, scan skin?? if images \ and images.length > 1 - images.flatten! - images.uniq! + images=images.flatten.uniq images.delete_if {|x| x =~/https?:\/\// } - #images.sort! + #images=images.sort path_pod="#{@env.processing_path.processing}/sisupod" path_pod_conf="#{@env.processing_path.processing}/sisupod/_sisu" images_path_pod="#{path_pod}/image" @@ -284,7 +283,7 @@ module SiSU_Doc def sisupod_xz FileUtils::mkdir_p(@file.output_path.sisupod.dir) unless FileTest.directory?(@file.output_path.sisupod.dir) tree=(@opt.cmd =~/[vVM]/ \ - && SiSU_Env::System_call.new.program_found?('tree')) \ + && SiSU_Env::SystemCall.new.program_found?('tree')) \ ? 'tree sisupod' : '' if FileTest.directory?(@env.processing_path.processing) @@ -294,7 +293,7 @@ module SiSU_Doc tar -cJf #{@zipfile}.txz sisupod #echo "#{@file.place_file.sisupod.dir}" }) - FileUtils::mv("#{@zipfile}.txz", @file.place_file.sisupod.dir) + FileUtils::mv("#{@zipfile}.txz",@file.place_file.sisupod.dir) FileUtils::rm_r(Dir.glob("sisupod/*")) Dir.chdir(@env.path.pwd) SiSU_Screen::Ansi.new('',"#{@opt.fns}.txz").blue_tab unless @opt.cmd =~/q/ diff --git a/lib/sisu/v3/sitemaps.rb b/lib/sisu/v3/sitemaps.rb index 7f81b6be..cefdba8e 100644 --- a/lib/sisu/v3/sitemaps.rb +++ b/lib/sisu/v3/sitemaps.rb @@ -62,7 +62,7 @@ module SiSU_Sitemaps require_relative 'sysenv' # sysenv.rb include SiSU_Env require_relative 'shared_xml' # shared_xml.rb - include SiSU_XML_munge + include SiSU_XML_Munge class Source def initialize(opt) @opt=opt @@ -72,25 +72,25 @@ module SiSU_Sitemaps end def songsheet begin - @sys=SiSU_Env::System_call.new - fn_set_lang=SiSU_Env::Standardise_language.new(@opt.lng).language - @fn=SiSU_Env::Env_call.new(@opt.fns).lang(fn_set_lang[:c]) + @sys=SiSU_Env::SystemCall.new + fn_set_lang=SiSU_Env::StandardiseLanguage.new(@opt.lng).language + @fn=SiSU_Env::EnvCall.new(@opt.fns).lang(fn_set_lang[:c]) if @opt.cmd =~/Y/ @md=SiSU_Param::Parameters.new(@opt).get - @trans=SiSU_XML_munge::Trans.new(@md) #check @md is required - @env=SiSU_Env::Info_env.new(@md.fns) -# @file=SiSU_Env::SiSU_file.new(@md) - @rdf=SiSU_XML_tags::RDF.new(@md) + @trans=SiSU_XML_Munge::Trans.new(@md) #check @md is required + @env=SiSU_Env::InfoEnv.new(@md.fns) +# @file=SiSU_Env::FileOp.new(@md) + @rdf=SiSU_XML_Tags::RDF.new(@md) @fnb_utf8_xml=@md.fnb.dup @trans.char_enc.utf8(@fnb_utf8_xml) if @sys.locale =~/utf-?8/i #% utf8 output_map(sitemap) elsif @opt.mod.inspect =~/--sitemaps/ @sitemap_idx_fn='sitemapindex.xml' - @env=SiSU_Env::Info_env.new + @env=SiSU_Env::InfoEnv.new output_idx(sitemap_index) SiSU_Screen::Ansi.new(@opt.cmd,"sitemap index:","#{@env.path.output}/#{@sitemap_idx_fn}").result unless @opt.cmd =~/q/ end - rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error + rescue; SiSU_Errors::InfoError.new($!,$@,@opt.cmd,@opt.fns).error ensure end end @@ -105,8 +105,8 @@ module SiSU_Sitemaps filename=@fn[:sitemap] touch_path=@md.file.output_path.sitemaps.dir touch_filename=@fn[:sitemap_touch] - SiSU_Env::SiSU_file.new(@md).make_path(path) - file=SiSU_Env::SiSU_file.new(@md).make_file(path,filename) + SiSU_Env::FileOp.new(@md).make_path(path) + file=SiSU_Env::FileOp.new(@md).make_file(path,filename) file << sitemap if FileTest.file?("#{touch_path}/#{touch_filename}") FileUtils::rm("#{touch_path}/#{touch_filename}") diff --git a/lib/sisu/v3/spell.rb b/lib/sisu/v3/spell.rb index 20e443c4..58b86af3 100644 --- a/lib/sisu/v3/spell.rb +++ b/lib/sisu/v3/spell.rb @@ -56,7 +56,7 @@ ** Description: spellchecking =end -module Utility +module SiSU_SpellUtility class Spell def initialize(input,filesrc,flg) @flg=flg @@ -70,23 +70,23 @@ module Utility end def check @input.each do |data| - data.gsub!(/(https?|www|ftp|gopher|png|jpg|gif|html|htm)\S+/i,' ') - data.gsub!(/( |#{Mx[:nbsp]})/i,' ') - data.gsub!(/<\/?(table|tr|td|b|p|href).*?>/i,' ') - data.gsub!(/(<==.+|<:\S+>|<!.+?!>|^@\S+?:.+|\{\{\{|~)/,' ') - data.gsub!(/(["|<>)(\n'`'.;&_-]|\=)/,' ') - data.gsub!(/\b(altExternal| - target|externalimg| - srcimagebext| - img|src|toc|pdf| - cd|org| - helvetica|roman - )\b/i,' ') - data.gsub!(/EOF/,'') + data=data.gsub(/(https?|www|ftp|gopher|png|jpg|gif|html|htm)\S+/i,' '). + gsub(/( |#{Mx[:nbsp]})/i,' '). + gsub(/<\/?(table|tr|td|b|p|href).*?>/i,' '). + gsub(/(<==.+|<:\S+>|<!.+?!>|^@\S+?:.+|\{\{\{|~)/,' '). + gsub(/(["|<>)(\n'`'.;&_-]|\=)/,' '). + gsub(/\b(altExternal| + target|externalimg| + srcimagebext| + img|src|toc|pdf| + cd|org| + helvetica|roman + )\b/i,' '). + gsub(/EOF/,'') @words=data.scan(/\S+/) @words.each { |y| @allwords << y } end - @allwords.uniq! + @allwords=@allwords.uniq if @flg =~ /S/ File.open('/home/ralph/spell_error','a+') do |file| #fix file.puts %{\n\n<<#{@filename}>>} diff --git a/lib/sisu/v3/sst_convert_markup.rb b/lib/sisu/v3/sst_convert_markup.rb index 10eabcb5..29aca8dd 100644 --- a/lib/sisu/v3/sst_convert_markup.rb +++ b/lib/sisu/v3/sst_convert_markup.rb @@ -62,7 +62,7 @@ module SiSU_Modify require_relative 'sst_identify_markup' # sst_identify_markup.rb require_relative 'sst_from_xml' # sst_from_xml.rb require_relative 'response' # response.rb - class Convert_markup + class ConvertMarkup def initialize(opt) @opt=opt @description='This is a script that contains canned text conversions for reuse' @@ -173,7 +173,7 @@ WOK end end def convert_to_simple_xml_model_sax - SiSU_simple_xml_model_sax::Convert.new(@opt).read + SiSU_SimpleXML_ModelSax::Convert.new(@opt).read end def convert_to_simple_xml_model_dom SiSU_simple_xml_model_dom::Convert.new(@opt).read @@ -185,11 +185,11 @@ WOK SiSU_Kdissert::Convert.new(@opt).read end def convert_s_xml_to_sst - SiSU_sst_from_xml::Convert.new(@opt).read + SiSU_sstFromXML::Convert.new(@opt).read end def convert_footnotes require_relative 'sst_do_inline_footnotes' - SiSU_Convert_footnotes::Source.new(@opt).read + SiSU_ConvertFootnotes::Source.new(@opt).read end def conversion #%% do it --------------------------> @@ -231,7 +231,7 @@ WOK if i =~/(?:\.sst|\.ssm|\.ssi)$/ @new,@matched,@flag_start,@flag_end,@empty1,@empty2=true,false,false,false,false,false o="#{i}.bk" #o is for old - markup_version=SiSU_Markup::Markup_identify.new(@opt).markup_version? + markup_version=SiSU_Markup::MarkupIdentify.new(@opt).markup_version? if (@opt.mod.inspect=~/37/ and markup_version=~/0.38/) \ or (@opt.mod.inspect=~/current|38/ and markup_version=~/0.37/) puts "#{i} #{markup_version}" @@ -296,17 +296,17 @@ end #%% files to match for this conversion set -------------------------> require_relative 'options' # options.rb argv=$* -@opt=SiSU_commandline::Options.new(argv) +@opt=SiSU_Commandline::Options.new(argv) case @opt.mod.inspect when /=kdi/ - SiSU_Modify::Convert_markup.new(@opt).conversion + SiSU_Modify::ConvertMarkup.new(@opt).conversion when /(?:36|37|38)?to-?(?:37|38)|--convert|--to|--from|default/ @opt.files.each do |fns| @opt.fns=fns - SiSU_Modify::Convert_markup.new(@opt).conversion + SiSU_Modify::ConvertMarkup.new(@opt).conversion end else @opt.mod='--help' - SiSU_Modify::Convert_markup.new(@opt).help + SiSU_Modify::ConvertMarkup.new(@opt).help end __END__ diff --git a/lib/sisu/v3/sst_do_inline_footnotes.rb b/lib/sisu/v3/sst_do_inline_footnotes.rb index c5af68de..d1e1bef6 100644 --- a/lib/sisu/v3/sst_do_inline_footnotes.rb +++ b/lib/sisu/v3/sst_do_inline_footnotes.rb @@ -57,7 +57,7 @@ footnotes, invoked using: sisu --to-footnotes filename.sst =end -module SiSU_Convert_footnotes +module SiSU_ConvertFootnotes require_relative 'defaults' # defaults.rb include SiSU_Viz require_relative 'sysenv' # sysenv.rb @@ -65,7 +65,7 @@ module SiSU_Convert_footnotes require_relative 'param' # param.rb include SiSU_Param require_relative 'dal_syntax' # dal_syntax.rb - include SiSU_Syntax + include SiSU_DAL_Syntax require_relative 'i18n' # i18n.rb class Instantiate < SiSU_Param::Parameters::Instructions @@flag={} #Beware!! @@ -84,9 +84,9 @@ module SiSU_Convert_footnotes def initialize(opt) @opt=opt @@fns||@opt.fns - @my_make=SiSU_Env::Create_file.new(@opt.fns) - @fnm=SiSU_Env::Info_file.new(@opt.fns).marshal.dal_content - SiSU_Env::Create_system_link.new.images + @my_make=SiSU_Env::CreateFile.new(@opt.fns) + @fnm=SiSU_Env::InfoFile.new(@opt.fns).marshal.dal_content + SiSU_Env::CreateSystemLink.new.images end def read #creates dal begin @@ -94,7 +94,7 @@ module SiSU_Convert_footnotes @@dal_array=[] @@fns=@opt.fns create_dal - rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error + rescue; SiSU_Errors::InfoError.new($!,$@,@opt.cmd,@opt.fns).error ensure Instantiate.new end @@ -109,7 +109,7 @@ module SiSU_Convert_footnotes dal=if @@dal_array.empty?; read_fnm else @@dal_array.dup #check end - rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error + rescue; SiSU_Errors::InfoError.new($!,$@,@opt.cmd,@opt.fns).error ensure Instantiate.new end @@ -129,7 +129,7 @@ module SiSU_Convert_footnotes if @md.en[:mismatch]==0 \ or @md.opt.mod.inspect =~/=footnotes-force/ meta=nil - dal=SiSU_Convert_footnotes::Make.new(@md,file_array).song + dal=SiSU_ConvertFootnotes::Make.new(@md,file_array).song SiSU_Screen::Ansi.new(@opt.cmd,@opt.fns,"#{@md.fns}.fn").output if @md.opt.cmd =~/v/ SiSU_Screen::Ansi.new(@opt.cmd,"#{@md.fns}.fn -> #{@md.fns}.fn").txt_red unless @md.opt.cmd =~/q/ dal.each {|s| dal_array << "#{s.strip}\n\n" unless s.strip.empty?} @@ -142,15 +142,15 @@ module SiSU_Convert_footnotes def read_fnm dal=[] dal=if FileTest.file?(@fnm); File.open(@fnm){ |f| dal=Marshal.load(f)} - else SiSU_Convert_footnotes::Source.new(@opt).create_dal #watch + else SiSU_ConvertFootnotes::Source.new(@opt).create_dal #watch end end end class Output def initialize(md,data) @md,@data=md,data - @my_make=SiSU_Env::Create_file.new(@md.fns) - dir=SiSU_Env::Info_env.new(@md.fns) + @my_make=SiSU_Env::CreateFile.new(@md.fns) + dir=SiSU_Env::InfoEnv.new(@md.fns) @hard="#{Dir.pwd}/#{@md.fns}.fn" end def hard_output @@ -167,9 +167,9 @@ module SiSU_Convert_footnotes 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) - l=SiSU_Env::Standardise_language.new(@md.opt.lng).language + @env=SiSU_Env::InfoEnv.new(@md.fns) + @skin=SiSU_Env::InfoSkin.new(@md) + l=SiSU_Env::StandardiseLanguage.new(@md.opt.lng).language @language=l[:n] @translate=SiSU_Translate::Source.new(@md,@language) end @@ -184,7 +184,7 @@ module SiSU_Convert_footnotes reset data=@data @metafile="#{@env.processing_path.dal}/#{@md.fns}.meta" - my_make_source_file=SiSU_Env::Create_file.new(@md.fns) + my_make_source_file=SiSU_Env::CreateFile.new(@md.fns) data=data.join.split("\n\n") data_new=[] data.each do |x| @@ -193,10 +193,10 @@ module SiSU_Convert_footnotes end end data=data_new.flatten - data=SiSU_Convert_footnotes::Make.new(@md,data).substitutions_and_insertions? - data=SiSU_Convert_footnotes::Make.new(@md,data).character_check - data=SiSU_Convert_footnotes::Make.new(@md,data).endnotes - SiSU_Convert_footnotes::Output.new(@md,data).hard_output + data=SiSU_ConvertFootnotes::Make.new(@md,data).substitutions_and_insertions? + data=SiSU_ConvertFootnotes::Make.new(@md,data).character_check + data=SiSU_ConvertFootnotes::Make.new(@md,data).endnotes + SiSU_ConvertFootnotes::Output.new(@md,data).hard_output reset data end @@ -418,12 +418,12 @@ module SiSU_Convert_footnotes when /~\{\s+.+?\}~/ # auto-numbered endnotes <!e!> <!e_!> --> para.gsub!(/\s*\}~/,' }~') # required 2003w31 @word_mode=para.scan(/\S+/) - word_mode=SiSU_Convert_footnotes::Make.new(@md,@word_mode).endnote_call_number + word_mode=SiSU_ConvertFootnotes::Make.new(@md,@word_mode).endnote_call_number para=word_mode.join(' ') endnote_ref+=1 when /~\^(?:\s|$)|<:e>/ #%Note inserts endnotes previously gathered from /^(<!e[:_]!>|[-~]\{{3})/ (in earlier loop) word_mode=para.scan(/\S+/) - word_mode=SiSU_Convert_footnotes::Make.new(@md,word_mode).endnote_call_number + word_mode=SiSU_ConvertFootnotes::Make.new(@md,word_mode).endnote_call_number para=word_mode.join(' ') endnote_ref+=1 end @@ -468,5 +468,5 @@ module SiSU_Convert_footnotes end end __END__ -@particulars=SiSU_Particulars::Combined_singleton.instance.get_all(opt) +@particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt) dal_array=@particulars.dal_array # dal file drawn here diff --git a/lib/sisu/v3/sst_from_xml.rb b/lib/sisu/v3/sst_from_xml.rb index ff29cc77..59495e5a 100644 --- a/lib/sisu/v3/sst_from_xml.rb +++ b/lib/sisu/v3/sst_from_xml.rb @@ -57,7 +57,7 @@ (master document) =end -module SiSU_sst_from_xml +module SiSU_sstFromXML require_relative 'sysenv' # sysenv.rb class Convert require 'rexml/document' @@ -65,7 +65,7 @@ module SiSU_sst_from_xml def initialize(opt) @opt=opt @sisu,@sisu_base=[],[] - @ver=SiSU_Env::Info_version.instance.get_version + @ver=SiSU_Env::InfoVersion.instance.get_version end def tell(filename,type) SiSU_Screen::Ansi.new(@opt.cmd,"XML #{type} to SiSU sst","#{filename} --> #{filename}.sst").green_hi_blue diff --git a/lib/sisu/v3/sst_identify_markup.rb b/lib/sisu/v3/sst_identify_markup.rb index 2089a9a8..af30f19b 100644 --- a/lib/sisu/v3/sst_identify_markup.rb +++ b/lib/sisu/v3/sst_identify_markup.rb @@ -59,7 +59,7 @@ =end module SiSU_Markup - class Markup_inform + class MarkupInform attr_accessor :version def initialize(version,message,declared_markup='',declared_type='') @version,@message,@declared_markup,@declared_type=version,message,declared_markup,declared_type @@ -77,10 +77,10 @@ module SiSU_Markup @declared_type end def history - Markup_history.new(@version).query + MarkupHistory.new(@version).query end end - class Markup_identify + class MarkupIdentify def initialize(opt) @opt=opt @description='This is a script attempts to identify the version of markup used in SiSU (and provides information on changes in markup)' @@ -121,14 +121,14 @@ WOK if @flag_2_0 \ or y =~/^@make:|^@classify|^\s\s?:[a-z_-]+?:\s+\S/ version=2.0.to_f - markup=Markup_inform.new(version,'2.0' + oldlinks,@declared_markup,@declared_type) + markup=MarkupInform.new(version,'2.0' + oldlinks,@declared_markup,@declared_type) @flag_2_0=true break end unless @flag_38 if (y =~/^:?A~/ and f =~/(?:\.sst|\.ssm|\.ssi)/) version='0.38' - markup=Markup_inform.new(version,'0.38' + oldlinks,@declared_markup,@declared_type) + markup=MarkupInform.new(version,'0.38' + oldlinks,@declared_markup,@declared_type) @flag_38=true end end @@ -136,14 +136,14 @@ WOK if @flag_1_0 \ or y =~/^=\{.+?\}\s*$/ version='0.69' - markup=Markup_inform.new(version,'0.69' + oldlinks,@declared_markup,@declared_type) + markup=MarkupInform.new(version,'0.69' + oldlinks,@declared_markup,@declared_type) @flag_1_0=true break end if @flag_66 \ or y =~/[a-z+][:;]\{.+?\}[:;][a-z+]/ version='0.66' - markup=Markup_inform.new(version,'0.66' + oldlinks,@declared_markup,@declared_type) + markup=MarkupInform.new(version,'0.66' + oldlinks,@declared_markup,@declared_type) @flag_66=true break end @@ -162,26 +162,26 @@ WOK if @flag_57 \ or (y =~/^:?A~\?? @title/ and f =~/(?:\.sst|\.ssm|\.ssi)/) version='0.57' - markup=Markup_inform.new(version,'0.57' + oldlinks,@declared_markup,@declared_type) + markup=MarkupInform.new(version,'0.57' + oldlinks,@declared_markup,@declared_type) @flag_57=true break end if @flag_38 \ or (y =~/^:?A~/ and f =~/(?:\.sst|\.ssm|\.ssi)/) version='0.38' - markup=Markup_inform.new(version,'0.38' + oldlinks,@declared_markup,@declared_type) + markup=MarkupInform.new(version,'0.38' + oldlinks,@declared_markup,@declared_type) @flag_38=true break if i >= 200 if y =~ /(?:~{\*+|~\[\*|~\[\+)\s/ version='0.42' - markup=Markup_inform.new(version,'0.42' + oldlinks,@declared_markup,@declared_type) + markup=MarkupInform.new(version,'0.42' + oldlinks,@declared_markup,@declared_type) break end end if (y =~/^1~/ and f =~/(?:\.sst|\.ssm|\.ssi)/) \ and not @flag_38 version='0.37' - markup=Markup_inform.new(version,'0.37 is substantially 0.16 - 0.36 markup with new file-extension' + oldlinks,@declared_markup,@declared_type) + markup=MarkupInform.new(version,'0.37 is substantially 0.16 - 0.36 markup with new file-extension' + oldlinks,@declared_markup,@declared_type) break end if y =~/^1~/ \ @@ -193,31 +193,31 @@ WOK " (change file extension from .#{t}#{n} to .ssm)" else " (change file extension from .#{t}#{n} to .sst)" end - markup=Markup_inform.new(version,'0.16 - 0.36' + instruct + links,@declared_markup,@declared_type) + markup=MarkupInform.new(version,'0.16 - 0.36' + instruct + links,@declared_markup,@declared_type) break end if y =~/^0\{~/ \ and not @flag_38 version='0.1' - markup=Markup_inform.new(version,'0.1 - 0.15',@declared_markup,@declared_type) + markup=MarkupInform.new(version,'0.1 - 0.15',@declared_markup,@declared_type) break end if y =~/^0\{{3}/ \ and not @flag_38 - markup=Markup_inform.new('circa. 1997','old, check date',@declared_markup,@declared_type) + markup=MarkupInform.new('circa. 1997','old, check date',@declared_markup,@declared_type) break end markup='Not a recognised file type ' end end markup - else Markup_history.new(@opt).help_query + else MarkupHistory.new(@opt).help_query end end def determine_markup_version if @opt.fns.nil? \ or @opt.fns.empty? - Markup_history.new(@opt).help_identify + MarkupHistory.new(@opt).help_identify end if File.exist?(@opt.fns) if @opt.fns =~/\.(?:sst|ssm|ssi|s[123i]|r[123])/ @@ -251,7 +251,7 @@ WOK end end end - class Markup_history + class MarkupHistory def initialize(opt) @opt=opt end @@ -470,5 +470,5 @@ end puts "SiSU files:" puts f f.each do |x| - SiSU_Markup::Markup_identify.new(x).markup_version? + SiSU_Markup::MarkupIdentify.new(x).markup_version? end diff --git a/lib/sisu/v3/sst_to_s_xml_sax.rb b/lib/sisu/v3/sst_to_s_xml_sax.rb index 9a16a437..e3e219e0 100644 --- a/lib/sisu/v3/sst_to_s_xml_sax.rb +++ b/lib/sisu/v3/sst_to_s_xml_sax.rb @@ -56,7 +56,7 @@ ** Description: simple xml representation (sax style) =end -module SiSU_simple_xml_model_sax +module SiSU_SimpleXML_ModelSax require_relative 'particulars' # particulars.rb include SiSU_Particulars require_relative 'defaults' # defaults.rb @@ -67,10 +67,10 @@ module SiSU_simple_xml_model_sax include SiSU_Env require_relative 'dal_doc_str' # dal_doc_str.rb require_relative 'shared_xml' # shared_xml.rb - include SiSU_XML_munge + include SiSU_XML_Munge require_relative 'shared_sem' # shared_sem.rb require_relative 'xml_format' # xml_format.rb - include SiSU_XML_format + include SiSU_XML_Format require_relative 'rexml' # rexml.rb include SiSU_Rexml @@alt_id_count,@@tablehead,@@number_of_cols=0,0,0 @@ -79,7 +79,7 @@ module SiSU_simple_xml_model_sax @@fns=nil def initialize(opt) @opt=opt - @particulars=SiSU_Particulars::Combined_singleton.instance.get_env_md(opt) + @particulars=SiSU_Particulars::CombinedSingleton.instance.get_env_md(opt) end def read begin @@ -100,8 +100,8 @@ module SiSU_simple_xml_model_sax @fns_array=if @@fns_array.empty?; read_fnm else @@fns_array.dup #check end - SiSU_simple_xml_model_sax::Convert::Songsheet.new(@fns_array,@particulars).songsheet - rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error + SiSU_SimpleXML_ModelSax::Convert::Songsheet.new(@fns_array,@particulars).songsheet + rescue; SiSU_Errors::InfoError.new($!,$@,@opt.cmd,@opt.fns).error ensure #file closed in songsheet end end @@ -119,10 +119,10 @@ module SiSU_simple_xml_model_sax end def songsheet begin - SiSU_simple_xml_model_sax::Convert::Scroll.new(@data,@particulars).songsheet - SiSU_simple_xml_model_sax::Convert::Tidy.new(@md,@env).xml if @md.opt.cmd =~/[vVM]/ # test wellformedness, comment out when not in use + SiSU_SimpleXML_ModelSax::Convert::Scroll.new(@data,@particulars).songsheet + SiSU_SimpleXML_ModelSax::Convert::Tidy.new(@md,@env).xml if @md.opt.cmd =~/[vVM]/ # test wellformedness, comment out when not in use SiSU_Rexml::Rexml.new(@md,@md.fn[:sxs]).xml if @md.opt.cmd =~/M/ # test rexml parsing, comment out when not in use #debug - rescue; SiSU_Errors::Info_error.new($!,$@,@md.opt.cmd,@md.fns).error + rescue; SiSU_Errors::InfoError.new($!,$@,@md.opt.cmd,@md.fns).error ensure end end @@ -130,17 +130,17 @@ module SiSU_simple_xml_model_sax class Scroll require_relative 'shared_txt' # shared_txt.rb require_relative 'css' # css.rb - include SiSU_text_utils + include SiSU_TextUtils @@xml={ body: [], open: [], close: [], head: [] } def initialize(data='',particulars='') @data,@env,@md=data,particulars.env,particulars.md - @vz=SiSU_Env::Get_init.instance.skin + @vz=SiSU_Env::GetInit.instance.skin @regx=/^(?:#{Mx[:mk_o]}:p[bn]#{Mx[:mk_c]}\s*)?(?:#{Mx[:lv_o]}[1-9]:(\S*)#{Mx[:lv_c]})?(.+)/ @tab="\t" if @md - @trans=SiSU_XML_munge::Trans.new(@md) + @trans=SiSU_XML_Munge::Trans.new(@md) end - @sys=SiSU_Env::System_call.new + @sys=SiSU_Env::SystemCall.new end def songsheet pre @@ -196,7 +196,7 @@ WOK embedded_endnotes(para) if para[@regx] paragraph="#{para[@regx,2]}" - util=SiSU_text_utils::Wrap.new(paragraph,70) + util=SiSU_TextUtils::Wrap.new(paragraph,70) wrapped=util.line_wrap end @@xml[:body] << "#{@tab*0}<object>" if para[@regx] @@ -262,14 +262,14 @@ WOK end def markup data=[] - dir=SiSU_Env::Info_env.new(@md.fns) + dir=SiSU_Env::InfoEnv.new(@md.fns) xml_sc(@md) @endnotes,@level,@cont,@copen,@xml_contents_close=[],[],[],[],[] @rcdc=false (0..6).each { |x| @cont[x]=@level[x]=false } (4..6).each { |x| @xml_contents_close[x]='' } @data.each do |para| - data << SiSU_document_structure_extract::Structure.new(@md,para).structure #takes on Mx marks + data << SiSU_DAL_DocumentStructureExtract::Structure.new(@md,para).structure #takes on Mx marks end data.each do |para| if para !~/^\s*(?:%+ |<:code>)/ @@ -277,14 +277,14 @@ WOK para=@trans.xml_semantic_tags(para) end if para =~/[:;]\{|\}[:;]/ - para=SiSU_sem::Tags.new(para,@md).rm.all + para=SiSU_Sem::Tags.new(para,@md).rm.all end end para=@trans.markup_light(para) @trans.char_enc.utf8(para) if @sys.locale =~/utf-?8/i #% utf8 para.gsub!(/^@(\S+?):/,"#{Mx[:lv_o]}@\\1#{Mx[:lv_c]}") if para =~/\A#{Mx[:lv_o]}@(\S+?)#{Mx[:lv_c]}\s*(.+?)\Z/m # for headers - d_meta=SiSU_text_utils::Header_scan.new(@md,para).meta + d_meta=SiSU_TextUtils::HeaderScan.new(@md,para).meta if d_meta; xml_head(d_meta) end end @@ -294,9 +294,9 @@ WOK @rcdc=true end if para !~/(^@\S+?:|^\s*$|<ENDNOTES>|<EOF>)/ - @sto=SiSU_text_parts::Split_text_object.new(@md,para).lev_segname_para + @sto=SiSU_text_parts::SplitTextObject.new(@md,para).lev_segname_para unless @rcdc - format_scroll=SiSU_XML_format::Format_scroll.new(@md,@sto.text) if @sto.format =~/i[1-9]|ordinary/ + format_scroll=SiSU_XML_Format::FormatScroll.new(@md,@sto.text) if @sto.format =~/i[1-9]|ordinary/ case @sto.format when /^(1):(\S*)/ xml_clean(para) @@ -310,7 +310,7 @@ WOK xml_clean(para) xml_structure(para,$1,$2) para=@sto.lev_para_ocn.heading_body3 - when /^(4):(\S*)/ # work on see Split_text_object + when /^(4):(\S*)/ # work on see SplitTextObject xml_clean(para) xml_structure(para,$1,$2) para=@sto.lev_para_ocn.heading_body4 @@ -332,7 +332,7 @@ WOK para.gsub!(/>/,'>') para=code_structure(para) elsif para =~/<!Th?.+/ # tables come as single block #work area 2005w13 - table=SiSU_Tables::Table_xml.new(para) + table=SiSU_Tables::TableXML.new(para) para=table.table_split para=table_structure(para) else xml_structure(para,nil,nil) @@ -345,16 +345,16 @@ WOK if para =~/.*<:#>.*$/ para=case para when /<:i1>/ - format_text=Format_text_object.new(para,'') + format_text=FormatTextObject.new(para,'') format_text.scr_inden_ocn_e_no_paranum when /<:i2>/ - format_text=Format_text_object.new(para,'') + format_text=FormatTextObject.new(para,'') format_text.scr_inden_ocn_e_no_paranum end end if para =~/<:center>/ one,two=/(.*)<:center>(.*)/.match(para)[1,2] - format_text=Format_text_object.new(one,two) + format_text=FormatTextObject.new(one,two) para=format_text.center end end @@ -374,10 +374,10 @@ WOK end end def pre - rdf=SiSU_XML_tags::RDF.new(@md) - dir=SiSU_Env::Info_env.new + rdf=SiSU_XML_Tags::RDF.new(@md) + dir=SiSU_Env::InfoEnv.new @@xml[:head],@@xml[:body]=[],[] - css=SiSU_Env::CSS_select.new(@md).xml_sax + css=SiSU_Env::CSS_Select.new(@md).xml_sax encoding=if @sys.locale =~/utf-?8/i; '<?xml version="1.0" encoding="UTF-8" standalone="no"?>' else '<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>' end @@ -420,8 +420,8 @@ WOK end new_file_data=@sisu.join @sisu=new_file_data.scan(/.+/) - SiSU_Env::SiSU_file.new(@md).mkdir - filename_sxm=SiSU_Env::SiSU_file.new(@md,@md.fn[:sxs]).mkfile_pwd + SiSU_Env::FileOp.new(@md).mkdir + filename_sxm=SiSU_Env::FileOp.new(@md,@md.fn[:sxs]).mkfile_pwd if filename_sxm.class==File @sisu.each {|para| filename_sxm.puts para} filename_sxm.close @@ -432,7 +432,7 @@ WOK class Tidy def initialize(md,dir) @md,@env=md,dir - @prog=SiSU_Env::Info_program.new + @prog=SiSU_Env::InfoProgram.new end def xml if @prog.tidy !=false #note values can be other than true @@ -441,7 +441,7 @@ WOK SiSU_Screen::Ansi.new(@md.opt.cmd,'','','check document structure') tell.grey_open unless @md.opt.cmd =~/q/ tidyfile='/dev/null' #don't want one or screen output, check for alternative flags - tidy =SiSU_Env::System_call.new("#{Dir.pwd}/#{@md.fn[:sxs]}",tidyfile) + tidy =SiSU_Env::SystemCall.new("#{Dir.pwd}/#{@md.fn[:sxs]}",tidyfile) tidy.well_formed? tell.p_off unless @md.opt.cmd =~/q/ end diff --git a/lib/sisu/v3/sysenv.rb b/lib/sisu/v3/sysenv.rb index 16dabd36..4383a893 100644 --- a/lib/sisu/v3/sysenv.rb +++ b/lib/sisu/v3/sysenv.rb @@ -65,7 +65,7 @@ module SiSU_Env include FileUtils::Verbose require 'singleton' @@noyaml=false - class Info_date + class InfoDate require 'date' attr_accessor :dt,:t def initialize @@ -91,7 +91,7 @@ module SiSU_Env '2012' end end - class Info_system + class InfoSystem require 'rbconfig' include Singleton @@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'] @@ -241,7 +241,7 @@ module SiSU_Env def initialize @user,@home,@hostname,@pwd,@sisu_etc,@host,@arch,@rbver,@dir_arch,@dir_sitearch,@dir_bin,@locale,@default_dir,@rc_path,@yamlrc_path,@ad_path=\ @@user,@@home,@@hostname,@@pwd,@@sisu_etc,@@host,@@arch,@@rbver,@@dir_arch,@@dir_sitearch,@@dir_bin,@@locale,@@default_dir,@@rc_path,@@yamlrc_path,@@ad_path - #note rbver is duplicated in Info_version + #note rbver is duplicated in InfoVersion end end class Load @@ -280,7 +280,7 @@ module SiSU_Env load_prog end end - class Get_init < Info_system + class GetInit < InfoSystem include Singleton @@noyaml=false @@rc,@@sisurc_path,@@vz,@@tx=nil,nil,nil,nil @@ -373,16 +373,16 @@ module SiSU_Env @@ad end end - class Env_call + class EnvCall @@rc,@@fns,@@fnn,@@fnb,@@fnt,@@flv,@@fnz=nil,nil,nil,nil,nil,nil,nil @@ad={} attr_accessor :rc,:fnn,:fnb,:fnt,:fnv,:fnz,:ad def initialize(fns='') super() @fns=fns - @sys=Info_system.instance - @rc=Get_init.instance.sisu_yaml.rc - @ad=Get_init.instance.ads + @sys=InfoSystem.instance + @rc=GetInit.instance.sisu_yaml.rc + @ad=GetInit.instance.ads if @fns \ and @fns != '' \ and @fns !=@@fns @@ -405,56 +405,62 @@ module SiSU_Env @fnn,@fnb,@fnt,@flv,@fnz=@@fnn,@@fnb,@@fnt,@@flv,@@fnz end def output_dir_structure - def by_language_code? - x=if defined? @rc['output_dir_structure_by'] \ - and @rc['output_dir_structure_by'] =~/language/ - true - elsif defined? @rc['output_structure']['by_language'] \ - and @rc['output_structure']['by_language'] ==true - true - else false + def by? + output_structure=:filename #set default output structure + output_structure=if defined? @rc['output_dir_structure_by'] + output_structure=if (@rc['output_dir_structure_by'] =~/dump/) \ + or ((defined? @rc['output_structure']['dump']) \ + && @rc['output_structure']['dump'] ==true) + :dump + elsif (@rc['output_dir_structure_by'] =~/redirect/) \ + or ((defined? @rc['output_structure']['redirect']) \ + && @rc['output_structure']['redirect'] ==true) + :redirect + elsif (@rc['output_dir_structure_by'] =~/language/) \ + or ((defined? @rc['output_structure']['by_language']) \ + && @rc['output_structure']['by_language'] ==true) + :language + elsif (@rc['output_dir_structure_by'] =~/filetype/) \ + or ((defined? @rc['output_structure']['by_filetype']) \ + && @rc['output_structure']['by_filetype'] ==true) + :filetype + elsif (@rc['output_dir_structure_by'] =~/filename/) \ + or ((defined? @rc['output_structure']['by_filename']) \ + && @rc['output_structure']['by_filename'] ==true) + :filename + else #recheck current default + :language + end end end + def dump? + ((by?) ==:dump) \ + ? true + : false + end + def redirect? + ((by?) ==:redirect) \ + ? true + : false + end + def by_language_code? + ((by?) ==:language) \ + ? true + : false + end def by_filetype? - x=if by_language_code? - false - elsif defined? @rc['output_dir_structure_by'] \ - and @rc['output_dir_structure_by'] =~/filetype/ - true - elsif defined? @rc['output_structure']['by_filetype'] \ - and @rc['output_structure']['by_filetype'] ==true - true - else false - end + ((by?) ==:filetype) \ + ? true + : false end def by_filename? - x=if by_language_code? - false - elsif by_filetype? - false - elsif defined? @rc['output_dir_structure_by'] \ - and @rc['output_dir_structure_by'] =~/filename/ - true - elsif defined? @rc['output_structure']['by_filename'] \ - and @rc['output_structure']['by_filename'] ==true - true - else true - end + ((by?) ==:filename) \ + ? true + : false end def multilingual? by_language_code? end - def by? - by=if by_language_code? - 'language' - elsif by_filetype? - 'filetype' - elsif by_filename? - 'filename' - else - 'filename' - end - end self end def document_language_versions_found #REVISIT @@ -472,8 +478,8 @@ module SiSU_Env @fn[:t]=filename[m,2] end end - lng_base=Info_env.new.language_default_set - lang=SiSU_Env::Standardise_language.new + lng_base=SiSU_Env::InfoEnv.new.language_default_set + lang=SiSU_Env::StandardiseLanguage.new langs=lang.codes x=[] if FileTest.file?("#{@fn[:m]}.#{@fn[:t]}") @@ -483,7 +489,7 @@ module SiSU_Env end #x << { f: "#{@fns}", l: lng_base } langs.each do |l| - lng=SiSU_Env::Standardise_language.new(l) + lng=SiSU_Env::StandardiseLanguage.new(l) if FileTest.file?("#{@fn[:m]}~#{lng.code}.#{@fn[:t]}") x << { f: "#{@fn[:m]}~#{lng.code}.#{@fn[:t]}", l: lng.code } elsif FileTest.file?("#{@fn[:m]}~#{lng.name}.#{@fn[:t]}") @@ -521,34 +527,33 @@ module SiSU_Env @fn[:t]=@fns[m,2] end end - lang=SiSU_Env::Standardise_language.new + lang=SiSU_Env::StandardiseLanguage.new langs=lang.codes x=[] if FileTest.file?("#{@fn[:m]}.#{@fn[:t]}"); x << "#{@fn[:m]}.#{@fn[:t]}" end - dir=SiSU_Env::Info_env.new(@fns) + dir=SiSU_Env::InfoEnv.new(@fns) @m << { m: 'sisu_manifest.html', l: 'English' } #fix later, default language langs.each do |l| - lng=SiSU_Env::Standardise_language.new(l) + lng=SiSU_Env::StandardiseLanguage.new(l) fns_c="#{@fn[:m]}~#{lng.code}.#{@fn[:t]}" fns_l="#{@fn[:m]}~#{lng.name}.#{@fn[:t]}" if FileTest.file?(fns_c) - fn_set_lang=SiSU_Env::Standardise_language.new.file_to_language(fns_c) #reconsider file_to_language + fn_set_lang=SiSU_Env::StandardiseLanguage.new.file_to_language(fns_c) #reconsider file_to_language lng=fn_set_lang[:n] - fn=SiSU_Env::Env_call.new(fns_c).lang(fn_set_lang[:c]) + fn=SiSU_Env::EnvCall.new(fns_c).lang(fn_set_lang[:c]) @m << { m: fn[:manifest], l: lng } elsif FileTest.file?(fns_l) - fn_set_lang=SiSU_Env::Standardise_language.new.file_to_language(fns_l) #reconsider file_to_language + fn_set_lang=SiSU_Env::StandardiseLanguage.new.file_to_language(fns_l) #reconsider file_to_language @fnl=dir.i18n.lang_filename(fn_set_lang[:c]) - fn=SiSU_Env::Env_call.new(fns_l).lang(fn_set_lang[:c]) + fn=SiSU_Env::EnvCall.new(fns_l).lang(fn_set_lang[:c]) @m << { m: fn[:manifest], l: lng } end end - @m.uniq! - @m + @m=@m.uniq end def filename(code,name,suffix) - #d=SiSU_Env::Info_env.new(@fns) + #d=SiSU_Env::InfoEnv.new(@fns) #fnl=d.i18n.lang_filename(code) "#{name}#{suffix}" #if code @@ -604,15 +609,15 @@ module SiSU_Env @fn end end - class System_call + class SystemCall @@locale_flag=false def initialize(input='',output='',cmd='') @input,@output,@cmd=input,output,cmd - @prog=SiSU_Env::Info_program.new - @sys=Info_system.instance + @prog=SiSU_Env::InfoProgram.new + @sys=InfoSystem.instance end def program_found?(program) - found=`whereis #{program}` + found=`which #{program}` #`whereis #{program}` (found =~/bin\/#{program}\b/) ? true : false end def locale #locales utf8 or other @@ -623,10 +628,10 @@ module SiSU_Env end def file_encoding(filename,cmd='') #file encoding program='file' - fnsp=Info_env.new(filename).source_file_with_path + fnsp=SiSU_Env::InfoEnv.new(filename).source_file_with_path if program_found?(program) encoding=%x{file -L #{fnsp}}.strip - encoding.gsub!(/#{fnsp}:(\s+|$)/,'') + encoding=encoding.gsub(/#{fnsp}:(\s+|$)/,'') encoding=if encoding \ and not encoding.empty? encoding @@ -799,9 +804,10 @@ module SiSU_Env end def makeinfo #texinfo program='makeinfo' + options='' #'--force' #'' program_ref="\n\t\tsee http://www.gnu.org/software/texinfo/" (program_found?(program)) \ - ? system("#{program} #{@input}\n") + ? system("#{program} #{options} #{@input}\n") : (puts "\tWARN: #{program} is not installed #{program_ref}") end def scp @@ -846,11 +852,11 @@ module SiSU_Env end end end - class Standardise_language + class StandardiseLanguage require_relative 'i18n' # i18n.rb def initialize(l='') @language=(l.nil? || l.empty?) \ - ? Info_env.new.language_default_set + ? SiSU_Env::InfoEnv.new.language_default_set : l @r=%{(?:#{Px[:lng_lst].join('|')})} @lang_info=SiSU_i18n::Languages.new @@ -962,7 +968,7 @@ module SiSU_Env Px[:lng_lst] # constants.rb end end - class Info_env < Env_call + class InfoEnv < EnvCall require 'pathname' require 'fileutils' include FileUtils @@ -972,7 +978,7 @@ module SiSU_Env def initialize(fns='',md=nil) super() #you may not want to re-execute this static info so frequently! @fns,@md=fns,md - @env=Env_call.new(fns) if fns + @env=SiSU_Env::EnvCall.new(fns) if fns fnb=if @md \ and defined? @md.fnb @md.fnb @@ -986,7 +992,7 @@ module SiSU_Env end if fnb; @@fb ||=fnb end - @sys=Info_system.instance + @sys=InfoSystem.instance @fnb ||=@@fb #clean up this... used primarily for zap which is not passed normal parameters @fixed_websev_root='' # @home @pwd=@@pwd=Dir.pwd @@ -1116,10 +1122,9 @@ module SiSU_Env FileUtils::rm_rf(spp) end paths=[] - flv=Env_call.new(opt.fns).document_language_versions_found + flv=SiSU_Env::EnvCall.new(opt.fns).document_language_versions_found flv[:f].each {|l| lng_dirs << l[:l] } - lng_dirs.uniq! - lng_dirs.each do |lng| + lng_dirs.uniq.each do |lng| paths << "#{spp}/doc/#{lng}" end paths \ @@ -1189,12 +1194,174 @@ module SiSU_Env end end def manifest_minitoc? - flag=if defined? @rc['manifest']['minitoc'] \ - and not @rc['manifest']['minitoc'].nil? + flag=if (defined? @rc['manifest']['minitoc'] \ + and not @rc['manifest']['minitoc'].nil?) @rc['manifest']['minitoc'] else false end end + def build + def omit_list + @off_list ||=if (defined? @rc['omit_list'] \ + and not @rc['omit_list'].nil?) + @rc['omit_list'] + elsif (defined? @rc['omit']['list'] \ + and not @rc['omit']['list'].nil?) + @rc['omit']['list'] + else + nil + end + end + def listed?(test) #fix + listed=if omit_list + x=(omit_list.scan(/\b#{test}\b/)).join + test==x \ + ? true + : false + else + false + end + listed + end + def ocn? + if (defined? @rc['omit']['ocn'] \ + and not @rc['omit']['ocn'].nil?) \ + or listed?('ocn') + :off + else + :na + end + end + def toc? + if (defined? @rc['omit']['toc'] \ + and not @rc['omit']['toc'].nil?) \ + or listed?('toc') + :off + else + :na + end + end + def manifest? + if (defined? @rc['omit']['manifest'] \ + and not @rc['omit']['manifest'].nil?) \ + or listed?('manifest') + :off + else + :na + end + end + def links_to_manifest? + flag=if (defined? @rc['omit']['links_to_manifest'] \ + and not @rc['omit']['links_to_manifest'].nil?) \ + or (listed?('links_to_manifest') \ + || listed?('manifest_links')) + :off + else + :na + end + end + def metadata? + if (defined? @rc['omit']['metadata'] \ + and not @rc['omit']['metadata'].nil?) \ + or listed?('metadata') + :off + else + :na + end + end + def minitoc? + flag=if (defined? @rc['omit']['minitoc'] \ + and not @rc['omit']['minitoc'].nil?) \ + or (listed?('minitoc')) + :off + else + :na + end + end + def manifest_minitoc? + flag=if (defined? @rc['omit']['manifest_minitoc'] \ + and not @rc['omit']['manifest_minitoc'].nil?) \ + or listed?('manifest_minitoc') + :off + else + :na + end + end + def html_minitoc? + flag=if (defined? @rc['omit']['html_minitoc'] \ + and not @rc['omit']['html_minitoc'].nil?) \ + or (listed?('html_minitoc') \ + || listed?('minitoc')) + :off + else + :na + end + end + def html_navigation? + flag=if (defined? @rc['omit']['html_navigation'] \ + and not @rc['omit']['html_navigation'].nil?) \ + or listed?('html_navigation') + :off + else + :na + end + end + def html_navigation_bar? + flag=if (defined? @rc['omit']['html_navigation_bar'] \ + and not @rc['omit']['html_navigation_bar'].nil?) \ + or listed?('html_navigation_bar') + :off + else + :na + end + end + def segsubtoc? + flag=if (defined? @rc['omit']['segsubtoc'] \ + and not @rc['omit']['segsubtoc'].nil?) \ + or listed?('segsubtoc') + :off + else + :na + end + end + def html_right_pane? + flag=if (defined? @rc['omit']['html_right_pane'] \ + and not @rc['omit']['html_right_pane'].nil?) \ + or listed?('html_right_pane') + :off + else + :na + end + end + def html_top_band? + flag=if (defined? @rc['omit']['html_top_band'] \ + and not @rc['omit']['html_top_band'].nil?) \ + or listed?('html_top_band') + :off + else + :na + end + end + def search_form? #decide later, as is configured here (in sisurc) and can be turned off on command line + flag=if (defined? @rc['omit']['search_form'] \ + and not @rc['omit']['search_form'].nil?) \ + or listed?('search_form') + :off + else + :na + end + end + def html_search_form? #decide later, as is configured here (in sisurc) and can be turned off on command line + flag=if (defined? @rc['omit']['html_search_form'] \ + and not @rc['omit']['html_search_form'].nil?) \ + or listed?('html_search_form') + :off + else + :na + end + end + self + end def odt_ocn? ((defined? @rc['odt']['ocn']) \ && @rc['odt']['ocn']==true) \ @@ -1208,9 +1375,9 @@ module SiSU_Env : false end def widget #needs (md) #move - @rc=SiSU_Env::Get_init.instance.sisu_yaml.rc - @ad=SiSU_Env::Get_init.instance.ads - @vz=SiSU_Env::Get_init.instance.skin + @rc=SiSU_Env::GetInit.instance.sisu_yaml.rc + @ad=SiSU_Env::GetInit.instance.ads + @vz=SiSU_Env::GetInit.instance.skin @flag={ ad: false, md: false, sk: false, rc: false } def promo? @flag[:ad]=if @md.flag_promo && @ad[:flag_promo] @@ -1283,7 +1450,7 @@ module SiSU_Env end end def search_form(type='sisusearch',action=nil,db=nil,table=false) - rc=SiSU_Env::Get_init.instance.sisu_yaml.rc + rc=SiSU_Env::GetInit.instance.sisu_yaml.rc create_form_sisu=if action \ and db \ and action =~/https?:\/\// \ @@ -1339,7 +1506,7 @@ WOK form end def search_form_static(action=nil,db=nil) - rc=SiSU_Env::Get_init.instance.sisu_yaml.rc + rc=SiSU_Env::GetInit.instance.sisu_yaml.rc create_form=if rc['search']['sisu']['flag']==true \ and action \ and db \ @@ -1387,8 +1554,8 @@ WOK self end def widget_static - @rc=SiSU_Env::Get_init.instance.sisu_yaml.rc - @vz=SiSU_Env::Get_init.instance.skin + @rc=SiSU_Env::GetInit.instance.sisu_yaml.rc + @vz=SiSU_Env::GetInit.instance.skin @flag={ ad: false, md: false, sk: false, rc: false } def search? flag=if defined? @rc['search'] \ @@ -1435,7 +1602,7 @@ WOK end end def search_form(action=nil,db=nil) - rc=SiSU_Env::Get_init.instance.sisu_yaml.rc + rc=SiSU_Env::GetInit.instance.sisu_yaml.rc create_form=if defined? rc['search']['sisu']['flag'] \ and rc['search']['sisu']['flag']==true \ and action \ @@ -1584,7 +1751,12 @@ WOK end end def default_output_css - if @env.output_dir_structure.by_language_code? + if (@md.opt.opt_act[:dump][:bool] \ + && @md.opt.opt_act[:dump][:inst]) \ + || (@md.opt.opt_act[:redirect][:bool] \ + && @md.opt.opt_act[:redirect][:inst]) + './' + elsif @env.output_dir_structure.by_language_code? '../../' elsif @env.output_dir_structure.by_filetype? '../' @@ -1626,7 +1798,7 @@ WOK @sys.home end def sisurc_path - Get_init.instance.sisu_yaml.rc_path + GetInit.instance.sisu_yaml.rc_path end def pwd @sys.pwd @@ -1680,7 +1852,14 @@ WOK defaults[:sisu_share] end def style - defaults[:stylesheet_stub] + if (@md.opt.opt_act[:dump][:bool] \ + && @md.opt.opt_act[:dump][:inst]) \ + || (@md.opt.opt_act[:redirect][:bool] \ + && @md.opt.opt_act[:redirect][:inst]) + 'css' + else + defaults[:stylesheet_stub] + end end def sample_data #sample data repository source directory defaults[:sample_data_path] @@ -1689,7 +1868,7 @@ WOK @sys.rc_path end def yamlrc - Get_init.instance.sisu_yaml.rc_path + GetInit.instance.sisu_yaml.rc_path end def man #check use (defined? @rc['webserv']['man']) \ @@ -2437,7 +2616,7 @@ WOK elsif conf; @rc['default']['language'] #3 config: from sisurc.yaml else defaults[:language] #4 sisu: program default end #1 document: param gets - SiSU_Env::Standardise_language.new(l) + SiSU_Env::StandardiseLanguage.new(l) end #def multilingual # x=(defined? @rc['output_structure']['multilingual'] \ @@ -2511,7 +2690,7 @@ WOK end if f_pod \ && FileTest.file?(f_pod) - tree=(SiSU_Env::System_call.new.program_found?('tree')) \ + tree=(SiSU_Env::SystemCall.new.program_found?('tree')) \ ? "tree #{processing_path.processing}/sisupod" : '' if FileTest.directory?(processing_path.processing) @@ -2541,10 +2720,10 @@ WOK sisupod_processing_path end end - class Info_processing_flag + class InfoProcessingFlag attr_accessor :color,:cf_0,:cf_1,:cf_2,:cf_3,:cf_4,:cf_5 def initialize - @rc=Get_init.instance.sisu_yaml.rc + @rc=GetInit.instance.sisu_yaml.rc end def color #processing flag shortcuts (defined? @rc['flag']['color']) ? @rc['flag']['color'] : false @@ -2554,7 +2733,7 @@ WOK and not (@rc['flag']['default'].nil? \ or @rc['flag']['default'].empty?) @rc['flag']['default'] - else '-NQhewpotbxXyYv' + else '-NQhewpotbxXdyYv' end end def cf_1 #processing flag shortcuts @@ -2570,7 +2749,7 @@ WOK and not (@rc['flag']['ii'].nil? \ or @rc['flag']['ii'].empty?) @rc['flag']['ii'] - else '-NQhewpotbxXy' + else '-NQhewpotbxXdy' end end def cf_3 #processing flag shortcuts @@ -2578,7 +2757,7 @@ WOK and not (@rc['flag']['iii'].nil? \ or @rc['flag']['iii'].empty?) @rc['flag']['iii'] - else '-NQhewpotbxXyY' + else '-NQhewpotbxXdyY' end end def cf_4 #processing flag shortcuts @@ -2586,7 +2765,7 @@ WOK and not (@rc['flag']['iv'].nil? \ or @rc['flag']['iv'].empty?) @rc['flag']['iv'] - else '-NQhewpotbxXDyY --update' + else '-NQhewpotbxXdDyY --update' end end def cf_5 #processing flag shortcuts @@ -2594,11 +2773,11 @@ WOK and not (@rc['flag']['v'].nil? \ or @rc['flag']['v'].empty?) @rc['flag']['v'] - else '-NQhewpotbxXDyYv --update' + else '-NQhewpotbxXdDyYv --update' end end end - class Info_settings < Info_env + class InfoSettings < InfoEnv def permission?(prog) #program defaults (defined? @rc['permission_set'][prog]) \ ? @rc['permission_set'][prog] @@ -2610,14 +2789,14 @@ WOK : false end end - class File_map < Info_env + class FileMap < InfoEnv attr_accessor :local_sisu_source def initialize(opt='') #watch / REVIEW super() @opt=opt #,opt.fns,opt.cmd @env=(@opt.fns && !(@opt.fns.empty?) \ - ? (SiSU_Env::Info_env.new(@opt.fns)) - : (SiSU_Env::Info_env.new('dummy.sst'))) + ? (SiSU_Env::InfoEnv.new(@opt.fns)) + : (SiSU_Env::InfoEnv.new('dummy.sst'))) if @opt.cmd =~/m/; @md=SiSU_Param::Parameters.new(@opt).get end ft=[] @@ -2735,19 +2914,21 @@ WOK : @source_path end end - class Clean_output + class CleanOutput require 'fileutils' include FileUtils::Verbose def initialize(opt) @opt=opt - z=File_map.new(@opt) + z=SiSU_Env::FileMap.new(@opt) @zap=z.local_sisu_source if @opt.cmd =~ /[hH]/ @zap=Dir.glob(@zap).join(' ') - if @opt.cmd !~ /w/; @zap.gsub!(/#{@source_path}\/concordance.html/,'') + @zap=if @opt.cmd !~ /w/ + @zap.gsub(/#{@source_path}\/concordance.html/,'') + else @zap end end - @env=SiSU_Env::Info_env.new + @env=SiSU_Env::InfoEnv.new end def zap def main_output @@ -2781,11 +2962,11 @@ WOK self end end - class Info_remote_host + class InfoRemoteHost def initialize - @rc=Get_init.instance.sisu_yaml.rc + @rc=GetInit.instance.sisu_yaml.rc end - def remote_host #see Info_remote remote_host_base_general + def remote_host #see InfoRemote remote_host_base_general r=[] r=if (defined? @rc['remote'] \ and @rc['remote'].class==Array) @@ -2829,48 +3010,48 @@ WOK end def rhost def r1 - (defined? SiSU_Env::Info_remote_host.new.remote_host[0][:name]) \ - ? (SiSU_Env::Info_remote_host.new.remote_host[0][:name]) + (defined? SiSU_Env::InfoRemoteHost.new.remote_host[0][:name]) \ + ? (SiSU_Env::InfoRemoteHost.new.remote_host[0][:name]) : nil end def r2 - (defined? SiSU_Env::Info_remote_host.new.remote_host[1][:name]) \ - ? (SiSU_Env::Info_remote_host.new.remote_host[1][:name]) + (defined? SiSU_Env::InfoRemoteHost.new.remote_host[1][:name]) \ + ? (SiSU_Env::InfoRemoteHost.new.remote_host[1][:name]) : nil end def r3 - (defined? SiSU_Env::Info_remote_host.new.remote_host[2][:name]) \ - ? (SiSU_Env::Info_remote_host.new.remote_host[2][:name]) + (defined? SiSU_Env::InfoRemoteHost.new.remote_host[2][:name]) \ + ? (SiSU_Env::InfoRemoteHost.new.remote_host[2][:name]) : nil end def r4 - (defined? SiSU_Env::Info_remote_host.new.remote_host[3][:name]) \ - ? (SiSU_Env::Info_remote_host.new.remote_host[3][:name]) + (defined? SiSU_Env::InfoRemoteHost.new.remote_host[3][:name]) \ + ? (SiSU_Env::InfoRemoteHost.new.remote_host[3][:name]) : nil end def r5 - (defined? SiSU_Env::Info_remote_host.new.remote_host[4][:name]) \ - ? (SiSU_Env::Info_remote_host.new.remote_host[4][:name]) + (defined? SiSU_Env::InfoRemoteHost.new.remote_host[4][:name]) \ + ? (SiSU_Env::InfoRemoteHost.new.remote_host[4][:name]) : nil end def r6 - (defined? SiSU_Env::Info_remote_host.new.remote_host[5][:name]) \ - ? (@ls + SiSU_Env::Info_remote_host.new.remote_host[5][:name]) + (defined? SiSU_Env::InfoRemoteHost.new.remote_host[5][:name]) \ + ? (@ls + SiSU_Env::InfoRemoteHost.new.remote_host[5][:name]) : nil end self end end - class Info_remote < File_map + class InfoRemote < FileMap @@flag_remote=false require 'socket' def initialize(opt) super(opt) # @opt=opt - @rc=Get_init.instance.sisu_yaml.rc + @rc=GetInit.instance.sisu_yaml.rc end def remote_host_base_general - SiSU_Env::Info_remote_host.new.remote_host + SiSU_Env::InfoRemoteHost.new.remote_host end def remote_host_base remote_host_base_general.each do |remote_conn| @@ -2901,15 +3082,15 @@ WOK and remote_gen !~/\/\//) \ and @@flag_remote==true \ and @opt.cmd !~/U/ - System_call.new(local_gen,remote_gen).scp + SiSU_Env::SystemCall.new(local_gen,remote_gen).scp if FileTest.file?("#{local_src}/#{src_txt}") - System_call.new("#{local_src}/#{src_txt}",remote_src).scp + SiSU_Env::SystemCall.new("#{local_src}/#{src_txt}",remote_src).scp end if FileTest.file?("#{local_pod}/#{src_pod}") - System_call.new("#{local_src}/#{src_pod}",remote_pod).scp + SiSU_Env::SystemCall.new("#{local_src}/#{src_pod}",remote_pod).scp end if FileTest.file?("#{local_epub}/#{@opt.fnb}.epub") - System_call.new("#{local_epub}/#{@opt.fnb}.epub",remote_epub,@opt.cmd).scp + SiSU_Env::SystemCall.new("#{local_epub}/#{@opt.fnb}.epub",remote_epub,@opt.cmd).scp end elsif @opt.cmd =~/U/ puts "#{__FILE__} #{__LINE__}" if @opt.cmd =~/M/ @@ -2936,7 +3117,7 @@ WOK and @@flag_remote==true \ and @opt.cmd !~/U/ puts "begin scp_base: #{local} -> #{remote}" - System_call.new("#{local}/#{@env.path.style}/",remote).scp + SiSU_Env::SystemCall.new("#{local}/#{@env.path.style}/",remote).scp elsif @opt.cmd =~/U/ puts "#{__FILE__} #{__LINE__}" if @opt.cmd =~/M/ puts "begin scp_base: #{local} -> #{remote}" @@ -2954,9 +3135,9 @@ WOK and @@flag_remote==true \ and @opt.cmd !~/U/ puts "begin scp_base_all: #{local} -> #{remote}" - System_call.new("#{local}/_sisu/image_sys/",remote).scp - System_call.new("#{local}/_sisu/image/",remote).scp - System_call.new("#{local}/#{@env.path.style}/",remote).scp + SiSU_Env::SystemCall.new("#{local}/_sisu/image_sys/",remote).scp + SiSU_Env::SystemCall.new("#{local}/_sisu/image/",remote).scp + SiSU_Env::SystemCall.new("#{local}/#{@env.path.style}/",remote).scp elsif @opt.cmd =~/U/ puts "#{__FILE__} #{__LINE__}" if @opt.cmd =~/M/ puts "scp_base_all: #{local} -> #{remote}" @@ -2970,7 +3151,7 @@ WOK self end def images_from_skin - skin=Info_skin.new(@md).select + skin=SiSU_Env::InfoSkin.new(@md).select skin_array=nil skin_images_array=[] if skin @@ -2986,7 +3167,7 @@ WOK skin_images_array end def rsync - @f=SiSU_Env::SiSU_file.new(@md) + @f=SiSU_Env::FileOp.new(@md) def document self.remote_host_base.each do |remote_conn| local_gen=@source_path @@ -3001,7 +3182,7 @@ WOK and remote_gen !~/\/\//) \ and @@flag_remote==true \ and @opt.cmd !~/U/ -# System_call.new("#{local_src}/#{src_txt}",remote_src,@opt.cmd).rsync +# SiSU_Env::SystemCall.new("#{local_src}/#{src_txt}",remote_src,@opt.cmd).rsync delete_extra_files='--delete' # '--delete-after' inp=[] if (@opt.cmd =~/h/ \ @@ -3108,13 +3289,13 @@ WOK ##create file structure without copying files?: ##rsync -av -f"+ */" -f"- *" @f.output_path.base.dir remote:./path/. #local_dirs=%{-f"+ */" -f"- *" #{@f.output_path.base.dir}/*} - #System_call.new(local_dirs,remote_gen,@opt.cmd).rsync + #SiSU_Env::SystemCall.new(local_dirs,remote_gen,@opt.cmd).rsync local=local_gen + ' ' + images + ' ' + images_skin + ' ' + images_system + ' ' + local_css - System_call.new(local,remote_rel,@opt.cmd).rsync('--relative',@f.output_path.base.dir) + SiSU_Env::SystemCall.new(local,remote_rel,@opt.cmd).rsync('--relative',@f.output_path.base.dir) rescue p __LINE__.to_s + ':' + __FILE__ local_dirs=%{--include='*/' --exclude='*' #{@f.output_path.base.dir}} - System_call.new(local_dirs,remote_gen,@opt.cmd).rsync + SiSU_Env::SystemCall.new(local_dirs,remote_gen,@opt.cmd).rsync end elsif @opt.cmd =~/U/ puts "#{__FILE__} #{__LINE__}" if @opt.cmd =~/M/ @@ -3141,9 +3322,9 @@ WOK and @rc['permission_set']['remote_base_site'] \ and @@flag_remote==true \ and @opt.cmd !~/U/ - System_call.new("#{image_sys}","#{remote_conf}").rsync - System_call.new("#{images}","#{remote_conf}").rsync - System_call.new("#{ldest}","#{remote}").rsync + SiSU_Env::SystemCall.new("#{image_sys}","#{remote_conf}").rsync + SiSU_Env::SystemCall.new("#{images}","#{remote_conf}").rsync + SiSU_Env::SystemCall.new("#{ldest}","#{remote}").rsync elsif @opt.cmd =~/U/ puts "#{__FILE__} #{__LINE__}" if @opt.cmd =~/M/ puts "rsync_base: #{local} -> #{remote}" @@ -3164,9 +3345,9 @@ WOK and @opt.cmd !~/U/ delete_extra_files='--delete' # '--delete-after' puts "begin rsync_base_sync: #{local} -> #{remote}" - System_call.new("#{local}/_sisu/image_sys/",remote).rsync(delete_extra_files) - System_call.new("#{local}/_sisu/image/",remote).rsync(delete_extra_files) - System_call.new("#{local}/#{@env.path.style}/",remote).rsync(delete_extra_files) + SiSU_Env::SystemCall.new("#{local}/_sisu/image_sys/",remote).rsync(delete_extra_files) + SiSU_Env::SystemCall.new("#{local}/_sisu/image/",remote).rsync(delete_extra_files) + SiSU_Env::SystemCall.new("#{local}/#{@env.path.style}/",remote).rsync(delete_extra_files) elsif @opt.cmd =~/U/ puts "#{__FILE__} #{__LINE__}" if @opt.cmd =~/M/ puts "rsync_base_sync: #{local} -> #{remote}" @@ -3185,7 +3366,7 @@ WOK remote="#{remote_conn[:name]}/#{@env.path.stub_pwd}/." if @@flag_remote delete_extra_files='--delete' # '--delete-after' - System_call.new(local,remote).rsync(delete_extra_files) + SiSU_Env::SystemCall.new(local,remote).rsync(delete_extra_files) elsif @opt.cmd =~/U/ puts "#{__FILE__} #{__LINE__}" if @opt.cmd =~/M/ puts "rsync_sitemaps: #{local} -> #{remote}" @@ -3199,7 +3380,7 @@ WOK remote="#{remote_conn[:name]}/#{@env.path.stub_pwd}/." if @@flag_remote delete_extra_files='--delete' # '--delete-after' - System_call.new(local,remote).rsync(delete_extra_files) + SiSU_Env::SystemCall.new(local,remote).rsync(delete_extra_files) elsif @opt.cmd =~/U/ puts "#{__FILE__} #{__LINE__}" if @opt.cmd =~/M/ puts "rsync_sitemaps: #{local} -> #{remote}" @@ -3208,7 +3389,7 @@ WOK end end end - class Info_version <Info_env + class InfoVersion <InfoEnv include Singleton require 'rbconfig' @@lib_path=nil @@ -3226,11 +3407,11 @@ WOK %x{ruby -v}.strip end end - class Create_system_link #revisit problems created 2004w41 + class CreateSystemLink #revisit problems created 2004w41 require 'fileutils' include FileUtils::Verbose def initialize - @env=SiSU_Env::Info_env.new + @env=SiSU_Env::InfoEnv.new end def images unless FileTest.directory?("#{@env.path.output}/_sisu") @@ -3248,12 +3429,12 @@ WOK #File.symlink("../../man/form", "#{@env.path.output}/man/pdf") unless File.symlink?("#{@env.path.output}/man/pdf")==true end end - class Info_file <Info_env #todo unify with SiSU_file + class InfoFile <InfoEnv #todo unify with FileOp def initialize(fns) begin super(fns) @fns=fns - @env=SiSU_Env::Info_env.new(@fns) + @env=SiSU_Env::InfoEnv.new(@fns) m=/((.+?)(?:\~\w\w(?:_\w\w)?)?)\.((?:-|ssm\.)?sst|ssm)$/ #watch added match for sss @fnn,@fnb,@fnt=@fns[m,1],@fns[m,2],@fns[m,3] rescue; STDERR.puts SiSU_Screen::Ansi.new(@fns,$!,$@).rescue @@ -3314,7 +3495,7 @@ WOK end self end - def mkdir #check moved from SiSU_file, existing mkdir + def mkdir #check moved from FileOp, existing mkdir def processing def dal FileUtils::mkdir_p(@env.processing_path.dal) unless FileTest.directory?(@env.processing_path.dal) @@ -3326,31 +3507,434 @@ WOK end end end - class SiSU_file <Info_file #todo unify with Create_file - def initialize(md,fno='') - begin - @md,@fno=md,fno - @env=SiSU_Env::Info_env.new(@md.fns) - rescue; STDERR.puts SiSU_Screen::Ansi.new(@cmd,$!,$@).rescue - ensure + class ProcessingSettings + def initialize(md) + @md=md + end + def cnf_rc #sisurc.yml + @rc=SiSU_Env::GetInit.instance.sisu_yaml.rc + end + def env_rc #env rc (including sisurc.yml) + @env_rc ||=SiSU_Env::InfoEnv.new(@md.fns) + end + def doc_rc #document rc, make instructions + @md.make + end + def cmd_rc #command-line rc + @cmd_rc=@md.opt.opt_act + end + def build + def ocn? + if cmd_rc[:ocn][:set]==:on + true + elsif cmd_rc[:ocn][:set]==:off + false + elsif @md.make.ocn? ==:off + false + elsif env_rc.build.ocn? ==:off + false + else + true + end + end + def toc? + if cmd_rc[:toc][:set]==:on + true + elsif cmd_rc[:toc][:set]==:off + false + elsif @md.make.toc? ==:off + false + elsif env_rc.build.toc? ==:off + false + else + true + end + end + def manifest? + if cmd_rc[:manifest][:set]==:on + true + elsif cmd_rc[:manifest][:set]==:off + false + elsif @md.make.manifest? ==:off + false + elsif env_rc.build.manifest? ==:off + false + else + true + end + end + def links_to_manifest? + if cmd_rc[:links_to_manifest][:set]==:on + true + elsif cmd_rc[:links_to_manifest][:set]==:off + false + elsif @md.make.links_to_manifest? ==:off + false + elsif env_rc.build.links_to_manifest? ==:off + false + else + true + end + end + def metadata? + if cmd_rc[:metadata][:set]==:on + true + elsif cmd_rc[:metadata][:set]==:off + false + elsif @md.make.metadata? ==:off + false + elsif env_rc.build.metadata? ==:off + false + else + true + end + end + def minitoc? + if html_top_band? == false #one form of navigation necessary + true + elsif cmd_rc[:minitoc][:set]==:on + true + elsif cmd_rc[:minitoc][:set]==:off + false + elsif @md.make.minitoc? ==:off + false + elsif env_rc.build.minitoc? ==:off + false + else + true + end + end + def manifest_minitoc? + if html_top_band? == false #one form of navigation necessary + true + elsif cmd_rc[:manifest_minitoc][:set]==:on \ + || cmd_rc[:minitoc][:set]==:on + true + elsif cmd_rc[:manifest_minitoc][:set]==:off \ + || cmd_rc[:minitoc][:set]==:off + false + elsif @md.make.manifest_minitoc? ==:off \ + || @md.make.minitoc? ==:off + false + elsif env_rc.build.manifest_minitoc? ==:off \ + || env_rc.build.minitoc? ==:off + false + elsif minitoc? == false + false + else + true + end + end + def html_minitoc? + if html_top_band? == false #one form of navigation necessary + true + elsif cmd_rc[:html_minitoc][:set]==:on \ + || cmd_rc[:minitoc][:set]==:on + true + elsif cmd_rc[:html_minitoc][:set]==:off \ + || cmd_rc[:minitoc][:set]==:off + false + elsif @md.make.html_minitoc? ==:off \ + || @md.make.minitoc? ==:off + false + elsif env_rc.build.html_minitoc? ==:off \ + || env_rc.build.minitoc? ==:off + false + elsif minitoc? == false + false + else + true + end + end + def html_top_band? + if cmd_rc[:html_top_band][:set]==:on + true + elsif cmd_rc[:html_top_band][:set]==:off + false + elsif @md.make.html_top_band? ==:off + false + elsif env_rc.build.html_top_band? ==:off + false + else + true + end end + def html_navigation? + if cmd_rc[:html_navigation][:set]==:on + true + elsif cmd_rc[:html_navigation][:set]==:off + false + elsif @md.make.html_navigation? ==:off + false + elsif env_rc.build.html_navigation? ==:off + false + else + true + end + end + def html_navigation_bar? + if cmd_rc[:html_navigation_bar][:set]==:on + true + elsif cmd_rc[:html_navigation_bar][:set]==:off + false + elsif @md.make.html_navigation_bar? ==:off + false + elsif env_rc.build.html_navigation_bar? ==:off + false + else + true + end + end + def search_form? + if cmd_rc[:search_form][:set]==:on + true + elsif cmd_rc[:search_form][:set]==:off + false + elsif @md.make.search_form? ==:off + false + elsif env_rc.build.search_form? ==:off + false + else + true + end + end + def html_search_form? + if cmd_rc[:html_search_form][:set]==:on \ + || cmd_rc[:search_form][:set]==:on + true + elsif cmd_rc[:html_search_form][:set]==:off \ + || cmd_rc[:search_form][:set]==:off + false + elsif @md.make.html_search_form? ==:off \ + || @md.make.search_form? ==:off + false + elsif env_rc.build.html_search_form? ==:off \ + || env_rc.build.search_form? ==:off + false + elsif search_form? == false + false + else + true + end + end + def html_right_pane? + if cmd_rc[:html_right_pane][:set]==:on + true + elsif cmd_rc[:html_right_pane][:set]==:off + false + elsif @md.make.html_right_pane? ==:off + false + elsif env_rc.build.html_right_pane? ==:off + false + else + true + end + end + def segsubtoc? + if cmd_rc[:segsubtoc][:set]==:on + true + elsif cmd_rc[:segsubtoc][:set]==:off + false + elsif @md.make.segsubtoc? ==:off + false + elsif env_rc.build.segsubtoc? ==:off + false + else + true + end + end + self end def output_dir_structure def by_language_code? - @env.output_dir_structure.by_language_code? + env_rc.output_dir_structure.by_language_code? end def by_filetype? - @env.output_dir_structure.by_filetype? + env_rc.output_dir_structure.by_filetype? end def by_filename? - @env.output_dir_structure.by_filename? + env_rc.output_dir_structure.by_filename? end def multilingual? - @env.output_dir_structure.by_language_code? - #by_language_code? + by_language_code? + end + def dump? + ((cmd_rc[:dump][:bool] \ + && cmd_rc[:dump][:inst]) \ + || (env_rc.output_dir_structure.dump?)) \ + ? true + : false + end + def redirect? + ((cmd_rc[:redirect][:bool] \ + && cmd_rc[:redirect][:inst]) \ + || (env_rc.output_dir_structure.redirect?)) \ + ? true + : false + end + def dump_or_redirect? + ((dump?) || (redirect?)) \ + ? true + : false + end + def by? + if dump? + :dump + elsif redirect? + :redirect + elsif by_language_code? + :language + elsif by_filetype? + :filetype + elsif by_filename? + :filename + else #recheck current default + :language + end end self end + end + class InfoDb < InfoEnv + @@rc=nil + def initialize + @@pwd ||=Dir.pwd + @pwd=Dir.pwd + @env=SiSU_Env::InfoEnv.new + pt=Pathname.new(@pwd) + r=Px[:lng_lst].join('|') + u=/.+?\/([^\/]+)(?:\/(?:#{r})$|$)/ + @pwd_stub=pt.realpath.to_s[u,1] + @rc=@@rc ||=GetInit.instance.sisu_yaml.rc + @defaults=SiSU_Env::InfoEnv.new.defaults + end + def share_source? + ((defined? @rc['db']['share_source']) \ + && @rc['db']['share_source']==true) \ + ? @rc['db']['share_source'] + : false + end + def engine + def default + ((defined? @rc['db']['engine']['default']) \ + && @rc['db']['engine']['default']=~/postgresql|sqlite/) \ + ? @rc['db']['engine']['default'] + : 'sqlite' + end + self + end + def psql + def user + ((defined? @rc['db']['postgresql']['user']) \ + && @rc['db']['postgresql']['user']=~/\S+/) \ + ? @rc['db']['postgresql']['user'] + : @env.user + end + def db #db_name + "#{Db[:name_prefix]}#{@pwd_stub}" + end + def port #PGPORT + ((defined? @rc['db']['postgresql']['port']) \ + && ( @rc['db']['postgresql']['port'] =~/\d+/ \ + || @rc['db']['postgresql']['port'].class==Fixnum)) \ + ? @rc['db']['postgresql']['port'] + : (@defaults[:postgresql_port]) + end + def password + ((defined? @rc['db']['postgresql']['password']) \ + && @rc['db']['postgresql']['password']=~/\S+/) \ + ? @rc['db']['postgresql']['password'] + : '' + end + def host + ((defined? @rc['db']['postgresql']['host']) \ + && @rc['db']['postgresql']['host']=~/(?:\S{1,3}\.){3}\S{1,3}|\S+?\.\S+/) \ + ? @rc['db']['postgresql']['host'] + : '' + end + def dbi + (psql.host =~/(?:\S{1,3}\.){3}\S{1,3}|\S+?\.\S+/) \ + ? "DBI:Pg:database=#{psql.db};host=#{psql.host};port=#{psql.port}" + : "DBI:Pg:database=#{psql.db};port=#{psql.port}" + end + def conn_dbi + DBI.connect(psql.dbi,psql.user,psql.db) + end + self + end + def mysql + def db + #"#{Db[:name_prefix]}#{@pwd_stub}" + end + def port + '**' + end + def dbi + "dbi:Mysql:database=#{mysql.db};port=#{mysql.port}" + end + self + end + def sqlite + def db + "#{@env.path.webserv}/#{@pwd_stub}/sisu_sqlite.db" + end + def db_discreet(md) + # "#{@env.path.webserv}/#{@pwd_stub}/sisu_sqlite.db" + end + def dbi + "DBI:SQLite3:#{sqlite.db}" #sqlite3 ? + end + def sqlite3 + sqlite.db #sqlite3 ? + end + def conn_dbi + DBI.connect(sqlite.dbi) + end + def conn_sqlite3 + SQLite3::Database.new(sqlite.sqlite3) + end + self + end + end + class DbOp <InfoDb + def initialize(md) + begin + @md=md + rescue; STDERR.puts SiSU_Screen::Ansi.new(@cmd,$!,$@).rescue + ensure + end + end + def sqlite_discreet + def db + "#{@md.file.output_path.sqlite_discreet.dir}/#{@md.file.base_filename.sqlite_discreet}" + end + def dbi + "DBI:SQLite3:#{sqlite_discreet.db}" + end + def sqlite3 + sqlite_discreet.db + end + def conn_dbi + DBI.connect(sqlite_discreet.dbi) + end + def conn_sqlite3 + SQLite3::Database.new(sqlite_discreet.sqlite3) + end + self + end + end + class FileOp <InfoFile #todo unify with CreateFile + def initialize(md,fno='') + begin + @md,@fno=md,fno + @env=SiSU_Env::InfoEnv.new(@md.fns) + rescue; STDERR.puts SiSU_Screen::Ansi.new(@cmd,$!,$@).rescue + ensure + end + end + def output_dir_structure + ProcessingSettings.new(@md).output_dir_structure + end def mkdir_initialize # not used but consider using FileUtils::mkdir_p(output_path.base.dir) unless FileTest.directory?(output_path.base.dir) FileUtils::mkdir_p("#{output_path.base.dir}/#{@md.fnb}") unless FileTest.directory?("#{output_path.base.dir}/#{@md.fnb}") @@ -3400,7 +3984,8 @@ WOK @@filename_html_scroll=File.new(p_fn,'w+') end def html_seg_index - pth=(by_filename?) \ + pth=((by_filename?) \ + || (output_dir_structure.dump?)) \ ? "#{output_path.html.dir}" : "#{output_path.html.dir}/#{@md.fnb}" fn=base_filename.html_seg_index @@ -3409,7 +3994,8 @@ WOK @@filename_html_index=File.new(p_fn,'w+') end def html_segtoc - pth=(by_filename?) \ + pth=((by_filename?) \ + || (output_dir_structure.dump?)) \ ? "#{output_path.html.dir}" : "#{output_path.html.dir}/#{@md.fnb}" fn=base_filename.html_segtoc @@ -3597,6 +4183,15 @@ WOK end self end + def sqlite_discreet + def dir + output_path.sqlite_discreet.dir + '/' + base_filename.sqlite_discreet + end + def rel + output_path.sqlite_discreet.rel + '/' + base_filename.sqlite_discreet + end + self + end def hash_digest def dir output_path.hash_digest.dir + '/' + base_filename.hash_digest @@ -3719,9 +4314,9 @@ WOK def base_filename def txt ft='.txt' - if @env.output_dir_structure.by_language_code? + if output_dir_structure.by_language_code? @md.fnb + ft - elsif @env.output_dir_structure.by_filetype? + elsif output_dir_structure.by_filetype? @md.fnb + @md.lang_code_insert + ft else 'plain' + @md.lang_code_insert + ft @@ -3729,9 +4324,9 @@ WOK end def html_scroll ft='.html' - if @env.output_dir_structure.by_language_code? + if output_dir_structure.by_language_code? @md.fnb + ft - elsif @env.output_dir_structure.by_filetype? + elsif output_dir_structure.by_filetype? @md.fnb + @md.lang_code_insert + ft else 'scroll' + @md.lang_code_insert + ft @@ -3739,7 +4334,7 @@ WOK end def html_seg_index ft='.html' - if @env.output_dir_structure.by_language_code? + if output_dir_structure.by_language_code? 'index' + ft else 'index' + @md.lang_code_insert + ft @@ -3747,7 +4342,9 @@ WOK end def html_segtoc ft='.html' - if @env.output_dir_structure.by_language_code? + if output_dir_structure.dump_or_redirect? + @md.fnb + '.toc' + ft + elsif output_dir_structure.by_language_code? 'toc' + ft else 'toc' + @md.lang_code_insert + ft @@ -3755,7 +4352,7 @@ WOK end def html_book_index ft='.html' - if @env.output_dir_structure.by_language_code? + if output_dir_structure.by_language_code? 'book_index' + ft else 'book_index' + @md.lang_code_insert + ft @@ -3763,7 +4360,9 @@ WOK end def html_concordance ft='.html' - if @env.output_dir_structure.by_language_code? + if output_dir_structure.dump_or_redirect? + @md.fnb + '.concordance' + ft + elsif output_dir_structure.by_language_code? 'concordance' + ft else 'concordance' + @md.lang_code_insert + ft @@ -3771,9 +4370,9 @@ WOK end def xhtml ft= '.xhtml' - if @env.output_dir_structure.by_language_code? + if output_dir_structure.by_language_code? @md.fnb + ft - elsif @env.output_dir_structure.by_filetype? + elsif output_dir_structure.by_filetype? @md.fnb + @md.lang_code_insert + ft else 'scroll' + @md.lang_code_insert + ft @@ -3781,7 +4380,7 @@ WOK end def epub ft='.epub' - if @env.output_dir_structure.by_language_code? + if output_dir_structure.by_language_code? @md.fnb + ft else @md.fnb + @md.lang_code_insert + ft @@ -3789,9 +4388,9 @@ WOK end def odt ft='.odt' - if @env.output_dir_structure.by_language_code? + if output_dir_structure.by_language_code? @md.fnb + ft - elsif @env.output_dir_structure.by_filetype? + elsif output_dir_structure.by_filetype? @md.fnb + @md.lang_code_insert + ft else 'opendocument' + @md.lang_code_insert + ft @@ -3799,9 +4398,9 @@ WOK end def xml_sax ft='.sax.xml' - if @env.output_dir_structure.by_language_code? + if output_dir_structure.by_language_code? @md.fnb + ft - elsif @env.output_dir_structure.by_filetype? + elsif output_dir_structure.by_filetype? @md.fnb + @md.lang_code_insert + ft else 'scroll' + @md.lang_code_insert + ft @@ -3809,22 +4408,22 @@ WOK end def xml_dom ft='.dom.xml' - if @env.output_dir_structure.by_language_code? + if output_dir_structure.by_language_code? @md.fnb + ft - elsif @env.output_dir_structure.by_filetype? + elsif output_dir_structure.by_filetype? @md.fnb + @md.lang_code_insert + ft else 'scroll' + @md.lang_code_insert + ft end end def pdf_p - if @env.output_dir_structure.by_language_code? + if output_dir_structure.by_language_code? @md.fnb + '.portrait.' else 'portrait' + @md.lang_code_insert + '.' end end def pdf_l - if @env.output_dir_structure.by_language_code? + if output_dir_structure.by_language_code? @md.fnb + '.landscape.' else 'landscape' + @md.lang_code_insert + '.' end @@ -3861,7 +4460,7 @@ WOK end def manpage ft='1' - if @env.output_dir_structure.by_language_code? + if output_dir_structure.by_language_code? @md.fnb + '.' + ft else @md.fnb + '.' + @md.opt.f_pth[:lng_is] + '.' + ft @@ -3869,7 +4468,7 @@ WOK end def info ft='info' - if @env.output_dir_structure.by_language_code? + if output_dir_structure.by_language_code? @md.fnb + '.' + ft else @md.fnb + '.' + @md.opt.f_pth[:lng_is] + '.' + ft @@ -3877,17 +4476,25 @@ WOK end def texinfo ft='texinfo' - if @env.output_dir_structure.by_language_code? + if output_dir_structure.by_language_code? @md.fnb + '.' + ft else @md.fnb + '.' + @md.opt.f_pth[:lng_is] + '.' + ft end end + def sqlite_discreet + ft='.sql.db' + if output_dir_structure.by_language_code? + @md.fnb + ft + else + @md.fnb + @md.lang_code_insert + ft + end + end def hash_digest ft='.txt' - if @env.output_dir_structure.by_language_code? + if output_dir_structure.by_language_code? @md.fnb + '.hash_digest' + ft - elsif @env.output_dir_structure.by_filetype? + elsif output_dir_structure.by_filetype? @md.fnb + @md.lang_code_insert + ft else 'digest' + @md.lang_code_insert + ft @@ -3895,9 +4502,9 @@ WOK end def sitemap ft='.xml' - if @env.output_dir_structure.by_language_code? + if output_dir_structure.by_language_code? @md.fnb + '.sitemap' + ft - elsif @env.output_dir_structure.by_filetype? + elsif output_dir_structure.by_filetype? @md.fnb + @md.lang_code_insert + ft else 'sitemap' + @md.lang_code_insert + ft @@ -3905,9 +4512,9 @@ WOK end def qrcode_title ft='.title.png' - if @env.output_dir_structure.by_language_code? + if output_dir_structure.by_language_code? @md.fnb + ft - elsif @env.output_dir_structure.by_filetype? + elsif output_dir_structure.by_filetype? @md.fnb + @md.lang_code_insert + ft else #fix 'sisu_manifest' + @md.lang_code_insert + ft @@ -3915,9 +4522,9 @@ WOK end def qrcode_md ft='.md.png' - if @env.output_dir_structure.by_language_code? + if output_dir_structure.by_language_code? @md.fnb + ft - elsif @env.output_dir_structure.by_filetype? + elsif output_dir_structure.by_filetype? @md.fnb + @md.lang_code_insert + ft else #fix 'sisu_manifest' + @md.lang_code_insert + ft @@ -3925,9 +4532,9 @@ WOK end def manifest_txt ft='.txt' - if @env.output_dir_structure.by_language_code? + if output_dir_structure.by_language_code? @md.fnb + ft - elsif @env.output_dir_structure.by_filetype? + elsif output_dir_structure.by_filetype? @md.fnb + @md.lang_code_insert + ft else #fix 'sisu_manifest' + @md.lang_code_insert + ft @@ -3935,9 +4542,11 @@ WOK end def manifest ft='.html' - if @env.output_dir_structure.by_language_code? + if output_dir_structure.dump_or_redirect? + @md.fnb + '.manifest' + ft + elsif output_dir_structure.by_language_code? @md.fnb + ft - elsif @env.output_dir_structure.by_filetype? + elsif output_dir_structure.by_filetype? @md.fnb + @md.lang_code_insert + ft else #fix 'sisu_manifest' + @md.lang_code_insert + ft @@ -3967,52 +4576,70 @@ WOK @ft=ft def dir def abc - if @env.output_dir_structure.by_language_code? + if output_dir_structure.redirect? + "#{@md.opt.opt_act[:redirect][:inst]}/#{@md.fnb}" + elsif output_dir_structure.dump? + @md.opt.opt_act[:dump][:inst] + elsif output_dir_structure.by_language_code? "#{output_path.base.dir}/#{@md.opt.lng}/#{@ft}" - elsif @env.output_dir_structure.by_filetype? + elsif output_dir_structure.by_filetype? "#{output_path.base.dir}/#{@ft}" else "#{output_path.base.dir}/#{@md.fnb}" end end def ab - if @env.output_dir_structure.by_language_code? + if output_dir_structure.redirect? + "#{@md.opt.opt_act[:redirect][:inst]}/#{@md.fnb}" + elsif output_dir_structure.dump? + @md.opt.opt_act[:dump][:inst] + elsif output_dir_structure.by_language_code? "#{output_path.base.dir}/#{@md.opt.lng}/#{@ft}" else "#{output_path.base.dir}/#{@ft}" end end def ab_src - if @env.output_dir_structure.by_language_code? + if output_dir_structure.redirect? + "#{@md.opt.opt_act[:redirect][:inst]}/#{@md.fnb}" + elsif output_dir_structure.dump? + @md.opt.opt_act[:dump][:inst] + elsif output_dir_structure.by_language_code? "#{output_path.base.dir}/#{@ft}/#{@md.opt.lng}" else "#{output_path.base.dir}/#{@ft}" end end def ab_pod - "#{output_path.base.dir}/#{@ft}" + if output_dir_structure.redirect? + "#{@md.opt.opt_act[:redirect][:inst]}/#{@md.fnb}" + elsif output_dir_structure.dump? + @md.opt.opt_act[:dump][:inst] + else + "#{output_path.base.dir}/#{@ft}" + end end self end def url def abc - if @env.output_dir_structure.by_language_code? + if output_dir_structure.by_language_code? "#{output_path.base.url}/#{@md.opt.lng}/#{@ft}" - elsif @env.output_dir_structure.by_filetype? + elsif output_dir_structure.by_filetype? "#{output_path.base.url}/#{@ft}" else "#{output_path.base.url}/#{@md.fnb}" end end def ab - if @env.output_dir_structure.by_language_code? + if output_dir_structure.by_language_code? "#{output_path.base.url}/#{@md.opt.lng}/#{@ft}" else "#{output_path.base.url}/#{@ft}" end end def ab_src - if @env.output_dir_structure.by_language_code? + if output_dir_structure.by_language_code? "#{output_path.base.url}/#{@ft}/#{@md.opt.lng}" else "#{output_path.base.url}/#{@ft}" @@ -4025,30 +4652,32 @@ WOK end def rel def abc - if @env.output_dir_structure.by_language_code? + if output_dir_structure.by_language_code? "#{@md.opt.lng}/#{@ft}" - elsif @env.output_dir_structure.by_filetype? + elsif output_dir_structure.by_filetype? "#{@ft}" else "#{@md.fnb}" end end def ab - if @env.output_dir_structure.by_language_code? + if output_dir_structure.by_language_code? "#{@md.opt.lng}/#{@ft}" else "#{@ft}" end end def ab_src - if @env.output_dir_structure.by_language_code? + if output_dir_structure.dump_or_redirect? + "." + elsif output_dir_structure.by_language_code? "#{@ft}/#{@md.opt.lng}" else "#{@ft}" end end def ab_pod - if @env.output_dir_structure.by_language_code? + if output_dir_structure.by_language_code? "#{@ft}" else "#{@ft}" @@ -4058,30 +4687,36 @@ WOK end def rel_sm def abc - if @env.output_dir_structure.by_language_code? + if output_dir_structure.by_language_code? "#{@md.opt.lng}/#{@ft}" - elsif @env.output_dir_structure.by_filetype? + elsif output_dir_structure.by_filetype? "#{@ft}" else "#{@md.fnb}" end end def ab - if @env.output_dir_structure.by_language_code? - "#{@md.opt.lng}/#{@ft}" - else - "#{@ft}" + if output_dir_structure.dump_or_redirect? + '.' + elsif output_dir_structure.by_language_code? \ + or output_dir_structure.by_filetype? + '../' + @ft + else '.' end end def ab_src - if @env.output_dir_structure.by_language_code? + if output_dir_structure.dump_or_redirect? + '.' + elsif output_dir_structure.by_language_code? "#{@ft}/#{@md.opt.lng}" else "#{@ft}" end end def ab_pod - if @env.output_dir_structure.by_language_code? + if output_dir_structure.dump_or_redirect? + '.' + elsif output_dir_structure.by_language_code? "../../#{@ft}/#{@md.opt.lng}" else "../#{@ft}" @@ -4091,16 +4726,16 @@ WOK end def rcp def abc - if @env.output_dir_structure.by_language_code? + if output_dir_structure.by_language_code? "#{output_path.stub.rcp}/#{@md.opt.lng}/#{@ft}" - elsif @env.output_dir_structure.by_filetype? + elsif output_dir_structure.by_filetype? "#{output_path.stub.rcp}/#{@ft}" else "#{output_path.stub.rcp}/#{@md.fnb}" end end def ab - if @env.output_dir_structure.by_language_code? + if output_dir_structure.by_language_code? "#{output_path.stub.rcp}/#{@md.opt.lng}/#{@ft}" else "#{output_path.stub.rcp}/#{@ft}" @@ -4108,16 +4743,6 @@ WOK end self end - def rel_sm - def ab - if @env.output_dir_structure.by_language_code? \ - or @env.output_dir_structure.by_filetype? - '../' + @ft - else '.' - end - end - self - end self end def output_path @@ -4151,9 +4776,18 @@ WOK end self end + def webserver_path + if output_dir_structure.dump? + @md.opt.opt_act[:dump][:inst] + elsif output_dir_structure.redirect? + @md.opt.opt_act[:redirect][:inst] + else + "#{@env.path.webserv}" + end + end def base def dir - "#{@env.path.webserv}/#{@md.opt.f_pth[:pth_stub]}" + "#{webserver_path}/#{@md.opt.f_pth[:pth_stub]}" end def url "#{@env.url.webserv}/#{@md.opt.f_pth[:pth_stub]}" @@ -4313,9 +4947,11 @@ WOK set_path(ft).rel_sm.ab end def rel_image - if @env.output_dir_structure.by_language_code? + if output_dir_structure.dump_or_redirect? + './image' + elsif output_dir_structure.by_language_code? '../../_sisu/image' - elsif @env.output_dir_structure.by_filetype? + elsif output_dir_structure.by_filetype? '../_sisu/image' else '../_sisu/image' @@ -4343,9 +4979,11 @@ WOK set_path(ft).rel_sm.ab end def rel_image - if @env.output_dir_structure.by_language_code? + if output_dir_structure.dump_or_redirect? + './image' + elsif output_dir_structure.by_language_code? '../../../_sisu/image' - elsif @env.output_dir_structure.by_filetype? + elsif output_dir_structure.by_filetype? '../../_sisu/image' else '../_sisu/image' @@ -4377,9 +5015,9 @@ WOK set_path(ft).rel_sm.ab end def rel_image - if @env.output_dir_structure.by_language_code? + if output_dir_structure.by_language_code? '../../_sisu/image' - elsif @env.output_dir_structure.by_filetype? + elsif output_dir_structure.by_filetype? '../_sisu/image' else '../_sisu/image' @@ -4509,6 +5147,27 @@ WOK end self end + def sqlite_discreet + def ft + 'sql' + end + def dir + set_path(ft).dir.ab + end + def url + set_path(ft).url.ab + end + def rel + set_path(ft).rel.ab + end + def rcp + set_path(ft).rcp.ab + end + def rel_sm + set_path(ft).rel_sm.ab + end + self + end def hash_digest def ft 'hashes' @@ -4564,6 +5223,9 @@ WOK def rcp set_path(ft).rcp.abc end + def rel_sm + set_path(ft).rel_sm.ab + end self end def harvest @@ -4583,9 +5245,9 @@ WOK set_path(ft).rcp.ab end def rel_sm - if @env.output_dir_structure.by_language_code? + if output_dir_structure.by_language_code? '' - elsif @env.output_dir_structure.by_filetype? + elsif output_dir_structure.by_filetype? '' else '' @@ -4726,11 +5388,11 @@ WOK self end end - class Create_file <Info_env #todo unify with SiSU_file + class CreateFile <InfoEnv #todo unify with FileOp def initialize(fns) begin super(fns) - @env=SiSU_Env::Info_env.new(fns) + @env=SiSU_Env::InfoEnv.new(fns) rescue; STDERR.puts SiSU_Screen::Ansi.new(@fns,$!,$@).rescue ensure end @@ -4808,13 +5470,13 @@ WOK File.new("#{@env.processing_path.texinfo}/#{@fnb}.texinfo",'w+') end end - class Clear <Info_env #todo unify with SiSU_file + class Clear <InfoEnv #todo unify with FileOp def initialize(cmd,fns,operation='') @cmd=cmd begin super(fns) - @env=SiSU_Env::Info_env.new(fns) - ver=Info_version.instance + @env=SiSU_Env::InfoEnv.new(fns) + ver=InfoVersion.instance if operation.class.inspect =~/SiSU_Param/ @md=operation end @@ -4838,127 +5500,27 @@ WOK end def param_instantiate @cX||=SiSU_Screen::Ansi.new(@cmd) - @@date=Info_date.new + @@date=SiSU_Env::InfoDate.new @@proc=@@filename_txt=@@filename_texinfo=@@filename_lout_portrait=@@filename_lout_landscape=@@filename_html_scroll=@@filename_html_index=@@filename_html_segtoc=@@filename_semantic=@@filename_rss=@@newfile=@@drr=@@yaml=@@yamladdr=nil @@publisher='SiSU scribe' end end - class Info_db < Info_env - @@rc=nil - def initialize - @@pwd ||=Dir.pwd - @pwd=Dir.pwd - @env=SiSU_Env::Info_env.new - #m=/.+\/(?:src\/)?(\S+)/m # m=/.+?\/(?:src\/)?([^\/]+)$/im # m=/.+\/(\S+)/m - #@pwd_stub=@pwd[m,1] - pt=Pathname.new(@pwd) - r=Px[:lng_lst].join('|') - u=/.+?\/([^\/]+)(?:\/(?:#{r})$|$)/ - @pwd_stub=pt.realpath.to_s[u,1] - @rc=@@rc ||=Get_init.instance.sisu_yaml.rc - @defaults=Info_env.new.defaults - end - def share_source? - ((defined? @rc['db']['share_source']) \ - && @rc['db']['share_source']==true) \ - ? @rc['db']['share_source'] - : false - end - def engine - def default - ((defined? @rc['db']['engine']['default']) \ - && @rc['db']['engine']['default']=~/postgresql|sqlite/) \ - ? @rc['db']['engine']['default'] - : 'sqlite' - end - self - end - def psql - def user - ((defined? @rc['db']['postgresql']['user']) \ - && @rc['db']['postgresql']['user']=~/\S+/) \ - ? @rc['db']['postgresql']['user'] - : @env.user - end - def db #db_name - "#{Db[:name_prefix]}#{@pwd_stub}" - end - def port #PGPORT - ((defined? @rc['db']['postgresql']['port']) \ - && ( @rc['db']['postgresql']['port'] =~/\d+/ \ - || @rc['db']['postgresql']['port'].class==Fixnum)) \ - ? @rc['db']['postgresql']['port'] - : (@defaults[:postgresql_port]) - end - def password - ((defined? @rc['db']['postgresql']['password']) \ - && @rc['db']['postgresql']['password']=~/\S+/) \ - ? @rc['db']['postgresql']['password'] - : '' - end - def host - ((defined? @rc['db']['postgresql']['host']) \ - && @rc['db']['postgresql']['host']=~/(?:\S{1,3}\.){3}\S{1,3}|\S+?\.\S+/) \ - ? @rc['db']['postgresql']['host'] - : '' - end - def dbi - (psql.host =~/(?:\S{1,3}\.){3}\S{1,3}|\S+?\.\S+/) \ - ? "DBI:Pg:database=#{psql.db};host=#{psql.host};port=#{psql.port}" - : "DBI:Pg:database=#{psql.db};port=#{psql.port}" - end - def conn_dbi - DBI.connect(psql.dbi,psql.user,psql.db) - end - self - end - def mysql - def db - #"#{Db[:name_prefix]}#{@pwd_stub}" - end - def port - '**' - end - def dbi - "dbi:Mysql:database=#{mysql.db};port=#{mysql.port}" - end - self - end - def sqlite - def db - "#{@env.path.webserv}/#{@pwd_stub}/sisu_sqlite.db" - end - def dbi - "DBI:SQLite3:#{sqlite.db}" #sqlite3 ? - end - def sqlite3 - sqlite.db #sqlite3 ? - end - def conn_dbi - DBI.connect(sqlite.dbi) - end - def conn_sqlite3 - SQLite3::Database.new(sqlite.sqlite3) - end - self - end - end - class Info_port < Info_env + class InfoPort < InfoEnv def initialize - @env=SiSU_Env::Info_env.new + @env=SiSU_Env::InfoEnv.new end def webrick @env.url.webrick_port end end - class Info_program < Info_env #revisit + class InfoProgram < InfoEnv #revisit attr_accessor :editor,:wc,:tidy,:rexml,:pdflatex,:postgresql,:sqlite def initialize - prog=SiSU_Env::Info_env.new.program + prog=SiSU_Env::InfoEnv.new.program @editor,@wc,@tidy,@rexml,@pdflatex,@postgresql,@sqlite=prog.text_editor,prog.wc,prog.tidy,prog.rexml,prog.pdflatex,prog.postgresql,prog.sqlite end end - class Info_skin + class InfoSkin def initialize(md=nil,skin=nil) @md=md @d_sk=if skin.class==String ; skin @@ -4970,7 +5532,7 @@ WOK @home,@pwd=ENV['HOME'],ENV['PWD'] m=/.+\/(?:src\/)?(\S+)/m # m=/.+?\/(?:src\/)?([^\/]+)$/im # m=/.+\/(\S+)/m @pwd_stub=@pwd[m,1] - @env=SiSU_Env::Info_env.new + @env=SiSU_Env::InfoEnv.new end def select # skin loading logic here load "#{SiSU_lib}/defaults.rb" @@ -5016,7 +5578,7 @@ WOK end end end - class CSS_default + class CSS_Default def html 'html.css' end @@ -5042,10 +5604,10 @@ WOK 'harvest.css' end end - class CSS_select < Info_env + class CSS_Select < InfoEnv def initialize(md) @md=md - @env=SiSU_Env::Info_env.new + @env=SiSU_Env::InfoEnv.new('',@md) end def html css=if @md.doc_css \ @@ -5053,7 +5615,7 @@ WOK "#{@md.doc_css}_html.css" elsif FileTest.file?("#{@env.path.output}/#{@env.path.style}/#{@env.path.stub_pwd}_html.css") "#{@env.path.stub_pwd}_html.css" - else CSS_default.new.html + else SiSU_Env::CSS_Default.new.html end end def html_tables @@ -5062,7 +5624,7 @@ WOK "#{@md.doc_css}_html_tables.css" elsif FileTest.file?("#{@env.path.output}/#{@env.path.style}/#{@env.path.stub_pwd}_html_tables.css") "#{@env.path.stub_pwd}_html_tables.css" - else CSS_default.new.html_tables + else SiSU_Env::CSS_Default.new.html_tables end end def xhtml @@ -5071,7 +5633,7 @@ WOK "#{@md.doc_css}_xhtml.css" elsif FileTest.file?("#{@env.path.output}/#{@env.path.style}/#{@env.path.stub_pwd}_xhtml.css") "#{@env.path.stub_pwd}_xhtml.css" - else CSS_default.new.xhtml + else SiSU_Env::CSS_Default.new.xhtml end end def xml_sax @@ -5080,7 +5642,7 @@ WOK "#{@md.doc_css}_xml_sax.css" elsif FileTest.file?("#{@env.path.output}/#{@env.path.style}/#{@env.path.stub_pwd}_xml_sax.css") "#{@env.path.stub_pwd}_xml_sax.css" - else CSS_default.new.xml_sax + else SiSU_Env::CSS_Default.new.xml_sax end end def xml_dom @@ -5089,7 +5651,7 @@ WOK "#{@md.doc_css}_xml_dom.css" elsif FileTest.file?("#{@env.path.output}/#{@env.path.style}/#{@env.path.stub_pwd}_xml_dom.css") "#{@env.path.stub_pwd}_xml_dom.css" - else CSS_default.new.xml_dom + else SiSU_Env::CSS_Default.new.xml_dom end end def docbook_xml @@ -5098,7 +5660,7 @@ WOK "#{@md.doc_css}_xml_dom.css" elsif FileTest.file?("#{@env.path.output}/#{@env.path.style}/#{@env.path.stub_pwd}_docbook.css") "#{@env.path.stub_pwd}_docbook.css" - else CSS_default.new.docbook_xml + else SiSU_Env::CSS_Default.new.docbook_xml end end def homepage @@ -5107,16 +5669,16 @@ WOK "#{@md.doc_css}_homepage.css" elsif FileTest.file?("#{@env.path.output}/#{@env.path.style}/#{@env.path.stub_pwd}_homepage.css") "#{@env.path.stub_pwd}_homepage.css" - else CSS_default.new.homepage + else SiSU_Env::CSS_Default.new.homepage end end end - class CSS_stylesheet + class CSS_Stylesheet def initialize(md) @md=md - @css=CSS_select.new(@md) - @env=SiSU_Env::Info_env.new - @file=SiSU_Env::SiSU_file.new(@md) + @css=SiSU_Env::CSS_Select.new(@md) + @env=SiSU_Env::InfoEnv.new('',@md) + @file=SiSU_Env::FileOp.new(@md) end def html %{ <link rel="stylesheet" href="#{@file.path_rel_links.html_scroll_css}#{@env.path.style}/#{@css.html}" type="text/css" />} @@ -5143,15 +5705,15 @@ WOK %{<?xml-stylesheet type="text/css" href="#{@file.path_rel_links.xml_css}#{@env.path.style}/#{@css.xml_dom}"?>} end end - class Create_site < Info_env + class CreateSite < InfoEnv require_relative 'css' # css.rb include SiSU_Style def initialize(cmd) @cmd=cmd - @env=SiSU_Env::Info_env.new + @env=SiSU_Env::InfoEnv.new @home,@pwd=ENV['HOME'],ENV['PWD'] #@pwd=Dir.pwd - @rc=Get_init.instance.sisu_yaml.rc - @vz=SiSU_Env::Get_init.instance.skin + @rc=GetInit.instance.sisu_yaml.rc + @vz=SiSU_Env::GetInit.instance.skin @vz_home=SiSU_Viz::Home.new end def homepage @@ -5203,7 +5765,7 @@ WOK def cp_external_images src="#{@env.processing_path.processing}/external_document/image" dest="#{@env.path.webserv}/#{@env.path.stub_pwd}/_sisu/image_external" - if FileTest.directory?(src) + if FileTest.directory?(src) cp_images(src,dest) end end @@ -5240,7 +5802,7 @@ WOK end else SiSU_Screen::Ansi.new(@cmd,"modify css is not set or is set to: false").warn if @cmd=~/[MV]/ end - fn_css=SiSU_Env::CSS_default.new + fn_css=SiSU_Env::CSS_Default.new css=SiSU_Style::CSS.new path_style="#{@env.path.output}/#{@env.path.style}" FileUtils::mkdir_p(path_style) unless FileTest.directory?(path_style) diff --git a/lib/sisu/v3/termsheet.rb b/lib/sisu/v3/termsheet.rb index aca9e00e..3ac2515b 100644 --- a/lib/sisu/v3/termsheet.rb +++ b/lib/sisu/v3/termsheet.rb @@ -70,7 +70,7 @@ def talent(termsheet,flag) no_ocn='0' if flag =~/0/ #flag to request switch off of text object numbering @@info=nil @@info=termsheet.gsub(/(.+?)\.termsheet\.rb/,'../facility_data/\1.html') - @env=SiSU_Env::Info_env.new + @env=SiSU_Env::InfoEnv.new @dir_fd="#{@env.path.output}/facility_data" FileUtils::mkdir_p(@dir_fd) unless FileTest.directory?(@dir_fd)==true html_output=[] @@ -130,7 +130,7 @@ if @proc =~ /^-?[wft]/ talent(termsheet,@proc) end end -@env=SiSU_Env::Info_env.new +@env=SiSU_Env::InfoEnv.new @dir_fd="#{@env.path.output}/facility_data" @url="#{@env.url.webserv}/facility_data" @@report << %{\n#{@@cX.grey}See#{@@cX.off}: #{@@cX.blue}#{@dir_fd}/all.txt\t#{@dir_fd}/toc.html\t#{@dir_fd}/#{@@cX.off}\n\n#{@@cX.grey}See#{@@cX.off}: #{@@cX.blue}#{@url}/all.txt\t#{@url}/toc.html\t#{@url}/#{@@cX.off}\n\n} diff --git a/lib/sisu/v3/texinfo.rb b/lib/sisu/v3/texinfo.rb index 90810120..2496ce7a 100644 --- a/lib/sisu/v3/texinfo.rb +++ b/lib/sisu/v3/texinfo.rb @@ -63,7 +63,7 @@ module SiSU_TexInfo include SiSU_Viz #include Stamp ... needed removed arbitrarily 2005w05/1 (warnings about undefined flags) require_relative 'texinfo_format' # texinfo_format.rb - include SiSU_Texinfo_format + include SiSU_TexInfoFormat @tex_file=[] @@tabular="{tabular}" @@table_pagebreak_counter,@@tex_endnote_call_counter,@@tex_table_flag,@@tex_counter,@@tex_column,@@tex_columns,@@counting=0,0,0,0,0,0,0 @@ -78,8 +78,8 @@ module SiSU_TexInfo def initialize(opt) @opt=opt @md=SiSU_Param::Parameters.new(@opt).get - @env=SiSU_Env::Info_env.new(@opt.fns) - @vz=SiSU_Env::Get_init.instance.skin + @env=SiSU_Env::InfoEnv.new(@opt.fns) + @vz=SiSU_Env::GetInit.instance.skin end def directories begin @@ -107,7 +107,7 @@ module SiSU_TexInfo tell @md=SiSU_Param::Parameters.new(@opt).get directories - @marshalfile=SiSU_Env::Info_file.new(@opt.fns).marshal.dal_content + @marshalfile=SiSU_Env::InfoFile.new(@opt.fns).marshal.dal_content if FileTest.file?(@marshalfile)==true File.open(@marshalfile) { |f| @@tuned_file=Marshal.load(f)} #tell.meta_verse_skipped if @opt.cmd =~/[vVM]/ @@ -116,84 +116,88 @@ module SiSU_TexInfo SiSU_Metaverse.songsheet(tex_array) end tex_array=@@tuned_file - Texinfo_make.new(@md,tex_array).songsheet + TeXinfoMake.new(@md,tex_array).songsheet tex_array='' rescue; STDERR.puts SiSU_Screen::Ansi.new(@opt.cmd,$!,$@).rescue ensure end end end - class Texinfo_make + class TeXinfoMake include SiSU_Param - include SiSU_Texinfo_format + include SiSU_TexInfoFormat @@tex_1='(?:.+?)+~' #?? debug @@tabular="{tabular}" @@tex_pattern_margin_number="\\\\marginpar.+?\s+" def initialize(md,data) @md,@data=md,data - @env=SiSU_Env::Info_env.new(@md.fns) - @vz=SiSU_Env::Get_init.instance.skin - @f=SiSU_Env::SiSU_file.new(@md) + @env=SiSU_Env::InfoEnv.new(@md.fns) + @vz=SiSU_Env::GetInit.instance.skin + @f=SiSU_Env::FileOp.new(@md) end def songsheet begin - @data=pre - @data=endnote - @data=markup - @data=tail - output + data=@data + data=pre(data) + data=endnote(data) + data,head=markup(data) + objs_txt=tail(data) + doc_txt=[head,objs_txt] + output(doc_txt) makeinfo #KEEP reinstate when fixed #% place_info rescue; STDERR.puts SiSU_Screen::Ansi.new(@md.opt.cmd,$!,$@).rescue ensure end end - def pre - data=@data + def pre(data) + data_new=[] data.each do |dob| # DEBUG 2003w16 this is a kludge, because i could not get parameters # from param, Sort out ... revert to more elegant solution if dob.is =='table' @@flag['tables']='y' # KLUDGE get from param end - dob.obj.gsub!(/<:p[bn]>/,'') - dob.obj.gsub!(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,'\1(\2 [linked to:] \3)') - dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s)\{(.+?)\}((?:https?|file):\/\/\S+)/,'\1(\2 [linked to:] \3)') - do_mono=SiSU_Texinfo_format::Texinfo.new(@md,dob) + dob.obj=dob.obj.gsub(/<:p[bn]>/,''). + gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,'\1(\2 [linked to:] \3)'). + gsub(/(^|#{Mx[:gl_c]}|\s)\{(.+?)\}((?:https?|file):\/\/\S+)/,'\1(\2 [linked to:] \3)') + do_mono=SiSU_TexInfoFormat::Texinfo.new(@md,dob) dob.obj=do_mono.spec_char(dob.obj) + data_new << dob end - data + data_new end - def endnote - data=@data + def endnote(data) + data_new=[] data.each do |dob| - if dob.of=~/para|block/ - dob.obj.gsub!(/\s*#{Mx[:en_a_o]}(?:\d+)\s+(.+?)#{Mx[:en_a_c]}/m,' @footnote{ \1} ') - dob.obj.gsub!(/\s*#{Mx[:en_a_o]}(\*+)\s+(.+?)#{Mx[:en_a_c]}/m,' @footnote{ \1} ') + if dob.of==:para \ + || dob.of==:block + dob.obj=dob.obj.gsub(/\s*#{Mx[:en_a_o]}(?:\d+)\s+(.+?)#{Mx[:en_a_c]}/m,' @footnote{ \1} '). + gsub(/\s*#{Mx[:en_a_o]}(\*+)\s+(.+?)#{Mx[:en_a_c]}/m,' @footnote{ \1} ') end - dob + data_new << dob end - data + data_new end def poem - data=@data + data,data_new=@data,[] @tex_file=[] @@counting=0 data.each do |dob| - if dob.is =='code' + if dob.is ==:code @@flag['code']=true @@counting=1 end - if dob.is =='verse' + if dob.is ==:verse @@flag['poem']=1 end if @@flag['code'] if @@flag['code'] \ - and dob.obj =~ /#{Mx[:gr_o]}code[-_](?:end|close)#{Mx[:gr_c]}/ #watch change not tested 200501 #fix + && (dob.obj =~ /#{Mx[:gr_o]}code[-_](?:end|close)#{Mx[:gr_c]}/) #watch change not tested 200501 #fix @@flag['code']=false end if @@flag['code'] \ - and dob.obj =~ /\S/ + && (dob.obj =~ /\S/) sub_array=dob.obj.dup @@line_mode=sub_array.scan(/.+/) Tune.code_lines(@@line_mode) @@ -201,11 +205,11 @@ module SiSU_TexInfo end elsif @@flag['poem']==1 if @@flag['poem']==1 \ - and dob.obj =~ /#{Mx[:gr_o]}verse[-_](?:end|close)#{Mx[:gr_c]}/ #watch change not tested 200501 #fix + && (dob.obj =~ /#{Mx[:gr_o]}verse[-_](?:end|close)#{Mx[:gr_c]}/) #watch change not tested 200501 #fix @@flag['poem']=0 end if @@flag['poem']==1 \ - and dob.obj =~ /\S/ + && (dob.obj =~ /\S/) sub_array=dob.obj.dup @@line_mode=sub_array.scan(/.+/) Tune.code_lines(@@line_mode) @@ -213,53 +217,58 @@ module SiSU_TexInfo end end @tex_file << dob.obj + data_new << dob end + data_new end def code_lines - data=@data + data,data_new=@data,[] data.each do |line| - if line =~ /\S/ \ - and line !~ /#{Mx[:gr_o]}(code|verse).+/ #fix - if @@flag['code'] - line.gsub!(/^\s*(.+)/m,"\\noindent \\marginpar\[left-text\]{\\begin{tiny}#{@@counting}\\end{tiny}}\\1\\") + if (line =~ /\S/) \ + && (line !~ /#{Mx[:gr_o]}(code|verse).+/) #fix + line=if @@flag['code'] + line.gsub(/^\s*(.+)/m,"\\noindent \\marginpar\[left-text\]{\\begin{tiny}#{@@counting}\\end{tiny}}\\1\\") @@counting+=1 if @@flag['code'] - else line.gsub!(/(.+)/m,'\noindent\1') + else line.gsub(/(.+)/m,'\noindent\1') end end + data_new << line end end def tables - data=@data + data,data_new=@data,[] @tex_file=[] @@tableheader=0 data.each do |dob| if dob.obj =~ /#{Mx[:tc_p]}|#{Mx[:gr_o]}T/ui #fix - do_mono=SiSU_Texinfo_format::Texinfo.new(@md,dob) + do_mono=SiSU_TexInfoFormat::Texinfo.new(@md,dob) dob.obj=do_mono.longtable # using longtable latex package end @tex_file << dob.obj + data_new << dob end + data_new end - def markup - data=@data + def markup(data) + data_new=[] @tex_file=[] @row_break='\\\\\\' @break_page="#{@row_break}\n#{@row_break} \n" md={} - @tex_file << SiSU_Texinfo_format::Texinfo.new(@md).head - mono=SiSU_Texinfo_format::Texinfo.new(@md) + @tex_file << SiSU_TexInfoFormat::Texinfo.new(@md).head + mono=SiSU_TexInfoFormat::Texinfo.new(@md) @tex_file << mono.topnode(@md.title.full) texinfo_menu=[] n_menu,n_submenu=0,0 @submenu,@subsubmenu={},{} data.each do |dob| - if dob.is =='heading' \ - and dob.ln.to_s =~ /^[1-3]$/ - toc=SiSU_Texinfo_format::Texinfo.new(@md,dob) + if dob.is ==:heading \ + && (dob.ln.to_s =~ /^[1-3]$/) + toc=SiSU_TexInfoFormat::Texinfo.new(@md,dob) texinfo_menu << toc.menu - elsif dob.is =='heading' \ - and dob.ln.to_s =~ /^[4-6]$/ - toc=SiSU_Texinfo_format::Texinfo.new(@md,dob) + elsif dob.is ==:heading \ + && (dob.ln.to_s =~ /^[4-6]$/) + toc=SiSU_TexInfoFormat::Texinfo.new(@md,dob) texinfo_menu << toc.menu case dob.ln when 4 @@ -275,10 +284,12 @@ module SiSU_TexInfo @subsubmenu[n_submenu] << toc.menu end else - dob.obj.gsub!(/\s*(?:<:?br>|<br \/>)\s*/,"\n\n") + dob.obj=dob.obj.gsub(/\s*(?:<:?br>|<br \/>)\s*/,"\n\n") end + data_new << dob end - texinfo_menu.compact! + data=data_new + texinfo_menu=texinfo_menu.compact texinfo_menu << "* Dublin Core::" @tex_file << texinfo_menu @tex_file << "* Index::\n" + @@ -286,85 +297,91 @@ module SiSU_TexInfo "@c %% 5\n\n" n_menu,n_submenu=0,0 @@do_submenu,@@do_subsubmenu=1,1 + data_new=[] data.each do |dob| - mono=SiSU_Texinfo_format::Texinfo.new(@md,dob) - if dob.is=='heading' + mono=SiSU_TexInfoFormat::Texinfo.new(@md,dob) + if dob.is==:heading case dob.ln - when 1; mono.level1 - when 2; mono.level2 - when 3; mono.level3 + when 1; dob=mono.level1 + when 2; dob=mono.level2 + when 3; dob=mono.level3 when 4; - mono.level4 + dob=mono.level4 n_menu+=1 @@do_submenu,@@do_subsubmenu=1,1 when 5; n_submenu+=1 @@do_subsubmenu=1 if @@do_submenu==1 - menu=SiSU_Texinfo_format::Texinfo_txt.new(@md,dob,@submenu[n_menu]) + menu=SiSU_TexInfoFormat::TeXinfoTxt.new(@md,dob,@submenu[n_menu]) dob.obj="#{menu.submenu}#{mono.level5.obj}" @@do_submenu=0 - else mono.level5 + else dob=mono.level5 end when 6; if @@do_submenu==1 - menu=SiSU_Texinfo_format::Texinfo_txt.new(@md,dob,@submenu[n_menu]) + menu=SiSU_TexInfoFormat::TeXinfoTxt.new(@md,dob,@submenu[n_menu]) dob.obj="#{menu.subsubmenu}#{mono.level6.obj}" @@do_subsubmenu=0 else - mono.level6 + dob=mono.level6 end end else if dob.obj !~/\S/ dob.obj=nil else - if dob.is=='para' \ - and dob.obj !~/##{dob.ocn}/ + if dob.is==:para \ + && (dob.obj !~/##{dob.ocn}/) dob.obj="#{dob.obj} ##{dob.ocn}" end end end #%case with endnotes - dob.obj.gsub!(/\s*[0-8]\\+(\S+)?\s+/,' ') if dob.obj - @tex_file << dob.obj if dob.obj and dob.is !~/structure|comment/ #sort exceptions + dob.obj=dob.obj.gsub(/\s*[0-8]\\+(\S+)?\s+/,' ') if dob.obj + data_new << dob end - data=@tex_file + [data_new, @tex_file] end def number_titles - data=@data + data,data_new=@data,[] @tex_file=[] input=%{#{@md.markup}}[/(num_top\s*=\s*(\d?))?/m,2] # else default usually 4 # this was a bit of a trick required to pass nil to input if nothing matched... #puts input num_top=input.to_i t_no1=0; t_no2=0; t_no3=0; t_no4=0; no1=num_top; no2=(num_top + 1); no3=(num_top + 2); no4=(num_top + 3); data.each do |dob| - if @md.markup =~ /num_top/i \ - and dob.obj !~ /#{Rx[:meta]}/ - if dob.obj =~ /^[1-6]\\+(?:~\S+)?\s*<!h-.+?-!>/ \ - and dob.obj !~ /<:\d-endnotes>/ - header=dob.obj[/<!h-(.+?)-!>/m, 1].gsub!(/-/m,'.') - dob.obj.gsub!(/^(?:[1-6]\\+(?:~\S+)|<:([12356]|4-.+?-)>)\s*<!h-.+?-!>/, + if (@md.markup =~ /num_top/i) \ + && (dob.obj !~ /#{Rx[:meta]}/) + if (dob.obj =~ /^[1-6]\\+(?:~\S+)?\s*<!h-.+?-!>/) \ + && (dob.obj !~ /<:\d-endnotes>/) + header=dob.obj[/<!h-(.+?)-!>/m, 1].gsub(/-/m,'.') + dob.obj=dob.obj.gsub(/^(?:[1-6]\\+(?:~\S+)|<:([12356]|4-.+?-)>)\s*<!h-.+?-!>/, "\\1 #{header} ") end elsif dob.obj=~ /<!h!>|<!h\d!>|<!h.+?!>|<!!h.+?!>/ if dob.obj=~ /<!h-.+?-!>/ - dob.obj.gsub!(/<!h-(.+?)-!>/,'\1 ') + dob.obj=dob.obj.gsub(/<!h-(.+?)-!>/,'\1 ') end end @tex_file << dob.obj end - data=@tex_file + data_new << dob end - def tail - data=@data - tex=SiSU_Texinfo_format::Texinfo.new(@md) - data << tex.dublincore - data << tex.tail + def tail(data) + tex=SiSU_TexInfoFormat::Texinfo.new(@md) + objs_txt=[] + data.each do |dob| + if dob.obj \ + && (dob.is !=:structure \ + && dob.is !=:comment) + objs_txt << dob.obj if dob.obj + end + end + objs_txt << tex.dublincore << tex.tail + objs_txt end - def output - data=@data - data.compact! + def output(data) filename_texinfo=%{#{@env.processing_path.texi}/#{@md.fnb}.texinfo} file_texinfo=File.new(filename_texinfo,'w+') puts filename_texinfo if @md.opt.cmd =~/M/ @@ -378,9 +395,9 @@ module SiSU_TexInfo pwd=Dir.pwd case sfx when /(?:-|ssm\.)?sst$/ - @env=SiSU_Env::Info_env.new(@md.fns,@md.opt.cmd) + @env=SiSU_Env::InfoEnv.new(@md.fns,@md.opt.cmd) Dir.chdir(@env.processing_path.texi) - texinfo=SiSU_Env::System_call.new("#{fnb}.texinfo") + texinfo=SiSU_Env::SystemCall.new("#{fnb}.texinfo") texinfo.makeinfo end Dir.chdir(pwd) diff --git a/lib/sisu/v3/texinfo_format.rb b/lib/sisu/v3/texinfo_format.rb index df9d2800..fa5390b6 100644 --- a/lib/sisu/v3/texinfo_format.rb +++ b/lib/sisu/v3/texinfo_format.rb @@ -56,7 +56,7 @@ ** Description: texinfo formatting template =end -module SiSU_Texinfo_format +module SiSU_TexInfoFormat @@table_pg_break_counter=1 require_relative 'param' # param.rb include SiSU_Param @@ -74,31 +74,30 @@ module SiSU_Texinfo_format p dob.class p caller end - @vz=SiSU_Env::Get_init.instance.skin + @vz=SiSU_Env::GetInit.instance.skin end def head t=Time.now year=t.year filename=%{#{@md.fns}}[/(.+?)\.\w\w\d\d$/,1] title=spec_char(@md.title.full) - title=title.gsub(/<(br|p|i)>|<\/\s*(br|p|i)>|<(br|p)\s*\/>/," #{Tex[:backslash]*2} ") - title.gsub!(/\$/,"\\$") - title.gsub!(/[,]\s*/,' - ') + title=title.gsub(/<(br|p|i)>|<\/\s*(br|p|i)>|<(br|p)\s*\/>/," #{Tex[:backslash]*2} "). + gsub(/\$/,"\\$"). + gsub(/[,]\s*/,' - ') if @md.title.sub subtitle=spec_char(@md.title.sub) - subtitle=subtitle.gsub(/<(br|p|i)>|<\/\s*(br|p|i)>|<(br|p)\s*\/>/," #{Tex[:backslash]*2} ") - subtitle.gsub!(/\$/,"\\$") - subtitle.gsub!(/[,]\s*/,' - ') + subtitle=subtitle.gsub(/<(br|p|i)>|<\/\s*(br|p|i)>|<(br|p)\s*\/>/," #{Tex[:backslash]*2} "). + gsub(/\$/,"\\$"). + gsub(/[,]\s*/,' - ') subtitle="@subtitle @value{VERSION}, @value{UPDATED}\n" #bugwatch end subtitle ||='' author=@md.author if @md.author author ||='' - author.gsub!(/[\*]/,'') #if author - v=SiSU_Env::Info_version.instance.get_version + author=author.gsub(/[\*]/,'') #if author + v=SiSU_Env::InfoVersion.instance.get_version head =<<WOK \\input texinfo @c -*-texinfo-*- -@comment $Id$ @comment %**start of header @setfilename #{@md.fnb}.info @settitle #{title} @value{VERSION} @@ -151,9 +150,9 @@ WOK end def topnode(txt) txt=spec_char(txt) - txt=txt.gsub(/<(br|p|i)>|<\/\s*(br|p|i)>|<(br|p)\s*\/>/," #{Tex[:backslash]*2} ") - txt.gsub!(/\$/,"\\$") - txt.gsub!(/[,]\s*/,' - ') + txt=txt.gsub(/<(br|p|i)>|<\/\s*(br|p|i)>|<(br|p)\s*\/>/," #{Tex[:backslash]*2} "). + gsub(/\$/,"\\$"). + gsub(/[,]\s*/,' - ') "@c %% 4\n" + "@ifnottex\n" + "@node Top\n" + @@ -262,165 +261,154 @@ WOK relation="Relation: #{relation}\n\n" if relation #dc coverage="Coverage: #{coverage}\n\n" if coverage #dc rights="Rights: #{rights}\n\n" if rights #dc - "@node Dublin Core\n" + - "@unnumbered Dublin Core\n" + - "@cindex chapter, Dublin Core\n\n" + - "#{full_title}" + - "#{author}" + - "#{subject}" + - "#{description}" + - "#{publisher}" + - "#{contributor}" + - "#{date}" + - "#{date_created}" + - "#{date_issued}" + - "#{date_available}" + - "#{date_valid}" + - "#{date_modified}" + - "#{format}" + - "#{identifier}" + - "#{source}" + - "#{language}" + - "#{relation}" + - "#{coverage}" + - "#{rights}" + - "\n\n" + <<WOK +@node Dublin Core +@unnumbered Dublin Core +@cindex chapter, Dublin Core + +#{full_title}#{author}#{subject}#{description}#{publisher}#{contributor}#{date}#{date_created}#{date_issued}#{date_available}#{date_valid}#{date_modified}#{format}#{identifier}#{source}#{language}#{relation}#{coverage}#{rights} + +WOK end def tail - "@c %% 6\n" + - "@node Index\n" + - "@unnumbered Index\n" + - "@printindex cp\n\n" + - "@bye" + <<WOK +@c %% 6 +@node Index +@unnumbered Index +@printindex cp + +@bye +WOK end def clean(dob) - if dob.is=='heading' \ + if dob.is==:heading \ and dob.obj !~/##{dob.ocn}/ dob.obj="#{dob.obj} ##{dob.ocn}" end - dob.obj.gsub!(/<:#>/,'') - dob.obj.strip! + dob.obj=dob.obj.gsub(/\n/m,' '). + gsub(/<:#>/,''). + gsub(/,\s+/,' - '). + strip dob end def menu dob=clean(@dob) m=dob.obj - m.gsub!(/[:,]\s*/,' - ') - m.gsub!(/@footnote\{.+?\}\s+/,'') + m=m.gsub(/[:,]\s*/,' - '). + gsub(/@footnote\{.+?\}\s+/,'') m="* #{m}::" end def level1 dob=clean(@dob) nd=dob.obj.gsub(/@footnote\{.+?\}\s+/,'') - dob.obj="@node #{nd}\n@unnumbered #{dob.obj}\n@cindex chapter, #{nd}\n" + dob.obj="@node #{nd}\n@unnumbered #{nd}\n@cindex chapter, #{nd}\n" dob end def level2 dob=clean(@dob) nd=dob.obj.gsub(/@footnote\{.+?\}\s+/,'') - dob.obj="@node #{nd}\n@unnumbered #{dob.obj}\n@cindex chapter, #{nd}\n" + dob.obj="@node #{nd}\n@unnumbered #{nd}\n@cindex chapter, #{nd}\n" dob end def level3 dob=clean(@dob) nd=dob.obj.gsub(/@footnote\{.+?\}\s+/,'') - dob.obj="@node #{nd}\n@unnumbered #{dob.obj}\n@cindex chapter, #{nd}\n" + dob.obj="@node #{nd}\n@unnumbered #{nd}\n@cindex chapter, #{nd}\n" dob end def level4 dob=clean(@dob) nd=dob.obj.gsub(/@footnote\{.+?\}\s+/,'') - dob.obj="@node #{nd}\n@unnumbered #{dob.obj}\n@cindex chapter, #{nd}\n" + dob.obj="@node #{nd}\n@unnumbered #{nd}\n@cindex chapter, #{nd}\n" dob end def level5 dob=clean(@dob) nd=dob.obj.gsub(/@footnote\{.+?\}\s+/,'') - dob.obj="@node #{nd}\n@unnumbered #{dob.obj}\n@cindex chapter, #{nd}\n" + dob.obj="@node #{nd}\n@unnumbered #{nd}\n@cindex chapter, #{nd}\n" dob end def level6 dob=clean(@dob) nd=dob.obj.gsub(/@footnote\{.+?\}\s+/,'') - dob.obj="@node #{nd}\n@unnumbered #{dob.obj}\n@cindex chapter, #{nd}\n" + dob.obj="@node #{nd}\n@unnumbered #{nd}\n@cindex chapter, #{nd}\n" dob end def submenu @dob.obj=@dob.obj.join("\n") - @dob.obj.gsub!(/[5]\\+~\S+/,'') + @dob.obj=@dob.obj.gsub(/[5]\\+~\S+/,'') dob=clean(@dob) - dob.obj="@menu\n#{dob.obj}\n@end menu\n\n" - dob.obj.gsub!(/.+/m,"#{dob.obj}") + dob.obj="@menu\n#{dob.obj}\n@end menu\n\n". + gsub(/.+/m,"#{dob.obj}") end def subsubmenu @dob.obj=@dob.obj.join("\n") - @dob.obj.gsub!(/[6]\\+~\S+/,'') + @dob.obj=@dob.obj.gsub(/[6]\\+~\S+/,'') dob=clean(@dob) - dob.obj="@menu\n#{dob.obj}\n@end menu\n\n" - dob.obj.gsub!(/.+/m,"#{dob.obj}") + dob.obj="@menu\n#{dob.obj}\n@end menu\n\n". + gsub(/.+/m,"#{dob.obj}") end def indent1 - @dob.obj.gsub!(/<:i1>(.*)/,'\1') + @dob.obj=@dob.obj.gsub(/<:i1>(.*)/,'\1') end def indent2 - @dob.obj.gsub!(/<:i2>(.*)/,'\1') + @dob.obj=@dob.obj.gsub(/<:i2>(.*)/,'\1') end def spec_char(txt) # special characters - txt.gsub!(/#{Mx[:br_eof]}/i,'') - txt.gsub!(/#{Mx[:gl_o]}#169#{Mx[:gl_c]}/,'(c)') - txt.gsub!(/#{Mx[:gl_o]}#(?:lt|060)#{Mx[:gl_c]}/,'<'); txt.gsub!(/#{Mx[:gl_o]}(gt|#062)#{Mx[:gl_c]}/,'>') - txt.gsub!(/#{Mx[:gl_o]}#123#{Mx[:gl_c]}/,'{'); txt.gsub!(/#{Mx[:gl_o]}#125#{Mx[:gl_c]}/,'}') - txt.gsub!(/#{Mx[:gl_o]}#(?:126|152)#{Mx[:gl_c]}/i,'~') - txt.gsub!(/#{Mx[:gl_o]}#033#{Mx[:gl_c]}/,'!') - txt.gsub!(/#{Mx[:gl_o]}#035#{Mx[:gl_c]}/,'#') - txt.gsub!(/#{Mx[:gl_o]}#042#{Mx[:gl_c]}/,'*') - txt.gsub!(/#{Mx[:gl_o]}#047#{Mx[:gl_c]}/,'/') - txt.gsub!(/#{Mx[:gl_o]}#095#{Mx[:gl_c]}/,'_') - txt.gsub!(/#{Mx[:gl_o]}#092#{Mx[:gl_c]}/,'\\') - txt.gsub!(/(?:#{Mx[:br_line]}|#{Mx[:br_nl]})\s*/,"\n\n") # watch - txt.gsub!(/<sup><font face=symbol>&atild;<\/font><\/sup>/,' ') - #txt.gsub!(/\\/,'\\backslash ') - txt.gsub!(/<:pb>/,'\\newpage') - txt.gsub!(/\\backslash copyright/,'\\copyright ') - txt.gsub!(/\^/,'\\wedge ') - txt.gsub!(/(\$)/,"\\$") - txt.gsub!(/\~/,'\\~') - txt.gsub!(/#{Mx[:url_o]}(https?:\S+?)#{Mx[:url_c]}/,'<\1>') - txt.gsub!(/#{Mx[:url_o]}_(https?:\S+?)#{Mx[:url_c]}/,'\1') - txt.gsub!(/§/i,'\S') - txt.gsub!(/£/i,'\pounds') - txt.gsub!(/å/,'\aa'); txt.gsub!(/Å/,'\AA') - txt.gsub!(/æ/,'\ae'); txt.gsub!(/Æ/,'\AE') - txt.gsub!(/ø/,'\o'); txt.gsub!(/Ø/,'\O') - txt.gsub!(/<a href=".+?">/i,' ') - txt.gsub!(/<\/a>/i,' ') - txt.gsub!(/<!>/i,' ') - txt.gsub!(/#{Mx[:br_paragrph]}/i,'') #watch - txt.gsub!(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'*\1*') - txt.gsub!(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'/\1/') - txt.gsub!(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'_\1_') - txt.gsub!(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,'[\1]') - txt.gsub!(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,'^\1^') - txt.gsub!(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'+\1+') - txt.gsub!(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'"\1"') - txt.gsub!(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'-\1-') - txt.gsub!(/@/i,'@@') - txt.gsub!(/\{/,'@{'); txt.gsub!(/\}/,'@}') - txt.gsub!(/(?: |#{Mx[:nbsp]})+/,' ') # ~ character for hardspace - txt.gsub!(/&(\S+?);/,' ') - txt.gsub!(/&/,'<=and>') - txt.gsub!(/(\s+&\s+)/,' and ') - txt.gsub!(/(\&)/,"\\&") - txt.gsub!(/"(.+?)"/,"`\\1'") # open & close " - txt.gsub!(/\s+"/," `") # open " - txt.gsub!(/^([1-6-]\\+(?:~\S+)?|<.+?>)?\s*"/,'\1`') # open " - txt.gsub!(/"(\s|\.|,|:|;)/,"'\\1") # close " - txt.gsub!(/"([1-6-]\\+(?:~\S+)?|<.+?>)?\s*$/,"'\\1") # close " - txt.gsub!(/"(\.|,)/,"'") # close " - txt.gsub!(/\s+'/," `") # open ' - txt.gsub!(/^([1-6-]\\+(?:~\S+)?|<.+?>)?\s*'/,'\1`') # open ' - txt.gsub!(/(<font.*?>|<\/font>)/,'') - txt + txt=txt.gsub(/#{Mx[:br_eof]}/i,''). + gsub(/#{Mx[:gl_o]}#169#{Mx[:gl_c]}/,'(c)'). + gsub(/#{Mx[:gl_o]}#(?:lt|060)#{Mx[:gl_c]}/,'<').gsub(/#{Mx[:gl_o]}(gt|#062)#{Mx[:gl_c]}/,'>'). + gsub(/#{Mx[:gl_o]}#123#{Mx[:gl_c]}/,'{').gsub(/#{Mx[:gl_o]}#125#{Mx[:gl_c]}/,'}'). + gsub(/#{Mx[:gl_o]}#(?:126|152)#{Mx[:gl_c]}/i,'~'). + gsub(/#{Mx[:gl_o]}#033#{Mx[:gl_c]}/,'!'). + gsub(/#{Mx[:gl_o]}#035#{Mx[:gl_c]}/,'#'). + gsub(/#{Mx[:gl_o]}#042#{Mx[:gl_c]}/,'*'). + gsub(/#{Mx[:gl_o]}#047#{Mx[:gl_c]}/,'/'). + gsub(/#{Mx[:gl_o]}#095#{Mx[:gl_c]}/,'_'). + gsub(/#{Mx[:gl_o]}#092#{Mx[:gl_c]}/,'\\'). + gsub(/(?:#{Mx[:br_line]}|#{Mx[:br_nl]})\s*/,"\n\n"). # watch + gsub(/<sup><font face=symbol>&atild;<\/font><\/sup>/,' '). + #gsub(/\\/,'\\backslash '). + gsub(/<:pb>/,'\\newpage'). + gsub(/\\backslash copyright/,'\\copyright '). + gsub(/\^/,'\\wedge '). + gsub(/(\$)/,"\\$"). + gsub(/\~/,'\\~'). + gsub(/#{Mx[:url_o]}(https?:\S+?)#{Mx[:url_c]}/,'<\1>'). + gsub(/#{Mx[:url_o]}_(https?:\S+?)#{Mx[:url_c]}/,'\1'). + gsub(/§/i,'\S'). + gsub(/£/i,'\pounds'). + gsub(/å/,'\aa').gsub(/Å/,'\AA'). + gsub(/æ/,'\ae').gsub(/Æ/,'\AE'). + gsub(/ø/,'\o').gsub(/Ø/,'\O'). + gsub(/<a href=".+?">/i,' '). + gsub(/<\/a>/i,' '). + gsub(/<!>/i,' '). + gsub(/#{Mx[:br_paragrph]}/i,''). #watch + gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'*\1*'). + gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'/\1/'). + gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'_\1_'). + gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,'[\1]'). + gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,'^\1^'). + gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'+\1+'). + gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'"\1"'). + gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'-\1-'). + gsub(/@/i,'@@'). + gsub(/\{/,'@{').gsub(/\}/,'@}'). + gsub(/(?: |#{Mx[:nbsp]})+/,' '). # ~ character for hardspace + gsub(/&(\S+?);/,' '). + gsub(/&/,'<=and>'). + gsub(/(\s+&\s+)/,' and '). + gsub(/(\&)/,"\\&"). + gsub(/"(.+?)"/,"`\\1'"). # open & close " + gsub(/\s+"/," `"). # open " + gsub(/^([1-6-]\\+(?:~\S+)?|<.+?>)?\s*"/,'\1`'). # open " + gsub(/"(\s|\.|,|:|;)/,"'\\1"). # close " + gsub(/"([1-6-]\\+(?:~\S+)?|<.+?>)?\s*$/,"'\\1"). # close " + gsub(/"(\.|,)/,"'"). # close " + gsub(/\s+'/," `"). # open ' + gsub(/^([1-6-]\\+(?:~\S+)?|<.+?>)?\s*'/,'\1`'). # open ' + gsub(/(<font.*?>|<\/font>)/,'') end def longtable @end_table="\\end{longtable}" @@ -440,28 +428,28 @@ WOK @colW=@colW.join @@start_table="\\setlength{\\LTleft}{0pt}\n\\setlength{\\LTright}{\\fill}\n" + "\\begin{longtable}[hb]#{@colW}\n" - @dob.obj.gsub!(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c\d+?;.+#{Mx[:gr_c]}/u,"#{@@start_table}") #fix + @dob.obj=@dob.obj.gsub(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c\d+?;.+#{Mx[:gr_c]}/u,"#{@@start_table}") #fix end if @dob =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/ #fix - @dob.obj.gsub!(/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/," #{@end_table}") #fix + @dob.obj=@dob.obj.gsub(/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/," #{@end_table}") #fix end - @dob.obj.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}/u,'') + @dob.obj=@dob.obj.gsub(/#{Mx[:tc_o]}#{Mx[:tc_p]}/u,'') if @@tableheader==1 if @dob =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u tablefoot=para[/\<!f(.+?)!\>/,1] - @dob.obj.gsub!(/\<!f(.+?)!\>/,'') - @dob.obj.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u, - "{\\begin{tiny} {\\bfseries \\1}\\end{tiny}}&") - @dob.obj.gsub!(/&>\s*$/, - " #{@row_break} \\hline\\endhead #{@row_break}") + @dob.obj=@dob.obj.gsub(/\<!f(.+?)!\>/,''). + gsub(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u, + "{\\begin{tiny} {\\bfseries \\1}\\end{tiny}}&"). + gsub(/&>\s*$/, + " #{@row_break} \\hline\\endhead #{@row_break}") @dob="#{@dob} \\multicolumn{#{@@number_of_cols}}{l}{\\tiny #{tablefoot}} \\\\ \\hline\n\\endfoot\n\\hline\n" if tablefoot @@tableheader=0 @@number_of_cols=0 end else if @dob =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u - @dob.obj.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u,"\\begin{tiny}\\1\\end{tiny}&") - @dob.obj.gsub!(/&>\s*$/," #{@row_break}") + @dob.obj=@dob.obj.gsub(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u,"\\begin{tiny}\\1\\end{tiny}&"). + gsub(/&>\s*$/," #{@row_break}") end end @dob @@ -482,10 +470,10 @@ WOK @colW << "p{#{col_w}cm}" if col_w end @@start_table="\\begin{tabular}{#{@colW}}\n" - @dob.obj.gsub!(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c\d+?;.+#{Mx[:gr_c]}/u,"#{@@start_table}") #fix + @dob.obj=@dob.obj.gsub(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c\d+?;.+#{Mx[:gr_c]}/u,"#{@@start_table}") #fix end if @dob =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/ #fix - @dob.obj.gsub!(/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/,"#{@end_table}") #fix + @dob.obj=@dob.obj.gsub(/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/,"#{@end_table}") #fix @@table_pg_break_counter=1 end if @dob =~/#{Mx[:tc_o]}#{Mx[:tc_p]}/u @@ -496,39 +484,39 @@ WOK "#{@@start_table}\n" @@table_pg_break_counter=1 else - @dob.obj.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}/u,'') + @dob.obj=@dob.obj.gsub(/#{Mx[:tc_o]}#{Mx[:tc_p]}/u,'') @@table_pg_break_counter+=1 tablefoot=@dob[/\<!f(.+?)!\>/] - @dob.obj.gsub!(/\<!f(.+?)!\>/,'') + @dob.obj=@dob.obj.gsub(/\<!f(.+?)!\>/,'') end end if @dob =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u - @dob.obj.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u,"\\begin{tiny}\\1\\end{tiny}&") - @dob.obj.gsub!(/&>\s*$/,"#{@row_break}") + @dob.obj=@dob.obj.gsub(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u,"\\begin{tiny}\\1\\end{tiny}&"). + gsub(/&>\s*$/,"#{@row_break}") end @dob end def graphics - dir=SiSU_Env::Info_env.new(@md.fns) - @dob.obj.gsub!(/<::\s+(\S+?)\s+>/i, #watch + dir=SiSU_Env::InfoEnv.new(@md.fns) + @dob.obj=@dob.obj.gsub(/<::\s+(\S+?)\s+>/i, #watch "\\includegraphics*[width=11pt]{#{dir.path.image_source_include}/c_\\1.png}") end def image - dir=SiSU_Env::Info_env.new(@md.fns) + dir=SiSU_Env::InfoEnv.new(@md.fns) width="100" width=@dob[/<:image.+?width=``(\d+)''.+?>/im,1] width=width.to_i*0.4 - @dob.obj.gsub!(/<:image\s+((?:https?|file|ftp)\S+)\s+(\S+)\s+.+\s+?>/i, - "\\href{\\1}{\\includegraphics*[width=#{width}pt]{#{dir.path.image_source_include}/\\2}}") - @dob.obj.gsub!(/<:image\s+(\S+)\s+.+\s+?>/i, - "\\includegraphics*[width=#{width}pt]{#{dir.path.image_source_include}/\\1}") + @dob.obj=@dob.obj.gsub(/<:image\s+((?:https?|file|ftp)\S+)\s+(\S+)\s+.+\s+?>/i, + "\\href{\\1}{\\includegraphics*[width=#{width}pt]{#{dir.path.image_source_include}/\\2}}"). + gsub(/<:image\s+(\S+)\s+.+\s+?>/i, + "\\includegraphics*[width=#{width}pt]{#{dir.path.image_source_include}/\\1}") end def png # very messy clean up ! - work area, testing z=@dob[/\\\{(.+?)\}(?:image|png)/,1] # match operator for z \\ fragile ! image,w,x,y=z.scan(/\S+/) - image.gsub!(/\\/,'') - @dob.obj.gsub!(/\\\{\S+\.(png|jpg|gif).+?\}(image|png)/,"<image #{image} not available>") # fragile match operator\\ fragile ! + image=image.gsub(/\\/,'') + @dob.obj=@dob.obj.gsub(/\\\{\S+\.(png|jpg|gif).+?\}(image|png)/,"<image #{image} not available>") # fragile match operator\\ fragile ! end def http # very messy clean up ! - work area, testing @@ -536,7 +524,7 @@ WOK url=@dob[/((?:https?|file|ftp):\S+)/im,1] if @dob =~/\.(png|jpg|gif)/ image,w,x,y=z.scan(/\S+/) - image.gsub!(/\\/,'') + image=image.gsub(/\\/,'') width=200 width=z[/w=(\d+)/im,1] if z =~/w=(\d+)/ width=width.to_i*0.8 @@ -545,41 +533,39 @@ WOK caption="{\\\\\\\ \n\\begin{scriptsize}#{c}\\end{scriptsize}&}" if c end if image - dir=SiSU_Env::Info_env.new(@md.fns) - @dob.obj.gsub!(/#{Mx[:lnk_o]}\S+\.(png|jpg|gif).+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/, # fragile match operator\\ fragile ! + dir=SiSU_Env::InfoEnv.new(@md.fns) + @dob.obj=@dob.obj.gsub(/#{Mx[:lnk_o]}\S+\.(png|jpg|gif).+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/, # fragile match operator\\ fragile ! "\n\\href{#{url}}{\\includegraphics*[width=#{width}pt]{#{dir.path.image_source_include}/#{image}}}#{caption}") else link=z[/(.+?)\\/im,1] - @dob.obj.gsub!(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+#{Mx[:url_c]}/,"\n\\noindent\\href{#{url}}{#{link}}") # fragile match operator\\ fragile ! + @dob.obj=@dob.obj.gsub(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+#{Mx[:url_c]}/,"\n\\noindent\\href{#{url}}{#{link}}") # fragile match operator\\ fragile ! end end end - class Texinfo_txt + class TeXinfoTxt def initialize(md,dob,txt) @md,@dob,@txt=md,dob,txt end def clean(dob,txt) - if dob.is=='heading' \ + if dob.is==:heading \ and txt !~/##{dob.ocn}/ txt="#{dob.obj} ##{dob.ocn}" end - txt.gsub!(/<:#>/,'') - txt.strip! - txt + txt=txt.gsub(/<:#>/,'').strip end def submenu txt=@txt.join("\n") - txt.gsub!(/[5]\\+~\S+/,'') + txt=txt.gsub(/[5]\\+~\S+/,'') txt=clean(@dob,txt) txt="@menu\n#{txt}\n@end menu\n\n" - txt.gsub!(/.+/m,"#{txt}") + txt=txt.gsub(/.+/m,"#{txt}") end def subsubmenu txt=@txt.join("\n") - txt.gsub!(/[6]\\+~\S+/,'') + txt=txt.gsub(/[6]\\+~\S+/,'') txt=clean(@dob,txt) txt="@menu\n#{dob.obj}\n@end menu\n\n" - txt.gsub!(/.+/m,"#{txt}") + txt=txt.gsub(/.+/m,"#{txt}") end end end diff --git a/lib/sisu/v3/texpdf.rb b/lib/sisu/v3/texpdf.rb index 47005d16..f0fb6b99 100644 --- a/lib/sisu/v3/texpdf.rb +++ b/lib/sisu/v3/texpdf.rb @@ -72,7 +72,7 @@ module SiSU_TeX @@tex_debug_counter=@@table_pagebreak_counter=@@tex_footnote_call_counter=@@tex_table_flag=@@tex_counter=@@tex_column=@@tex_columns=@@tex_columns=@@counting=0 @@tex_pattern_margin_number=/\\\\begin\\\{tiny\\\}\\\\hspace\\\{0mm\\\}\\\\end\\\{tiny\\\}\\\{\\\\marginpar.+?\s+/ @@n=@@tableheader=@@rights=nil - @@date ||=SiSU_Env::Info_date.new + @@date ||=SiSU_Env::InfoDate.new class Source require 'pstore' require_relative 'sysenv' # sysenv.rb @@ -83,18 +83,18 @@ module SiSU_TeX include SiSU_TeX def initialize(opt) @opt=opt - @particulars=SiSU_Particulars::Combined_singleton.instance.get_all(opt) + @particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt) @md=@particulars.md - @env=SiSU_Env::Info_env.new(@md.fns) #@env=@particulars.env + @env=SiSU_Env::InfoEnv.new(@md.fns) #@env=@particulars.env end def directories begin case @opt.fns when /\.(?:-|ssm\.)?sst$/ - SiSU_Env::SiSU_file.new(@md).mkdir + SiSU_Env::FileOp.new(@md).mkdir Dir.mkdir(@env.processing_path.tex) unless FileTest.directory?(@env.processing_path.tex) end - rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error + rescue; SiSU_Errors::InfoError.new($!,$@,@opt.cmd,@opt.fns).error ensure end end @@ -114,14 +114,14 @@ module SiSU_TeX $flag=@md.opt.cmd #introduced to pass 0 for no object citation numbers... to texpdf_format directories #% needed needs to be reprogrammed !!! - SiSU_Env::Info_skin.new(@md).select + SiSU_Env::InfoSkin.new(@md).select dal_array=SiSU_DAL::Source.new(@opt).get # dal file drawn here - SiSU_TeX::Source::LaTeX_create.new(@particulars).songsheet + SiSU_TeX::Source::LaTeXcreate.new(@particulars).songsheet dal_array='' pwd=Dir.pwd - SiSU_TeX::Source::LaTeX_to_pdf.new(@md,@particulars.env).latexrun_selective + SiSU_TeX::Source::LaTeXtoPdf.new(@md,@particulars.env).latexrun_selective Dir.chdir(pwd) - rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error + rescue; SiSU_Errors::InfoError.new($!,$@,@opt.cmd,@opt.fns).error ensure unless @opt.cmd =~/[MV]/ #check maintenance flag texfiles=Dir["#{@env.processing_path.tex}/#{@opt.fns}*"] @@ -137,25 +137,25 @@ module SiSU_TeX @@tex_debug_counter=@@table_pagebreak_counter=@@tex_footnote_call_counter=@@tex_table_flag=@@tex_counter=@@tex_column=@@tex_columns=@@tex_columns=@@counting=0 @@tex_col_w=[] @@n=@@tableheader=@@rights=nil - @@date=SiSU_Env::Info_date.new + @@date=SiSU_Env::InfoDate.new @@flag={} $flag=1 #remove at some stage SiSU_Env::Clear.new(@opt.cmd,@opt.fns).param_instantiate end end private - class LaTeX_to_pdf + class LaTeXtoPdf @@n_lpdf||=0 #change def initialize(md,env) @md,@env=md,env - @f=SiSU_Env::SiSU_file.new(@md).base_filename + @f=SiSU_Env::FileOp.new(@md).base_filename end def latex_do(texfilename,papersize) @texfilename=texfilename @@n_lpdf=@@n_lpdf+1 SiSU_Screen::Ansi.new(@md.opt.cmd,"#{papersize} portrait ->").dark_grey_title_hi if @md.opt.cmd =~/[MVv]/ tex_fn_base=@texfilename.gsub(/\.tex$/,'') - cmd=SiSU_Env::System_call.new("#{tex_fn_base}.tex",'',@md.opt.cmd) + cmd=SiSU_Env::SystemCall.new("#{tex_fn_base}.tex",'',@md.opt.cmd) tell=SiSU_Screen::Ansi.new(@md.opt.cmd) tell.grey_open if @md.opt.cmd =~/[MVv]/ if "#{tex_fn_base}" =~/\w+/ \ @@ -164,7 +164,7 @@ module SiSU_TeX end tell.p_off if @md.opt.cmd =~/[MVv]/ SiSU_Screen::Ansi.new(@md.opt.cmd,"#{papersize} landscape ->").dark_grey_title_hi if @md.opt.cmd =~/[MVv]/ - cmd=SiSU_Env::System_call.new("#{tex_fn_base}.landscape.tex",'',@md.opt.cmd) + cmd=SiSU_Env::SystemCall.new("#{tex_fn_base}.landscape.tex",'',@md.opt.cmd) tell.grey_open if @md.opt.cmd =~/[MVv]/ if "#{tex_fn_base}" =~/\w+/ \ and "#{papersize}" =~/\w+/ @@ -208,8 +208,8 @@ module SiSU_TeX when /\.(?:-|ssm\.)?sst$/ if FileTest.directory?(@env.processing_path.tex)==true Dir.chdir(@env.processing_path.tex) - texfile=@md.fns.gsub(/$/,".#{ps}.tex") - texfile=texfile.gsub(/~/,'-') + texfile=@md.fns.gsub(/$/,".#{ps}.tex"). + gsub(/~/,'-') if File.exist?(texfile) \ and File.size(texfile) > 0 @tex_f_no+=1 @@ -261,11 +261,11 @@ module SiSU_TeX end lst=Dir["*.{aux,log,out}"] lst.each {|file| File.unlink(file)} if lst - rescue; SiSU_Errors::Info_error.new($!,$@,@md.opt.cmd,@md.fns).error + rescue; SiSU_Errors::InfoError.new($!,$@,@md.opt.cmd,@md.fns).error end end end - class LaTeX_create + class LaTeXcreate @@tex_head={ 'a4'=> { p: nil, l: nil }, 'a5'=> { p: nil, l: nil }, @@ -278,23 +278,18 @@ module SiSU_TeX def initialize(particulars) @particulars=particulars @md=@particulars.md - @env=SiSU_Env::Info_env.new(@md.fns) #@env=@particulars.env + @env=SiSU_Env::InfoEnv.new(@md.fns) #@env=@particulars.env @data=@particulars.dal_array # dal file drawn here @st={ tex: {} } - @tex_ml=SiSU_TeX_Pdf::Use_TeX.new(@md) - @vz=SiSU_Env::Get_init.instance.skin - @dp=@@dp ||=SiSU_Env::Info_env.new.digest.pattern + @tex_ml=SiSU_TeX_Pdf::UseTeX.new(@md) + @vz=SiSU_Env::GetInit.instance.skin + @dp=@@dp ||=SiSU_Env::InfoEnv.new.digest.pattern @brace_url=SiSU_Viz::Skin.new.url_decoration - vz=SiSU_Env::Get_init.instance.skin - l=SiSU_Env::Standardise_language.new(@md.opt.lng).language + l=SiSU_Env::StandardiseLanguage.new(@md.opt.lng).language @language=l[:n] @translate=SiSU_Translate::Source.new(@md,@language) - @skin_no_ocn=if defined? vz.ocn_display_off \ - and vz.ocn_display_off==true - true - else false - end @codeblock_box='listings' #alternative 'boites' + @make ||=SiSU_Env::ProcessingSettings.new(@md) end def songsheet begin @@ -305,7 +300,7 @@ module SiSU_TeX if defined? @md.rights.all \ and not @md.rights.all.empty? rght=@md.rights #.author.dup #dup is necessary, else contents of :rights changed - sp_char=SiSU_TeX_Pdf::Special_characters.new(@md,rght.copyright.all) + sp_char=SiSU_TeX_Pdf::SpecialCharacters.new(@md,rght.copyright.all) copymark=@md.author_copymark \ ? '{\begin{small}\copyright\end{small}} ' : '' @@ -315,7 +310,7 @@ module SiSU_TeX end if defined? @md.notes.prefix_b \ and not @md.notes.prefix_b.empty? - sp_char=SiSU_TeX_Pdf::Special_characters.new(@md,@md.notes.prefix_b) + sp_char=SiSU_TeX_Pdf::SpecialCharacters.new(@md,@md.notes.prefix_b) prefix_b=sp_char.special_characters_safe @@prefix_b="\n #{Tex[:backslash]*2}[3]\\ \\linebreak \\ #{prefix_b}\n" unless @@prefix_b end @@ -324,16 +319,10 @@ module SiSU_TeX if @md.flag_tables #WORK ON 2009 data=tables(data) #uncomment to start experimenting with tables end - ocn=if @md.markup.inspect =~/no_ocn/ \ - or @md.opt.mod.inspect =~/--no-ocn/ \ - or @skin_no_ocn - false - else true - end data=number_paras(data) data=markup(data) output(data) - rescue; SiSU_Errors::Info_error.new($!,$@,@md.opt.cmd,@md.fns).error + rescue; SiSU_Errors::InfoError.new($!,$@,@md.opt.cmd,@md.fns).error ensure end end @@ -345,26 +334,26 @@ module SiSU_TeX # from param, Sort out ... revert to more elegant solution # even more of a kludge as had to insert newlines where code is used not satisfactory, think about dob.tmp=dob.obj #.dup - if dob.is=='para' \ - or dob.is=='heading' - dob.tmp.gsub!(/#{Mx[:mk_o]}:name#\S+?#{Mx[:mk_c]}/,'') - dob.tmp=SiSU_TeX_Pdf::Special_characters.new(@md,dob.tmp).special_characters + if dob.is==:para \ + || dob.is==:heading + dob.tmp=dob.tmp.gsub(/#{Mx[:mk_o]}:name#\S+?#{Mx[:mk_c]}/,'') + dob.tmp=SiSU_TeX_Pdf::SpecialCharacters.new(@md,dob.tmp).special_characters if dob.tmp =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/ - dob.tmp=SiSU_TeX_Pdf::Format_text_object.new(@md,dob.tmp).url_str_internal(dob.tmp) + dob.tmp=SiSU_TeX_Pdf::FormatTextObject.new(@md,dob.tmp).url_str_internal(dob.tmp) end - elsif dob.is =='code' + elsif dob.is ==:code dob.tmp=if @codeblock_box=='listings' dob.tmp else - SiSU_TeX_Pdf::Special_characters.new(@md,dob.tmp).special_characters_code + SiSU_TeX_Pdf::SpecialCharacters.new(@md,dob.tmp).special_characters_code end - elsif dob.is =='break' + elsif dob.is ==:break if dob.obj==Mx[:br_page]; dob.tmp='\newpage' elsif dob.obj==Mx[:br_page_new]; dob.tmp='\clearpage' elsif dob.obj==Mx[:br_obj]; dob.tmp='\parasep' end - elsif dob.is=='comment' \ - or dob.is=='meta' + elsif dob.is==:comment \ + || dob.is==:meta dob.tmp='' #dob.tmp=nil end end @@ -374,9 +363,9 @@ module SiSU_TeX data.each do |dob| # EMBEDDED FOOTNOTES / ENDNOTES should be straightforward but not quite a synch. if dob.tmp =~/#{Mx[:en_a_o]}[\d*+]+\s|#{Mx[:en_b_o]}([*+]\d+)\s/ - dob.tmp.gsub!(/#{Mx[:en_a_o]}(\d+)\s+(.+?)#{Mx[:en_a_c]}/m,"\\footnote[\\1]{%\n \\2} ") - dob.tmp.gsub!(/#{Mx[:en_b_o]}([*+]\d+)\s+(.+?)#{Mx[:en_b_c]}/m,"\\FootnoteA{\\1}{%\n \\2} ") - dob.tmp.gsub!(/#{Mx[:en_a_o]}([*+]+)\s+(.+?)#{Mx[:en_a_c]}/m,"\\FootnoteA{\\1}{%\n \\2} ") + dob.tmp=dob.tmp.gsub(/#{Mx[:en_a_o]}(\d+)\s+(.+?)#{Mx[:en_a_c]}/m,"\\footnote[\\1]{%\n \\2} "). + gsub(/#{Mx[:en_b_o]}([*+]\d+)\s+(.+?)#{Mx[:en_b_c]}/m,"\\FootnoteA{\\1}{%\n \\2} "). + gsub(/#{Mx[:en_a_o]}([*+]+)\s+(.+?)#{Mx[:en_a_c]}/m,"\\FootnoteA{\\1}{%\n \\2} ") end end data @@ -387,9 +376,9 @@ module SiSU_TeX @md.papersize_array.each do |ps| @@tableheader={ ps => { p: 0, l: 0 } } dob.tmp={ tmp: dob.tmp, paper_size: ps } - format_l=SiSU_TeX_Pdf::Format_text_object.new(md,dob) + format_l=SiSU_TeX_Pdf::FormatTextObject.new(md,dob) dob.tmp={ tmp: dob.tmp, paper_size: ps } - format_p=SiSU_TeX_Pdf::Format_text_object.new(md,dob) + format_p=SiSU_TeX_Pdf::FormatTextObject.new(md,dob) @block[ps]={ l: format_l.longtable_landscape, p: format_p.longtable_portrait @@ -403,7 +392,7 @@ module SiSU_TeX data.each do |dob| @tex_file << if dob.class==String \ or dob.class==Hash; dob - elsif dob.is=='table' + elsif dob.is==:table tables_hash(@md,dob) #Hash result else dob end @@ -414,17 +403,17 @@ module SiSU_TeX dob end def box_boites(dob,ocn) - sp_char=SiSU_TeX_Pdf::Special_characters.new(@md,dob.tmp,dob.is) + sp_char=SiSU_TeX_Pdf::SpecialCharacters.new(@md,dob.tmp,dob.is) dob.tmp=sp_char.special_characters_safe - dob.tmp.gsub!(/(#{Mx[:nbsp]})/m,'{\color{mywhite}\1}') - #dob.tmp.gsub!(/#{Mx[:nbsp]}/m,'{~}') # dob.tmp.gsub!(/#{Mx[:nbsp]}\s*/m,'{~}') - dob.tmp.gsub!(/#{Mx[:vline]}/m,'\vline') - dob.tmp.gsub!(/ \\( |#{Mx[:br_nl]})/,' {\textbackslash}\1') - dob.tmp.gsub!(/#{Mx[:br_nl]}\s*\Z/m,'') - dob.tmp.gsub!(/#{Mx[:br_nl]}{2}/,'\newline \\\\\\ ') - dob.tmp.gsub!(/#{Mx[:br_nl]}/,' \\\\\\ ') - dob.tmp.gsub!(/\n\n\n/m," \\newline\n\n") - ocn=SiSU_TeX_Pdf::Format_text_object.new(@md).ocn_display(dob) + dob.tmp=dob.tmp.gsub(/(#{Mx[:nbsp]})/m,'{\color{mywhite}\1}'). + #dob.tmp.gsub(/#{Mx[:nbsp]}/m,'{~}') # dob.tmp.gsub(/#{Mx[:nbsp]}\s*/m,'{~}') + gsub(/#{Mx[:vline]}/m,'\vline'). + gsub(/ \\( |#{Mx[:br_nl]})/,' {\textbackslash}\1'). + gsub(/#{Mx[:br_nl]}\s*\Z/m,''). + gsub(/#{Mx[:br_nl]}{2}/,'\newline \\\\\\ '). + gsub(/#{Mx[:br_nl]}/,' \\\\\\ '). + gsub(/\n\n\n/m," \\newline\n\n") + ocn=SiSU_TeX_Pdf::FormatTextObject.new(@md).ocn_display(dob) dob.tmp = ocn \ + @tex_ml.paraskip_small \ + '\begin{Codeblock}' \ @@ -437,14 +426,14 @@ module SiSU_TeX dob end def box_listings(dob,ocn) - sp_char=SiSU_TeX_Pdf::Special_characters.new(@md,dob.tmp,dob.is) + sp_char=SiSU_TeX_Pdf::SpecialCharacters.new(@md,dob.tmp,dob.is) dob.tmp=sp_char.characters_code_listings - dob.tmp.gsub!(/^\s+/m,'') #bug, fix earlier, should be made unecessary - dob.tmp.gsub!(/#{Mx[:nbsp]}/m,' ') - dob.tmp.gsub!(/#{Mx[:vline]}/m,'|') - dob.tmp.gsub!(/#{Mx[:br_nl]}(?:\s?\n)?/m,"\n") - dob.tmp.gsub!(/\n\n\n/m," \n\n") - ocn=SiSU_TeX_Pdf::Format_text_object.new(@md).ocn_display(dob) + dob.tmp=dob.tmp.gsub(/^\s+/m,''). #bug, fix earlier, should be made unecessary + gsub(/#{Mx[:nbsp]}/m,' '). + gsub(/#{Mx[:vline]}/m,'|'). + gsub(/#{Mx[:br_nl]}(?:\s?\n)?/m,"\n"). + gsub(/\n\n\n/m," \n\n") + ocn=SiSU_TeX_Pdf::FormatTextObject.new(@md).ocn_display(dob) dob.tmp = ocn \ + @tex_ml.paraskip_small \ + '\begin{Codeblock}' \ @@ -463,16 +452,18 @@ module SiSU_TeX def markup_common(dob) tex_f=nil txt_obj={ dal: dob } - if dob.of=='block' - @lineone=case dob.is - when /block|group|alt|verse/ - dob.tmp.gsub!(/#{Mx[:nbsp]}/m,'{~}') - dob.tmp.gsub!(/#{Mx[:gl_bullet]}/m,'$\txtbullet$\hspace{\enspace}') #Bullet environment not used for grouped text, ∴ no hanging indent here - dob.tmp.gsub!(/#{Mx[:br_nl]}+/m,"\n\n") #match not ideal, but currently not inserting extra newlines anyway - ocn=SiSU_TeX_Pdf::Format_text_object.new(@md).ocn_display(dob) - dob.tmp=if dob.is=='group' \ - or dob.is=='block' \ - or dob.is=='alt' + if dob.of==:block + @lineone=if dob.is==:block \ + || dob.is==:group \ + || dob.is==:alt \ + || dob.is==:verse + dob.tmp=dob.tmp.gsub(/#{Mx[:nbsp]}/m,'{~}'). + gsub(/#{Mx[:gl_bullet]}/m,'$\txtbullet$\hspace{\enspace}'). #Bullet environment not used for grouped text, ∴ no hanging indent here + gsub(/#{Mx[:br_nl]}+/m,"\n\n") #match not ideal, but currently not inserting extra newlines anyway + ocn=SiSU_TeX_Pdf::FormatTextObject.new(@md).ocn_display(dob) + dob.tmp=if dob.is==:group \ + || dob.is==:block \ + || dob.is==:alt ocn \ + @tex_ml.paraskip_small \ + "\n" \ @@ -482,7 +473,7 @@ module SiSU_TeX + '\\end{footnotesize}' \ + "\n" \ + @tex_ml.paraskip_normal - elsif dob.is=~/verse/ + elsif dob.is==:verse ocn \ + @tex_ml.paraskip_tiny \ + "\n" \ @@ -495,7 +486,7 @@ module SiSU_TeX + "\n\\linebreak\n" end dob - when /code/ + elsif dob.is ==:code dob=if @codeblock_box == 'listings' box_listings(dob,ocn) elsif @codeblock_box == 'boites' @@ -509,9 +500,9 @@ module SiSU_TeX dob=enclose(dob) unless dob.tmp =~/^$/ dob else - tst=SiSU_TeX_Pdf::Format_text_object.new(@md,dob) + tst=SiSU_TeX_Pdf::FormatTextObject.new(@md,dob) case dob.is - when 'heading' + when :heading case dob.ln when 1..3 tst.heading_major @@ -523,17 +514,17 @@ module SiSU_TeX tst.level6 else dob end - when 'heading_insert' + when :heading_insert br="\n\\\\\n" if dob.name=='book_index' h=tst.heading_major heading="\\clearpage\n" + h.tmp idx_arr=[] - idx=SiSU_Particulars::Combined_singleton.instance.get_idx_tex(@md.opt).tex_idx + idx=SiSU_Particulars::CombinedSingleton.instance.get_idx_tex(@md.opt).tex_idx idx.each do |x| x=if x.class==String - x=SiSU_TeX_Pdf::Special_characters.new(@md,x).special_characters - x=SiSU_TeX_Pdf::Format_text_object.new(@md,x).url_str_internal(x,true) + x=SiSU_TeX_Pdf::SpecialCharacters.new(@md,x).special_characters + x=SiSU_TeX_Pdf::FormatTextObject.new(@md,x).url_str_internal(x,true) else x=nil end idx_arr << x.sub(/,$/,'') if x.class==String @@ -551,11 +542,11 @@ module SiSU_TeX elsif dob.ln==4 \ and dob.obj=~/Metadata\b/ h=tst.level4 - metadata=Metadata::TeX_metadata.new(@md).metadata_tex + metadata=SiSU_Metadata::TeX_Metadata.new(@md).metadata_tex dob.tmp=h.tmp + ' ' + '\begin{scriptsize}' + metadata.join(br) + '\end{scriptsize}' else dob.tmp='' # dob.tmp={ l: '', p: '' } end - when 'para' + when :para if dob.bullet_ dob.tmp=tst.bullet elsif dob.indent \ @@ -568,35 +559,35 @@ module SiSU_TeX and (dob.indent != dob.hang or dob.indent =~/[1-9]/) dob.tmp=tst.hang else - dob.tmp.strip! + dob.tmp=dob.tmp.strip dob=enclose(dob) unless dob.tmp =~/^$/ end else - dob.tmp.strip! unless dob.is=='code' + dob.tmp=dob.tmp.strip unless dob.is==:code dob=enclose(dob) unless dob.tmp =~/^$/ end if dob.class==String - dob.tmp.gsub!(/\s*(?:#{Mx[:br_line]}|#{Mx[:br_nl]})\s*/,' \newline ') #% tread with care - dob.tmp.gsub!(/(\.#{Tex[:tilde]}\S*\s*|<:\S+>|#{Mx[:fa_o]}.*?#{Mx[:fa_c]}|#{Mx[:gr_o]}.*?#{Mx[:gr_c]}|<!.*?!>|<!>)/,' ') #% tread with care + dob.tmp=dob.tmp.gsub(/\s*(?:#{Mx[:br_line]}|#{Mx[:br_nl]})\s*/,' \newline '). #% tread with care + gsub(/(\.#{Tex[:tilde]}\S*\s*|<:\S+>|#{Mx[:fa_o]}.*?#{Mx[:fa_c]}|#{Mx[:gr_o]}.*?#{Mx[:gr_c]}|<!.*?!>|<!>)/,' ') #% tread with care end dob end if dob.tmp =~/(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image\b)/m \ - && dob.is !='code' - dob=SiSU_TeX_Pdf::Bare_urls.new(@md,dob).bare_urls - tst=SiSU_TeX_Pdf::Format_text_object.new(@md,dob) + && dob.is !=:code + dob=SiSU_TeX_Pdf::BareUrls.new(@md,dob).bare_urls + tst=SiSU_TeX_Pdf::FormatTextObject.new(@md,dob) dob=tst.urls_txt_and_images dob elsif dob.tmp =~/https?:\/\/\S+\b/m \ - && dob.is =='code' \ + && dob.is ==:code \ && @codeblock_box !='listings' - dob=SiSU_TeX_Pdf::Bare_urls.new(@md,dob).bare_urls_in_code + dob=SiSU_TeX_Pdf::BareUrls.new(@md,dob).bare_urls_in_code dob end if dob.class !=Hash \ && dob.tmp =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}image\b/ \ - && dob.is !='code' - tst=SiSU_TeX_Pdf::Format_text_object.new(@md,dob) + && dob.is !=:code + tst=SiSU_TeX_Pdf::FormatTextObject.new(@md,dob) end dob end @@ -666,9 +657,9 @@ WOK title=@md.title.full.gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}|#{Mx[:br_paragraph]}|\\\\/,' - ') #no line splitting in heading neither html nor latex @md.papersize_array.each do |ps| txt_obj={ txt: "#{home}: - #{title}", paper_size: ps, orientation: 'portrait' } - orient_portrait=SiSU_TeX_Pdf::Format_head.new(@md,txt_obj) + orient_portrait=SiSU_TeX_Pdf::FormatHead.new(@md,txt_obj) txt_obj={ txt: "#{home}: - #{title}", paper_size: ps, orientation: 'landscape' } - orient_landscape=SiSU_TeX_Pdf::Format_head.new(@md,txt_obj) + orient_landscape=SiSU_TeX_Pdf::FormatHead.new(@md,txt_obj) @@tex_head[ps][:p]=orient_portrait.document_head_with_orientation(@codeblock_box) @@tex_head[ps][:l]=orient_landscape.document_head_with_orientation(@codeblock_box) end @@ -709,13 +700,13 @@ WOK @copymark='' #check and remove as now is superflous x={} txt_obj={ title: @md.title.full } - x[:l]=SiSU_TeX_Pdf::Format_text_object.new(@md,txt_obj).title_landscape - x[:p]=SiSU_TeX_Pdf::Format_text_object.new(@md,txt_obj).title_portrait + x[:l]=SiSU_TeX_Pdf::FormatTextObject.new(@md,txt_obj).title_landscape + x[:p]=SiSU_TeX_Pdf::FormatTextObject.new(@md,txt_obj).title_portrait @tex_file << x x=nil if defined? @md.creator.author \ and @md.creator.author - sp_char=SiSU_TeX_Pdf::Special_characters.new(@md,@md.creator.author) + sp_char=SiSU_TeX_Pdf::SpecialCharacters.new(@md,@md.creator.author) author=sp_char.special_characters @tex_file << if @md.author_home <<WOK @@ -739,12 +730,20 @@ WOK @tex_file << @@prefix_b if defined? @md.creator.prefix_b and @md.creator.prefix_b end x={} - x[:l] =<<WOK -#{@tex_ml.newpage('landscape')} -\\pagestyle{fancy} + if (@make.build.toc?) + toc=<<WOK \\renewcommand{\\contentsname}{#{@translate.contents}} \\tableofcontents +WOK + toc_pb={ l: @tex_ml.newpage('landscape'), p: @tex_ml.newpage('portrait') } + else + toc='' + toc_pb={ l: '', p: '' } + end + x[:l] =<<WOK #{@tex_ml.newpage('landscape')} +\\pagestyle{fancy} +#{toc}#{toc_pb[:l]} \\pagenumbering{arabic} #{@tex_ml.paraskip_normal} #{@tex_ml.newpage('landscape')} @@ -752,8 +751,7 @@ WOK x[:p] =<<WOK #{@tex_ml.newpage('portrait')} \\pagestyle{fancy} -\\renewcommand{\\contentsname}{#{@translate.contents}} -\\tableofcontents +#{toc}#{toc_pb[:p]} #{@tex_ml.newpage('portrait')} \\pagenumbering{arabic} #{@tex_ml.paraskip_normal} @@ -763,10 +761,10 @@ WOK x=nil data.each do |dob| #% case follows with levels 1-6 indents & graphics if dob.class==Hash - elsif dob.of=='para' \ - or dob.of=='block' #GATEWAY FIX FIX stuff + elsif dob.of==:para \ + || dob.of==:block #GATEWAY FIX FIX stuff dob=markup_common(dob) - elsif dob.is=='table' + elsif dob.is==:table if ( dob.tmp['a4'] \ or dob.tmp['a5'] \ or dob.tmp['b5'] \ @@ -809,14 +807,10 @@ WOK @tex_file << "\n\\end{document}" end def number_paras_numbering(dob) # need tables and other types of object - if dob.of =~/para/ #\ + if dob.of ==:para paranum=dob.ocn ? dob.ocn : '' paranum = '' if paranum.to_i==0 - paranumber_display=if @md.markup.inspect =~/no_ocn/ \ - or @md.opt.mod.inspect =~/--no-ocn/ \ - or not dob.ocn_ - '' - else + paranumber_display=if @make.build.ocn? tags='' #[keep] code that follows inserts "name tags" as hypertargets, currently using ocn (converting nametags to ocn) for internal linking, related code: |texpdf_format.rb|@|uses nametags directly| #if dob.tags.length > 0 # insert tags "hypertargets" @@ -825,6 +819,7 @@ WOK # end #end "\\begin{tiny}\\hspace{0mm}\\end{tiny}{\\marginpar{\\begin{tiny}\\hspace{0mm}\\hypertarget{#{dob.ocn}}{#{dob.ocn}}#{tags}\\end{tiny}}}" #ocn object citation numbering + else '' end dob.tmp = paranumber_display + dob.tmp end @@ -860,7 +855,9 @@ WOK else p "#{__FILE__}:#{__LINE__}" if @md.opt.cmd.inspect =~/M/ end else - dob=if dob.of !~/comment|meta|layout/ + dob=if dob.of !=:comment \ + || dob.of !=:meta \ + || dob.of !=:layout number_paras_numbering(dob) else dob end @@ -872,12 +869,16 @@ WOK ps,h,fn=o[:ps],o[:h],o[:filename] if h[ps] \ and (h[ps][:p] and h[ps][:l]) - h[ps][:p].gsub!(/[ ]+$/m,'') if h[ps][:p] - h[ps][:l].gsub!(/[ ]+$/m,'') if h[ps][:l] - #h[ps][:p].gsub!(/(?:^[ ]+|[ ]+$)/m,'') if h[ps][:p] - #h[ps][:l].gsub!(/(?:^[ ]+|[ ]+$)/m,'') if h[ps][:l] - h[ps][:p].gsub!(/\n\n\n+/m,"\n\n") if h[ps][:p] - h[ps][:l].gsub!(/\n\n\n+/m,"\n\n") if h[ps][:l] + if h[ps][:p] + h[ps][:p]=h[ps][:p].gsub(/[ ]+$/m,''). + gsub(/\n\n\n+/m,"\n\n") + end + if h[ps][:l] + h[ps][:l]=h[ps][:l].gsub(/[ ]+$/m,''). + gsub(/\n\n\n+/m,"\n\n") + end + #h[ps][:p].gsub!(/(?:^[ ]+|[ ]+$)/m,'') if h[ps][:p] + #h[ps][:l].gsub!(/(?:^[ ]+|[ ]+$)/m,'') if h[ps][:l] if h[ps][:p] !~/\A\s*\Z/ fn[:portrait].puts h[ps][:p],"\n" end @@ -885,12 +886,16 @@ WOK fn[:landscape].puts h[ps][:l],"\n" end elsif (h[:p] and h[:l]) - h[:p].gsub!(/[ ]+$/m,'') if h[:p] - h[:l].gsub!(/[ ]+$/m,'') if h[:l] - #h[:p].gsub!(/(?:^[ ]+|[ ]+$)/m,'') if h[:p] - #h[:l].gsub!(/(?:^[ ]+|[ ]+$)/m,'') if h[:l] - h[:p].gsub!(/\n\n\n+/m,"\n\n") if h[:p] - h[:l].gsub!(/\n\n\n+/m,"\n\n") if h[:l] + if h[:p] + h[:p]=h[:p].gsub(/[ ]+$/m,''). + gsub(/\n\n\n+/m,"\n\n") + end + if h[:l] + h[:l]=h[:l].gsub(/[ ]+$/m,''). + gsub(/\n\n\n+/m,"\n\n") + end + #h[:p].gsub!(/(?:^[ ]+|[ ]+$)/m,'') if h[:p] + #h[:l].gsub!(/(?:^[ ]+|[ ]+$)/m,'') if h[:l] if h[:p] !~/\A\s*\Z/ fn[:portrait].puts h[:p],"\n" end @@ -901,9 +906,7 @@ WOK end end def output(array) - array.flatten! - array.compact! - @array=array + @array=array=array.flatten.compact fns_l=@md.fns.gsub(/~/,'-') #this is a sorry fix, but necessary as it appears latex programs like not ~ @md.papersize_array.each do |ps| file={ @@ -919,16 +922,16 @@ WOK file[:portrait].puts morph,"\n" file[:landscape].puts morph,"\n" end - elsif morph.class.inspect =~ /SiSU_document_structure/ \ + elsif morph.class.inspect =~ /SiSU_DAL_DocumentStructure/ \ and morph.tmp \ and morph.tmp.class==String - if morph.is !='code' \ - && morph.of !='block' - morph.tmp.gsub!(/^\s+/,'') + if morph.is !=:code \ + && morph.of !=:block + morph.tmp=morph.tmp.gsub(/^\s+/,'') else morph.tmp end - if morph.tmp !~/\A\s*\Z/ \ - or morph.is=='code' + if (morph.tmp !~/\A\s*\Z/) \ + || morph.is==:code file[:portrait].puts morph.tmp,"\n" file[:landscape].puts morph.tmp,"\n" end diff --git a/lib/sisu/v3/texpdf_format.rb b/lib/sisu/v3/texpdf_format.rb index 25cb0c63..ae277ec6 100644 --- a/lib/sisu/v3/texpdf_format.rb +++ b/lib/sisu/v3/texpdf_format.rb @@ -59,30 +59,30 @@ module SiSU_TeX_Pdf @@table_pg_break_counter=1 include SiSU_Viz - class Bare_urls + class BareUrls def initialize(md,dob=nil) @md,@dob=md,dob @brace_url=SiSU_Viz::Skin.new.url_decoration end def bare_urls - @dob.obj.gsub!(/#{Mx[:url_o]}([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)#{Mx[:url_c]}/, - "#{@brace_url.tex_open}\\1</a>#{@brace_url.tex_close}") - @dob.tmp.gsub!(/(^|[^\\])_/m,'\1\_') #watch may not work - @dob.tmp.gsub!(/(^|[^#{Mx[:lnk_c]}])#{Mx[:url_o]}_?(?:\\?_)?(\S+?)#{Mx[:url_c]}/m, - "\\1#{@brace_url.tex_open}\\begin{scriptsize}\\url{\\2}\\end{scriptsize}#{@brace_url.tex_close}") + @dob.obj=@dob.obj.gsub(/#{Mx[:url_o]}([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)#{Mx[:url_c]}/, + "#{@brace_url.tex_open}\\1</a>#{@brace_url.tex_close}") + @dob.tmp=@dob.tmp.gsub(/(^|[^\\])_/m,'\1\_'). #watch may not work + gsub(/(^|[^#{Mx[:lnk_c]}])#{Mx[:url_o]}_?(?:\\?_)?(\S+?)#{Mx[:url_c]}/m, + "\\1#{@brace_url.tex_open}\\begin{scriptsize}\\url{\\2}\\end{scriptsize}#{@brace_url.tex_close}") @dob end def bare_urls_in_code - @dob.tmp.gsub!(/(^|[^\\])_/m,'\1\_') #watch may not work - @dob.tmp.gsub!(/(https?:\/\/\S+?)([{]|[.,;)\]]?(?: |$))/m, - '\begin{scriptsize}\url{\1}\end{scriptsize}\2') + @dob.tmp=@dob.tmp.gsub(/(^|[^\\])_/m,'\1\_'). #watch may not work + gsub(/(https?:\/\/\S+?)([{]|[.,;)\]]?(?: |$))/m, + '\begin{scriptsize}\url{\1}\end{scriptsize}\2') @dob end end - class Format_text_object + class FormatTextObject require_relative 'defaults' # defaults.rb attr_accessor :string,:string1,:orientation,:url,:dir,:tex - @@sys=SiSU_Env::System_call.new + @@sys=SiSU_Env::SystemCall.new @@tex_pattern_margin_number=/\\begin\{tiny\}\\hspace\{0mm\}\\end\{tiny\}\{\\marginpar.+?\}\}\}/ @@tableheader={ 'a4' => { p: 0, l: 0 }, @@ -91,7 +91,7 @@ module SiSU_TeX_Pdf 'letter' => { p: 0, l: 0 }, 'legal' => { p: 0, l: 0 } } - @@sys=SiSU_Env::System_call.new + @@sys=SiSU_Env::SystemCall.new def initialize(md,dob=nil) @md,@dob=md,dob if defined? @md.image \ @@ -100,31 +100,34 @@ module SiSU_TeX_Pdf else @center_begin,@center_end='','' end @start_table='' - @tx=SiSU_Env::Get_init.instance.tex + @tx=SiSU_Env::GetInit.instance.tex @brace_rel=SiSU_Viz::Skin.new.rel_decoration - @env ||=SiSU_Env::Info_env.new(@md.fns) - @tex2pdf=@@tex3pdf ||=SiSU_Env::System_call.new.tex2pdf_engine + @env ||=SiSU_Env::InfoEnv.new(@md.fns) + @tex2pdf=@@tex3pdf ||=SiSU_Env::SystemCall.new.tex2pdf_engine + @make ||=SiSU_Env::ProcessingSettings.new(@md) end def ocn_display(dob) - "\\begin{tiny}\\hspace{0mm}\\end{tiny}{\\marginpar{\\begin{tiny}\\hspace{0mm}\\hypertarget{#{dob.ocn}}{#{dob.ocn}}\\end{tiny}}}" #ocn object citation numbering + show_ocn=(@make.build.ocn?) \ + ? dob.ocn + : '' + "\\begin{tiny}\\hspace{0mm}\\end{tiny}{\\marginpar{\\begin{tiny}\\hspace{0mm}\\hypertarget{#{dob.ocn}}{#{show_ocn}}\\end{tiny}}}" #ocn object citation numbering end def table_special_characters(r) - r.gsub!(/#{Mx[:tc_p]}|$/u,'&') - r.gsub!(/%/,'\%') - r.gsub!(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'\begin{bfseries}\1 \end{bfseries}') - r.gsub!(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'\emph{\1}') - r.gsub!(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'\uline{\1}') # ulem - r.gsub!(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,"``\\1''") # quote #CHECK - r.gsub!(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'\uline{\1}') # ulem - r.gsub!(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'\sout{\1}') # ulem - r.gsub!(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,"\$^{\\textrm{\\1}}\$") - r.gsub!(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,"\$_{\\textrm{\\1}}\$") - r + r=r.gsub(/#{Mx[:tc_p]}|$/u,'&'). + gsub(/%/,'\%'). + gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'\begin{bfseries}\1 \end{bfseries}'). + gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'\emph{\1}'). + gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'\uline{\1}'). # ulem + gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,"``\\1''"). # quote #CHECK + gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'\uline{\1}'). # ulem + gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'\sout{\1}'). # ulem + gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,"\$^{\\textrm{\\1}}\$"). + gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,"\$_{\\textrm{\\1}}\$") end def longtable_landscape end_table='\end{longtable}' row_break='\\\\\\' - txt=if @dob.is=='table' + txt=if @dob.is==:table tw=case @dob.tmp[:paper_size] when /a4/i; @tx.a4.landscape.w #European default, SiSU default when /letter/i; @tx.letter.landscape.w #U.S. default @@ -147,19 +150,21 @@ module SiSU_TeX_Pdf "\\begin{tiny}\n\\begin{longtable}#{colW}\n" rows=@dob.obj.split(/#{Mx[:br_nl]}/) if @dob.head_ #result imperfect, check on - rows[0].gsub!(/(^|.+?)(?:#{Mx[:tc_p]}|$)/u,'\bfseries \1&') - rows[0].gsub!(/&\s*$/," #{row_break} \\hline\\endhead #{row_break}") + rows[0]=rows[0].gsub(/(^|.+?)(?:#{Mx[:tc_p]}|$)/u,'\bfseries \1&'). + gsub(/&\s*$/," #{row_break} \\hline\\endhead #{row_break}") end + rows_new=[] rows.each do |r| r=table_special_characters(r) - r.gsub!(/$/," #{row_break}\n") unless r =~/#{row_break*2}$/ + r=r.gsub(/$/," #{row_break}\n") unless r =~/#{row_break*2}$/ if r=~/\<!f(.+?)!\>/ # not tested table footer if any tablefoot=$1 - r.gsub!(/\<!f(.+?)!\>/,'') + r=r.gsub(/\<!f(.+?)!\>/,'') r="#{r} \\multicolumn{#{@dob.cols}}{l}{\\tiny #{tablefoot}} \\\\ \\hline\n\\endfoot\n\\hline\n" end + rows_new << r end - table=rows.join #@dob[:dal].obj=rows.join + table=rows_new.join #@dob[:dal].obj=rows.join ocn_display(@dob) + start_table + table + " #{end_table}\n\\end{tiny}" else '' end @@ -167,7 +172,7 @@ module SiSU_TeX_Pdf def longtable_portrait end_table='\end{longtable}' row_break='\\\\\\' - txt=if @dob.is=='table' + txt=if @dob.is==:table tw=case @dob.tmp[:paper_size] when /a4/i; @tx.a4.portrait.w #European default, SiSU default when /letter/i; @tx.letter.portrait.w #U.S. default @@ -190,19 +195,21 @@ module SiSU_TeX_Pdf "\\begin{tiny}\n\\begin{longtable}#{colW}\n" rows=@dob.obj.split(/#{Mx[:br_nl]}/) if @dob.head_ - rows[0].gsub!(/(^|.+?)(?:#{Mx[:tc_p]}|$)/u,'\bfseries \1&') - rows[0].gsub!(/&\s*$/," #{row_break} \\hline\\endhead #{row_break}") + rows[0]=rows[0].gsub(/(^|.+?)(?:#{Mx[:tc_p]}|$)/u,'\bfseries \1&'). + gsub(/&\s*$/," #{row_break} \\hline\\endhead #{row_break}") end + rows_new=[] rows.each do |r| r=table_special_characters(r) - r.gsub!(/$/," #{row_break}\n") unless r =~/#{row_break*2}$/ + r=r.gsub(/$/," #{row_break}\n") unless r =~/#{row_break*2}$/ if r=~/\<!f(.+?)!\>/ # not tested table footer if any tablefoot=$1 - r.gsub!(/\<!f(.+?)!\>/,'') + r=r.gsub(/\<!f(.+?)!\>/,'') r="#{r} \\multicolumn{#{@dob.cols}}{l}{\\tiny #{tablefoot}} \\\\ \\hline\n\\endfoot\n\\hline\n" end + rows_new << r end - table=rows.join #@dob[:dal].obj=rows.join + table=rows_new.join #@dob[:dal].obj=rows.join ocn_display(@dob) + start_table + table + " #{end_table}\n\\end{tiny}" else '' end @@ -210,17 +217,17 @@ module SiSU_TeX_Pdf def heading_major dob=@dob title=@md.title.full - dob.tmp.strip! if dob.tmp - dob.tmp.gsub!(/\\begin\{(bfseries|itshape)\}(.+?)\\end\{\1\}/m,'\2') + dob.tmp=dob.tmp.strip if dob.tmp + dob.tmp=dob.tmp.gsub(/\\begin\{(bfseries|itshape)\}(.+?)\\end\{\1\}/m,'\2') cont_ln=dob.tmp.dup - cont_ln.gsub!(/\\begin\{(monosp)\}(.+?)\\end\{\1\}/m,'\2') - cont_ln.gsub!(@@tex_pattern_margin_number,'') + cont_ln=cont_ln.gsub(/\\begin\{(monosp)\}(.+?)\\end\{\1\}/m,'\2'). + gsub(@@tex_pattern_margin_number,'') clearp=(dob.lv =~/B/ && dob.obj =='Metadata') ? "\\clearpage\n" : '' if dob.tmp =~/\\[Ff]ootnote/ #and dob =~/^[1-6]#{Tex[:tilde]}/ # removing footnotes from headings! - cont_ln.gsub!(/\s*\\footnote\[\d+\]\{%\n .+? \}\s*/,' ') - cont_ln.gsub!(/\s*\\Footnote[A]\{[*+]+\d*\}\{%\n .+? \}\s*/,' ') + cont_ln=cont_ln.gsub(/\s*\\footnote\[\d+\]\{%\n .+? \}\s*/,' '). + gsub(/\s*\\Footnote[A]\{[*+]+\d*\}\{%\n .+? \}\s*/,' ') end - dob.tmp.gsub!(/^(.*)\n?$/m, + dob.tmp=dob.tmp.gsub(/^(.*)\n?$/m, "#{clearp}\\part*{\\1} \\addcontentsline{toc}{section}{#{cont_ln}} \\markboth{#{title}}\n") @@ -228,23 +235,23 @@ module SiSU_TeX_Pdf end def level4 dob=@dob - dob.tmp.strip! if dob.tmp - dob.tmp.gsub!(/\\begin\{(bfseries|itshape)\}(.+?)\\end\{\1\}/m,'\2') + dob.tmp=dob.tmp.strip if dob.tmp + dob.tmp=dob.tmp.gsub(/\\begin\{(bfseries|itshape)\}(.+?)\\end\{\1\}/m,'\2') cont_ln=dob.tmp.dup - cont_ln.gsub!(/\\begin\{(monosp)\}(.+?)\\end\{\1\}/m,'\2') - cont_ln.gsub!(@@tex_pattern_margin_number,'') - cont_ln.gsub!(/#{Tex[:backslash]*2}/,"#{Tex[:backslash]*4}") # added w42 - cont_ln.gsub!(/\\footnote\[\d+\]\{%.+?\\end\{scriptsize\}\s*\}/m,'') #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22 - cont_ln.gsub!(/\\Footnote[A]\{[*+]+\d*\}\{%.+?\\end\{scriptsize\}\s*\}/m,'') #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22 + cont_ln=cont_ln.gsub(/\\begin\{(monosp)\}(.+?)\\end\{\1\}/m,'\2'). + gsub(@@tex_pattern_margin_number,''). + gsub(/#{Tex[:backslash]*2}/,"#{Tex[:backslash]*4}"). # added w42 + gsub(/\\footnote\[\d+\]\{%.+?\\end\{scriptsize\}\s*\}/m,''). #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22 + gsub(/\\Footnote[A]\{[*+]+\d*\}\{%.+?\\end\{scriptsize\}\s*\}/m,'') #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22 title=@md.title.full if dob.name =~/endnotes/ - dob.tmp.gsub!(/.+/m,'') + dob.tmp=dob.tmp.gsub(/.+/m,'') end if dob.tmp =~/\\footnote/ #and dob =~/^[1-6]#{Tex[:tilde]}/ # removing footnotes from headings! - cont_ln.gsub!(/\s*\\footnote\[\d+\]\{%\n .+? \}\s*/,' ') - cont_ln.gsub!(/\s*\\Footnote[A]\{[*+]+\d*\}\{%\n .+? \}\s*/,' ') + cont_ln=cont_ln.gsub(/\s*\\footnote\[\d+\]\{%\n .+? \}\s*/,' '). + gsub(/\s*\\Footnote[A]\{[*+]+\d*\}\{%\n .+? \}\s*/,' ') end - dob.tmp.gsub!(/^(.*)?\n?$/m,"\\subsubsection*{\\1} + dob.tmp=dob.tmp.gsub(/^(.*)?\n?$/m,"\\subsubsection*{\\1} \\addcontentsline{toc}{subsection}{#{cont_ln}} \\markright{#{title}}") dob @@ -252,19 +259,19 @@ module SiSU_TeX_Pdf def level5 dob=@dob # there is a problem here with creation of headers does not do what you would want it to header starts with a * and is not in bold work on \\@txt*, same for next section 2002w46 - dob.tmp.strip! if dob.tmp - dob.tmp.gsub!(/\\begin\{(bfseries|itshape)\}(.+?)\\end\{\1\}/m,'\2') + dob.tmp=dob.tmp.strip if dob.tmp + dob.tmp=dob.tmp.gsub(/\\begin\{(bfseries|itshape)\}(.+?)\\end\{\1\}/m,'\2') cont_ln=dob.tmp.dup - cont_ln.gsub!(/\\begin\{(monosp)\}(.+?)\\end\{\1\}/m,'\2') - cont_ln.gsub!(@@tex_pattern_margin_number,'') - cont_ln.gsub!(/\\footnote\[\d+\]\{%.+?\\end\{scriptsize\}\s*\}/m,'') #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22 - cont_ln.gsub!(/\\Footnote[A]\{[*+]+\d*\}\{%.+?\\end\{scriptsize\}\s*\}/m,'') #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22 - cont_ln.gsub!(/\\\&/,' and ') #revisit: tmp bugfix 200507, substitutes & with 'and' in toc, needed e.g. for AT&T, see ffa + cont_ln=cont_ln.gsub(/\\begin\{(monosp)\}(.+?)\\end\{\1\}/m,'\2'). + gsub(@@tex_pattern_margin_number,''). + gsub(/\\footnote\[\d+\]\{%.+?\\end\{scriptsize\}\s*\}/m,''). #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22 + gsub(/\\Footnote[A]\{[*+]+\d*\}\{%.+?\\end\{scriptsize\}\s*\}/m,''). #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22 + gsub(/\\\&/,' and ') #revisit: tmp bugfix 200507, substitutes & with 'and' in toc, needed e.g. for AT&T, see ffa if dob.tmp =~/\\footnote/ #and dob =~/^[1-6]#{Tex[:tilde]}/ # removing footnotes from headings! - cont_ln.gsub!(/\s*\\footnote\[\d+\]\{%\n .+? \}\s*/,' ') - cont_ln.gsub!(/\s*\\Footnote[A]\{[*+]+\d*\}\{%\n .+? \}\s*/,' ') + cont_ln=cont_ln.gsub(/\s*\\footnote\[\d+\]\{%\n .+? \}\s*/,' '). + gsub(/\s*\\Footnote[A]\{[*+]+\d*\}\{%\n .+? \}\s*/,' ') end - dob.tmp.gsub!(/^(.*)?\n?$/m, + dob.tmp=dob.tmp.gsub(/^(.*)?\n?$/m, "\\subsubsection*{\\1} \\addcontentsline{toc}{subsubsection}{#{cont_ln} \\\\ }") @@ -273,22 +280,22 @@ module SiSU_TeX_Pdf def level6 dob=@dob # there is a problem here with creation of headers does not do what you would want it to header starts with a * and is not in bold work on \\sub@txt*, same for previous section 2002w46 - dob.tmp.strip! if dob.tmp - dob.tmp.gsub!(/\\begin\{(bfseries|itshape)\}(.+?)\\end\{\1\}/m,'\2') + dob.tmp=dob.tmp.strip if dob.tmp + dob.tmp=dob.tmp.gsub(/\\begin\{(bfseries|itshape)\}(.+?)\\end\{\1\}/m,'\2') cont_ln=dob.tmp.dup - cont_ln.gsub!(/\\begin\{(monosp)\}(.+?)\\end\{\1\}/m,'\2') - cont_ln.gsub!(@@tex_pattern_margin_number,'') - cont_ln.gsub!(/\\footnote\[\d+\]\{%.+?\\end\{scriptsize\}\s*\}/m,'') #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22 - cont_ln.gsub!(/\\Footnote[A]\{[*+]+\d*\}\{%.+?\\end\{scriptsize\}\s*\}/m,'') #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22 + cont_ln=cont_ln.gsub(/\\begin\{(monosp)\}(.+?)\\end\{\1\}/m,'\2'). + gsub(@@tex_pattern_margin_number,''). + gsub(/\\footnote\[\d+\]\{%.+?\\end\{scriptsize\}\s*\}/m,''). #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22 + gsub(/\\Footnote[A]\{[*+]+\d*\}\{%.+?\\end\{scriptsize\}\s*\}/m,'') #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22 if dob.tmp =~/\\footnote/ #and dob =~/^[1-6]#{Tex[:tilde]}/ # removing footnotes from headings! - cont_ln.gsub!(/\s*\\footnote\[\d+\]\{%\n .+? \}\s*/,' ') - cont_ln.gsub!(/\s*\\Footnote[A]\{[*+]+\d*\}\{%\n .+? \}\s*/,' ') + cont_ln=cont_ln.gsub(/\s*\\footnote\[\d+\]\{%\n .+? \}\s*/,' '). + gsub(/\s*\\Footnote[A]\{[*+]+\d*\}\{%\n .+? \}\s*/,' ') end - dob.tmp.gsub!(/^(.*)?\n?$/m, + dob.tmp=dob.tmp.gsub(/^(.*)?\n?$/m, "\\subsubsection*{\\1} \\addcontentsline{toc}{subsubsection}{~~~~#{cont_ln} \\\\ }") - #dob.tmp.gsub!(/^(.*)?\n?$/m, + #dob.tmp.gsub(/^(.*)?\n?$/m, # '\subsubsection*{\1}') dob end @@ -462,7 +469,7 @@ module SiSU_TeX_Pdf blt end def symbol_graphic - dir=SiSU_Env::Info_env.new(@md.fns) + dir=SiSU_Env::InfoEnv.new(@md.fns) image='c_' + /<:=\s*(\S+?)\s*>/m.match(@txt).captures.join + '.png' #watch if FileTest.file?("#{dir.path.image_source_include}/#{image}") @txt.gsub!(/<:=\s*(\S+?)\s*>/, @@ -473,7 +480,7 @@ module SiSU_TeX_Pdf end end def image - dir=SiSU_Env::Info_env.new(@md.fns) + dir=SiSU_Env::InfoEnv.new(@md.fns) image,m=/#{Mx[:lnk_o]}\s*(\S+)\s+.+?width=``(\d+)''.+?#{Mx[:lnk_c]}/m.match(@txt).captures width=m[1] || '100' width=width.to_i*0.4 @@ -496,7 +503,7 @@ module SiSU_TeX_Pdf end end def png(ps='') #fc missing image check - dir=SiSU_Env::Info_env.new(@md.fns) + dir=SiSU_Env::InfoEnv.new(@md.fns) # messy clean up z=@txt[/#{Mx[:lnk_o]}(\S.+?)#{Mx[:lnk_c]}(?:image|png)/,1].strip if @txt =~ /#{Mx[:lnk_o]}\S.+?#{Mx[:lnk_c]}(?:image|png)/ # match operator for z \\ fragile ! if z #debug 2004w14 @@ -534,7 +541,7 @@ module SiSU_TeX_Pdf end end def url_str_internal(str,idx=nil) - map_nametags=SiSU_Particulars::Combined_singleton.instance.get_map_nametags(@md).nametags_map #p map_nametags + map_nametags=SiSU_Particulars::CombinedSingleton.instance.get_map_nametags(@md).nametags_map #p map_nametags rgx_url_generic=/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/m rgx_url_relative=/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:rel_o]}:\S+?#{Mx[:rel_c]}/m rgx_url_internal=/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:rel_o]}#?\S+?#{Mx[:rel_c]}/m @@ -569,8 +576,7 @@ module SiSU_TeX_Pdf #? (str.sub!(rgx_url_internal,"\\hyperlink{#{url}}{#{link}}")) \ #: (str.sub!(rgx_url_internal,"#{@brace_rel.tex_open}\\hyperlink{#{url}}{#{link}}#{@brace_rel.tex_close}")) end - str.gsub!(/#{Xx[:protect]}/,'') - str + str=str.gsub(/#{Xx[:protect]}/,'') end def url_str(str) rgx_url_generic=/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/m @@ -582,7 +588,7 @@ module SiSU_TeX_Pdf link=z.strip link.gsub!(/&/,"#{Xx[:protect]}&") str.sub!(rgx_url_generic,"#{@brace_rel.tex_open}\\href{#{url}}{#{link}}#{@brace_rel.tex_close}") - str.gsub!(/#{Xx[:protect]}/,'') + str=str.gsub(/#{Xx[:protect]}/,'') str else str end @@ -607,6 +613,8 @@ module SiSU_TeX_Pdf link.gsub!(/&/,"#{Xx[:protect]}&") dob.tmp.sub!(rgx_url_generic,"#{@brace_rel.tex_open}\\href{#{url}}{#{link}}#{@brace_rel.tex_close}#{punctuate}") dob.tmp.gsub!(/#{Xx[:protect]}/,'') + #dob.tmp=dob.tmp.sub(rgx_url_generic,"#{@brace_rel.tex_open}\\href{#{url}}{#{link}}#{@brace_rel.tex_close}#{punctuate}"). + # gsub(/#{Xx[:protect]}/,'') dob else dob end @@ -616,7 +624,7 @@ module SiSU_TeX_Pdf end def urls_txt_and_images dob=@dob - dir=SiSU_Env::Info_env.new(@md.fns) + dir=SiSU_Env::InfoEnv.new(@md.fns) @dm={ 'a4'=> @tx.a4.landscape.img_px, 'letter'=> @tx.letter.landscape.img_px, @@ -737,7 +745,7 @@ module SiSU_TeX_Pdf dob end def title - title=SiSU_TeX_Pdf::Special_characters.new(@md,@md.title.full).special_characters_safe + title=SiSU_TeX_Pdf::SpecialCharacters.new(@md,@md.title.full).special_characters_safe "\n\\title{#{title}}" end def title_landscape @@ -747,11 +755,11 @@ module SiSU_TeX_Pdf title end end - class Format_head + class FormatHead require_relative 'prog_text_translation' # prog_text_translation.rb def initialize(md,t_o) @md,@t_o=md,t_o - @env=SiSU_Env::Info_env.new(@md.fns) + @env=SiSU_Env::InfoEnv.new(@md.fns) if t_o.class==Hash @txt =t_o[:txt] || nil @subtitle=t_o[:subtitle] || nil @@ -762,24 +770,24 @@ module SiSU_TeX_Pdf p t_o.class p caller end - @tx=SiSU_Env::Get_init.instance.tex + @tx=SiSU_Env::GetInit.instance.tex @brace_url=SiSU_Viz::Skin.new.url_decoration - @tex2pdf=@@tex3pdf ||=SiSU_Env::System_call.new.tex2pdf_engine + @tex2pdf=@@tex3pdf ||=SiSU_Env::SystemCall.new.tex2pdf_engine @ps=@txt if @txt=~/(?:a4|letter|legal|book|a5|b5)/i @lang ||=SiSU_i18n::Languages.new #.list[@md.opt.lng][:xlp] @author=if defined? @md.creator.author \ and @md.creator.author=~/\S+/ - SiSU_TeX_Pdf::Special_characters.new(@md,@md.creator.author).special_characters_safe + SiSU_TeX_Pdf::SpecialCharacters.new(@md,@md.creator.author).special_characters_safe else '' end @subject=if defined? @md.classify.subject \ and @md.classify.subject=~/\S+/ - SiSU_TeX_Pdf::Special_characters.new(@md,@md.classify.subject).special_characters_safe + SiSU_TeX_Pdf::SpecialCharacters.new(@md,@md.classify.subject).special_characters_safe else '' end @keywords=if defined? @md.classify.keywords \ and @md.classify.keywords=~/\S+/ - SiSU_TeX_Pdf::Special_characters.new(@md,@md.classify.keywords).special_characters_safe + SiSU_TeX_Pdf::SpecialCharacters.new(@md,@md.classify.keywords).special_characters_safe else '' end end @@ -797,7 +805,7 @@ module SiSU_TeX_Pdf end if lang_char_arr.length > 0 lang_char_arr.slice(1..9).each { |ch| otherlang << @lang.list[ch][:xlp] } - otherlang.uniq! + otherlang=otherlang.uniq end otherlang=otherlang.join(',') { mainlang: mainlang, otherlang: otherlang } @@ -1171,59 +1179,58 @@ WOK def a4generic end end - class Special_characters - def initialize(md,str,is='') + class SpecialCharacters + def initialize(md,str,is=:default) @md,@txt,@is=md,str,is @brace_url=SiSU_Viz::Skin.new.url_decoration - @tex2pdf=@@tex3pdf ||=SiSU_Env::System_call.new.tex2pdf_engine + @tex2pdf=@@tex3pdf ||=SiSU_Env::SystemCall.new.tex2pdf_engine end - def xetex_code_listings(str,is='') # ~ ^ $ & % _ { } #LaTeX special characters - KEEP list + def xetex_code_listings(str,is=:default) # ~ ^ $ & % _ { } #LaTeX special characters - KEEP list word=str.scan(/\S+|\n/) #unless line =~/^(?:@\S|%+\s)/ para_array=[] str=if word word.each do |w| # _ - / # | : ! ^ ~ - w.gsub!(/#{Mx[:gl_o]}#lt#{Mx[:gl_c]}/,'<'); w.gsub!(/#{Mx[:gl_o]}#gt#{Mx[:gl_c]}/,'>') - w.gsub!(/[\\]?~/,'~') - w.gsub!(/[#{Mx[:br_line]}#{Mx[:br_paragraph]}]/,"\n") #watch - w.gsub!(/#{Mx[:gl_o]}#(?:126|152)#{Mx[:gl_c]}/,'~') #126 usual - w.gsub!(/\\?\||#{Mx[:gl_o]}#124#{Mx[:gl_c]}/,'|') #unless is=='code' #unless w=~/<~\d+;(?:[ohmu]|[0-6]:)\d+;\w\d+>/ # | SiSU not really special sisu character but done, also LaTeX + w=w.gsub(/#{Mx[:gl_o]}#lt#{Mx[:gl_c]}/,'<').gsub(/#{Mx[:gl_o]}#gt#{Mx[:gl_c]}/,'>'). + gsub(/[\\]?~/,'~'). + gsub(/[#{Mx[:br_line]}#{Mx[:br_paragraph]}]/,"\n"). #watch + gsub(/#{Mx[:gl_o]}#(?:126|152)#{Mx[:gl_c]}/,'~'). #126 usual + gsub(/\\?\||#{Mx[:gl_o]}#124#{Mx[:gl_c]}/,'|') #unless is=='code' #unless w=~/<~\d+;(?:[ohmu]|[0-6]:)\d+;\w\d+>/ # | SiSU not really special sisu character but done, also LaTeX para_array << w end str=para_array.join(' ') - str=str.strip unless is=='code' + str=str.strip unless is==:code str else '' end - str.gsub(/\s*#{Mx[:mk_o]}:name#\S+?#{Mx[:mk_c]}\s*/,' ') - str.gsub!(/.+?<-#>/,'') - str.gsub!(/#{Mx[:br_eof]}/,'') - str.gsub!(/#{Mx[:br_endnotes]}/,'') + str=str.gsub(/\s*#{Mx[:mk_o]}:name#\S+?#{Mx[:mk_c]}\s*/,' '). + gsub(/.+?<-#>/,''). + gsub(/#{Mx[:br_eof]}/,''). + gsub(/#{Mx[:br_endnotes]}/,''). #problem sequence -> - str.gsub!(/&(?:lt|#060);/,'<') # < SiSU special character also LaTeX - str.gsub!(/#{Mx[:gl_o]}#(?:gt|062)#{Mx[:gl_c]}/,'>') # > SiSU special character also LaTeX - str.gsub!(/#{Mx[:gl_o]}#123#{Mx[:gl_c]}/,'{') # { SiSU special character also LaTeX - str.gsub!(/#{Mx[:gl_o]}#125#{Mx[:gl_c]}/,'}') # } SiSU special character also LaTeX - str.gsub!(/#{Mx[:gl_o]}#(?:126|152)#{Mx[:gl_c]}/,'~') # ~ SiSU special character also LaTeX - str.gsub!(/#{Mx[:gl_o]}#035#{Mx[:gl_c]}/,'#') # # SiSU special character also LaTeX - str.gsub!(/#{Mx[:gl_o]}#033#{Mx[:gl_c]}/,'!') # ! SiSU not really special sisu character but done, also LaTeX - #str.gsub!(/(^|\s)\*\s/,'\1\asterisk ') # * should you wish to escape astrisk e.g. describing \*{bold}* - str.gsub!(/#{Mx[:gl_o]}#042#{Mx[:gl_c]}/,'*') # * should you wish to escape astrisk e.g. describing \*{bold}* - str.gsub!(/#{Mx[:gl_o]}#045#{Mx[:gl_c]}/,'-') # - SiSU special character also LaTeX - str.gsub!(/#{Mx[:gl_o]}#043#{Mx[:gl_c]}/,'+') # + SiSU special character also LaTeX - str.gsub!(/#{Mx[:gl_o]}#044#{Mx[:gl_c]}/,',') # + SiSU special character also LaTeX - str.gsub!(/#{Mx[:gl_o]}#038#{Mx[:gl_c]}/,'&') #unless @txt=~/<:code>/ # / SiSU special character also LaTeX - str.gsub!(/#{Mx[:gl_o]}#047#{Mx[:gl_c]}/,'/') # / SiSU special character also LaTeX - str.gsub!(/#{Mx[:gl_o]}#092#{Mx[:gl_c]}/,'\\') # \ SiSU special character also LaTeX - str.gsub!(/#{Mx[:gl_o]}#095#{Mx[:gl_c]}/,'_') # _ SiSU special character also LaTeX - str.gsub!(/#{Mx[:gl_o]}#124#{Mx[:gl_c]}/,'|') # | SiSU not really special sisu character but done, also LaTeX - str.gsub!(/#{Mx[:gl_o]}#058#{Mx[:gl_c]}/,':') # : SiSU not really special sisu character but done, also LaTeX - str.gsub!(/#{Mx[:gl_o]}#094#{Mx[:gl_c]}|\^/,'^') # ^ SiSU not really special sisu character but done, also LaTeX + gsub(/&(?:lt|#060);/,'<'). # < SiSU special character also LaTeX + gsub(/#{Mx[:gl_o]}#(?:gt|062)#{Mx[:gl_c]}/,'>'). # > SiSU special character also LaTeX + gsub(/#{Mx[:gl_o]}#123#{Mx[:gl_c]}/,'{'). # { SiSU special character also LaTeX + gsub(/#{Mx[:gl_o]}#125#{Mx[:gl_c]}/,'}'). # } SiSU special character also LaTeX + gsub(/#{Mx[:gl_o]}#(?:126|152)#{Mx[:gl_c]}/,'~'). # ~ SiSU special character also LaTeX + gsub(/#{Mx[:gl_o]}#035#{Mx[:gl_c]}/,'#'). # # SiSU special character also LaTeX + gsub(/#{Mx[:gl_o]}#033#{Mx[:gl_c]}/,'!'). # ! SiSU not really special sisu character but done, also LaTeX + #gsub(/(^|\s)\*\s/,'\1\asterisk '). # * should you wish to escape astrisk e.g. describing \*{bold}* + gsub(/#{Mx[:gl_o]}#042#{Mx[:gl_c]}/,'*'). # * should you wish to escape astrisk e.g. describing \*{bold}* + gsub(/#{Mx[:gl_o]}#045#{Mx[:gl_c]}/,'-'). # - SiSU special character also LaTeX + gsub(/#{Mx[:gl_o]}#043#{Mx[:gl_c]}/,'+'). # + SiSU special character also LaTeX + gsub(/#{Mx[:gl_o]}#044#{Mx[:gl_c]}/,','). # + SiSU special character also LaTeX + gsub(/#{Mx[:gl_o]}#038#{Mx[:gl_c]}/,'&'). #unless @txt=~/<:code>/ # / SiSU special character also LaTeX + gsub(/#{Mx[:gl_o]}#047#{Mx[:gl_c]}/,'/'). # / SiSU special character also LaTeX + gsub(/#{Mx[:gl_o]}#092#{Mx[:gl_c]}/,'\\'). # \ SiSU special character also LaTeX + gsub(/#{Mx[:gl_o]}#095#{Mx[:gl_c]}/,'_'). # _ SiSU special character also LaTeX + gsub(/#{Mx[:gl_o]}#124#{Mx[:gl_c]}/,'|'). # | SiSU not really special sisu character but done, also LaTeX + gsub(/#{Mx[:gl_o]}#058#{Mx[:gl_c]}/,':'). # : SiSU not really special sisu character but done, also LaTeX + gsub(/#{Mx[:gl_o]}#094#{Mx[:gl_c]}|\^/,'^'). # ^ SiSU not really special sisu character but done, also LaTeX ##watch placement, problem sequence ^ - str.gsub!(/<sup><font face=symbol>&atild;<\/font><\/sup>/,' ') - str.gsub!(/\\copy(right|mark)?/,'<=copymark>') # ok problem with superscript - str + gsub(/<sup><font face=symbol>&atild;<\/font><\/sup>/,' '). + gsub(/\\copy(right|mark)?/,'<=copymark>') # ok problem with superscript end - def xetex_special_characters_1(str,is='') # ~ ^ $ & % _ { } #LaTeX special characters - KEEP list + def xetex_special_characters_1(str,is=:default) # ~ ^ $ & % _ { } #LaTeX special characters - KEEP list #str=Iconv.conv('ISO-8859-1', 'UTF-8', @txt) # `require': iconv will be deprecated in the future, use String#encode instead. word=str.scan(/\S+|\n/) #unless line =~/^(?:@\S|%+\s)/ para_array=[] @@ -1232,155 +1239,150 @@ WOK if w !~/https?:/ \ and w=~/\/\S+?\// \ and w.length > 6 - w.gsub!(/([_.\/])/,'\1\-') + w=w.gsub(/([_.\/])/,'\1\-') end - w.gsub!(/#{Mx[:gl_o]}#lt#{Mx[:gl_c]}/,'<'); w.gsub!(/#{Mx[:gl_o]}#gt#{Mx[:gl_c]}/,'>') - w.gsub!(/[\\]?~/,'<=tilde>') - w.gsub!(/[#{Mx[:br_line]}#{Mx[:br_paragraph]}]/,' \newline ') #watch - w.gsub!(/#{Mx[:gl_o]}#(?:126|152)#{Mx[:gl_c]}/,'<=tilde>') #126 usual - w.gsub!(/\\?\||#{Mx[:gl_o]}#124#{Mx[:gl_c]}/,'\pipe') #unless is=='code' #unless w=~/<~\d+;(?:[ohmu]|[0-6]:)\d+;\w\d+>/ # | SiSU not really special sisu character but done, also LaTeX + w=w.gsub(/#{Mx[:gl_o]}#lt#{Mx[:gl_c]}/,'<').gsub(/#{Mx[:gl_o]}#gt#{Mx[:gl_c]}/,'>'). + gsub(/[\\]?~/,'<=tilde>'). + gsub(/[#{Mx[:br_line]}#{Mx[:br_paragraph]}]/,' \newline '). #watch + gsub(/#{Mx[:gl_o]}#(?:126|152)#{Mx[:gl_c]}/,'<=tilde>'). #126 usual + gsub(/\\?\||#{Mx[:gl_o]}#124#{Mx[:gl_c]}/,'\pipe') #unless is=='code' #unless w=~/<~\d+;(?:[ohmu]|[0-6]:)\d+;\w\d+>/ # | SiSU not really special sisu character but done, also LaTeX if w !~/#{Mx[:rel_o]}/ \ and w !~/#{Mx[:gl_o]}#/ - w.gsub!(/\#/,'<=hash>') + w=w.gsub(/\#/,'<=hash>') end para_array << w end str=para_array.join(' ') - str=str.strip unless is=='code' + str=str.strip unless is==:code str else '' end - str.gsub(/\s*#{Mx[:mk_o]}:name#\S+?#{Mx[:mk_c]}\s*/,' ') - str.gsub!(/.+?<-#>/,'') - str.gsub!(/#{Mx[:br_eof]}/,'') - str.gsub!(/#{Mx[:br_endnotes]}/,'') + str=str.gsub(/\s*#{Mx[:mk_o]}:name#\S+?#{Mx[:mk_c]}\s*/,' '). + gsub(/.+?<-#>/,''). + gsub(/#{Mx[:br_eof]}/,''). + gsub(/#{Mx[:br_endnotes]}/,'') #problem sequence -> - str.gsub!(/&(?:nbsp);|#{Mx[:nbsp]}/,'\hardspace') unless is=='code' # < SiSU special character also LaTeX - str.gsub!(/&(?:lt|#060);/,'\lt') # < SiSU special character also LaTeX - str.gsub!(/#{Mx[:gl_o]}#(?:gt|062)#{Mx[:gl_c]}/,'\gt') # > SiSU special character also LaTeX - str.gsub!(/#{Mx[:gl_o]}#123#{Mx[:gl_c]}/,'\curlyopen') # { SiSU special character also LaTeX - str.gsub!(/#{Mx[:gl_o]}#125#{Mx[:gl_c]}/,'\curlyclose') # } SiSU special character also LaTeX - str.gsub!(/#{Mx[:gl_o]}#(?:126|152)#{Mx[:gl_c]}/,'<=tilde>') # ~ SiSU special character also LaTeX - str.gsub!(/#{Mx[:gl_o]}#035#{Mx[:gl_c]}/,'\#') # # SiSU special character also LaTeX - str.gsub!(/#{Mx[:gl_o]}#033#{Mx[:gl_c]}/,'!') # ! SiSU not really special sisu character but done, also LaTeX - str.gsub!(/(^|\s)\*\s/,'\1\asterisk ') # * should you wish to escape astrisk e.g. describing \*{bold}* - str.gsub!(/#{Mx[:gl_o]}#042#{Mx[:gl_c]}/,'\*') # * should you wish to escape astrisk e.g. describing \*{bold}* - str.gsub!(/#{Mx[:gl_o]}#045#{Mx[:gl_c]}/,'-') # - SiSU special character also LaTeX - str.gsub!(/#{Mx[:gl_o]}#043#{Mx[:gl_c]}/,'+') # + SiSU special character also LaTeX - str.gsub!(/#{Mx[:gl_o]}#044#{Mx[:gl_c]}/,',') # + SiSU special character also LaTeX - str.gsub!(/#{Mx[:gl_o]}#038#{Mx[:gl_c]}/,'<=amp>') #unless @txt=~/<:code>/ # / SiSU special character also LaTeX - str.gsub!(/#{Mx[:gl_o]}#047#{Mx[:gl_c]}/,'\slash') # / SiSU special character also LaTeX - str.gsub!(/#{Mx[:gl_o]}#092#{Mx[:gl_c]}/,'\textbackslash') # \ SiSU special character also LaTeX - str.gsub!(/#{Mx[:gl_o]}#095#{Mx[:gl_c]}/,'<=underscore>') # _ SiSU special character also LaTeX - str.gsub!(/#{Mx[:gl_o]}#124#{Mx[:gl_c]}/,'|') # | SiSU not really special sisu character but done, also LaTeX - str.gsub!(/#{Mx[:gl_o]}#058#{Mx[:gl_c]}/,':') # : SiSU not really special sisu character but done, also LaTeX - str.gsub!(/#{Mx[:gl_o]}#094#{Mx[:gl_c]}|\^/,'\caret') # ^ SiSU not really special sisu character but done, also LaTeX + str=str.gsub(/&(?:nbsp);|#{Mx[:nbsp]}/,'\hardspace') unless is==:code # < SiSU special character also LaTeX + str=str.gsub(/&(?:lt|#060);/,'\lt'). # < SiSU special character also LaTeX + gsub(/#{Mx[:gl_o]}#(?:gt|062)#{Mx[:gl_c]}/,'\gt'). # > SiSU special character also LaTeX + gsub(/#{Mx[:gl_o]}#123#{Mx[:gl_c]}/,'\curlyopen'). # { SiSU special character also LaTeX + gsub(/#{Mx[:gl_o]}#125#{Mx[:gl_c]}/,'\curlyclose'). # } SiSU special character also LaTeX + gsub(/#{Mx[:gl_o]}#(?:126|152)#{Mx[:gl_c]}/,'<=tilde>'). # ~ SiSU special character also LaTeX + gsub(/#{Mx[:gl_o]}#035#{Mx[:gl_c]}/,'\#'). # # SiSU special character also LaTeX + gsub(/#{Mx[:gl_o]}#033#{Mx[:gl_c]}/,'!'). # ! SiSU not really special sisu character but done, also LaTeX + gsub(/(^|\s)\*\s/,'\1\asterisk '). # * should you wish to escape astrisk e.g. describing \*{bold}* + gsub(/#{Mx[:gl_o]}#042#{Mx[:gl_c]}/,'\*'). # * should you wish to escape astrisk e.g. describing \*{bold}* + gsub(/#{Mx[:gl_o]}#045#{Mx[:gl_c]}/,'-'). # - SiSU special character also LaTeX + gsub(/#{Mx[:gl_o]}#043#{Mx[:gl_c]}/,'+'). # + SiSU special character also LaTeX + gsub(/#{Mx[:gl_o]}#044#{Mx[:gl_c]}/,','). # + SiSU special character also LaTeX + gsub(/#{Mx[:gl_o]}#038#{Mx[:gl_c]}/,'<=amp>'). #unless @txt=~/<:code>/ # / SiSU special character also LaTeX + gsub(/#{Mx[:gl_o]}#047#{Mx[:gl_c]}/,'\slash'). # / SiSU special character also LaTeX + gsub(/#{Mx[:gl_o]}#092#{Mx[:gl_c]}/,'\textbackslash'). # \ SiSU special character also LaTeX + gsub(/#{Mx[:gl_o]}#095#{Mx[:gl_c]}/,'<=underscore>'). # _ SiSU special character also LaTeX + gsub(/#{Mx[:gl_o]}#124#{Mx[:gl_c]}/,'|'). # | SiSU not really special sisu character but done, also LaTeX + gsub(/#{Mx[:gl_o]}#058#{Mx[:gl_c]}/,':'). # : SiSU not really special sisu character but done, also LaTeX + gsub(/#{Mx[:gl_o]}#094#{Mx[:gl_c]}|\^/,'\caret'). # ^ SiSU not really special sisu character but done, also LaTeX ##watch placement, problem sequence ^ - str.gsub!(/<sup><font face=symbol>&atild;<\/font><\/sup>/,' ') - str.gsub!(/\\copy(right|mark)?/,'<=copymark>') # ok problem with superscript - str - end - def xetex_special_characters_2(str,is='') - str.gsub!(/#{Mx[:gl_o]}#156#{Mx[:gl_c]}/,'\oe ') - str.gsub!(/\$/,'\$') - str.gsub!(/\#/,'\#') - str.gsub!(/\%/,'\%') - str.gsub!(/\~/,'\~') #revist, should not be necessary to mark remaining tildes + gsub(/<sup><font face=symbol>&atild;<\/font><\/sup>/,' '). + gsub(/\\copy(right|mark)?/,'<=copymark>') # ok problem with superscript + end + def xetex_special_characters_2(str,is=:default) + str=str.gsub(/#{Mx[:gl_o]}#156#{Mx[:gl_c]}/,'\oe '). + gsub(/\$/,'\$'). + gsub(/\#/,'\#'). + gsub(/\%/,'\%'). + gsub(/\~/,'\~') #revist, should not be necessary to mark remaining tildes if str !~/^\s*#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}image\s/ - str.gsub!(/_/,'\_') + str=str.gsub(/_/,'\_') end - str.gsub!(/\{/,'\{') - str.gsub!(/\}/,'\}') - if is=='code' - str.gsub!(/&/,'{\\\&}') - str.gsub!(/\\~(\\\{)/,'{$\tilde$}\1') - str.gsub!(/(\\\})\\~/,'\1{$\tilde$}') - str.gsub!(/\\~(\[)/,'{$\tilde$}\1') - str.gsub!(/(\])\\~/,'\1{$\tilde$}') - str.gsub!(/<=tilde>/,'{$\tilde$}') - str.gsub!(/<=hash>/,'{\#}') + str=str.gsub(/\{/,'\{'). + gsub(/\}/,'\}') + str=if is==:code + str.gsub(/&/,'{\\\&}'). + gsub(/\\~(\\\{)/,'{$\tilde$}\1'). + gsub(/(\\\})\\~/,'\1{$\tilde$}'). + gsub(/\\~(\[)/,'{$\tilde$}\1'). + gsub(/(\])\\~/,'\1{$\tilde$}'). + gsub(/<=tilde>/,'{$\tilde$}'). + gsub(/<=hash>/,'{\#}') else - str.gsub!(/ |#{Mx[:nbsp]}/,'~') # ~ character for hardspace - str.gsub!(/&/,'<=amp>') + str.gsub(/ |#{Mx[:nbsp]}/,'~'). # ~ character for hardspace + gsub(/&/,'<=amp>') end - str.gsub!(/&\S+?;/,' ') - str.gsub!(/§/u,'\S') #latex: space between next character not preserved? #str.gsub!(/§ /,'\S ') - str.gsub!(/£/u,'\pounds') - str.gsub!(/<a href=".+?">/,' ') - str.gsub!(/<\/a>/,' ') - str.gsub!(/((?:^|\s)#{Mx[:lnk_c]})#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/, - '\1\begin{scriptsize}\url{\2}\end{scriptsize}\3') #special case \{ e.g. \}http://url - str.gsub!(/#{Mx[:url_o]}\\_(\S+?)#{Mx[:url_c]}/, - '\begin{scriptsize}\url{\1}\end{scriptsize}') #special case \{ e.g. \}http://url - str.gsub!(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/, - '\begin{scriptsize}\\url{\1}\end{scriptsize}') #specially escaped url no decoration - unless is=='code' - str.gsub!(/(^|#{Mx[:gl_c]}|\s)((?:https?|file|ftp):\/\/\S+?\.[^'"\s]+?)([;.,]?(?=\s|$))/, + str=str.gsub(/&\S+?;/,' '). + gsub(/§/u,'\S'). #latex: space between next character not preserved? #str.gsub(/§ /,'\S ') + gsub(/£/u,'\pounds'). + gsub(/<a href=".+?">/,' '). + gsub(/<\/a>/,' '). + gsub(/((?:^|\s)#{Mx[:lnk_c]})#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/, + '\1\begin{scriptsize}\url{\2}\end{scriptsize}\3'). #special case \{ e.g. \}http://url + gsub(/#{Mx[:url_o]}\\_(\S+?)#{Mx[:url_c]}/, + '\begin{scriptsize}\url{\1}\end{scriptsize}'). #special case \{ e.g. \}http://url + gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/, + '\begin{scriptsize}\\url{\1}\end{scriptsize}') #specially escaped url no decoration + unless is==:code + str=str.gsub(/(^|#{Mx[:gl_c]}|\s)((?:https?|file|ftp):\/\/\S+?\.[^'"\s]+?)([;.,]?(?=\s|$))/, "\\1#{@brace_url.tex_open}\\begin{scriptsize}\\url{\\2}\\end{scriptsize}#{@brace_url.tex_close}\\3") #url matching with decoration <url> positive lookahead, sequence issue with { linked }http://url cannot use \b at start - else #code-block: angle brackets special characters, note _ already escaped - str.gsub!(/\\_</m,'{\UseTextSymbol{OML}{<}}') - str.gsub!(/\\_>/m,'{\UseTextSymbol{OML}{>}}') end - str.gsub!(/<:ee>/,'') - str.gsub!(/<!>/,' ') + str=str.gsub(/<:ee>/,''). + gsub(/<!>/,' '). #proposed change, insert, but may be redundant - str.gsub!(/<(br|p)>|<\/\s*(br|p)>|<(br|p)\s*\/>/," #{Tex[:backslash]*2} ") # Work Area - str.gsub!(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'\begin{bfseries}\1 \end{bfseries}') - str.gsub!(/<h\d+>(.+?)<\/h\d+>/,'\begin{bfseries}\1 \end{bfseries}') - str.gsub!(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'\emph{\1}') - str.gsub!(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'\uline{\1}') # ulem - str.gsub!(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,"``\\1''") # quote #CHECK - str.gsub!(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'\uline{\1}') # ulem - str.gsub!(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'\sout{\1}') # ulem - str.gsub!(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,"\$^{\\textrm{\\1}}\$") - str.gsub!(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,"\$_{\\textrm{\\1}}\$") - str.gsub!(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/,'\begin{monosp}\1\end{monosp}') - unless is=='code' - str.gsub!(/"(.+?)"/,'“\1”') # quote marks / quotations open & close " need condition exclude for code - str.gsub!(/\s+"/,' “') # open " - str.gsub!(/^(#{Mx[:lv_o]}[1-6-]:\S*?#{Mx[:lv_c]}|<.+?>)?\s*"/,'\1“') #fix Mx[:lv_o] # open " - str.gsub!(/"(\s|\.|,|:|;)/,'”\1') # close " - str.gsub!(/"(#{Mx[:lv_o]}[1-6-]:\S*?#{Mx[:lv_c]}|<.+?>)?\s*$/,'”\1') #fix Mx[:lv_o] # close " - str.gsub!(/"(\.|,)/,'”') # close " - str.gsub!(/\s+'/,' `') # open ' - str.gsub!(/^(#{Mx[:lv_o]}[1-6-]:\S*?#{Mx[:lv_c]}|<.+?>)?\s*'/,'\1`') #fix Mx[:lv_o] # open ' + gsub(/<(br|p)>|<\/\s*(br|p)>|<(br|p)\s*\/>/," #{Tex[:backslash]*2} "). # Work Area + gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'\begin{bfseries}\1 \end{bfseries}'). + gsub(/<h\d+>(.+?)<\/h\d+>/,'\begin{bfseries}\1 \end{bfseries}'). + gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'\emph{\1}'). + gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'\uline{\1}'). # ulem + gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,"``\\1''"). # quote #CHECK + gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'\uline{\1}'). # ulem + gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'\sout{\1}'). # ulem + gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,"\$^{\\textrm{\\1}}\$"). + gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,"\$_{\\textrm{\\1}}\$"). + gsub(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/,'\begin{monosp}\1\end{monosp}') + unless is==:code + str=str.gsub(/"(.+?)"/,'“\1”'). # quote marks / quotations open & close " need condition exclude for code + gsub(/\s+"/,' “'). # open " + gsub(/^(#{Mx[:lv_o]}[1-6-]:\S*?#{Mx[:lv_c]}|<.+?>)?\s*"/,'\1“'). #fix Mx[:lv_o] # open " + gsub(/"(\s|\.|,|:|;)/,'”\1'). # close " + gsub(/"(#{Mx[:lv_o]}[1-6-]:\S*?#{Mx[:lv_c]}|<.+?>)?\s*$/,'”\1'). #fix Mx[:lv_o] # close " + gsub(/"(\.|,)/,'”'). # close " + gsub(/\s+'/,' `'). # open ' + gsub(/^(#{Mx[:lv_o]}[1-6-]:\S*?#{Mx[:lv_c]}|<.+?>)?\s*'/,'\1`') #fix Mx[:lv_o] # open ' end - str.gsub!(/(<font.*?>|<\/font>)/,'') - str.gsub!(/\s*#{Mx[:fa_superscript_o]}(\S+?)#{Mx[:fa_superscript_c]}/,'^\1') + str=str.gsub(/(<font.*?>|<\/font>)/,''). + gsub(/\s*#{Mx[:fa_superscript_o]}(\S+?)#{Mx[:fa_superscript_c]}/,'^\1') str end def xetex_special_characters_3(str) - str.gsub!(/<br(\s*[^\/][^>])/,'\1') # clean up, incredibly messy :-( footnote indents, problems if match exists in ordinary paragraphs? check! Work Area 200501 a bit tricky as must be able to match multiple times, and to clean remainder - str.gsub!(/([^<][^b][^r]\s+)\/>/,'\1') # clean up, incredibly messy :-( footnote indents, problems if match exists in ordinary paragraphs? check! Work Area 200501 a bit tricky as must be able to match multiple times, and to clean remainder + str=str.gsub(/<br(\s*[^\/][^>])/,'\1'). # clean up, incredibly messy :-( footnote indents, problems if match exists in ordinary paragraphs? check! Work Area 200501 a bit tricky as must be able to match multiple times, and to clean remainder + gsub(/([^<][^b][^r]\s+)\/>/,'\1') # clean up, incredibly messy :-( footnote indents, problems if match exists in ordinary paragraphs? check! Work Area 200501 a bit tricky as must be able to match multiple times, and to clean remainder while str =~/(https?:\/\/\S+?)(?:<=tilde>\S+)+/ #tilde in urls \href treated differently from text #FIX - str.gsub!(/(https?:\/\/\S+?)(?:<=tilde>(\S+))+/,'\1~\2') + str=str.gsub(/(https?:\/\/\S+?)(?:<=tilde>(\S+))+/,'\1~\2') end - str.gsub!(/<=tilde>/,'{$\tilde$}') - str.gsub!(/(https?:\/\/\S+?)(?:(?:<=hash>)(\S+))+/,'\1#\2') #hash in urls \href treated differently from text #FIX - str.gsub!(/<=hash>/,'{\#}') + str=str.gsub(/<=tilde>/,'{$\tilde$}'). + gsub(/(https?:\/\/\S+?)(?:(?:<=hash>)(\S+))+/,'\1#\2'). #hash in urls \href treated differently from text #FIX + gsub(/<=hash>/,'{\#}') while str =~/(https?:\/\/\S+?)(?:<=amp>\S+)+/ #amp in urls \href treated differently from text #FIX - str.gsub!(/(https?:\/\/\S+?)(?:<=amp>(\S+))+/,'\1&\2') + str=str.gsub(/(https?:\/\/\S+?)(?:<=amp>(\S+))+/,'\1&\2') end - str.gsub!(/<=amp>/,'{\\\&}') #changed ... 2005 - str.gsub!(/<=copymark>\s*(.+)/, - '^\copyright \textnormal{\1} \2') # watch likely to be problematic + str=str.gsub(/<=amp>/,'{\\\&}'). #changed ... 2005 + gsub(/<=copymark>\s*(.+)/, + '^\copyright \textnormal{\1} \2') # watch likely to be problematic str end def special_characters_safe_close(str) - str.gsub!(/<=tilde>/,'{$\tilde$}') - str.gsub!(/<=hash>/,'{\#}') - str.gsub!(/<=amp>/,'{\\\&}') #changed ... 2005 - str.gsub!(/<=copymark>\s*(.+)/, - '^\copyright \textnormal{\1} \2') # watch likely to be problematic - str + str=str.gsub(/<=tilde>/,'{$\tilde$}'). + gsub(/<=hash>/,'{\#}'). + gsub(/<=amp>/,'{\\\&}'). #changed ... 2005 + gsub(/<=copymark>\s*(.+)/, + '^\copyright \textnormal{\1} \2') # watch likely to be problematic end def special_characters_code_fix(str) - str.gsub!(/<=tilde>/,'{$\tilde$}') + str=str.gsub(/<=tilde>/,'{$\tilde$}') str end def special_characters_unsafe_1(str) #depreciated, make obsolete # some substitutions are sequence sensitive, rearrange with care. - str.gsub!(/\\textbackslash (copyright|clearpage|newpage)/,"\\\\\\1") #kludge bad solution, find out where tail is sent through specChar ! + str=str.gsub(/\\textbackslash (copyright|clearpage|newpage)/,"\\\\\\1") #kludge bad solution, find out where tail is sent through specChar ! str end def special_characters #special characters - some substitutions are sequence sensitive, rearrange with care. @@ -1393,8 +1395,8 @@ WOK end def special_word_break_points str=@txt - str.gsub!(/([_,.;:\/|=])/,'\1\-') - str.gsub!(/(--)(\S{4,})/,'\1\-\2') + str=str.gsub(/([_,.;:\/|=])/,'\1\-'). + gsub(/(--)(\S{4,})/,'\1\-\2') @txt=str end def special_number_break_points @@ -1416,16 +1418,16 @@ WOK end def special_characters_code str=@txt - str.gsub!(/ \\\\([ #{Mx[:br_nl]}]+|$)/,' \textbackslash\textbackslash\hardspace\1') + str=str.gsub(/ \\\\([ #{Mx[:br_nl]}]+|$)/,' \textbackslash\textbackslash\hardspace\1') str end end - class Use_TeX + class UseTeX attr_accessor :url,:txt,:date def initialize(md) @md=md - @vz=SiSU_Env::Get_init.instance.skin - @date=SiSU_Env::Info_date.new # #{@date.year} + @vz=SiSU_Env::GetInit.instance.skin + @date=SiSU_Env::InfoDate.new # #{@date.year} @copymark='{\\begin{footnotesize}\\raisebox{1ex}{\\copyright}\\end{footnotesize}}' @brace_url=SiSU_Viz::Skin.new.url_decoration end @@ -1499,7 +1501,7 @@ WOK end end def sisu_rights - v=SiSU_Env::Info_version.instance.get_version + v=SiSU_Env::InfoVersion.instance.get_version base_prog_txt=if @md.base_program case @md.base_program when /kdissert/i; "\n\\\\ This document prepared using \\href{http://freehackers.org/~tnagy/kdissert/}{Kdissert \\ http://freehackers.org/~tnagy/kdissert/ } \\\\ Kdissert is Document Mapping software by Thomas Nagy" @@ -1527,7 +1529,7 @@ WOK " \\footnote{%\nGenerated by \\href{http://www.jus.uio.no/sisu}{SiSU} \\ \\href{http://www.jus.uio.no/sisu}{www.jus.uio.no/sisu} \\newline \\href{http://www.sisudoc.org}{www.sisudoc.org} \\\n}" end def doc_sc_info - v=SiSU_Env::Info_version.instance.get_version + v=SiSU_Env::InfoVersion.instance.get_version <<WOK \\\\ {\\begin{footnotesize} @@ -1539,7 +1541,7 @@ Generated by \\href{http://www.jus.uio.no/sisu}{SiSU www.jus.uio.no/sisu }\\- ve WOK end def doc_no_sc_info - v=SiSU_Env::Info_version.instance.get_version + v=SiSU_Env::InfoVersion.instance.get_version <<WOK \\\\ {\\begin{small} @@ -1560,9 +1562,9 @@ WOK WOK end def doc_tail - dir=SiSU_Env::Info_env.new(@md.fns) + dir=SiSU_Env::InfoEnv.new(@md.fns) base_html="#{dir.url.root}/#{@md.fnb}" - v=SiSU_Env::Info_version.instance.get_version + v=SiSU_Env::InfoVersion.instance.get_version sisu_ico=if FileTest.file?("#{dir.path.image_source_include}/sisu.png") "\\includegraphics*[width=60pt]{#{dir.path.image_source_include}/sisu.png}" else @@ -1600,7 +1602,7 @@ WOK WOK end def mail_tail #not retested, the old mail_tail is commented out and appended to this program - dir=SiSU_Env::Info_env.new(@md.fns) + dir=SiSU_Env::InfoEnv.new(@md.fns) <<WOK \\subsection*{Mail sender details} \\addcontentsline{toc}{subsection}{Mail sender details} diff --git a/lib/sisu/v3/update.rb b/lib/sisu/v3/update.rb index 5b5430e2..f4ad275c 100644 --- a/lib/sisu/v3/update.rb +++ b/lib/sisu/v3/update.rb @@ -56,7 +56,7 @@ ** Description: update previous output (with similar output file type formats) =end -module SiSU_Update_control_flag +module SiSU_UpdateControlFlag require_relative 'sysenv' # sysenv.rb include SiSU_Env include SiSU_Param @@ -67,23 +67,23 @@ module SiSU_Update_control_flag end def read begin - @env=SiSU_Env::Info_env.new(@md.fns) + @env=SiSU_Env::InfoEnv.new(@md.fns) out=@env.path.output base_path="#{out}/#{@md.fnb}" SiSU_Screen::Ansi.new(@md.opt.cmd,'Checking previous output',base_path).green_hi_blue unless @md.opt.cmd =~/q/ - Set_CF.new(@md).set_flags - rescue; SiSU_Errors::Info_error.new($!,$@,@md.opt.cmd,@md.fns).error + SetCF.new(@md).set_flags + rescue; SiSU_Errors::InfoError.new($!,$@,@md.opt.cmd,@md.fns).error ensure end end private - class Set_CF + class SetCF def initialize(md) @md=md - @env=SiSU_Env::Info_env.new(@md.fns) + @env=SiSU_Env::InfoEnv.new(@md.fns) out=@env.path.output @base_path="#{out}/#{@md.fnb}" - @pdf_fn=SiSU_Env::SiSU_file.new(@md).base_filename + @pdf_fn=SiSU_Env::FileOp.new(@md).base_filename end def set_flags #-mNhwpoabxXyv flag='-v' diff --git a/lib/sisu/v3/urls.rb b/lib/sisu/v3/urls.rb index a2385376..31614a37 100644 --- a/lib/sisu/v3/urls.rb +++ b/lib/sisu/v3/urls.rb @@ -56,7 +56,7 @@ ** Description: urls for output files =end -module SiSU_urls +module SiSU_Urls require_relative 'particulars' # particulars.rb include SiSU_Particulars require_relative 'sysenv' # sysenv.rb @@ -68,24 +68,24 @@ module SiSU_urls end def read begin - SiSU_urls::Output_urls.new(@opt).songsheet if @opt.fnb - rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd).error + SiSU_Urls::OutputUrls.new(@opt).songsheet if @opt.fnb + rescue; SiSU_Errors::InfoError.new($!,$@,@opt.cmd).error ensure end end end - class Output_urls + class OutputUrls attr_reader :fns,:fnb,:cmd,:dir,:m_regular,:u def initialize(opt) @opt=opt - @particulars=SiSU_Particulars::Combined_singleton.instance.get_env_md(opt) + @particulars=SiSU_Particulars::CombinedSingleton.instance.get_env_md(opt) @cmd=@opt.cmd @md=@particulars.md @env=@particulars.env @fnb=@env.fnb - fn_set_lang=SiSU_Env::Standardise_language.new(@opt.lng).language + fn_set_lang=SiSU_Env::StandardiseLanguage.new(@opt.lng).language @fnl=@env.i18n.lang_filename(fn_set_lang[:c]) - @fn=SiSU_Env::Env_call.new(@opt.fns).lang(fn_set_lang[:c]) + @fn=SiSU_Env::EnvCall.new(@opt.fns).lang(fn_set_lang[:c]) @m_regular=/(.+?)\.(?:(?:-|ssm\.)?sst|ssm)$/ @prog=@env.program source=if @opt.fns =~/\.sst$/; @opt.fns @@ -124,7 +124,7 @@ module SiSU_urls def songsheet begin @opt.cmd=~/U/ ? urls_all : (urls_select unless @opt.cmd=~/q/) - rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error + rescue; SiSU_Errors::InfoError.new($!,$@,@opt.cmd,@opt.fns).error ensure end end @@ -215,7 +215,7 @@ module SiSU_urls SiSU_Screen::Ansi.new(@opt.cmd,"[#{@opt.f_pth[:lng_is]}] -#{x} DBI psql","#{@pwd_stub}::#{@opt.fns}",y).result end def sqlite(x,y) - SiSU_Screen::Ansi.new(@opt.cmd,"[#{@opt.f_pth[:lng_is]}] -#{x} DBI sqlite","sqlite3 #{@env.path.webserv}/#{@md.opt.f_pth[:pth_stub]}/sisu_sqlite.db", "#{y}").result + SiSU_Screen::Ansi.new(@opt.cmd,"[#{@opt.f_pth[:lng_is]}] -#{x} DBI sqlite","sqlite3 #{@md.file.output_path.sqlite_discreet.dir}/#{@md.file.base_filename.sqlite_discreet}\n sqlite3 #{@env.path.webserv}/#{@md.opt.f_pth[:pth_stub]}/sisu_sqlite.db\n", "#{y}").result end self end diff --git a/lib/sisu/v3/webrick.rb b/lib/sisu/v3/webrick.rb index 88fb67ef..42281321 100644 --- a/lib/sisu/v3/webrick.rb +++ b/lib/sisu/v3/webrick.rb @@ -61,7 +61,7 @@ def brick(port,get='') cgidir=if get=~/pwd/; Dir.pwd else '/usr/lib/cgi-bin' # @env.path.cgi end - port=SiSU_Env::Info_port.new.webrick + port=SiSU_Env::InfoPort.new.webrick begin s=HTTPServer.new( Port: port, @@ -75,7 +75,7 @@ def brick(port,get='') s.mount('/cgi-bin', HTTPServlet::FileHandler, cgi_dir, { FancyIndexing: true }) trap("INT"){ s.shutdown } s.start - rescue; SiSU_Errors::Info_error.new($!,$@,'-W',nil).error #fix + rescue; SiSU_Errors::InfoError.new($!,$@,'-W',nil).error #fix ensure end end @@ -86,8 +86,8 @@ begin # require_relative 'sysenv' # sysenv.rb include SiSU_Env; include SiSU_Screen @cX=SiSU_Screen::Ansi.new('yes').cX - @env=SiSU_Env::Info_env.new - port=SiSU_Env::Info_port.new + @env=SiSU_Env::InfoEnv.new + port=SiSU_Env::InfoPort.new @argv=$* @host=@env.url.webrick host='localhost' @@ -168,7 +168,7 @@ WOK brick(@port,get) rescue; require_relative 'sysenv' # sysenv.rb - SiSU_Errors::Info_error.new($!,$@,'-W',nil).error #fix + SiSU_Errors::InfoError.new($!,$@,'-W',nil).error #fix ensure end __END__ diff --git a/lib/sisu/v3/wikispeak.rb b/lib/sisu/v3/wikispeak.rb index a524981b..955432c0 100644 --- a/lib/sisu/v3/wikispeak.rb +++ b/lib/sisu/v3/wikispeak.rb @@ -76,7 +76,7 @@ module SiSU_Wikispeak def read begin @md=SiSU_Param::Parameters.new(@opt).get - @env=SiSU_Env::Info_env.new(@opt.fns) + @env=SiSU_Env::InfoEnv.new(@opt.fns) path=@env.path.output_tell tool=(@opt.cmd =~/[MVv]/) \ ? "#{@env.program.text_editor} #{path}/#{@md.fnb}/#{@md.fn[:wiki]}" @@ -85,13 +85,13 @@ module SiSU_Wikispeak SiSU_Screen::Ansi.new(@opt.cmd,@opt.fns,"#{@env.path.output_tell}/#{@md.fnb}/#{@md.fn[:wiki]}").flow if @opt.cmd =~/[MV]/ @dal_array=SiSU_DAL::Source.new(@opt).get # dal file drawn here SiSU_Wikispeak::Source::Scroll.new(@dal_array,@md).songsheet - SiSU_Env::Info_skin.new(@md).select #watch - rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error + SiSU_Env::InfoSkin.new(@md).select #watch + rescue; SiSU_Errors::InfoError.new($!,$@,@opt.cmd,@opt.fns).error ensure end end private - class Split_text_object <Source + class SplitTextObject <Source require_relative 'plaintext_format' # plaintext_format.rb include Format include SiSU_Viz @@ -101,7 +101,7 @@ module SiSU_Wikispeak def initialize(para) @para=para @format,@ocn='ordinary','ordinary' - @dp=@@dp ||=SiSU_Env::Info_env.new.digest.pattern + @dp=@@dp ||=SiSU_Env::InfoEnv.new.digest.pattern end def lev_segname_para_ocn @text=nil @@ -132,23 +132,23 @@ module SiSU_Wikispeak end format=@format.dup @lev_para_ocn=if @para =~/.+#{Mx[:id_o]}~\d+;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{#Mx[:id_c]}$/ - Format::Format_text_object.new(format,@text,@ocn) + Format::FormatTextObject.new(format,@text,@ocn) else - Format::Format_text_object.new(format,@text,"#{Mx[:id_o]}~(\d+);[um]\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}") + Format::FormatTextObject.new(format,@text,"#{Mx[:id_o]}~(\d+);[um]\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}") end self end end class Scroll <Source require_relative 'shared_txt' # shared_txt.rb - include SiSU_text_utils + include SiSU_TextUtils @@endnotes_para=[] @@wiki={ body: [], open: [], close: [], head: [], metadata: [], tail: [], endnotes: [] } @@dp=nil def initialize(data,md) @data,@md=data,md - @vz=SiSU_Env::Get_init.instance.skin - @dp=@@dp ||=SiSU_Env::Info_env.new.digest.pattern + @vz=SiSU_Env::GetInit.instance.skin + @dp=@@dp ||=SiSU_Env::InfoEnv.new.digest.pattern @regx=/^(?:(?:#{Mx[:br_line]}\s*|#{Mx[:br_nl]}\s*)?#{Mx[:lv_o]}\d:(\S*?)#{Mx[:lv_c]}\s*)?(.+)/ #fix Mx[:lv_o] #m # 2004w18 pb pn removal added @tab="\t" @@dostype='unix footnotes' @@ -164,7 +164,7 @@ module SiSU_Wikispeak @n=[] end def wiki_metadata(meta) - util=SiSU_text_utils::Wrap.new(meta.text,70,15,1) + util=SiSU_TextUtils::Wrap.new(meta.text,70,15,1) txt=util.line_wrap @@wiki[:metadata] <<= if meta.type=='meta' <<WOK @@ -175,8 +175,8 @@ WOK end end def wiki_tail - SiSU_Env::Info_skin.new(@md).select - vz=SiSU_Env::Get_init.instance.skin + SiSU_Env::InfoSkin.new(@md).select + vz=SiSU_Env::GetInit.instance.skin generator="Generated by: #{@md.sisu_version[:project]} #{@md.sisu_version[:version]} of #{@md.sisu_version[:date_stamp]} (#{@md.sisu_version[:date]})" if @md.sisu_version[:version] lastdone="Last Generated on: #{Time.now}" rubyv="Ruby version: #{@md.ruby_version}" @@ -227,7 +227,7 @@ WOK end def markup # Used for major markup instructions data=@data - dir=SiSU_Env::Info_env.new(@md.fns) + dir=SiSU_Env::InfoEnv.new(@md.fns) @data_mod,@endnotes,@level,@cont,@copen,@wiki_contents_close=Array.new(6){[]} (0..6).each { |x| @cont[x]=@level[x]=false } (4..6).each { |x| @wiki_contents_close[x]='' } @@ -257,16 +257,16 @@ WOK para.gsub!(/(?:^|[^_\\])#{Mx[:lnk_o]}\s*\S+?\.(?:png|jpg|gif)\s+.+?"(.*?)"\s*#{Mx[:lnk_c]}\S+/,'[image: "\1"]') wordlist=para.scan(/\S+/) if para =~/^@(\S+?):\s+(.+?)\Z/m # for headers - d_meta=SiSU_text_utils::Header_scan.new(@md,para).meta + d_meta=SiSU_TextUtils::HeaderScan.new(@md,para).meta if d_meta; wiki_metadata(d_meta) end end if para !~/(^@\S+?:|#{Mx[:br_endnotes]}|#{Mx[:br_eof]})/ if para =~@regx #/.+?<~\d+;\w\d+;\w\d+>.*/ #watch change paranum=para[@regx,3] - @p_num=Format::Paragraph_number.new(paranum) + @p_num=Format::ParagraphNumber.new(paranum) end - @sto=Split_text_object.new(para).lev_segname_para_ocn + @sto=SplitTextObject.new(para).lev_segname_para_ocn ### problem in scroll, it appears tables are getting paragraph numbers m=/#{Mx[:id_o]}~(\d+);(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/ if para =~m \ @@ -281,7 +281,7 @@ WOK when /^(3)~(?:(\S+))?/ wiki_structure(para,$1,@sto.ocn,$2) @sto.lev_para_ocn.heading_body3 - when /^(4)~(\S+)/ # work on see SiSU_text_parts::Split_text_object + when /^(4)~(\S+)/ # work on see SiSU_text_parts::SplitTextObject wiki_structure(para,$1,@sto.ocn,$2) @sto.lev_para_ocn.heading_body4 when /^(5)~(?:(\S+))?/ @@ -305,7 +305,7 @@ WOK elsif para =~/(#{Mx[:tc_p]}|#{Mx[:gr_o]}Th?)/u #tables ! #fix elsif para =~/(.*)<!#!>(.*)/ one,two=$1,$2 - format_text=Format_text_object.new(one,two) + format_text=FormatTextObject.new(one,two) para=format_text.seg_no_paranum end if (para =~/<a name="n\d+">/ \ @@ -315,12 +315,12 @@ WOK case para when /<:i1>/ if para =~/.*<:#>.*$/ - format_text=Format_text_object.new(para,'') + format_text=FormatTextObject.new(para,'') para=format_text.scr_indent_one_no_paranum end when /<:i2>/ if para =~/.*<:#>.*$/ - format_text=Format_text_object.new(para,'') + format_text=FormatTextObject.new(para,'') para=format_text.scr_indent_one_no_paranum end end @@ -329,7 +329,7 @@ WOK end if para =~/<:center>/ one,two=/(.*)<:center>(.*)/.match(para)[1,2] - format_text=Format_text_object.new(one,two) + format_text=FormatTextObject.new(one,two) para=format_text.center end para.gsub!(/<!.+!>/,' ') if para ## Clean Prepared Text @@ -355,8 +355,8 @@ WOK @content,@md=content,md end def wiki #%wiki output - SiSU_Env::SiSU_file.new(@md).mkdir - filename_wiki=SiSU_Env::SiSU_file.new(@md,@md.fn[:wiki]).mkfile + SiSU_Env::FileOp.new(@md).mkdir + filename_wiki=SiSU_Env::FileOp.new(@md,@md.fn[:wiki]).mkfile @sisu=[] @content.each do |para| # this is a hack if para =~/^\S/ diff --git a/lib/sisu/v3/xhtml.rb b/lib/sisu/v3/xhtml.rb index 6f8c6da5..c537275c 100644 --- a/lib/sisu/v3/xhtml.rb +++ b/lib/sisu/v3/xhtml.rb @@ -64,9 +64,9 @@ module SiSU_XHTML require_relative 'sysenv' # sysenv.rb include SiSU_Env require_relative 'shared_xml' # shared_xml.rb - include SiSU_XML_munge + include SiSU_XML_Munge require_relative 'xml_format' # xml_format.rb - include SiSU_XML_format + include SiSU_XML_Format require_relative 'rexml' # rexml.rb include SiSU_Rexml require_relative 'shared_metadata' # shared_metadata.rb @@ -75,7 +75,7 @@ module SiSU_XHTML class Source def initialize(opt) @opt=opt - @particulars=SiSU_Particulars::Combined_singleton.instance.get_all(opt) + @particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt) end def read begin @@ -95,7 +95,7 @@ module SiSU_XHTML SiSU_Screen::Ansi.new(@opt.cmd,@opt.fns,"/#{@md.file.output_path.xhtml.dir}/#{@md.file.base_filename.xhtml}").flow if @opt.cmd =~/[MV]/ end SiSU_XHTML::Source::Songsheet.new(@particulars).song - rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error + rescue; SiSU_Errors::InfoError.new($!,$@,@opt.cmd,@opt.fns).error ensure end end @@ -103,14 +103,14 @@ module SiSU_XHTML class Songsheet def initialize(particulars) @env,@md,@dal_array,@particulars=particulars.env,particulars.md,particulars.dal_array,particulars - @file=SiSU_Env::SiSU_file.new(@md) + @file=SiSU_Env::FileOp.new(@md) end def song begin SiSU_XHTML::Source::Scroll.new(@particulars).songsheet SiSU_XHTML::Source::Tidy.new(@md,@file.place_file.xhtml.dir).xml if @md.opt.cmd =~/[vVM]/ # test wellformedness, comment out when not in use SiSU_Rexml::Rexml.new(@md,@file.place_file.xhtml.dir).xml if @md.opt.cmd =~/M/ # test rexml parsing, comment out when not in use #debug - rescue; SiSU_Errors::Info_error.new($!,$@,@md.opt.cmd,@md.fns).error + rescue; SiSU_Errors::InfoError.new($!,$@,@md.opt.cmd,@md.fns).error ensure end end @@ -118,15 +118,15 @@ module SiSU_XHTML class Scroll require_relative 'shared_xhtml' # shared_xhtml.rb #check already called require_relative 'shared_txt' # shared_txt.rb - include SiSU_text_utils + include SiSU_TextUtils require_relative 'css' # css.rb @@xml={ body: [], sisu: [], open: [], close: [], head: [] } def initialize(particulars) @env,@md,@dal_array=particulars.env,particulars.md,particulars.dal_array - @vz=SiSU_Env::Get_init.instance.skin + @vz=SiSU_Env::GetInit.instance.skin @tab="\t" - @trans=SiSU_XML_munge::Trans.new(@md) - @sys=SiSU_Env::System_call.new + @trans=SiSU_XML_Munge::Trans.new(@md) + @sys=SiSU_Env::SystemCall.new end def songsheet pre @@ -136,39 +136,39 @@ module SiSU_XHTML end protected def embedded_endnotes(dob='') - dob.obj.gsub!(/#{Mx[:en_a_o]}(\d+)\s+(.+?)#{Mx[:en_a_c]}/, - '<endnote><number>\1</number><note>\2</note></endnote> ') - dob.obj.gsub!(/#{Mx[:en_b_o]}([*+]\d+)\s+(.+?)#{Mx[:en_b_c]}/, - '<endnote><symbol>\1</symbol><note>\2</note></endnote> ') - dob.obj.gsub!(/#{Mx[:en_a_o]}([*+]+)\s+(.+?)#{Mx[:en_a_c]}/, - '<endnote><symbol>\1</symbol><note>\2</note></endnote> ') + dob.obj=dob.obj.gsub(/#{Mx[:en_a_o]}(\d+)\s+(.+?)#{Mx[:en_a_c]}/, + '<endnote><number>\1</number><note>\2</note></endnote> '). + gsub(/#{Mx[:en_b_o]}([*+]\d+)\s+(.+?)#{Mx[:en_b_c]}/, + '<endnote><symbol>\1</symbol><note>\2</note></endnote> '). + gsub(/#{Mx[:en_a_o]}([*+]+)\s+(.+?)#{Mx[:en_a_c]}/, + '<endnote><symbol>\1</symbol><note>\2</note></endnote> ') end def extract_endnotes(dob='') notes=dob.obj.scan(/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]})([\d*+]+\s+.+?)(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/) notes.flatten.each do |e| s=e.to_s - util=SiSU_text_utils::Wrap.new(s,70) + util=SiSU_TextUtils::Wrap.new(s,70) wrap=util.line_wrap - wrap.gsub!(/^(\d+)\s+(.+?)\s*\Z/m, <<WOK + wrap=wrap.gsub(/^(\d+)\s+(.+?)\s*\Z/m, <<WOK #{Ax[:tab]*1}<endnote notenumber="\\1"> #{Ax[:tab]*2}\\1. \\2 #{Ax[:tab]*1}</endnote> WOK -) - wrap.gsub!(/^([*+]\d+)\s+(.+?)\s*\Z/m, <<WOK +). + gsub(/^([*+]\d+)\s+(.+?)\s*\Z/m, <<WOK #{Ax[:tab]*1}<endnote symbol="\\1"> #{Ax[:tab]*2}\\1 \\2 #{Ax[:tab]*1}</endnote> WOK -) - wrap.gsub!(/^([*+]+)\s+(.+?)\s*\Z/m, <<WOK +). + gsub(/^([*+]+)\s+(.+?)\s*\Z/m, <<WOK #{Ax[:tab]*1}<endnote symbol="\\1.length"> #{Ax[:tab]*2}\\1 \\2 #{Ax[:tab]*1}</endnote> WOK ) #KEEP alternative presentation of endnotes -# wrap.gsub!(/^(\d+)\s+(.+?)\s*\Z/m, <<WOK +# wrap=wrap.gsub(/^(\d+)\s+(.+?)\s*\Z/m, <<WOK ##{Ax[:tab]*1}<p class="endnote" notenumber="\\1"> ##{Ax[:tab]*2}\\1. \\2 ##{Ax[:tab]*1}</p> @@ -178,7 +178,7 @@ WOK end end def xml_head - metadata=Metadata::Summary.new(@md).xhtml_scroll.metadata + metadata=SiSU_Metadata::Summary.new(@md).xhtml_scroll.metadata @@xml[:head] << metadata end def name_tags(dob) @@ -192,18 +192,19 @@ WOK tags end def xml_structure(dob,type='norm') - if dob.is =~/para|heading/ + if dob.is ==:para \ + || dob.is ==:heading named=name_tags(dob) - if dob.is=='heading' + if dob.is==:heading lv=dob.ln n=dob.ln - 1 n3=dob.ln + 2 else lv=nil end extract_endnotes(dob) - dob.obj.gsub!(/#{Mx[:en_a_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_a_c]}/,'<en>\1</en>') #footnote/endnote clean - dob.obj.gsub!(/#{Mx[:en_b_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_b_c]}/,'<en>\1</en>') #footnote/endnote clean - util=SiSU_text_utils::Wrap.new(dob.obj,70) + dob.obj=dob.obj.gsub(/#{Mx[:en_a_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_a_c]}/,'<en>\1</en>'). #footnote/endnote clean + gsub(/#{Mx[:en_b_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_b_c]}/,'<en>\1</en>') #footnote/endnote clean + util=SiSU_TextUtils::Wrap.new(dob.obj,70) wrapped=util.line_wrap @@xml[:body] << if defined? dob.ocn %{#{Ax[:tab]*0}<object id="#{dob.ocn}">} @@ -220,9 +221,9 @@ WOK def block_structure(dob) named=name_tags(dob) dob=@trans.markup_block(dob) - dob.obj.strip! - dob.obj.gsub!(/#{Mx[:en_a_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_a_c]}/,'<en>\1</en>') #footnote/endnote clean - dob.obj.gsub!(/#{Mx[:en_b_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_b_c]}/,'<en>\1</en>') #footnote/endnote clean + dob.obj=dob.obj.strip. + gsub(/#{Mx[:en_a_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_a_c]}/,'<en>\1</en>'). #footnote/endnote clean + gsub(/#{Mx[:en_b_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_b_c]}/,'<en>\1</en>') #footnote/endnote clean @@xml[:body] << %{#{Ax[:tab]*0}<object id="#{dob.ocn}">} @@xml[:body] << %{#{Ax[:tab]*1}<ocn>#{dob.ocn}</ocn>} @@xml[:body] << %{#{Ax[:tab]*1}<text class="block">#{named}#{Ax[:tab]*1}} @@ -233,9 +234,9 @@ WOK def group_structure(dob) named=name_tags(dob) dob=@trans.markup_group(dob) - dob.obj.strip! - dob.obj.gsub!(/#{Mx[:en_a_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_a_c]}/,'<en>\1</en>') #footnote/endnote clean - dob.obj.gsub!(/#{Mx[:en_b_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_b_c]}/,'<en>\1</en>') #footnote/endnote clean + dob.obj=dob.obj.strip. + gsub(/#{Mx[:en_a_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_a_c]}/,'<en>\1</en>'). #footnote/endnote clean + gsub(/#{Mx[:en_b_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_b_c]}/,'<en>\1</en>') #footnote/endnote clean @@xml[:body] << %{#{Ax[:tab]*0}<object id="#{dob.ocn}">} @@xml[:body] << %{#{Ax[:tab]*1}<ocn>#{dob.ocn}</ocn>} @@xml[:body] << %{#{Ax[:tab]*1}<text class="group">#{named}#{Ax[:tab]*1}} @@ -246,7 +247,7 @@ WOK def poem_structure(dob) named=name_tags(dob) dob=@trans.markup_group(dob) - dob.obj.strip! + dob.obj=dob.obj.strip @@xml[:body] << %{#{Ax[:tab]*0}<object id="#{dob.ocn}">} @@xml[:body] << %{#{Ax[:tab]*1}<ocn>#{dob.ocn}</ocn>} @@xml[:body] << %{#{Ax[:tab]*1}<text class="verse">#{named}#{Ax[:tab]*1}} @@ -257,8 +258,7 @@ WOK def code_structure(dob) named=name_tags(dob) dob=@trans.markup_group(dob) - dob.obj.gsub!(/\s\s/,'  ') - dob.obj.strip! + dob.obj=dob.obj.gsub(/\s\s/,'  ').strip @@xml[:body] << %{#{Ax[:tab]*0}<object id="#{dob.ocn}">} @@xml[:body] << %{#{Ax[:tab]*1}<ocn>#{dob.ocn}</ocn>} @@xml[:body] << %{#{Ax[:tab]*1}<text class="code">#{named}#{Ax[:tab]*1}} @@ -268,7 +268,7 @@ WOK end def table_structure(dob) named=name_tags(dob) - table=SiSU_XHTML_shared::Table_xhtml.new(dob) + table=SiSU_XHTML_Shared::TableXHTML.new(dob) @@xml[:body] << %{#{Ax[:tab]*0}<object id="#{dob.ocn}">} @@xml[:body] << %{#{Ax[:tab]*1}<ocn>#{dob.ocn}</ocn>} @@xml[:body] << %{#{Ax[:tab]*2}#{named}#{table.table.obj}} @@ -292,11 +292,11 @@ WOK if dob.obj !~/(^#{Rx[:meta]}|#{Mx[:br_eof]}|#{Mx[:br_endnotes]})/ if defined? dob.ocn #look to move to format section ocn=(dob.ocn.to_s =~/\d+/) ? dob.ocn : nil - @p_num=SiSU_XML_format::Paragraph_number.new(@md,ocn) + @p_num=SiSU_XML_Format::ParagraphNumber.new(@md,ocn) end if not @rcdc - x=SiSU_XML_format::Format_seg.new(@md,dob) - if dob.is=='heading' + x=SiSU_XML_Format::FormatSeg.new(@md,dob) + if dob.is==:heading xml_structure(dob) dob.obj=case dob.ln when 1; x.heading_body1 @@ -307,25 +307,25 @@ WOK when 6; x.heading_body6 end else - if dob.is =='verse' + if dob.is ==:verse poem_structure(dob) - elsif dob.is =='group' + elsif dob.is ==:group group_structure(dob) - elsif dob.is =='block' + elsif dob.is ==:block block_structure(dob) - elsif dob.is =='code' + elsif dob.is ==:code code_structure(dob) - elsif dob.is =='table' + elsif dob.is ==:table table_structure(dob) - elsif dob.is =='para' \ + elsif dob.is ==:para \ and dob.indent.to_s =~/[1-9]/ \ and dob.bullet_==true xml_structure(dob,"indent_bullet#{dob.indent}") - elsif dob.is =='para' \ + elsif dob.is ==:para \ and dob.indent.to_s =~/[1-9]/ \ and dob.indent == dob.hang xml_structure(dob,"indent#{dob.indent}") - elsif dob.is=='para' \ + elsif dob.is==:para \ and dob.hang.to_s =~/[0-9]/ \ and dob.indent != dob.hang xml_structure(dob,"hang#{dob.hang.to_s}_indent#{dob.indent.to_s}") @@ -335,7 +335,7 @@ WOK if dob.obj =~/.*<:#>.*$/ #investigate removal dob.obj=if dob.obj =~ /#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]}/ txt_obj={ txt: dob } - format_text=Format_text_object.new(@md,txt_obj) + format_text=FormatTextObject.new(@md,txt_obj) format_text.scr_inden_ocn_e_no_paranum end end @@ -343,7 +343,7 @@ WOK end else # end - dob.obj.gsub!(/#{Mx[:pa_o]}:\S+#{Mx[:pa_c]}/,'') if dob.obj + dob.obj=dob.obj.gsub(/#{Mx[:pa_o]}:\S+#{Mx[:pa_c]}/,'') if dob.obj end end 6.downto(4) do |x| @@ -356,14 +356,14 @@ WOK end end def pre - rdf=SiSU_XML_tags::RDF.new(@md) - dir=SiSU_Env::Info_env.new + rdf=SiSU_XML_Tags::RDF.new(@md) + dir=SiSU_Env::InfoEnv.new @@xml[:head],@@xml[:body]=[],[] - css=SiSU_Env::CSS_stylesheet.new(@md) + stylesheet=SiSU_Style::CSS_HeadInfo.new(@md,'xhtml').stylesheet encoding=(@sys.locale =~/utf-?8/i) ? '<?xml version="1.0" encoding="UTF-8" standalone="no"?>' : '<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>' @@xml[:open] =<<WOK #{encoding} -#{css.xhtml} +#{stylesheet.css_head_xml} #{rdf.comment_xml} <document> WOK @@ -380,7 +380,7 @@ WOK content << @@xml[:open] << @@xml[:head] << @@xml[:body] << @@xml[:metadata] content << @@xml[:owner_details] if @md.stmp =~/\w\w/ content << @@xml[:tail] << @@xml[:close] - content.flatten!.compact! + content=content.flatten.compact Output.new(content,@md).xhtml @@xml={} end @@ -388,13 +388,13 @@ WOK class Output def initialize(data,md) @data,@md=data,md - @file=SiSU_Env::SiSU_file.new(@md) + @file=SiSU_Env::FileOp.new(@md) end def xhtml - SiSU_Env::SiSU_file.new(@md).mkdir + SiSU_Env::FileOp.new(@md).mkdir filename_xml=@file.write_file.xhtml @data.each do |str| - str.gsub!(/\A\s+\Z/m,'') #str.gsub!(/^\s+$/,'') + str=str.gsub(/\A\s+\Z/m,'') #str.gsub(/^\s+$/,'') filename_xml.puts str unless str.empty? end filename_xml.close @@ -403,7 +403,7 @@ WOK class Tidy def initialize(md,file) @md,@file=md,file - @prog=SiSU_Env::Info_program.new + @prog=SiSU_Env::InfoProgram.new end def xml if @prog.tidy !=false @@ -414,7 +414,7 @@ WOK tell.grey_open end tidyfile='/dev/null' #don't want one or screen output, check for alternative flags - tidy=SiSU_Env::System_call.new(@file,tidyfile) + tidy=SiSU_Env::SystemCall.new(@file,tidyfile) tidy.well_formed? tell.p_off unless @md.opt.cmd =~/q/ end diff --git a/lib/sisu/v3/xhtml_table.rb b/lib/sisu/v3/xhtml_table.rb index 189e5a1d..cea438a2 100644 --- a/lib/sisu/v3/xhtml_table.rb +++ b/lib/sisu/v3/xhtml_table.rb @@ -56,13 +56,13 @@ ** Description: shared html parts =end -module SiSU_XHTML_table +module SiSU_XHTML_Table require_relative 'defaults' # defaults.rb - class Table_xhtml + class TableXHTML @@tablehead=0 @@tablefoot=[] #watch def initialize(table) - @table_obj,@vz=table,SiSU_Env::Get_init.instance.skin + @table_obj,@vz=table,SiSU_Env::GetInit.instance.skin end def table table_obj=@table_obj @@ -78,8 +78,8 @@ module SiSU_XHTML_table table_row_with_columns=table_row.split(Mx[:tc_p]) trc,nc=[],0 table_row_with_columns.each do |c| - c.gsub!(/^~$/,'') # tilde / empty cell - c.gsub!(/<:br>/,'<br />') + c=c.gsub(/^~$/,''). # tilde / empty cell + gsub(/<:br>/,'<br />') trc <<= if table_obj.head_ and nr==0; %{<th width="#{table_obj.widths[nc]}%">#{c}</th>} else %{<td width="#{table_obj.widths[nc]}%">#{c}</td>} end diff --git a/lib/sisu/v3/xml.rb b/lib/sisu/v3/xml.rb index 9ed3e871..aa75e139 100644 --- a/lib/sisu/v3/xml.rb +++ b/lib/sisu/v3/xml.rb @@ -64,9 +64,9 @@ module SiSU_XML_SAX require_relative 'sysenv' # sysenv.rb include SiSU_Env require_relative 'shared_xml' # shared_xml.rb - include SiSU_XML_munge + include SiSU_XML_Munge require_relative 'xml_format' # xml_format.rb - include SiSU_XML_format + include SiSU_XML_Format require_relative 'rexml' # rexml.rb include SiSU_Rexml require_relative 'shared_metadata' # shared_metadata.rb @@ -75,7 +75,7 @@ module SiSU_XML_SAX class Source def initialize(opt) @opt=opt - @particulars=SiSU_Particulars::Combined_singleton.instance.get_all(opt) + @particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt) end def read begin @@ -93,7 +93,7 @@ module SiSU_XML_SAX SiSU_Screen::Ansi.new(@opt.cmd,@opt.fns,"file://#{@md.file.output_path.xml_sax.dir}/#{@md.file.base_filename.xml_sax}").flow if @opt.cmd =~/[MV]/ end SiSU_XML_SAX::Source::Songsheet.new(@particulars).song - rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error + rescue; SiSU_Errors::InfoError.new($!,$@,@opt.cmd,@opt.fns).error ensure #file closed in songsheet end @@ -102,29 +102,29 @@ module SiSU_XML_SAX class Songsheet def initialize(particulars) @env,@md,@dal_array,@particulars=particulars.env,particulars.md,particulars.dal_array,particulars - @file=SiSU_Env::SiSU_file.new(@md) + @file=SiSU_Env::FileOp.new(@md) end def song begin SiSU_XML_SAX::Source::Scroll.new(@particulars).songsheet SiSU_XML_SAX::Source::Tidy.new(@md,@file.place_file.xml_sax.dir).xml if @md.opt.cmd =~/[vVM]/ # test wellformedness, comment out when not in use SiSU_Rexml::Rexml.new(@md,@file.place_file.xml_sax.dir).xml if @md.opt.cmd =~/M/ # test rexml parsing, comment out when not in use #debug - rescue; SiSU_Errors::Info_error.new($!,$@,@md.opt.cmd,@md.fns).error + rescue; SiSU_Errors::InfoError.new($!,$@,@md.opt.cmd,@md.fns).error ensure end end end class Scroll require_relative 'shared_txt' # shared_txt.rb - include SiSU_text_utils + include SiSU_TextUtils require_relative 'css' # css.rb require_relative 'shared_xhtml' # decide use, whether xml rather than xhtml @@xml={ body: [], open: [], close: [], head: [] } def initialize(particulars) @env,@md,@dal_array=particulars.env,particulars.md,particulars.dal_array - @vz=SiSU_Env::Get_init.instance.skin - @trans=SiSU_XML_munge::Trans.new(@md) - @sys=SiSU_Env::System_call.new + @vz=SiSU_Env::GetInit.instance.skin + @trans=SiSU_XML_Munge::Trans.new(@md) + @sys=SiSU_Env::SystemCall.new end def songsheet pre @@ -134,20 +134,20 @@ module SiSU_XML_SAX end protected def embedded_endnotes(dob='') - dob.obj.gsub!(/#{Mx[:en_a_o]}(\d+)\s+(.+?)#{Mx[:en_a_c]}/, - '<endnote><number>\1</number><note>\2</note></endnote> ') - dob.obj.gsub!(/#{Mx[:en_b_o]}([*+]\d+)\s+(.+?)#{Mx[:en_b_c]}/, - '<endnote><symbol>\1</symbol><note>\2</note></endnote> ') - dob.obj.gsub!(/#{Mx[:en_a_o]}([*+]+)\s+(.+?)#{Mx[:en_a_c]}/, - '<endnote><symbol>\1</symbol><note>\2</note></endnote> ') + dob.obj=dob.obj.gsub(/#{Mx[:en_a_o]}(\d+)\s+(.+?)#{Mx[:en_a_c]}/, + '<endnote><number>\1</number><note>\2</note></endnote> '). + gsub(/#{Mx[:en_b_o]}([*+]\d+)\s+(.+?)#{Mx[:en_b_c]}/, + '<endnote><symbol>\1</symbol><note>\2</note></endnote> '). + gsub(/#{Mx[:en_a_o]}([*+]+)\s+(.+?)#{Mx[:en_a_c]}/, + '<endnote><symbol>\1</symbol><note>\2</note></endnote> ') end def extract_endnotes(dob='') notes=dob.obj.scan(/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]})([\d*+]+\s+.+?)(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/) notes.flatten.each do |e| s=e.to_s - util=SiSU_text_utils::Wrap.new(s,70) + util=SiSU_TextUtils::Wrap.new(s,70) wrap=util.line_wrap - wrap.gsub!(/^(\d+)\s+(.+?)\s*\Z/m, <<WOK + wrap=wrap.gsub(/^(\d+)\s+(.+?)\s*\Z/m, <<WOK #{Ax[:tab]*1}<endnote notenumber="\\1"> #{Ax[:tab]*2}<number>\\1</number> #{Ax[:tab]*2}<note> @@ -155,8 +155,8 @@ module SiSU_XML_SAX #{Ax[:tab]*2}</note> #{Ax[:tab]*1}</endnote> WOK -) - wrap.gsub!(/^([*+]\d+)\s+(.+?)\s*\Z/m, <<WOK +). + gsub(/^([*+]\d+)\s+(.+?)\s*\Z/m, <<WOK #{Ax[:tab]*1}<endnote symbol="\\1"> #{Ax[:tab]*2}<symbol>\\1</symbol> #{Ax[:tab]*2}<note> @@ -164,8 +164,8 @@ WOK #{Ax[:tab]*2}</note> #{Ax[:tab]*1}</endnote> WOK -) - wrap.gsub!(/^([*+]+)\s+(.+?)\s*\Z/m, <<WOK +). + gsub(/^([*+]+)\s+(.+?)\s*\Z/m, <<WOK #{Ax[:tab]*1}<endnote symbol="\\1.length"> #{Ax[:tab]*2}<symbol>\\1</symbol> #{Ax[:tab]*2}<note> @@ -178,7 +178,7 @@ WOK end end def xml_head - metadata=Metadata::Summary.new(@md).xml_sax.metadata + metadata=SiSU_Metadata::Summary.new(@md).xml_sax.metadata @@xml[:head] << metadata end def xml_sc(md='') @@ -204,18 +204,18 @@ WOK @@xml[:sc]=sc end def xml_structure(dob,type='norm') - if dob.is=='heading' + if dob.is==:heading lv=dob.ln n=dob.ln - 1 n3=dob.ln + 2 else lv=nil end extract_endnotes(dob) - dob.obj.gsub!(/#{Mx[:en_a_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_a_c]}/,'<en>\1</en>') #footnote/endnote clean - dob.obj.gsub!(/#{Mx[:en_b_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_b_c]}/,'<en>\1</en>') #footnote/endnote clean + dob.obj=dob.obj.gsub(/#{Mx[:en_a_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_a_c]}/,'<en>\1</en>'). #footnote/endnote clean + gsub(/#{Mx[:en_b_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_b_c]}/,'<en>\1</en>') #footnote/endnote clean #if defined? dob.obj #t_ograph="#{dob.obj}" - util=SiSU_text_utils::Wrap.new(dob.obj,70) + util=SiSU_TextUtils::Wrap.new(dob.obj,70) wrapped=util.line_wrap #end @@xml[:body] << if defined? dob.ocn; %{#{Ax[:tab]*0}<object id="#{dob.ocn}">} @@ -232,10 +232,10 @@ WOK end def block_structure(dob='') extract_endnotes(dob) - dob.obj.gsub!(/#{Mx[:en_a_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_a_c]}/,'<en>\1</en>') #footnote/endnote clean - dob.obj.gsub!(/#{Mx[:en_b_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_b_c]}/,'<en>\1</en>') #footnote/endnote clean + dob.obj=dob.obj.gsub(/#{Mx[:en_a_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_a_c]}/,'<en>\1</en>'). #footnote/endnote clean + gsub(/#{Mx[:en_b_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_b_c]}/,'<en>\1</en>') #footnote/endnote clean dob=@trans.markup_block(dob) - dob.obj.strip! + dob.obj=dob.obj.strip @@xml[:body] << %{#{Ax[:tab]*0}<object id="#{dob.ocn}">} @@xml[:body] << %{#{Ax[:tab]*1}<ocn>#{dob.ocn}</ocn>} @@xml[:body] << %{#{Ax[:tab]*1}<text class="block">#{Ax[:tab]*1}} @@ -247,10 +247,10 @@ WOK end def group_structure(dob='') extract_endnotes(dob) - dob.obj.gsub!(/#{Mx[:en_a_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_a_c]}/,'<en>\1</en>') #footnote/endnote clean - dob.obj.gsub!(/#{Mx[:en_b_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_b_c]}/,'<en>\1</en>') #footnote/endnote clean + dob.obj=dob.obj.gsub(/#{Mx[:en_a_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_a_c]}/,'<en>\1</en>'). #footnote/endnote clean + gsub(/#{Mx[:en_b_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_b_c]}/,'<en>\1</en>') #footnote/endnote clean dob=@trans.markup_group(dob) - dob.obj.strip! + dob.obj=dob.obj.strip @@xml[:body] << %{#{Ax[:tab]*0}<object id="#{dob.ocn}">} @@xml[:body] << %{#{Ax[:tab]*1}<ocn>#{dob.ocn}</ocn>} @@xml[:body] << %{#{Ax[:tab]*1}<text class="group">#{Ax[:tab]*1}} @@ -262,8 +262,8 @@ WOK end def poem_structure(dob='') dob=@trans.markup_group(dob) - #dob.obj.gsub!(/\s\s/,'  ') - dob.obj.strip! + #dob.obj.gsub(/\s\s/,'  ') + dob.obj=dob.obj.strip @@xml[:body] << %{#{Ax[:tab]*0}<object id="#{dob.ocn}">} @@xml[:body] << %{#{Ax[:tab]*1}<ocn>#{dob.ocn}</ocn>} @@xml[:body] << %{#{Ax[:tab]*1}<text class="verse">#{Ax[:tab]*1}} @@ -273,8 +273,7 @@ WOK end def code_structure(dob='') dob=@trans.markup_group(dob) - dob.obj.gsub!(/\s\s/,'  ') - dob.obj.strip! + dob.obj=dob.obj.gsub(/\s\s/,'  ').strip @@xml[:body] << %{#{Ax[:tab]*0}<object id="#{dob.ocn}">} @@xml[:body] << %{#{Ax[:tab]*1}<ocn>#{dob.ocn}</ocn>} @@xml[:body] << %{#{Ax[:tab]*1}<text class="code">#{Ax[:tab]*1}} @@ -283,7 +282,7 @@ WOK @@xml[:body] << "#{Ax[:tab]*0}</object>" end def table_structure(dob) - table=SiSU_XHTML_shared::Table_xhtml.new(dob) + table=SiSU_XHTML_Shared::TableXHTML.new(dob) @@xml[:body] << %{#{Ax[:tab]*0}<object id="#{dob.ocn}">} @@xml[:body] << %{#{Ax[:tab]*1}<ocn>#{dob.ocn}</ocn>} @@xml[:body] << %{#{Ax[:tab]*1}<text class="table">#{Ax[:tab]*1}} @@ -307,20 +306,20 @@ WOK @trans.char_enc.utf8(dob) if @sys.locale =~/utf-?8/i #% utf8 dob=@trans.markup(dob) if @rcdc==false \ - and (dob.is =~/^meta/ \ + and (dob.is ==:meta \ and dob.obj =~/Document Information/) @rcdc=true end if dob.obj !~/(^#{Rx[:meta]}|#{Mx[:br_eof]}|#{Mx[:br_endnotes]})/ if defined? dob.ocn #look to move to format section ocn=((dob.ocn.to_s =~/\d+/) ? dob.ocn : nil) - @p_num=SiSU_XML_format::Paragraph_number.new(@md,ocn) + @p_num=SiSU_XML_Format::ParagraphNumber.new(@md,ocn) end if not @rcdc if defined? dob.ocn \ and dob.ocn.to_s =~/\d+/ - x=SiSU_XML_format::Format_seg.new(@md,dob) - if dob.is=='heading' + x=SiSU_XML_Format::FormatSeg.new(@md,dob) + if dob.is==:heading xml_structure(dob) dob.obj=case dob.ln when 1; x.heading_body1 @@ -331,25 +330,25 @@ WOK when 6; x.heading_body6 end else - if dob.is=='verse' + if dob.is==:verse poem_structure(dob) - elsif dob.is=='group' + elsif dob.is==:group group_structure(dob) - elsif dob.is=='block' + elsif dob.is==:block block_structure(dob) - elsif dob.is=='code' + elsif dob.is==:code code_structure(dob) - elsif dob.is=='table' # FIX, check css, will need to modify + elsif dob.is==:table # FIX, check css, will need to modify table_structure(dob) - elsif dob.is =~ /^para/ \ + elsif dob.is ==:para \ and dob.indent.to_s =~/[1-9]/ \ and dob.bullet_==true xml_structure(dob,"indent_bullet#{dob.indent}") - elsif dob.is =~ /^para/ \ + elsif dob.is ==:para \ and dob.indent.to_s =~/[1-9]/ \ and dob.indent == dob.hang xml_structure(dob,"indent#{dob.indent}") - elsif dob.is =~ /^para/ \ + elsif dob.is ==:para \ and dob.hang.to_s =~/[0-9]/ \ and dob.indent != dob.hang xml_structure(dob,"hang#{dob.hang.to_s}_indent#{dob.indent.to_s}") @@ -359,11 +358,11 @@ WOK elsif dob.obj =~/(#{Mx[:br_eof]}|#{Mx[:br_endnotes]})/ elsif dob.obj =~/MetaData/ txt_obj={ txt: '<br /><a name="metadata">MetaData</a>' } - format_scroll=Format_scroll.new(@md,txt_obj) + format_scroll=FormatScroll.new(@md,txt_obj) dob.obj=format_scroll.bold_para elsif dob.obj =~/(Owner Details)/ # txt_obj={ txt: '<br /><a name="owner.details">Owner Details</a>' } -# format_scroll=Format_scroll.new(@md,txt_obj) +# format_scroll=FormatScroll.new(@md,txt_obj) # @@xml[:owner_details]=format_scroll.bold_para dob.obj='' end @@ -374,13 +373,13 @@ WOK if dob.obj =~/.*<:#>.*$/ #investigate removal dob.obj=if dob.obj =~ /#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]}/ txt_obj={ txt: dob } - format_text=Format_text_object.new(@md,txt_obj) + format_text=FormatTextObject.new(@md,txt_obj) format_text.scr_inden_ocn_e_no_paranum end end else # end - dob.obj.gsub!(/#{Mx[:pa_o]}:\S+#{Mx[:pa_c]}/,'') if dob.obj + dob.obj=dob.obj.gsub(/#{Mx[:pa_o]}:\S+#{Mx[:pa_c]}/,'') if dob.obj end end 6.downto(4) do |x| @@ -394,16 +393,16 @@ WOK #6.downto(1) { |x| y=x - 1; @@xml[:body] << "#{Ax[:tab]*y}</level #{x}>" if @level[x]==true } end def pre - rdf=SiSU_XML_tags::RDF.new(@md) - dir=SiSU_Env::Info_env.new + rdf=SiSU_XML_Tags::RDF.new(@md) + dir=SiSU_Env::InfoEnv.new @@xml[:head],@@xml[:body]=[],[] - css=SiSU_Env::CSS_stylesheet.new(@md) + stylesheet=SiSU_Style::CSS_HeadInfo.new(@md,'xml_sax').stylesheet encoding=if @sys.locale =~/utf-?8/i; '<?xml version="1.0" encoding="UTF-8" standalone="no"?>' else '<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>' end @@xml[:open] =<<WOK #{encoding} -#{css.xml_sax} +#{stylesheet.css_head_xml} #{rdf.comment_xml} <document> WOK @@ -421,7 +420,7 @@ WOK content << @@xml[:open] << @@xml[:head] << @@xml[:body] << @@xml[:metadata] content << @@xml[:owner_details] if @md.stmp =~/\w\w/ content << @@xml[:tail] << @@xml[:close] - content.flatten!.compact! + content=content.flatten.compact Output.new(content,@md).xml @@xml={} end @@ -429,13 +428,13 @@ WOK class Output def initialize(data,md) @data,@md=data,md - @file=SiSU_Env::SiSU_file.new(@md) + @file=SiSU_Env::FileOp.new(@md) end def xml - SiSU_Env::SiSU_file.new(@md).mkdir + SiSU_Env::FileOp.new(@md).mkdir filename_xml=@file.write_file.xml_sax @data.each do |str| - str.gsub!(/\A\s+\Z/m,'') #str.gsub!(/^\s+$/,'') + str=str.gsub(/\A\s+\Z/m,'') filename_xml.puts str unless str.empty? end filename_xml.close @@ -444,7 +443,7 @@ WOK class Tidy def initialize(md,file) @md,@file=md,file - @prog=SiSU_Env::Info_program.new + @prog=SiSU_Env::InfoProgram.new end def xml if @prog.tidy !=false #note values can be other than true @@ -455,7 +454,7 @@ WOK tell.grey_open end tidyfile='/dev/null' #don't want one or screen output, check for alternative flags - tidy=SiSU_Env::System_call.new(@file,tidyfile) + tidy=SiSU_Env::SystemCall.new(@file,tidyfile) tidy.well_formed? tell.p_off unless @md.opt.cmd =~/q/ end diff --git a/lib/sisu/v3/xml_dom.rb b/lib/sisu/v3/xml_dom.rb index 53c60bf8..6b8c4e5c 100644 --- a/lib/sisu/v3/xml_dom.rb +++ b/lib/sisu/v3/xml_dom.rb @@ -62,9 +62,9 @@ module SiSU_XML_DOM include SiSU_Env require_relative 'dal' # dal.rb require_relative 'shared_xml' # shared_xml.rb - include SiSU_XML_munge + include SiSU_XML_Munge require_relative 'xml_format' # xml_format.rb - include SiSU_XML_format + include SiSU_XML_Format require_relative 'rexml' # rexml.rb include SiSU_Rexml require_relative 'shared_metadata' # shared_metadata.rb @@ -73,7 +73,7 @@ module SiSU_XML_DOM class Source def initialize(opt) @opt=opt - @particulars=SiSU_Particulars::Combined_singleton.instance.get_all(opt) + @particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt) end def read begin @@ -91,7 +91,7 @@ module SiSU_XML_DOM SiSU_Screen::Ansi.new(@opt.cmd,@opt.fns,"file://#{@md.file.output_path.xml_dom.dir}/#{@md.file.base_filename.xml_dom}").flow if @opt.cmd =~/[MV]/ end SiSU_XML_DOM::Source::Songsheet.new(@particulars).songsheet - rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error + rescue; SiSU_Errors::InfoError.new($!,$@,@opt.cmd,@opt.fns).error ensure end end @@ -99,28 +99,28 @@ module SiSU_XML_DOM class Songsheet def initialize(particulars) @env,@md,@dal_array,@particulars=particulars.env,particulars.md,particulars.dal_array,particulars - @file=SiSU_Env::SiSU_file.new(@md) + @file=SiSU_Env::FileOp.new(@md) end def songsheet begin SiSU_XML_DOM::Source::Scroll.new(@particulars).songsheet SiSU_XML_DOM::Source::Tidy.new(@md,@file.place_file.xml_dom.dir).xml if @md.opt.cmd =~/[vVM]/ # test wellformedness, comment out when not in use SiSU_Rexml::Rexml.new(@md,@file.place_file.xml_dom.dir).xml if @md.opt.cmd =~/M/ # test rexml parsing, comment out when not in use #debug - rescue; SiSU_Errors::Info_error.new($!,$@,@md.opt.cmd,@md.fns).error + rescue; SiSU_Errors::InfoError.new($!,$@,@md.opt.cmd,@md.fns).error ensure end end end class Scroll require_relative 'shared_txt' # shared_txt.rb - include SiSU_text_utils + include SiSU_TextUtils require_relative 'shared_xhtml' # decide use, whether xml rather than xhtml @@xml={ body: [], open: [], close: [], head: [], sc: [] } def initialize(particulars) @env,@md,@dal_array=particulars.env,particulars.md,particulars.dal_array - @vz=SiSU_Env::Get_init.instance.skin - @trans=SiSU_XML_munge::Trans.new(@md) - @sys=SiSU_Env::System_call.new + @vz=SiSU_Env::GetInit.instance.skin + @trans=SiSU_XML_Munge::Trans.new(@md) + @sys=SiSU_Env::SystemCall.new end def songsheet pre @@ -130,15 +130,15 @@ module SiSU_XML_DOM end protected def xml_markup(dob='') - dob.obj.gsub!(/#{Mx[:en_a_o]}(\d+)\s+(.+?)#{Mx[:en_a_c]}/, - '<endnote><number>\1</number><note>\2</note></endnote> ') - dob.obj.gsub!(/#{Mx[:en_b_o]}([*+]\d+)\s+(.+?)#{Mx[:en_b_c]}/, - '<endnote><symbol>\1</symbol><note>\2</note></endnote> ') - dob.obj.gsub!(/#{Mx[:en_a_o]}([*+]+)\s+(.+?)#{Mx[:en_a_c]}/, - '<endnote><symbol>\1</symbol><note>\2</note></endnote> ') + dob.obj=dob.obj.gsub(/#{Mx[:en_a_o]}(\d+)\s+(.+?)#{Mx[:en_a_c]}/, + '<endnote><number>\1</number><note>\2</note></endnote> '). + gsub(/#{Mx[:en_b_o]}([*+]\d+)\s+(.+?)#{Mx[:en_b_c]}/, + '<endnote><symbol>\1</symbol><note>\2</note></endnote> '). + gsub(/#{Mx[:en_a_o]}([*+]+)\s+(.+?)#{Mx[:en_a_c]}/, + '<endnote><symbol>\1</symbol><note>\2</note></endnote> ') end def xml_head - metadata=Metadata::Summary.new(@md).xml_dom.metadata + metadata=SiSU_Metadata::Summary.new(@md).xml_dom.metadata @@xml[:head] << metadata end def xml_sc(md='') @@ -165,7 +165,7 @@ WOK end def xml_element(dob,xml_el='',xml_content='',type='norm') n=n1=n2=n3=0 - if dob.is=='heading' + if dob.is==:heading lv=dob.ln n=dob.ln - 1 n1=dob.ln @@ -200,7 +200,7 @@ WOK end def xml_structure(dob,type='norm') n=n1=n2=n3=0 - if dob.is=='heading' + if dob.is==:heading lv=dob.ln n=dob.ln - 1 n1=dob.ln @@ -309,31 +309,28 @@ WOK end def block_structure(dob) dob=@trans.markup_block(dob) #decide check & FIX - dob.obj.gsub!(/#{Mx[:en_a_o]}(\d+)\s+(.+?)#{Mx[:en_a_c]}/m, - '<endnote><number>\1</number><note>\2</note></endnote> ') - dob.obj.strip! + dob.obj=dob.obj.gsub(/#{Mx[:en_a_o]}(\d+)\s+(.+?)#{Mx[:en_a_c]}/m, + '<endnote><number>\1</number><note>\2</note></endnote> ').strip dob end def group_structure(dob) dob=@trans.markup_group(dob) #decide check & FIX - dob.obj.gsub!(/#{Mx[:en_a_o]}(\d+)\s+(.+?)#{Mx[:en_a_c]}/m, - '<endnote><number>\1</number><note>\2</note></endnote> ') - dob.obj.strip! + dob.obj=dob.obj.gsub(/#{Mx[:en_a_o]}(\d+)\s+(.+?)#{Mx[:en_a_c]}/m, + '<endnote><number>\1</number><note>\2</note></endnote> ').strip dob end def poem_structure(dob) dob=@trans.markup_group(dob) #decide check & FIX - dob.obj.strip! + dob.obj=dob.obj.strip dob end def code_structure(dob) dob=@trans.markup_group(dob) #decide check & FIX - dob.obj.gsub!(/\s\s/,'  ') - dob.obj.strip! + dob.obj=dob.obj.gsub(/\s\s/,'  ').strip dob end def table_structure(dob) #tables - table=SiSU_XHTML_shared::Table_xhtml.new(dob) + table=SiSU_XHTML_Shared::TableXHTML.new(dob) end def markup(data) xml_sc(@md) @@ -347,18 +344,18 @@ WOK @trans.char_enc.utf8(dob) if @sys.locale =~/utf-?8/i #% utf8 dob=@trans.markup(dob) if @rcdc==false \ - and (dob.is =~/^meta/ \ + and (dob.is ==:meta \ and dob.obj =~/Document Information/) @rcdc=true end if dob !~/(^#{Rx[:meta]}|#{Mx[:br_eof]}|#{Mx[:br_endnotes]})/ - @p_num=SiSU_XML_format::Paragraph_number.new(@md,dob.ocn) if defined? dob.ocn + @p_num=SiSU_XML_Format::ParagraphNumber.new(@md,dob.ocn) if defined? dob.ocn if not @rcdc if defined? dob.ocn \ and dob.ocn.to_s =~/\d+/ - format_scroll=SiSU_XML_format::Format_scroll.new(@md,dob) if dob.is=='para' and dob.indent ##FIX - x=SiSU_XML_format::Format_seg.new(@md,dob) - if dob.is=='heading' + format_scroll=SiSU_XML_Format::FormatScroll.new(@md,dob) if dob.is==:para and dob.indent ##FIX + x=SiSU_XML_Format::FormatSeg.new(@md,dob) + if dob.is==:heading if dob.ln==1 type="heading_section_#{dob.ln.to_s}" xml_markup(dob) @@ -391,32 +388,32 @@ WOK end else ocn=dob.ocn - if dob.is=='verse' + if dob.is==:verse type='verse' poem_structure(dob) #redo - elsif dob.is=='group' + elsif dob.is==:group type='group' group_structure(dob) #redo - elsif dob.is=='block' + elsif dob.is==:block type='block' block_structure(dob) #redo - elsif dob.is=='code' + elsif dob.is==:code type='code' code_structure(dob) #redo - elsif dob.is=='table' # tables come as single block #work area 2005w13 + elsif dob.is==:table # tables come as single block #work area 2005w13 type='table' table_structure(dob) - elsif dob.is=='para' \ + elsif dob.is==:para \ and dob.indent.to_s =~/[1-9]/ \ and dob.bullet_ type="indent_bullet#{dob.indent.to_s}" xml_markup(dob) - elsif dob.is=='para' \ + elsif dob.is==:para \ and dob.indent.to_s =~/[1-9]/ \ and dob.indent == dob.hang type="indent#{dob.indent.to_s}" xml_markup(dob) - elsif dob.is=='para' \ + elsif dob.is==:para \ and dob.hang.to_s =~/[0-9]/ \ and dob.indent != dob.hang type="hang#{dob.hang.to_s}_indent#{dob.indent.to_s}" @@ -430,7 +427,7 @@ WOK elsif dob.obj =~/(#{Mx[:br_eof]}|#{Mx[:br_endnotes]})/ elsif dob.obj =~/(MetaData)/ txt_obj={ txt: '<br /><a name="metadata">MetaData</a>' } - format_scroll=Format_scroll.new(@md,txt_obj) + format_scroll=FormatScroll.new(@md,txt_obj) dob.obj=format_scroll.bold_para elsif dob.obj =~/(Owner Details)/ dob.obj='' @@ -442,7 +439,7 @@ WOK if dob.obj =~/.*<:#>.*$/ dob.obj=if dob.obj =~ /#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]}/ txt_obj={ txt: dob.obj } - format_text=Format_text_object.new(@md,txt_obj) + format_text=FormatTextObject.new(@md,txt_obj) format_text.scr_inden_ocn_e_no_paranum end end @@ -450,7 +447,7 @@ WOK end else # end - dob.obj.gsub!(/#{Mx[:pa_o]}:\S+#{Mx[:pa_c]}/,'') if dob.obj + dob.obj=dob.obj.gsub(/#{Mx[:pa_o]}:\S+#{Mx[:pa_c]}/,'') if dob.obj end end @content_flag=true @@ -471,15 +468,15 @@ WOK end end def pre - rdf=SiSU_XML_tags::RDF.new(@md) - dir=SiSU_Env::Info_env.new - css=SiSU_Env::CSS_stylesheet.new(@md) + rdf=SiSU_XML_Tags::RDF.new(@md) + dir=SiSU_Env::InfoEnv.new + stylesheet=SiSU_Style::CSS_HeadInfo.new(@md,'xml_dom').stylesheet encoding=if @sys.locale =~/utf-?8/i; '<?xml version="1.0" encoding="UTF-8" standalone="no"?>' else '<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>' end @@xml[:open] =<<WOK #{encoding} -#{css.xml_dom} +#{stylesheet.css_head_xml} #{rdf.comment_xml} <document> WOK @@ -497,7 +494,7 @@ WOK content << @@xml[:open] << @@xml[:head] << @@xml[:body] << @@xml[:metadata] content << @@xml[:owner_details] if @md.stmp =~/\w\w/ content << @@xml[:tail] << @@xml[:close] - content.flatten!.compact! + content=content.flatten.compact Output.new(content,@md).xml @@xml[:head],@@xml[:body],@@xml[:tail]=[],[],[] # check whether should be nil end @@ -506,13 +503,13 @@ WOK include SiSU_Param def initialize(data,md) @data,@md=data,md - @file=SiSU_Env::SiSU_file.new(@md) + @file=SiSU_Env::FileOp.new(@md) end def xml - SiSU_Env::SiSU_file.new(@md).mkdir + SiSU_Env::FileOp.new(@md).mkdir filename_xml=@file.write_file.xml_dom @data.each do |str| - str.gsub!(/#{Mx[:pa_o]}:\S+#{Mx[:pa_c]}/,'') + str=str.gsub(/#{Mx[:pa_o]}:\S+#{Mx[:pa_c]}/,'') filename_xml.puts str unless str.empty? end filename_xml.close @@ -521,7 +518,7 @@ WOK class Tidy def initialize(md,file) @md,@file=md,file - @prog=SiSU_Env::Info_program.new + @prog=SiSU_Env::InfoProgram.new end def xml if @prog.tidy !=false @@ -530,7 +527,7 @@ WOK tell=SiSU_Screen::Ansi.new(@md.opt.cmd,'invert','','') tell.grey_open unless @md.opt.cmd =~/q/ tidyfile='/dev/null' #don't want one or screen output, check for alternative flags - tidy=SiSU_Env::System_call.new(@file,tidyfile) + tidy=SiSU_Env::SystemCall.new(@file,tidyfile) tidy.well_formed? tell.p_off unless @md.opt.cmd =~/q/ end diff --git a/lib/sisu/v3/xml_fictionbook.rb b/lib/sisu/v3/xml_fictionbook.rb index 1425dc74..8fe1e7c1 100644 --- a/lib/sisu/v3/xml_fictionbook.rb +++ b/lib/sisu/v3/xml_fictionbook.rb @@ -61,9 +61,9 @@ module SiSU_XML_Fictionbook require_relative 'sysenv' # sysenv.rb include SiSU_Env require_relative 'shared_txt' # shared_txt.rb - include SiSU_text_utils + include SiSU_TextUtils require_relative 'shared_xml' # shared_xml.rb - include SiSU_XML_munge + include SiSU_XML_Munge include SiSU_Param pwd=Dir.pwd class Source @@ -76,7 +76,7 @@ module SiSU_XML_Fictionbook @md=SiSU_Param::Parameters.new(@opt).get @dal_array=SiSU_DAL::Source.new(@opt).get SiSU_XML_Fictionbook::Source::Scroll.new(@dal_array,@md).songsheet - rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error + rescue; SiSU_Errors::InfoError.new($!,$@,@opt.cmd,@opt.fns).error ensure end end @@ -84,8 +84,8 @@ module SiSU_XML_Fictionbook class Scroll <Source def initialize(data='',md='') @data,@md=data,md - @trans=SiSU_XML_munge::Trans.new(@md) - @file_fictionbook=SiSU_Env::SiSU_file.new(@md,'fictionbook.xml').mkfile + @trans=SiSU_XML_Munge::Trans.new(@md) + @file_fictionbook=SiSU_Env::FileOp.new(@md,'fictionbook.xml').mkfile end def songsheet @t='fictionbook' @@ -103,8 +103,8 @@ module SiSU_XML_Fictionbook tail end def head - version=SiSU_Env::Info_version.instance.get_version - rb_ver=SiSU_Env::Info_version.instance.rbversion + version=SiSU_Env::InfoVersion.instance.get_version + rb_ver=SiSU_Env::InfoVersion.instance.rbversion date_available=if defined? @md.date.available; "\n <p>#{@md.date.available} Initial version</p>" else '' end @@ -151,14 +151,14 @@ WOK @data.each do |para| @endnotes << para.scan(/~\{(.+?)\}~/m) end - @endnotes.flatten! + @endnotes=@endnotes.flatten end def endnotes @endnotes.each do |endnote| - endnote.strip! + endnote=endnote.strip endnote=@trans.markup_fictionbook(endnote) endnote="<p>#{endnote}</p>" - util=SiSU_text_utils::Wrap.new(endnote,80,10) + util=SiSU_TextUtils::Wrap.new(endnote,80,10) endnote=util.line_wrap put(endnote) end @@ -171,12 +171,12 @@ WOK put(tail) end def markup(para,type='') - para.strip! + para=para.strip para=@trans.markup_fictionbook(para) para=if type.empty?; "<p>#{para}</p>" else "<#{type}><p>#{para}</p></#{type}>" end - util=SiSU_text_utils::Wrap.new(para,80,10) + util=SiSU_TextUtils::Wrap.new(para,80,10) wrap=util.line_wrap end def put(line) diff --git a/lib/sisu/v3/xml_format.rb b/lib/sisu/v3/xml_format.rb index c0d9d622..b40efc18 100644 --- a/lib/sisu/v3/xml_format.rb +++ b/lib/sisu/v3/xml_format.rb @@ -57,11 +57,11 @@ ** Notes: tidy -xml index.xml >> index.tidy =end -module SiSU_XML_format +module SiSU_XML_Format require_relative 'param' # param.rb include SiSU_Param include SiSU_Viz - class Paragraph_number + class ParagraphNumber def initialize(md,paranum) @md=md @paranum=(paranum ? (/(\d+)/m.match(paranum)[1]) : nil) @@ -84,7 +84,7 @@ module SiSU_XML_format p_num_goto end end - class Head_information + class HeadInformation def initialize #dc rdf @full_title=@subtitle=@author=@subject=@description=@publisher=@contributor=@date=@type=@format=@identifier=@source=@language=@relation=@coverage=@rights=@copyright=@owner=@keywords='' @md=@@md @@ -193,7 +193,7 @@ module SiSU_XML_format @copyright=%{<meta name="copyright" content="#{@md.rights.copyright.all}" />\n} if @md.rights.copyright.all # possibly redundant see dc.rights @owner=%{<meta name="owner" content="#{@md.owner}" />\n} if @md.owner @keywords=%{<meta name="keywords" content="#{@md.keywords}" />\n} if @md.keywords - @vz=SiSU_Env::Get_init.instance.skin #margin,paragraph,table,banner,url,png,txt,color,font,nav_txt,nav_png,credits,js,php + @vz=SiSU_Env::GetInit.instance.skin #margin,paragraph,table,banner,url,png,txt,color,font,nav_txt,nav_png,credits,js,php @index='index' end def toc_head_escript #embedded script in this case PHP @@ -274,7 +274,7 @@ module SiSU_XML_format WOK end end - class Format_text_object + class FormatTextObject attr_accessor :md,:txt,:format,:paranum,:p_num,:para_id,:headname,:font def initialize(md,dob) @md,@dob=md,dob @@ -282,19 +282,19 @@ WOK @paranum=/(\d+)/m.match(@dob[:ocn])[1] @headname='' @headname=%{<a name="h#{dob.name}"></a>} if defined? dob.name - @p_num=SiSU_XML_format::Paragraph_number.new(@md,dob.ocn) + @p_num=SiSU_XML_Format::ParagraphNumber.new(@md,dob.ocn) end rgx=/^[1-6-]~{1,2}/ #watch @lnk_url=@lnk_url.gsub(rgx,'') if @lnk_url =~rgx rgx=/~\{\d+\s+(.+?)\}~/ @lnk_url=@lnk_url.gsub(rgx,'\1') if @lnk_url =~rgx - @vz=SiSU_Env::Get_init.instance.skin + @vz=SiSU_Env::GetInit.instance.skin end def scr_endnote_body "<endnote>#{@txt}</endnote> " end end - class Format_scroll < Format_text_object + class FormatScroll < FormatTextObject def initialize(md,dob) super(md,dob) end @@ -327,33 +327,26 @@ WOK %{<p class="paranum"><font size="1" color="#777777"> #{@dob.ocn}</font></p>\n} end end - class Paragraph_number + class ParagraphNumber def initialize(md,ocn) @md,@ocn=md,ocn.to_s @ocn ||='' - vz=SiSU_Env::Get_init.instance.skin - @skin_no_ocn=if not ocn - true - elsif defined? vz.ocn_display_off \ - and vz.ocn_display_off==true - true - else false - end end def ocn_display - if @md.markup.inspect =~/no_ocn/ \ - or @md.opt.mod.inspect =~/--no-ocn/ \ - or @skin_no_ocn - ocn_class='ocn_off' - @ocn.gsub(/^(\d+|)$/, - %{<label class="#{ocn_class}"> </label>}) - elsif @ocn.to_i==0 - @ocn.gsub(/^(\d+|)$/, - %{<label class="#{ocn_class}"><a name="#{@ocn}"> </a></label>}) - else + @make=SiSU_Env::ProcessingSettings.new(@md) + if @make.build.ocn? ocn_class='ocn' + if @ocn.to_i==0 + @ocn.gsub(/^(\d+|)$/, + %{<label class="#{ocn_class}"><a name="#{@ocn}"> </a></label>}) + else + @ocn.gsub(/^(\d+|)$/, + %{<label class="#{ocn_class}"><a name="#{@ocn}">\\1</a></label>}) + end + else + ocn_class='ocn_off' @ocn.gsub(/^(\d+|)$/, - %{<label class="#{ocn_class}"><a name="#{@ocn}">\\1</a></label>}) + %{<label class="#{ocn_class}"> </label>}) end end def name @@ -366,15 +359,15 @@ WOK %{<a href="##{@ocn}">} end end - class Head_information + class HeadInformation include SiSU_Viz attr_reader :md,:sfx,:pdf,:rdf,:vz def initialize(md) @md=md - @rdf=SiSU_XML_tags::RDF.new(md) + @rdf=SiSU_XML_Tags::RDF.new(md) # DublinCore 1 - title - @vz=SiSU_Env::Get_init.instance.skin - @css=SiSU_Env::CSS_stylesheet.new(md) + @vz=SiSU_Env::GetInit.instance.skin + @stylesheet=SiSU_Style::CSS_HeadInfo.new(md).stylesheet @seg_name_html=(SiSU_HTML::Source::Seg.new.seg_name_html || []) @seg_name_html_tracker=(SiSU_HTML::Source::Seg.new.seg_name_html_tracker || []) @index='index' @@ -408,7 +401,7 @@ WOK end class XML end - class Head_toc < Head_information + class HeadToc < HeadInformation def initialize(md) super(md) @md=md @@ -544,7 +537,7 @@ WOK <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> #{@rdf.rdftoc} #{@rdf.metatag_html} -#{@css.html} +#{@stylesheet.css_head} </head> #{@vz.color_body} <a name="top" id="top"></a> @@ -708,7 +701,7 @@ WOK } end end - class Head_seg < Head_information + class HeadSeg < HeadInformation def initialize(md) #(md='') super(md) end @@ -788,7 +781,7 @@ WOK def doc_types #used in seg_nav_band ### scroll=seg='' wgt=Widget.new(@md) - #dir=SiSU_Env::Info_env.new(@md.fns) + #dir=SiSU_Env::InfoEnv.new(@md.fns) x=if @md.concord_make %{ <table summary="segment navigation available documents types: toc,doc,pdf,concordance" border="0" cellpadding="3" cellspacing="0"> @@ -834,7 +827,7 @@ WOK <font size="2">} end def header_advert_local_1 - dir=SiSU_Env::Info_env.new(@fns) + dir=SiSU_Env::InfoEnv.new(@fns) %{ <center> <table summary="image" border="0" cellpadding="3" cellspacing="0" align="center"> <tr><td align="center" bgcolor="white"> @@ -846,7 +839,7 @@ WOK </center>} end def header_advert_local_2 - dir=SiSU_Env::Info_env.new(@fns) + dir=SiSU_Env::InfoEnv.new(@fns) %{ <center> <table summary="image" border="0" cellpadding="3" cellspacing="0" align="center"> <tr><td align="center" bgcolor="white"> @@ -858,7 +851,7 @@ WOK </center>} end def header_advert_external - dir=SiSU_Env::Info_env.new(@fns) + dir=SiSU_Env::InfoEnv.new(@fns) %{ <center> <table summary="image" border="0" cellpadding="3" cellspacing="0" align="center"> <tr><td align="center" bgcolor="white"> @@ -938,7 +931,7 @@ WOK <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> #{@rdf.rdfseg} #{@rdf.metatag_html} -#{@css.html} +#{@stylesheet.css_head} </head> #{@vz.color_body} <a name="top" id="top"></a> @@ -968,7 +961,7 @@ WOK } end end - class Head_scroll < Head_toc + class HeadScroll < HeadToc def initialize(md) #(md='') super(md) end @@ -1002,8 +995,8 @@ WOK #{@vz.paragraph_txt}} end end - class Format_text_object - @vz=SiSU_Env::Get_init.instance.skin + class FormatTextObject + @vz=SiSU_Env::GetInit.instance.skin attr_accessor :md,:dob,:txt,:ocn,:format,:table,:link,:linkname,:paranum,:p_num,:headname,:banner,:url def initialize(md,t_o) @md,@t_o=md,t_o @@ -1026,7 +1019,7 @@ WOK @ocn=if defined? t_o.ocn; t_o.ocn.to_s else nil end - @headname=if t_o.is=='heading' and defined? t_o.name; t_o.name + @headname=if t_o.is==:heading and defined? t_o.name; t_o.name else nil end else @@ -1038,7 +1031,7 @@ WOK end if defined? @t_o.ocn ocn=((@t_o.ocn.to_s =~/\d+/) ? @t_o.ocn : nil) - @p_num=Paragraph_number.new(@md,ocn) + @p_num=ParagraphNumber.new(@md,ocn) end if @format and not @format.empty? if @format=~/^\d:(\S+)/ #need more reliable marker #if @format =~ /#{Rx[:lv]}/ @@ -1049,7 +1042,7 @@ WOK end end @dob=t_o if defined? t_o.is - @vz=SiSU_Env::Get_init.instance.skin + @vz=SiSU_Env::GetInit.instance.skin end def endnote_body %{ @@ -1177,17 +1170,18 @@ WOK end def gsub_body #fix - case @txt + @txt=case @txt when /^\s*\((i+|iv|v|vi+|ix|x|xi+)\)/ - @txt.gsub!(/^\((i+|iv|v|vi+|ix|x|xi+)\)/,'<b>(\1)</b>') - @txt.gsub!(/^(#{Mx[:pa_o]}i[1-9]#{Mx[:pa_c]})\s*\((i+|iv|v|vi+|ix|x|xi+)\)/,'\1<b>(\2)</b>') + @txt.gsub(/^\((i+|iv|v|vi+|ix|x|xi+)\)/,'<b>(\1)</b>'). + gsub(/^(#{Mx[:pa_o]}i[1-9]#{Mx[:pa_c]})\s*\((i+|iv|v|vi+|ix|x|xi+)\)/,'\1<b>(\2)</b>') when /^\s*\(?(\d|[a-z])+\)/ - @txt.gsub!(/^\((\d+|[a-z])+\)/,'<b>(\1)</b>') - @txt.gsub!(/^(#{Mx[:pa_o]}i[1-9]#{Mx[:pa_c]})\s*\((\d+|[a-z])+\)/,'\1<b>(\2)</b>') + @txt.gsub(/^\((\d+|[a-z])+\)/,'<b>(\1)</b>'). + gsub(/^(#{Mx[:pa_o]}i[1-9]#{Mx[:pa_c]})\s*\((\d+|[a-z])+\)/,'\1<b>(\2)</b>') when /^\s*\d{1,3}\.\s/ - @txt.gsub!(/^\s*(\d+\.)/,'<b>\1</b>') + @txt.gsub(/^\s*(\d+\.)/,'<b>\1</b>') when /^\s*[A-Z]\.\s/ - @txt.gsub!(/^\s*([A-Z]\.)/,'<b>\1</b>') + @txt.gsub(/^\s*([A-Z]\.)/,'<b>\1</b>') + else @txt end end def bold_para @@ -1200,8 +1194,8 @@ WOK #{@vz.table_close}} end def bold_header - @txt.gsub!(/[1-9]~(\S+)/,'<a name="\1"></a>') - @txt.gsub!(/[1-9]~/,'') + @txt=@txt.gsub(/[1-9]~(\S+)/,'<a name="\1"></a>'). + gsub(/[1-9]~/,'') %{<p class="bold"> #{@txt} </p> @@ -1222,13 +1216,13 @@ WOK %{<p class="centerbold">#{@txt}</p>\n} end end - class Format_scroll < Format_text_object + class FormatScroll < FormatTextObject def initialize(md,txt) super(md,txt) - @vz=SiSU_Env::Get_init.instance.skin + @vz=SiSU_Env::GetInit.instance.skin end end - class Format_seg < Format_text_object + class FormatSeg < FormatTextObject def initialize(md,txt) super(md,txt) end @@ -1297,9 +1291,9 @@ WOK note='' if txt =~/(#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]}\s*)/m note=$1 - note.gsub!(/[\n\s]+/m,' ') - txt.gsub!(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ') - txt.gsub!(/<a[\n\s]+name="-\d+"[\n\s]+href="#_\d+"> <sup>\d+<\/sup> /m,'') + note=note.gsub(/[\n\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,'') end %{<#{tag} class="#{attrib}"> <a href="##{@ocn}"><i>#{txt}</i></a> #{note} @@ -1313,7 +1307,7 @@ WOK end #% para sisu def header_sub(tag,attrib) - @txt.gsub!(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ') + @txt=@txt.gsub(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ') %{ <div class="substance"> #{@p_num.ocn_display} @@ -1362,7 +1356,7 @@ WOK "<center>#{@txt}</center>" end end - class Format_toc < Format_text_object + class FormatToc < FormatTextObject def initialize(md,txt) super(md,txt) end diff --git a/lib/sisu/v3/xml_md_oai_pmh_dc.rb b/lib/sisu/v3/xml_md_oai_pmh_dc.rb index 4837b8e1..eb2bb09c 100644 --- a/lib/sisu/v3/xml_md_oai_pmh_dc.rb +++ b/lib/sisu/v3/xml_md_oai_pmh_dc.rb @@ -56,7 +56,7 @@ ** Description: summary of generated outputs and metadata =end -module SiSU_XML_metadata +module SiSU_XML_Metadata require_relative 'sysenv' # sysenv.rb include SiSU_Env require_relative 'param' # param.rb @@ -184,7 +184,7 @@ WOK end def meta_content_clean(content='') unless content.nil? - content.tr!('"',"'") + content=content.tr('"',"'") end content end @@ -192,8 +192,8 @@ WOK '</oai_dc:dc>' end def output - SiSU_Env::SiSU_file.new(@md).mkdir - oai_pmh=SiSU_Env::SiSU_file.new(@md,@md.fn[:oai_pmh]).mkfile #implement in param + SiSU_Env::FileOp.new(@md).mkdir + oai_pmh=SiSU_Env::FileOp.new(@md,@md.fn[:oai_pmh]).mkfile #implement in param oai_pmh << pre body.each do |x| oai_pmh << x diff --git a/lib/sisu/v3/xml_scaffold.rb b/lib/sisu/v3/xml_scaffold.rb index 5b0056c7..f43daacf 100644 --- a/lib/sisu/v3/xml_scaffold.rb +++ b/lib/sisu/v3/xml_scaffold.rb @@ -56,7 +56,7 @@ ** Description: SiSU information Structuring Universe, processing =end -module SiSU_XML_scaffold +module SiSU_XML_Scaffold require_relative 'particulars' # particulars.rb include SiSU_Particulars require_relative 'dal' # dal.rb @@ -66,14 +66,14 @@ module SiSU_XML_scaffold class Source def initialize(opt) @opt=opt - @particulars=SiSU_Particulars::Combined_singleton.instance.get_all(opt) + @particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt) @sp=' ' end def read begin @md,@dal_array=@particulars.md,@particulars.dal_array - SiSU_XML_scaffold::Source::Scroll.new(@dal_array,@md).songsheet - rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error + SiSU_XML_Scaffold::Source::Scroll.new(@dal_array,@md).songsheet + rescue; SiSU_Errors::InfoError.new($!,$@,@opt.cmd,@opt.fns).error ensure end end @@ -110,13 +110,13 @@ module SiSU_XML_scaffold def structure_outline(data) puts "\ninfo outline --->\n\n" data.each do |o| - puts "#{o.ocn} #{o.ln} #{o.obj}" if o.is =~/^heading/ + puts "#{o.ocn} #{o.ln} #{o.obj}" if (o.is ==:heading || o.is ==:heading_insert) end end def structure_simple(data) puts "\nheading outline --->\n\n" data.each_with_index do |o,i| - if o.is =~ /^heading/; puts "<#{@s[o.ln]}>#{o.ocn} #{o.ln} #{o.obj}</#{@s[o.ln]}>" + if (o.is ==:heading || o.is ==:heading_insert); puts "<#{@s[o.ln]}>#{o.ocn} #{o.ln} #{o.obj}</#{@s[o.ln]}>" end end end @@ -125,7 +125,7 @@ module SiSU_XML_scaffold h=[0,false,false,false] puts "<#{@s[0]}>" data.each_with_index do |o,i| - if o.is =~/^heading/ + if (o.is ==:heading || o.is ==:heading_insert) case o.ln when 1 structure_build_tag_close(o.ln,h) diff --git a/lib/sisu/v3/xml_tables.rb b/lib/sisu/v3/xml_tables.rb index 1f154bda..5457a2fc 100644 --- a/lib/sisu/v3/xml_tables.rb +++ b/lib/sisu/v3/xml_tables.rb @@ -63,30 +63,30 @@ module SiSU_Tables @@tablehead=0 @@tablefoot=[] #watch #bug??? #check was @@tablefoot def initialize(one,ocn='') - @one,@parablock,@ocn,@vz=one,one,ocn,SiSU_Env::Get_init.instance.skin + @one,@parablock,@ocn,@vz=one,one,ocn,SiSU_Env::GetInit.instance.skin end def table_split #% used but, no longer operational, revisit @new_content=[] @one.split(/\n/).each do |parablock| - table=Table_xml.new("#{parablock}\n") + table=TableXML.new("#{parablock}\n") @new_content << table.table end @new_content.join end end - class Table_xml <Table + class TableXML <Table @@tablehead=0 @@tablefoot=[] def initialize(one,ocn='') - @one,@parablock,@ocn,@vz=one,one,ocn,SiSU_Env::Get_init.instance.skin + @one,@parablock,@ocn,@vz=one,one,ocn,SiSU_Env::GetInit.instance.skin end def table m=@parablock[/<!f(.+?)!>/,1] @@tablefoot << m if m - @parablock.gsub!(/<!f.+?!>/,'') + @parablock=@parablock.gsub(/<!f.+?!>/,'') @@tablehead=1 if @parablock =~/#{Mx[:gr_o]}Th#{Mx[:tc_p]}/u if @parablock =~/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}/u - @parablock.gsub!(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}.+?#{Mx[:tc_p]}~(\d+);\w\d+;\w\d+#{Mx[:gr_c]}/u, + @parablock=@parablock.gsub(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}.+?#{Mx[:tc_p]}~(\d+);\w\d+;\w\d+#{Mx[:gr_c]}/u, %{\n<ocn>#{@ocn}</ocn><table summary="normal text css" width="100%" border="0" bgcolor="white" cellpadding="2" align="center">}) end if @parablock =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/ @@ -96,37 +96,37 @@ module SiSU_Tables end if @@tablehead==1 if @parablock =~/#{Mx[:tc_p]}#{Mx[:tc_p]}/u - @parablock.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u, + @parablock=@parablock.gsub(/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u, %{<tr> <td width="\\1%" valign="top"> - #{@vz.paragraph_table_xml}<b>}) - @parablock.gsub!(/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u, - %{</b></td><td width="\\1%" valign="top"> - #{@vz.paragraph_table_xml}<b>}) - @parablock.gsub!(/#{Mx[:tc_c]}/,"</b>\n</td>\n</tr>") + #{@vz.paragraph_table_xml}<b>}). + gsub(/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u, + %{</b></td><td width="\\1%" valign="top"> + #{@vz.paragraph_table_xml}<b>}). + gsub(/#{Mx[:tc_c]}/,"</b>\n</td>\n</tr>") @@tablehead=0 end @parablock else - @parablock.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u, + @parablock=@parablock.gsub(/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u, %{<tr> <td width="\\1%" valign="top"> - #{@vz.paragraph_table_xml}}) - @parablock.gsub!(/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u, - %{ + #{@vz.paragraph_table_xml}}). + gsub(/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u, + %{ </td> <td width="\\1%" valign="top"> - #{@vz.paragraph_table_xml}}) - @parablock.gsub!(/#{Mx[:tc_c]}/,"\n</td>\n</tr>\n") + #{@vz.paragraph_table_xml}}). + gsub(/#{Mx[:tc_c]}/,"\n</td>\n</tr>\n") end @parablock end end - class Table_xml_exp <Table + class TableXMLexp <Table @@tablehead=0 @@tablefoot=[] def initialize(one) - @one,@parablock,@vz=one,one,SiSU_Env::Get_init.instance.skin + @one,@parablock,@vz=one,one,SiSU_Env::GetInit.instance.skin end def table_head(inf) %{<table summary="normal text css" width="100%" border="0" bgcolor="white" cellpadding="2" align="center"> @@ -159,7 +159,7 @@ module SiSU_Tables def table m=@parablock[/<!f(.+?)!>/,1] @@tablefoot << m if m - @parablock.gsub!(/<!f.+?!>/,'') + @parablock=@parablock.gsub(/<!f.+?!>/,'') @@tablehead=1 if @parablock =~/#{Mx[:gr_o]}Th#{Mx[:tc_p]}/u if @parablock =~/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}.+?#{Mx[:tc_p]}~(\d+);\w\d+;\w\d+#{Mx[:gr_c]}/u; @parablock=table_head($1) end @@ -173,26 +173,26 @@ module SiSU_Tables if @@tablehead==1 if @parablock =~/#{Mx[:tc_p]}#{Mx[:tc_p]}/u if @parablock =~/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u - @parablock.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u,table_row($1,true)) + @parablock=@parablock.gsub(/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u,table_row($1,true)) end if @parablock =~/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u - @parablock.gsub!(/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u,table_cell($1,true)) + @parablock=@parablock.gsub(/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u,table_cell($1,true)) end if @parablock =~/#{Mx[:tc_c]}/ - @parablock.gsub!(/#{Mx[:tc_c]}/,table_row_close(true)) + @parablock=@parablock.gsub(/#{Mx[:tc_c]}/,table_row_close(true)) end @@tablehead=0 end @parablock else if @parablock =~/^#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u - @parablock.gsub!(/^#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u,table_row($1)) + @parablock=@parablock.gsub(/^#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u,table_row($1)) end if @parablock =~/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u - @parablock.gsub!(/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u,table_cell($1)) + @parablock=@parablock.gsub(/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u,table_cell($1)) end if @parablock =~/#{Mx[:tc_c]}/ - @parablock.gsub!(/#{Mx[:tc_c]}/,table_row_close) + @parablock=@parablock.gsub(/#{Mx[:tc_c]}/,table_row_close) end @parablock end diff --git a/lib/sisu/v3/zap.rb b/lib/sisu/v3/zap.rb index 3e967e32..9c9b61eb 100644 --- a/lib/sisu/v3/zap.rb +++ b/lib/sisu/v3/zap.rb @@ -63,12 +63,12 @@ module SiSU_Zap class Source def initialize(opt) @opt=opt - @env=SiSU_Env::Info_env.new(@opt.fns) + @env=SiSU_Env::InfoEnv.new(@opt.fns) @zap_path="#{@env.path.output}/#{@env.fnb}" - @zap=SiSU_Env::Clean_output.new(@opt) + @zap=SiSU_Env::CleanOutput.new(@opt) end def read - if SiSU_Env::Info_settings.new.permission?('zap') + if SiSU_Env::InfoSettings.new.permission?('zap') tell=SiSU_Screen::Ansi.new(@opt.cmd,"Clean files related to processing #{@opt.cmd} ->","#{@opt.fns} -> #{@zap_path}") @zap.zap.main_output @zap.zap.site_map |