diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/sisu/v5/concordance.rb | 4 | ||||
-rw-r--r-- | lib/sisu/v5/db_import.rb | 2 | ||||
-rw-r--r-- | lib/sisu/v5/dbi.rb | 2 | ||||
-rw-r--r-- | lib/sisu/v5/dbi_discrete.rb | 2 | ||||
-rw-r--r-- | lib/sisu/v5/html_format.rb | 2 | ||||
-rw-r--r-- | lib/sisu/v5/html_lite_shared.rb (renamed from lib/sisu/v5/shared_html_lite.rb) | 2 | ||||
-rw-r--r-- | lib/sisu/v5/html_scroll.rb | 2 | ||||
-rw-r--r-- | lib/sisu/v5/html_segments.rb | 2 | ||||
-rw-r--r-- | lib/sisu/v5/html_shared.rb (renamed from lib/sisu/v5/shared_html.rb) | 2 | ||||
-rw-r--r-- | lib/sisu/v5/hub.rb | 18 | ||||
-rw-r--r-- | lib/sisu/v5/manpage.rb | 4 | ||||
-rw-r--r-- | lib/sisu/v5/plaintext_format.rb | 104 | ||||
-rw-r--r-- | lib/sisu/v5/sitemaps.rb | 2 | ||||
-rw-r--r-- | lib/sisu/v5/src_kdissert_share.rb (renamed from lib/sisu/v5/share_src_kdissert.rb) | 2 | ||||
-rw-r--r-- | lib/sisu/v5/src_share.rb (renamed from lib/sisu/v5/share_src.rb) | 4 | ||||
-rw-r--r-- | lib/sisu/v5/src_shared.rb (renamed from lib/sisu/v5/shared_sisupod_source.rb) | 2 | ||||
-rw-r--r-- | lib/sisu/v5/src_sisupod_make.rb (renamed from lib/sisu/v5/sisupod_make.rb) | 4 | ||||
-rw-r--r-- | lib/sisu/v5/sst_to_s_xml_sax.rb | 4 | ||||
-rw-r--r-- | lib/sisu/v5/txt_plain.rb (renamed from lib/sisu/v5/plaintext.rb) | 8 | ||||
-rw-r--r-- | lib/sisu/v5/txt_shared.rb (renamed from lib/sisu/v5/shared_txt.rb) | 8 | ||||
-rw-r--r-- | lib/sisu/v5/wikispeak.rb | 4 | ||||
-rw-r--r-- | lib/sisu/v5/xhtml.rb | 6 | ||||
-rw-r--r-- | lib/sisu/v5/xhtml_epub2.rb (renamed from lib/sisu/v5/epub.rb) | 108 | ||||
-rw-r--r-- | lib/sisu/v5/xhtml_epub2_concordance.rb (renamed from lib/sisu/v5/epub_concordance.rb) | 26 | ||||
-rw-r--r-- | lib/sisu/v5/xhtml_epub2_format.rb (renamed from lib/sisu/v5/epub_format.rb) | 6 | ||||
-rw-r--r-- | lib/sisu/v5/xhtml_epub2_segments.rb (renamed from lib/sisu/v5/epub_segments.rb) | 68 | ||||
-rw-r--r-- | lib/sisu/v5/xhtml_epub2_tune.rb (renamed from lib/sisu/v5/epub_tune.rb) | 20 | ||||
-rw-r--r-- | lib/sisu/v5/xhtml_shared.rb (renamed from lib/sisu/v5/shared_xhtml.rb) | 2 | ||||
-rw-r--r-- | lib/sisu/v5/xml_dom.rb | 6 | ||||
-rw-r--r-- | lib/sisu/v5/xml_fictionbook.rb | 305 | ||||
-rw-r--r-- | lib/sisu/v5/xml_odf_odt.rb (renamed from lib/sisu/v5/odf.rb) | 28 | ||||
-rw-r--r-- | lib/sisu/v5/xml_odf_odt_format.rb (renamed from lib/sisu/v5/odf_format.rb) | 4 | ||||
-rw-r--r-- | lib/sisu/v5/xml_sax.rb | 6 | ||||
-rw-r--r-- | lib/sisu/v5/xml_shared.rb (renamed from lib/sisu/v5/shared_xml.rb) | 70 |
34 files changed, 233 insertions, 606 deletions
diff --git a/lib/sisu/v5/concordance.rb b/lib/sisu/v5/concordance.rb index 8c675e36..3bb313d4 100644 --- a/lib/sisu/v5/concordance.rb +++ b/lib/sisu/v5/concordance.rb @@ -113,8 +113,8 @@ module SiSU_Concordance private 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 + #revisit, both requires (html & xml_shared) needed for stand alone operation (sisu -w [filename]) + require_relative 'xml_shared' # xml_shared.rb require_relative 'html' # html.rb def initialize(particulars) @particulars,@md=particulars,particulars.md diff --git a/lib/sisu/v5/db_import.rb b/lib/sisu/v5/db_import.rb index 8a8cc13d..dc73bbf5 100644 --- a/lib/sisu/v5/db_import.rb +++ b/lib/sisu/v5/db_import.rb @@ -64,7 +64,7 @@ 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_relative 'html_lite_shared' # html_lite_shared.rb require 'sqlite3' class Import < SiSU_DbText::Prepare include SiSU_Param diff --git a/lib/sisu/v5/dbi.rb b/lib/sisu/v5/dbi.rb index e59a09b7..6a40d3ce 100644 --- a/lib/sisu/v5/dbi.rb +++ b/lib/sisu/v5/dbi.rb @@ -66,7 +66,7 @@ module SiSU_DBI include SiSU_Param require_relative 'db_dbi' # db_dbi.rb include SiSU_DbDBI - require_relative 'shared_html_lite' # shared_html_lite.rb + require_relative 'html_lite_shared' # html_lite_shared.rb include SiSU_FormatShared class SQL def initialize(opt) diff --git a/lib/sisu/v5/dbi_discrete.rb b/lib/sisu/v5/dbi_discrete.rb index 957009b1..95fb9ce3 100644 --- a/lib/sisu/v5/dbi_discrete.rb +++ b/lib/sisu/v5/dbi_discrete.rb @@ -66,7 +66,7 @@ module SiSU_DBI_Discrete #% database building include SiSU_Param require_relative 'db_dbi' # db_dbi.rb include SiSU_DbDBI - require_relative 'shared_html_lite' # shared_html_lite.rb + require_relative 'html_lite_shared' # html_lite_shared.rb include SiSU_FormatShared require 'fileutils' include FileUtils::Verbose diff --git a/lib/sisu/v5/html_format.rb b/lib/sisu/v5/html_format.rb index 3a20ef67..db9fb449 100644 --- a/lib/sisu/v5/html_format.rb +++ b/lib/sisu/v5/html_format.rb @@ -93,7 +93,7 @@ module SiSU_HTML_Format end class HeadInformation require_relative 'css' # css.rb - require_relative 'shared_xml' # shared_xml.rb + require_relative 'xml_shared' # xml_shared.rb include SiSU_Viz attr_reader :md,:rdf,:vz def initialize(md) diff --git a/lib/sisu/v5/shared_html_lite.rb b/lib/sisu/v5/html_lite_shared.rb index e46510ea..20e07f8c 100644 --- a/lib/sisu/v5/shared_html_lite.rb +++ b/lib/sisu/v5/html_lite_shared.rb @@ -50,7 +50,7 @@ * Git <http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=summary> - <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v5/shared_html_lite.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v5/html_lite_shared.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> diff --git a/lib/sisu/v5/html_scroll.rb b/lib/sisu/v5/html_scroll.rb index 3ac75aaa..f525b462 100644 --- a/lib/sisu/v5/html_scroll.rb +++ b/lib/sisu/v5/html_scroll.rb @@ -60,7 +60,7 @@ =end module SiSU_HTML_Scroll - require_relative 'shared_html' # shared_html.rb + require_relative 'html_shared' # html_shared.rb require_relative 'html' # html.rb require_relative 'shared_metadata' # shared_metadata.rb require_relative 'html_promo' # html_promo.rb diff --git a/lib/sisu/v5/html_segments.rb b/lib/sisu/v5/html_segments.rb index 79dda0e2..d6b341ac 100644 --- a/lib/sisu/v5/html_segments.rb +++ b/lib/sisu/v5/html_segments.rb @@ -60,7 +60,7 @@ =end module SiSU_HTML_Seg - require_relative 'shared_html' # shared_html.rb + require_relative 'html_shared' # html_shared.rb require_relative 'html' # html.rb require_relative 'html_promo' # html_promo.rb require_relative 'shared_metadata' # shared_metadata.rb diff --git a/lib/sisu/v5/shared_html.rb b/lib/sisu/v5/html_shared.rb index 84c89ecf..63a8964e 100644 --- a/lib/sisu/v5/shared_html.rb +++ b/lib/sisu/v5/html_shared.rb @@ -50,7 +50,7 @@ * Git <http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=summary> - <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v5/shared_html.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v5/html_shared.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> diff --git a/lib/sisu/v5/hub.rb b/lib/sisu/v5/hub.rb index 9390d517..a4fd408f 100644 --- a/lib/sisu/v5/hub.rb +++ b/lib/sisu/v5/hub.rb @@ -299,8 +299,8 @@ module SiSU SiSU_DigestView::Source.new(@opt).read end if @opt.act[:txt][:set]==:on #% --txt, -t -a - require_relative 'plaintext' # plaintext.rb - SiSU_Plaintext::Source.new(@opt).read + require_relative 'txt_plain' # txt_plain.rb + SiSU_Txt_Plain::Source.new(@opt).read end if @opt.act[:html][:set]==:on #% --html, -h -H require_relative 'html' # html.rb @@ -320,12 +320,12 @@ module SiSU SiSU_Concordance::Source.new(@opt).read end if @opt.act[:epub][:set]==:on #% --epub, -e - require_relative 'epub' # epub.rb - SiSU_EPUB::Source.new(@opt).read + require_relative 'xhtml_epub2' # xhtml_epub2.rb + SiSU_XHTML_EPUB2::Source.new(@opt).read end if @opt.act[:odt][:set]==:on #% --odt, -o opendocument - require_relative 'odf' # odf.rb - SiSU_ODF::Source.new(@opt).read + require_relative 'xml_odf_odt' # xml_odf_odt.rb + SiSU_XML_ODF_ODT::Source.new(@opt).read end if @opt.act[:xhtml][:set]==:on #% --xhtml, -b xhtml require_relative 'xhtml' # xhtml.rb @@ -391,12 +391,12 @@ module SiSU or @opt.act[:sisupod][:set]==:on \ or @opt.act[:git][:set]==:on begin - require_relative 'shared_sisupod_source' + require_relative 'src_shared' OptionLoopFiles.new(@opt).loop_files_on_given_option do SiSU_Source::SiSUpodSource.new(@opt).read end if @opt.act[:share_source][:set]==:on - require_relative 'share_src' # -s share_src.rb + require_relative 'src_share' # -s src_share.rb begin ensure OptionLoopFiles.new(@opt).loop_files_on_given_option_bundle do @@ -405,7 +405,7 @@ module SiSU end end if @opt.act[:sisupod][:set]==:on #% --sisupod, -S make sisupod - require_relative 'sisupod_make' # -S sisupod_make.rb + require_relative 'src_sisupod_make' # -S src_sisupod_make.rb begin ensure OptionLoopFiles.new(@opt).loop_files_on_given_option_bundle do diff --git a/lib/sisu/v5/manpage.rb b/lib/sisu/v5/manpage.rb index 905cf87f..ccdd829c 100644 --- a/lib/sisu/v5/manpage.rb +++ b/lib/sisu/v5/manpage.rb @@ -69,7 +69,7 @@ module SiSU_Manpage require_relative 'manpage_format' # manpage_format.rb include SiSU_ManpageFormat require_relative 'shared_metadata' # shared_metadata.rb - require_relative 'shared_txt' # shared_txt.rb + require_relative 'txt_shared' # txt_shared.rb @@alt_id_count,@@alt_id_count,@@tablehead,@@number_of_cols=0,0,0,0 @@tablefoot='' class Source @@ -112,7 +112,7 @@ module SiSU_Manpage private class Scroll <Source require_relative 'defaults' # defaults.rb - require_relative 'shared_txt' # shared_txt.rb + require_relative 'txt_shared' # txt_shared.rb include SiSU_TextUtils @@endnotes={ para: [], end: [] } def initialize(md,data) diff --git a/lib/sisu/v5/plaintext_format.rb b/lib/sisu/v5/plaintext_format.rb deleted file mode 100644 index acad8828..00000000 --- a/lib/sisu/v5/plaintext_format.rb +++ /dev/null @@ -1,104 +0,0 @@ -# encoding: utf-8 -=begin - - * Name: SiSU - - * Description: a framework for document structuring, publishing and search - - * Author: Ralph Amissah - - * Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013 Ralph Amissah, All Rights Reserved. - - * License: GPL 3 or later: - - SiSU, a framework for document structuring, publishing and search - - Copyright (C) Ralph Amissah - - This program is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. - - You should have received a copy of the GNU General Public License along with - this program. If not, see <http://www.gnu.org/licenses/>. - - If you have Internet connection, the latest version of the GPL should be - available at these locations: - <http://www.fsf.org/licensing/licenses/gpl.html> - <http://www.gnu.org/licenses/gpl.html> - - <http://www.sisudoc.org/sisu/en/manifest/gpl.fsf.html> - - * SiSU uses: - * Standard SiSU markup syntax, - * Standard SiSU meta-markup syntax, and the - * Standard SiSU object citation numbering and system - - * Hompages: - <http://www.jus.uio.no/sisu> - <http://www.sisudoc.org> - - * Download: - <http://www.sisudoc.org/sisu/en/SiSU/download.html> - - * Git - <http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=summary> - <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v5/plaintext_format.rb;hb=HEAD> - - * Ralph Amissah - <ralph@amissah.com> - <ralph.amissah@gmail.com> - - ** Description: plaintext formatting template - -=end -module SiSU_Plaintext_Format - require_relative 'param' # param.rb - include SiSU_Param - include SiSU_Viz - class ParagraphNumber - def initialize(paranum) - @paranum=/(\d+)/m.match(paranum.to_s)[1] - end - def display - @paranum.gsub(/(\d+)/,"\n#{Dx[:ocn_o]}\\1#{Dx[:ocn_c]}") - end - def name #unused - @paranum.gsub(/(\d+)/,'\1') - end - def goto #unused - @paranum.gsub(/(\d+)/,'"#\1"') - end - end - class FormatTextObject - def initialize(md,t_o) - @md,@t_o=md,t_o - if t_o.is_a?(Hash) - @txt =t_o[:txt] || nil - @lnk_url =t_o[:lnk_url] || nil - @lnk_txt =t_o[:lnk_txt] || nil - else - p t_o.class - p caller - end - rgx=/^#{Rx[:lv]}/ - @txt=@txt.gsub(rgx,'') if @txt =~rgx - rgx=/#{Mx[:en_a_o]}[\d*+]+\s+(.+?)#{Mx[:en_a_c]}/ - @txt=@txt.gsub(rgx,'\1') if @txt =~rgx - @vz=SiSU_Viz::Defaults.new - end - def scr_endnote_body - "<endnote>#{@txt}</endnote> " - end - end - class XML - end -end -__END__ diff --git a/lib/sisu/v5/sitemaps.rb b/lib/sisu/v5/sitemaps.rb index 8e4d1410..6e81369a 100644 --- a/lib/sisu/v5/sitemaps.rb +++ b/lib/sisu/v5/sitemaps.rb @@ -64,7 +64,7 @@ module SiSU_Sitemaps include SiSU_Param require_relative 'sysenv' # sysenv.rb include SiSU_Env - require_relative 'shared_xml' # shared_xml.rb + require_relative 'xml_shared' # xml_shared.rb include SiSU_XML_Munge class Source def initialize(opt) diff --git a/lib/sisu/v5/share_src_kdissert.rb b/lib/sisu/v5/src_kdissert_share.rb index b696891e..a71aca99 100644 --- a/lib/sisu/v5/share_src_kdissert.rb +++ b/lib/sisu/v5/src_kdissert_share.rb @@ -50,7 +50,7 @@ * Git <http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=summary> - <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v5/share_src_kdissert.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v5/src_share_kdissert.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> diff --git a/lib/sisu/v5/share_src.rb b/lib/sisu/v5/src_share.rb index 69dd7bb9..1aba0d95 100644 --- a/lib/sisu/v5/share_src.rb +++ b/lib/sisu/v5/src_share.rb @@ -50,7 +50,7 @@ * Git <http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=summary> - <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v5/share_src.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v5/src_share.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -60,7 +60,7 @@ =end module SiSU_Markup - require_relative 'shared_sisupod_source' # shared_sisupod_source.rb + require_relative 'src_shared' # src_shared.rb include SiSU_Source require_relative 'sysenv' # sysenv.rb include SiSU_Env diff --git a/lib/sisu/v5/shared_sisupod_source.rb b/lib/sisu/v5/src_shared.rb index 021d2e0f..65c4288e 100644 --- a/lib/sisu/v5/shared_sisupod_source.rb +++ b/lib/sisu/v5/src_shared.rb @@ -50,7 +50,7 @@ * Git <http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=summary> - <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v5/shared_sisupod_source.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v5/src_shared.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> diff --git a/lib/sisu/v5/sisupod_make.rb b/lib/sisu/v5/src_sisupod_make.rb index 4a53e968..d244ece4 100644 --- a/lib/sisu/v5/sisupod_make.rb +++ b/lib/sisu/v5/src_sisupod_make.rb @@ -50,7 +50,7 @@ * Git <http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=summary> - <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v5/sisupod_make.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v5/src_sisupod_make.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -60,7 +60,7 @@ =end module SiSU_Doc - require_relative 'shared_sisupod_source' # shared_sisupod_source.rb + require_relative 'src_shared' # scr_shared.rb include SiSU_Source require_relative 'sysenv' # sysenv.rb include SiSU_Env diff --git a/lib/sisu/v5/sst_to_s_xml_sax.rb b/lib/sisu/v5/sst_to_s_xml_sax.rb index 09fecc9e..5f18496a 100644 --- a/lib/sisu/v5/sst_to_s_xml_sax.rb +++ b/lib/sisu/v5/sst_to_s_xml_sax.rb @@ -69,7 +69,7 @@ module SiSU_SimpleXML_ModelSax require_relative 'sysenv' # sysenv.rb include SiSU_Env require_relative 'ao_doc_str' # ao_doc_str.rb - require_relative 'shared_xml' # shared_xml.rb + require_relative 'xml_shared' # xml_shared.rb include SiSU_XML_Munge require_relative 'shared_sem' # shared_sem.rb require_relative 'xml_format' # xml_format.rb @@ -138,7 +138,7 @@ module SiSU_SimpleXML_ModelSax end end class Scroll - require_relative 'shared_txt' # shared_txt.rb + require_relative 'txt_shared' # txt_shared.rb require_relative 'css' # css.rb include SiSU_TextUtils @@xml={ body: [], open: [], close: [], head: [] } diff --git a/lib/sisu/v5/plaintext.rb b/lib/sisu/v5/txt_plain.rb index 57838342..e6a8f46f 100644 --- a/lib/sisu/v5/plaintext.rb +++ b/lib/sisu/v5/txt_plain.rb @@ -64,10 +64,10 @@ module SiSU_Plaintext require_relative 'ao' # ao.rb require_relative 'sysenv' # sysenv.rb include SiSU_Env - require_relative 'plaintext_format' # plaintext_format.rb + require_relative 'txt_plaint_format' # plaintext_format.rb include SiSU_Plaintext_Format require_relative 'shared_metadata' # shared_metadata.rb - require_relative 'shared_txt' # shared_txt.rb + require_relative 'txt_shared' # txt_shared.rb include SiSU_Param include SiSU_Viz @@alt_id_count,@@alt_id_count,@@tablehead,@@number_of_cols=0,0,0,0 @@ -109,7 +109,7 @@ module SiSU_Plaintext else 78 end #wrap_width=(defined? md.make.plaintext_wrap) ? md.make.plaintext_wrap : 78 - SiSU_Plaintext::Source::Scroll.new(md,ao_array,wrap_width).songsheet + SiSU_Txt_Plain::Source::Scroll.new(md,ao_array,wrap_width).songsheet rescue SiSU_Errors::Rescued.new($!,$@,@opt.cmd,@opt.fns).location do __LINE__.to_s + ':' + __FILE__ @@ -120,7 +120,7 @@ module SiSU_Plaintext private class Scroll <Source require_relative 'defaults' # defaults.rb - require_relative 'shared_txt' # shared_txt.rb + require_relative 'txt_shared' # txt_shared.rb include SiSU_TextUtils @@endnotes={ para: [], end: [] } def initialize(md,data,wrap_width) diff --git a/lib/sisu/v5/shared_txt.rb b/lib/sisu/v5/txt_shared.rb index 0e3b6018..31a976d2 100644 --- a/lib/sisu/v5/shared_txt.rb +++ b/lib/sisu/v5/txt_shared.rb @@ -50,7 +50,7 @@ * Git <http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=summary> - <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v5/shared_txt.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v5/txt_shared.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -128,6 +128,12 @@ module SiSU_TextUtils end @arr end + def no_wrap + @para + end + def no_wrap_no_breaks + @para.gsub(/\n/m,' ').gsub(/\s\s+/,' ') + end end class HeaderScan def initialize(md,para) diff --git a/lib/sisu/v5/wikispeak.rb b/lib/sisu/v5/wikispeak.rb index 65e87c13..b87fef61 100644 --- a/lib/sisu/v5/wikispeak.rb +++ b/lib/sisu/v5/wikispeak.rb @@ -67,7 +67,7 @@ module SiSU_Wikispeak include SiSU_Viz require_relative 'plaintext_format' # plaintext_format.rb include Format - require_relative 'shared_txt' + require_relative 'txt_shared' @@alt_id_count,@@alt_id_count,@@tablehead,@@number_of_cols=0,0,0,0 @@tablefoot='' class Source @@ -149,7 +149,7 @@ module SiSU_Wikispeak end end class Scroll <Source - require_relative 'shared_txt' # shared_txt.rb + require_relative 'txt_shared' # txt_shared.rb include SiSU_TextUtils @@endnotes_para=[] @@wiki={ body: [], open: [], close: [], head: [], metadata: [], tail: [], endnotes: [] } diff --git a/lib/sisu/v5/xhtml.rb b/lib/sisu/v5/xhtml.rb index 995316b1..841ae03e 100644 --- a/lib/sisu/v5/xhtml.rb +++ b/lib/sisu/v5/xhtml.rb @@ -66,7 +66,7 @@ module SiSU_XHTML include SiSU_Particulars require_relative 'sysenv' # sysenv.rb include SiSU_Env - require_relative 'shared_xml' # shared_xml.rb + require_relative 'xml_shared' # xml_shared.rb include SiSU_XML_Munge require_relative 'xml_format' # xml_format.rb include SiSU_XML_Format @@ -134,8 +134,8 @@ module SiSU_XHTML end end class Scroll - require_relative 'shared_xhtml' # shared_xhtml.rb #check already called - require_relative 'shared_txt' # shared_txt.rb + require_relative 'xhtml_shared' # xhtml_shared.rb #check already called + require_relative 'txt_shared' # txt_shared.rb include SiSU_TextUtils require_relative 'css' # css.rb @@xml={ body: [], sisu: [], open: [], close: [], head: [] } diff --git a/lib/sisu/v5/epub.rb b/lib/sisu/v5/xhtml_epub2.rb index 5f4957aa..c54d77ff 100644 --- a/lib/sisu/v5/epub.rb +++ b/lib/sisu/v5/xhtml_epub2.rb @@ -59,20 +59,20 @@ ** Description: epub generation, processing =end -module SiSU_EPUB +module SiSU_XHTML_EPUB2 require 'pstore' require_relative 'particulars' # particulars.rb include SiSU_Particulars require_relative 'defaults' # defaults.rb include SiSU_Viz require_relative 'xhtml_table' # xhtml_table.rb - require_relative 'epub_format' # epub_format.rb - include SiSU_EPUB_Format - require_relative 'epub_segments' # epub_segments.rb - include SiSU_EPUB_Seg - require_relative 'epub_tune' # epub_tune.rb - include SiSU_EPUB_Tune - require_relative 'epub_concordance' # epub_concordance.rb + require_relative 'xhtml_epub2_format' # xhtml_epub2_format.rb + include SiSU_XHTML_EPUB2_Format + require_relative 'xhtml_epub2_segments' # xhtml_epub2_segments.rb + include SiSU_XHTML_EPUB2_Seg + require_relative 'xhtml_epub2_tune' # xhtml_epub2_tune.rb + include SiSU_XHTML_EPUB2_Tune + require_relative 'xhtml_epub2_concordance' # xhtml_epub2_concordance.rb class Source def initialize(opt) @opt=opt @@ -106,13 +106,13 @@ module SiSU_EPUB @env.processing_path.epub_cp_images(@md) data=nil SiSU_Env::FileOp.new(@md).mkdir.output.epub - @tuned_file_array=SiSU_EPUB::Source::XHTML_Environment.new(@particulars).tuned_file_instructions + @tuned_file_array=SiSU_XHTML_EPUB2::Source::XHTML_Environment.new(@particulars).tuned_file_instructions data=@tuned_file_array - toc=SiSU_EPUB::Source::Toc.new(@md,data).songsheet + toc=SiSU_XHTML_EPUB2::Source::Toc.new(@md,data).songsheet data=@tuned_file_array - SiSU_EPUB::Source::ScrollHeadAndSegToc.new(@md,toc).in_common #watch - SiSU_EPUB::Source::Seg.new(@md,data).songsheet - SiSU_EPUB::Source::Output.new(@md).songsheet + SiSU_XHTML_EPUB2::Source::ScrollHeadAndSegToc.new(@md,toc).in_common #watch + SiSU_XHTML_EPUB2::Source::Seg.new(@md,data).songsheet + SiSU_XHTML_EPUB2::Source::Output.new(@md).songsheet rescue SiSU_Errors::Rescued.new($!,$@,@opt.cmd,@opt.fns).location do __LINE__.to_s + ':' + __FILE__ @@ -150,12 +150,12 @@ module SiSU_EPUB @tell=SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set]) directories ao_array=@particulars.ao_array # ao file drawn here - @tuned_file_array=SiSU_EPUB_Tune::Tune.new(ao_array,@md).songsheet + @tuned_file_array=SiSU_XHTML_EPUB2_Tune::Tune.new(ao_array,@md).songsheet @tuned_file_array end end class Endnotes - include SiSU_EPUB_Format + include SiSU_XHTML_EPUB2_Format def initialize(md,data) @md,@data=md,data end @@ -177,7 +177,7 @@ module SiSU_EPUB end endnote_array.flatten.each do |note| txt_obj={ txt: note } - format_scroll=SiSU_EPUB_Format::FormatScroll.new(@md,txt_obj) + format_scroll=SiSU_XHTML_EPUB2_Format::FormatScroll.new(@md,txt_obj) @scr_endnotes << format_scroll.endnote_body end end @@ -193,7 +193,7 @@ module SiSU_EPUB def initialize(md=nil,data='') @md,@data=md,data @vz=SiSU_Viz::Defaults.new - @epub=SiSU_EPUB_Format::HeadInformation.new(@md) + @epub=SiSU_XHTML_EPUB2_Format::HeadInformation.new(@md) @tell=SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set]) if @md @make=SiSU_Env::ProcessingSettings.new(@md) end @@ -262,7 +262,7 @@ module SiSU_EPUB md_opf_a_content << @epub.metadata_opf.manifest_content(dob_toc,lv_name) md_opf_a_spine << @epub.metadata_opf.spine(dob_toc,lv_name) md_opf_a_guide << @epub.metadata_opf.guide(dob_toc,lv_name) - SiSU_EPUB::Source::Toc.new(@md,dob_toc).level_1 + SiSU_XHTML_EPUB2::Source::Toc.new(@md,dob_toc).level_1 when 2 @s_b_no +=1 lv_name='section_b' + @s_b_no.to_s @@ -279,7 +279,7 @@ module SiSU_EPUB md_opf_a_content << @epub.metadata_opf.manifest_content(dob_toc,lv_name) md_opf_a_spine << @epub.metadata_opf.spine(dob_toc,lv_name) md_opf_a_guide << @epub.metadata_opf.guide(dob_toc,lv_name) - SiSU_EPUB::Source::Toc.new(@md,dob_toc).level_2 + SiSU_XHTML_EPUB2::Source::Toc.new(@md,dob_toc).level_2 when 3 @s_c_no +=1 lv_name='section_c' + @s_c_no.to_s @@ -295,7 +295,7 @@ module SiSU_EPUB md_opf_a_content << @epub.metadata_opf.manifest_content(dob_toc,lv_name) md_opf_a_spine << @epub.metadata_opf.spine(dob_toc,lv_name) md_opf_a_guide << @epub.metadata_opf.guide(dob_toc,lv_name) - SiSU_EPUB::Source::Toc.new(@md,dob_toc).level_3 + SiSU_XHTML_EPUB2::Source::Toc.new(@md,dob_toc).level_3 when 4 @ncx_cls=[] lv_name=dob_toc.name @@ -309,7 +309,7 @@ module SiSU_EPUB md_opf_a_content << @epub.metadata_opf.manifest_content(dob_toc,lv_name) md_opf_a_spine << @epub.metadata_opf.spine(dob_toc,lv_name) md_opf_a_guide << @epub.metadata_opf.guide(dob_toc,lv_name) - SiSU_EPUB::Source::Toc.new(@md,dob_toc).level_4 + SiSU_XHTML_EPUB2::Source::Toc.new(@md,dob_toc).level_4 when 5 @ncx_cls=[] hashtag='#o' + dob_toc.ocn.to_s @@ -322,7 +322,7 @@ module SiSU_EPUB md_opf_a_content << @epub.metadata_opf.manifest_content(dob_toc,lv_name,hashtag) md_opf_a_spine << @epub.metadata_opf.spine(dob_toc,lv_name,hashtag) md_opf_a_guide << @epub.metadata_opf.guide(dob_toc,lv_name,hashtag) - SiSU_EPUB::Source::Toc.new(@md,dob_toc).level_5 + SiSU_XHTML_EPUB2::Source::Toc.new(@md,dob_toc).level_5 when 6 @ncx_cls=[] hashtag='#o' + dob_toc.ocn.to_s @@ -334,7 +334,7 @@ module SiSU_EPUB md_opf_a_content << @epub.metadata_opf.manifest_content(dob_toc,lv_name,hashtag) md_opf_a_spine << @epub.metadata_opf.spine(dob_toc,lv_name,hashtag) md_opf_a_guide << @epub.metadata_opf.guide(dob_toc,lv_name,hashtag) - SiSU_EPUB::Source::Toc.new(@md,dob_toc).level_6 + SiSU_XHTML_EPUB2::Source::Toc.new(@md,dob_toc).level_6 else nil end toc.each do |k,d| @@ -374,8 +374,8 @@ 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 - SiSU_EPUB::Source::Output.new(@md,@@toc[:opf]).epub_metadata_opf - SiSU_EPUB::Source::Output.new(@md,@@toc[:ncx]).epub_toc_ncx + SiSU_XHTML_EPUB2::Source::Output.new(@md,@@toc[:opf]).epub_metadata_opf + SiSU_XHTML_EPUB2::Source::Output.new(@md,@@toc[:ncx]).epub_toc_ncx @md.firstseg=@@firstseg @@toc end @@ -391,7 +391,7 @@ module SiSU_EPUB end toc={} txt_obj={ txt: title } - format_toc=SiSU_EPUB_Format::FormatToc.new(@md,txt_obj) + format_toc=SiSU_XHTML_EPUB2_Format::FormatToc.new(@md,txt_obj) toc[:seg]=if dob.name =~/^meta/ \ and dob.obj =~/Document Information/ #check format_toc.lev0 @@ -411,7 +411,7 @@ module SiSU_EPUB %{<b><a href="##{link}">#{linkname}</a></b>} end txt_obj={ txt: title } - format_toc=SiSU_EPUB_Format::FormatToc.new(@md,txt_obj) + format_toc=SiSU_XHTML_EPUB2_Format::FormatToc.new(@md,txt_obj) toc[:scr]=if dob.name =~/^meta/ \ and dob.obj =~/Document Information/ format_toc.lev0 @@ -424,16 +424,16 @@ module SiSU_EPUB linkname,ocn=dob.obj.strip,dob.ocn if ocn \ and ocn !~/#/ - p_num=SiSU_EPUB_Format::ParagraphNumber.new(@md,ocn) + p_num=SiSU_XHTML_EPUB2_Format::ParagraphNumber.new(@md,ocn) end txt_obj={ txt: linkname } - format_toc=SiSU_EPUB_Format::FormatToc.new(@md,txt_obj) + format_toc=SiSU_XHTML_EPUB2_Format::FormatToc.new(@md,txt_obj) toc={} toc[:seg]=format_toc.lev2 if p_num title=%{#{p_num.goto}#{linkname}</a>} txt_obj={ txt: title } - format_toc=SiSU_EPUB_Format::FormatToc.new(@md,txt_obj) + format_toc=SiSU_XHTML_EPUB2_Format::FormatToc.new(@md,txt_obj) toc[:scr]=format_toc.lev2 end toc @@ -443,16 +443,16 @@ module SiSU_EPUB linkname,ocn=dob.obj.strip,dob.ocn if ocn \ and ocn !~/#/ - p_num=SiSU_EPUB_Format::ParagraphNumber.new(@md,ocn) + p_num=SiSU_XHTML_EPUB2_Format::ParagraphNumber.new(@md,ocn) end txt_obj={ txt: linkname } - format_toc=SiSU_EPUB_Format::FormatToc.new(@md,txt_obj) + format_toc=SiSU_XHTML_EPUB2_Format::FormatToc.new(@md,txt_obj) toc={} toc[:seg]=format_toc.lev3 if p_num title=%{#{p_num.goto}#{linkname}</a>} txt_obj={ txt: title } - format_toc=SiSU_EPUB_Format::FormatToc.new(@md,txt_obj) + format_toc=SiSU_XHTML_EPUB2_Format::FormatToc.new(@md,txt_obj) toc[:scr]=format_toc.lev3 end toc @@ -460,7 +460,7 @@ module SiSU_EPUB def level_4 dob=@data linkname,ocn=dob.obj.strip,dob.ocn - p_num=SiSU_EPUB_Format::ParagraphNumber.new(@md,ocn) if ocn + p_num=SiSU_XHTML_EPUB2_Format::ParagraphNumber.new(@md,ocn) if ocn if dob.ln==4 seg_link=%{ <a href="#{dob.name}#{Sfx[:epub_xhtml]}"> #{dob.obj} @@ -471,14 +471,14 @@ module SiSU_EPUB %{<a href="\\1#{Sfx[:epub_xhtml]}">} + %{\\1 \\2</a> }) end - p_num=SiSU_EPUB_Format::ParagraphNumber.new(@md,ocn) if ocn + p_num=SiSU_XHTML_EPUB2_Format::ParagraphNumber.new(@md,ocn) if ocn txt_obj={ txt: seg_link } - format_toc=SiSU_EPUB_Format::FormatToc.new(@md,txt_obj) + format_toc=SiSU_XHTML_EPUB2_Format::FormatToc.new(@md,txt_obj) toc={} toc[:seg]=format_toc.lev4 title=%{#{p_num.goto}#{linkname}</a>} if p_num txt_obj={ txt: title } - format_toc=SiSU_EPUB_Format::FormatToc.new(@md,txt_obj) + format_toc=SiSU_XHTML_EPUB2_Format::FormatToc.new(@md,txt_obj) toc[:scr]=format_toc.lev4 toc end @@ -488,16 +488,16 @@ module SiSU_EPUB toc={} if ocn \ and ocn !~/#/ - p_num=SiSU_EPUB_Format::ParagraphNumber.new(@md,ocn) + p_num=SiSU_XHTML_EPUB2_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::FormatToc.new(@md,txt_obj) + format_toc=SiSU_XHTML_EPUB2_Format::FormatToc.new(@md,txt_obj) toc[:seg]=format_toc.lev5 title=%{#{p_num.goto}#{linkname}</a>} txt_obj={ txt: title } - format_toc=SiSU_EPUB_Format::FormatToc.new(@md,txt_obj) + format_toc=SiSU_XHTML_EPUB2_Format::FormatToc.new(@md,txt_obj) toc[:scr]=format_toc.lev5 end toc @@ -508,16 +508,16 @@ module SiSU_EPUB toc={} if ocn \ and ocn !~/#/ - p_num=SiSU_EPUB_Format::ParagraphNumber.new(@md,ocn) + p_num=SiSU_XHTML_EPUB2_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::FormatToc.new(@md,txt_obj) + format_toc=SiSU_XHTML_EPUB2_Format::FormatToc.new(@md,txt_obj) toc[:seg]=format_toc.lev6 title=%{#{p_num.goto}#{linkname}</a>} txt_obj={ txt: title } - format_toc=SiSU_EPUB_Format::FormatToc.new(@md,txt_obj) + format_toc=SiSU_XHTML_EPUB2_Format::FormatToc.new(@md,txt_obj) toc[:scr]=format_toc.lev6 end toc @@ -536,7 +536,7 @@ module SiSU_EPUB || @md.opt.act[:maintenance][:set]==:on) SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],'Scroll & Segtoc').txt_grey end - format_head_toc=SiSU_EPUB_Format::HeadToc.new(@md) + format_head_toc=SiSU_XHTML_EPUB2_Format::HeadToc.new(@md) dochead=format_head_toc.head dochead=dochead.gsub(/toc\.(html)/,'doc.\1') #kludge toc_shared << dochead #<< ads.div.major @@ -544,18 +544,18 @@ module SiSU_EPUB if defined? @md.rights.all \ and @md.rights.all rights=format_head_toc.rights.all - rights=SiSU_EPUB_Tune::CleanXHTML.new(rights).clean + rights=SiSU_XHTML_EPUB2_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::CleanXHTML.new(prefix_b).clean + prefix_b=SiSU_XHTML_EPUB2_Tune::CleanXHTML.new(prefix_b).clean end tmp_head=nil 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::FormatTextObject.new(@md,txt_obj) + format_txt_obj=SiSU_XHTML_EPUB2_Format::FormatTextObject.new(@md,txt_obj) toc_shared << format_txt_obj.center_bold segtoc << format_txt_obj.center_bold if defined? @md.creator.author \ @@ -563,7 +563,7 @@ module SiSU_EPUB creator_endnote=@md.creator.author.gsub(/(\*+)/,%{#{$ep[:hsp]}<sup><a href="#notes">\\1</a></sup>}) tmp_head=creator_endnote + "\n" txt_obj={ txt: tmp_head } - format_txt_obj=SiSU_EPUB_Format::FormatTextObject.new(@md,txt_obj) + format_txt_obj=SiSU_XHTML_EPUB2_Format::FormatTextObject.new(@md,txt_obj) toc_shared << format_txt_obj.center_bold segtoc << format_txt_obj.center_bold end @@ -599,8 +599,8 @@ module SiSU_EPUB #Segtoc tail added here segtoc << format_head_toc.xhtml_close segtoc=segtoc.flatten.compact #watch - SiSU_EPUB::Source::Output.new(@md).make_cover_image - SiSU_EPUB::Source::Output.new(@md,segtoc).make_segtoc + SiSU_XHTML_EPUB2::Source::Output.new(@md).make_cover_image + SiSU_XHTML_EPUB2::Source::Output.new(@md,segtoc).make_segtoc segtoc=[] @toc[:scr],@toc[:seg]=[],[] toc_shared @@ -608,13 +608,13 @@ module SiSU_EPUB end class Table < SiSU_XHTML_Table::TableXHTML end - class Seg < SiSU_EPUB_Seg::Seg + class Seg < SiSU_XHTML_EPUB2_Seg::Seg end class Output def initialize(md,output='') @md,@output=md,output @epub_doc="#{@md.fnb}.epub" - @epub_header=SiSU_EPUB_Format::HeadInformation.new(@md) + @epub_header=SiSU_XHTML_EPUB2_Format::HeadInformation.new(@md) @make=SiSU_Env::ProcessingSettings.new(@md) @make_file=SiSU_Env::CreateFile.new(@md.fns) end @@ -638,7 +638,7 @@ module SiSU_EPUB end def css out=@make_file.epub.xhtml_css - out << SiSU_EPUB_Format::CSS.new.css_epub_xhtml + out << SiSU_XHTML_EPUB2_Format::CSS.new.css_epub_xhtml out.close end def epub_toc_ncx @@ -691,7 +691,7 @@ module SiSU_EPUB end end def concordance - SiSU_EPUB_Concordance::Source.new(@md.opt).read + SiSU_XHTML_EPUB2_Concordance::Source.new(@md.opt).read end def output_zip FileUtils::mkdir_p(@md.file.output_path.epub.dir) unless FileTest.directory?(@md.file.output_path.epub.dir) diff --git a/lib/sisu/v5/epub_concordance.rb b/lib/sisu/v5/xhtml_epub2_concordance.rb index ab5b272a..5668521b 100644 --- a/lib/sisu/v5/epub_concordance.rb +++ b/lib/sisu/v5/xhtml_epub2_concordance.rb @@ -60,15 +60,15 @@ of words in document) =end -module SiSU_EPUB_Concordance +module SiSU_XHTML_EPUB2_Concordance require_relative 'particulars' # particulars.rb include SiSU_Particulars require_relative 'sysenv' # sysenv.rb include SiSU_Env require_relative 'defaults' # defaults.rb include SiSU_Viz - require_relative 'epub_format' # epub_format.rb - include SiSU_EPUB_Format + require_relative 'xhtml_epub2_format' # xhtml_epub2_format.rb + include SiSU_XHTML_EPUB2_Format class Source def initialize(opt) @opt=opt @@ -80,13 +80,13 @@ module SiSU_EPUB_Concordance wordmax=@env.concord_max unless @md.wc_words.nil? if @md.wc_words < wordmax - SiSU_EPUB_Concordance::Source::Words.new(@particulars).songsheet + SiSU_XHTML_EPUB2_Concordance::Source::Words.new(@particulars).songsheet else SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],"*WARN* concordance skipped, large document has over #{wordmax} words (#{@md.wc_words})").warn unless @md.opt.act[:quiet][:set]==:on end else SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],"*WARN* 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.act[:quiet][:set]==:on - SiSU_EPUB_Concordance::Source::Words.new(@particulars).songsheet + SiSU_XHTML_EPUB2_Concordance::Source::Words.new(@particulars).songsheet end rescue SiSU_Errors::Rescued.new($!,$@,@md.opt.cmd,@md.fns).location do @@ -98,11 +98,11 @@ module SiSU_EPUB_Concordance private class DocTitle include SiSU_Viz - #revisit, both requires (html & shared_xml) needed for stand alone operation (sisu -w [filename]) - require_relative 'epub' # epub.rb + #revisit, both requires (html & xml_shared) needed for stand alone operation (sisu -w [filename]) + require_relative 'xhtml_epub2' # xhtml_epub2.rb def initialize(particulars) @particulars,@md=particulars,particulars.md - @data=SiSU_EPUB::Source::XHTML_Environment.new(particulars).tuned_file_instructions + @data=SiSU_XHTML_EPUB2::Source::XHTML_Environment.new(particulars).tuned_file_instructions @vz=SiSU_Viz::Defaults.new @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>} @@ -112,7 +112,7 @@ WOK end def create @css=SiSU_Env::CSS_Stylesheet.new(@particulars.md) - format_head_toc=SiSU_EPUB_Format::HeadToc.new(@md) + format_head_toc=SiSU_XHTML_EPUB2_Format::HeadToc.new(@md) dochead=format_head_toc.head <<WOK #{dochead} @@ -148,8 +148,8 @@ WOK class Words require_relative 'defaults' # defaults.rb include SiSU_Viz - require_relative 'epub_format' # epub_format.rb - include SiSU_EPUB_Format + require_relative 'xhtml_epub2_format' # xhtml_epub2_format.rb + include SiSU_XHTML_EPUB2_Format require_relative 'sysenv' # sysenv.rb include SiSU_Screen def initialize(particulars) @@ -288,7 +288,7 @@ WOK end end seg='' - @file_concordance << SiSU_EPUB_Concordance::Source::DocTitle.new(@particulars).create + @file_concordance << SiSU_XHTML_EPUB2_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>,#{$ep[:hsp]}}} @@ -306,7 +306,7 @@ WOK end end end - keyword=SiSU_EPUB_Concordance::Source::Word.new(word,@freq[word]).html + keyword=SiSU_XHTML_EPUB2_Concordance::Source::Word.new(word,@freq[word]).html if keyword !~ @rxp_excluded0 if @word_map[word][0] =~ /\d+/ @file_concordance << %{#{keyword}#{seg}#{@word_map[word].uniq.compact.join}} diff --git a/lib/sisu/v5/epub_format.rb b/lib/sisu/v5/xhtml_epub2_format.rb index 1c57cd20..e53c3bfe 100644 --- a/lib/sisu/v5/epub_format.rb +++ b/lib/sisu/v5/xhtml_epub2_format.rb @@ -59,7 +59,7 @@ ** Description: epub formating, css template =end -module SiSU_EPUB_Format +module SiSU_XHTML_EPUB2_Format include SiSU_Viz class ParagraphNumber def initialize(md,ocn) @@ -1241,8 +1241,8 @@ module SiSU_EPUB_Format # DublinCore 1 - title @vz=SiSU_Viz::Defaults.new @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 || []) + @seg_name_xhtml=(SiSU_XHTML_EPUB2::Source::Seg.new.seg_name_xhtml || []) + @seg_name_xhtml_tracker=(SiSU_XHTML_EPUB2::Source::Seg.new.seg_name_xhtml_tracker || []) @tocband_scroll,@tocband_segtoc=nil,nil @index,@metalink='index','#metadata' end diff --git a/lib/sisu/v5/epub_segments.rb b/lib/sisu/v5/xhtml_epub2_segments.rb index 16e26855..d16e98e8 100644 --- a/lib/sisu/v5/epub_segments.rb +++ b/lib/sisu/v5/xhtml_epub2_segments.rb @@ -59,9 +59,9 @@ ** Description: epub segment generation, processing =end -module SiSU_EPUB_Seg - require_relative 'shared_xhtml' # shared_xhtml.rb - require_relative 'epub' # epub.rb +module SiSU_XHTML_EPUB2_Seg + require_relative 'xhtml_shared' # xhtml_shared.rb + require_relative 'xhtml_epub2' # xhtml_epub2.rb require_relative 'shared_metadata' # shared_metadata.rb class Output def initialize(md,outputfile,seg,type='') @@ -74,19 +74,19 @@ module SiSU_EPUB_Seg if @type=='endnotes' @seg[:headings]=[] #watch txt_obj={ txt: 'Endnotes', ocn_display: ''} - format_seg=SiSU_EPUB_Format::FormatSeg.new(@md,txt_obj) + format_seg=SiSU_XHTML_EPUB2_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_seg=SiSU_EPUB_Format::FormatSeg.new(@md,txt_obj) + format_seg=SiSU_XHTML_EPUB2_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=SiSU_Metadata::Summary.new(@md).xhtml_display.metadata @seg[:headings]=[] txt_obj={ txt: 'Metadata', ocn_display: ''} - format_seg=SiSU_EPUB_Format::FormatSeg.new(@md,txt_obj) + format_seg=SiSU_XHTML_EPUB2_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' @@ -101,7 +101,7 @@ WOK end @seg[:headings]=[] txt_obj={ txt: 'Manifest', ocn_display: ''} - format_seg=SiSU_EPUB_Format::FormatSeg.new(@md,txt_obj) + format_seg=SiSU_XHTML_EPUB2_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 @@ -141,7 +141,7 @@ WOK begin data=get_subtoc_endnotes(@data) data=articles(data) - SiSU_EPUB_Seg::Seg.new.cleanup # (((( added )))) + SiSU_XHTML_EPUB2_Seg::Seg.new.cleanup # (((( added )))) #### (((( END )))) #### rescue SiSU_Errors::Rescued.new($!,$@,@md.opt.cmd,@md.fns).location do @@ -236,32 +236,32 @@ WOK || dob.is==:heading_insert) \ and dob.ln==4 if tracking != 0 - SiSU_EPUB_Seg::Seg.new(@md).tail + SiSU_XHTML_EPUB2_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 \ or @@seg_name_xhtml[tracking-1] !~/endnotes|book_index|metadata/ - SiSU_EPUB_Seg::Output.new(@md,output_epub_cont_seg,@@seg).output + SiSU_XHTML_EPUB2_Seg::Output.new(@md,output_epub_cont_seg,@@seg).output elsif dob.is==:heading_insert if @@seg_name_xhtml[tracking-1]=='endnotes' - SiSU_EPUB_Seg::Output.new(@md,output_epub_cont_seg,@@seg,'endnotes').output + SiSU_XHTML_EPUB2_Seg::Output.new(@md,output_epub_cont_seg,@@seg,'endnotes').output elsif @@seg_name_xhtml[tracking-1]=='book_index' - SiSU_EPUB_Seg::Output.new(@md,output_epub_cont_seg,@@seg,'idx').output + SiSU_XHTML_EPUB2_Seg::Output.new(@md,output_epub_cont_seg,@@seg,'idx').output @@seg[:idx]=[] elsif @@seg_name_xhtml[tracking-1]=='metadata' # navigation bug FIX - SiSU_EPUB_Seg::Output.new(@md,output_epub_cont_seg,@@seg,'metadata').output + SiSU_XHTML_EPUB2_Seg::Output.new(@md,output_epub_cont_seg,@@seg,'metadata').output else puts "#{__FILE__}::#{__LINE__}" end else puts "#{__FILE__}::#{__LINE__}" end - SiSU_EPUB_Seg::Seg.new.reinitialise + SiSU_XHTML_EPUB2_Seg::Seg.new.reinitialise heading_art(dob) head(dob) 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') - 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 + SiSU_XHTML_EPUB2_Seg::Output.new(@md,output_epub_cont_seg,@@seg,'metadata').output + SiSU_XHTML_EPUB2_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 @@ -296,7 +296,7 @@ WOK data end def heading_art(dob) - @@seg[:title]=SiSU_EPUB_Format::HeadSeg.new(@md).head + @@seg[:title]=SiSU_XHTML_EPUB2_Format::HeadSeg.new(@md).head end def head(dob) clean=/<!.*?!>|<:.*?>$/ @@ -309,9 +309,9 @@ WOK ocn=(@@heading1[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/]) \ ? $1 : '' - @p_num=SiSU_EPUB_Format::ParagraphNumber.new(@md,ocn) + @p_num=SiSU_XHTML_EPUB2_Format::ParagraphNumber.new(@md,ocn) txt_obj={ txt: @@heading1, ocn_display: @p_num.ocn_display } - format_seg=SiSU_EPUB_Format::FormatSeg.new(@md,txt_obj) + format_seg=SiSU_XHTML_EPUB2_Format::FormatSeg.new(@md,txt_obj) @@seg[:headings] << format_seg.title_heading1.gsub(clean,'') @@heading1=@@heading1.gsub(/#{$ep[:hsp]}<a name="-[\d*+]+" href="#_[\d*+]+">#{$ep[:hsp]}<sup>[\d*+]+<\/sup>#{$ep[:hsp]}<\/a>/,'') end @@ -320,9 +320,9 @@ WOK ocn=(heading2[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/]) \ ? $1 : '' - @p_num=SiSU_EPUB_Format::ParagraphNumber.new(@md,ocn) + @p_num=SiSU_XHTML_EPUB2_Format::ParagraphNumber.new(@md,ocn) txt_obj={ txt: heading2, ocn_display: @p_num.ocn_display } - format_seg=SiSU_EPUB_Format::FormatSeg.new(@md,txt_obj) + format_seg=SiSU_XHTML_EPUB2_Format::FormatSeg.new(@md,txt_obj) @@seg[:headings] << format_seg.title_heading2.gsub(clean,'') @@heading2=@@heading2.gsub(/#{$ep[:hsp]}<a name="-[\d*+]+" href="#_[\d*+]+">#{$ep[:hsp]}<sup>[\d*+]+<\/sup>#{$ep[:hsp]}<\/a>/,'') end @@ -331,9 +331,9 @@ WOK ocn=(heading3[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/]) \ ? $1 : '' - @p_num=SiSU_EPUB_Format::ParagraphNumber.new(@md,ocn) + @p_num=SiSU_XHTML_EPUB2_Format::ParagraphNumber.new(@md,ocn) txt_obj={ txt: heading3, ocn_display: @p_num.ocn_display } - format_seg=SiSU_EPUB_Format::FormatSeg.new(@md,txt_obj) + format_seg=SiSU_XHTML_EPUB2_Format::FormatSeg.new(@md,txt_obj) @@seg[:headings] << format_seg.title_heading3.gsub(clean,'') @@heading3=@@heading3.gsub(/#{$ep[:hsp]}<a name="-[\d*+]+" href="#_[\d*+]+">#{$ep[:hsp]}<sup>[\d*+]+<\/sup>#{$ep[:hsp]}<\/a>/,'') end @@ -342,9 +342,9 @@ WOK ocn=(heading4[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/]) \ ? $1 : '' - @p_num=SiSU_EPUB_Format::ParagraphNumber.new(@md,ocn) + @p_num=SiSU_XHTML_EPUB2_Format::ParagraphNumber.new(@md,ocn) txt_obj={ txt: heading4, ocn_display: @p_num.ocn_display } - format_seg=SiSU_EPUB_Format::FormatSeg.new(@md,txt_obj) + format_seg=SiSU_XHTML_EPUB2_Format::FormatSeg.new(@md,txt_obj) @@seg[:headings] << format_seg.title_heading4.gsub(clean,'') end @@tracker=@@tracker+1 @@ -355,9 +355,9 @@ WOK || dob.is ==:heading_insert \ || dob.is ==:para #extend as necessary FIX - @p_num=SiSU_EPUB_Format::ParagraphNumber.new(@md,dob.ocn) + @p_num=SiSU_XHTML_EPUB2_Format::ParagraphNumber.new(@md,dob.ocn) end - sto=SiSU_EPUB_Format::FormatTextObject.new(@md,dob) + sto=SiSU_XHTML_EPUB2_Format::FormatTextObject.new(@md,dob) dob_xhtml=if dob.is==:heading \ || dob.is==:heading_insert \ || dob.is==:para @@ -408,13 +408,13 @@ WOK || 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) + format_seg=SiSU_XHTML_EPUB2_Format::FormatSeg.new(@md,dob) end 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::FormatSeg.new(@md,dob) + format_seg=SiSU_XHTML_EPUB2_Format::FormatSeg.new(@md,dob) dob.obj=format_seg.no_paranum end if (dob.is==:heading \ @@ -430,7 +430,7 @@ WOK end end def tail - format_head_seg=SiSU_EPUB_Format::HeadSeg.new(@md) + format_head_seg=SiSU_XHTML_EPUB2_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} @@ -486,10 +486,10 @@ WOK and dob.ln.to_s =~/^[56]/ case dob.ln when 5 - format_seg=SiSU_EPUB_Format::FormatSeg.new(@md,dob) + format_seg=SiSU_XHTML_EPUB2_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::FormatSeg.new(@md,dob) + format_seg=SiSU_XHTML_EPUB2_Format::FormatSeg.new(@md,dob) subtoc=format_seg.subtoc_lev6 #keep and make available, this is the subtoc end @@seg_subtoc_array << subtoc @@ -516,7 +516,7 @@ WOK try=e_n.split(/<br \/>/) try.each do |e| txt_obj={ txt: e } - format_seg=SiSU_EPUB_Format::FormatSeg.new(@md,txt_obj) + format_seg=SiSU_XHTML_EPUB2_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 @@ -529,7 +529,7 @@ 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::FormatSeg.new(@md,txt_obj) + format_seg=SiSU_XHTML_EPUB2_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 diff --git a/lib/sisu/v5/epub_tune.rb b/lib/sisu/v5/xhtml_epub2_tune.rb index 5ec5fa56..b46f49f0 100644 --- a/lib/sisu/v5/epub_tune.rb +++ b/lib/sisu/v5/xhtml_epub2_tune.rb @@ -60,10 +60,10 @@ =end require_relative 'param' -module SiSU_EPUB_Tune +module SiSU_XHTML_EPUB2_Tune require_relative 'sysenv' # sysenv.rb include SiSU_Env; include SiSU_Screen - require_relative 'epub_format' # epub_format.rb #watch + require_relative 'xhtml_epub2_format' # xhtml_epub2_format.rb #watch @@line_mode='' @@endnote_array=[] @@endnote_call_counter=1 @@ -127,15 +127,15 @@ module SiSU_EPUB_Tune || @md.opt.act[:maintenance][:set]==:on) SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],'Tune').txt_grey end - data=SiSU_EPUB_Tune::Tune.new(@data,@md).amp_angle_brackets - 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 + data=SiSU_XHTML_EPUB2_Tune::Tune.new(@data,@md).amp_angle_brackets + data=SiSU_XHTML_EPUB2_Tune::Tune.new(data,@md).endnotes_html + data=SiSU_XHTML_EPUB2_Tune::Tune.new(data,@md).url_markup + data=SiSU_XHTML_EPUB2_Tune::Tune.new(data,@md).markup if @md.opt.act[:maintenance][:set]==:on #Hard Output Tune Optional on/off here - data=SiSU_EPUB_Tune::Output.new(data,@md).hard_output - SiSU_EPUB_Tune::Output.new(data,@md).marshal + data=SiSU_XHTML_EPUB2_Tune::Output.new(data,@md).hard_output + SiSU_XHTML_EPUB2_Tune::Output.new(data,@md).marshal end - SiSU_EPUB_Tune::Tune.new(@data,@md).output + SiSU_XHTML_EPUB2_Tune::Tune.new(@data,@md).output rescue SiSU_Errors::Rescued.new($!,$@,@md.opt.cmd,@md.fns).location do __LINE__.to_s + ':' + __FILE__ @@ -163,7 +163,7 @@ module SiSU_EPUB_Tune gsub(/#{Dx[:url_o]}/,Dx[:url_o_xml]).gsub(/#{Dx[:url_c]}/,Dx[:url_o_xml]). gsub(/#{Mx[:nbsp]}/,$ep[:hsp]). gsub(/<(p|br)>/,'<\1 />') - dob.obj=SiSU_EPUB_Tune::CleanXHTML.new(dob.obj).clean + dob.obj=SiSU_XHTML_EPUB2_Tune::CleanXHTML.new(dob.obj).clean @tuned_file << dob end end diff --git a/lib/sisu/v5/shared_xhtml.rb b/lib/sisu/v5/xhtml_shared.rb index c9534823..27ddba4b 100644 --- a/lib/sisu/v5/shared_xhtml.rb +++ b/lib/sisu/v5/xhtml_shared.rb @@ -50,7 +50,7 @@ * Git <http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=summary> - <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v5/shared_xhtml.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v5/xhtml_shared.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> diff --git a/lib/sisu/v5/xml_dom.rb b/lib/sisu/v5/xml_dom.rb index 6a2d7505..6f0391f1 100644 --- a/lib/sisu/v5/xml_dom.rb +++ b/lib/sisu/v5/xml_dom.rb @@ -67,7 +67,7 @@ module SiSU_XML_DOM require_relative 'sysenv' # sysenv.rb include SiSU_Env require_relative 'ao' # ao.rb - require_relative 'shared_xml' # shared_xml.rb + require_relative 'xml_shared' # xml_shared.rb include SiSU_XML_Munge require_relative 'xml_format' # xml_format.rb include SiSU_XML_Format @@ -135,9 +135,9 @@ module SiSU_XML_DOM end end class Scroll - require_relative 'shared_txt' # shared_txt.rb + require_relative 'txt_shared' # txt_shared.rb include SiSU_TextUtils - require_relative 'shared_xhtml' # decide use, whether xml rather than xhtml + require_relative 'xhtml_shared' # decide use, whether xml rather than xhtml @@xml={ body: [], open: [], close: [], head: [], sc: [] } def initialize(particulars) @env,@md,@ao_array=particulars.env,particulars.md,particulars.ao_array diff --git a/lib/sisu/v5/xml_fictionbook.rb b/lib/sisu/v5/xml_fictionbook.rb deleted file mode 100644 index 446e12e2..00000000 --- a/lib/sisu/v5/xml_fictionbook.rb +++ /dev/null @@ -1,305 +0,0 @@ -# encoding: utf-8 -=begin - - * Name: SiSU - - * Description: a framework for document structuring, publishing and search - - * Author: Ralph Amissah - - * Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013 Ralph Amissah, All Rights Reserved. - - * License: GPL 3 or later: - - SiSU, a framework for document structuring, publishing and search - - Copyright (C) Ralph Amissah - - This program is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. - - You should have received a copy of the GNU General Public License along with - this program. If not, see <http://www.gnu.org/licenses/>. - - If you have Internet connection, the latest version of the GPL should be - available at these locations: - <http://www.fsf.org/licensing/licenses/gpl.html> - <http://www.gnu.org/licenses/gpl.html> - - <http://www.sisudoc.org/sisu/en/manifest/gpl.fsf.html> - - * SiSU uses: - * Standard SiSU markup syntax, - * Standard SiSU meta-markup syntax, and the - * Standard SiSU object citation numbering and system - - * Hompages: - <http://www.jus.uio.no/sisu> - <http://www.sisudoc.org> - - * Download: - <http://www.sisudoc.org/sisu/en/SiSU/download.html> - - * Git - <http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=summary> - <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v5/xml_fictionbook.rb;hb=HEAD> - - * Ralph Amissah - <ralph@amissah.com> - <ralph.amissah@gmail.com> - - ** Description: extract and print an XML rendition of document structure to screen - -=end -module SiSU_XML_Fictionbook - require_relative 'dal' # dal.rb - require_relative 'sysenv' # sysenv.rb - include SiSU_Env - require_relative 'shared_txt' # shared_txt.rb - include SiSU_TextUtils - require_relative 'shared_xml' # shared_xml.rb - include SiSU_XML_Munge - include SiSU_Param - class Source - def initialize(opt) - @opt=opt - @sp=' ' - end - def read - begin - @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::Rescued.new($!,$@,@opt.cmd,@opt.fns).location do - __LINE__.to_s + ':' + __FILE__ - end - ensure - end - end - private - class Scroll <Source - def initialize(data='',md='') - @data,@md=data,md - @trans=SiSU_XML_Munge::Trans.new(@md) - @file_fictionbook=SiSU_Env::FileOp.new(@md,'fictionbook.xml').mkfile - end - def songsheet - @t='fictionbook' - @s=['section', #@s=['body', - 'section', - 'section', - 'section', - 'section', - 'section', - 'section' - ] - head - extract_endnotes - structure - tail - end - def head - 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 - date_modified=if defined? @md.date.modified; "\n <p>#{@md.date.modified} Last Modified</p>" - else '' - end - head=<<WOK -<?xml version="1.0" encoding="UTF-8"?> -<FictionBook xmlns:xlink="http://www.w3.org/1999/xlink" - xmlns="http://www.gribuser.ru/xml/fictionbook/2.0"> -<description> - <title-info> - <genre match="100">***</genre> - <author> - <first-name>***</first-name> - <middle-name>***</middle-name> - <last-name>***</last-name> - </author> - <book-title>#{@md.title.full}</book-title> - <annotation> - </annotation> - <date value="#{@md.date}">yyyy</date> - </title-info> - <document-info> - <author> - <first-name/> - <last-name/> - <nickname/> - </author> - <program-used>#{version[:project]} #{version[:version]} and #{rb_ver}</program-used> - <date value="#{version[:date]}">#{version[:date]}</date> - <src-ocr/> - <version>1.0</version> - <history>#{date_available}#{date_modified} - </history> - </document-info> -</description> -<body> -WOK - put(head) - end - def extract_endnotes - @endnotes=[] - @data.each do |para| - @endnotes << para.scan(/~\{(.+?)\}~/m) - end - @endnotes=@endnotes.flatten - end - def endnotes - @endnotes.each do |endnote| - endnote=endnote.strip - endnote=@trans.markup_fictionbook(endnote) - endnote="<p>#{endnote}</p>" - util=SiSU_TextUtils::Wrap.new(endnote,80,10) - endnote=util.line_wrap - put(endnote) - end - end - def tail - tail=<<WOK -</body> -</FictionBook> -WOK - put(tail) - end - def markup(para,type='') - para=para.strip - para=@trans.markup_fictionbook(para) - para=if type.empty?; "<p>#{para}</p>" - else "<#{type}><p>#{para}</p></#{type}>" - end - util=SiSU_TextUtils::Wrap.new(para,80,10) - util.line_wrap - end - def put(line) - @file_fictionbook.puts line - puts line if @md.opt.act[:verbose_plus][:set]==:on - end - def structure_build_tag_close(lev,h) - @sp=' ' - case h[0] - when 1 - put("#{@sp*1}</#{@s[1]}>") if (lev <= 1) and h[1] - put("</#{@s[0]}>") if (lev==0) - when 2 - put("#{@sp*2}</#{@s[2]}>") if (lev <= 2) and h[2] - put("#{@sp*1}</#{@s[1]}>") if (lev <= 1) and h[1] - put("</#{@s[0]}>") if (lev==0) - when 3 - put("#{@sp*3}</#{@s[3]}>") if (lev <= 3) and h[3] - put("#{@sp*2}</#{@s[2]}>") if (lev <= 2) and h[2] - put("#{@sp*1}</#{@s[1]}>") if (lev <= 1) and h[1] - put("</#{@s[0]}>") if (lev==0) - when 4 - put("#{@sp*4}</#{@s[4]}>") if (lev <= 4) - put("#{@sp*3}</#{@s[3]}>") if (lev <= 3) and h[3] - put("#{@sp*2}</#{@s[2]}>") if (lev <= 2) and h[2] - put("#{@sp*1}</#{@s[1]}>") if (lev <= 1) and h[1] - put("</#{@s[0]}>") if (lev==0) - when 5 - put("#{@sp*5}</#{@s[5]}>") if (lev <= 5) - put("#{@sp*4}</#{@s[4]}>") if (lev <= 4) - put("#{@sp*3}</#{@s[3]}>") if (lev <= 3) and h[3] - put("#{@sp*2}</#{@s[2]}>") if (lev <= 2) and h[2] - put("#{@sp*1}</#{@s[1]}>") if (lev <= 1) and h[1] - put("</#{@s[0]}>") if (lev==0) - when 6 - put("#{@sp*6}</#{@s[6]}>") if (lev <= 6) - put("#{@sp*5}</#{@s[5]}>") if (lev <= 5) - put("#{@sp*4}</#{@s[4]}>") if (lev <= 4) - put("#{@sp*3}</#{@s[3]}>") if (lev <= 3) and h[3] - put("#{@sp*2}</#{@s[2]}>") if (lev <= 2) and h[2] - put("#{@sp*1}</#{@s[1]}>") if (lev <= 1) and h[1] - put("</#{@s[0]}>") if (lev==0) - end - end - def structure_build(ds) - @h=[0,false,false,false] - put("<#{@s[0]}>") - ds.each_with_index do |x,i| - @ef=false - case x[:lev] - when /^1/ - structure_build_tag_close(1,@h) - y="#{@sp*1}<#{@s[1]}>\n#{x[:para]}" - @h=[1,true,false,false] - when /^2/ - structure_build_tag_close(2,@h) - y="#{@sp*2}<#{@s[2]}>\n#{x[:para]}" - @h=[2,true,true,false] - when /^0:0/ #endnotes and metadata - structure_build_tag_close(2,@h) - y="#{@sp*2}<#{@s[2]}>\n#{x[:para]}" - @h=[2,true,true,false] - @ef=true if x[:hdr] =~/u0/ - when /^3/ - structure_build_tag_close(3,@h) - y="#{@sp*3}<#{@s[3]}>\n#{x[:para]}" - @h=[3,true,true,true] - when /^4/ - structure_build_tag_close(4,@h) - y="#{@sp*4}<#{@s[4]}>\n#{x[:para]}" - @h[0]=4 - when /^m2/ #metadata - structure_build_tag_close(4,@h) - y="#{@sp*4}<#{@s[4]}>\n#{x[:para]}" - @h[0]=4 - when /^5/ - structure_build_tag_close(5,@h) - y="#{@sp*5}<#{@s[5]}>\n#{x[:para]}" - @h[0]=5 - when /^6/ - structure_build_tag_close(6,@h) - y="#{@sp*6}<#{@s[6]}>\n#{x[:para]}" - @h[0]=6 - else - y=if @md.opt.act[:verbose_plus][:set]==:on; "#{x[:para]}" - else nil - end - end - put(y) if y - endnotes if @ef - end - structure_build_tag_close(0,@h) - end - def structure - data=@data - @ds=[] - c=0 - data.each do |para| - rgx_headers=/#{Mx[:id_o]}~(\d+);((?:\w|[0-6]:)\d+);(\w\d+)#{Mx[:id_c]}/ #fix - if para =~rgx_headers - x=(rgx_headers).match(para) - if x[3] =~/^[hum]\d+/ - @ds[c]={} - @ds[c][:ocn]=x[1] - @ds[c][:lev]=x[2] - @ds[c][:hdr]=x[3] - @ds[c][:para]=markup(para,'title') - else - @ds[c]={} - @ds[c][:para]=markup(para) if @md.opt.act[:verbose_plus][:set]==:on - end - c+=1 - end - end - structure_build(@ds) - @ds - end - end - end -end -__END__ diff --git a/lib/sisu/v5/odf.rb b/lib/sisu/v5/xml_odf_odt.rb index c865b0cb..e7389110 100644 --- a/lib/sisu/v5/odf.rb +++ b/lib/sisu/v5/xml_odf_odt.rb @@ -59,17 +59,17 @@ ** Description: opendocument text generation =end -module SiSU_ODF +module SiSU_XML_ODF_ODT require_relative 'particulars' # particulars.rb include SiSU_Particulars require_relative 'ao' # ao.rb require_relative 'sysenv' # sysenv.rb include SiSU_Env include SiSU_Viz - require_relative 'odf_format' # odf_format.rb - include SiSU_ODF_Format + require_relative 'xml_odf_odt_format' # xml_odf_odt_format.rb + include SiSU_XML_ODF_ODT_Format require_relative 'shared_metadata' # shared_metadata.rb - require_relative 'shared_txt' # shared_txt.rb + require_relative 'txt_shared' # txt_shared.rb @@alt_id_count,@@alt_id_count,@@tablehead,@@number_of_cols=0,0,0,0 class Source require 'zlib' @@ -98,7 +98,7 @@ module SiSU_ODF SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],@opt.fns,"file://#{@md.file.output_path.odt.dir}/#{@md.file.base_filename.odt}").flow end end - SiSU_ODF::Source::Scroll.new(@particulars).songsheet + SiSU_XML_ODF_ODT::Source::Scroll.new(@particulars).songsheet rescue SiSU_Errors::Rescued.new($!,$@,@opt.cmd,@opt.fns).location do __LINE__.to_s + ':' + __FILE__ @@ -109,7 +109,7 @@ module SiSU_ODF private class Scroll <Source require_relative 'defaults' # defaults.rb - require_relative 'shared_txt' # shared_txt.rb + require_relative 'txt_shared' # txt_shared.rb @@img_count=0 @@odf={ body: [], head: [], toc: [], metadata: [], tail: [], book_idx: [], endnotes: [] } @@docstart=true @@ -163,7 +163,7 @@ module SiSU_ODF idx_arr,idx_raw=[],SiSU_Particulars::CombinedSingleton.instance.get_idx_raw(@md.opt).raw_idx idx_raw.each do |x| x=if x.is_a?(String) - SiSU_ODF_Format::FormatBookIndex.new(x).book_idx_bookmark + SiSU_XML_ODF_ODT_Format::FormatBookIndex.new(x).book_idx_bookmark else nil end idx_arr << x.strip if x.is_a?(String) @@ -181,7 +181,7 @@ module SiSU_ODF @@odf[:tail] << "\n</office:text></office:body></office:document-content>" end def set_bookmark_tag(dob) - SiSU_ODF_Format::Tags.new.set_bookmark_tag(dob) + SiSU_XML_ODF_ODT_Format::Tags.new.set_bookmark_tag(dob) end def heading(dob,p_num) dob=footnote(dob) @@ -521,14 +521,14 @@ module SiSU_ODF def table(dob,p_num) # if dob.is ==:table dob=footnote(dob) #check - table=SiSU_ODF_Format::Table.new(@md,dob,p_num) + table=SiSU_XML_ODF_ODT_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::FormatObjBreak.new(@md,dob) + br=SiSU_XML_ODF_ODT_Format::FormatObjBreak.new(@md,dob) if dob.obj==Mx[:br_page] \ or dob.obj==Mx[:br_page_new] dob=br.br_page @@ -554,7 +554,7 @@ module SiSU_ODF if @env.odt_ocn? if defined? dob.ocn \ and dob.ocn.is_a?(Fixnum) - p_num=SiSU_ODF_Format::ParagraphNumber.new(dob.ocn).set_bookmark_and_display + p_num=SiSU_XML_ODF_ODT_Format::ParagraphNumber.new(dob.ocn).set_bookmark_and_display end end end @@ -677,7 +677,7 @@ module SiSU_ODF and (dob.obj =~/~metadata/ or dob =~/#{Mx[:lv_o]}1:meta#{Mx[:lv_x]}\s*Document Information/) #fix Mx[:lv_o] if dob.is !~/(^#{Rx[:meta]}|#{Mx[:br_eof]}|#{Mx[:br_endnotes]})/ #check if defined? dob.ocn and dob.ocn =~/\d+/ - @p_num=SiSU_ODF_Format::ParagraphNumber.new(dob.ocn) + @p_num=SiSU_XML_ODF_ODT_Format::ParagraphNumber.new(dob.ocn) end if dob.is ==:heading \ || dob.is ==:para \ @@ -758,7 +758,7 @@ WOK br_pg << @@odf[:metadata] << @@odf[:tail] - SiSU_ODF::Source::Output.new(content,@md,@env).odf + SiSU_XML_ODF_ODT::Source::Output.new(content,@md,@env).odf @@odf={ head: [], toc: [], body: [], tail: [], book_idx: [], metadata: [] } end end @@ -769,7 +769,7 @@ WOK def odf #%odf output env=SiSU_Env::FileOp.new(@md) env.mkdir - header=SiSU_ODF_Format::ODT_Head_1_2.new(@md) + header=SiSU_XML_ODF_ODT_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/v5/odf_format.rb b/lib/sisu/v5/xml_odf_odt_format.rb index 587c9fd0..27628e82 100644 --- a/lib/sisu/v5/odf_format.rb +++ b/lib/sisu/v5/xml_odf_odt_format.rb @@ -59,7 +59,7 @@ ** Description: opendocument formatting, default opendocument template =end -module SiSU_ODF_Format +module SiSU_XML_ODF_ODT_Format require_relative 'param' # param.rb include SiSU_Param include SiSU_Viz @@ -195,7 +195,7 @@ module SiSU_ODF_Format when 14; 'N' else 'D' end - tag=SiSU_ODF_Format::Tags.new.set_bookmark_tag(@dob) + tag=SiSU_XML_ODF_ODT_Format::Tags.new.set_bookmark_tag(@dob) %{<table:table table:name="Table#{count}" table:style-name="Table#{type}">#{@p_num[:set_ref]}#{tag}#{break_line}} + %{<table:table-column table:style-name="Table#{type}.#{alpha}" table:number-columns-repeated="#{@dob.cols}"/>#{break_line}} end diff --git a/lib/sisu/v5/xml_sax.rb b/lib/sisu/v5/xml_sax.rb index a53abdd6..aa701822 100644 --- a/lib/sisu/v5/xml_sax.rb +++ b/lib/sisu/v5/xml_sax.rb @@ -66,7 +66,7 @@ module SiSU_XML_SAX include SiSU_Particulars require_relative 'sysenv' # sysenv.rb include SiSU_Env - require_relative 'shared_xml' # shared_xml.rb + require_relative 'xml_shared' # xml_shared.rb include SiSU_XML_Munge require_relative 'xml_format' # xml_format.rb include SiSU_XML_Format @@ -135,10 +135,10 @@ module SiSU_XML_SAX end end class Scroll - require_relative 'shared_txt' # shared_txt.rb + require_relative 'txt_shared' # txt_shared.rb include SiSU_TextUtils require_relative 'css' # css.rb - require_relative 'shared_xhtml' # decide use, whether xml rather than xhtml + require_relative 'xhtml_shared' # decide use, whether xml rather than xhtml @@xml={ body: [], open: [], close: [], head: [] } def initialize(particulars) @env,@md,@ao_array=particulars.env,particulars.md,particulars.ao_array diff --git a/lib/sisu/v5/shared_xml.rb b/lib/sisu/v5/xml_shared.rb index 76b5374b..caad8be0 100644 --- a/lib/sisu/v5/shared_xml.rb +++ b/lib/sisu/v5/xml_shared.rb @@ -50,7 +50,7 @@ * Git <http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=summary> - <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v5/shared_xml.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v5/xml_shared.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -430,26 +430,56 @@ module SiSU_XML_Munge dob.obj=tidywords(wordlist).join(' ').strip dob end - def markup_fictionbook(dob='') - 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(/<[-~]#>/,''). + def clean(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;') + end + def markup_fictionbook(str='',is='') + str=str.gsub(/#{Mx[:en_a_o]}([\d+*]+).+?#{Mx[:en_a_c]}/m,'<a xlink:href="#footnote\1" type="note">[\1]</a>'). + gsub(/&/,'&'). #sort + gsub(/#{Mx[:mk_o]}#([a-zA-Z]+)#{Mx[:mk_c]}/,'&\1;'). 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 + gsub(/#{Mx[:mk_o]}(#[0-9]+)#{Mx[:mk_c]}/,'&\1;') + str=str.gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,'<br />') unless is==:table + str=str.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[:lnk_o]}\s*(\S+?\.(?:png|jpg|gif)).+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}|image)/m,'<image xlink:href="#\1" />'). + gsub(/#{Mx[:url_o]}(.+?)#{Mx[:url_c]}/,"#{Dx[:url_o]}\\1#{Dx[:url_c]}"). + 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 />') + clean(str) + end + def markup_docbook(dob='') # work on, initially a copy of fictionbook! + dob.obj=dob.obj.gsub(/#{Mx[:en_a_o]}(.+?)#{Mx[:en_a_c]}/m,'<footnote>\1</footnote>'). + gsub(/&/,'&'). #sort + gsub(/#{Mx[:mk_o]}#([a-zA-Z]+)#{Mx[:mk_c]}/,'&\1;'). + gsub(/(^|#{Mx[:gl_c]}|\s)&\s+/,'\1& '). #sort + 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[:url_o]}(.+?)#{Mx[:url_c]}/,"#{Dx[:url_o]}\\1#{Dx[:url_c]}"). + 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.obj=clean(dob.obj) dob end def markup_group(dob='') |