From 960c3088bc88f2db879154053280b06c160d4d70 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Tue, 21 Apr 2015 14:45:52 -0400 Subject: lib/sisu/*, single libs directory (c&d gone) (7) * removed lib/sisu/{current,develop} dir branches v7 (v5 & v6 retired) * simplify dir structure, offer single version per snapshot * have enjoyed carrying stable and development versions v5 & v6 in a single tarball, may return to this structure --- lib/sisu/develop/src_po4a_sst_ao_sst.rb | 893 -------------------------------- 1 file changed, 893 deletions(-) delete mode 100644 lib/sisu/develop/src_po4a_sst_ao_sst.rb (limited to 'lib/sisu/develop/src_po4a_sst_ao_sst.rb') diff --git a/lib/sisu/develop/src_po4a_sst_ao_sst.rb b/lib/sisu/develop/src_po4a_sst_ao_sst.rb deleted file mode 100644 index c1c85052..00000000 --- a/lib/sisu/develop/src_po4a_sst_ao_sst.rb +++ /dev/null @@ -1,893 +0,0 @@ -# encoding: utf-8 -=begin - -* Name: SiSU - -** Description: documents, structuring, processing, publishing, search -*** pot file generation - -** Author: Ralph Amissah - - - -** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, - All Rights Reserved. - -** License: GPL 3 or later: - - SiSU, a framework for document structuring, publishing and search - - Copyright (C) Ralph Amissah - - This program is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. - - You should have received a copy of the GNU General Public License along with - this program. If not, see . - - If you have Internet connection, the latest version of the GPL should be - available at these locations: - - - - - -** SiSU uses: - * Standard SiSU markup syntax, - * Standard SiSU meta-markup syntax, and the - * Standard SiSU object citation numbering and system - -** Hompages: - - - -** Git - - - -=end -module SiSU_SStm_AO_SStm - require_relative 'ao' # ao.rb - require_relative 'se' # se.rb - include SiSU_Env - require_relative 'ao_composite' # ao_composite.rb - require_relative 'shared_metadata' # shared_metadata.rb - require_relative 'src_po4a_share' # src_po4a_share.rb - require_relative 'src_po4a_sst_ao_sst_set' # src_po4a_sst_ao_sst_set.rb - include SiSU_Param - require_relative 'object_munge' # object_munge.rb - require_relative 'utils_composite' # utils_composite.rb - require_relative 'utils_response' # utils_response.rb - class Source - include SiSU_Object_Munge - include SiSU_Languages_Selected - include SiSU_Response - @@md_src,@@md_master= - nil, nil - @@auto_translation_ = :go - def initialize(opt,fn=nil) - @opt,@fn=opt,fn - #unless @opt.fns =~/(.+?\.(?:-|ssm\.)?sst)$/ - # puts "#{@opt.fns} not a processed file type" - #end - file_arr=SiSU_Info_Env::InfoEnv.new. - source_file_processing_array(@opt.fno) - SiSU_Param::Parameters::Instructions.new(file_arr,@opt).extract - r=Px[:lng_lst_rgx].gsub(/\|#{language.source_language_selected_str}\|/,'|') - @lang_regx=%r{(?:#{r})} - @@todo=if source_language_selected_str == opt.f_pth[:lng] - :same_file - else :compare - end - if opt.f_pth[:lng]==@opt.lng_base \ - and opt.f_pth[:lng]==source_language_selected_str - @@md_master=SiSU_Param::Parameters.new(opt).get - end - end - def wrap_width_set(md,env) - if defined? md.make.plaintext_wrap \ - and md.make.plaintext_wrap - md.make.plaintext_wrap - elsif defined? env.plaintext_wrap \ - and env.plaintext_wrap - #env.plaintext_wrap # 78 use 75 - 75 - else 75 #78 - end - end - def process_file(md,env,file,wrap_width,fn) - if source_language_selected_str == @opt.f_pth[:lng] - @@ao_arr_lang_trans= - SiSU_AO::Source.new( - @opt, - fn, - :po4a - ).get # ao file drawn here - end - @ao_arr_lang_src= - SiSU_AO::Source.new( - @opt, - fn, - :po4a - ).get # ao file drawn here - SiSU_SStm_AO_SStm::Source::Scroll.new( - fn, - @ao_arr_lang_src, - @@ao_arr_lang_trans, - @@md_src, - @@md_master, - wrap_width - ).songsheet - end - def read_process_src_files - begin - src={} - src[:pth]=@opt.f_pth[:pth] - src[:files]=if @opt.fns =~ /\.(?:(?:-|ssm\.)sst|ssm)$/ - @opt.fns=@opt.fns.gsub(/\.ssm\.sst$/,'.ssm') - SiSU_Assemble::CompositeFileList.new(@opt).read - else - [@opt.fns] - end - md=SiSU_Param::Parameters.new(@opt).get - env=SiSU_Env::InfoEnv.new(@opt.fns) - file=SiSU_Env::FileOp.new(md) - lng=/\/([^\/]+)$/.match(src[:pth])[1] - if language.source_language_selected_str == lng - SiSU_Po4a_Project::Po4aDistClean.new(@opt,file).song - end - wrap_width=wrap_width_set(md,env) - lng = /\/([^\/]+)$/.match(src[:pth])[1] - ans=response?('process files?') - if ans - src[:files].each do |fn| - puts "[#{lng}] #{fn}" - process_file(md,env,file,wrap_width,fn) - end - end - rescue - SiSU_Errors::Rescued.new($!,$@,@opt.selections.str,@opt.fns).location do - __LINE__.to_s + ':' + __FILE__ - end - ensure - end - end - def read_setup - begin - md=SiSU_Param::Parameters.new(@opt).get - file=SiSU_Env::FileOp.new(md) - SiSU_Po4a_Project::Po4aCfg.new(@opt,file).song - SiSU_Po4a_Project::Po4aProject.new(@opt,file).song - rescue - SiSU_Errors::Rescued.new($!,$@,@opt.selections.str,@opt.fns).location do - __LINE__.to_s + ':' + __FILE__ - end - ensure - end - end - private - class Scroll 0 \ - and not @@endnotes_ - @pot[:body] << br - wrap_endnotes(notes_s,notes_t) - elsif @@endnotes[:para] \ - and @@endnotes_ - @pot[:body] << br*2 - end - end - def para(dob_src='',notes_s='',dob_trn='',notes_t='') #% used to extract the structure of a document - util=nil - wrapped=if dob_src.indent =~/[1-9]/ \ - and dob_src.indent == dob_src.hang - s_mark=desc=orig=trans='' - mark=if dob_src.bullet_ - "_#{dob_src.indent}* " - else - "_#{dob_src.indent} " - end - orig="#{mark}#{dob_src.obj}" - trans=((dob_trn=='') \ - || (dob_src.obj == dob_trn.obj)) \ - ? '' - : "#{mark}#{dob_trn.obj}" - if @md.opt.f_pth[:lng_is] !=@md.opt.lng_base \ - and trans.empty? \ - and auto_translate? - trans=auto_translation(dob_src.obj,:src) - end - util=pot_structure_wrap(orig,trans) - elsif dob_src.hang =~/[0-9]/ \ - and dob_src.indent != dob_src.hang - s_mark=desc=orig=trans='' - mark="_#{dob_src.hang}_#{dob_src.indent} " - orig="#{mark}#{dob_src.obj}" - trans=((dob_trn=='') \ - || (dob_src.obj == dob_trn.obj)) \ - ? '' - : "#{mark}#{dob_trn.obj}" - if @md.opt.f_pth[:lng_is] !=@md.opt.lng_base \ - and trans.empty? \ - and auto_translate? - trans=auto_translation(dob_src.obj,:src) - end - util=pot_structure_wrap(orig,trans) - else - s_mark=desc=orig=trans='' - if dob_src.bullet_ - mark='_* ' - orig="#{mark}#{dob_src.obj}" - trans=((dob_trn=='') \ - || (dob_src.obj == dob_trn.obj)) \ - ? '' - : "#{mark}#{dob_trn.obj}" - if @md.opt.f_pth[:lng_is] !=@md.opt.lng_base \ - and trans.empty? \ - and auto_translate? - trans=auto_translation(dob_src.obj,:src) - end - else - mark='' - orig=dob_src.obj - trans=((dob_trn=='') \ - || (dob_src.obj == dob_trn.obj)) \ - ? '' - : "#{mark}#{dob_trn.obj}" - if @md.opt.f_pth[:lng_is] !=@md.opt.lng_base \ - and trans.empty? \ - and auto_translate? - trans=auto_translation(dob_src.obj,:src) - end - end - util=pot_structure_wrap(orig,trans) - end - wrapped=util.line_wrap - @pot[:body] << wrapped << br # main text, contents, body KEEP - if @@endnotes[:para] \ - and notes_s.length > 0 \ - and not @@endnotes_ - @pot[:body] << br - wrap_endnotes(notes_s,notes_t) - elsif @@endnotes[:para] \ - and @@endnotes_ - @pot[:body] << br*2 - end - end - def block(dob_src='',notes_s='',dob_trn='',notes_t='') #% used to extract the structure of a document - mark_o ="block{\n\n" - mark_c ="\n\n}block" - orig="#{mark_o}#{dob_src.obj}#{mark_c}" - trans=((dob_trn=='') \ - || (dob_src.obj == dob_trn.obj)) \ - ? '' - : "#{mark_o}#{dob_trn.obj}#{mark_c}" - if @md.opt.f_pth[:lng_is] !=@md.opt.lng_base \ - and trans.empty? \ - and auto_translate? - trans=auto_translation(dob_src.obj,:src) - end - util=pot_structure_wrap(orig,trans) - unwrapped=util.no_line_wrap_block - @pot[:body] << unwrapped << br - end - def group(dob_src='',notes_s='',dob_trn='',notes_t='') #% used to extract the structure of a document - mark_o ="group{\n\n" - mark_c ="\n\n}group" - orig="#{mark_o}#{dob_src.obj}#{mark_c}" - trans=((dob_trn=='') \ - || (dob_src.obj == dob_trn.obj)) \ - ? '' - : "#{mark_o}#{dob_trn.obj}#{mark_c}" - if @md.opt.f_pth[:lng_is] !=@md.opt.lng_base \ - and trans.empty? \ - and auto_translate? - trans=auto_translation(dob_src.obj,:src) - end - util=pot_structure_wrap(orig,trans) - unwrapped=util.no_line_wrap_block - @pot[:body] << unwrapped << br - end - def verse(dob_src='',notes_s='',dob_trn='',notes_t='') #% used to extract the structure of a document - mark="poem{\n\nverse\n\nverse\n\n...\n\n}poem" - instruct=s_mark='' - if @md.opt.act[:maintenance][:set]==:on - instruct=%{\n# verse are part of the text block described as a poem, } \ - + %{the first verse is preceeded by an opening marker, } \ - + %{and the last verse by a closing marker, } \ - + %{the content of which should remain unwrapped} - s_mark="\n# " + %{"\\n\\n#{mark}\\n\\n"} - end - orig=dob_src.obj - trans=(dob_trn=='') \ - ? '' - : dob_trn.obj - util=pot_structure_wrap(orig,trans) - unwrapped=util.no_line_wrap_block - @pot[:body] << unwrapped << br - end - def code(dob_src='',notes_s='',dob_trn='',notes_t='') #% used to extract the structure of a document - mark_o ="code{\n\n" - mark_c ="\n\n}code" - orig="#{mark_o}#{dob_src.obj}#{mark_c}" - trans=(dob_trn=='') \ - ? '' - : "#{mark_o}#{dob_trn.obj}#{mark_c}" - util=pot_structure_wrap(orig,trans) - unwrapped=util.no_line_wrap_block - @pot[:body] << unwrapped << br - end - def table(dob_src='',notes_s='',dob_trn='',notes_t='') #% used to extract the structure of a document - mark_o ="table{\n\n" - mark_c ="\n\n}table" - orig="#{mark_o}#{dob_src.obj}#{mark_c}" - orig=orig.gsub(/#{Mx[:tc_c]}/m,"\n") - trans=(dob_trn=='') \ - ? '' - : "#{mark_o}#{dob_trn.obj}#{mark_c}" - trans=trans.gsub(/#{Mx[:tc_c]}/m,"\n") - util=pot_structure_wrap(orig,trans) - unwrapped=util.no_line_wrap_block - @pot[:body] << unwrapped << br - end - def idx_markup(idx) - struct=['={' + "\n "] - idx.sort.each do |x| - x.each_with_index do |y,i0| - case y - when String - unless struct[-1] =~/=\{/ - struct << ' ;' + "\n " - end - struct << y - if x[i0+1].class == Hash \ - and x[i0+1][:sub].length > 0 - struct << ' :' + "\n " - end - when Hash - if y[:plus].to_i > 0 - struct << '+' + y[:plus].to_s - end - if y[:sub].length > 0 - y[:sub].each_with_index do |z,i1| - z.each_with_index do |a,i2| - if z.length > 0 - struct << a[0] - if a[1][:plus].to_i > 0 - struct << '+' + a[1][:plus].to_s - end - if (i1 + 1) < y[:sub].length - struct << '|' - end - end - end - end - end - end - end - end - struct << "\n" + '}' - #puts struct.join - struct.join - end - def idx(dob_src='') #% used for book index but broken as original markup lost, already abstracted, fix - orig=pot_structure.idx_markup(dob_src.idx) #'={' + dob_src.idx + '}' - util=pot_structure_wrap(orig,'') - unwrapped=util.no_line_wrap_block - if @pot[:body][-1] == "\n" - @pot[:body][-1] = unwrapped #<< br - @pot[:body] << br - else # expect to catch all above, problem if wraps, must =~/^=\{/ - @pot[:body] << unwrapped << br # places idx in separate object - end - end - self - end - def compare_structure_src_trn(data_src,data_trn,todo) - #@endnotes,@copen,@pot_contents_close=Array.new(3){[]} - a_l= data_src.length - s,t=0,0 - 0.upto(a_l-1) do |i| - if todo==:compare - unless data_src[s] \ - and data_trn[t] - break - end - if data_src[s].of == :comment \ - and data_trn[t].of == :comment \ - and (data_src[s].is == data_trn[t].is) - s+=1;t+=1 - next - end - if ((data_src[s].is == :comment) \ - || (data_trn[t].is == :comment)) \ - and (data_src[s].is != data_trn[t].is) - if data_src[s].is == :comment - if @md.opt.act[:maintenance][:set]==:on - puts "src (comment):\n\t" \ - + data_src[s].obj - end - s+=1 - #next if data_src[s].is == :comment - elsif data_trn[t].is == :comment - if @md.opt.act[:maintenance][:set]==:on - puts "trans (comment):\n\t" \ - + data_trn[t].obj - end - t+=1 - #next if data_trn[t].is == :comment - end - end - if ((defined? data_src[s].ocn) \ - && (data_src[s].ocn.is_a?(Fixnum))) \ - and ((defined? data_trn[t].ocn) \ - && (data_trn[t].ocn.is_a?(Fixnum))) \ - and (data_src[s].ocn == data_trn[t].ocn) - @m_s,@m_t=s,t - elsif ((defined? data_src[s].ocn) \ - && (data_src[s].ocn.is_a?(Fixnum))) \ - and ((defined? data_trn[t].ocn) \ - && (data_trn[t].ocn.is_a?(Fixnum))) \ - and (data_src[s].ocn != data_trn[t].ocn) - p '--- OCN ---' - p 'mis-match' - p data_src[s].ocn if defined? data_src[s].ocn - p data_src[s].obj if defined? data_src[s].obj - p data_trn[t].ocn if defined? data_trn[t].ocn - p data_trn[t].obj if defined? data_trn[t].obj - p '---' - p 'previous match' - p data_src[@m_s].ocn if defined? data_src[@m_s].ocn - p data_src[@m_s].obj if defined? data_src[@m_s].obj - p data_trn[@m_t].ocn if defined? data_trn[@m_t].ocn - p data_trn[@m_t].obj if defined? data_trn[@m_s].obj - exit - elsif (((defined? data_src[s].ocn) \ - && (defined? data_trn[t].ocn)) \ - and data_src[s].ocn.class != data_trn[t].ocn.class) - p '--- OCN class ---' - p 'mis-match' - p data_src[s].ocn if defined? data_src[s].ocn - p data_src[s].obj if defined? data_src[s].obj - p data_trn[t].ocn if defined? data_trn[t].ocn - p data_trn[t].obj if defined? data_trn[t].obj - #p '---' - #p 'previous match' - #p data_src[@m_s].ocn - #p data_src[@m_s].obj - #p data_trn[@m_t].ocn - #p data_trn[@m_t].obj - #elsif (defined? data_src[s].ocn != defined? data_trn[t].ocn) \ - #and (data_src[s].ocn.nil? != data_trn[t].ocn.nil?) - # p '--- missing OCN? ---' - # p 'mis-match' - # p data_src[s].ocn if defined? data_src[s].ocn - # p data_src[s].obj - # p data_trn[t].ocn if defined? data_trn[t].ocn - # p data_trn[t].obj - else - end - end - notes_s='' - data_src[s],notes_s=markup(data_src[s]) - data_src[s],nul=pot_data(data_src[s],notes_s) - s+=1;t+=1 - end - @pot #watch - end - def pot_data(dob_src='',notes_s) - if dob_src.obj !~/(^#{Rx[:meta]}|#{Mx[:br_eof]}|#{Mx[:br_endnotes]})/ - if defined? dob_src.ocn \ - and dob_src.ocn.to_s =~/\d+/ - paranum=dob_src.ocn.to_s - @p_num=SiSU_Po4aUtils::ParagraphNumber.new(paranum) - end - case dob_src.is - when :heading - pot_structure.heading(dob_src,notes_s) - when :para - pot_structure.para(dob_src,notes_s) - when :group - pot_structure.group(dob_src,notes_s) - when :block - pot_structure.block(dob_src,notes_s) - when :verse - pot_structure.verse(dob_src,notes_s) - when :code - pot_structure.code(dob_src,notes_s) - when :table - pot_structure.table(dob_src,notes_s) - end - if defined? dob_src.idx \ - and not dob_src.idx.nil? \ - and not dob_src.idx.empty? - pot_structure.idx(dob_src) - end - #if dob_src ## Clean Prepared Text - # dob_src.obj=dob_src.obj.gsub(//,' '). - # gsub(/<:\S+>/,' ') if dob_src ## Clean Prepared Text - #end - end - #[dob_src,dob_trn] - end - def markup(dob) - dob,notes=objects.textface_marks_po4a(dob,:separate) - [dob,notes] - end - def publish(fn,pot) - content=[] - content << pot[:open] - content << pot[:head] - content << pot[:metadata] - content << pot[:body] - content << @@endnotes[:end] if @@endnotes_ - Output.new(fn,content,@md,@process).po4a - @@endnotes={ para: [], end: [] } - end - end - class Output 0 - para.each do |line| - if line - line=line.gsub(/\s+$/m,''). - gsub(/^\A[ ]*\Z/m,'') - if line=~/^\A[ ]*\Z/m - emptyline+=1 - else emptyline=0 - end - file_pot.puts line if emptyline < 2 #remove extra line spaces (fix upstream) - end - end - else file_pot.puts para #unix plaintext # /^([*=-]|\.){5}/ - end - end - file_pot.close - SiSU_Po4aUtils::PotNumber.new.reset - #po4a_git - end - def po4a_git - unless @md.opt.act[:maintenance][:set]==:on - require_relative 'git' # git.rb - git=SiSU_Git::Source.new(@md.opt,@process) - unless FileTest.directory?(@file.output_path.pot_git.dir) - git.create_file_structure_git - end - if @md.opt.f_pth[:lng] == @md.opt.lng_base - FileUtils::cp( - @file.place_file.pot.dir, - @file.output_path.pot_git.dir - ) - else # naive, work on --> - FileUtils::cp( - @file.place_file.po.dir, - @file.output_path.po_git.dir - ) #unless FileTest.file?(@file.place_file.po_git.dir) - end - git.read - end - end - end - end -end -__END__ -REMOVE -!\|#\|&*\|-\|/\|_\|{\|}\|~\|&# - -tables are problematic, difficult to reconstitute instruction, check - -metadata, move to top? and work on - -footnotes, different types, asterisk, also do you want to have separate -paragraphs, or breaks within one block? - -where no ocn appropriately use ~# or -# or indeed 1~name- - -comments in document, what to do about them, not sure they are currently -retained in dal, could be quite valuable to keep - -Translate Shell -http://www.soimort.org/translate-shell/ -translate.google.com -- cgit v1.2.3