diff options
-rw-r--r-- | bin/sisu | 4 | ||||
l--------- | bin/sisu6 (renamed from bin/sisu4) | 0 | ||||
l--------- | conf/sisu/v6/sisurc.yml (renamed from conf/sisu/v4/sisurc.yml) | 0 | ||||
-rw-r--r-- | data/doc/sisu/CHANGELOG_v1 | 1 | ||||
-rw-r--r-- | data/doc/sisu/CHANGELOG_v2 | 1 | ||||
-rw-r--r-- | data/doc/sisu/CHANGELOG_v3 | 3 | ||||
-rw-r--r-- | data/doc/sisu/CHANGELOG_v4 | 2 | ||||
-rw-r--r-- | data/doc/sisu/CHANGELOG_v5 | 5 | ||||
-rw-r--r-- | data/doc/sisu/CHANGELOG_v6 | 4 | ||||
l--------- | data/doc/sisu/markup-samples/sisu_manual/_sisu/v6/sisurc.yml (renamed from data/doc/sisu/markup-samples/sisu_manual/_sisu/v4/sisurc.yml) | 0 | ||||
-rw-r--r-- | lib/sisu/v4/plaintext_format.rb | 116 | ||||
-rw-r--r-- | lib/sisu/v4/xml_fictionbook.rb | 305 | ||||
-rw-r--r-- | lib/sisu/v6/air.rb (renamed from lib/sisu/v4/air.rb) | 11 | ||||
-rw-r--r-- | lib/sisu/v6/ao.rb (renamed from lib/sisu/v4/dal.rb) | 254 | ||||
-rw-r--r-- | lib/sisu/v6/ao_character_check.rb (renamed from lib/sisu/v4/dal_character_check.rb) | 7 | ||||
-rw-r--r-- | lib/sisu/v6/ao_doc_objects.rb (renamed from lib/sisu/v4/dal_doc_objects.rb) | 73 | ||||
-rw-r--r-- | lib/sisu/v6/ao_doc_str.rb (renamed from lib/sisu/v4/dal_doc_str.rb) | 774 | ||||
-rw-r--r-- | lib/sisu/v6/ao_endnotes.rb (renamed from lib/sisu/v4/dal_endnotes.rb) | 9 | ||||
-rw-r--r-- | lib/sisu/v6/ao_expand_insertions.rb (renamed from lib/sisu/v4/dal_expand_insertions.rb) | 19 | ||||
-rw-r--r-- | lib/sisu/v6/ao_hash_digest.rb (renamed from lib/sisu/v4/dal_hash_digest.rb) | 11 | ||||
-rw-r--r-- | lib/sisu/v6/ao_idx.rb (renamed from lib/sisu/v4/dal_idx.rb) | 29 | ||||
-rw-r--r-- | lib/sisu/v6/ao_images.rb (renamed from lib/sisu/v4/dal_images.rb) | 21 | ||||
-rw-r--r-- | lib/sisu/v6/ao_metadata.rb (renamed from lib/sisu/v4/dal_metadata.rb) | 11 | ||||
-rw-r--r-- | lib/sisu/v6/ao_misc_arrange.rb (renamed from lib/sisu/v4/dal_misc_arrange.rb) | 9 | ||||
-rw-r--r-- | lib/sisu/v6/ao_numbering.rb (renamed from lib/sisu/v4/dal_numbering.rb) | 60 | ||||
-rw-r--r-- | lib/sisu/v6/ao_syntax.rb (renamed from lib/sisu/v4/dal_syntax.rb) | 9 | ||||
-rw-r--r-- | lib/sisu/v6/author_format.rb (renamed from lib/sisu/v4/author_format.rb) | 5 | ||||
-rw-r--r-- | lib/sisu/v6/cgi.rb (renamed from lib/sisu/v4/cgi.rb) | 5 | ||||
-rw-r--r-- | lib/sisu/v6/cgi_pgsql.rb (renamed from lib/sisu/v4/cgi_pgsql.rb) | 15 | ||||
-rw-r--r-- | lib/sisu/v6/cgi_sql_common.rb (renamed from lib/sisu/v4/cgi_sql_common.rb) | 11 | ||||
-rw-r--r-- | lib/sisu/v6/cgi_sqlite.rb (renamed from lib/sisu/v4/cgi_sqlite.rb) | 17 | ||||
-rw-r--r-- | lib/sisu/v6/composite.rb (renamed from lib/sisu/v4/composite.rb) | 25 | ||||
-rw-r--r-- | lib/sisu/v6/concordance.rb (renamed from lib/sisu/v4/concordance.rb) | 42 | ||||
-rw-r--r-- | lib/sisu/v6/conf.rb (renamed from lib/sisu/v4/conf.rb) | 29 | ||||
-rw-r--r-- | lib/sisu/v6/constants.rb (renamed from lib/sisu/v4/constants.rb) | 54 | ||||
-rw-r--r-- | lib/sisu/v6/css.rb (renamed from lib/sisu/v4/css.rb) | 5 | ||||
-rw-r--r-- | lib/sisu/v6/db_columns.rb (renamed from lib/sisu/v4/db_columns.rb) | 5 | ||||
-rw-r--r-- | lib/sisu/v6/db_create.rb (renamed from lib/sisu/v4/db_create.rb) | 66 | ||||
-rw-r--r-- | lib/sisu/v6/db_dbi.rb (renamed from lib/sisu/v4/db_dbi.rb) | 5 | ||||
-rw-r--r-- | lib/sisu/v6/db_drop.rb (renamed from lib/sisu/v4/db_drop.rb) | 10 | ||||
-rw-r--r-- | lib/sisu/v6/db_import.rb (renamed from lib/sisu/v4/db_import.rb) | 133 | ||||
-rw-r--r-- | lib/sisu/v6/db_indexes.rb (renamed from lib/sisu/v4/db_indexes.rb) | 16 | ||||
-rw-r--r-- | lib/sisu/v6/db_load_tuple.rb (renamed from lib/sisu/v4/db_load_tuple.rb) | 69 | ||||
-rw-r--r-- | lib/sisu/v6/db_remove.rb (renamed from lib/sisu/v4/db_remove.rb) | 15 | ||||
-rw-r--r-- | lib/sisu/v6/db_select.rb (renamed from lib/sisu/v4/db_select.rb) | 23 | ||||
-rw-r--r-- | lib/sisu/v6/db_sqltxt.rb (renamed from lib/sisu/v4/db_sqltxt.rb) | 9 | ||||
-rw-r--r-- | lib/sisu/v6/db_tests.rb (renamed from lib/sisu/v4/db_tests.rb) | 9 | ||||
-rw-r--r-- | lib/sisu/v6/dbi.rb (renamed from lib/sisu/v4/dbi.rb) | 25 | ||||
-rw-r--r-- | lib/sisu/v6/dbi_discrete.rb (renamed from lib/sisu/v4/dbi_discrete.rb) | 19 | ||||
-rw-r--r-- | lib/sisu/v6/defaults.rb (renamed from lib/sisu/v4/defaults.rb) | 25 | ||||
-rw-r--r-- | lib/sisu/v6/digests.rb (renamed from lib/sisu/v4/digests.rb) | 92 | ||||
-rw-r--r-- | lib/sisu/v6/embedded.rb (renamed from lib/sisu/v4/embedded.rb) | 24 | ||||
-rw-r--r-- | lib/sisu/v6/errors.rb (renamed from lib/sisu/v4/errors.rb) | 5 | ||||
-rw-r--r-- | lib/sisu/v6/git.rb (renamed from lib/sisu/v4/git.rb) | 35 | ||||
-rw-r--r-- | lib/sisu/v6/harvest.rb (renamed from lib/sisu/v4/harvest.rb) | 9 | ||||
-rw-r--r-- | lib/sisu/v6/harvest_authors.rb (renamed from lib/sisu/v4/harvest_authors.rb) | 16 | ||||
-rw-r--r-- | lib/sisu/v6/harvest_topics.rb (renamed from lib/sisu/v4/harvest_topics.rb) | 24 | ||||
-rw-r--r-- | lib/sisu/v6/html.rb (renamed from lib/sisu/v4/html.rb) | 112 | ||||
-rw-r--r-- | lib/sisu/v6/html_format.rb (renamed from lib/sisu/v4/html_format.rb) | 31 | ||||
-rw-r--r-- | lib/sisu/v6/html_lite_shared.rb (renamed from lib/sisu/v4/shared_html_lite.rb) | 5 | ||||
-rw-r--r-- | lib/sisu/v6/html_minitoc.rb (renamed from lib/sisu/v4/html_minitoc.rb) | 40 | ||||
-rw-r--r-- | lib/sisu/v6/html_promo.rb (renamed from lib/sisu/v4/html_promo.rb) | 7 | ||||
-rw-r--r-- | lib/sisu/v6/html_scroll.rb (renamed from lib/sisu/v4/html_scroll.rb) | 22 | ||||
-rw-r--r-- | lib/sisu/v6/html_segments.rb (renamed from lib/sisu/v4/html_segments.rb) | 69 | ||||
-rw-r--r-- | lib/sisu/v6/html_shared.rb (renamed from lib/sisu/v4/shared_html.rb) | 5 | ||||
-rw-r--r-- | lib/sisu/v6/html_table.rb (renamed from lib/sisu/v4/html_table.rb) | 5 | ||||
-rw-r--r-- | lib/sisu/v6/html_tune.rb (renamed from lib/sisu/v4/html_tune.rb) | 17 | ||||
-rw-r--r-- | lib/sisu/v6/hub.rb (renamed from lib/sisu/v4/hub.rb) | 152 | ||||
-rw-r--r-- | lib/sisu/v6/i18n.rb (renamed from lib/sisu/v4/i18n.rb) | 145 | ||||
-rw-r--r-- | lib/sisu/v6/manifest.rb (renamed from lib/sisu/v4/manifest.rb) | 100 | ||||
-rw-r--r-- | lib/sisu/v6/manpage.rb (renamed from lib/sisu/v4/manpage.rb) | 62 | ||||
-rw-r--r-- | lib/sisu/v6/manpage_format.rb (renamed from lib/sisu/v4/manpage_format.rb) | 19 | ||||
-rw-r--r-- | lib/sisu/v6/options.rb (renamed from lib/sisu/v4/options.rb) | 325 | ||||
-rw-r--r-- | lib/sisu/v6/param.rb (renamed from lib/sisu/v4/param.rb) | 75 | ||||
-rw-r--r-- | lib/sisu/v6/param_identify_markup.rb (renamed from lib/sisu/v4/param_identify_markup.rb) | 9 | ||||
-rw-r--r-- | lib/sisu/v6/param_make.rb (renamed from lib/sisu/v4/param_make.rb) | 20 | ||||
-rw-r--r-- | lib/sisu/v6/particulars.rb (renamed from lib/sisu/v4/particulars.rb) | 31 | ||||
-rw-r--r-- | lib/sisu/v6/po4a.rb (renamed from lib/sisu/v4/po4a.rb) | 85 | ||||
-rw-r--r-- | lib/sisu/v6/po4a_set.rb (renamed from lib/sisu/v4/po4a_set.rb) | 97 | ||||
-rw-r--r-- | lib/sisu/v6/prog_text_translation.rb (renamed from lib/sisu/v4/prog_text_translation.rb) | 467 | ||||
-rw-r--r-- | lib/sisu/v6/qrcode.rb (renamed from lib/sisu/v4/qrcode.rb) | 35 | ||||
-rw-r--r-- | lib/sisu/v6/relaxng.rb (renamed from lib/sisu/v4/relaxng.rb) | 59 | ||||
-rw-r--r-- | lib/sisu/v6/remote.rb (renamed from lib/sisu/v4/remote.rb) | 27 | ||||
-rw-r--r-- | lib/sisu/v6/response.rb (renamed from lib/sisu/v4/response.rb) | 5 | ||||
-rw-r--r-- | lib/sisu/v6/rexml.rb (renamed from lib/sisu/v4/rexml.rb) | 14 | ||||
-rw-r--r-- | lib/sisu/v6/screen_text_color.rb (renamed from lib/sisu/v4/screen_text_color.rb) | 139 | ||||
-rw-r--r-- | lib/sisu/v6/shared_images.rb (renamed from lib/sisu/v4/shared_images.rb) | 5 | ||||
-rw-r--r-- | lib/sisu/v6/shared_markup_alt.rb (renamed from lib/sisu/v4/shared_markup_alt.rb) | 7 | ||||
-rw-r--r-- | lib/sisu/v6/shared_metadata.rb (renamed from lib/sisu/v4/shared_metadata.rb) | 15 | ||||
-rw-r--r-- | lib/sisu/v6/shared_sem.rb (renamed from lib/sisu/v4/shared_sem.rb) | 5 | ||||
-rw-r--r-- | lib/sisu/v6/sitemaps.rb (renamed from lib/sisu/v4/sitemaps.rb) | 11 | ||||
-rw-r--r-- | lib/sisu/v6/spell.rb (renamed from lib/sisu/v4/spell.rb) | 5 | ||||
-rw-r--r-- | lib/sisu/v6/src_kdissert_share.rb (renamed from lib/sisu/v4/share_src_kdissert.rb) | 11 | ||||
-rw-r--r-- | lib/sisu/v6/src_share.rb (renamed from lib/sisu/v4/share_src.rb) | 26 | ||||
-rw-r--r-- | lib/sisu/v6/src_shared.rb (renamed from lib/sisu/v4/shared_sisupod_source.rb) | 19 | ||||
-rw-r--r-- | lib/sisu/v6/src_sisupod_make.rb (renamed from lib/sisu/v4/sisupod_make.rb) | 35 | ||||
-rw-r--r-- | lib/sisu/v6/sst_convert_markup.rb (renamed from lib/sisu/v4/sst_convert_markup.rb) | 64 | ||||
-rw-r--r-- | lib/sisu/v6/sst_do_inline_footnotes.rb (renamed from lib/sisu/v4/sst_do_inline_footnotes.rb) | 80 | ||||
-rw-r--r-- | lib/sisu/v6/sst_from_xml.rb (renamed from lib/sisu/v4/sst_from_xml.rb) | 13 | ||||
-rw-r--r-- | lib/sisu/v6/sst_identify_markup.rb (renamed from lib/sisu/v4/sst_identify_markup.rb) | 7 | ||||
-rw-r--r-- | lib/sisu/v6/sst_to_s_xml_sax.rb (renamed from lib/sisu/v4/sst_to_s_xml_sax.rb) | 43 | ||||
-rw-r--r-- | lib/sisu/v6/sysenv.rb (renamed from lib/sisu/v4/sysenv.rb) | 1007 | ||||
-rw-r--r-- | lib/sisu/v6/termsheet.rb (renamed from lib/sisu/v4/termsheet.rb) | 5 | ||||
-rw-r--r-- | lib/sisu/v6/texinfo.rb (renamed from lib/sisu/v4/texinfo.rb) | 47 | ||||
-rw-r--r-- | lib/sisu/v6/texinfo_format.rb (renamed from lib/sisu/v4/texinfo_format.rb) | 21 | ||||
-rw-r--r-- | lib/sisu/v6/texpdf.rb (renamed from lib/sisu/v4/texpdf.rb) | 108 | ||||
-rw-r--r-- | lib/sisu/v6/texpdf_format.rb (renamed from lib/sisu/v4/texpdf_format.rb) | 281 | ||||
-rw-r--r-- | lib/sisu/v6/txt_asciidoc.rb | 556 | ||||
-rw-r--r-- | lib/sisu/v6/txt_markdown.rb | 591 | ||||
-rw-r--r-- | lib/sisu/v6/txt_plain.rb | 583 | ||||
-rw-r--r-- | lib/sisu/v6/txt_rst.rb | 552 | ||||
-rw-r--r-- | lib/sisu/v6/txt_shared.rb (renamed from lib/sisu/v4/shared_txt.rb) | 109 | ||||
-rw-r--r-- | lib/sisu/v6/txt_textile.rb (renamed from lib/sisu/v4/plaintext.rb) | 300 | ||||
-rw-r--r-- | lib/sisu/v6/update.rb (renamed from lib/sisu/v4/update.rb) | 7 | ||||
-rw-r--r-- | lib/sisu/v6/urls.rb (renamed from lib/sisu/v4/urls.rb) | 163 | ||||
-rw-r--r-- | lib/sisu/v6/utils.rb (renamed from lib/sisu/v4/utils.rb) | 43 | ||||
-rw-r--r-- | lib/sisu/v6/webrick.rb (renamed from lib/sisu/v4/webrick.rb) | 5 | ||||
-rw-r--r-- | lib/sisu/v6/wikispeak.rb (renamed from lib/sisu/v4/wikispeak.rb) | 34 | ||||
-rw-r--r-- | lib/sisu/v6/xhtml.rb (renamed from lib/sisu/v4/xhtml.rb) | 71 | ||||
-rw-r--r-- | lib/sisu/v6/xhtml_epub2.rb (renamed from lib/sisu/v4/epub.rb) | 239 | ||||
-rw-r--r-- | lib/sisu/v6/xhtml_epub2_concordance.rb (renamed from lib/sisu/v4/epub_concordance.rb) | 57 | ||||
-rw-r--r-- | lib/sisu/v6/xhtml_epub2_format.rb (renamed from lib/sisu/v4/epub_format.rb) | 28 | ||||
-rw-r--r-- | lib/sisu/v6/xhtml_epub2_segments.rb (renamed from lib/sisu/v4/epub_segments.rb) | 135 | ||||
-rw-r--r-- | lib/sisu/v6/xhtml_epub2_tune.rb (renamed from lib/sisu/v4/epub_tune.rb) | 37 | ||||
-rw-r--r-- | lib/sisu/v6/xhtml_shared.rb (renamed from lib/sisu/v4/shared_xhtml.rb) | 5 | ||||
-rw-r--r-- | lib/sisu/v6/xhtml_table.rb (renamed from lib/sisu/v4/xhtml_table.rb) | 5 | ||||
-rw-r--r-- | lib/sisu/v6/xml_docbook5.rb | 277 | ||||
-rw-r--r-- | lib/sisu/v6/xml_dom.rb (renamed from lib/sisu/v4/xml_dom.rb) | 76 | ||||
-rw-r--r-- | lib/sisu/v6/xml_fictionbook2.rb | 372 | ||||
-rw-r--r-- | lib/sisu/v6/xml_format.rb (renamed from lib/sisu/v4/xml_format.rb) | 26 | ||||
-rw-r--r-- | lib/sisu/v6/xml_md_oai_pmh_dc.rb (renamed from lib/sisu/v4/xml_md_oai_pmh_dc.rb) | 5 | ||||
-rw-r--r-- | lib/sisu/v6/xml_odf_odt.rb (renamed from lib/sisu/v4/odf.rb) | 146 | ||||
-rw-r--r-- | lib/sisu/v6/xml_odf_odt_format.rb (renamed from lib/sisu/v4/odf_format.rb) | 87 | ||||
-rw-r--r-- | lib/sisu/v6/xml_sax.rb (renamed from lib/sisu/v4/xml.rb) | 72 | ||||
-rw-r--r-- | lib/sisu/v6/xml_scaffold_structure_collapsed.rb | 203 | ||||
-rw-r--r-- | lib/sisu/v6/xml_scaffold_structure_sisu.rb (renamed from lib/sisu/v4/xml_scaffold.rb) | 142 | ||||
-rw-r--r-- | lib/sisu/v6/xml_shared.rb (renamed from lib/sisu/v4/shared_xml.rb) | 98 | ||||
-rw-r--r-- | lib/sisu/v6/xml_tables.rb (renamed from lib/sisu/v4/xml_tables.rb) | 5 | ||||
-rw-r--r-- | lib/sisu/v6/zap.rb (renamed from lib/sisu/v4/zap.rb) | 13 | ||||
l--------- | man/man1/sisu6.1 (renamed from man/man1/sisu4.1) | 0 |
140 files changed, 8084 insertions, 3532 deletions
@@ -10,10 +10,10 @@ class Orient end def version def stable - '4' + '5' end def unstable - '5' + '6' end def default stable diff --git a/conf/sisu/v4/sisurc.yml b/conf/sisu/v6/sisurc.yml index e492f789..e492f789 120000 --- a/conf/sisu/v4/sisurc.yml +++ b/conf/sisu/v6/sisurc.yml diff --git a/data/doc/sisu/CHANGELOG_v1 b/data/doc/sisu/CHANGELOG_v1 index 611d5c97..cef3a4dc 100644 --- a/data/doc/sisu/CHANGELOG_v1 +++ b/data/doc/sisu/CHANGELOG_v1 @@ -1,4 +1,5 @@ %% SiSU version 1 + v1 branch is legacy: v2 branch supersedes & replaces it v1 sisu pretty mature in operation and syntax v1 branch removed from sisu 3.0 available in sisu =< 2.7 diff --git a/data/doc/sisu/CHANGELOG_v2 b/data/doc/sisu/CHANGELOG_v2 index 889cc0b1..7e73c840 100644 --- a/data/doc/sisu/CHANGELOG_v2 +++ b/data/doc/sisu/CHANGELOG_v2 @@ -1,4 +1,5 @@ %% SiSU version 2 + v2 branch is legacy: v3 branch supersedes & replaces it v2 branch supersedes & replaces v1 branch v2 introduces new processing middle layer (document abstraction); diff --git a/data/doc/sisu/CHANGELOG_v3 b/data/doc/sisu/CHANGELOG_v3 index e67d0f86..ba0ba601 100644 --- a/data/doc/sisu/CHANGELOG_v3 +++ b/data/doc/sisu/CHANGELOG_v3 @@ -1,10 +1,11 @@ %% SiSU version 3 <http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=summary> <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=data/doc/sisu/CHANGELOG_v3;hb=HEAD> + v3 branch closed with opening of v5 from >= 4.1 v3 branch is legacy: v4 branch supersedes & replaces it v3 branch supersedes & replaces v2 branch -v3 introduces alternative (configurable) output structures +v2 introduces alternative (configurable) output structures v1 branch is removed; it is available in sisu =< 2.7 * homepage at: <http://www.jus.uio.no/sisu> diff --git a/data/doc/sisu/CHANGELOG_v4 b/data/doc/sisu/CHANGELOG_v4 index d9e3c365..b8ecf14b 100644 --- a/data/doc/sisu/CHANGELOG_v4 +++ b/data/doc/sisu/CHANGELOG_v4 @@ -32,7 +32,7 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_4.2.21.orig.tar.xz sisu_4.2.21.orig.tar.xz sisu_4.2.21-1.dsc -[closing] +[closed] * bin/sisu changes to simplify switching to new stable and development branches diff --git a/data/doc/sisu/CHANGELOG_v5 b/data/doc/sisu/CHANGELOG_v5 index 2e835cf2..55d7a492 100644 --- a/data/doc/sisu/CHANGELOG_v5 +++ b/data/doc/sisu/CHANGELOG_v5 @@ -38,6 +38,11 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_5.3.0.orig.tar.xz sisu_5.3.0.orig.tar.xz sisu_5.3.0-1.dsc +* v5 stable branch + * v4 branch closed -(>4.2.20)- + * v5 stable branch (>=5.3.0) + * v6 development branch opened (copy v5) (>=6.0.0) + %% 5.2.4.orig.tar.xz (2014-01-26:03/7) http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/sisu_5.2.4 http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/debian/sisu_5.2.4-1 diff --git a/data/doc/sisu/CHANGELOG_v6 b/data/doc/sisu/CHANGELOG_v6 index 739d2517..6b755eb0 100644 --- a/data/doc/sisu/CHANGELOG_v6 +++ b/data/doc/sisu/CHANGELOG_v6 @@ -28,3 +28,7 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_6.0.0.orig.tar.xz sisu_6.0.0.orig.tar.xz sisu_6.0.0-1.dsc +* v6 development branch opened + * v4 branch closed -(>4.2.20)- + * v5 stable branch (>=5.3.0) + * v6 development branch opened (copy v5) (>=6.0.0) diff --git a/data/doc/sisu/markup-samples/sisu_manual/_sisu/v4/sisurc.yml b/data/doc/sisu/markup-samples/sisu_manual/_sisu/v6/sisurc.yml index e492f789..e492f789 120000 --- a/data/doc/sisu/markup-samples/sisu_manual/_sisu/v4/sisurc.yml +++ b/data/doc/sisu/markup-samples/sisu_manual/_sisu/v6/sisurc.yml diff --git a/lib/sisu/v4/plaintext_format.rb b/lib/sisu/v4/plaintext_format.rb deleted file mode 100644 index 34325264..00000000 --- a/lib/sisu/v4/plaintext_format.rb +++ /dev/null @@ -1,116 +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/v4/plaintext_format.rb;hb=HEAD> - - * Ralph Amissah - <ralph@amissah.com> - <ralph.amissah@gmail.com> - - ** Description: plaintext formatting template - -=end -module SiSU_PlaintextFormat - 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[\\1]") - 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 - def heading_body1 - end - def heading_body2 - end - def heading_body3 - end - def heading_body4 - end - def heading_body5 - end - def heading_body6 - end - end - class XML - end -end -__END__ diff --git a/lib/sisu/v4/xml_fictionbook.rb b/lib/sisu/v4/xml_fictionbook.rb deleted file mode 100644 index 119f7d78..00000000 --- a/lib/sisu/v4/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/v4/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.cmd =~/V/ - 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.cmd =~/V/; "#{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.cmd =~/V/ - end - c+=1 - end - end - structure_build(@ds) - @ds - end - end - end -end -__END__ diff --git a/lib/sisu/v4/air.rb b/lib/sisu/v6/air.rb index 1965eb10..2af4038e 100644 --- a/lib/sisu/v4/air.rb +++ b/lib/sisu/v6/air.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/air.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/air.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -62,7 +63,7 @@ module SiSU_Air require_relative 'particulars' # particulars.rb class Source - @@dal_array=[] + @@ao_array=[] @@fns=nil def initialize(opt) @opt=opt @@ -70,7 +71,7 @@ module SiSU_Air @particulars=SiSU_Particulars::Combined.new(opt) #@env=@particulars.env #@md=@particulars.md - #@dal_array=@particulars.dal_array + #@ao_array=@particulars.ao_array end def read end @@ -78,7 +79,7 @@ module SiSU_Air def print puts @particulars.md.inspect puts @particulars.env.inspect - puts @particulars.dal_array + puts @particulars.ao_array end end end diff --git a/lib/sisu/v4/dal.rb b/lib/sisu/v6/ao.rb index 839e4c9a..6f7b1ac8 100644 --- a/lib/sisu/v4/dal.rb +++ b/lib/sisu/v6/ao.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/dal.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/ao.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -60,26 +61,26 @@ in subsequent processing =end -module SiSU_DAL +module SiSU_AO require_relative 'defaults' # defaults.rb include SiSU_Viz require_relative 'sysenv' # sysenv.rb include SiSU_Env require_relative 'param' # param.rb include SiSU_Param - require_relative 'dal_doc_objects' # dal_doc_objects.rb - require_relative 'dal_syntax' # dal_syntax.rb - 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 - require_relative 'dal_hash_digest' # dal_hash_digest.rb - require_relative 'dal_endnotes' # dal_endnotes.rb - require_relative 'dal_images' # dal_images.rb - require_relative 'dal_metadata' # dal_metadata.rb - require_relative 'dal_character_check' # dal_character_check.rb - require_relative 'dal_misc_arrange' # dal_misc_arrange.rb - require_relative 'dal_expand_insertions' # dal_expand_insertions.rb + require_relative 'ao_doc_objects' # ao.rb + require_relative 'ao_syntax' # ao_syntax.rb + include SiSU_AO_Syntax + require_relative 'ao_doc_str' # ao_doc_str.rb + require_relative 'ao_idx' # ao_idx.rb + require_relative 'ao_numbering' # ao_numbering.rb + require_relative 'ao_hash_digest' # ao_hash_digest.rb + require_relative 'ao_endnotes' # ao_endnotes.rb + require_relative 'ao_images' # ao_images.rb + require_relative 'ao_metadata' # ao_metadata.rb + require_relative 'ao_character_check' # ao_character_check.rb + require_relative 'ao_misc_arrange' # ao_misc_arrange.rb + require_relative 'ao_expand_insertions' # ao_expand_insertions.rb require_relative 'prog_text_translation' # prog_text_translation.rb require_relative 'shared_sem' # shared_sem.rb class Instantiate < SiSU_Param::Parameters::Instructions @@ -89,7 +90,7 @@ module SiSU_DAL end end class Source <Instantiate - @@dal_array=[] + @@ao_array=[] @@idx_arr={ sst: [], tex: [], html: [], xhtml: [] } @@map_arr={ nametags: [], ocn_htmlseg: [] } @@fns=nil @@ -105,55 +106,55 @@ module SiSU_DAL opt.fns end @make_fns=SiSU_Env::InfoFile.new(fn_use) - @fnm=@make_fns.marshal.dal_metadata - @fnc=@make_fns.marshal.dal_content - @idx_sst=@make_fns.marshal.dal_idx_sst_rel_html_seg - @idx_raw=@make_fns.marshal.dal_idx_sst_rel - @idx_html=@make_fns.marshal.dal_idx_html - @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 + @fnm=@make_fns.marshal.ao_metadata + @fnc=@make_fns.marshal.ao_content + @idx_sst=@make_fns.marshal.ao_idx_sst_rel_html_seg + @idx_raw=@make_fns.marshal.ao_idx_sst_rel + @idx_html=@make_fns.marshal.ao_idx_html + @idx_xhtml=@make_fns.marshal.ao_idx_xhtml + @map_nametags=@make_fns.marshal.ao_map_nametags + @map_ocn_htmlseg=@make_fns.marshal.ao_map_ocn_htmlseg @env=SiSU_Env::InfoEnv.new end - def read #creates dal + def read #creates ao begin - @@dal_array=[] + @@ao_array=[] @@fns=(@fnx && @fnx =~/\.ss[tmi]$/) \ ? @fnx : @opt.fns - create_dal + create_ao rescue SiSU_Errors::Rescued.new($!,$@,@opt.cmd,@@fns).location do __LINE__.to_s + ':' + __FILE__ end ensure - SiSU_DAL::Instantiate.new + SiSU_AO::Instantiate.new end end - def get #reads dal, unless does not exist then creates first + def get #reads ao, unless does not exist then creates first begin - dal=[] + ao=[] unless @@fns==@opt.fns \ or @@fns==@fnx @@fns=(@fnx && @fnx =~/\.ss[tmi]$/) \ ? @fnx : @opt.fns - @@dal_array=[] + @@ao_array=[] end - dal=(@@dal_array.empty?) \ + ao=(@@ao_array.empty?) \ ? read_fnc - : @@dal_array.dup + : @@ao_array.dup rescue SiSU_Errors::Rescued.new($!,$@,@opt.cmd,@opt.fns).location do __LINE__.to_s + ':' + __FILE__ end ensure - SiSU_DAL::Instantiate.new + SiSU_AO::Instantiate.new end end - def get_idx_sst #reads dal idx.sst, #unless does not exist then creates first + def get_idx_sst #reads ao idx.sst, #unless does not exist then creates first begin - dal=[] + ao=[] unless @@fns==@opt.fns \ or @@fns==@fnx @@fns=(@fnx && @fnx =~/\.ss[tmi]$/) \ @@ -161,18 +162,18 @@ module SiSU_DAL : @opt.fns @@idx_arr[:sst]=[] end - dal=(@@idx_arr[:sst].empty?) ? read_idx_sst : @@idx_arr[:sst].dup #check + ao=(@@idx_arr[:sst].empty?) ? read_idx_sst : @@idx_arr[:sst].dup #check rescue SiSU_Errors::Rescued.new($!,$@,@opt.cmd,@opt.fns).location do __LINE__.to_s + ':' + __FILE__ end ensure - SiSU_DAL::Instantiate.new + SiSU_AO::Instantiate.new end end def get_idx_raw begin - dal=[] + ao=[] unless @@fns==@opt.fns \ or @@fns==@fnx @@fns=(@fnx && @fnx =~/\.ss[tmi]$/) \ @@ -180,18 +181,18 @@ module SiSU_DAL : @opt.fns @@idx_arr[:tex]=[] end - dal=(@@idx_arr[:tex].empty?) ? read_idx_raw : @@idx_arr[:tex].dup #check + ao=(@@idx_arr[:tex].empty?) ? read_idx_raw : @@idx_arr[:tex].dup #check rescue SiSU_Errors::Rescued.new($!,$@,@opt.cmd,@opt.fns).location do __LINE__.to_s + ':' + __FILE__ end ensure - SiSU_DAL::Instantiate.new + SiSU_AO::Instantiate.new end end - def get_idx_html #reads dal idx.html, #unless does not exist then creates first + def get_idx_html #reads ao idx.html, #unless does not exist then creates first begin - dal=[] + ao=[] unless @@fns==@opt.fns \ or @@fns==@fnx @@fns=(@fnx && @fnx =~/\.ss[tmi]$/) \ @@ -199,18 +200,18 @@ module SiSU_DAL : @opt.fns @@idx_arr[:html]=[] end - dal=(@@idx_arr[:html].empty?) ? read_idx_html : @@idx_arr[:html].dup + ao=(@@idx_arr[:html].empty?) ? read_idx_html : @@idx_arr[:html].dup rescue SiSU_Errors::Rescued.new($!,$@,@opt.cmd,@opt.fns).location do __LINE__.to_s + ':' + __FILE__ end ensure - SiSU_DAL::Instantiate.new + SiSU_AO::Instantiate.new end end - def get_idx_xhtml #reads dal idx.xhtml, #unless does not exist then creates first + def get_idx_xhtml #reads ao idx.xhtml, #unless does not exist then creates first begin - dal=[] + ao=[] unless @@fns==@opt.fns \ or @@fns==@fnx @@fns=(@fnx && @fnx =~/\.ss[tmi]$/) \ @@ -218,18 +219,18 @@ module SiSU_DAL : @opt.fns @@idx_arr[:xthml]=[] end - dal=(@@idx_arr[:xhtml].empty?) ? read_idx_xhtml : @@idx_arr[:xhtml].dup + ao=(@@idx_arr[:xhtml].empty?) ? read_idx_xhtml : @@idx_arr[:xhtml].dup rescue SiSU_Errors::Rescued.new($!,$@,@opt.cmd,@opt.fns).location do __LINE__.to_s + ':' + __FILE__ end ensure - SiSU_DAL::Instantiate.new + SiSU_AO::Instantiate.new end end - def get_map_nametags #reads dal map.nametags, #unless does not exist then creates first + def get_map_nametags #reads ao map.nametags, #unless does not exist then creates first begin - dal=[] + ao=[] unless @@fns==@opt.fns \ or @@fns==@fnx @@fns=(@fnx && @fnx =~/\.ss[tmi]$/) \ @@ -237,18 +238,18 @@ module SiSU_DAL : @opt.fns @@map_arr[:nametags]=[] end - dal=(@@map_arr[:nametags].empty?) ? read_map_nametags : @@map_arr[:nametags].dup + ao=(@@map_arr[:nametags].empty?) ? read_map_nametags : @@map_arr[:nametags].dup rescue SiSU_Errors::Rescued.new($!,$@,@opt.cmd,@opt.fns).location do __LINE__.to_s + ':' + __FILE__ end ensure - SiSU_DAL::Instantiate.new + SiSU_AO::Instantiate.new end end - def get_map_ocn_htmlseg #reads dal map.ocn_htmlseg, #unless does not exist then creates first + def get_map_ocn_htmlseg #reads ao map.ocn_htmlseg, #unless does not exist then creates first begin - dal=[] + ao=[] unless @@fns==@opt.fns \ or @@fns==@fnx @@fns=(@fnx && @fnx =~/\.ss[tmi]$/) \ @@ -256,22 +257,24 @@ module SiSU_DAL : @opt.fns @@map_arr[:ocn_htmlseg]=[] end - dal=(@@map_arr[:ocn_htmlseg].empty?) ? read_map_ocn_htmlseg : @@map_arr[:ocn_htmlseg].dup + ao=(@@map_arr[:ocn_htmlseg].empty?) ? read_map_ocn_htmlseg : @@map_arr[:ocn_htmlseg].dup rescue SiSU_Errors::Rescued.new($!,$@,@opt.cmd,@opt.fns).location do __LINE__.to_s + ':' + __FILE__ end ensure - SiSU_DAL::Instantiate.new + SiSU_AO::Instantiate.new end end protected - def create_dal - dal_array=[] - unless @opt.cmd =~/q/ - tell=(@opt.cmd=~/[vVM]/) \ - ? SiSU_Screen::Ansi.new(@opt.cmd,'Document Abstraction') - : SiSU_Screen::Ansi.new(@opt.cmd,'Document Abstraction',"[#{@opt.f_pth[:lng_is]}] #{@opt.fno}") + def create_ao + ao_array=[] + unless @opt.act[:quiet][:set]==:on + tell=(@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) \ + ? SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Document Abstraction') + : SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Document Abstraction',"[#{@opt.f_pth[:lng_is]}] #{@opt.fno}") tell.blue_title_hi end fn=(@fnx && @fnx =~/\.ss[tmi]$/) \ @@ -283,15 +286,21 @@ module SiSU_DAL meta=file_array=@env.source_file_processing_array(fn) @md=SiSU_Param::Parameters::Instructions.new(meta,@opt).extract meta=nil - dal=SiSU_DAL::Make.new(fn,@md,file_array).song - if @opt.cmd =~/[vM]/ + ao=SiSU_AO::Make.new(fn,@md,file_array).song + if (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) 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/ + if (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on) + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],@opt.fns,"~meta/#{@opt.fns}.meta").output + elsif @opt.act[:maintenance][:set]==:on + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"ao -> #{cf.meta}").txt_grey + end end - dal.each {|s| dal_array << s} - if @opt.cmd =~/M/ - dal_array.each do |obj| + ao.each {|s| ao_array << s} + if @opt.act[:maintenance][:set]==:on + ao_array.each do |obj| if defined? obj.parent if defined? obj.ln if defined? obj.node @@ -309,19 +318,19 @@ module SiSU_DAL end end end - dal_array + ao_array end def read_fnm - dal=[] - dal=(FileTest.file?(@fnm)) \ - ? (File.open(@fnm,'r:utf-8'){ |f| dal=Marshal.load(f)}) - : SiSU_DAL::Source.new(@opt).create_dal + ao=[] + ao=(FileTest.file?(@fnm)) \ + ? (File.open(@fnm,'r:utf-8'){ |f| ao=Marshal.load(f)}) + : SiSU_AO::Source.new(@opt).create_ao end def read_fnc - dal=[] - dal=(FileTest.file?(@fnc)) \ - ? (File.open(@fnc,'r:utf-8'){ |f| dal=Marshal.load(f)}) - : SiSU_DAL::Source.new(@opt).create_dal + ao=[] + ao=(FileTest.file?(@fnc)) \ + ? (File.open(@fnc,'r:utf-8'){ |f| ao=Marshal.load(f)}) + : SiSU_AO::Source.new(@opt).create_ao end def read_idx_sst m=[] @@ -402,7 +411,7 @@ module SiSU_DAL end end def hard_output - if @md.opt.cmd =~/M/ + if @md.opt.act[:maintenance][:set]==:on filename_meta=@cf.metaverse.file_meta @data.each {|o| filename_meta.puts o.inspect.sub(/:0x[0-9a-f]{8}\s/,': ')} #to make diffing easier filename_txt=@cf.metaverse.file_txt @@ -431,58 +440,58 @@ module SiSU_DAL end end else - hard="#{@dir.processing_path.dal}/#{@md.fns}.meta" + hard="#{@dir.processing_path.ao}/#{@md.fns}.meta" File.unlink(hard) if FileTest.file?(hard) - hard="#{@dir.processing_path.dal}/#{@md.fns}.txt" + hard="#{@dir.processing_path.ao}/#{@md.fns}.txt" File.unlink(hard) if FileTest.file?(hard) - hard="#{@dir.processing_path.dal}/#{@md.fns}.debug.txt" + hard="#{@dir.processing_path.ao}/#{@md.fns}.debug.txt" File.unlink(hard) if FileTest.file?(hard) end end def make_marshal_content - marshal_dal=@make.marshal.dal_content - File.open(marshal_dal,'w'){|f| Marshal.dump(@data,f)} if @data.is_a?(Array) + marshal_ao=@make.marshal.ao_content + File.open(marshal_ao,'w'){|f| Marshal.dump(@data,f)} if @data.is_a?(Array) end def make_marshal_metadata - marshal_dal=@make.marshal.dal_metadata - File.open(marshal_dal,'w'){|f| Marshal.dump(@data,f)} if @data.is_a?(Array) + marshal_ao=@make.marshal.ao_metadata + File.open(marshal_ao,'w'){|f| Marshal.dump(@data,f)} if @data.is_a?(Array) end def idx_html_hard_output if @md.book_idx \ - and @md.opt.cmd =~/M/ + and @md.opt.act[:maintenance][:set]==:on filename_meta=@cf.file_meta_idx_html if @data.is_a?(Array) @data.each {|s| p s.inspect + "\n" unless s.is_a?(String)} @data.each {|s| filename_meta.puts s.strip + "\n" unless s.strip.empty?} end else - hard_idx_html="#{@dir.processing_path.dal}/#{@md.fns}.idx.html" + hard_idx_html="#{@dir.processing_path.ao}/#{@md.fns}.idx.html" File.unlink(hard_idx_html) if FileTest.file?(hard_idx_html) end end def make_marshal_idx_sst_html_seg - marshal_dal=@make.marshal.dal_idx_sst_rel_html_seg - File.open(marshal_dal,'w'){|f| Marshal.dump(@data,f)} if @data.is_a?(Array) + marshal_ao=@make.marshal.ao_idx_sst_rel_html_seg + File.open(marshal_ao,'w'){|f| Marshal.dump(@data,f)} if @data.is_a?(Array) end def make_marshal_idx_sst_rel - marshal_dal=@make.marshal.dal_idx_sst_rel - File.open(marshal_dal,'w'){|f| Marshal.dump(@data,f)} if @data.is_a?(Array) + marshal_ao=@make.marshal.ao_idx_sst_rel + File.open(marshal_ao,'w'){|f| Marshal.dump(@data,f)} if @data.is_a?(Array) end def make_marshal_idx_html - marshal_dal=@make.marshal.dal_idx_html - File.open(marshal_dal,'w'){|f| Marshal.dump(@data,f)} if @data.is_a?(Array) + marshal_ao=@make.marshal.ao_idx_html + File.open(marshal_ao,'w'){|f| Marshal.dump(@data,f)} if @data.is_a?(Array) end def make_marshal_idx_xhtml - marshal_dal=@make.marshal.dal_idx_xhtml - File.open(marshal_dal,'w'){|f| Marshal.dump(@data,f)} if @data.is_a?(Array) + marshal_ao=@make.marshal.ao_idx_xhtml + File.open(marshal_ao,'w'){|f| Marshal.dump(@data,f)} if @data.is_a?(Array) end def make_marshal_map_nametags - marshal_dal=@make.marshal.dal_map_nametags - File.open(marshal_dal,'w'){|f| Marshal.dump(@data,f)} if @data.is_a?(Hash) + marshal_ao=@make.marshal.ao_map_nametags + File.open(marshal_ao,'w'){|f| Marshal.dump(@data,f)} if @data.is_a?(Hash) end def make_marshal_map_name_ocn_htmlseg - marshal_dal=@make.marshal.dal_map_ocn_htmlseg - File.open(marshal_dal,'w'){|f| Marshal.dump(@data,f)} if @data.is_a?(Hash) + marshal_ao=@make.marshal.ao_map_ocn_htmlseg + File.open(marshal_ao,'w'){|f| Marshal.dump(@data,f)} if @data.is_a?(Hash) end end class Make @@ -497,27 +506,28 @@ module SiSU_DAL def song reset data=@data - data=SiSU_DAL_Insertions::Insertions.new(@md,data).expand_insertions? # dal_expand_insertions.rb - data=SiSU_DAL_MiscArrangeText::SI.new(@md,data).prepare_text # dal_misc_arrange.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 + data=SiSU_AO_Insertions::Insertions.new(@md,data).expand_insertions? # ao_expand_insertions.rb + data=SiSU_AO_MiscArrangeText::SI.new(@md,data).prepare_text # ao_misc_arrange.rb + data,metadata=SiSU_AO_DocumentStructureExtract::Build.new(@md,data).identify_parts # ao_doc_str.rb + data=SiSU_AO_Syntax::Markup.new(@md,data).songsheet # ao_syntax.rb + data,endnote_array=SiSU_AO_CharacterCheck::Check.new(data).character_check_and_oldstyle_endnote_array # ao_character_check.rb + data=SiSU_AO_Images::Images.new(@md,data).images # ao_images.rb + data,tags_map,ocn_html_seg_map=SiSU_AO_Numbering::Numbering.new(@md,data).numbering_song # ao_numbering.rb + data,book_index_rel,book_index_rel_html_seg,html_idx,xhtml_idx=SiSU_AO_BookIndex::BookIndex.new(@md,data,@env).indexing_song if @md.book_idx # ao_idx.rb + data=SiSU_AO_Endnotes::Endnotes.new(@md,data,endnote_array).endnotes # ao_endnotes.rb outputdata=data - if @md.opt.cmd =~/[mM]/ - SiSU_DAL::Output.new(@fn,@md,outputdata).hard_output - SiSU_DAL::Output.new(@fn,@md,outputdata).make_marshal_content - SiSU_DAL::Output.new(@fn,@md,metadata).make_marshal_metadata - SiSU_DAL::Output.new(@fn,@md,html_idx).idx_html_hard_output - SiSU_DAL::Output.new(@fn,@md,book_index_rel_html_seg).make_marshal_idx_sst_html_seg - SiSU_DAL::Output.new(@fn,@md,book_index_rel).make_marshal_idx_sst_rel - SiSU_DAL::Output.new(@fn,@md,html_idx).make_marshal_idx_html - SiSU_DAL::Output.new(@fn,@md,xhtml_idx).make_marshal_idx_xhtml - SiSU_DAL::Output.new(@fn,@md,tags_map).make_marshal_map_nametags - SiSU_DAL::Output.new(@fn,@md,ocn_html_seg_map).make_marshal_map_name_ocn_htmlseg + if (@md.opt.act[:ao][:set]==:on \ + || @md.opt.act[:maintenance][:set]==:on) + SiSU_AO::Output.new(@fn,@md,outputdata).hard_output + SiSU_AO::Output.new(@fn,@md,outputdata).make_marshal_content + SiSU_AO::Output.new(@fn,@md,metadata).make_marshal_metadata + SiSU_AO::Output.new(@fn,@md,html_idx).idx_html_hard_output + SiSU_AO::Output.new(@fn,@md,book_index_rel_html_seg).make_marshal_idx_sst_html_seg + SiSU_AO::Output.new(@fn,@md,book_index_rel).make_marshal_idx_sst_rel + SiSU_AO::Output.new(@fn,@md,html_idx).make_marshal_idx_html + SiSU_AO::Output.new(@fn,@md,xhtml_idx).make_marshal_idx_xhtml + SiSU_AO::Output.new(@fn,@md,tags_map).make_marshal_map_nametags + SiSU_AO::Output.new(@fn,@md,ocn_html_seg_map).make_marshal_map_name_ocn_htmlseg end reset outputdata diff --git a/lib/sisu/v4/dal_character_check.rb b/lib/sisu/v6/ao_character_check.rb index 54e01f4a..8774d7a8 100644 --- a/lib/sisu/v4/dal_character_check.rb +++ b/lib/sisu/v6/ao_character_check.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/dal_character_check.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/ao_character_check.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -59,7 +60,7 @@ ** Description: system environment, resource control and configuration details =end -module SiSU_DAL_CharacterCheck +module SiSU_AO_CharacterCheck class Check def initialize(data) @data=data diff --git a/lib/sisu/v4/dal_doc_objects.rb b/lib/sisu/v6/ao_doc_objects.rb index 0561b363..15e949c4 100644 --- a/lib/sisu/v4/dal_doc_objects.rb +++ b/lib/sisu/v6/ao_doc_objects.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/dal_doc_objects.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/ao_doc_objects.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -59,7 +60,7 @@ ** Description: document abstraction =end -module SiSU_DAL_DocumentStructure +module SiSU_AO_DocumentStructure class Extract def extract(h,o) h ? h : o @@ -107,36 +108,38 @@ module SiSU_DAL_DocumentStructure end def heading_ln(lv) case lv - when /A/; 1 - when /B/; 2 - when /C/; 3 - when /1/; 4 - when /2/; 5 - when /3/; 6 - when /4/; 7 - when /5/; 8 - when /6/; 9 + when /A/ then 0 + when /B/ then 1 + when /C/ then 2 + when /D/ then 3 + when /1/ then 4 + when /2/ then 5 + when /3/ then 6 + when /4/ then 7 + when /5/ then 8 + when /6/ then 9 end end def heading_lv(ln) case ln.to_s - when /1/; 'A' - when /2/; 'B' - when /3/; 'C' - when /4/; '1' - when /5/; '2' - when /6/; '3' - when /7/; '4' - when /8/; '5' - when /9/; '6' + when /0/ then 'A' + when /1/ then 'B' + when /2/ then 'C' + when /3/ then 'D' + when /4/ then '1' + when /5/ then '2' + when /6/ then '3' + when /7/ then '4' + when /8/ then '5' + when /9/ then '6' end end def heading(h,o=nil) if not h[:ln] \ - and (h[:lv] and h[:lv]=~/[1-6A-C]/) + and (h[:lv] and h[:lv]=~/[1-6A-D]/) h[:ln]=heading_ln(h[:lv]) elsif not h[:lv] \ - and (h[:ln] and h[:ln].to_s=~/[1-9]/) + and (h[:ln] and h[:ln].to_s=~/[0-9]/) h[:lv]=heading_lv(h[:ln]) end of= @of #String, classification - group @@ -150,7 +153,7 @@ module SiSU_DAL_DocumentStructure osp= h[:osp] || ((defined? o.osp) ? o.osp : nil) node= h[:node] || ((defined? o.node) ? o.node : nil) #[Node relationship doc structure info] parent= h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] - lv= h[:lv] || ((defined? o.lv) ? o.lv : nil) #Alpha-numeric, document structure as used in markup, A-C then 1-6 + lv= h[:lv] || ((defined? o.lv) ? o.lv : nil) #Alpha-numeric, document structure as used in markup, A-D then 1-6 ln= h[:ln] || ((defined? o.ln) ? o.ln : nil) #Integer, document structure level, for convenience in processing 1-9 lc= h[:lc] || ((defined? o.lc) ? o.lc : nil) #Integer, document structure collapsed level, convenience (collapse sisu's dual level document structure for markup with simple linear structure) toc_= h[:toc_] || ((defined? o.toc_) ? o.toc_ : false) #Bool, do not include in toc, (relevant to headings) @@ -250,9 +253,10 @@ module SiSU_DAL_DocumentStructure ocn_= if h[:ocn_].nil? then ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider else h[:ocn_] end + num= h[:num] || ((defined? o.num) ? o.num : nil) digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, either sha256 or md5 tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use - @of,@is,@tags,@obj,@idx,@ocn,@odv,@osp,@parent,@number_,@note_,@ocn_,@digest,@tmp=of,is,tags,obj,idx,ocn,odv,osp,parent,number_,note_,ocn_,digest,tmp + @of,@is,@tags,@obj,@idx,@ocn,@odv,@osp,@parent,@number_,@note_,@ocn_,@num,@digest,@tmp=of,is,tags,obj,idx,ocn,odv,osp,parent,number_,note_,ocn_,num,digest,tmp self end def block(h,o=nil) @@ -269,9 +273,10 @@ module SiSU_DAL_DocumentStructure ocn_= if h[:ocn_].nil? then ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider else h[:ocn_] end + num= h[:num] || ((defined? o.num) ? o.num : nil) digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, either sha256 or md5 tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use - @of,@is,@tags,@obj,@idx,@ocn,@odv,@osp,@parent,@note_,@ocn_,@digest,@tmp=of,is,tags,obj,idx,ocn,odv,osp,parent,note_,ocn_,digest,tmp + @of,@is,@tags,@obj,@idx,@ocn,@odv,@osp,@parent,@note_,@ocn_,@num,@digest,@tmp=of,is,tags,obj,idx,ocn,odv,osp,parent,note_,ocn_,num,digest,tmp self end def group(h,o=nil) @@ -288,9 +293,10 @@ module SiSU_DAL_DocumentStructure ocn_= if h[:ocn_].nil? then ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider else h[:ocn_] end + num= h[:num] || ((defined? o.num) ? o.num : nil) digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, either sha256 or md5 tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use - @of,@is,@tags,@obj,@idx,@ocn,@odv,@osp,@parent,@note_,@ocn_,@digest,@tmp=of,is,tags,obj,idx,ocn,odv,osp,parent,note_,ocn_,digest,tmp + @of,@is,@tags,@obj,@idx,@ocn,@odv,@osp,@parent,@note_,@ocn_,@num,@digest,@tmp=of,is,tags,obj,idx,ocn,odv,osp,parent,note_,ocn_,num,digest,tmp self end def alt(h,o=nil) #see block @@ -307,9 +313,10 @@ module SiSU_DAL_DocumentStructure ocn_= if h[:ocn_].nil? then ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider else h[:ocn_] end + num= h[:num] || ((defined? o.num) ? o.num : nil) digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, either sha256 or md5 tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use - @of,@is,@tags,@obj,@idx,@ocn,@odv,@osp,@parent,@note_,@ocn_,@digest,@tmp=of,is,tags,obj,idx,ocn,odv,osp,parent,note_,ocn_,digest,tmp + @of,@is,@tags,@obj,@idx,@ocn,@odv,@osp,@parent,@note_,@ocn_,@num,@digest,@tmp=of,is,tags,obj,idx,ocn,odv,osp,parent,note_,ocn_,num,digest,tmp self end def verse(h,o=nil) #part of poem decide how you deal with this @@ -325,9 +332,10 @@ module SiSU_DAL_DocumentStructure ocn_= if h[:ocn_].nil? then ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider else h[:ocn_] end + num= h[:num] || ((defined? o.num) ? o.num : nil) digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, either sha256 or md5 tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use - @of,@is,@tags,@obj,@idx,@ocn,@odv,@osp,@parent,@note_,@ocn_,@digest,@tmp=of,is,tags,obj,idx,ocn,odv,osp,parent,note_,ocn_,digest,tmp + @of,@is,@tags,@obj,@idx,@ocn,@odv,@osp,@parent,@note_,@ocn_,@num,@digest,@tmp=of,is,tags,obj,idx,ocn,odv,osp,parent,note_,ocn_,num,digest,tmp @h=nil self end @@ -336,7 +344,7 @@ module SiSU_DAL_DocumentStructure 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 - @is=@obj=@lv=@name=@idx=@indent=@hang=@size=@ocn,@number,@head_,@cols,@widths=@odv=@osp=@parent=@note_=@ocn_=@digest=@tmp=nil + @is=@obj=@lv=@name=@idx=@indent=@hang=@size=@ocn,@number,@head_,@cols,@widths=@odv=@osp=@parent=@note_=@ocn_=@num=@digest=@tmp=nil @tags=[] end def table(h,o=nil) @@ -356,9 +364,10 @@ module SiSU_DAL_DocumentStructure ocn_=if h[:ocn_].nil? then ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider else h[:ocn_] end + num= h[:num] || ((defined? o.num) ? o.num : nil) digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, either sha256 or md5 tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use - @of,@is,@tags,@cols,@widths,@obj,@idx,@ocn,@odv,@osp,@parent,@head_,@note_,@ocn_,@digest,@tmp=of,is,tags,cols,widths,obj,idx,ocn,odv,osp,parent,head_,note_,ocn_,digest,tmp + @of,@is,@tags,@cols,@widths,@obj,@idx,@ocn,@odv,@osp,@parent,@head_,@note_,@ocn_,@num,@digest,@tmp=of,is,tags,cols,widths,obj,idx,ocn,odv,osp,parent,head_,note_,ocn_,num,digest,tmp self end end @@ -400,7 +409,7 @@ module SiSU_DAL_DocumentStructure of= @of #String, classification - group 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 + lv= h[:lv] || ((defined? o.lv) ? o.lv : nil) #Alpha-numeric, document structure as used in markup, A-D then 1-6 ln= h[:ln] || ((defined? o.ln) ? o.ln : nil) #Integer, document structure level, for convenience in processing 1-9 lc= h[:lc] || ((defined? o.lc) ? o.lc : nil) #Integer, document structure collapsed level, convenience (collapse sisu's dual level document structure for markup with simple linear structure) node= h[:node] || ((defined? o.node) ? o.node : nil) #[Node relationship doc structure info] diff --git a/lib/sisu/v4/dal_doc_str.rb b/lib/sisu/v6/ao_doc_str.rb index 96e1ac5d..0cdd553b 100644 --- a/lib/sisu/v4/dal_doc_str.rb +++ b/lib/sisu/v6/ao_doc_str.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/dal_doc_str.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/ao_doc_str.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -59,7 +60,7 @@ ** Description: document abstraction =end -module SiSU_DAL_DocumentStructureExtract +module SiSU_AO_DocumentStructureExtract class Instantiate < SiSU_Param::Parameters::Instructions @@flag={ ocn: :on, @@ -89,22 +90,23 @@ module SiSU_DAL_DocumentStructureExtract } def initialize(md,data) @md,@data=md,data - 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]) - @pbl=SiSU_DAL_DocumentStructure::ObjectLayout.new.break(Hx[:br_page_line]) + SiSU_AO_DocumentStructureExtract::Instantiate.new + @pb=SiSU_AO_DocumentStructure::ObjectLayout.new.break(Hx[:br_page]) + @pbn=SiSU_AO_DocumentStructure::ObjectLayout.new.break(Hx[:br_page_new]) + @pbl=SiSU_AO_DocumentStructure::ObjectLayout.new.break(Hx[:br_page_line]) end def ln_get(lv) case lv - when /A/; 1 - when /B/; 2 - when /C/; 3 - when /1/; 4 - when /2/; 5 - when /3/; 6 - when /4/; 7 - when /5/; 8 - when /6/; 9 + when /A/ then 0 + when /B/ then 1 + when /C/ then 2 + when /D/ then 3 + when /1/ then 4 + when /2/ then 5 + when /3/ then 6 + when /4/ then 7 + when /5/ then 8 + when /6/ then 9 end end def image_test(str) @@ -220,7 +222,7 @@ module SiSU_DAL_DocumentStructureExtract def identify_parts tuned_file=[] @tuned_block,@tuned_code=[],[] - @@counter,@verse_count=0,0 + @@counter,@verse_count,@num_code_block,@num_poem,@num_group,@num_block,@num_alt,@num_table=0,0,0,0,0,0,0,0 @metadata={} @data.each do |t_o| if t_o =~/^--([+~-])[#]$/ @@ -238,7 +240,7 @@ module SiSU_DAL_DocumentStructureExtract @@flag[:ocn]=:on {flag: :ocn_on} end - t_o=SiSU_DAL_DocumentStructure::ObjectFlag.new.flag_ocn(h) + t_o=SiSU_AO_DocumentStructure::ObjectFlag.new.flag_ocn(h) next end t_o=t_o.gsub(/(?:\n\s*\n)+/m,"\n") if @@flag[:code]==:off @@ -271,13 +273,13 @@ module SiSU_DAL_DocumentStructureExtract when /^%+\s/ #comment t_o=if t_o=~/^%+\s+(.+)/ h={obj: $1} - SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h) + SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) else nil end - when /^:?([A-C1-6])\~/ #heading / lv + when /^:?([A-D1-6])\~/ #heading / lv lv=$1 ln=ln_get(lv) - t_o=if t_o=~/^:?[A-C1-6]\~\s+(.+)/m + t_o=if t_o=~/^:?[A-D1-6]\~\s+(.+)/m obj=$1 note=endnote_test?(obj) obj,tags=extract_tags(obj) @@ -292,8 +294,8 @@ module SiSU_DAL_DocumentStructureExtract end end h={ lv: lv, ln: ln, obj: obj, idx: idx, tags: tags } - SiSU_DAL_DocumentStructure::ObjectHeading.new.heading(h) - elsif t_o=~/^:?[A-C1-6]\~(\S+?)-\s+(.+)/m + SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h) + elsif t_o=~/^:?[A-D1-6]\~(\S+?)-\s+(.+)/m name,obj=$1,$2 note=endnote_test?(obj) obj,tags=extract_tags(obj) @@ -308,8 +310,8 @@ module SiSU_DAL_DocumentStructureExtract end end h={ lv: lv, name: name, obj: obj, idx: idx, autonum_: false, tags: tags} - SiSU_DAL_DocumentStructure::ObjectHeading.new.heading(h) - elsif t_o=~/^:?[A-C1-6]\~(\S+)\s+(.+)/m + SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h) + elsif t_o=~/^:?[A-D1-6]\~(\S+)\s+(.+)/m name,obj=$1,$2 note=endnote_test?(obj) obj,tags=extract_tags(obj,name) @@ -324,7 +326,7 @@ module SiSU_DAL_DocumentStructureExtract end end h={ lv: lv, name: name, obj: obj, idx: idx, tags: tags } - SiSU_DAL_DocumentStructure::ObjectHeading.new.heading(h) + SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h) else nil end when /^_(?:[1-9]!?|[1-9]?\*)\s+/ #indented and/or bullet paragraph @@ -347,7 +349,7 @@ module SiSU_DAL_DocumentStructureExtract end end h={ bullet_: bullet, hang: hang, indent: indent, obj: obj, idx: idx, note_: note, image_: image, tags: tags } - SiSU_DAL_DocumentStructure::ObjectPara.new.paragraph(h) + SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h) end else nil end @@ -370,18 +372,18 @@ module SiSU_DAL_DocumentStructureExtract end end h={ hang: hang, indent: indent, obj: obj, idx: idx, note_: note, image_: image, tags: tags } - SiSU_DAL_DocumentStructure::ObjectPara.new.paragraph(h) + SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h) end else nil end when /^<(?:br)?:(?:pa?r|o(?:bj|---)?)>\s*$/ #[br:par] #[br:obj] - SiSU_DAL_DocumentStructure::ObjectLayout.new.break(Hx[:br_obj]) + SiSU_AO_DocumentStructure::ObjectLayout.new.break(Hx[:br_obj]) when /^(?:-\\\\-|<:pb>)\s*$/ #[br:pg] - SiSU_DAL_DocumentStructure::ObjectLayout.new.break(Hx[:br_page],:markup) + SiSU_AO_DocumentStructure::ObjectLayout.new.break(Hx[:br_page],:markup) when /^(?:=\\\\=|<:pn>)\s*$/ #[br:pgn] - SiSU_DAL_DocumentStructure::ObjectLayout.new.break(Hx[:br_page_new],:markup) + SiSU_AO_DocumentStructure::ObjectLayout.new.break(Hx[:br_page_new],:markup) when /^-\.\.-\s*$/ #[br:pgl] - SiSU_DAL_DocumentStructure::ObjectLayout.new.break(Hx[:br_page_line],:markup) + SiSU_AO_DocumentStructure::ObjectLayout.new.break(Hx[:br_page_line],:markup) else #paragraph image=image_test(t_o) note=endnote_test?(t_o) @@ -394,59 +396,65 @@ module SiSU_DAL_DocumentStructureExtract end unless obj=~/\A\s*\Z/m h={ bullet_: false, indent: 0, hang: 0, obj: obj, idx: idx, note_: note, image_: image, tags: tags } - SiSU_DAL_DocumentStructure::ObjectPara.new.paragraph(h) + SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h) end end elsif @@flag[:code]==:off if t_o =~/^(?:code\{|[`]{3}\s+code)/ @@flag[:code]=case t_o - when /^code\{/; :curls - when /^[`]{3}\s+code/; :tics + when /^code\{/ then :curls + when /^[`]{3}\s+code/ then :tics else @@flag[:code] #error end @@counter=1 @codeblock_numbered=(t_o =~/^(?:code\{#|[`]{3}\s+code\s[#])/) ? true : false - h={ obj: 'code block start' } #introduce a counter - t_o=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h) + @num_code_block +=1 + h={ obj: "code block start #{@num_code_block}" } + t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) elsif t_o =~/^(?:poem\{|[`]{3}\s+poem)/ @@flag[:poem]=case t_o - when /^poem\{/; :curls - when /^[`]{3}\s+poem/; :tics + when /^poem\{/ then :curls + when /^[`]{3}\s+poem/ then :tics else @@flag[:poem] #error end - h={ obj: 'poem start' } #introduce a counter - t_o=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h) + @num_poem +=1 + h={ obj: "poem start #{@num_poem}" } + t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) tuned_file << t_o elsif t_o =~/^(?:group\{|[`]{3}\s+group)/ @@flag[:group]=case t_o - when /^group\{/; :curls - when /^[`]{3}\s+group/; :tics + when /^group\{/ then :curls + when /^[`]{3}\s+group/ then :tics else @@flag[:group] #error end - h={ obj: 'group text start' } #introduce a counter - t_o=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h) + @num_group +=1 + h={ obj: "group text start #{@num_group}" } + t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) tuned_file << t_o elsif t_o =~/^(?:block\{|[`]{3}\s+block)/ @@flag[:block]=case t_o - when /^block\{/; :curls - when /^[`]{3}\s+block/; :tics + when /^block\{/ then :curls + when /^[`]{3}\s+block/ then :tics else @@flag[:block] #error end - h={ obj: 'block text start' } #introduce a counter - t_o=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h) + @num_block +=1 + h={ obj: "block text start #{@num_block}" } + t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) tuned_file << t_o elsif t_o =~/^(?:alt\{|[`]{3}\s+alt)/ @@flag[:alt]=case t_o - when /^alt\{/; :curls - when /^[`]{3}\s+alt/; :tics + when /^alt\{/ then :curls + when /^[`]{3}\s+alt/ then :tics else @@flag[:alt] #error end - h={ obj: 'alt text start' } #introduce a counter - t_o=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h) + @num_alt +=1 + h={ obj: "alt text start #{@num_alt}" } + t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) tuned_file << t_o elsif t_o =~/^(?:table\{|[`]{3}\s+table|\{table)[ ~]/ - h={ obj: 'table start' } #introduce a counter - ins=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h) + @num_table +=1 + h={ obj: "table start #{@num_table}" } + ins=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) tuned_file << ins if t_o=~/^table\{(?:~h)?\s+/ @@flag[:table]=:curls @@ -499,11 +507,11 @@ module SiSU_DAL_DocumentStructureExtract width=100.00/cols cols.times { col << width } end - h={ head_: hd, cols: cols, widths: col, obj: rows, idx: idx, tags: tags } - t_o=SiSU_DAL_DocumentStructure::ObjectTable.new.table(h) unless h.nil? + h={ head_: hd, cols: cols, widths: col, obj: rows, idx: idx, tags: tags, num: @num_table } + t_o=SiSU_AO_DocumentStructure::ObjectTable.new.table(h) unless h.nil? tuned_file << t_o - h={ obj: 'table end' } #introduce a counter - t_o=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h) + h={ obj: "table end #{@num_table}" } + t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) t_o elsif t_o=~/^[`]{3}\s+table(?:~h)?\s+/ m1,m2,hd=nil,nil,nil @@ -522,11 +530,11 @@ module SiSU_DAL_DocumentStructureExtract 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_DAL_DocumentStructure::ObjectTable.new.table(h) unless h.nil? + h={ head_: hd, cols: col.length, widths: col, obj: rows, idx: idx, tags: tags, num: @num_table } + t_o=SiSU_AO_DocumentStructure::ObjectTable.new.table(h) unless h.nil? tuned_file << t_o - h={ obj: 'table end' } #introduce a counter - t_o=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h) + h={ obj: "table end #{@num_table}" } + t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) t_o elsif t_o=~/^\{table(?:~h)?\s+/ m1,m2,hd=nil,nil,nil @@ -545,11 +553,11 @@ module SiSU_DAL_DocumentStructureExtract 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_DAL_DocumentStructure::ObjectTable.new.table(h) unless h.nil? + h={ head_: hd, cols: col.length, widths: col, obj: rows, idx: idx, tags: tags, num: @num_table } + t_o=SiSU_AO_DocumentStructure::ObjectTable.new.table(h) unless h.nil? tuned_file << t_o - h={ obj: 'table end' } #introduce a counter - t_o=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h) + h={ obj: "table end #{@num_table}" } + t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) t_o end end @@ -563,11 +571,11 @@ module SiSU_DAL_DocumentStructureExtract @@flag[:table]=:off 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_DAL_DocumentStructure::ObjectTable.new.table(@h) + t_o=SiSU_AO_DocumentStructure::ObjectTable.new.table(@h) tuned_file << t_o @h,@rows=nil,'' - h={ obj: 'table end' } #introduce a counter - t_o=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h) + h={ obj: "table end #{@num_table}" } + t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) t_o else if t_o.is_a?(String) \ @@ -585,19 +593,19 @@ module SiSU_DAL_DocumentStructureExtract @@flag[:code]=:off obj=@tuned_code.join("\n") tags=[] - h={ obj: obj, tags: tags, number_: @codeblock_numbered } - t_o=SiSU_DAL_DocumentStructure::ObjectBlockTxt.new.code(h) + h={ obj: obj, tags: tags, num: @num_code_block, number_: @codeblock_numbered } + t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.code(h) @tuned_code=[] tuned_file << t_o - h={ obj: 'code block end' } #introduce a counter - t_o=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h) + h={ obj: "code block end #{@num_code_block}" } + t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) end if (@@flag[:code]==:curls or @@flag[:code]==:tics) \ and t_o.is_a?(String) sub_array=t_o.dup + "#{Mx[:br_nl]}" @line_mode=[] sub_array.scan(/.+/) {|w| @line_mode << w if w =~/[\S]+/} - t_o=SiSU_DAL_DocumentStructureExtract::Build.new(@md,@line_mode).build_lines(:code).join + t_o=SiSU_AO_DocumentStructureExtract::Build.new(@md,@line_mode).build_lines(:code).join @tuned_code << t_o t_o=nil end @@ -608,38 +616,38 @@ module SiSU_DAL_DocumentStructureExtract if (@@flag[:poem]==:curls and t_o =~/^\}poem/) \ or (@@flag[:poem]==:tics and t_o =~/^[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) @@flag[:poem]=:off - h={ obj: 'poem end' } #introduce a counter - t_o=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h) + h={ obj: "poem end #{@num_poem}" } + t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) elsif (@@flag[:group]==:curls and t_o =~/^\}group/) \ or (@@flag[:group]==:tics and t_o =~/^[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) @@flag[:group]=:off obj,tags=extract_tags(@tuned_block.join("\n")) - h={ obj: obj, tags: tags } + h={ obj: obj, tags: tags, num: @num_group } @tuned_block=[] - t_o=SiSU_DAL_DocumentStructure::ObjectBlockTxt.new.group(h) + t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.group(h) tuned_file << t_o - h={ obj: 'group text end' } #introduce a counter - t_o=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h) + h={ obj: "group text end #{@num_group}" } + t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) elsif (@@flag[:block]==:curls and t_o =~/^\}block/) \ or (@@flag[:block]==:tics and t_o =~/^[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) @@flag[:block]=:off obj,tags=extract_tags(@tuned_block.join("\n")) - h={ obj: obj, tags: tags } + h={ obj: obj, tags: tags, num: @num_block } @tuned_block=[] - t_o=SiSU_DAL_DocumentStructure::ObjectBlockTxt.new.block(h) + t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.block(h) tuned_file << t_o - h={ obj: 'block text end' } #introduce a counter - t_o=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h) + h={ obj: "block text end #{@num_block}" } + t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) elsif (@@flag[:alt]==:curls and t_o =~/^\}alt/) \ or (@@flag[:alt]==:tics and t_o =~/^[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) @@flag[:alt]=:off obj,tags=extract_tags(@tuned_block.join("\n")) - h={ obj: obj, tags: tags } - t_o=SiSU_DAL_DocumentStructure::ObjectBlockTxt.new.alt(h) + h={ obj: obj, tags: tags, num: @num_alt } + t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.alt(h) @tuned_block=[] tuned_file << t_o - h={ obj: 'alt text end' } #introduce a counter - t_o=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h) + h={ obj: "alt text end #{@num_alt}" } + t_o=SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) end if (@@flag[:poem]==:curls or @@flag[:poem]==:tics \ or @@flag[:group]==:curls or @@flag[:group]==:tics \ @@ -650,13 +658,13 @@ module SiSU_DAL_DocumentStructureExtract sub_array=t_o.dup @line_mode=sub_array.scan(/.+/) type=if @@flag[:poem]==:curls or @@flag[:poem]==:tics - t_o=SiSU_DAL_DocumentStructureExtract::Build.new(@md,@line_mode).build_lines(type).join + t_o=SiSU_AO_DocumentStructureExtract::Build.new(@md,@line_mode).build_lines(type).join poem=t_o.split(/\n\n/) poem.each do |v| v=v.gsub(/\n/m,"#{Mx[:br_nl]}\n") obj,tags=extract_tags(v) - h={ obj: obj, tags: tags } - t_o=SiSU_DAL_DocumentStructure::ObjectBlockTxt.new.verse(h) + h={ obj: obj, tags: tags, num: @num_poem } + t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.verse(h) tuned_file << t_o end :poem @@ -690,27 +698,27 @@ module SiSU_DAL_DocumentStructureExtract end if @md.flag_endnotes tuned_file << @pb - h={ ln: 2, obj: 'Endnotes', autonum_: false } - tuned_file << SiSU_DAL_DocumentStructure::ObjectHeading.new.heading_insert(h) - h={ ln: 4, obj: 'Endnotes', name: 'endnotes', autonum_: false } - tuned_file << SiSU_DAL_DocumentStructure::ObjectHeading.new.heading_insert(h) + h={ ln: 1, lc: 1, obj: 'Endnotes', autonum_: false } + tuned_file << SiSU_AO_DocumentStructure::ObjectHeading.new.heading_insert(h) + h={ ln: 4, lc: 2, obj: 'Endnotes', name: 'endnotes', autonum_: false } + tuned_file << SiSU_AO_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_DAL_DocumentStructure::ObjectHeading.new.heading_insert(h) - h={ ln: 4, obj: 'Index', name: 'book_index', autonum_: false } - tuned_file << SiSU_DAL_DocumentStructure::ObjectHeading.new.heading_insert(h) + h={ ln: 1, lc: 1, obj: 'Index', autonum_: false } + tuned_file << SiSU_AO_DocumentStructure::ObjectHeading.new.heading_insert(h) + h={ ln: 4, lc: 2, obj: 'Index', name: 'book_index', autonum_: false } + tuned_file << SiSU_AO_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_DAL_DocumentStructure::ObjectHeading.new.heading_insert(h) - h={ ln: 4, obj: 'SiSU Metadata, document information', name: 'metadata', autonum_: false, ocn_: false } - tuned_file << SiSU_DAL_DocumentStructure::ObjectHeading.new.heading_insert(h) + h={ ln: 1, lc: 1, obj: 'Metadata', autonum_: false, ocn_: false } + tuned_file << SiSU_AO_DocumentStructure::ObjectHeading.new.heading_insert(h) + h={ ln: 4, lc: 2, obj: 'SiSU Metadata, document information', name: 'metadata', autonum_: false, ocn_: false } + tuned_file << SiSU_AO_DocumentStructure::ObjectHeading.new.heading_insert(h) h={ obj: 'eof' } - meta=SiSU_DAL_DocumentStructure::ObjectMetadata.new.metadata(@metadata) + meta=SiSU_AO_DocumentStructure::ObjectMetadata.new.metadata(@metadata) [tuned_file,meta] end def table_rows_and_columns_array(table_str) @@ -723,11 +731,11 @@ module SiSU_DAL_DocumentStructureExtract end def meta_heading(h) h={ lv: h[:lv], ln: h[:ln], name: h[:name], obj: h[:obj], ocn: '0' } - SiSU_DAL_DocumentStructure::ObjectHeading.new.heading(h) + SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h) end def meta_para(str) h={ obj: str, ocn_: false } - SiSU_DAL_DocumentStructure::ObjectPara.new.paragraph(h) + SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h) end def build_lines(type=:none) lines,lines_new=@data,[] @@ -767,24 +775,27 @@ module SiSU_DAL_DocumentStructureExtract || (@dob.hang != @dob.indent)) \ and not @dob.bullet_ @dob=case @dob.obj + when /^#{@md.lv0}/ + h={ lv: 'A', ln: 0 } + SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,@dob) when /^#{@md.lv1}/ - h={ lv: 'A', ln: 1 } - SiSU_DAL_DocumentStructure::ObjectHeading.new.heading(h,@dob) + h={ lv: 'B', ln: 1 } + SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,@dob) when /^#{@md.lv2}/ - h={ lv: 'B', ln: 2 } - SiSU_DAL_DocumentStructure::ObjectHeading.new.heading(h,@dob) + h={ lv: 'C', ln: 2 } + SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,@dob) when /^#{@md.lv3}/ - h={ lv: 'C', ln: 3 } - SiSU_DAL_DocumentStructure::ObjectHeading.new.heading(h,@dob) + h={ lv: 'D', ln: 3 } + SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,@dob) when /^#{@md.lv4}/ h={ lv: '1', ln: 4 } - SiSU_DAL_DocumentStructure::ObjectHeading.new.heading(h,@dob) + SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,@dob) when /^#{@md.lv5}/ h={ lv: '2', ln: 5 } - SiSU_DAL_DocumentStructure::ObjectHeading.new.heading(h,@dob) + SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,@dob) when /^#{@md.lv6}/ h={ lv: '3', ln: 6 } - SiSU_DAL_DocumentStructure::ObjectHeading.new.heading(h,@dob) + SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,@dob) else @dob end else @dob @@ -798,38 +809,28 @@ module SiSU_DAL_DocumentStructureExtract end def structure_info def lv - %w[0 A~ B~ C~ 1 2 3] + %w[A~ B~ C~ D~ 1 2 3] end def possible_parents(child) case child - when /A~/ - 'none' - when /B~/ - 'A~' - when /C~/ - 'B~' - when /1/ - 'A~, B~, C~' - when /2/ - '1' - when /3/ - '2' + when /A~/ then 'none' + when /B~/ then 'A~' + when /C~/ then 'B~' + when /D~/ then 'C~' + when /1/ then 'A~, B~, C~, D~' + when /2/ then '1' + when /3/ then '2' end end def possible_children(parent) case parent - when /A~/ - 'B~, 1' - when /B~/ - 'C~, 1' - when /C~/ - '1' - when /1/ - '2' - when /2/ - '3' - when /3/ - 'none' + when /A~/ then 'B~, 1' + when /B~/ then 'C~, 1' + when /C~/ then 'D~, 1' + when /D~/ then '1' + when /1/ then '2' + when /2/ then '3' + when /3/ then 'none' end end self @@ -857,227 +858,310 @@ has incorrect level and/or parent level} def ocn #and auto segment numbering increment data=@data @o_array=[] - node=ocn=ocn_dv=ocn_sp=ocnh=ocnh1=ocnh2=ocnh3=ocnh4=ocnh5=ocnh6=ocno=ocnp=ocnt=ocnc=ocng=ocni=ocnu=0 # h heading, o other, t table, g group, i image + node=ocn=ocn_dv=ocn_sp=ocnh=ocnh0=ocnh1=ocnh2=ocnh3=ocnh4=ocnh5=ocnh6=ocno=ocnp=ocnt=ocnc=ocng=ocni=ocnu=0 # h heading, o other, t table, g group, i image regex_exclude_ocn_and_node = /#{Rx[:meta]}|^@\S+?:\s|^4~endnotes|^#{Mx[:lv_o]}4:endnotes#{Mx[:lv_c]}|^\^~ |<:e[:_]\d+?>|^<:\#|<:- |<[:!]!4|<hr width|#{Mx[:br_endnotes]}|\A\s*\Z/mi #ocn here # added with Tune.code #¡ parent=node1=node2=node3=node4=node5=node6=nil node0='0:0;0' - @collapsed_lv1=1 + @collapsed_lv0=0 data.each do |dob| h={} 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 ln=case dob.lv - when 'A'; 1 - when 'B'; 2 - when 'C'; 3 - when '1'; 4 - when '2'; 5 - when '3'; 6 - when '4'; 7 - when '5'; 8 - when '6'; 9 + when 'A' then 0 + when 'B' then 1 + when 'C' then 2 + when 'D' then 3 + when '1' then 4 + when '2' then 5 + when '3' then 6 + when '4' then 7 + when '5' then 8 + when '6' then 9 end end - if not dob.obj =~/<:#>|~#|-#/ \ - or not dob.toc_ # fix this no longer in dob.obj + if not dob.obj =~/~#|-#/ ocn+=1 - if dob.is==:heading \ - and (ln.to_s =~/^[1-9]/ \ - or ln.to_s =~@md.lv1 \ - or ln.to_s =~@md.lv2 \ - or ln.to_s =~@md.lv3 \ - or ln.to_s =~@md.lv4 \ - or ln.to_s =~@md.lv5 \ - or ln.to_s =~@md.lv6) + end + if dob.is==:heading \ + and (ln.to_s =~/^[0-9]/ \ + or ln.to_s =~@md.lv0 \ + or ln.to_s =~@md.lv1 \ + or ln.to_s =~@md.lv2 \ + or ln.to_s =~@md.lv3 \ + or ln.to_s =~@md.lv4 \ + or ln.to_s =~@md.lv5 \ + or ln.to_s =~@md.lv6) + if not dob.obj =~/~#|-#/ ocnh+=1 - if ln==1 \ - or ln=~@md.lv1; ocnh1+=1 #heading + end + if ln==0 \ + or ln=~@md.lv0 + if not dob.obj =~/~#|-#/ + ocn_flag=true + ocnh0+=1 #heading + node0="0:#{ocnh0};#{ocn}" + else + ocn_flag=false + node0="0:0;0" + end + document_structure_check_info(node0,node0) + @collapsed_lv0=0 + collapsed_level=@collapsed_lv0 + node,ocn_sp,parent=node0,"h#{ocnh}",'ROOT' + elsif ln==1 \ + or ln=~@md.lv1 + if not dob.obj =~/~#|-#/ + ocn_flag=true + ocnh1+=1 #heading node1="1:#{ocnh1};#{ocn}" + else + ocn_flag=false + node1="1:0;0" + end + parent=if node0 document_structure_check_info(node1,node0) - @collapsed_lv1=1 - collapsed_level=@collapsed_lv1 - node,ocn_sp,parent=node1,"h#{ocnh}",node0 #FIX - elsif ln==2 \ - or ln=~@md.lv2; ocnh2+=1 + @collapsed_lv1=@collapsed_lv0+1 + node0 + else + document_structure_check_info(node0,node0,:error) + node0 + end + collapsed_level=@collapsed_lv1 + node,ocn_sp,parent=node1,"h#{ocnh}",node0 #FIX + elsif ln==2 \ + or ln=~@md.lv2 + if not dob.obj =~/~#|-#/ + ocn_flag=true + ocnh2+=1 node2="2:#{ocnh2};#{ocn}" - parent=if node1 - document_structure_check_info(node2,node1) - @collapsed_lv2=@collapsed_lv1+1 - node1 - else - document_structure_check_info(node2,node0,:error) - node0 - end - collapsed_level=@collapsed_lv2 - node,ocn_sp=node2,"h#{ocnh}" - elsif ln==3 \ - or ln=~@md.lv3; ocnh3+=1 + else + ocn_flag=false + node2="2:0;0" + end + parent=if node1 + document_structure_check_info(node2,node1) + @collapsed_lv2=@collapsed_lv1+1 + node1 + else + document_structure_check_info(node2,node0,:error) + node0 + end + collapsed_level=@collapsed_lv2 + node,ocn_sp=node2,"h#{ocnh}" + elsif ln==3 \ + or ln=~@md.lv3 + if not dob.obj =~/~#|-#/ + ocn_flag=true + ocnh3+=1 node3="3:#{ocnh3};#{ocn}" - parent=if node2 - document_structure_check_info(node3,node2) - @collapsed_lv3=@collapsed_lv2+1 - node2 - elsif node1 - warning_incorrect_parent_level_or_level(dob.obj) - puts %{parent is :A~ & this level #{dob.lv} + else + ocn_flag=false + node3="3:0;0" + end + parent=if node2 + document_structure_check_info(node3,node2) + @collapsed_lv3=@collapsed_lv2+1 + node2 + elsif node1 + warning_incorrect_parent_level_or_level(dob.obj) + puts %{parent is :A~ & this level #{dob.lv} either parent should be level :B~ or this level should be level :B~ rather than #{dob.lv}} - document_structure_check_info(node3,node1,:error) - @collapsed_lv3=@collapsed_lv1+1 - node1 - else - document_structure_check_info(node3,node0,:error) - warning_incorrect_parent_level_or_level(dob.obj) - node0 - end - collapsed_level=@collapsed_lv3 - node,ocn_sp=node3,"h#{ocnh}" - elsif ln==4 \ - or ln=~@md.lv4; ocnh4+=1 + document_structure_check_info(node3,node1,:error) + @collapsed_lv3=@collapsed_lv1+1 + node1 + else + document_structure_check_info(node3,node0,:error) + warning_incorrect_parent_level_or_level(dob.obj) + node0 + end + collapsed_level=@collapsed_lv3 + node,ocn_sp=node3,"h#{ocnh}" + elsif ln==4 \ + or ln=~@md.lv4 + if not dob.obj =~/~#|-#/ + ocn_flag=true + ocnh4+=1 node4="4:#{ocnh4};#{ocn}" - parent=if node3 - document_structure_check_info(node4,node3) - @collapsed_lv4=@collapsed_lv3+1 - node3 - elsif node2 - document_structure_check_info(node4,node2) - @collapsed_lv4=@collapsed_lv2+1 - node2 - elsif node1 - document_structure_check_info(node4,node1) - @collapsed_lv4=@collapsed_lv1+1 - node1 - else - warning_incorrect_parent_level_or_level(dob.obj) - document_structure_check_info(node4,node0,:error) - node0 - end - collapsed_level=@collapsed_lv4 - node,ocn_sp=node4,"h#{ocnh}" - elsif ln==5 \ - or ln=~@md.lv5; ocnh5+=1 + else + ocn_flag=false + node4="4:0;0" + end + parent=if node3 + document_structure_check_info(node4,node3) + @collapsed_lv4=@collapsed_lv3+1 + node3 + elsif node2 + document_structure_check_info(node4,node2) + @collapsed_lv4=@collapsed_lv2+1 + node2 + elsif node1 + document_structure_check_info(node4,node1) + @collapsed_lv4=@collapsed_lv1+1 + node1 + elsif node0 + document_structure_check_info(node4,node0) + @collapsed_lv4=@collapsed_lv0+1 + node0 + else + warning_incorrect_parent_level_or_level(dob.obj) + document_structure_check_info(node4,node0,:error) + node0 + end + collapsed_level=@collapsed_lv4 + node,ocn_sp=node4,"h#{ocnh}" + elsif ln==5 \ + or ln=~@md.lv5 + if not dob.obj =~/~#|-#/ + ocn_flag=true + ocnh5+=1 node5="5:#{ocnh5};#{ocn}" - parent=if node4 - document_structure_check_info(node5,node4) - @collapsed_lv5=@collapsed_lv4+1 - node4 - elsif node3 - warning_incorrect_parent_level_or_level(dob.obj) - document_structure_check_info(node5,node3,:error) - @collapsed_lv5=@collapsed_lv3+1 - node3 - elsif node2 - warning_incorrect_parent_level_or_level(dob.obj) - document_structure_check_info(node5,node2,:error) - @collapsed_lv5=@collapsed_lv2+1 - node2 - elsif node1 - warning_incorrect_parent_level_or_level(dob.obj) - document_structure_check_info(node5,node1,:error) - @collapsed_lv5=@collapsed_lv1+1 - node1 - else - document_structure_check_info(node5,node0,:error) - node0 - end - collapsed_level=@collapsed_lv5 - node,ocn_sp=node5,"h#{ocnh}" - elsif ln==6 \ - or ln=~@md.lv6; ocnh6+=1 + else + ocn_flag=false + node5="5:0;0" + end + parent=if node4 + document_structure_check_info(node5,node4) + @collapsed_lv5=@collapsed_lv4+1 + node4 + elsif node3 + warning_incorrect_parent_level_or_level(dob.obj) + document_structure_check_info(node5,node3,:error) + @collapsed_lv5=@collapsed_lv3+1 + node3 + elsif node2 + warning_incorrect_parent_level_or_level(dob.obj) + document_structure_check_info(node5,node2,:error) + @collapsed_lv5=@collapsed_lv2+1 + node2 + elsif node1 + warning_incorrect_parent_level_or_level(dob.obj) + document_structure_check_info(node5,node1,:error) + @collapsed_lv5=@collapsed_lv1+1 + node1 + else + document_structure_check_info(node5,node0,:error) + node0 + end + collapsed_level=@collapsed_lv5 + node,ocn_sp=node5,"h#{ocnh}" + elsif ln==6 \ + or ln=~@md.lv6 + if not dob.obj =~/~#|-#/ + ocn_flag=true + ocnh6+=1 node6="6:#{ocnh6};#{ocn}" - parent=if node5 - document_structure_check_info(node6,node5) - @collapsed_lv6=@collapsed_lv5+1 - node5 - elsif node4 - warning_incorrect_parent_level_or_level(dob.obj) - puts "parent is level 4~ & this level #{dob.lv} + else + ocn_flag=false + node6="6:0;0" + end + parent=if node5 + document_structure_check_info(node6,node5) + @collapsed_lv6=@collapsed_lv5+1 + node5 + elsif node4 + warning_incorrect_parent_level_or_level(dob.obj) + puts "parent is level 4~ & this level #{dob.lv} either parent should be level 5~ or this level should be 5~ rather #{dob.lv}" #level 6 - document_structure_check_info(node6,node4,:error) - @collapsed_lv6=@collapsed_lv4+1 - node4 - elsif node3 - warning_incorrect_parent_level_or_level(dob.obj) - document_structure_check_info(node6,node3,:error) - @collapsed_lv6=@collapsed_lv3+1 - node3 - elsif node2 - warning_incorrect_parent_level_or_level(dob.obj) - document_structure_check_info(node6,node2,:error) - @collapsed_lv6=@collapsed_lv2+1 - node2 - elsif node1 - warning_incorrect_parent_level_or_level(dob.obj) - document_structure_check_info(node6,node1,:error) - @collapsed_lv6=@collapsed_lv1+1 - node1 - else - document_structure_check_info(node6,node0,:error) - node0 - end - collapsed_level=@collapsed_lv6 - node,ocn_sp=node6,"h#{ocnh}" + document_structure_check_info(node6,node4,:error) + @collapsed_lv6=@collapsed_lv4+1 + node4 + elsif node3 + warning_incorrect_parent_level_or_level(dob.obj) + document_structure_check_info(node6,node3,:error) + @collapsed_lv6=@collapsed_lv3+1 + node3 + elsif node2 + warning_incorrect_parent_level_or_level(dob.obj) + document_structure_check_info(node6,node2,:error) + @collapsed_lv6=@collapsed_lv2+1 + node2 + elsif node1 + warning_incorrect_parent_level_or_level(dob.obj) + document_structure_check_info(node6,node1,:error) + @collapsed_lv6=@collapsed_lv1+1 + node1 + else + document_structure_check_info(node6,node0,:error) + node0 end + collapsed_level=@collapsed_lv6 + node,ocn_sp=node6,"h#{ocnh}" + end + else + if not dob.obj =~/~#|-#/ + ocn_flag=true else - ocno+=1 - if dob.is==:table - ocnt+=1 - ocn_sp,parent="t#{ocnt}",node - elsif dob.is==:code - ocnc+=1 - ocn_sp,parent="c#{ocnc}",node - 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 #check - ocni+=1 - ocn_sp,parent="i#{ocni}",node - else ocnp+=1 #paragraph - ocn_sp,parent="p#{ocnp}",node - end + ocn_flag=false + end + ocno+=1 + if dob.is==:table + ocnt+=1 + ocn_sp,parent="t#{ocnt}",node + elsif dob.is==:code + ocnc+=1 + ocn_sp,parent="c#{ocnc}",node + 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 #check + ocni+=1 + ocn_sp,parent="i#{ocni}",node + else ocnp+=1 #paragraph + ocn_sp,parent="p#{ocnp}",node end - if dob.is==:heading - dob.ln,dob.node,dob.ocn,dob.odv,dob.osp,dob.parent,dob.lc=ln,node,ocn,ocn_dv,ocn_sp,parent,collapsed_level + end + if dob.is==:heading + if ocn_flag==true + dob.ln,dob.node,dob.ocn,dob.ocn_,dob.odv,dob.osp,dob.parent,dob.lc=ln,node,ocn,ocn_flag,ocn_dv,ocn_sp,parent,collapsed_level else - if dob.of !=:meta \ - && dob.of !=:comment \ - && dob.of !=:layout - dob.ocn,dob.odv,dob.osp,dob.parent=ocn,ocn_dv,ocn_sp,parent + ocnu+=1 + dob.obj=dob.obj.gsub(/#{Mx[:fa_o]}[~-]##{Mx[:fa_c]}/,'') if dob.obj + ocn_dv,ocn_sp="u#{ocnu}","u#{ocnu}" + dob.ln,dob.node,dob.ocn,dob.ocn_,dob.odv,dob.osp,dob.parent,dob.lc=ln,node,nil,ocn_flag,ocn_dv,ocn_sp,parent,collapsed_level + end + else + if dob.of !=:meta \ + && dob.of !=:comment \ + && dob.of !=:layout + if ocn_flag == true + dob.ocn,dob.ocn_,dob.odv,dob.osp,dob.parent=ocn,ocn_flag,ocn_dv,ocn_sp,parent + else + ocnu+=1 + 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.ocn_,dob.odv,dob.osp,dob.parent=nil,ocn_flag,ocn_dv,ocn_sp,parent end end - else ocnu+=1 - 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=dob.obj.gsub(/#{Mx[:pa_non_object_no_heading]}/,'') if dob.is==:para h={ obj: dob.obj, ocn_: false, ocn: nil, hang: dob.hang, indent: dob.indent, bullet_: dob.bullet_, tags: dob.tags, parent: dob.parent } - dob=SiSU_DAL_DocumentStructure::ObjectPara.new.paragraph(h,dob) + dob=SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h,dob) elsif dob.is==:heading h={ obj: dob.obj, ocn_: false, ocn: nil, toc_: true, parent: dob.parent } - dob=SiSU_DAL_DocumentStructure::ObjectHeading.new.heading(h,dob) + dob=SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,dob) end elsif dob.obj=~/#{Mx[:pa_non_object_dummy_heading]}/ dob.obj=dob.obj.gsub(/#{Mx[:pa_non_object_dummy_heading]}/,'') if dob.is==:para h={ obj: dob.obj, ocn_: false, ocn: nil, hang: dob.hang, indent: dob.indent, bullet_: dob.bullet_, tags: dob.tags, parent: dob.parent } - dob=SiSU_DAL_DocumentStructure::ObjectPara.new.paragraph(h,dob) + dob=SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h,dob) elsif dob.is==:heading h={ obj: dob.obj, ocn_: false, ocn: nil, toc_: false, parent: dob.parent } - dob=SiSU_DAL_DocumentStructure::ObjectHeading.new.heading(h,dob) + dob=SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,dob) end else dob end @@ -1098,10 +1182,11 @@ or this level should be 5~ rather #{dob.lv}" #level 6 @data,@md=data,md end def dom - @s=['0', + @s=[ 'A', 'B', 'C', + 'D', '1', '2', '3' @@ -1116,7 +1201,7 @@ or this level should be 5~ rather #{dob.lv}" #level 6 hs=[0,false,false,false] t={ lv: @s[0], status: 'open' } tuned_file << tags(t) - if @md.opt.cmd =~/V/ + if @md.opt.act[:verbose_plus][:set]==:on puts "\nXML sisu structure outline --->\n" puts "<#{@s[0]}>" end @@ -1124,34 +1209,42 @@ or this level should be 5~ rather #{dob.lv}" #level 6 if o.is==:heading \ || o.is==:heading_insert case o.ln + when 0 + tuned_file << tag_close(o.ln,hs) + tuned_file << tag_open(o,@s) + if @md.opt.act[:verbose_plus][:set]==:on + puts_tag_close(o.ln,hs) + puts_tag_open(o,@s) + end + hs=[0,true,false,false,false] when 1 tuned_file << tag_close(o.ln,hs) tuned_file << tag_open(o,@s) - if @md.opt.cmd =~/V/ + if @md.opt.act[:verbose_plus][:set]==:on puts_tag_close(o.ln,hs) puts_tag_open(o,@s) end - hs=[1,true,false,false] + hs=[1,true,true,false,false] when 2 tuned_file << tag_close(o.ln,hs) tuned_file << tag_open(o,@s) - if @md.opt.cmd =~/V/ + if @md.opt.act[:verbose_plus][:set]==:on puts_tag_close(o.ln,hs) puts_tag_open(o,@s) end - hs=[2,true,true,false] + hs=[2,true,true,true,false] when 3 tuned_file << tag_close(o.ln,hs) tuned_file << tag_open(o,@s) - if @md.opt.cmd =~/V/ + if @md.opt.act[:verbose_plus][:set]==:on puts_tag_close(o.ln,hs) puts_tag_open(o,@s) end - hs=[3,true,true,true] + hs=[3,true,true,true,true] when 4 tuned_file << tag_close(o.ln,hs) tuned_file << tag_open(o,@s) - if @md.opt.cmd =~/V/ + if @md.opt.act[:verbose_plus][:set]==:on puts_tag_close(o.ln,hs) puts_tag_open(o,@s) end @@ -1159,7 +1252,7 @@ or this level should be 5~ rather #{dob.lv}" #level 6 when 5 tuned_file << tag_close(o.ln,hs) tuned_file << tag_open(o,@s) - if @md.opt.cmd =~/V/ + if @md.opt.act[:verbose_plus][:set]==:on puts_tag_close(o.ln,hs) puts_tag_open(o,@s) end @@ -1167,7 +1260,7 @@ or this level should be 5~ rather #{dob.lv}" #level 6 when 6 tuned_file << tag_close(o.ln,hs) tuned_file << tag_open(o,@s) - if @md.opt.cmd =~/V/ + if @md.opt.act[:verbose_plus][:set]==:on puts_tag_close(o.ln,hs) puts_tag_open(o,@s) end @@ -1176,7 +1269,9 @@ or this level should be 5~ rather #{dob.lv}" #level 6 end tuned_file << o end - puts_tag_close(0,hs) if @md.opt.cmd =~/V/ + if @md.opt.act[:verbose_plus][:set]==:on + puts_tag_close(0,hs) + end tuned_file << tag_close(0,hs) tuned_file=tuned_file.flatten end @@ -1185,18 +1280,19 @@ or this level should be 5~ rather #{dob.lv}" #level 6 ? %{<#{o[:lv]} id="#{o[:node]}">} : "</#{o[:lv]}>" ln=case o[:lv] - when 'A'; 1 - when 'B'; 2 - when 'C'; 3 - when '1'; 4 - when '2'; 5 - when '3'; 6 - when '4'; 7 - when '5'; 8 - when '6'; 9 + when 'A' then 0 + when 'B' then 1 + when 'C' then 2 + when 'D' then 3 + when '1' then 4 + when '2' then 5 + when '3' then 6 + when '4' then 7 + when '5' then 8 + when '6' then 9 end h={ tag: tag, node: o[:node], lv: o[:lv], ln: ln, status: o[:status] } - SiSU_DAL_DocumentStructure::ObjectStructure.new.xml_dom(h) #downstream code utilise else ignore like comments + SiSU_AO_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' } @@ -1206,6 +1302,11 @@ or this level should be 5~ rather #{dob.lv}" #level 6 def tag_close(lev,hs) ary=[] case hs[0] + when 0 + if (lev <= 0) and hs[0] + t={ lv: @s[0], status: 'close' } + ary << tags(t) + end when 1 if (lev <= 1) and hs[1] t={ lv: @s[1], status: 'close' } @@ -1328,6 +1429,9 @@ or this level should be 5~ rather #{dob.lv}" #level 6 end def puts_tag_close(lev,hs) case hs[0] + when 0 + #puts "#{@sp*0}</#{@s[0]}>" if (lev <= 0) and hs[0] + puts "</#{@s[0]}>" if (lev==0) when 1 puts "#{@sp*1}</#{@s[1]}>" if (lev <= 1) and hs[1] puts "</#{@s[0]}>" if (lev==0) diff --git a/lib/sisu/v4/dal_endnotes.rb b/lib/sisu/v6/ao_endnotes.rb index a32d02f7..21509098 100644 --- a/lib/sisu/v4/dal_endnotes.rb +++ b/lib/sisu/v6/ao_endnotes.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/dal_doc_endnotes.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/ao_doc_endnotes.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -59,7 +60,7 @@ ** Description: system environment, resource control and configuration details =end -module SiSU_DAL_Endnotes +module SiSU_AO_Endnotes class Endnotes def initialize(md,data,endnote_array=nil) @md,@data,@endnote_array=md,data,endnote_array @@ -82,7 +83,7 @@ module SiSU_DAL_Endnotes && 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=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') word_mode=dob.obj.scan(/\S+/m) word_mode=endnote_call_number(word_mode) dob.obj=word_mode.join(' ') diff --git a/lib/sisu/v4/dal_expand_insertions.rb b/lib/sisu/v6/ao_expand_insertions.rb index be258417..65386c48 100644 --- a/lib/sisu/v4/dal_expand_insertions.rb +++ b/lib/sisu/v6/ao_expand_insertions.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/dal_expand_insertions.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/ao_expand_insertions.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -59,7 +60,7 @@ ** Description: system environment, resource control and configuration details =end -module SiSU_DAL_Insertions +module SiSU_AO_Insertions class Insertions def initialize(md,data) @md,@data=md,data @@ -67,12 +68,12 @@ module SiSU_DAL_Insertions 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::InfoProcessingFlag.new cmd_list=case cmd_shortcut.inspect - when /0/; cf_defaults.cf_0 - when /1/; cf_defaults.cf_1 - when /2/; cf_defaults.cf_2 - when /3/; cf_defaults.cf_3 - when /4/; cf_defaults.cf_4 - when /5/; cf_defaults.cf_5 + when /0/ then cf_defaults.cf_0 + when /1/ then cf_defaults.cf_1 + when /2/ then cf_defaults.cf_2 + when /3/ then cf_defaults.cf_3 + when /4/ then cf_defaults.cf_4 + when /5/ then cf_defaults.cf_5 end file_type_names={} file_type_names[:gen],file_type_names[:src]=[],[] diff --git a/lib/sisu/v4/dal_hash_digest.rb b/lib/sisu/v6/ao_hash_digest.rb index 9c3f2d14..b2fd8bfd 100644 --- a/lib/sisu/v4/dal_hash_digest.rb +++ b/lib/sisu/v6/ao_hash_digest.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/dal_hash_digest.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/ao_hash_digest.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -59,7 +60,7 @@ ** Description: system environment, resource control and configuration details =end -module SiSU_DAL_Hash +module SiSU_AO_Hash require_relative 'shared_markup_alt.rb' #shared_markup_alt.rb class ObjectDigest def initialize(md,data,env=nil) @@ -96,7 +97,7 @@ module SiSU_DAL_Hash end end @tuned_file=@tuned_file.flatten - #use md5 or to create hash of each dal object including ocn, & add into to each dal object + #use md5 or to create hash of each ao object including ocn, & add into to each ao object end def endnote_digest(data) t_o_bit=[] @@ -143,7 +144,7 @@ module SiSU_DAL_Hash end t_o #KEEP intact end - def strip_clean_extra_spaces(s) # dal output tuned + def strip_clean_extra_spaces(s) # ao output tuned s=s.dup s=s.gsub(/[ ]+([,.;:?](?:$|\s))/,'\1') unless s =~/#{Mx[:en_a_o]}|#{Mx[:en_b_o]}/ s=s.gsub(/ [ ]+/,' '). diff --git a/lib/sisu/v4/dal_idx.rb b/lib/sisu/v6/ao_idx.rb index 5fbfe5df..cd6ab26f 100644 --- a/lib/sisu/v4/dal_idx.rb +++ b/lib/sisu/v6/ao_idx.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/dal_idx.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/ao_idx.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -59,7 +60,7 @@ ** Description: system environment, resource control and configuration details =end -module SiSU_DAL_BookIndex +module SiSU_AO_BookIndex class BookIndex def initialize(md,data,env=nil) @md,@data,@env=md,data,env @@ -138,15 +139,15 @@ module SiSU_DAL_BookIndex idx={} idx[:sst_rel_html_seg],idx[:sst_rel],idx[:html],idx[:xhtml]=[],[],[],[] h={obj: Mx[:br_page]} - o=SiSU_DAL_DocumentStructure::ObjectLayout.new.break(h) + o=SiSU_AO_DocumentStructure::ObjectLayout.new.break(h) idx[:sst_rel_html_seg] << o idx[:sst_rel] << o - h={lv: '2', name: 'index', obj: "Index"} - o=SiSU_DAL_DocumentStructure::ObjectHeading.new.heading(h) + h={lv: '1', name: 'index', obj: "Index"} + o=SiSU_AO_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_DAL_DocumentStructure::ObjectHeading.new.heading(h) + o=SiSU_AO_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] @@ -190,7 +191,7 @@ module SiSU_DAL_BookIndex @t=idx[:sst_rel].index(idx[:sst_rel].last) @q=idx[:html].index(idx[:html].last) @r=idx[:xhtml].index(idx[:xhtml].last) - print "\n" + x + ', ' if @md.opt.cmd =~/V/ + print "\n" + x + ', ' if @md.opt.act[:verbose_plus][:set]==:on elsif x.is_a?(Array) p 'array error? -->' print x @@ -202,13 +203,13 @@ module SiSU_DAL_BookIndex idx[:sst_rel][@t]=idx[:sst_rel][@t] + %{#{Mx[:lnk_o]}#{a[:range]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{a[:ocn]}#{Mx[:rel_c]}, } idx[:html][@q]=idx[:html][@q] + %{<a href="#{a[:seg]}.html##{a[:ocn]}">#{a[:range]}</a>, } idx[:xhtml][@q]=idx[:xhtml][@q] + %{<a href="#{a[:seg]}.xhtml#o#{a[:ocn]}">#{a[:range]}</a>, } - print a[:range] + ', ' if @md.opt.cmd =~/V/ + print a[:range] + ', ' if @md.opt.act[:verbose_plus][:set]==:on elsif a[:ocn] idx[:sst_rel_html_seg][@o]=idx[:sst_rel_html_seg][@o] + %{#{Mx[:lnk_o]}#{a[:ocn]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{a[:seg]}.html##{a[:ocn]}#{Mx[:rel_c]}, } idx[:sst_rel][@t]=idx[:sst_rel][@t] + %{#{Mx[:lnk_o]}#{a[:ocn]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{a[:ocn]}#{Mx[:rel_c]}, } idx[:html][@q]=idx[:html][@q] + %{<a href="#{a[:seg]}.html##{a[:ocn]}">#{a[:ocn]}</a>, } idx[:xhtml][@q]=idx[:xhtml][@q] + %{<a href="#{a[:seg]}.xhtml#o#{a[:ocn]}">#{a[:ocn]}</a>, } - print a[:ocn] + ', ' if @md.opt.cmd =~/V/ + print a[:ocn] + ', ' if @md.opt.act[:verbose_plus][:set]==:on else p 'error' end end @@ -223,20 +224,20 @@ module SiSU_DAL_BookIndex idx[:html][@q]=idx[:html][@q] + %{\n<p class="book_index_lev2">#{k}, } c=clean_xml(k.dup) idx[:xhtml][@r]=idx[:xhtml][@r] + %{\n<p class="book_index_lev2">#{c}, } - print "\n\t" + k + ', ' if @md.opt.cmd =~/V/ + print "\n\t" + k + ', ' if @md.opt.act[:verbose_plus][:set]==:on y.each do |z| if z[:range] idx[:sst_rel_html_seg][@o]=idx[:sst_rel_html_seg][@o] + %{#{Mx[:lnk_o]}#{z[:range]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{z[:seg]}.html##{z[:ocn]}#{Mx[:rel_c]}, } idx[:sst_rel][@t]=idx[:sst_rel][@t] + %{#{Mx[:lnk_o]}#{z[:range]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{z[:ocn]}#{Mx[:rel_c]}, } idx[:html][@q]=idx[:html][@q] + %{<a href="#{z[:seg]}.html##{z[:ocn]}">#{z[:range]}</a>, } idx[:xhtml][@q]=idx[:xhtml][@q] + %{<a href="#{z[:seg]}.xhtml#o#{z[:ocn]}">#{z[:range]}</a>, } - print z[:range] + ', ' if @md.opt.cmd =~/V/ + print z[:range] + ', ' if @md.opt.act[:verbose_plus][:set]==:on elsif z[:ocn] idx[:sst_rel_html_seg][@o]=idx[:sst_rel_html_seg][@o] + %{#{Mx[:lnk_o]}#{z[:ocn]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{z[:seg]}.html##{z[:ocn]}#{Mx[:rel_c]}, } idx[:sst_rel][@t]=idx[:sst_rel][@t] + %{#{Mx[:lnk_o]}#{z[:ocn]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{z[:ocn]}#{Mx[:rel_c]}, } idx[:html][@q]=idx[:html][@q] + %{<a href="#{z[:seg]}.html##{z[:ocn]}">#{z[:ocn]}</a>, } idx[:xhtml][@q]=idx[:xhtml][@q] + %{<a href="#{z[:seg]}.xhtml#o#{z[:ocn]}">#{z[:ocn]}</a>, } - print z[:ocn] + ', ' if @md.opt.cmd =~/V/ + print z[:ocn] + ', ' if @md.opt.act[:verbose_plus][:set]==:on else p 'error' end end @@ -249,7 +250,7 @@ module SiSU_DAL_BookIndex end end end - print "\n" if @md.opt.cmd =~/V/ + print "\n" if @md.opt.act[:verbose_plus][:set]==:on idx end def screen_print(the_idx) diff --git a/lib/sisu/v4/dal_images.rb b/lib/sisu/v6/ao_images.rb index 3d445b1e..76721d63 100644 --- a/lib/sisu/v4/dal_images.rb +++ b/lib/sisu/v6/ao_images.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/dal_images.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/ao_images.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -59,7 +60,7 @@ ** Description: system environment, resource control and configuration details =end -module SiSU_DAL_Images +module SiSU_AO_Images class Images #require 'RMagick' #include Magick @@ -78,8 +79,10 @@ module SiSU_DAL_Images @rmgk=false end else - if @md.opt.cmd =~/[vVM]/ - SiSU_Screen::Ansi.new(@md.opt.cmd,'*WARN* use of RMagick is not enabled in sisurc.yml').warn + if (@md.opt.act[:verbose][:set]==:on \ + || @md.opt.act[:verbose_plus][:set]==:on \ + || @md.opt.act[:maintenance][:set]==:on) + SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],'*WARN* use of RMagick is not enabled in sisurc.yml').warn end end data.each do |dob| @@ -104,8 +107,10 @@ module SiSU_DAL_Images img=Magick::ImageList.new("#{image_path}/#{image}") img_col,img_row=img.columns,img.rows else - if @md.opt.cmd =~/[vVM]/ - SiSU_Screen::Ansi.new(@md.opt.cmd,'*WARN* RMagick not present, will attempt to use imagemagick (identify) directly').warn + if (@md.opt.act[:verbose][:set]==:on \ + || @md.opt.act[:verbose_plus][:set]==:on \ + || @md.opt.act[:maintenance][:set]==:on) + SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],'*WARN* RMagick not present, will attempt to use imagemagick (identify) directly').warn end imgk=SiSU_Env::SystemCall.new.imagemagick gmgk=SiSU_Env::SystemCall.new.graphicksmagick @@ -142,7 +147,7 @@ module SiSU_DAL_Images end else images=dob.obj.scan(m) do |image| - SiSU_Screen::Ansi.new(@md.opt.cmd,'*WARN* where image dimensions have not been provided RMagick or imagemagick is required',image).warn #unless @opt.cmd =~/q/ + SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],'*WARN* where image dimensions have not been provided RMagick or imagemagick is required',image).warn unless @md.opt.act[:quiet][:set]==:on end end end diff --git a/lib/sisu/v4/dal_metadata.rb b/lib/sisu/v6/ao_metadata.rb index 9273d88a..3ca232f3 100644 --- a/lib/sisu/v4/dal_metadata.rb +++ b/lib/sisu/v6/ao_metadata.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/dal_metadata.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/ao_metadata.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -59,7 +60,7 @@ ** Description: system environment, resource control and configuration details =end -module SiSU_DAL_Metadata +module SiSU_AO_Metadata class Metadata def initialize(md,metad) @md,@metadata=md,metad @@ -69,11 +70,11 @@ module SiSU_DAL_Metadata end def make_para(obj,ocn) h={ obj: obj, ocn: 0 } - SiSU_DAL_DocumentStructure::ObjectPara.new.paragraph(h) + SiSU_AO_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_DAL_DocumentStructure::ObjectHeading.new.heading(h) + SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h) end def metadata end diff --git a/lib/sisu/v4/dal_misc_arrange.rb b/lib/sisu/v6/ao_misc_arrange.rb index e6cc72db..a2cbb6c1 100644 --- a/lib/sisu/v4/dal_misc_arrange.rb +++ b/lib/sisu/v6/ao_misc_arrange.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/dal_misc_arrange.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/ao_misc_arrange.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -59,14 +60,14 @@ ** Description: system environment, resource control and configuration details =end -module SiSU_DAL_MiscArrangeText +module SiSU_AO_MiscArrangeText class SI def initialize(md,data) @md,@data=md,data end def conditional_headings(para) 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 + gsub(/^((?:[1-9]|:?[A-D])~\S*)\s*$/,'\1~ [Note: heading marker::required title missing]~#') #conditional header for incorporated document 2004w12 if para =~/^@\S+?:/ 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") diff --git a/lib/sisu/v4/dal_numbering.rb b/lib/sisu/v6/ao_numbering.rb index c2ac6785..23d9fd73 100644 --- a/lib/sisu/v4/dal_numbering.rb +++ b/lib/sisu/v6/ao_numbering.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/dal_numbering.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/ao_numbering.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -59,7 +60,7 @@ ** Description: system environment, resource control and configuration details =end -module SiSU_DAL_Numbering +module SiSU_AO_Numbering class Numbering attr_accessor :obj,:osp,:ocn,:lv,:name,:index,:comment def initialize(md,data) @@ -97,9 +98,9 @@ module SiSU_DAL_Numbering def number_sub_heading(dob,num,title_no) unless dob.obj =~/\d+\.|(?:chapter|article|section|clause)\s+\d+/i #name selection arbitrary, fix 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} ") + when /-/ then dob.obj.gsub(/^/,"#{title_no} ") + when /^#/ then dob.obj.gsub(/^/,"#{title_no} ") + when /^[a-z_\.]+/ then 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 @@ -142,7 +143,7 @@ module SiSU_DAL_Numbering data=data.compact data.each do |dob| #@md.seg_names << [additions to segment names] title_no=nil - dob=SiSU_DAL_DocumentStructureExtract::Structure.new(@md,dob).structure_markup #must happen earlier, node info etc. require + dob=SiSU_AO_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 \ @@ -157,7 +158,7 @@ module SiSU_DAL_Numbering @subnumber=1 @subnumber=0 if dob.ln==no1 end - if dob.ln.to_s =~/^[1-6]/ \ + if dob.ln.to_s =~/^[0-6]/ \ and not dob.toc_ \ and dob.obj !~/#{Mx[:fa_o]}(?:~#|-#)#{Mx[:fa_c]}/ # <-- fix if dob.ln==no1 @@ -205,7 +206,7 @@ module SiSU_DAL_Numbering dob.tags=["h#{title_no}",dob.tags].flatten #check whether will work across file types with stop signs dob=number_sub_heading(dob,no3,title_no) end - elsif dob.ln.to_s =~/^[1-6]/ \ + elsif dob.ln.to_s =~/^[0-6]/ \ and dob.name =~ /^[\w-]+-/ # endnotes, watch2005# endnotes, watch2005 dob.tags=[dob.name,dob.tags].flatten if dob.name !~/^\d+$/ #check whether will work across file types with stop signs dob.name.gsub(/^([a-z_\.]+)-$/,'\1') @@ -215,7 +216,7 @@ module SiSU_DAL_Numbering 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 if (dob.name.nil? or dob.name.empty?) \ - and dob.ln.to_s =~/^[1-9]/ \ + and dob.ln.to_s =~/^[0-9]/ \ and dob.obj =~ /^([\d\.]+)/ #risky (must be unique) consider output to 4~~\d instead of 4~\d dob.name=$1 dob.tags=[dob.name,dob.tags].flatten if dob.name !~/^\d+$/ #check whether will work across file types with stop signs @@ -232,11 +233,11 @@ module SiSU_DAL_Numbering @tuned_file=@tuned_file.flatten end def ocn(data) #and auto segment numbering increment - @tuned_file=SiSU_DAL_DocumentStructureExtract::OCN.new(@md,data).ocn + @tuned_file=SiSU_AO_DocumentStructureExtract::OCN.new(@md,data).ocn @tuned_file end def xml(data) - @tuned_file=SiSU_DAL_DocumentStructureExtract::XML.new(@md,data).dom + @tuned_file=SiSU_AO_DocumentStructureExtract::XML.new(@md,data).dom @tuned_file end def minor_numbering(data) #and auto segment numbering increment @@ -249,7 +250,7 @@ module SiSU_DAL_Numbering || 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) + and dob.ln.to_s=~/^[0-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 if dob.obj =~/^#[ 1]/ \ @@ -288,7 +289,9 @@ module SiSU_DAL_Numbering tags={} art_filename_auto=1 @counter=1 - if not @md.seg_autoname_safe and @md.opt.cmd =~/[MV]/ + if not @md.seg_autoname_safe \ + and (@md.opt.act[:verbose_plus][:set]==:on \ + || @md.opt.act[:maintenance][:set]==:on) puts 'manual segment names, numbers used as names, risk warning (segmented html)' end ocn_html_seg=[] @@ -311,7 +314,9 @@ module SiSU_DAL_Numbering dob.name=possible_seg_name dob.tags=[dob.name,dob.tags].flatten if dob.name !~/^\d+$/ @md.seg_names << possible_seg_name - else puts 'warn, there may be a conflicting numbering scheme' if @md.opt.cmd =~/[VM]/ + elsif (@md.opt.act[:verbose_plus][:set]==:on \ + or @md.opt.act[:maintenance][:set]==:on) + puts 'warn, there may be a conflicting numbering scheme' end end if dob.ln==4 \ @@ -350,11 +355,11 @@ module SiSU_DAL_Numbering m=dob.ln.to_s dob_tmp=[] if @md.pagenew.inspect =~/#{m}/ - dob_tmp << SiSU_DAL_DocumentStructure::ObjectLayout.new.break(Hx[:br_page_new]) << dob + dob_tmp << SiSU_AO_DocumentStructure::ObjectLayout.new.break(Hx[:br_page_new]) << dob elsif @md.pagebreak.inspect =~/#{m}/ - dob_tmp << SiSU_DAL_DocumentStructure::ObjectLayout.new.break(Hx[:br_page]) << dob + dob_tmp << SiSU_AO_DocumentStructure::ObjectLayout.new.break(Hx[:br_page]) << dob elsif @md.pageline.inspect =~/#{m}/ - dob_tmp << SiSU_DAL_DocumentStructure::ObjectLayout.new.break(Hx[:br_page_line]) << dob + dob_tmp << SiSU_AO_DocumentStructure::ObjectLayout.new.break(Hx[:br_page_line]) << dob end unless dob_tmp.length > 0; dob else dob_tmp @@ -368,7 +373,7 @@ module SiSU_DAL_Numbering : @segname tags["#{dob.ocn}"]={ segname: @segname } ocn_html_seg[dob.ocn]=if (dob.is==:heading || dob.is==:heading_insert) - if dob.ln =~/[1-3]/ + if dob.ln =~/[0-3]/ { seg: nil, level: dob.ln } else #elsif dob.ln =~/[4-6]/ { seg: @seg, level: dob.ln } @@ -407,7 +412,10 @@ module SiSU_DAL_Numbering end def set_heading_top(data) #% make sure no false positives unless @md.set_heading_top - puts "\tdocument contains no top level heading, (will have to manufacture one)" if @md.opt.cmd =~/[MV]/ + if (@md.opt.act[:verbose_plus][:set]==:on \ + or @md.opt.act[:maintenance][:set]==:on) + puts "\tdocument contains no top level heading, (will have to manufacture one)" + end @tuned_file=[] data.each do |t_o| unless @md.set_heading_top @@ -431,11 +439,14 @@ module SiSU_DAL_Numbering end def set_heading_seg(data) #% make sure no false positives unless @md.set_heading_seg - puts "\tdocument contains no segment level, (will have to manufacture one)" if @md.opt.cmd =~/[MV]/ + if (@md.opt.act[:verbose_plus][:set]==:on \ + or @md.opt.act[:maintenance][:set]==:on) + puts "\tdocument contains no segment level, (will have to manufacture one)" + end @tuned_file=[] data.each do |dob| unless @md.set_heading_seg - if defined? dob.ln and dob.ln.to_s !~/^[123]/m \ + if defined? dob.ln and dob.ln.to_s !~/^[0-3]/m \ and dob.obj !~/\A\s*\Z/m \ and dob.is !=:layout @md.set_heading_seg=true @@ -452,7 +463,10 @@ module SiSU_DAL_Numbering end def set_header_title(data) #% make sure no false positives unless @md.set_header_title - puts "\t no document title provided, (will have to manufacture one)" if @md.opt.cmd =~/[MV]/ + if (@md.opt.act[:verbose_plus][:set]==:on \ + or @md.opt.act[:maintenance][:set]==:on) + puts "\t no document title provided, (will have to manufacture one)" + end @tuned_file=[] data.each do |t_o| unless @md.set_header_title diff --git a/lib/sisu/v4/dal_syntax.rb b/lib/sisu/v6/ao_syntax.rb index 0f57307e..e3777f50 100644 --- a/lib/sisu/v4/dal_syntax.rb +++ b/lib/sisu/v6/ao_syntax.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/dal_syntax.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/ao_syntax.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -59,7 +60,7 @@ ** Description: Syntax for markup, input markup syntaxes, determined here =end -module SiSU_DAL_Syntax +module SiSU_AO_Syntax class Words def initialize(line,md,mkp) @line,@md,@mkp=line,md,mkp @@ -411,7 +412,7 @@ module SiSU_DAL_Syntax 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 + and dob.ln ==0 dob.obj=dob.obj.gsub(/\s*@title\b/," #{@md.title.full}") dob.obj=if defined? @md.creator.author \ and @md.creator.author diff --git a/lib/sisu/v4/author_format.rb b/lib/sisu/v6/author_format.rb index 479fbc8b..7b791bd7 100644 --- a/lib/sisu/v4/author_format.rb +++ b/lib/sisu/v6/author_format.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/author_format.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/author_format.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> diff --git a/lib/sisu/v4/cgi.rb b/lib/sisu/v6/cgi.rb index acaa5396..a4065344 100644 --- a/lib/sisu/v4/cgi.rb +++ b/lib/sisu/v6/cgi.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/cgi.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/cgi.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> diff --git a/lib/sisu/v4/cgi_pgsql.rb b/lib/sisu/v6/cgi_pgsql.rb index f012fb51..2bcd42e3 100644 --- a/lib/sisu/v4/cgi_pgsql.rb +++ b/lib/sisu/v6/cgi_pgsql.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/cgi_pgsql.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/cgi_pgsql.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -66,7 +67,7 @@ module SiSU_CGI_PgSQL class SearchPgSQL < CGI_Common def initialize(opt,webserv) @opt,@webserv=opt,webserv - @cX=SiSU_Screen::Ansi.new(opt.cmd).cX + @cX=SiSU_Screen::Ansi.new(opt.act[:color_state][:set]).cX @env=SiSU_Env::InfoEnv.new('',opt) @sys=SiSU_Env::SystemCall.new @db=SiSU_Env::InfoDb.new @@ -166,20 +167,20 @@ module SiSU_CGI_PgSQL # set file permissions to 755 WOK a=case @webserv - when /pwd/; '' + when /pwd/ then '' else <<-WOK sudo cp -vi #{Dir.pwd}/#{@cgi_file_name} /usr/lib/cgi-bin/.; \\ sudo chmod -v 755 /usr/lib/cgi-bin/#{@cgi_file_name} WOK end - SiSU_Screen::Ansi.new(@opt.cmd,a).warn + SiSU_Screen::Ansi.new(opt.act[:color_state][:set],a).warn a=<<-WOK #{@env.webserv_base_cgi(@opt)}/cgi-bin/#{@cgi_file_name} WOK - SiSU_Screen::Ansi.new(@opt.cmd,a).print_blue + SiSU_Screen::Ansi.new(opt.act[:color_state][:set],a).print_blue a="\n\t(to create and populate postgresql database see 'man sisu' and in particular the --pg option)\n\t[the database to be used for this directory (#{@db.psql.db}) will have to be created manually if it does not exist,\n\tusing postgresql tools directly: 'createdb #{@db.psql.db}' for a list of existing databases try 'psql --list']" - SiSU_Screen::Ansi.new(@opt.cmd,a).txt_grey + SiSU_Screen::Ansi.new(opt.act[:color_state][:set],a).txt_grey else puts 'failed in attempt to write #{@cgi_file_name} to present directory, is directory writable?' end end diff --git a/lib/sisu/v4/cgi_sql_common.rb b/lib/sisu/v6/cgi_sql_common.rb index 2597b4a2..44d06880 100644 --- a/lib/sisu/v4/cgi_sql_common.rb +++ b/lib/sisu/v6/cgi_sql_common.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/cgi_sql_common.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/cgi_sql_common.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -82,7 +83,7 @@ module SiSU_CGI_SQL * Author: Ralph Amissah - * Copyright: (C) 1997 - 2013, Ralph Amissah, All Rights Reserved. + * Copyright: (C) 1997 - 2014, Ralph Amissah, All Rights Reserved. * License: GPL 3 or later: @@ -572,7 +573,7 @@ module SiSU_CGI_SQL <br /> <a href="http://www.sisudoc.org" > <b>#{v[:project]}</b></a> <sup>©</sup> Ralph Amissah - 1993, current 2013. + 1993, current 2014. All Rights Reserved. <br /> #{v[:project]} is software for document structuring, publishing and search, @@ -610,7 +611,7 @@ module SiSU_CGI_SQL <br />Standard SiSU meta-markup syntax, and the <br />Standard SiSU <u>object citation numbering</u> and system, (object/text identifying/locating system) <br /> - <sup>©</sup> Ralph Amissah 1997, current 2013. + <sup>©</sup> Ralph Amissah 1997, current 2014. All Rights Reserved. </font></p> </td></tr> diff --git a/lib/sisu/v4/cgi_sqlite.rb b/lib/sisu/v6/cgi_sqlite.rb index da7aa97a..fff0f98f 100644 --- a/lib/sisu/v4/cgi_sqlite.rb +++ b/lib/sisu/v6/cgi_sqlite.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/cgi_sql_sqlite.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/cgi_sql_sqlite.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -66,7 +67,7 @@ module SiSU_CGI_SQLite class SearchSQLite < CGI_Common def initialize(opt,webserv) @opt,@webserv=opt,webserv - @cX=SiSU_Screen::Ansi.new(opt.cmd).cX + @cX=SiSU_Screen::Ansi.new(opt.act[:color_state][:set]).cX @env=SiSU_Env::InfoEnv.new('',opt) @image_src="#{@env.url.webserv_cgi(@opt)}/_sisu/image_sys" @name_of={} @@ -99,13 +100,13 @@ module SiSU_CGI_SQLite end f2 << %{ selected_db=case cgi['db']\n} serve.each do |x| - f2 << %{ when /#{Db[:name_prefix]}#{x}/; '<option value="#{Db[:name_prefix]}#{x}">#{x}</option>'\n} + f2 << %{ when /#{Db[:name_prefix]}#{x}/ then '<option value="#{Db[:name_prefix]}#{x}">#{x}</option>'\n} end f2 << " end\n" f3 << %{ db_name='#{@name_of_sqlite_db_file}'\n} f3 << %{ db_sqlite=case cgi['db']\n} serve.each do |x| - f3 << %{ when /#{Db[:name_prefix]}#{x}/; "#{@env.path.webserv}/#{x}/\#{db_name}"\n} + f3 << %{ when /#{Db[:name_prefix]}#{x}/ then "#{@env.path.webserv}/#{x}/\#{db_name}"\n} end f3 << %{ else '#{@env.path.webserv}/#{serve[0]}/\#{db_name}'\n end\n} if FileTest.writable?('.') @@ -138,7 +139,7 @@ module SiSU_CGI_SQLite # set file permissions to 755 WOK a=case @webserv - when /pwd/; '' + when /pwd/ then '' else <<-WOK sudo cp -vi #{Dir.pwd}/#{@cgi_file_name} /usr/lib/cgi-bin/.; \\ @@ -146,13 +147,13 @@ module SiSU_CGI_SQLite WOK end b='(to create and populate sisu sqlite database see "man sisu" and in particular the -d flag)' - SiSU_Screen::Ansi.new(@opt.cmd,a,b).warn + SiSU_Screen::Ansi.new(opt.act[:color_state][:set],a,b).warn a=<<-WOK #{@env.webserv_base_cgi(@opt)}/cgi-bin/#{@cgi_file_name} WOK - SiSU_Screen::Ansi.new(@opt.cmd,a).print_blue + SiSU_Screen::Ansi.new(opt.act[:color_state][:set],a).print_blue else puts "failed in attempt to write #{@cgi_file_name} to present directory, is directory writable?" end end diff --git a/lib/sisu/v4/composite.rb b/lib/sisu/v6/composite.rb index 2d537f4a..044f31c4 100644 --- a/lib/sisu/v4/composite.rb +++ b/lib/sisu/v6/composite.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/composite.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/composite.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -163,14 +164,18 @@ module SiSU_Assemble def insertions? data=@fns_array tuned_file,imagedir=[],[] - SiSU_Screen::Ansi.new(@opt.cmd,'Composite Document',"[#{@opt.f_pth[:lng_is]}] #{@opt.fno}").grey_title_hi unless @opt.cmd =~/q/ + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Composite Document',"[#{@opt.f_pth[:lng_is]}] #{@opt.fno}").grey_title_hi unless @opt.act[:quiet][:set]==:on data.each do |para| if para =~/^<<\s+(\S+?\.ss[it])$/ \ or para =~/^<<\{(\S+?\.ss[it])\}$/ \ or para =~/^(?:<<\s*)\|(\S+?)\|@\|.+?\|(?:req(?:quire)?\b|\s*\})?/ \ or para =~/^r\{(.+?)\}/ #depreciated loadfile=$1.strip - SiSU_Screen::Ansi.new(@opt.cmd,'loading:',loadfile).txt_grey if @opt.cmd =~/[MVv]/ + if (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'loading:',loadfile).txt_grey + end tuned_file << if loadfile =~ /(?:https?|file):\/\/\S+?\.ss[ti]$/ # and NetTest imagedir = /((?:https?|file):\/\/\S+?)\/[^\/]+?\.ss[ti]$/.match(loadfile).captures.join + '/_sisu/image' #watch require 'uri' @@ -190,7 +195,7 @@ module SiSU_Assemble file=insertion(loadfile,insert_array) file[:prepared] else - cX=SiSU_Screen::Ansi.new(@opt.cmd).cX + cX=SiSU_Screen::Ansi.new(@opt.act[:color_state][:set]).cX STDERR.puts "\t #{cX.fuchsia}ERROR#{cX.off} #{cX.brown}#{@opt.fns}#{cX.off} #{cX.fuchsia}requires invalid or non-existent file:#{cX.off} #{cX.brown}#{loadfile}#{cX.off}" para end @@ -229,19 +234,23 @@ module SiSU_Assemble def insertions? data=@fns_array tuned_file=[] - SiSU_Screen::Ansi.new(@opt.cmd,'Composite Document',@opt.fno).grey_title_hi unless @opt.cmd =~/q/ + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Composite Document',@opt.fno).grey_title_hi unless @opt.act[:quiet][:set]==:on @ssm=[@opt.fns] data.each do |para| if para =~/^<<\s+(\S+?\.ss[it])$/ loadfile=$1.strip - SiSU_Screen::Ansi.new(@opt.cmd,'loading:',loadfile).txt_grey if @opt.cmd =~/[MVv]/ + if (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'loading:',loadfile).txt_grey + end tuned_file << if loadfile =~ /(?:https?|file):\/\/\S+?\.ss[ti]$/ @ssm << loadfile elsif loadfile =~ /\.ss[ti]$/ \ and FileTest.file?(loadfile) @ssm << loadfile else - cX=SiSU_Screen::Ansi.new(@opt.cmd).cX + cX=SiSU_Screen::Ansi.new(@opt.act[:color_state][:set]).cX STDERR.puts "\t #{cX.fuchsia}ERROR#{cX.off} #{cX.brown}#{@opt.fns}#{cX.off} #{cX.fuchsia}requires invalid or non-existent file:#{cX.off} #{cX.brown}#{loadfile}#{cX.off}" para end diff --git a/lib/sisu/v4/concordance.rb b/lib/sisu/v6/concordance.rb index 5387dce3..a20178ab 100644 --- a/lib/sisu/v4/concordance.rb +++ b/lib/sisu/v6/concordance.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/concordance.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/concordance.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -79,23 +80,27 @@ module SiSU_Concordance begin @env,@md=@particulars.env,@particulars.md @env.url.output_tell - unless @md.opt.cmd =~/q/ - tool=(@md.opt.cmd =~/[MVv]/) \ + unless @md.opt.act[:quiet][:set]==:on + tool=(@md.opt.act[:verbose][:set]==:on \ + || @md.opt.act[:verbose_plus][:set]==:on \ + || @md.opt.act[:maintenance][:set]==:on) \ ? "#{@env.program.web_browser} #{@md.file.output_path.html_concordance.dir}/#{@md.file.base_filename.html_concordance}" : "[#{@opt.f_pth[:lng_is]}] #{@opt.fno}" - @md.opt.cmd=~/[MVvz]/ \ - ? SiSU_Screen::Ansi.new(@opt.cmd,"Concordance",tool).green_hi_blue - : SiSU_Screen::Ansi.new(@opt.cmd,'Concordance',tool).green_title_hi + (@md.opt.act[:verbose][:set]==:on \ + || @md.opt.act[:verbose_plus][:set]==:on \ + || @md.opt.act[:maintenance][:set]==:on) \ + ? SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"Concordance",tool).green_hi_blue + : SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Concordance',tool).green_title_hi end wordmax=@env.concord_max unless @md.wc_words.nil? if @md.wc_words < wordmax SiSU_Concordance::Source::Words.new(@particulars).songsheet else - SiSU_Screen::Ansi.new(@md.opt.cmd,"concordance skipped, large document has over #{wordmax} words (#{@md.wc_words})").warn unless @md.opt.cmd =~/q/ + SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],"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.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_Screen::Ansi.new(@md.opt.act[:color_state][:set],"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_Concordance::Source::Words.new(@particulars).songsheet end rescue @@ -109,8 +114,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 @@ -198,7 +203,7 @@ WOK def initialize(particulars) @particulars=particulars begin - @env,@md,@dal_array=particulars.env,particulars.md,particulars.dal_array + @env,@md,@ao_array=particulars.env,particulars.md,particulars.ao_array @file=SiSU_Env::FileOp.new(@md) @freq=Hash.new(0) @dp=@@dp ||=SiSU_Env::InfoEnv.new.digest.pattern @@ -252,7 +257,7 @@ WOK def map_para @seg,ocn=nil,nil @word_map={} - @dal_array.each do |line| + @ao_array.each do |line| if defined? line.ocn \ and line.ocn.to_s =~/\d/ if (line.is ==:heading \ @@ -322,9 +327,9 @@ WOK end else @word_map[word] << case line - when @rxp_lv1; location_seg('T1',ocn) #fix @rxp_lv # Mx[:lv_o] - when @rxp_lv2; location_seg('T2',ocn) #fix @rxp_lv # Mx[:lv_o] - when @rxp_lv3; location_seg('T3',ocn) #fix @rxp_lv # Mx[:lv_o] + when @rxp_lv1 then location_seg('T1',ocn) #fix @rxp_lv # Mx[:lv_o] + when @rxp_lv2 then location_seg('T2',ocn) #fix @rxp_lv # Mx[:lv_o] + when @rxp_lv3 then location_seg('T3',ocn) #fix @rxp_lv # Mx[:lv_o] end end end @@ -365,7 +370,10 @@ WOK # special cases endnotes and header levels 1 - 3 end @file_concordance << %{</div></body>\n</html>} # footer - SiSU_Screen::Ansi.new(@md.opt.cmd,@md.fns,"#{@md.file.output_path.html_concordance.dir}/#{@md.file.base_filename.html_concordance}").flow if @md.opt.cmd =~/[MV]/ + if @md.opt.act[:verbose_plus][:set]==:on \ + || @md.opt.act[:maintenance][:set]==:on + SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],@md.fns,"#{@md.file.output_path.html_concordance.dir}/#{@md.file.base_filename.html_concordance}").flow + end end end end diff --git a/lib/sisu/v4/conf.rb b/lib/sisu/v6/conf.rb index 8ede007d..c2333191 100644 --- a/lib/sisu/v4/conf.rb +++ b/lib/sisu/v6/conf.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/conf.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/conf.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -96,29 +97,29 @@ module SiSU_Initialize @pwd,@home=Dir.pwd,@env.path.home end def make_homepage - SiSU_Screen::Ansi.new(@opt.cmd,'invert','Make homepage','').colorize unless @opt.cmd =~/q/ + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'invert','Make homepage','').colorize unless @opt.act[:quiet][:set]==:on 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_Screen::Ansi.new(@opt.act[:color_state][:set],'invert','Copy images','').colorize unless @opt.act[:quiet][:set]==:on 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_Screen::Ansi.new(@opt.act[:color_state][:set],'invert','Copy external images','').colorize if @opt.act[:verbose_plus][:set]==:on 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_Screen::Ansi.new(@opt.act[:color_state][:set],'invert','Copy webserver/output file images','').colorize unless @opt.act[:quiet][:set]==:on SiSU_Env::CreateSite.new(@opt.cmd).cp_webserver_images end def css - SiSU_Screen::Ansi.new(@opt.cmd,'invert','Configuring CSSs','').colorize unless @opt.cmd =~/q/ + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'invert','Configuring CSSs','').colorize unless @opt.act[:quiet][:set]==:on 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/ + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'invert','Configuring DTDs','').colorize unless @opt.act[:quiet][:set]==:on @rxng=SiSU_Relaxng::RelaxNG.new @path.each { |d| FileUtils::mkdir_p(d[1]) unless FileTest.directory?(d[1]) } #ugly code, sort later @@ -161,7 +162,7 @@ module SiSU_Initialize end def trang_rnc_model_output_sax s=@suffix - rnc_src=@env.processing_path.dal + '/sax.' + s[:rnc] + rnc_src=@env.processing_path.ao + '/sax.' + s[:rnc] rnc_file=@path[:rnc] + '/' + @rxng.rnc_name.output_sax rng_file=@path[:rng] + '/' + @rxng.rng_name.output_sax xsd_file=@path[:xsd] + '/' + @rxng.xsd_name.output_sax @@ -183,7 +184,7 @@ module SiSU_Initialize end def trang_rnc_model_output_dom s=@suffix - rnc_src=@env.processing_path.dal + '/dom.' + s[:rnc] + rnc_src=@env.processing_path.ao + '/dom.' + s[:rnc] rnc_file=@path[:rnc] + '/' + @rxng.rnc_name.output_dom rng_file=@path[:rng] + '/' + @rxng.rng_name.output_dom xsd_file=@path[:xsd] + '/' + @rxng.xsd_name.output_dom @@ -205,7 +206,7 @@ module SiSU_Initialize end def trang_rnc_model_output_xhtml s=@suffix - rnc_src=@env.processing_path.dal + '/xhtml.' + s[:rnc] + rnc_src=@env.processing_path.ao + '/xhtml.' + s[:rnc] rnc_file=@path[:rnc] + '/' + @rxng.rnc_name.output_xhtml rng_file=@path[:rng] + '/' + @rxng.rng_name.output_xhtml xsd_file=@path[:xsd] + '/' + @rxng.xsd_name.output_xhtml @@ -226,7 +227,7 @@ module SiSU_Initialize end end def trang_rnc_model_input_sax - rnc_file=@env.processing_path.dal + '/sax.rnc' + rnc_file=@env.processing_path.ao + '/sax.rnc' dtd_file=@path[:xsd] + '/' + @rxng.rng_name.input_sax rnc=File.new(rnc_file,'w') rnc << @rxng.rnc_model_output_sax @@ -235,7 +236,7 @@ module SiSU_Initialize schema.relaxng(@opt.cmd) end def trang_rnc_model_input_dom - rnc_file=@env.processing_path.dal + '/dom.rnc' + rnc_file=@env.processing_path.ao + '/dom.rnc' dtd_file=@path[:xsd] + '/' + @rxng.rng_name.input_dom rnc=File.new(rnc_file,'w') rnc << @rxng.rnc_model_output_dom @@ -244,7 +245,7 @@ module SiSU_Initialize schema.relaxng(@opt.cmd) end def trang_rnc_model_input_node - rnc_file=@env.processing_path.dal + '/node.rnc' + rnc_file=@env.processing_path.ao + '/node.rnc' dtd_file=@path[:xsd] + '/' + @rxng.rng_name.input_node rnc=File.new(rnc_file,'w') rnc << @rxng.rnc_model_input_node diff --git a/lib/sisu/v4/constants.rb b/lib/sisu/v6/constants.rb index bb90cdc8..34ff92e7 100644 --- a/lib/sisu/v4/constants.rb +++ b/lib/sisu/v6/constants.rb @@ -9,7 +9,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -51,7 +52,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/v4/constants.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/constants.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -61,22 +62,33 @@ =end #Ax,Xx,Mx,Rx,Hx,Dx,Px,Ep,Db,Gt,Tex=Array.new(11){{}} -YEAR='2013' +YEAR='2014' Sfx={ - txt: '.txt', - html: '.html', - xhtml: '.xhtml', - xml: '.xml', - xml_sax: '.sax.xml', - xml_dom: '.dom.xml', - epub: '.epub', - epub_xhtml: '.xhtml', - odt: '.odt', - pdf: '.pdf', - manpage: '.1', - info: '.info', - texinfo: '.texinfo', - sql: '.sql.db', + txt: '.txt', + txt_textile: '.textile', + txt_asciidoc: '.ad', + txt_markdown: '.md', + txt_rst: '.rst', + html: '.html', + xhtml: '.xhtml', + xml: '.xml', + xml_sax: '.sax.xml', + xml_dom: '.dom.xml', + xml_scaffold: '.scaffold.xml', + xml_scaffold_structure_sisu: '.scaffold.sisu.xml', + xml_scaffold_structure_collapse: '.scaffold.collapse.xml', + xml_docbook: '.docbook.xml', + xml_docbook_article: '.article.docbook.xml', + xml_docbook_book: '.book.docbook.xml', + xml_fictionbook: '.fb2', + epub: '.epub', + epub_xhtml: '.xhtml', + odt: '.odt', + pdf: '.pdf', + manpage: '.1', + info: '.info', + texinfo: '.texinfo', + sql: '.sql.db', } Ax={ tab: "\t", @@ -90,6 +102,7 @@ Xx={ } Mx={ meta_o: '〔@', meta_c: '〕', + lv_o_0: 0, lv_o_1: 1, lv_o_2: 2, lv_o_3: 3, @@ -163,7 +176,8 @@ Hx={ #Mx[:sm_subset_o]='∈ '; Mx[:sm_subset_c]='∋ ' Rx={ mx_fa_clean: /#{Mx[:fa_o]}.+?#{Mx[:fa_c]}|#{Mx[:pa_o]}.+?#{Mx[:pa_c]}|#{Mx[:mk_o]}.+?#{Mx[:mk_c]}/, - lv: /〔([1-9]):(\S*?)〕/, + lv: /〔([0-9]):(\S*?)〕/, + lv_0: /#{Mx[:lv_o_0]}(\S*?)#{Mx[:lv_c]}/, lv_1: /#{Mx[:lv_o_1]}(\S*?)#{Mx[:lv_c]}/, lv_2: /#{Mx[:lv_o_2]}(\S*?)#{Mx[:lv_c]}/, lv_3: /#{Mx[:lv_o_3]}(\S*?)#{Mx[:lv_c]}/, @@ -345,8 +359,8 @@ 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} -puts "#{__FILE__} #{__LINE__} #{para}" if @opt.cmd =~/M/ -puts "#{__FILE__} #{__LINE__} #{t_o}" if @opt.cmd =~/M/ +puts "#{__FILE__} #{__LINE__} #{para}" if @opt.act[:maintenance][:set]==:on +puts "#{__FILE__} #{__LINE__} #{t_o}" if @opt.act[:maintenance][:set]==:on 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 ├ 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/v4/css.rb b/lib/sisu/v6/css.rb index 0a433b31..81cb115b 100644 --- a/lib/sisu/v4/css.rb +++ b/lib/sisu/v6/css.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/css.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/css.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> diff --git a/lib/sisu/v4/db_columns.rb b/lib/sisu/v6/db_columns.rb index 488df7c5..1b21cf96 100644 --- a/lib/sisu/v4/db_columns.rb +++ b/lib/sisu/v6/db_columns.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/db_columns.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/db_columns.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> diff --git a/lib/sisu/v4/db_create.rb b/lib/sisu/v6/db_create.rb index e5b8dc78..661059a1 100644 --- a/lib/sisu/v4/db_create.rb +++ b/lib/sisu/v6/db_create.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/db_create.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/db_create.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -67,7 +68,7 @@ module SiSU_DbCreate @@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 + @cX=SiSU_Screen::Ansi.new(@opt.act[:color_state][:set]).cX @comment=(@sql_type=='pg') \ ? (SiSU_DbCreate::Comment.new(@conn,@sql_type)) : nil @@ -84,9 +85,13 @@ module SiSU_DbCreate def create_db @env=SiSU_Env::InfoEnv.new(@opt.fns) tell=(@sql_type=='sqlite') \ - ? SiSU_Screen::Ansi.new(@opt.cmd,'Create SQLite db tables in:',%{"#{@file}"}) - : SiSU_Screen::Ansi.new(@opt.cmd,'Create pgSQL db tables in:',%{"#{Db[:name_prefix]}#{@env.path.stub_pwd}"}) - tell.dark_grey_title_hi if @opt.cmd =~/[vVM]/ + ? SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Create SQLite db tables in:',%{"#{@file}"}) + : SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Create pgSQL db tables in:',%{"#{Db[:name_prefix]}#{@env.path.stub_pwd}"}) + if (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) + tell.dark_grey_title_hi + end 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? @@ -97,12 +102,15 @@ module SiSU_DbCreate end def create_table def metadata_and_text - print %{ + if (@opt.act[:verbose_plus][:set]==:on \ + or @opt.act[:maintenance][:set]==:on) + print %{ currently using sisu dbi module to be populated from document files create tables metadata_and_text data import through ruby transfer - } if @opt.cmd =~/[VM]/ + } + end create_metadata_and_text=%{ CREATE TABLE metadata_and_text ( tid BIGINT PRIMARY KEY, @@ -207,11 +215,14 @@ module SiSU_DbCreate @comment.psql.metadata_and_text if @comment end def doc_objects # create doc_objects base - print %{ + if (@opt.act[:verbose_plus][:set]==:on \ + or @opt.act[:maintenance][:set]==:on) + print %{ to be populated from documents files create tables doc_objects data import through ruby transfer - } if @opt.cmd =~/[VM]/ + } + end create_doc_objects=%{ CREATE TABLE doc_objects ( lid BIGINT PRIMARY KEY, @@ -225,6 +236,7 @@ module SiSU_DbCreate seg VARCHAR(256) NULL, lev_an VARCHAR(1), lev SMALLINT NULL, + lev0 SMALLINT, lev1 SMALLINT, lev2 SMALLINT, lev3 SMALLINT, @@ -250,11 +262,14 @@ module SiSU_DbCreate @comment.psql.doc_objects if @comment end def endnotes - print %{ + if (@opt.act[:verbose_plus][:set]==:on \ + or @opt.act[:maintenance][:set]==:on) + print %{ to be populated from document files create tables endnotes data import through ruby transfer - } if @opt.cmd =~/[VM]/ + } + end create_endnotes=%{ CREATE TABLE endnotes ( nid BIGINT PRIMARY KEY, @@ -273,11 +288,14 @@ module SiSU_DbCreate @comment.psql.endnotes if @comment end def endnotes_asterisk - print %{ + if (@opt.act[:verbose_plus][:set]==:on \ + or @opt.act[:maintenance][:set]==:on) + print %{ to be populated from document files create tables endnotes_asterisk data import through ruby transfer - } if @opt.cmd =~/[VM]/ + } + end create_endnotes_asterisk=%{ CREATE TABLE endnotes_asterisk ( nid BIGINT PRIMARY KEY, @@ -296,11 +314,14 @@ module SiSU_DbCreate @comment.psql.endnotes_asterisk if @comment end def endnotes_plus - print %{ + if (@opt.act[:verbose_plus][:set]==:on \ + or @opt.act[:maintenance][:set]==:on) + print %{ to be populated from document files create tables endnotes_plus data import through ruby transfer - } if @opt.cmd =~/[VM]/ + } + end create_endnotes_plus=%{ CREATE TABLE endnotes_plus ( nid BIGINT PRIMARY KEY, @@ -319,12 +340,15 @@ module SiSU_DbCreate @comment.psql.endnotes_plus if @comment end def urls # create doc_objects file links mapping - print %{ + if (@opt.act[:verbose_plus][:set]==:on \ + or @opt.act[:maintenance][:set]==:on) + print %{ currently using sisu dbi module to be populated from doc_objects files create tables urls data import through ruby transfer - } if @opt.cmd =~/[VM]/ + } + end create_urls=%{ CREATE TABLE urls ( metadata_tid BIGINT REFERENCES metadata_and_text, @@ -461,9 +485,9 @@ module SiSU_DbCreate %{COMMENT ON COLUMN doc_objects.metadata_tid IS 'tie to title in metadata_and_text';}, %{COMMENT ON COLUMN doc_objects.lev_an - IS 'doc level A-C 1-6';}, + IS 'doc level A-D 1-6';}, %{COMMENT ON COLUMN doc_objects.lev - IS 'doc level 1-6 \d\~';}, + IS 'doc level 0-6 \d\~';}, %{COMMENT ON COLUMN doc_objects.seg IS 'segment name from level number 4 (lv 1)';}, %{COMMENT ON COLUMN doc_objects.ocn @@ -488,6 +512,8 @@ module SiSU_DbCreate IS 'text object - substantive text: light html markup';}, %{COMMENT ON COLUMN doc_objects.book_idx IS 'book index creation information for paragraph, if provided';}, + %{COMMENT ON COLUMN doc_objects.lev0 + IS 'document structure, level number 0';}, %{COMMENT ON COLUMN doc_objects.lev1 IS 'document structure, level number 1';}, %{COMMENT ON COLUMN doc_objects.lev2 diff --git a/lib/sisu/v4/db_dbi.rb b/lib/sisu/v6/db_dbi.rb index 7fd9b520..6e5f125d 100644 --- a/lib/sisu/v4/db_dbi.rb +++ b/lib/sisu/v6/db_dbi.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/db_dbi.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/db_dbi.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> diff --git a/lib/sisu/v4/db_drop.rb b/lib/sisu/v6/db_drop.rb index 80167822..94fc5e99 100644 --- a/lib/sisu/v4/db_drop.rb +++ b/lib/sisu/v6/db_drop.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/db_drop.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/db_drop.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -149,7 +150,7 @@ module SiSU_DbDrop end end def base #% drop base indexes - print "\n drop documents common indexes\n" unless @opt.cmd =~/q/ + print "\n drop documents common indexes\n" unless @opt.act[:quiet][:set]==:on sql_arr=[ %{DROP INDEX idx_title;}, %{DROP INDEX idx_author;}, @@ -158,6 +159,7 @@ module SiSU_DbDrop %{DROP INDEX idx_ocn;}, %{DROP INDEX idx_digest_clean;}, %{DROP INDEX idx_digest_all;}, + %{DROP INDEX idx_lev0;}, %{DROP INDEX idx_lev1;}, %{DROP INDEX idx_lev2;}, %{DROP INDEX idx_lev3;}, @@ -176,7 +178,7 @@ module SiSU_DbDrop conn_execute_array(sql_arr) end def text #% drop TEXT indexes, sqlite - print "\n drop documents TEXT indexes\n" unless @opt.cmd =~/q/ + print "\n drop documents TEXT indexes\n" unless @opt.act[:quiet][:set]==:on sql_arr=[ %{DROP INDEX idx_clean;}, %{DROP INDEX idx_endnote}, diff --git a/lib/sisu/v4/db_import.rb b/lib/sisu/v6/db_import.rb index 0384795a..e9fc4d5c 100644 --- a/lib/sisu/v4/db_import.rb +++ b/lib/sisu/v6/db_import.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/db_import.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/db_import.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -64,7 +65,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 @@ -74,9 +75,9 @@ module SiSU_DbImport attr_accessor :tp def initialize(opt,conn,file_maint,sql_type='pg') @opt,@conn,@file_maint,@sql_type=opt,conn,file_maint,sql_type - @cX=SiSU_Screen::Ansi.new(@opt.cmd).cX + @cX=SiSU_Screen::Ansi.new(@opt.act[:color_state][:set]).cX @env=SiSU_Env::InfoEnv.new(@opt.fns) - @dal="#{@env.processing_path.dal}" + @dal="#{@env.processing_path.ao}" @fnb=if @opt.fns.empty? \ or @opt.cmd.empty? '' @@ -102,7 +103,7 @@ module SiSU_DbImport ? @conn.execute( sql ).join.to_i : @conn.execute( sql ) { |x| x.fetch_all.flatten[0] } rescue - puts "#{__FILE__}:#{__LINE__}" if @opt.cmd =~/M/ + puts "#{__FILE__}:#{__LINE__}" if @opt.act[:maintenance][:set]==:on end @col[:lid]=0 if @col[:lid].nil? or @col[:lid].to_s.empty? sql='SELECT MAX(nid) FROM endnotes' @@ -112,19 +113,23 @@ module SiSU_DbImport : @id_n=@conn.execute( sql ) { |x| x.fetch_all.flatten[0] } @id_n ||=0 rescue - puts "#{__FILE__}:#{__LINE__}" if @opt.cmd =~/M/ + puts "#{__FILE__}:#{__LINE__}" if @opt.act[:maintenance][:set]==:on 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 + @col[:lv0]=@col[:lv1]=@col[:lv2]=@col[:lv3]=@col[:lv4]=@col[:lv5]=@col[:lv6]=0 @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 - @dal_array=SiSU_DAL::Source.new(@opt).get # dal file drawn here - SiSU_Screen::Ansi.new(@opt.cmd,"#{@db.psql.db}::#{@opt.fns}").puts_blue if @opt.cmd =~/vVM/ - SiSU_Screen::Ansi.new(@opt.cmd,'Marshal Load',@fnc).puts_grey if @opt.cmd =~/v/ + require_relative 'ao' # ao.rb + @ao_array=SiSU_AO::Source.new(@opt).get # ao file drawn here + if (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"#{@db.psql.db}::#{@opt.fns}").puts_blue + end + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Marshal Load',@fnc).puts_grey if @opt.act[:verbose][:set]==:on #% select_first_match=%{ SELECT metadata_and_text.tid @@ -138,15 +143,16 @@ module SiSU_DbImport if not file_exist t_d=[] # transaction_data t_d << db_import_metadata - t_d << db_import_documents(@dal_array) - t_d << db_import_urls(@dal_array,@fnc) #import OID on/off + t_d << db_import_documents(@ao_array) + t_d << db_import_urls(@ao_array,@fnc) #import OID on/off t_d=t_d.flatten - if @opt.cmd =~/[MV]/ + if (@opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) puts @conn.class if defined? @conn.class puts @conn.driver_name if defined? @conn.driver_name puts @conn.driver if defined? @conn.driver end - begin + begin #% sql if @sql_type=~/sqlite/ @conn.transaction do |conn| t_d.each do |sql| @@ -178,7 +184,7 @@ module SiSU_DbImport sql=File.new(sqlfn,'w') t_d.each {|i| sql.puts i} p sqlfn - if @opt.cmd =~/M/ + if @opt.act[:maintenance][:set]==:on puts sql p @conn.methods.sort puts "#{__FILE__}:#{__LINE__}" @@ -191,7 +197,7 @@ module SiSU_DbImport sql=File.new(sqlfn,'w') t_d.each {|i| sql.puts i} p sqlfn - if @opt.cmd =~/M/ + if @opt.act[:maintenance][:set]==:on puts sql p @conn.methods.sort puts "#{__FILE__}:#{__LINE__}" @@ -230,7 +236,11 @@ module SiSU_DbImport book_idx_str end def db_import_metadata #% import documents - populate database - print %{ #{@cX.grey}import documents dbi_unit #{@cX.off} } if @opt.cmd =~/vVM/ + if (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) + print %{ #{@cX.grey}import documents dbi_unit #{@cX.off} } + end @tp={} @md=SiSU_Param::Parameters.new(@opt).get #% sisutxt & fulltxt @@ -259,10 +269,14 @@ module SiSU_DbImport end @@id_t=id_t if id_t rescue - puts "#{__FILE__} #{__LINE__}" if @opt.cmd =~/M/ + puts "#{__FILE__} #{__LINE__}" if @opt.act[:maintenance][:set]==:on end @@id_t+=1 #bug related, needs to be performed once at start of file, but consider moving, as, placed here it means program will fail if document header lacks @title: - puts %{\n#{@cX.grey}Processing file number#{@cX.off}: #{@cX.green}#{@@id_t}#{@@cX.off}} if @opt.cmd =~/vVM/ + if (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) + puts %{\n#{@cX.grey}Processing file number#{@cX.off}: #{@cX.green}#{@@id_t}#{@@cX.off}} + end end ################ CLEAR ############## SiSU_DbDBI::Test.new(self,@opt).verify #% import title names, filenames (tuple) @@ -270,12 +284,12 @@ module SiSU_DbImport tuple=t.tuple tuple end - def db_import_documents(dal_array) #% import documents - populate main database table, import into substantive database tables (tuple) + def db_import_documents(ao_array) #% import documents - populate main database table, import into substantive database tables (tuple) begin @col[:tid]=@@id_t @en,@en_ast,@en_pls,@tuple_array=[],[],[],[] @col[:en_a],@col[:en_z]=nil,nil - dal_array.each do |data| + ao_array.each do |data| data.obj.gsub!(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'\1') data.obj.gsub!(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'\1') data.obj.gsub!(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'\1') @@ -296,8 +310,23 @@ module SiSU_DbImport notedata=data.obj.dup #% :headings 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,'','' + && (data.ln.inspect=~/[0-3]/) + ( + @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 body=SiSU_FormatShared::CSS_Format.new(@md,data).lev4_minus @@ -316,14 +345,28 @@ module SiSU_DbImport t=SiSU_DbTuple::LoadDocuments.new(@conn,@col,@opt,@file_maint) @tuple_array << t.tuple case @col[:lev] - when /1/; @col[:lv1]+=1 - when /2/; @col[:lv2]+=1 - when /3/; @col[:lv3]+=1 + when /0/ then @col[:lv0]+=1 + when /1/ then @col[:lv1]+=1 + when /2/ then @col[:lv2]+=1 + when /3/ then @col[:lv3]+=1 end @col[:lev]=@col[:plaintext]=@col[:body]='' 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,'','' + ( + @@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 @col[:lid]+=1 @@ -351,7 +394,20 @@ module SiSU_DbImport @col[:lev]=@col[:plaintext]=@col[:body]='' 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,'','' + ( + 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 \ && data.ln==5 \ && data.name #check data.name @@ -419,8 +475,21 @@ module SiSU_DbImport #% : else #% regular text @col[:lid]+=1 - txt='' - txt,@col[:ocn],@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.odv,data.osp,data.of,data.is,'',data.parent,'','' + ( + txt='' + txt,@col[:ocn], + @col[:ocnd],@col[:ocns], + @col[:t_of],@col[:t_is], + @col[:node],@col[:parent], + @col[:digest_clean],@col[:digest_all], + @col[:lev]= + data.obj,data.ocn, + data.odv,data.osp, + data.of,data.is, + '',data.parent, + '','', + 9 + ) @hname=if @col[:seg] \ and not @col[:seg].to_s.empty? @@hname=@col[:seg].to_s diff --git a/lib/sisu/v4/db_indexes.rb b/lib/sisu/v6/db_indexes.rb index 98cf28cb..f293012f 100644 --- a/lib/sisu/v4/db_indexes.rb +++ b/lib/sisu/v6/db_indexes.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/db_indexes.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/db_indexes.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -74,11 +75,15 @@ module SiSU_DbIndex end end def base - print "\n create documents common indexes\n" if @opt.cmd =~/[VM]/ + if (@opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) + print "\n create documents common indexes\n" + end sql_arr=[ %{CREATE INDEX idx_ocn ON doc_objects(ocn);}, %{CREATE INDEX idx_digest_clean ON doc_objects(digest_clean);}, %{CREATE INDEX idx_digest_all ON doc_objects(digest_all);}, + %{CREATE INDEX idx_lev0 ON doc_objects(lev0);}, %{CREATE INDEX idx_lev1 ON doc_objects(lev1);}, %{CREATE INDEX idx_lev2 ON doc_objects(lev2);}, %{CREATE INDEX idx_lev3 ON doc_objects(lev3);}, @@ -102,7 +107,10 @@ module SiSU_DbIndex conn_execute_array(sql_arr) end def text - print "\n create documents TEXT indexes\n" if @opt.cmd =~/[VM]/ + if (@opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) + print "\n create documents TEXT indexes\n" + end sql_arr=[ %{CREATE INDEX idx_clean ON doc_objects(clean);}, %{CREATE INDEX idx_endnote ON endnotes(clean);} diff --git a/lib/sisu/v4/db_load_tuple.rb b/lib/sisu/v6/db_load_tuple.rb index 68d05ec8..c4740259 100644 --- a/lib/sisu/v4/db_load_tuple.rb +++ b/lib/sisu/v6/db_load_tuple.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/db_load_tuple.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/db_load_tuple.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -68,50 +69,46 @@ module SiSU_DbTuple def initialize(conn,col,opt,file_maint) @conn,@col,@opt,@file_maint=conn,col,opt,file_maint @col[:lev]=@col[:lev].to_i - unless @col[:lev]=~/^[1-6]/ \ - or @col[:lev]==1 \ - or @col[:lev]==2 \ - or @col[:lev]==3 \ - or @col[:lev]==4 \ - or @col[:lev]==5 \ - or @col[:lev]==6 #changed from \d+ ?? - @col[:lev]=0 + unless @col[:lev].inspect=~/^[0-6]/ \ + or @col[:lev]==0..6 + @col[:lev]=9 end @col[:ocn]=0 unless @col[:ocn].inspect=~/\d+/ - @cX=SiSU_Screen::Ansi.new(@opt.cmd).cX + @cX=SiSU_Screen::Ansi.new(@opt.act[:color_state][:set]).cX end def tuple #% import line sql_entry=if @col[:en_a] - "INSERT INTO doc_objects (lid, metadata_tid, lev, lev_an, clean, body, book_idx, ocn, ocnd, ocns, seg, lev1, lev2, lev3, lev4, lev5, lev6, en_a, en_z, t_of, t_is, node, parent, digest_clean, digest_all) " + - "VALUES (#{@col[:lid]}, #{@col[:tid]}, #{@col[:lev]}, '#{@col[:lev_an]}', '#{@col[:plaintext]}', '#{@col[:body]}', '#{@col[:book_idx]}', '#{@col[:ocn]}', '#{@col[:ocnd]}', '#{@col[:ocns]}', '#{@col[:seg]}', '#{@col[:lv1]}', '#{@col[:lv2]}', '#{@col[:lv3]}', '#{@col[:lv4]}', '#{@col[:lv5]}', '#{@col[:lv6]}', '#{@col[:en_a]}', '#{@col[:en_z]}', '#{@col[:t_of]}', '#{@col[:t_is]}', '#{@col[:node]}', '#{@col[:parent]}', '#{@col[:digest_clean]}', '#{@col[:digest_all]}');" + "INSERT INTO doc_objects (lid, metadata_tid, lev, lev_an, clean, body, book_idx, ocn, ocnd, ocns, seg, lev0, lev1, lev2, lev3, lev4, lev5, lev6, en_a, en_z, t_of, t_is, node, parent, digest_clean, digest_all) " + + "VALUES (#{@col[:lid]}, #{@col[:tid]}, #{@col[:lev]}, '#{@col[:lev_an]}', '#{@col[:plaintext]}', '#{@col[:body]}', '#{@col[:book_idx]}', '#{@col[:ocn]}', '#{@col[:ocnd]}', '#{@col[:ocns]}', '#{@col[:seg]}', '#{@col[:lv0]}', '#{@col[:lv1]}', '#{@col[:lv2]}', '#{@col[:lv3]}', '#{@col[:lv4]}', '#{@col[:lv5]}', '#{@col[:lv6]}', '#{@col[:en_a]}', '#{@col[:en_z]}', '#{@col[:t_of]}', '#{@col[:t_is]}', '#{@col[:node]}', '#{@col[:parent]}', '#{@col[:digest_clean]}', '#{@col[:digest_all]}');" else - "INSERT INTO doc_objects (lid, metadata_tid, lev, lev_an, clean, body, book_idx, ocn, ocnd, ocns, seg, lev1, lev2, lev3, lev4, lev5, lev6, t_of, t_is, node, parent, digest_clean, digest_all) " + - "VALUES (#{@col[:lid]}, #{@col[:tid]}, #{@col[:lev]}, '#{@col[:lev_an]}', '#{@col[:plaintext]}', '#{@col[:body]}', '#{@col[:book_idx]}', '#{@col[:ocn]}', '#{@col[:ocnd]}', '#{@col[:ocns]}', '#{@col[:seg]}', '#{@col[:lv1]}', '#{@col[:lv2]}', '#{@col[:lv3]}', '#{@col[:lv4]}', '#{@col[:lv5]}', '#{@col[:lv6]}', '#{@col[:t_of]}', '#{@col[:t_is]}', '#{@col[:node]}', '#{@col[:parent]}', '#{@col[:digest_clean]}', '#{@col[:digest_all]}');" + "INSERT INTO doc_objects (lid, metadata_tid, lev, lev_an, clean, body, book_idx, ocn, ocnd, ocns, seg, lev0, lev1, lev2, lev3, lev4, lev5, lev6, t_of, t_is, node, parent, digest_clean, digest_all) " + + "VALUES (#{@col[:lid]}, #{@col[:tid]}, #{@col[:lev]}, '#{@col[:lev_an]}', '#{@col[:plaintext]}', '#{@col[:body]}', '#{@col[:book_idx]}', '#{@col[:ocn]}', '#{@col[:ocnd]}', '#{@col[:ocns]}', '#{@col[:seg]}', '#{@col[:lv0]}', '#{@col[:lv1]}', '#{@col[:lv2]}', '#{@col[:lv3]}', '#{@col[:lv4]}', '#{@col[:lv5]}', '#{@col[:lv6]}', '#{@col[:t_of]}', '#{@col[:t_is]}', '#{@col[:node]}', '#{@col[:parent]}', '#{@col[:digest_clean]}', '#{@col[:digest_all]}');" end - if @opt.cmd =~/M/ - if @opt.cmd =~/V/ + if @opt.act[:verbose_plus][:set]==:on + if @opt.act[:maintenance][:set]==:on puts @file_maint.inspect puts sql_entry end @file_maint.puts sql_entry else - if @opt.cmd =~/V/ + if @opt.act[:verbose_plus][:set]==:on puts sql_entry @file_maint.puts sql_entry end end - if @opt.cmd =~/v/ - if @col[:lev].inspect =~/[12356789]/ + if @opt.act[:verbose][:set]==:on + if @col[:lev].inspect =~/[0-356]/ lev=case @col[:lev].inspect - when /1/; ':A' - when /2/; ':B' - when /3/; ':C' - when /5/; ' 2' - when /6/; ' 3' + when /0/ then ':A' + when /1/ then ':B' + when /2/ then ':C' + when /3/ then ':D' + when /5/ then ' 2' + when /6/ then ' 3' end - puts %{#{lev}>\t#{@col[:lv1]}\t#{@col[:lv2]}\t#{@col[:lv3]}\t#{@col[:lv4]}\t#{@col[:lv5]}\t#{@col[:lv6]}\t#{@col[:ocn]}\t#{@col[:node]}\t#{@col[:ocns]}} + puts %{#{lev}>\t#{@col[:lv0]}\t#{@col[:lv1]}\t#{@col[:lv2]}\t#{@col[:lv3]}\t#{@col[:lv4]}\t#{@col[:lv5]}\t#{@col[:lv6]}\t#{@col[:ocn]}\t#{@col[:node]}\t#{@col[:ocns]}} elsif @col[:lev].inspect =~/[4]/ - puts %{ #{@cX.green}1>#{@cX.off}\t#{@col[:lv1]}\t#{@col[:lv2]}\t#{@col[:lv3]}\t#{@col[:lv4]}\t#{@col[:lv5]}\t#{@col[:lv6]}\t#{@col[:ocn]}\t#{@col[:node]}\t#{@col[:ocns]}\t#{@col[:seg]}} + puts %{ #{@cX.green}1>#{@cX.off}\t#{@col[:lv0]}\t#{@col[:lv1]}\t#{@col[:lv2]}\t#{@col[:lv3]}\t#{@col[:lv4]}\t#{@col[:lv5]}\t#{@col[:lv6]}\t#{@col[:ocn]}\t#{@col[:node]}\t#{@col[:ocns]}\t#{@col[:seg]}} end end sql_entry @@ -283,11 +280,13 @@ tid) #{@tp.column.links.tuple[1]} #{@id} );" - if @md.opt.cmd =~/M/ + if @md.opt.act[:maintenance][:set]==:on puts "maintenance mode on: creating sql transaction file (for last transaction set (document) only):\n\t#{@file_maint.inspect}" @file_maint.puts sql_entry else - @file_maint.puts sql_entry if @md.opt.cmd =~/V/ + if @md.opt.act[:verbose_plus][:set]==:on + @file_maint.puts sql_entry + end end sql_entry end @@ -299,10 +298,12 @@ tid) def tuple sql_entry="INSERT INTO urls (#{@f[:txt]} #{@f[:html_toc]} #{@f[:html_doc]} #{@f[:xhtml]} #{@f[:xml_sax]} #{@f[:xml_dom]} #{@f[:odf]} #{@f[:pdf_p]} #{@f[:pdf_l]} #{@f[:concordance]} #{@f[:latex_p]} #{@f[:latex_l]} #{@f[:manifest]} #{@f[:digest]} #{@f[:markup]} #{@f[:sisupod]} metadata_tid) " + "VALUES (#{@u[:txt]} #{@u[:html_toc]} #{@u[:html_doc]} #{@u[:xhtml]} #{@u[:xml_sax]} #{@u[:xml_dom]} #{@u[:odf]} #{@u[:pdf_p]} #{@u[:pdf_l]} #{@u[:concordance]} #{@u[:latex_p]} #{@u[:latex_l]} #{@u[:manifest]} #{@u[:digest]} #{@u[:markup]} #{@u[:sisupod]} #{@id});" - if @opt.cmd =~/M/ + if @opt.act[:maintenance][:set]==:on @file_maint.puts sql_entry else - @file_maint.puts sql_entry if @opt.cmd =~/V/ + if @opt.act[:verbose_plus][:set]==:on + @file_maint.puts sql_entry + end end sql_entry end @@ -314,10 +315,12 @@ tid) def tuple sql_entry="INSERT INTO #{@en[:type]} (nid, document_lid, nr, clean, body, ocn, ocnd, ocns, metadata_tid, digest_clean) " + "VALUES ('#{@en[:id]}', '#{@en[:lid]}', '#{@en[:nr]}', '#{@en[:txt]}', '#{@en[:body]}', '#{@en[:ocn]}', '#{@en[:ocnd]}', '#{@en[:ocns]}', '#{@en[:id_t]}', '#{@en[:hash]}');" - if @opt.cmd =~/M/ + if @opt.act[:maintenance][:set]==:on @file_maint.puts sql_entry else - @file_maint.puts sql_entry if @opt.cmd =~/V/ + if @opt.act[:verbose_plus][:set]==:on + @file_maint.puts sql_entry + end end sql_entry end diff --git a/lib/sisu/v4/db_remove.rb b/lib/sisu/v6/db_remove.rb index c402f959..650c84a2 100644 --- a/lib/sisu/v4/db_remove.rb +++ b/lib/sisu/v6/db_remove.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/db_remove.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/db_remove.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -112,11 +113,15 @@ module SiSU_DbRemove @conn.execute(s) end end - if @opt.cmd =~/M/ - @file.puts sql_entry if @opt.cmd =~/M/ + if @opt.act[:maintenance][:set]==:on + @file.puts sql_entry end else - SiSU_Screen::Ansi.new(@opt.cmd,"no such file in database #{@db.psql.db}::#{@opt.fns}").puts_grey if @opt.cmd =~/vVM/ + if (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) + SiSU_Screen::Ansi.new(@opt.cmd,"no such file in database #{@db.psql.db}::#{@opt.fns}").puts_grey + end end end end diff --git a/lib/sisu/v4/db_select.rb b/lib/sisu/v6/db_select.rb index f6d07030..56b424d7 100644 --- a/lib/sisu/v4/db_select.rb +++ b/lib/sisu/v6/db_select.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/db_select.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/db_select.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -94,7 +95,7 @@ module SiSU_DbSelect file=if @opt.inspect =~/M/ if @opt.fns and not @opt.fns.empty? @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/ + puts "\n#{@env.processing_path.sqlite}/#{@opt.fns}.sql" if @sql_type =~/sqlite/ and @opt.act[:maintenance][:set]==:on @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+') @@ -172,21 +173,21 @@ module SiSU_DbSelect db_exist? @sdb_import.marshal_load tell=case @sql_type - when /sqlite/; SiSU_Screen::Ansi.new(@opt.cmd,"sqlite3 #{@db.sqlite.db} database?") - when /pg/; SiSU_Screen::Ansi.new(@opt.cmd,"pgaccess or psql #{@db.psql.db} database?") + when /sqlite/ then SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"sqlite3 #{@db.sqlite.db} database?") + when /pg/ then SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"pgaccess or psql #{@db.psql.db} database?") else '???' end - tell.puts_grey if @opt.cmd =~/v/ + tell.puts_grey if @opt.act[:verbose][:set]==:on when /^--update$/ db_exist? @sdb_remove_doc.remove @sdb_import.marshal_load tell=case @sql_type - when /sqlite/; SiSU_Screen::Ansi.new(@opt.cmd,"sqlite3 #{@db.sqlite.db} database?") - when /pg/; SiSU_Screen::Ansi.new(@opt.cmd,"pgaccess or psql #{@db.psql.db} database?") + when /sqlite/ then SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"sqlite3 #{@db.sqlite.db} database?") + when /pg/ then SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"pgaccess or psql #{@db.psql.db} database?") else '???' end - tell.puts_grey if @opt.cmd =~/v/ + tell.puts_grey if @opt.act[:verbose][:set]==:on when /^--remove$/ db_exist? @sdb_remove_doc.remove @@ -206,14 +207,14 @@ module SiSU_DbSelect when /^--(?:v\d+|dev)$/ else end - if @opt.cmd =~/M/ \ + if @opt.act[:maintenance][:set]==:on \ and @opt.cmd =~/d/ puts @job end end if @opt.act[:psql][:set]==:on \ and @opt.mod.inspect !~/--(?:createdb|init(?:ialize)?|create(?:all)?|createtables?|recreate|cr(eate)?lex|cr(eate)?metadata|import|update|remove|index|droptable(s)?|dropindex(es)?|dropall|drop)/ - SiSU_Screen::Ansi.new(@opt.cmd,"--pg requires further instruction").warn unless @opt.cmd =~/[q]/ + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"--pg requires further instruction").warn unless @opt.act[:quiet][:set]==:on end begin rescue; @sdb.output_dir? diff --git a/lib/sisu/v4/db_sqltxt.rb b/lib/sisu/v6/db_sqltxt.rb index c6b0f858..1beaa321 100644 --- a/lib/sisu/v4/db_sqltxt.rb +++ b/lib/sisu/v6/db_sqltxt.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/db_sqltxt.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/db_sqltxt.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -83,14 +84,14 @@ module SiSU_DbText and not @md.creator.author.empty? 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/ + SiSU_Screen::Ansi.new('v','WARNING Document Author information missing; provide @creator: :author:',@md.fnb).warn unless @md.opt.act[:quiet][:set]==:on end if defined? @md.title \ and defined? @md.title.full \ and not @md.title.full.empty? 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/ + SiSU_Screen::Ansi.new('v','WARNING Document Title missing; provide @title:',@md.fnb).warn unless @md.opt.act[:quiet][:set]==:on end end s=s.gsub(/^(?:_[1-9]\*?|_\*)\s+/m,''). diff --git a/lib/sisu/v4/db_tests.rb b/lib/sisu/v6/db_tests.rb index 86b3ad97..9bfff975 100644 --- a/lib/sisu/v4/db_tests.rb +++ b/lib/sisu/v6/db_tests.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/db_tests.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/db_tests.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -64,14 +65,14 @@ module SiSU_DbTests class Test def initialize(info,opt) @ck,@opt=info,opt - unless @opt.cmd =~/q/ + unless @opt.act[:quiet][:set]==:on puts @ck.tp[:fns] if @ck.tp[:fns] and not @ck.tp[:fns].empty? puts @ck.tp[:title] if @ck.tp[:title] and not @ck.tp[:title].empty? puts @ck.tp[:creator] if @ck.tp[:creator] and not @ck.tp[:creator].empty? end end def verify - unless @opt.cmd =~/q/ + unless @opt.act[:quiet][:set]==:on puts @ck.tp[:fns].length.to_s + ' checklength ' + @ck.tp[:fns] if @ck.tp[:fns] and @ck.tp[:fns].length >@ck.lt_filename puts @ck.tp[:title].length.to_s + ' checklength ' + @ck.tp[:title] if @ck.tp[:title] and @ck.tp[:title].length >@ck.lt_title puts @ck.tp[:subtitle].length.to_s + ' checklength ' + @ck.tp[:subtitle] if @ck.tp[:subtitle] and @ck.tp[:subtitle].length >@ck.lt_subtitle diff --git a/lib/sisu/v4/dbi.rb b/lib/sisu/v6/dbi.rb index 3cd9dc85..6804ab97 100644 --- a/lib/sisu/v4/dbi.rb +++ b/lib/sisu/v6/dbi.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/dbi.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/dbi.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -66,7 +67,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) @@ -77,22 +78,22 @@ module SiSU_DBI or @opt.mod.inspect =~/--(pg(?:sql)?|(?:sq)?lite)/ @sql_type=if @opt.cmd=~/D/ \ or @opt.mod.inspect =~/--pg(?:sql)?/ - maintenance_check(@opt,__FILE__,__LINE__) if @opt.cmd.inspect =~/M/ + maintenance_check(@opt,__FILE__,__LINE__) if @opt.act[:maintenance][:set]==:on 'pg' elsif @opt.cmd =~/d/ \ and @opt.mod.inspect =~/--(?:db[=-])?pg(?:sql)?/ - maintenance_check(@opt,__FILE__,__LINE__) if @opt.cmd.inspect =~/M/ + maintenance_check(@opt,__FILE__,__LINE__) if @opt.act[:maintenance][:set]==:on 'pg' elsif @opt.cmd=~/d/ \ or @opt.mod.inspect =~/--(?:sq)?lite/ - maintenance_check(@opt,__FILE__,__LINE__) if @opt.cmd.inspect =~/M/ + maintenance_check(@opt,__FILE__,__LINE__) if @opt.act[:maintenance][:set]==:on 'sqlite' elsif @opt.cmd =~/d/ \ and @opt.mod.inspect =~/--(?:db[=-])?(?:sq)?lite/ - maintenance_check(@opt,__FILE__,__LINE__) if @opt.cmd.inspect =~/M/ + maintenance_check(@opt,__FILE__,__LINE__) if @opt.act[:maintenance][:set]==:on 'sqlite' else - maintenance_check(@opt,__FILE__,__LINE__) if @opt.cmd.inspect =~/M/ + maintenance_check(@opt,__FILE__,__LINE__) if @opt.act[:maintenance][:set]==:on 'sqlite' end end @@ -107,7 +108,7 @@ module SiSU_DBI @conn=@db.psql.conn_dbi rescue if @opt.mod.inspect=~/--(createall|create)/ - cX=SiSU_Screen::Ansi.new(@opt.cmd).cX + cX=SiSU_Screen::Ansi.new(@opt.act[:color_state][:set]).cX puts <<-WOK manually create the database: "#{cX.green}#{@db.db}#{cX.off}" if it does not yet exist #{cX.yellow}createdb #{@db.db}#{cX.off} @@ -126,10 +127,10 @@ manually create the database: "#{cX.green}#{@db.db}#{cX.off}" if it does not yet end def connect case @sql_type - when /pg/; read_psql - when /sqlite/; read_sqlite + when /pg/ then read_psql + when /sqlite/ then read_sqlite end - SiSU_Screen::Ansi.new(@opt.cmd,"DBI (#{@sql_type}) #{@opt.mod}",@opt.fno).dbi_title unless @opt.cmd =~/q/ + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"DBI (#{@sql_type}) #{@opt.mod}",@opt.fno).dbi_title unless @opt.act[:quiet][:set]==:on begin SiSU_DbDBI::Case.new(@opt,@conn,@sql_type).cases rescue diff --git a/lib/sisu/v4/dbi_discrete.rb b/lib/sisu/v6/dbi_discrete.rb index d96fbe13..b842c767 100644 --- a/lib/sisu/v4/dbi_discrete.rb +++ b/lib/sisu/v6/dbi_discrete.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/dbi_discrete.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/dbi_discrete.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -66,7 +67,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 @@ -79,7 +80,7 @@ module SiSU_DBI_Discrete #% database building if @opt.cmd =~/[d]/ \ or @opt.mod.inspect =~/--((?:sq)?lite)/ @sql_type='sqlite' - maintenance_check(@opt,__FILE__,__LINE__) if @opt.cmd.inspect =~/M/ + maintenance_check(@opt,__FILE__,__LINE__) if @opt.act[:maintenance][:set]==:on end @output_path=@md.file.output_path.sqlite_discrete.dir @filename=@md.file.base_filename.sqlite_discrete @@ -121,7 +122,7 @@ module SiSU_DBI_Discrete #% database building sdb_index=SiSU_DbDBI::Index.new(@opt,conn,@file,'sqlite') sdb.output_dir? begin - SiSU_Screen::Ansi.new(@opt.cmd,'SQLite',"[#{@opt.f_pth[:lng_is]}] #{@opt.fno}").green_title_hi unless @opt.cmd =~/q/ + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'SQLite',"[#{@opt.f_pth[:lng_is]}] #{@opt.fno}").green_title_hi unless @opt.act[:quiet][:set]==:on sdb.create_db sdb.create_table.metadata_and_text sdb.create_table.doc_objects @@ -133,8 +134,8 @@ module SiSU_DBI_Discrete #% database building db_exist?(db,conn) sdb_import=SiSU_DbDBI::Import.new(@opt,conn,@file_maint,'sqlite') sdb_import.marshal_load - tell=SiSU_Screen::Ansi.new(@opt.cmd,"sqlite3 #{db.sqlite.db} database?") - tell.puts_grey if @opt.cmd =~/v/ + tell=SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"sqlite3 #{db.sqlite.db} database?") + tell.puts_grey if @opt.act[:verbose][:set]==:on rescue SiSU_Errors::Rescued.new($!,$@,'-d').location do __LINE__.to_s + ':' + __FILE__ @@ -151,7 +152,7 @@ module SiSU_DBI_Discrete #% database building end def connect begin - SiSU_Screen::Ansi.new(@opt.cmd,"DBI (#{@sql_type}) #{@opt.mod}",@opt.fns).dbi_title unless @opt.cmd =~/q/ + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"DBI (#{@sql_type}) #{@opt.mod}",@opt.fns).dbi_title unless @opt.act[:quiet][:set]==:on @db.sqlite_discrete.conn_sqlite3 rescue SiSU_Errors::Rescued.new($!,$@,@cf,@opt.fns).location do @@ -166,7 +167,7 @@ module SiSU_DBI_Discrete #% database building file=if @opt.inspect =~/M/ if @opt.fns and not @opt.fns.empty? @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/ + puts "\n#{@env.processing_path.sqlite}/#{@opt.fns}.sql" if @sql_type =~/sqlite/ and @opt.act[:maintenance][:set]==:on @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+') diff --git a/lib/sisu/v4/defaults.rb b/lib/sisu/v6/defaults.rb index 69af0fa5..ca3c0c04 100644 --- a/lib/sisu/v4/defaults.rb +++ b/lib/sisu/v6/defaults.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/defaults.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/defaults.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -563,8 +564,8 @@ module SiSU_Viz if italics_list r=italics_list.dup x=case r - when /\/i$/; 'i' - else '' + when /\/i$/ then 'i' + else '' end r=r.gsub(/^\/(.+?)\/i?/,'\1'). gsub(/\(/,'(?:') # avoid need to escape use of brackets within regex provided @@ -584,8 +585,8 @@ module SiSU_Viz if bold_list r=bold_list.dup x=case r - when /\/i$/; 'i' - else '' + when /\/i$/ then 'i' + else '' end r.gsub(/^\/(.+?)\/i?/,'\1'). gsub(/\(/,'(?:') # avoid need to escape use of brackets within regex provided @@ -1198,12 +1199,12 @@ WOK end def dimensions case @papersize - when /a4/; a4 - when /letter/; letter - when /legal/; legal - when /b5/; b5 - when /a5/; a5 - else a4 + when /a4/ then a4 + when /letter/ then letter + when /legal/ then legal + when /b5/ then b5 + when /a5/ then a5 + else a4 end end end diff --git a/lib/sisu/v4/digests.rb b/lib/sisu/v6/digests.rb index 75a340b0..954185d9 100644 --- a/lib/sisu/v4/digests.rb +++ b/lib/sisu/v6/digests.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/digests.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/digests.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -75,15 +76,22 @@ module SiSU_DigestView end def read begin - @env,@md,@dal_array=@particulars.env,@particulars.md,@particulars.dal_array - unless @opt.cmd =~/q/ - tool=(@opt.cmd =~/[MVv]/) \ + @env,@md,@ao_array=@particulars.env,@particulars.md,@particulars.ao_array + unless @opt.act[:quiet][:set]==:on + tool=(@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) \ ? "#{@env.program.text_editor} file://#{@md.file.output_path.hash_digest.dir}/#{@md.file.base_filename.hash_digest}" : "[#{@opt.f_pth[:lng_is]}] #{@opt.fno}" - @opt.cmd=~/[MVvz]/ \ - ? SiSU_Screen::Ansi.new(@opt.cmd,"Document #{@dg} Digests",tool).green_hi_blue - : 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]/ + (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) \ + ? SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"Document #{@dg} Digests",tool).green_hi_blue + : SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"Document #{@dg} Digests",tool).green_title_hi + if @opt.act[:verbose_plus][:set]==:on \ + or @opt.act[:maintenance][:set]==:on + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],@opt.fns,"file://#{@md.file.output_path.hash_digest.dir}/#{@md.file.base_filename.hash_digest}").flow + end end SiSU_DigestView::Source::Scroll.new(@particulars).songsheet rescue @@ -100,7 +108,7 @@ module SiSU_DigestView @@description,@@ds[:digests],@@ds[:tree],@@ds[:summary],@@sc_info=[],[],[],[],[] def initialize(particulars) #data='',md='') @particulars=particulars - @data,@env,@md=@particulars.dal_array,@particulars.env,@particulars.md + @data,@env,@md=@particulars.ao_array,@particulars.env,@particulars.md SiSU_Env::FileOp.new(@md).mkdir @@dg ||=@env.digest.type @@dl ||=@env.digest.length @@ -113,28 +121,28 @@ module SiSU_DigestView def songsheet @@description,@@ds[:digests],@@ds[:tree],@@ds[:summary],@@sc_info=[],[],[],[],[] message_digest - dal_structure + ao_structure supplementary output end def description(f,e='') - puts f + e.to_s if @md.opt.cmd =~/V/ + puts f + e.to_s if @md.opt.act[:verbose_plus][:set]==:on @@description << f << e end def digests(f,e='') - puts f if @md.opt.cmd =~/V/ + puts f if @md.opt.act[:verbose_plus][:set]==:on @@ds[:digests] << f + "\n" end - def dal_structure_tree(f,e='') - puts f + e.to_s if @md.opt.cmd =~/V/ + def ao_structure_tree(f,e='') + puts f + e.to_s if @md.opt.act[:verbose_plus][:set]==:on @@ds[:tree] << f << e end - def dal_structure_summary(f,e='') - puts f + e.to_s if @md.opt.cmd =~/V/ + def ao_structure_summary(f,e='') + puts f + e.to_s if @md.opt.act[:verbose_plus][:set]==:on @@ds[:summary] << f << e end def rcinfo(f,e='') - puts f + e.to_s if @md.opt.cmd =~/V/ + puts f + e.to_s if @md.opt.act[:verbose_plus][:set]==:on @@sc_info << f << e end def output @@ -201,7 +209,7 @@ module SiSU_DigestView elsif FileTest.file?("#{@env.path.image_source_include}/#{i}") @env.path.image_source_include else - SiSU_Screen::Ansi.new(@md.opt.cmd,"ERROR - image:", %{"#{i}" missing}, "search locations: #{@env.path.image_source_include_local}, #{@env.path.image_source_include_remote} and #{@env.path.image_source_include}").error2 unless @md.opt.cmd =~/q/ + SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],"ERROR - image:", %{"#{i}" missing}, "search locations: #{@env.path.image_source_include_local}, #{@env.path.image_source_include_remote} and #{@env.path.image_source_include}").error2 unless @md.opt.act[:quiet][:set]==:on nil end @img << /\S+\.(png|jpg|gif)/.match(i)[1] @@ -295,7 +303,7 @@ module SiSU_DigestView description("Document Digests\n") description(a) end - def dal_structure + def ao_structure data=@data endnotes=nil data.each do |t_o| @@ -323,46 +331,46 @@ module SiSU_DigestView end l=Hash.new(0) ocn=nil - dal_structure_tree("------------\n") - dal_structure_tree("document structure[*]\n") + ao_structure_tree("------------\n") + ao_structure_tree("document structure[*]\n") data.each do |t_o| if t_o.is==:heading x=case t_o.ln - when 1; l[1] +=1 #fix Mx[:lv_o] + when 1 then l[1] +=1 #fix Mx[:lv_o] ' '*0 << ':A' - when 2; l[2] +=1 #fix Mx[:lv_o] + when 2 then l[2] +=1 #fix Mx[:lv_o] ' '*1 << ':B' - when 3; l[3] +=1 #fix Mx[:lv_o] + when 3 then l[3] +=1 #fix Mx[:lv_o] ' '*2 << ':C' - when 4; l[4] +=1 #fix Mx[:lv_o] + when 4 then l[4] +=1 #fix Mx[:lv_o] ' '*3 << '1' - when 5; l[5] +=1 #fix Mx[:lv_o] + when 5 then l[5] +=1 #fix Mx[:lv_o] ' '*4 << '2' - when 6; l[6] +=1 #fix Mx[:lv_o] + when 6 then l[6] +=1 #fix Mx[:lv_o] ' '*5 << '3' else nil end end 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? + ao_structure_tree("#{x}\n") if x and not x.empty? end - dal_structure_tree(" [*] heading levels\n") - dal_structure_summary("------------\n") - dal_structure_summary("document structure[*]\n") + ao_structure_tree(" [*] heading levels\n") + ao_structure_summary("------------\n") + ao_structure_summary("document structure[*]\n") [0,1,2,3,4,5,6].each do |y| v=case y - when 1; ':A' - when 2; ':B' - when 3; ':C' - when 4; '1 ' - when 5; '2 ' - when 6; '3 ' + when 1 then ':A' + when 2 then ':B' + when 3 then ':C' + when 4 then '1 ' + when 5 then '2 ' + when 6 then '3 ' end - dal_structure_summary("#{v} = #{l[y]}\n") if l[y] > 0 + ao_structure_summary("#{v} = #{l[y]}\n") if l[y] > 0 end - dal_structure_summary("objects (ocn) = #{ocn}\n") - dal_structure_summary("endnotes = #{endnotes}\n") - dal_structure_summary(" [*] number of headers (@) and of each heading level (:A to :C and 1 to 3)\n") + ao_structure_summary("objects (ocn) = #{ocn}\n") + ao_structure_summary("endnotes = #{endnotes}\n") + ao_structure_summary(" [*] number of headers (@) and of each heading level (:A to :C and 1 to 3)\n") end def supplementary if defined? @md.sc_number \ diff --git a/lib/sisu/v4/embedded.rb b/lib/sisu/v6/embedded.rb index c36af0e5..7a72cac0 100644 --- a/lib/sisu/v4/embedded.rb +++ b/lib/sisu/v6/embedded.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/embedded.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/embedded.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -93,7 +94,10 @@ module SiSU_Embedded ldest=@env.path.output img_dir="#{@env.path.output}/_sisu/image" @rhost.each do |remote_conn| - if @md.opt.cmd.inspect =~/[vVMR]/ \ + if (@md.opt.act[:verbose][:set]==:on \ + || @md.opt.act[:verbose_plus][:set]==:on \ + || @md.opt.act[:maintenance][:set]==:on \ + || @md.opt.act[:rsync][:set]==:on) \ and FileTest.directory?(src) 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}/") @@ -112,12 +116,15 @@ module SiSU_Embedded ldest="#{@env.path.webserv}/#{@env.path.stub_pwd}/_sisu/mm/audio" @rhost.each do |remote_conn| rdest="#{remote_conn[:name]}/#{@env.path.stub_pwd}/_sisu/mm/audio" - if @md.opt.cmd.inspect =~/[vVMR]/ \ + if (@md.opt.act[:verbose][:set]==:on \ + || @md.opt.act[:verbose_plus][:set]==:on \ + || @md.opt.act[:maintenance][:set]==:on \ + || @md.opt.act[:rsync][:set]==:on) \ and FileTest.directory?(src) FileUtils::mkdir_p(ldest) unless FileTest.directory?(ldest) src_ec="#{src}/" + @md.ec[:audio].join(" #{src}/") SiSU_Env::SystemCall.new(src_ec,"#{ldest}/.",'q').rsync - if @md.opt.cmd.inspect =~/R/ #rsync to remote audio directory + if @md.opt.act[:rsync][:set]==:on #rsync to remote audio directory SiSU_Env::SystemCall.new(src_ec,"#{rdest}/.",'q').rsync end end @@ -129,12 +136,15 @@ module SiSU_Embedded ldest="#{@env.path.webserv}/#{@env.path.stub_pwd}/_sisu/mm/video" @rhost.each do |remote_conn| rdest="#{remote_conn[:name]}/#{@env.path.stub_pwd}/_sisu/mm/video" - if @md.opt.cmd.inspect =~/[vVMR]/ \ + if (@md.opt.act[:verbose][:set]==:on \ + || @md.opt.act[:verbose_plus][:set]==:on \ + || @md.opt.act[:maintenance][:set]==:on \ + || @md.opt.act[:rsync][:set]==:on) \ and FileTest.directory?(src) FileUtils::mkdir_p(ldest) unless FileTest.directory?(ldest) src_ec="#{src}/" + @md.ec[:multimedia].join(" #{src}/") SiSU_Env::SystemCall.new(src_ec,"#{ldest}/.",'q').rsync - if @md.opt.cmd.inspect =~/R/ #rsync to remote video directory + if @md.opt.act[:rsync][:set]==:on #rsync to remote video directory SiSU_Env::SystemCall.new(src_ec,"#{rdest}/.",'q').rsync end end diff --git a/lib/sisu/v4/errors.rb b/lib/sisu/v6/errors.rb index fc9726d4..fb5117ec 100644 --- a/lib/sisu/v4/errors.rb +++ b/lib/sisu/v6/errors.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/errors.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/errors.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> diff --git a/lib/sisu/v4/git.rb b/lib/sisu/v6/git.rb index f2291ba9..fbcfcf57 100644 --- a/lib/sisu/v4/git.rb +++ b/lib/sisu/v6/git.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/git.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/git.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -62,7 +63,7 @@ module SiSU_Git require_relative 'param' # param.rb require_relative 'sysenv' # sysenv.rb - require_relative 'dal' # dal.rb + require_relative 'ao' # ao.rb class Source def initialize(opt) @opt=opt @@ -81,12 +82,6 @@ module SiSU_Git fnt=@opt.fns[m,2] end git_path_fnb=@env.processing_path.git + '/' + fnb - #unless @opt.cmd =~/q/ - # @opt.cmd=~/[MVvz]/ \ - # ? SiSU_Screen::Ansi.new(@opt.cmd,'Git path',@git_path[:fnb]).green_hi_blue \ - # : SiSU_Screen::Ansi.new(@opt.cmd,'Git path',@git_path[:fnb]).green_title_hi - # SiSU_Screen::Ansi.new(@opt.cmd,"Git path","#{@opt.fns} -> #{@git_path[:fnb]}").warn if @opt.cmd =~/[MVv]/ - #end lng=(@md.opt.lng) ? (@md.opt.lng) : (@md.i18n[0]) @git_path={ fnb: git_path_fnb, @@ -99,7 +94,7 @@ module SiSU_Git video: git_path_fnb + '/' + Gt[:sisupod] + '/' + Gt[:video], conf: git_path_fnb + '/' + Gt[:sisupod] + '/' + Gt[:conf] } - SiSU_DAL::Source.new(@opt).read # -m + SiSU_AO::Source.new(@opt).read # -m end def create_file_structure_git make_dir_fnb @@ -113,11 +108,17 @@ module SiSU_Git #if program_found? # git_commit #end - unless @opt.cmd =~/q/ - @opt.cmd=~/[MVvz]/ \ - ? SiSU_Screen::Ansi.new(@opt.cmd,'Git path',@git_path[:fnb]).green_hi_blue - : SiSU_Screen::Ansi.new(@opt.cmd,'Git path',@git_path[:fnb]).green_title_hi - SiSU_Screen::Ansi.new(@opt.cmd,"Git path","#{@opt.fns} -> #{@git_path[:fnb]}").warn if @opt.cmd =~/[MVv]/ + unless @opt.act[:quiet][:set]==:on + (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) \ + ? SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Git path',@git_path[:fnb]).green_hi_blue + : SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Git path',@git_path[:fnb]).green_title_hi + if (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"Git path","#{@opt.fns} -> #{@git_path[:fnb]}").warn + end end end def program_found? @@ -190,9 +191,9 @@ module SiSU_Git def locate_parse_file composite_src=@opt.fns=~/\.ssm$/ ? true : false if composite_src \ - and @opt.cmd.inspect !~/m/ + and not @opt.act[:ao][:set]==:on ##SiSU_Assemble::Composite.new(@opt).read - #SiSU_DAL::Source.new(@opt).read # -m + #SiSU_AO::Source.new(@opt).read # -m "#{@env.processing_path.composite_file}/#{@opt.fnb}.ssm.sst" elsif composite_src "#{@env.processing_path.composite_file}/#{@opt.fnb}.ssm.sst" diff --git a/lib/sisu/v4/harvest.rb b/lib/sisu/v6/harvest.rb index 0b4dc4c2..9dfc34d2 100644 --- a/lib/sisu/v4/harvest.rb +++ b/lib/sisu/v6/harvest.rb @@ -10,7 +10,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -52,7 +53,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/v4/harvest.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/harvest.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -100,10 +101,10 @@ WOK def cases(opt,env) case opt.mod.inspect when/--harvest/i - css(opt) if opt.cmd.inspect =~/M/ + css(opt) if @opt.act[:maintenance][:set]==:on SiSU_HarvestAuthors::Songsheet.new(opt,env).songsheet SiSU_HarvestTopics::Songsheet.new(opt,env).songsheet - if opt.cmd.inspect =~/R/ + if @opt.act[:rsync][:set]==:on require_relative 'remote' # remote.rb SiSU_Remote::Put.new(opt).rsync_harvest end diff --git a/lib/sisu/v4/harvest_authors.rb b/lib/sisu/v6/harvest_authors.rb index a5f68cc7..4bbd1351 100644 --- a/lib/sisu/v4/harvest_authors.rb +++ b/lib/sisu/v6/harvest_authors.rb @@ -9,7 +9,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -51,7 +52,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/v4/harvest_authors.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/harvest_authors.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -197,8 +198,11 @@ module SiSU_HarvestAuthors file="#{harvest_pth}/authors.#{lng}.html" end FileUtils::mkdir_p(harvest_pth) unless FileTest.directory?(harvest_pth) - fileinfo=(@opt.cmd =~/[vVM]/) ? ("file://#{file}") : '' - SiSU_Screen::Ansi.new(@opt.cmd,"harvest authors (#{@opt.files.length} files)",fileinfo).dark_grey_title_hi unless @opt.cmd =~/q/ + fileinfo=(@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) \ + ? ("file://#{file}") : '' + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"harvest authors (#{@opt.files.length} files)",fileinfo).dark_grey_title_hi unless @opt.act[:quiet][:set]==:on @output[lng][:html]=File.new(file,'w') end end @@ -293,7 +297,7 @@ WOK end def html_head @the_idx.keys.each do |lng| - @output[lng][:html_mnt] << html_head_adjust(lng,'maintenance') if @opt.cmd.inspect =~/M/ + @output[lng][:html_mnt] << html_head_adjust(lng,'maintenance') if @opt.act[:maintenance][:set]==:on @output[lng][:html] << html_head_adjust(lng) end end @@ -307,7 +311,7 @@ WOK end a=a.join @the_idx.keys.each do |lng| - @output[lng][:html_mnt] << a if @opt.cmd.inspect =~/M/ + @output[lng][:html_mnt] << a if @opt.act[:maintenance][:set]==:on @output[lng][:html] << a end end diff --git a/lib/sisu/v4/harvest_topics.rb b/lib/sisu/v6/harvest_topics.rb index 09104f30..ce6e13c2 100644 --- a/lib/sisu/v4/harvest_topics.rb +++ b/lib/sisu/v6/harvest_topics.rb @@ -10,7 +10,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -52,7 +53,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/v4/harvest_topics.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/harvest_topics.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -150,7 +151,10 @@ module SiSU_HarvestTopics else { filename: filename, file: file, rough_idx: @idx_list, title: @fulltitle, author: creator, page: page, lang: lang } end else - p "missing required field in #{@filename} - [title]: <<#{@title}>>; [author]: <<#{@author_format}>>; [idx]: <<#{@idx_list}>>" if @opt.cmd.inspect =~/[VM]/ + if (@opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) + p "missing required field in #{@filename} - [title]: <<#{@title}>>; [author]: <<#{@author_format}>>; [idx]: <<#{@idx_list}>>" + end end idx_array[lang]=idx_array[lang].flatten idx_array @@ -472,10 +476,14 @@ module SiSU_HarvestTopics file="#{harvest_pth}/topics.#{lng}.html" end FileUtils::mkdir_p(harvest_pth) unless FileTest.directory?(harvest_pth) - fileinfo=(@opt.cmd =~/[vVM]/) ? ("file://#{file}") : '' - SiSU_Screen::Ansi.new(@opt.cmd,"harvest topics(#{@opt.files.length} files)",fileinfo).dark_grey_title_hi unless @opt.cmd =~/q/ + fileinfo=(@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) \ + ? ("file://#{file}") + : '' + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"harvest topics(#{@opt.files.length} files)",fileinfo).dark_grey_title_hi unless @opt.act[:quiet][:set]==:on @output[lng][:html]=File.new(file,'w') - if @opt.cmd.inspect =~/[M]/ + if @opt.act[:maintenance][:set]==:on @output[lng][:html_mnt]=File.new("#{@env.path.pwd}/topics.html",'w') end end @@ -651,7 +659,7 @@ WOK end def html_head @the_idx.keys.each do |lng| - @output[lng][:html_mnt] << html_head_adjust(lng,'maintenance') if @opt.cmd.inspect =~/M/ + @output[lng][:html_mnt] << html_head_adjust(lng,'maintenance') if @opt.act[:maintenance][:set]==:on @output[lng][:html] << html_head_adjust(lng) end end @@ -665,7 +673,7 @@ WOK end a=a.join @the_idx.keys.each do |lng| - @output[lng][:html_mnt] << a if @opt.cmd.inspect =~/M/ + @output[lng][:html_mnt] << a if @opt.act[:maintenance][:set]==:on @output[lng][:html] << a end end diff --git a/lib/sisu/v4/html.rb b/lib/sisu/v6/html.rb index 7acb279a..8a909677 100644 --- a/lib/sisu/v4/html.rb +++ b/lib/sisu/v6/html.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/html.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/html.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -95,14 +96,21 @@ module SiSU_HTML primary_output_file=(@opt.act[:html_seg][:set]==:on) \ ? (@md.file.output_path.html_seg.dir + '/' + @md.file.base_filename.html_segtoc) : (@md.file.output_path.html_scroll.dir + '/' + @md.file.base_filename.html_scroll) - unless @opt.cmd =~/q/ - tool=(@opt.cmd =~/[MVvz]/) \ + unless @opt.act[:quiet][:set]==:on + tool=(@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) \ ? ("#{@env.program.web_browser} file://#{primary_output_file}") : ("[#{@opt.f_pth[:lng_is]}] #{@opt.fno}") - @opt.cmd=~/[MVvz]/ \ - ? SiSU_Screen::Ansi.new(@opt.cmd,'HTML',tool).green_hi_blue - : SiSU_Screen::Ansi.new(@opt.cmd,'HTML',tool).green_title_hi - SiSU_Screen::Ansi.new(@opt.cmd,@opt.fns,"file://#{primary_output_file}").flow if @opt.cmd =~/[MV]/ + (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) \ + ? SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'HTML',tool).green_hi_blue + : SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'HTML',tool).green_title_hi + if (@opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],@opt.fns,"file://#{primary_output_file}").flow + end end data=nil tuned_file_array=SiSU_HTML::Source::HTML_Environment.new(@particulars).tuned_file_instructions @@ -128,7 +136,8 @@ module SiSU_HTML __LINE__.to_s + ':' + __FILE__ end ensure - unless @opt.cmd =~/[MV]/ #check maintenance flag + unless (@opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) texfiles=Dir["#{@env.processing_path.tune}/#{@opt.fns}*"] texfiles.each do |f| if FileTest.file?(f) @@ -153,9 +162,9 @@ module SiSU_HTML @env,@css=particulars.env,SiSU_Style::CSS.new end def tuned_file_instructions - @tell=SiSU_Screen::Ansi.new(@md.opt.cmd) - dal_array=@particulars.dal_array # dal file drawn here - tuned_file_array=SiSU_HTML_Tune::Tune.new(dal_array,@md).songsheet + @tell=SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set]) + ao_array=@particulars.ao_array # ao file drawn here + tuned_file_array=SiSU_HTML_Tune::Tune.new(ao_array,@md).songsheet tuned_file_array end end @@ -232,10 +241,14 @@ module SiSU_HTML def initialize(md=nil,data='') @data,@md=data,md @vz=SiSU_Viz::Defaults.new - @tell=SiSU_Screen::Ansi.new(@md.opt.cmd) if @md + @tell=SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set]) if @md end def songsheet #extracts toc for scroll & seg - SiSU_Screen::Ansi.new(@md.opt.cmd,'Toc').txt_grey if @md.opt.cmd =~/[MVv]/ + if (@md.opt.act[:verbose][:set]==:on \ + || @md.opt.act[:verbose_plus][:set]==:on \ + || @md.opt.act[:maintenance][:set]==:on) + SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],'Toc').txt_grey + end toc=nil @@firstseg=nil @@toc={ seg: [], seg_mini: [], scr: [] } @@ -246,12 +259,13 @@ module SiSU_HTML toc=if dob_toc.is ==:heading \ || dob.is==:heading_insert toc=case dob_toc.ln - 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 + when 0 then SiSU_HTML::Source::Toc.new(@md,dob_toc).level_0 + when 1 then SiSU_HTML::Source::Toc.new(@md,dob_toc).level_1 + when 2 then SiSU_HTML::Source::Toc.new(@md,dob_toc).level_2 + when 3 then SiSU_HTML::Source::Toc.new(@md,dob_toc).level_3 + when 4 then SiSU_HTML::Source::Toc.new(@md,dob_toc).level_4 + when 5 then SiSU_HTML::Source::Toc.new(@md,dob_toc).level_5 + when 6 then SiSU_HTML::Source::Toc.new(@md,dob_toc).level_6 else nil end end @@ -322,6 +336,29 @@ WOK @@toc[:seg_mini] << format_head_toc.mini_concordance end # <-- not used + def level_0 + dob=@data + linkname,link=dob.obj.strip,dob.ocn + if link \ + and link !~/#/ #% keep eye on link + SiSU_HTML_Format::ParagraphNumber.new(@md,link) + end + title=linkname + toc={} + txt_obj={ txt: title } + format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) + toc[:seg]=format_toc.lev0 + toc[:seg_mini]=format_toc.mini_lev0 + title=if dob.ocn ==0 then linkname + else + @@toc[:scr] << '<br />' + %{<b><a href="##{dob.ocn}">#{linkname}</a></b>} + end + txt_obj={ txt: title } + format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) + toc[:scr]=format_toc.lev0 + toc + end def level_1 dob=@data linkname,link=dob.obj.strip,dob.ocn @@ -329,7 +366,7 @@ WOK and link !~/#/ #% keep eye on link SiSU_HTML_Format::ParagraphNumber.new(@md,link) end - title=if dob.obj !~/^Metadata$/; linkname + title=if dob.obj !~/^Metadata$/ then linkname else link='metadata' %{<b><a href="#{link}#{@md.lang_code_insert}#{Sfx[:html]}">#{linkname}</a></b>} @@ -357,14 +394,13 @@ WOK end else @@toc[:scr] << '<br />' - link=(dob.ln) \ - ? dob.ln - : '' - %{<b><a href="##{link}">#{linkname}</a></b>} + %{<b><a href="##{dob.ocn}">#{linkname}</a></b>} end txt_obj={ txt: title } format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) - toc[:scr]=if dob.obj =~/^Metadata$/; '' + toc[:scr]=if dob.obj =~/^Metadata$/ then '' + elsif txt_obj[:txt] =~/<a href="#">/ + format_toc.lev1.gsub(/<a href="#">|<\/a>/,'') else format_toc.lev1 end toc @@ -386,7 +422,10 @@ WOK title=%{#{p_num.goto}#{linkname}</a>} txt_obj={ txt: title } format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) - toc[:scr]=format_toc.lev2 + toc[:scr]=if txt_obj[:txt] =~/<a href="#">/ + format_toc.lev2.gsub(/<a href="#">|<\/a>/,'') + else format_toc.lev2 + end end toc end @@ -407,7 +446,10 @@ WOK title=%{#{p_num.goto}#{linkname}</a>} txt_obj={ txt: title } format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) - toc[:scr]=format_toc.lev3 + toc[:scr]=if txt_obj[:txt] =~/<a href="#">/ + format_toc.lev3.gsub(/<a href="#">|<\/a>/,'') + else format_toc.lev3 + end end toc end @@ -541,13 +583,16 @@ WOK def in_common toc_shared=[] @segtoc=[] - SiSU_Screen::Ansi.new(@md.opt.cmd,'Scroll & Segtoc').txt_grey if @md.opt.cmd =~/[MVv]/ + if (@md.opt.act[:verbose][:set]==:on \ + || @md.opt.act[:verbose_plus][:set]==:on \ + || @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_HTML_Format::HeadToc.new(@md) dochead=format_head_toc.head 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 << dochead + @segtoc << format_head_toc.head if @make.build.html_top_band? toc_shared << format_head_toc.scroll_head_navigation_band end @@ -610,8 +655,7 @@ WOK #Segtoc tail added here @segtoc << "</p>\n" #bugfix sort later DEBUGNOW @segtoc << @seg_toc_band_bottom - 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 << format_head_toc.seg_navigation_tail << format_head_toc.html_close @segtoc=@segtoc.flatten.compact #watch if @md.opt.act[:html_seg][:set]==:on SiSU_HTML::Source::Output.new(@segtoc,@md).segtoc diff --git a/lib/sisu/v4/html_format.rb b/lib/sisu/v6/html_format.rb index e69e3de3..bf1703a1 100644 --- a/lib/sisu/v4/html_format.rb +++ b/lib/sisu/v6/html_format.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/html_format.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/html_format.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -93,7 +94,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) @@ -904,14 +905,14 @@ 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_DAL_DocumentStructure/ + elsif t_o.class.inspect =~/^(?:#<)?SiSU_AO_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) else - if @md.opt.cmd =~/M/ + if @md.opt.act[:maintenance][:set]==:on p t_o.class p caller end @@ -1029,7 +1030,7 @@ WOK para_form_css(tag,attrib) end def heading_normal(tag,attrib) - section_break=(tag=~/h[1-4]/) \ + section_break=(tag=~/h[1-5]/) \ ? '<br /><hr width=90% /><br />' : '' %{#{section_break} @@ -1044,6 +1045,9 @@ WOK def heading_body heading_normal('p','norm') end + def heading_body0 + heading_normal('h1','norm') + end def heading_body1 heading_normal('h1','norm') end @@ -1074,6 +1078,9 @@ WOK </div> } end + def title_heading0 + title_heading('h1','tiny') + end def title_heading1 title_heading('h1','tiny') end @@ -1331,6 +1338,9 @@ WOK else '' end end + def lev0 #docinfo + lev('h1','toc') + end def lev1 lev('h1','toc') end @@ -1349,13 +1359,14 @@ WOK def lev6 lev('h6','toc') end - def lev0 #docinfo - lev('h0','toc') - end def strip_endnotes(txt) 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_lev0 + @txt=strip_endnotes(@txt) + lev('h1','minitoc') + end def mini_lev1 @txt=strip_endnotes(@txt) lev('h1','minitoc') @@ -1381,7 +1392,7 @@ WOK lev('h6','minitoc') end def mini_lev0 #docinfo - lev('h0','minitoc') + lev('h1','minitoc') end def mini_tail %{ diff --git a/lib/sisu/v4/shared_html_lite.rb b/lib/sisu/v6/html_lite_shared.rb index def7a84d..b675fbd3 100644 --- a/lib/sisu/v4/shared_html_lite.rb +++ b/lib/sisu/v6/html_lite_shared.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/shared_html_lite.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/html_lite_shared.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> diff --git a/lib/sisu/v4/html_minitoc.rb b/lib/sisu/v6/html_minitoc.rb index 2733affb..0bb2794f 100644 --- a/lib/sisu/v4/html_minitoc.rb +++ b/lib/sisu/v6/html_minitoc.rb @@ -9,7 +9,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -51,7 +52,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/v4/html_minitoc.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/html_minitoc.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -70,10 +71,14 @@ def initialize(md,data) @md,@data=md,data @pat_strip_heading_name=/<a name="h?\d.*?">(.+?)<\/a>/ - @tell=SiSU_Screen::Ansi.new(@md.opt.cmd) if @md + @tell=SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set]) if @md end def songsheet - SiSU_Screen::Ansi.new(@md.opt.cmd,'Toc').txt_grey if @md.opt.cmd =~/[MVv]/ + if (@md.opt.act[:verbose][:set]==:on \ + || @md.opt.act[:verbose_plus][:set]==:on \ + || @md.opt.act[:maintenance][:set]==:on) + SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],'Toc').txt_grey + end toc=nil @toc=[] @data.each do |txt| @@ -84,12 +89,13 @@ gsub(@pat_strip_heading_name,'\1') #gsub(/(.*?)<a name="(\d+)"><\/a>(.*)/,'\1') #2002w42 altered gsub - problematic? - suspect toc=case txt.ln - 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 + when 0 then SiSU_HTML_MiniToc::TocMini.new(@md,txt).level_0 + when 1 then SiSU_HTML_MiniToc::TocMini.new(@md,txt).level_1 + when 2 then SiSU_HTML_MiniToc::TocMini.new(@md,txt).level_2 + when 3 then SiSU_HTML_MiniToc::TocMini.new(@md,txt).level_3 + when 4 then SiSU_HTML_MiniToc::TocMini.new(@md,txt).level_4 + when 5 then SiSU_HTML_MiniToc::TocMini.new(@md,txt).level_5 + when 6 then SiSU_HTML_MiniToc::TocMini.new(@md,txt).level_6 else end @toc << toc @@ -110,6 +116,18 @@ format_head_toc=SiSU_HTML_Format::HeadToc.new(@d0c) @@seg_mini << format_head_toc.mini_concordance end + def level_0 + txt=@data + 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::FormatToc.new(@md,txt_obj) + toc_mini=format_toc.mini_lev0 + toc_mini + end def level_1 txt=@data if (txt.is ==:heading \ @@ -117,7 +135,7 @@ && txt.ocn !=0 txt.obj=txt.obj.gsub(@pat_strip_heading_name,'\1') end - title=unless txt.obj =~/Document Information/; txt.obj + title=unless txt.obj =~/Document Information/ then txt.obj else link='metadata' %{<b><a href="#{link}#{@md.lang_code_insert}#{Sfx[:html]}">#{txt.obj}</a></b>} diff --git a/lib/sisu/v4/html_promo.rb b/lib/sisu/v6/html_promo.rb index 981bd7dc..c1949aa2 100644 --- a/lib/sisu/v4/html_promo.rb +++ b/lib/sisu/v6/html_promo.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/html_promo.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/html_promo.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -416,7 +417,7 @@ WOK end end else - SiSU_Screen::Ansi.new(@md.opt.cmd,"*WARN* category not found: #{category}").warn unless @md.opt.cmd =~/q/ + SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],"*WARN* category not found: #{category}").warn unless @md.opt.act[:quiet][:set]==:on end adverts.join end diff --git a/lib/sisu/v4/html_scroll.rb b/lib/sisu/v6/html_scroll.rb index 367e7d70..50c29ca8 100644 --- a/lib/sisu/v4/html_scroll.rb +++ b/lib/sisu/v6/html_scroll.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/html_scroll.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/html_scroll.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -60,7 +61,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 @@ -95,7 +96,7 @@ module SiSU_HTML_Scroll end if dob.obj =~/^Metadata$/ \ and dob.lv =='B' - dob.obj=dob.obj.gsub(/Metadata/,'') + dob.obj=dob.obj.gsub(/Metadata/,'') #dob.obj='' end if defined? dob.name \ and dob.name =~/^metadata/ \ @@ -114,7 +115,9 @@ module SiSU_HTML_Scroll end sto=SiSU_HTML_Format::FormatTextObject.new(@md,dob) para_html=if dob.is==:heading - x=if dob.ln==1 + x=if dob.ln==0 + sto.heading_body0 + elsif dob.ln==1 sto.heading_body1 elsif dob.ln==2 sto.heading_body2 @@ -131,7 +134,11 @@ module SiSU_HTML_Scroll and dob.from==:markup '<br /><hr width=90% /><br />' elsif dob.is==:heading_insert - x=if dob.ln==1 + x=if dob.ln==0 + unless dob.obj.empty? + sto.heading_body0 + end + elsif dob.ln==1 unless dob.obj.empty? sto.heading_body1 end @@ -215,8 +222,7 @@ module SiSU_HTML_Scroll def tails scr_tail=[] 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 << format_head_scroll.scroll_tail << format_head_scroll.html_close scr_tail end end diff --git a/lib/sisu/v4/html_segments.rb b/lib/sisu/v6/html_segments.rb index 73386381..efe37024 100644 --- a/lib/sisu/v4/html_segments.rb +++ b/lib/sisu/v6/html_segments.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/html_segments.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/html_segments.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -60,7 +61,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 @@ -143,8 +144,8 @@ module SiSU_HTML_Seg @@seg_name,@@seg_name_html=[],[] @@seg_url=@@fn=@@get_hash_to=@@get_hash_fn='' @@loop_count=@@seg_total=@@tracker=0 - @@is4=@@is3=@@is2=@@is1=0 - @@heading1=@@heading2=@@heading3=@@heading4=0 + @@is4=@@is3=@@is2=@@is1=@@is0=0 + @@heading0=@@heading1=@@heading2=@@heading3=@@heading4=0 @@seg[:tocband_banner],@@seg[:tocband_bannerless],@@seg[:title],@@seg[:headings],@@seg[:main],@@seg[:idx],@@seg[:tail],@@seg[:credits],@@seg_subtoc_array,@@seg_endnotes_array,@@seg[:endnote_all]=Array.new(11){[]} @@seg[:heading_endnotes]='' @@tablehead,@@number_of_cols=0,0 @@ -186,7 +187,7 @@ module SiSU_HTML_Seg protected def articles(data) tracking,newfile=0,0 - @@is4=@@is3=@@is2=@@is1=0 + @@is4=@@is3=@@is2=@@is1=@@is0=0 printed_endnote_seg='n' idx_html=nil if @md.book_idx @@ -206,7 +207,11 @@ module SiSU_HTML_Seg @@seg_name_html=@@seg_name @@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]/ + if (@md.opt.act[:verbose][:set]==:on \ + || @md.opt.act[:verbose_plus][:set]==:on \ + || @md.opt.act[:maintenance][:set]==:on) + SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],@@seg_name.length).segmented + end map_nametags=SiSU_Particulars::CombinedSingleton.instance.get_map_nametags(@md).nametags_map #p map_nametags data.each do |dob| if defined? dob.obj \ @@ -229,10 +234,7 @@ module SiSU_HTML_Seg if (dob.is==:heading \ || dob.is==:heading_insert) \ && dob.ln==4 - if dob.ocn==0 - @@heading4=dob.obj - else @@heading4=dob.obj - end + @@heading4=dob.obj @@is4=newfile=1 end if (dob.is==:heading \ @@ -253,10 +255,16 @@ module SiSU_HTML_Seg @@heading1=dob.obj @@is4,@@is3,@@is2,@@is1=0,0,0,1 end + if (dob.is==:heading \ + || dob.is==:heading_insert) \ + && dob.ln==0 + @@heading0=dob.obj + @@is4,@@is3,@@is2,@@is1,@@is0=0,0,0,0,1 + end if (@@is1 && !@@is2 && !@@is3 && !@@is4) if not (dob.is==:heading \ || dob.is==:heading_insert) \ - && dob.ln==1 + && dob.ln==0 $_ #; check end end @@ -279,9 +287,7 @@ module SiSU_HTML_Seg fn=@md.file.base_filename.html_seg(fnh) segfilename="#{@file.output_path.html_seg.dir}/#{fn}" output_seg_file=File.new(segfilename,'w') if @@seg_name_html[tracking-1] - minitoc=(@make.build.html_minitoc?) \ - ? @minitoc - : '' + minitoc=(@make.build.html_minitoc?) ? @minitoc : '' 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 @@ -348,7 +354,7 @@ module SiSU_HTML_Seg && (@make.build.html_navigation_bar?) x=if (dob.is==:heading \ || dob.is==:heading_insert) \ - && (dob.ln.to_s =~/^[1-6]/) + && (dob.ln.to_s =~/^[0-6]/) x=if @@tracker < @@seg_total-1 format_head_seg.dot_control_pre_next else @@ -367,31 +373,38 @@ module SiSU_HTML_Seg if @make.build.html_navigation? if @@tracker < @@seg_total-1 @@segtocband=if @@tracker==0 - format_head_seg.toc_next2 #if format_head_seg.toc_next2 + format_head_seg.toc_next2 else - format_head_seg.toc_pre_next2 #if format_head_seg.toc_pre_next2 + format_head_seg.toc_pre_next2 end - else @@segtocband=format_head_seg.toc_pre2 #if format_head_seg.toc_pre2 + else @@segtocband=format_head_seg.toc_pre2 end else @@segtocband='' end @p_num ||= '' - if @@is1==1 + if @@is0==1 @author=%{<b>#{@md.author}</b>\n} if @md.author.to_s =~/\S/ @@seg[:tocband_banner] << format_head_seg.navigation_band(@@segtocband,@@seg[:dot_nav]) - conditional_div_close=if @@get_hash_fn =~/metadata/ #watch - '</div>' - else '' - end - @@seg[:tocband_bannerless] << '<br />' << conditional_div_close << format_head_seg.navigation_band_bottom(@@segtocband,@@seg[:dot_nav]) + @@seg[:tocband_bannerless] << '<br />' << format_head_seg.navigation_band_bottom(@@segtocband,@@seg[:dot_nav]) if @title_banner_ @@seg[:headings] << format_head_seg.title_banner(@md.title.main,@md.title.sub,@author).gsub(clean,'') end - ocn=(@@heading1[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/]) \ + ocn=(@@heading0[/.+?#{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_HTML_Format::ParagraphNumber.new(@md,ocn) + txt_obj={ txt: @@heading0, ocn_display: @p_num.ocn_display } + format_seg=SiSU_HTML_Format::FormatSeg.new(@md,txt_obj) + @@seg[:headings] << format_seg.title_heading0.gsub(clean,'') + @@heading0=@@heading0.gsub(/ <a name="-[\d*+]+" href="#_[\d*+]+"> <sup>[\d*+]+<\/sup> <\/a>/,'') + end + if @@is1==1 + heading1=@@heading1 + 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_HTML_Format::ParagraphNumber.new(@md,ocn) - txt_obj={ txt: @@heading1, ocn_display: @p_num.ocn_display } + txt_obj={ txt: heading1, ocn_display: @p_num.ocn_display } format_seg=SiSU_HTML_Format::FormatSeg.new(@md,txt_obj) @@seg[:headings] << format_seg.title_heading1.gsub(clean,'') @@heading1=@@heading1.gsub(/ <a name="-[\d*+]+" href="#_[\d*+]+"> <sup>[\d*+]+<\/sup> <\/a>/,'') @@ -549,7 +562,7 @@ module SiSU_HTML_Seg if @md.flag_auto_endnotes if (dob.is==:heading \ || dob.is==:heading_insert) \ - && (dob.ln.to_s =~/^[1234]/) \ + && (dob.ln.to_s =~/^[0-4]/) \ and not @@fn.to_s.empty? @@seg_endnotes[@@fn]=[] @@seg_endnotes[@@fn] << @@seg_endnotes_array diff --git a/lib/sisu/v4/shared_html.rb b/lib/sisu/v6/html_shared.rb index 372b5033..577b0897 100644 --- a/lib/sisu/v4/shared_html.rb +++ b/lib/sisu/v6/html_shared.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/shared_html.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/html_shared.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> diff --git a/lib/sisu/v4/html_table.rb b/lib/sisu/v6/html_table.rb index 6d61d45b..41f1a07b 100644 --- a/lib/sisu/v4/html_table.rb +++ b/lib/sisu/v6/html_table.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/html_table.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/html_table.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> diff --git a/lib/sisu/v4/html_tune.rb b/lib/sisu/v6/html_tune.rb index 1876380a..384a19b0 100644 --- a/lib/sisu/v4/html_tune.rb +++ b/lib/sisu/v6/html_tune.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/html_tune.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/html_tune.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -80,7 +81,7 @@ module SiSU_HTML_Tune def initialize(data,md) @data,@md=data,md @file=SiSU_Env::InfoFile.new(@md.fns) - @cX=SiSU_Screen::Ansi.new(@md.opt.cmd).cX + @cX=SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set]).cX end def hard_output @filename_tune=@file.write_file_processing.html_tune @@ -124,11 +125,15 @@ module SiSU_HTML_Tune 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]/ + @cX=SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set]).cX + if (@md.opt.act[:verbose][:set]==:on \ + || @md.opt.act[:verbose_plus][:set]==:on \ + || @md.opt.act[:maintenance][:set]==:on) + SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],'Tune').txt_grey + end songsheet_array(@data) #data=songsheet_array(@data) - if @md.opt.cmd =~/M/ #Hard Output Tune Optional on/off here + if @md.opt.act[:maintenance][:set]==:on #Hard Output Tune Optional on/off here SiSU_HTML_Tune::Output.new(@data,@md).hard_output SiSU_HTML_Tune::Output.new(@data,@md).marshal end diff --git a/lib/sisu/v4/hub.rb b/lib/sisu/v6/hub.rb index 5965994f..7e2a009d 100644 --- a/lib/sisu/v4/hub.rb +++ b/lib/sisu/v6/hub.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/hub.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/hub.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -154,7 +155,7 @@ module SiSU end end if files_translated_idx.flatten.length > 1 - SiSU_Screen::Ansi.new(@opt.cmd,'Manifest re-run on (currently generated) translated files',"").grey_title_hi unless @opt.act[:quiet][:set] ==:on + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Manifest re-run on (currently generated) translated files',"").grey_title_hi unless @opt.act[:quiet][:set] ==:on files_translated_idx.flatten.each do |i| @opt.fns=@opt.files[i] @opt.f_pth=@opt.f_pths[i] @@ -280,85 +281,117 @@ module SiSU Dir.chdir(@opt.pth) #watch end @env=SiSU_Env::InfoEnv.new(@opt.fns) - if @opt.act[:dal][:set]==:on #% --dal, -m + if @opt.act[:ao][:set]==:on #% --ao --dal, -m unless @opt.act[:po4a][:set]==:on # --po4a, -P if @opt.fno =~ /\.ssm$/ require_relative 'composite' # composite.rb #pre-processing SiSU_Assemble::Composite.new(@opt).read end - require_relative 'dal' # -m dal.rb - SiSU_DAL::Source.new(@opt).read + require_relative 'ao' # -m ao.rb + SiSU_AO::Source.new(@opt).read end end if @opt.act[:qrcode][:set]==:on #% --qrcode, -Q - require_relative 'qrcode' # -Q qrcode.rb + require_relative 'qrcode' # qrcode.rb SiSU_QRcode::Source.new(@opt).read end if @opt.act[:hash_digests][:set]==:on #% --hash-digests, -N digest tree - require_relative 'digests' # -N digests.rb + require_relative 'digests' # digests.rb SiSU_DigestView::Source.new(@opt).read end if @opt.act[:txt][:set]==:on #% --txt, -t -a - require_relative 'plaintext' # -t -a 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 - require_relative 'html' # -h -H html.rb + if @opt.act[:txt_textile][:set]==:on #% --textile + require_relative 'txt_textile' # txt_textile.rb + SiSU_Txt_Textile::Source.new(@opt).read + end + if @opt.act[:txt_asciidoc][:set]==:on #% --asciidoc + require_relative 'txt_asciidoc' # txt_asciidoc.rb + SiSU_Txt_AsciiDoc::Source.new(@opt).read + end + if @opt.act[:txt_markdown][:set]==:on #% --markdown + require_relative 'txt_markdown' # txt_markdown.rb + SiSU_Txt_Markdown::Source.new(@opt).read + end + if @opt.act[:txt_rst][:set]==:on #% --rst, --rest + require_relative 'txt_rst' # txt_rst.rb + SiSU_Txt_rST::Source.new(@opt).read + end + if @opt.act[:html][:set]==:on #% --html, -h -H + require_relative 'html' # html.rb SiSU_HTML::Source.new(@opt).read else - if @opt.act[:html_seg][:set]==:on #% --html-seg - require_relative 'html' # -h -H html.rb + if @opt.act[:html_seg][:set]==:on #% --html-seg (-h -H) + require_relative 'html' # html.rb SiSU_HTML::Source.new(@opt).read end - if @opt.act[:html_scroll][:set]==:on #% --html-scroll - require_relative 'html' # -h -H html.rb + if @opt.act[:html_scroll][:set]==:on #% --html-scroll (-h -H) + require_relative 'html' # html.rb SiSU_HTML::Source.new(@opt).read end end if @opt.act[:concordance][:set]==:on #% --concordance, -w - require_relative 'concordance' # -w concordance.rb + require_relative 'concordance' # concordance.rb SiSU_Concordance::Source.new(@opt).read end if @opt.act[:epub][:set]==:on #% --epub, -e - require_relative 'epub' # -e 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' # -o 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' # -b xhtml.rb + require_relative 'xhtml' # xhtml.rb SiSU_XHTML::Source.new(@opt).read end + if @opt.act[:xml_scaffold_structure_sisu][:set]==:on #% --xml-scaffold --xml-scaffold-sisu + require_relative 'xml_scaffold_structure_sisu' # xml_scaffold_structure_sisu.rb + SiSU_XML_Scaffold_Structure_Sisu::Source.new(@opt).read + end + if @opt.act[:xml_scaffold_structure_collapse][:set]==:on #% --xml-scaffold-collapse + require_relative 'xml_scaffold_structure_collapsed' # xml_scaffold_structure_collapsed.rb + SiSU_XML_Scaffold_Structure_Collapse::Source.new(@opt).read + end + if @opt.act[:xml_docbook_book][:set]==:on #% --xml-docbook + require_relative 'xml_docbook5' # xml_docbook5.rb + SiSU_XML_Docbook_Book::Source.new(@opt).read + end + if @opt.act[:xml_fictionbook][:set]==:on #% --xml-fictionbook + require_relative 'xml_fictionbook2' # xml_fictionbook2.rb + SiSU_XML_Fictionbook::Source.new(@opt).read + end if @opt.act[:xml_sax][:set]==:on #% --xml-sax, -x xml sax type - require_relative 'xml' # -x xml.rb + require_relative 'xml_sax' # xml_sax.rb SiSU_XML_SAX::Source.new(@opt).read end if @opt.act[:xml_dom][:set]==:on #% --xml-dom, -X xml dom type - require_relative 'xml_dom' # -X xml_dom.rb + require_relative 'xml_dom' # xml_dom.rb SiSU_XML_DOM::Source.new(@opt).read end if @opt.act[:pdf][:set]==:on \ or @opt.act[:pdf_p][:set]==:on \ or @opt.act[:pdf_l][:set]==:on #% --pdf-l --pdf, -p latex/ texpdf - require_relative 'texpdf' # -p texpdf.rb + require_relative 'texpdf' # texpdf.rb SiSU_TeX::Source.new(@opt).read end if @opt.act[:manpage][:set]==:on #% --manpage, -i - require_relative 'manpage' # -i manpage.rb + require_relative 'manpage' # manpage.rb SiSU_Manpage::Source.new(@opt).read end if @opt.act[:texinfo][:set]==:on #% --texinfo, -I - require_relative 'texinfo' # -I texinfo.rb + require_relative 'texinfo' # texinfo.rb SiSU_TexInfo::Source.new(@opt).read end if @opt.act[:sqlite_discrete][:set]==:on #% --sqlite, -d DB sqlite - require_relative 'dbi_discrete' # -d dbi_discrete.rb + require_relative 'dbi_discrete' # dbi_discrete.rb SiSU_DBI_Discrete::SQL.new(@opt).build end if @opt.act[:manifest][:set]==:on #% --manifest, -y - require_relative 'manifest' # -y manifest.rb + require_relative 'manifest' # manifest.rb ((@opt.act[:sisupod][:set]==:on \ || @opt.act[:share_source][:set]==:on) \ && @opt.files.length < 2 ) \ @@ -383,12 +416,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 @@ -397,7 +430,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 @@ -430,7 +463,7 @@ module SiSU end ensure path_pod=@env.processing_path.processing_sisupod(@opt).paths - unless @opt.cmd =~/M/ + unless @opt.act[:maintenance][:set]==:on FileUtils::rm_rf("#{path_pod[:sisupod]}/*") if FileTest.directory?(path_pod[:sisupod]) end end @@ -511,16 +544,18 @@ module SiSU end end def do_initialization - @cX=SiSU_Screen::Ansi.new(@opt.cmd).cX + @cX=SiSU_Screen::Ansi.new(@opt.act[:color_state][:set]).cX SiSU_Env::InfoProcessingFlag.new - if @opt.act[:version_info][:set]==:on #% version information + if @opt.act[:version_info][:set]==:on #% version information SiSU_Env::InfoAbout.new(@opt).sisu_version - if @opt.cmd =~/[vVM]/ - SiSU_Screen::Ansi.new(@opt.cmd,' ' + File.dirname(__FILE__)).grey + if (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],' ' + File.dirname(__FILE__)).grey end end - if @opt.act[:dal][:set]==:on \ - or @opt.act[:maintenance][:set]==:on #% --maintenance, -m for -C + if @opt.act[:ao][:set]==:on \ + or @opt.act[:maintenance][:set]==:on #% --maintenance, -m for -C path={} path[:css]=@@env.path.output + '/_sisu/css' path[:xml]=@@env.path.output + '/_sisu/xml' @@ -565,13 +600,13 @@ module SiSU end end end - if @opt.act[:sample_search_form][:set]==:on #% --sample-search-form, -F cgi sample search form + if @opt.act[:sample_search_form][:set]==:on #% --sample-search-form, -F cgi sample search form SiSU::Operations.new(@opt).cgi end - if @opt.act[:webrick][:set]==:on #% --webrick, -W webrick + if @opt.act[:webrick][:set]==:on #% --webrick, -W webrick SiSU::Operations.new(@opt).webrick end - if @opt.act[:dal][:set]==:on + if @opt.act[:ao][:set]==:on @retry_count= -1 begin @get_s,@get_p,@get_pl=[],[],[] @@ -623,10 +658,14 @@ module SiSU and @opt.mod.join(';') =~/--(?:createdb|init(?:ialize)?|create(?:all)?|createtables|recreate|drop(?:all))/) :false else - (@opt.act[:dal][:set]==:on \ + (@opt.act[:ao][:set]==:on \ || @opt.act[:manpage][:set]==:on \ || @opt.act[:texinfo][:set]==:on \ || @opt.act[:txt][:set]==:on \ + || @opt.act[:txt_textile][:set]==:on \ + || @opt.act[:txt_asciidoc][:set]==:on \ + || @opt.act[:txt_markdown][:set]==:on \ + || @opt.act[:txt_rst][:set]==:on \ || @opt.act[:html][:set]==:on \ || @opt.act[:html_scroll][:set]==:on \ || @opt.act[:html_seg][:set]==:on \ @@ -636,6 +675,10 @@ module SiSU || @opt.act[:odt][:set]==:on \ || @opt.act[:xml_sax][:set]==:on \ || @opt.act[:xml_dom][:set]==:on \ + || @opt.act[:xml_scaffold_structure_sisu][:set]==:on \ + || @opt.act[:xml_scaffold_structure_collapse][:set]==:on \ + || @opt.act[:xml_docbook_book][:set]==:on \ + || @opt.act[:xml_fictionbook][:set]==:on \ || @opt.act[:pdf][:set]==:on \ || @opt.act[:pdf_p][:set]==:on \ || @opt.act[:pdf_l][:set]==:on \ @@ -670,7 +713,7 @@ module SiSU SiSU_DBI::SQL.new(@opt).connect end elsif action_on_file_ == :true \ - or ( + or ( #% ---> @opt.cmd =~/^-/ \ and @opt.cmd =~/([abCcDdeFGgHhIjikLMmNnoPpQqRrSsTtUuVvWwXxYyZ_0-9])/ \ and @opt.mod.inspect !~/--(?:sitemaps|query|identify)/ \ @@ -680,8 +723,18 @@ module SiSU if action_on_file_ == :true \ and @opt.files.length > 0 do_loops - @msg,@msgs="\tsisu -W [to start ruby web-server on output directory]\n",nil if @opt.cmd =~/[vVM]/ - @tell.call.print_brown if @opt.cmd =~/[uUvVM]/ unless @opt.files.join.empty? + if (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) + @msg,@msgs="\tsisu -W [to start ruby web-server on output directory]\n",nil + end + if (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on \ + || @opt.act[:urls_selected][:set]==:on \ + || @opt.act[:urls_all][:set]==:on) + @tell.call.print_brown unless @opt.files.join.empty? + end if defined? @@env.processing_path.processing \ and @@env.user \ and FileTest.directory?(@@env.processing_path.processing) \ @@ -693,7 +746,10 @@ module SiSU elsif action_on_file_ == :true \ and @opt.files.length == 0 STDERR.puts %{requested action requires valid sisu markup file [filename (.sst .ssm)] or wildcard (that includes a valid filename)} - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__).mark(:fuchsia) if @opt.cmd =~/[MV]/ + if (@opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__).mark(:fuchsia) + end end elsif @opt.mod.inspect =~/--query/ require_relative 'sst_identify_markup' # sst_identify_markup.rb @@ -729,7 +785,7 @@ module SiSU if @opt.fns =~/\.ssm\.sst$/ \ and @opt.cmd !~/[S_M]/ # rework necessry, revist, the _ flag is a hack, to keep ._sst files @msg,@msgs='temporary file removed',nil - @tell.call.warn unless @opt.cmd =~/V/ + @tell.call.warn unless @opt.act[:quiet][:set]==:on File.unlink(@opt.fns) if File.exist?(@opt.fns) #CONSIDER end else #SiSU::Operations.new(fns,'html').not_found diff --git a/lib/sisu/v4/i18n.rb b/lib/sisu/v6/i18n.rb index 5028c245..ecd30958 100644 --- a/lib/sisu/v4/i18n.rb +++ b/lib/sisu/v6/i18n.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/i18n.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/i18n.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -259,76 +260,76 @@ module SiSU_TextTranslation def tex_name(char) @lang=if char case char - when 'sq'; 'albanian' - when 'am'; 'amharic' - #when 'ar'; 'arabic' # see polyglossia - when 'hy'; 'armenian' - #when ''; 'asturian' # polyglossia - #when ''; 'bahasai' # polyglossia - #when ''; 'bahasam' # polyglossia - when 'eu'; 'basque' - when 'bn'; 'bengali' - when 'pt_BR'; 'brazilian' - when 'br'; 'breton' - when 'bg'; 'bulgarian' - when 'ca'; 'catalan' # see polyglossia - #when ''; 'coptic' # polyglossia - when 'hr'; 'croatian' - when 'cs'; 'czech' - when 'da'; 'danish' - #when ''; 'divehi' # polyglossia - when 'nl'; 'dutch' # see polyglossia - when 'en'; 'english' # see polyglossia - when 'eo'; 'esperanto' # see polyglossia - when 'et'; 'estonian' - when 'gl'; 'galician' - when 'de'; 'german' - when 'el'; 'greek' #gl ? - when 'he'; 'hebrew' - when 'hi'; 'hindi' - when 'is'; 'icelandic' - when 'ia'; 'interlingua' - when 'ga'; 'irish' - when 'it'; 'italian' - #when ''; 'farsi' # polyglossia - when 'fi'; 'finnish' - when 'fr'; 'french' - when 'lo'; 'lao' - when 'la'; 'latin' - when 'lv'; 'latvian' - when 'lt'; 'lithuanian' - #when ''; 'lsorbian' # polyglossia - #when ''; 'magyar' # polyglossia - when 'ml'; 'malayalam' - when 'mr'; 'marathi' - #when 'hu'; 'magyar' - when 'no'; 'norske' - when 'nn'; 'nynorsk' - when 'oc'; 'occitan' - when 'pl'; 'polish' - when 'pt'; 'portuges' - when 'ro'; 'romanian' - when 'ru'; 'russian' - when 'se'; 'samin' #(check sami?) - when 'sa'; 'sanskrit' - when 'sr'; 'serbian' - #when ''; 'scottish' # polyglossia (gd (Gaelic (Scots))) - when 'sk'; 'slovak' - when 'sl'; 'slovenian' - when 'es'; 'spanish' - when 'sv'; 'swedish' - when 'ta'; 'tamil' - when 'te'; 'telugu' - when 'th'; 'thai' - when 'tr'; 'turkish' - when 'tk'; 'turkmen' - when 'uk'; 'ukrainian' - when 'ur'; 'urdu' - #when ''; 'usorbian' # polyglossia - when 'vi'; 'vietnamese' - when 'cy'; 'welsh' - when 'us'; 'USenglish' # depreciated, see iso-639-2 - else 'english' + when 'sq' then 'albanian' + when 'am' then 'amharic' + #when 'ar' then 'arabic' # see polyglossia + when 'hy' then 'armenian' + #when '' then 'asturian' # polyglossia + #when '' then 'bahasai' # polyglossia + #when '' then 'bahasam' # polyglossia + when 'eu' then 'basque' + when 'bn' then 'bengali' + when 'pt_BR' then 'brazilian' + when 'br' then 'breton' + when 'bg' then 'bulgarian' + when 'ca' then 'catalan' # see polyglossia + #when '' then 'coptic' # polyglossia + when 'hr' then 'croatian' + when 'cs' then 'czech' + when 'da' then 'danish' + #when '' then 'divehi' # polyglossia + when 'nl' then 'dutch' # see polyglossia + when 'en' then 'english' # see polyglossia + when 'eo' then 'esperanto' # see polyglossia + when 'et' then 'estonian' + when 'gl' then 'galician' + when 'de' then 'german' + when 'el' then 'greek' #gl ? + when 'he' then 'hebrew' + when 'hi' then 'hindi' + when 'is' then 'icelandic' + when 'ia' then 'interlingua' + when 'ga' then 'irish' + when 'it' then 'italian' + #when '' then 'farsi' # polyglossia + when 'fi' then 'finnish' + when 'fr' then 'french' + when 'lo' then 'lao' + when 'la' then 'latin' + when 'lv' then 'latvian' + when 'lt' then 'lithuanian' + #when '' then 'lsorbian' # polyglossia + #when '' then 'magyar' # polyglossia + when 'ml' then 'malayalam' + when 'mr' then 'marathi' + #when 'hu' then 'magyar' + when 'no' then 'norske' + when 'nn' then 'nynorsk' + when 'oc' then 'occitan' + when 'pl' then 'polish' + when 'pt' then 'portuges' + when 'ro' then 'romanian' + when 'ru' then 'russian' + when 'se' then 'samin' #(check sami?) + when 'sa' then 'sanskrit' + when 'sr' then 'serbian' + #when '' then 'scottish' # polyglossia (gd (Gaelic (Scots))) + when 'sk' then 'slovak' + when 'sl' then 'slovenian' + when 'es' then 'spanish' + when 'sv' then 'swedish' + when 'ta' then 'tamil' + when 'te' then 'telugu' + when 'th' then 'thai' + when 'tr' then 'turkish' + when 'tk' then 'turkmen' + when 'uk' then 'ukrainian' + when 'ur' then 'urdu' + #when '' then 'usorbian' # polyglossia + when 'vi' then 'vietnamese' + when 'cy' then 'welsh' + when 'us' then 'USenglish' # depreciated, see iso-639-2 + else then 'english' end else 'english' end diff --git a/lib/sisu/v4/manifest.rb b/lib/sisu/v6/manifest.rb index db409f46..1d6bc6a9 100644 --- a/lib/sisu/v4/manifest.rb +++ b/lib/sisu/v6/manifest.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/manifest.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/manifest.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -86,12 +87,17 @@ module SiSU_Manifest xbrowser=@env.program.web_browser browser=@env.program.console_web_browser # webserv_url=@env.path.url.output_tell #fix in sysenv - unless @opt.cmd =~/q/ + unless @opt.act[:quiet][:set]==:on url_html="file://#{@md.file.output_path.manifest.dir}/#{@md.file.base_filename.manifest}" - @opt.cmd=~/[MVvz]/ \ - ? SiSU_Screen::Ansi.new(@opt.cmd,'Manifest',"#{xbrowser} #{url_html}").green_hi_blue - : SiSU_Screen::Ansi.new(@opt.cmd,'Manifest',"[#{@opt.f_pth[:lng_is]}]", "#{url_html}").grey_title_grey_blue - SiSU_Screen::Ansi.new(@opt.cmd,"#{browser} #{url_html}").grey_tab if @opt.cmd =~/v/i + (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) \ + ? SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Manifest',"#{xbrowser} #{url_html}").green_hi_blue + : SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Manifest',"[#{@opt.f_pth[:lng_is]}]", "#{url_html}").grey_title_grey_blue + if (@md.opt.act[:verbose][:set]==:on \ + || @md.opt.act[:verbose_plus][:set]==:on) + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"#{browser} #{url_html}").grey_tab + end end data=SiSU_HTML::Source::HTML_Environment.new(@particulars).tuned_file_instructions SiSU_Manifest::Source::Output.new(@md).check_output(data) @@ -162,7 +168,11 @@ module SiSU_Manifest dgst=(@dg =~/^sha(?:2|256)$/) \ ? sys.sha256("#{pth}/#{file}") : sys.md5("#{pth}/#{file}") - SiSU_Screen::Ansi.new(@md.opt.cmd,"#{dgst[1]} #{file}").warn if @md.opt.cmd =~/[vVM]/ + if (@md.opt.act[:verbose][:set]==:on \ + || @md.opt.act[:verbose_plus][:set]==:on \ + || @md.opt.act[:maintenance][:set]==:on) + SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],"#{dgst[1]} #{file}").warn + end 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" @@ -387,6 +397,41 @@ module SiSU_Manifest id,file='XML DOM',@f.base_filename.xml_dom summarize(id,file,pth,rel,url) end + if FileTest.file?(@f.place_file.xml_docbook_article.dir)==true + pth=@f.output_path.xml_docbook_article.dir + rel=@f.output_path.xml_docbook_article.rel_sm + url=@f.output_path.xml_docbook_article.url + id,file='XML Docbook Book',@f.base_filename.xml_docbook_article + summarize(id,file,pth,rel,url) + end + if FileTest.file?(@f.place_file.xml_docbook_book.dir)==true + pth=@f.output_path.xml_docbook_book.dir + rel=@f.output_path.xml_docbook_book.rel_sm + url=@f.output_path.xml_docbook_book.url + id,file='XML Docbook Book',@f.base_filename.xml_docbook_book + summarize(id,file,pth,rel,url) + end + if FileTest.file?(@f.place_file.xml_fictionbook.dir)==true + pth=@f.output_path.xml_fictionbook.dir + rel=@f.output_path.xml_fictionbook.rel_sm + url=@f.output_path.xml_fictionbook.url + id,file='XML Fictionbook',@f.base_filename.xml_fictionbook + summarize(id,file,pth,rel,url) + end + if FileTest.file?(@f.place_file.xml_scaffold_structure_sisu.dir)==true + pth=@f.output_path.xml_scaffold_structure_sisu.dir + rel=@f.output_path.xml_scaffold_structure_sisu.rel_sm + url=@f.output_path.xml_scaffold_structure_sisu.url + id,file='XML Scaffold sisu structure',@f.base_filename.xml_scaffold_structure_sisu + summarize(id,file,pth,rel,url) + end + if FileTest.file?(@f.place_file.xml_scaffold_structure_collapse.dir)==true + pth=@f.output_path.xml_scaffold_structure_collapse.dir + rel=@f.output_path.xml_scaffold_structure_collapse.rel_sm + url=@f.output_path.xml_scaffold_structure_collapse.url + id,file='XML Scaffold collapsed structure',@f.base_filename.xml_scaffold_structure_collapse + summarize(id,file,pth,rel,url) + end if FileTest.file?(@f.place_file.info.dir)==true pth=@f.output_path.texinfo.dir rel=@f.output_path.texinfo.rel_sm @@ -409,18 +454,45 @@ module SiSU_Manifest summarize(id,file,pth,rel,url) end if FileTest.file?(@f.place_file.txt.dir)==true - id=if @md.opt.cmd =~/a/ then 'Plaintext (Unix (UTF-8) with footnotes)' - elsif @md.opt.cmd =~/e/ then 'Plaintext (Unix (UTF-8) with endnotes)' - elsif @md.opt.cmd =~/A/ then 'Plaintext (dos (UTF-8) with footnotes)' - elsif @md.opt.cmd =~/E/ then 'Plaintext (dos (UTF-8) with endnotes)' - else 'Plaintext (UTF-8)' - end + id='Plaintext (UTF-8)' pth=@f.output_path.txt.dir rel=@f.output_path.txt.rel_sm url=@f.output_path.txt.url file=@f.base_filename.txt summarize(id,file,pth,rel,url) end + if FileTest.file?(@f.place_file.textile.dir)==true + id='Textile text (UTF-8)' + pth=@f.output_path.textile.dir + rel=@f.output_path.textile.rel_sm + url=@f.output_path.textile.url + file=@f.base_filename.textile + summarize(id,file,pth,rel,url) + end + if FileTest.file?(@f.place_file.asciidoc.dir)==true + id='AsciiDoc text (UTF-8)' + pth=@f.output_path.asciidoc.dir + rel=@f.output_path.asciidoc.rel_sm + url=@f.output_path.asciidoc.url + file=@f.base_filename.asciidoc + summarize(id,file,pth,rel,url) + end + if FileTest.file?(@f.place_file.markdown.dir)==true + id='Markdown text (UTF-8)' + pth=@f.output_path.markdown.dir + rel=@f.output_path.markdown.rel_sm + url=@f.output_path.markdown.url + file=@f.base_filename.markdown + summarize(id,file,pth,rel,url) + end + if FileTest.file?(@f.place_file.rst.dir)==true + id='rST text (UTF-8)' + pth=@f.output_path.rst.dir + rel=@f.output_path.rst.rel_sm + url=@f.output_path.rst.url + file=@f.base_filename.rst + summarize(id,file,pth,rel,url) + end if FileTest.file?("#{@base_path}/#{@md.fns}.tex")==true id,file='LaTeX (portrait)',"#{@md.fns}.tex" pth,rel,url='','','' diff --git a/lib/sisu/v4/manpage.rb b/lib/sisu/v6/manpage.rb index fd4e365d..deb85f39 100644 --- a/lib/sisu/v4/manpage.rb +++ b/lib/sisu/v6/manpage.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/manpage.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/manpage.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -61,7 +62,7 @@ =end module SiSU_Manpage - require_relative 'dal' # dal.rb + require_relative 'ao' # ao.rb require_relative 'sysenv' # sysenv.rb include SiSU_Env include SiSU_Param @@ -69,7 +70,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 @@ -85,16 +86,23 @@ module SiSU_Manpage begin @md=SiSU_Param::Parameters.new(@opt).get @env=SiSU_Env::InfoEnv.new(@opt.fns) - tool=(@opt.cmd =~/[MVv]/) \ + tool=(@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) \ ? "#{@env.program.text_editor} #{@md.file.output_path.manpage.dir}/#{@md.file.base_filename.manpage}" : "[#{@opt.f_pth[:lng_is]}] #{@opt.fno}" - @opt.cmd=~/[MVvz]/ \ + (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) \ && @opt.cmd !~/q/ \ - ? SiSU_Screen::Ansi.new(@opt.cmd,'Manpage',tool).green_hi_blue - : SiSU_Screen::Ansi.new(@opt.cmd,'Manpage',tool).green_title_hi - 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_Screen::Ansi.new(@opt.act[:color_state][:set],'Manpage',tool).green_hi_blue + : SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Manpage',tool).green_title_hi + if (@opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],@opt.fns,"#{@md.file.output_path.manpage.dir}/#{@md.file.base_filename.manpage}").flow + end + @ao_array=SiSU_AO::Source.new(@opt).get # ao file drawn here + SiSU_Manpage::Source::Scroll.new(@md,@ao_array).songsheet rescue SiSU_Errors::Rescued.new($!,$@,@opt.cmd,@opt.fns).location do __LINE__.to_s + ':' + __FILE__ @@ -105,7 +113,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) @@ -113,7 +121,6 @@ module SiSU_Manpage @brace_url=SiSU_Viz::Defaults.new.url_decoration @vz=SiSU_Viz::Defaults.new @tab="\t" - @br="\n" @@notes=:end @manpage={ body: [], open: [], close: [], head: [], metadata: [], tail: [], endnotes: [] } end @@ -121,6 +128,9 @@ module SiSU_Manpage manpage=markup(@data) publish(manpage) end + def break_line + "\n" + end # Used for extraction of endnotes from paragraphs def extract_endnotes(dob='') para=dob.obj.gsub(/#{Mx[:br_line]}/,"\n") @@ -169,7 +179,7 @@ GSUB end def manpage_tail @manpage[:tail] <<<<WOK -#{@br} +#{break_line} .TP .SH SEE ALSO sisu(1), @@ -228,21 +238,21 @@ WOK times=wrapped.length times=78 if times > 78 @manpage[:body] << case lv - when 1; '.SH ' << wrapped.upcase << @br << @br - when 2..3; '.SH ' << wrapped.upcase << @br << @br - when 4; '.SH ' << wrapped.upcase << @br << @br - when 5..6; '.SH ' << wrapped.upcase << @br << @br + when 0 then '.SH ' << wrapped.upcase << break_line << break_line + when 1..3 then '.SH ' << wrapped.upcase << break_line << break_line + when 4 then '.SH ' << wrapped.upcase << break_line << break_line + when 5..6 then '.SH ' << wrapped.upcase << break_line << break_line end else @manpage[:body] << if wrapped =~/^\.BI\s/ # main text, contents, body KEEP - '.TP' << @br << wrapped.gsub(/(^\.B)I\s/,'\1 ') # sleight ... simpler output (check gsub!) + '.TP' << break_line << wrapped.gsub(/(^\.B)I\s/,'\1 ') # sleight ... simpler output (check gsub!) else - @br + '.BR' + @br << wrapped + break_line + '.BR' + break_line << wrapped end end if @@endnotes[:para] \ and @@notes==:foot #edit out to switch off endnotes following paragraph to which they belong - @@endnotes[:para].each { |e| @manpage[:body] << e << @br } + @@endnotes[:para].each { |e| @manpage[:body] << e << break_line } elsif @@endnotes[:para] \ and @@notes==:end end @@ -330,19 +340,11 @@ WOK x=SiSU_ManpageFormat::FormatTextObject.new(@md,dob) if dob.is==:heading manpage_structure(dob) - dob.obj=case dob.ln - when 1; x.heading_body1 - when 2; x.heading_body2 - when 3; x.heading_body3 - when 4; x.heading_body4 - when 5; x.heading_body5 - when 6; x.heading_body6 - end elsif dob.is==:para manpage_structure(dob) else if dob.obj =~/#{table_message}/ - @manpage[:body] << dob.obj << @br + @manpage[:body] << dob.obj << break_line end end if (dob.obj =~/<a name="n\d+">/ \ diff --git a/lib/sisu/v4/manpage_format.rb b/lib/sisu/v6/manpage_format.rb index e361825a..1bb0e423 100644 --- a/lib/sisu/v4/manpage_format.rb +++ b/lib/sisu/v6/manpage_format.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/manpage_format.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/manpage_format.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -87,20 +88,6 @@ module SiSU_ManpageFormat def scr_endnote_body "<endnote>#{@dob.obj}</endnote> " end - def heading_body1 - end - def heading_body2 - end - def heading_body3 - end - def heading_body4 - end - def heading_body5 - end - def heading_body6 - end - end - class XML end end __END__ diff --git a/lib/sisu/v4/options.rb b/lib/sisu/v6/options.rb index 4f5087dc..632ac5a8 100644 --- a/lib/sisu/v4/options.rb +++ b/lib/sisu/v6/options.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/options.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/options.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -493,51 +494,51 @@ module SiSU_Commandline unless m.empty? m.each do |s| case s - when /^--(?:color-toggle)$/; c=c+'c' - when /^--(?:color-off)$/; c=c+'k' - when /^--(?:conf|config|configure|init|initialize|init-site)$/; c=c+'CC' - when /^--(?:dal?|machine|abstraction|abs)$/; c=c+'m' - when /^--(?:txt|text|plaintext)$/; c=c+'t' - when /^--(?:html)$/; c=c+'h' - when /^--(?:html-scroll|html-seg)$/; c=c+'H' + when /^--(?:color-toggle)$/ then c=c+'c' + when /^--(?:color-off)$/ then c=c+'k' + when /^--(?:conf|config|configure|init|initialize|init-site)$/ then c=c+'CC' + when /^--(?:ao|dal?|machine|abstraction|abs)$/ then c=c+'m' + when /^--(?:txt|text|plaintext)$/ then c=c+'t' + when /^--(?:html)$/ then c=c+'h' + when /^--(?:html-scroll|html-seg)$/ then c=c+'H' mod << s - when /^--(?:epub)$/; c=c+'e' - when /^--(?:od[ft])$/; c=c+'o' - when /^--(?:pdf)$/; c=c+'p' - when /^--pdf-(?:a4|a5|b5|legal|letter)$/; c=c+'p' - when /^--pdf-(?:p|l|portrait|landscape)$/; c=c+'L' - when /^--pdf-(?:p(?:ortrait)?|l(?:andscape)?)-(?:a4|letter|a5|b5|legal)$/; c=c+'L' - when /^--pdf-(?:a4|letter|a5|b5|legal)-(?:p(?:ortrait)?|l(?:andscape)?)$/; c=c+'L' - when /^--(?:concordance|wordmap)$/; c=c+'w' - when /^--(?:manpage|man)$/; c=c+'i' - when /^--(?:texinfo)$/; c=c+'I' - 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' - when /^--(?:manifest)$/; c=c+'y' - when /^--(?:qrcode)$/; c=c+'Q' - when /^--(?:sqlite)$/; c=c+'d' - when /^--(?:pg|pg?sql|postgresql)$/; c=c+'D' - when /^--(?:remote|rsync)$/; c=c+'R' - when /^--(?:scp)$/; c=c+'r' - when /^--(?:source)$/; c=c+'s' - when /^--(?:sisupod|pod)$/; c=c+'S' - when /^--(?:git)$/; c=c+'g' - when /^--(?:urls)$/; c=c+'U' - when /^--(?:zap|delete)$/; c=c+'Z' - when /^--(?:sample-search-form)$/; c=c+'F' - when /^--(?:webserv|webrick)$/; c=c+'W' - when /^--(?:profile)$/; c=c+'E' - when /^--(?:maintenance|keep-processing-files)$/; c=c+'M' - when /^--(?:verbose[=-]3)$/; c=c+'VM' - when /^--(?:verbose[=-]2|Verbose|VERBOSE)$/; c=c+'V' - when /^--(?:verbose(?:[=-]1)?)$/; c=c+'v' - when /^--(?:version)$/; c=c+'v' - when /^--(?:verbose[=-]0|quiet|silent)$/; c=c+'q' + when /^--(?:epub)$/ then c=c+'e' + when /^--(?:od[ft])$/ then c=c+'o' + when /^--(?:pdf)$/ then c=c+'p' + when /^--pdf-(?:a4|a5|b5|legal|letter)$/ then c=c+'p' + when /^--pdf-(?:p|l|portrait|landscape)$/ then c=c+'L' + when /^--pdf-(?:p(?:ortrait)?|l(?:andscape)?)-(?:a4|letter|a5|b5|legal)$/ then c=c+'L' + when /^--pdf-(?:a4|letter|a5|b5|legal)-(?:p(?:ortrait)?|l(?:andscape)?)$/ then c=c+'L' + when /^--(?:concordance|wordmap)$/ then c=c+'w' + when /^--(?:manpage|man)$/ then c=c+'i' + when /^--(?:texinfo)$/ then c=c+'I' + when /^--(?:xhtml)$/ then c=c+'b' + when /^--(?:xml-sax)$/ then c=c+'x' + when /^--(?:xml-dom)$/ then c=c+'X' + when /^--(?:images)$/ then c=c+'j' + when /^--(?:hash-digests)$/ then c=c+'N' + when /^--(?:po4a|pot?)$/ then c=c+'P' + when /^--(?:termsheet)$/ then c=c+'T' + when /^--(?:manifest)$/ then c=c+'y' + when /^--(?:qrcode)$/ then c=c+'Q' + when /^--(?:sqlite)$/ then c=c+'d' + when /^--(?:pg|pg?sql|postgresql)$/ then c=c+'D' + when /^--(?:remote|rsync)$/ then c=c+'R' + when /^--(?:scp)$/ then c=c+'r' + when /^--(?:source)$/ then c=c+'s' + when /^--(?:sisupod|pod)$/ then c=c+'S' + when /^--(?:git)$/ then c=c+'g' + when /^--(?:urls)$/ then c=c+'U' + when /^--(?:zap|delete)$/ then c=c+'Z' + when /^--(?:sample-search-form)$/ then c=c+'F' + when /^--(?:webserv|webrick)$/ then c=c+'W' + when /^--(?:profile)$/ then c=c+'E' + when /^--(?:maintenance|keep-processing-files)$/ then c=c+'M' + when /^--(?:verbose[=-]3)$/ then c=c+'VM' + when /^--(?:verbose[=-]2|Verbose|VERBOSE)$/ then c=c+'V' + when /^--(?:verbose(?:[=-]1)?)$/ then c=c+'v' + when /^--(?:version)$/ then c=c+'v' + when /^--(?:verbose[=-]0|quiet|silent)$/ then c=c+'q' else mod << s #mod only contains command modifiers; commands converted to character end end @@ -552,12 +553,12 @@ module SiSU_Commandline if cmd !~/[mn]/ extra+=if cmd =~/[abegHhIiLNOoPpQTtwXxyz]/ \ and cmd !~/[mn]/ - 'm' #% add dal + 'm' #% add ao elsif ((cmd =~/[Dd]/ \ or (mod.inspect =~/--(?:(?:sq)?lite|pg(?:sql)?)/)) \ and mod.inspect !~/(?:remove|(?:(?:re)?create(?:all)?|dropall|drop)$)/) \ and cmd !~/[mn]/ - 'm' #% add dal + 'm' #% add ao else '' end end @@ -630,38 +631,6 @@ module SiSU_Commandline else { bool: false, set: :na, inst: nil } end - act[:verbose]=(cmd =~/v/ \ - || mod.inspect =~/"--verbose"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:version_info]=(cmd =~/[vVM]/ \ - || mod.inspect =~/"--verbose"|"--maintenance"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:quiet]=(cmd =~/q/ \ - || mod.inspect =~/"--quiet"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:color_state]=if mod.inspect =~/"--color-on"|"--color"/ - { bool: true, set: :on } - elsif (cmd =~/k/ \ - || mod.inspect =~/"--color-off"/) - { bool: false, set: :off } - else { bool: true, set: :na } #fix default color - end -# act[:color_toggle]=if cmd =~/c/ \ -# or mod.inspect =~/"--color-toggle"/ -# true -# else false -# end - act[:maintenance]=(cmd =~/M/ \ - || mod.inspect =~/"--maintenance|--keep-processing-files"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:profile]=(cmd =~/E/ \ - || mod.inspect =~/"--profile"/) \ - ? { 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]+/) @@ -714,16 +683,6 @@ module SiSU_Commandline { 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 } - elsif act[:manifest]=(cmd =~/y/ \ - || mod.inspect =~/"--manifest"/) - { bool: true, set: :on } - 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)-manifest"/ \ @@ -806,10 +765,6 @@ module SiSU_Commandline { bool: false, set: :off } else { bool: true, set: :na } end - act[:dal]=(cmd =~/m/ \ - || mod.inspect =~/"--dal"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } act[:html]=if (cmd =~/h/ \ || mod.inspect =~/"--html"/) act[:html_scroll]={ bool: true, set: :on } @@ -907,6 +862,19 @@ module SiSU_Commandline || mod.inspect =~/"--xml-dom"/) \ ? { bool: true, set: :on } : { bool: false, set: :na } + act[:xml_docbook_book]=mod.inspect =~/"--docbook"|"--docbook-book"|"--xml-docbook"|"--xml-docbook_book"/ \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:xml_fictionbook]=(cmd =~/f/ \ + || mod.inspect =~/"--fictionbook"|"--xml-fictionbook"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:xml_scaffold_structure_sisu]=mod.inspect =~/"--xml-scaffold"|"--xml-scaffold-sisu"/ \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:xml_scaffold_structure_collapse]=mod.inspect =~/"--xml-scaffold-collapse"/ \ + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:xhtml]=(cmd =~/b/ \ || mod.inspect =~/"--xhtml"/) \ ? { bool: true, set: :on } @@ -915,6 +883,18 @@ module SiSU_Commandline || mod.inspect =~/"--txt"/) \ ? { bool: true, set: :on } : { bool: false, set: :na } + act[:txt_textile]=(mod.inspect =~/"--textile"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:txt_asciidoc]=(mod.inspect =~/"--asciidoc"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:txt_markdown]=(mod.inspect =~/"--markdown"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:txt_rst]=(mod.inspect =~/"--rst"|"--rest"|"--restructuredtext"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } act[:manpage]=(cmd =~/i/ \ || mod.inspect =~/"--manpage"|"--man"/) \ ? { bool: true, set: :on } @@ -923,10 +903,6 @@ module SiSU_Commandline || mod.inspect =~/"--texinfo"/) \ ? { bool: true, set: :on } : { bool: false, set: :na } - act[:fictionbook]=(cmd =~/f/ \ - || mod.inspect =~/"--fictionbook"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } act[:psql]=(cmd =~/D/ \ || mod.inspect =~/"--pg"|"--pgsql"/) \ ? { bool: true, set: :on } @@ -978,7 +954,7 @@ module SiSU_Commandline ? { bool: true, set: :on } : { bool: false, set: :na } act[:rsync]=(cmd =~/R/ \ - || mod.inspect =~/"--rsync"/) \ + || mod.inspect =~/"--rsync"|"--remote"/) \ ? { bool: true, set: :on } : { bool: false, set: :na } act[:zap]=(cmd =~/Z/ \ @@ -1004,6 +980,157 @@ module SiSU_Commandline act[:help]=(mod.inspect =~/"--help/) \ ? { bool: true, set: :on } : { bool: false, set: :na } + act[:ao]=if (cmd =~/m/ \ + || mod.inspect =~/"--ao"|"--dal"/) + { bool: true, set: :on } + elsif (act[:txt][:set]==:on \ + || act[:txt_textile][:set]==:on \ + || act[:txt_asciidoc][:set]==:on \ + || act[:txt_markdown][:set]==:on \ + || act[:txt_rst][:set]==:on \ + || act[:xhtml][:set]==:on \ + || act[:epub][:set]==:on \ + || act[:html][:set]==:on \ + || act[:html_seg][:set]==:on \ + || act[:html_scroll][:set]==:on \ + || act[:texinfo][:set]==:on \ + || act[:manpage][:set]==:on \ + || act[:hash_digests][:set]==:on \ + || act[:odt][:set]==:on \ + || act[:pdf][:set]==:on \ + || act[:pdf_p][:set]==:on \ + || act[:pdf_l][:set]==:on \ + || act[:qrcode][:set]==:on \ + || act[:share_source][:set]==:on \ + || act[:sisupod][:set]==:on \ + || act[:concordance][:set]==:on \ + || act[:xml_dom][:set]==:on \ + || act[:xml_sax][:set]==:on \ + || act[:xml_docbook_book][:set]==:on \ + || act[:xml_fictionbook][:set]==:on \ + || act[:xml_scaffold_structure_sisu][:set]==:on \ + || act[:xml_scaffold_structure_collapse][:set]==:on ) + { bool: true, set: :on } + #if cmd !~/[mn]/ + # extra+=if cmd =~/[abegHhIiLNOoPpQTtwXxyz]/ \ + # and cmd !~/[mn]/ + # 'm' #% add ao + #elsif (act[:txt][:set]==:on \ + # { bool: true, set: :on } + # elsif ((cmd =~/[Dd]/ \ + # or (mod.inspect =~/--(?:(?:sq)?lite|pg(?:sql)?)/)) \ + # and mod.inspect !~/(?:remove|(?:(?:re)?create(?:all)?|dropall|drop)$)/) \ + # and cmd !~/[mn]/ + # 'm' #% add ao + else + { bool: false, 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 } + elsif (cmd =~/y/ \ + || mod.inspect =~/"--manifest"/) + { bool: true, set: :on } + elsif (act[:txt][:set]==:on \ + || act[:txt_textile][:set]==:on \ + || act[:txt_asciidoc][:set]==:on \ + || act[:txt_markdown][:set]==:on \ + || act[:txt_rst][:set]==:on \ + || act[:xhtml][:set]==:on \ + || act[:epub][:set]==:on \ + || act[:html][:set]==:on \ + || act[:html_seg][:set]==:on \ + || act[:html_scroll][:set]==:on \ + || act[:texinfo][:set]==:on \ + || act[:manpage][:set]==:on \ + || act[:hash_digests][:set]==:on \ + || act[:odt][:set]==:on \ + || act[:pdf][:set]==:on \ + || act[:pdf_p][:set]==:on \ + || act[:pdf_l][:set]==:on \ + || act[:qrcode][:set]==:on \ + || act[:share_source][:set]==:on \ + || act[:sisupod][:set]==:on \ + || act[:concordance][:set]==:on \ + || act[:xml_dom][:set]==:on \ + || act[:xml_sax][:set]==:on \ + || act[:xml_docbook_book][:set]==:on \ + || act[:xml_fictionbook][:set]==:on \ + || act[:xml_scaffold_structure_sisu][:set]==:on \ + || act[:xml_scaffold_structure_collapse][:set]==:on ) + { bool: true, set: :on } + ## if cmd !~/y/ + ## extra+=if cmd =~/[abeHhIiNopQSstwXxz]/ \ + ## and cmd !~/y/ + ## 'ym' #% add manifest + #elsif (act[:txt][:set]==:on \ + # { bool: true, set: :on } + # elsif (cmd =~/[Dd]/ \ + # or mod.inspect =~/--(?:(?:sq)?lite|pg(?:sql)?)/) \ + # and files[0] !~/^remove$/ \ + # and cmd !~/y/ + # 'ym' #% add manifest + else { bool: true, set: :na } + end + act[:console_messages] = '' + act[:verbose]=if (cmd =~/v/ \ + || mod.inspect =~/"--verbose"/) + act[:console_messages] << ' --verbose ' + { bool: true, set: :on } + else + { bool: false, set: :na } + end + act[:verbose_plus]=if (cmd =~/V/ \ + || mod.inspect =~/"--very-verbose"/) + act[:console_messages] << ' --very-verbose ' + { bool: true, set: :on } + else + { bool: false, set: :na } + end + act[:version_info]=if (cmd =~/[vVM]/ \ + || mod.inspect =~/"--verbose"|"--maintenance"/) + act[:console_messages] << ' --maintenance ' + { bool: true, set: :on } + else + { bool: false, set: :na } + end + act[:quiet]=if (cmd =~/q/ \ + || mod.inspect =~/"--quiet"/) + act[:console_messages] << ' --quiet ' + { bool: true, set: :on } + else + { bool: false, set: :na } + end + act[:color_state]=if mod.inspect =~/"--color-on"|"--color"/ + act[:console_messages] << ' --color-on ' + { bool: true, set: :on } + elsif (cmd =~/k/ \ + || mod.inspect =~/"--color-off"/) + act[:console_messages] << ' --color-off ' + { bool: false, set: :off } + else { bool: true, set: :na } #fix default color + end +# act[:color_toggle]=if cmd =~/c/ \ +# or mod.inspect =~/"--color-toggle"/ +# true +# else false +# end + act[:maintenance]=if (cmd =~/M/ \ + || mod.inspect =~/"--maintenance|--keep-processing-files"/) + act[:console_messages] << ' --maintenance ' + { bool: true, set: :on } + else + { bool: false, set: :na } + end + act[:profile]=if (cmd =~/E/ \ + || mod.inspect =~/"--profile"/) + act[:console_messages] << ' --color-off ' + { bool: true, set: :on } + else + { bool: false, set: :na } + end @act=act end end diff --git a/lib/sisu/v4/param.rb b/lib/sisu/v6/param.rb index 86dd6a01..b74e0dc1 100644 --- a/lib/sisu/v4/param.rb +++ b/lib/sisu/v6/param.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/param.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/param.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -78,7 +79,7 @@ module SiSU_Param @@md=@@fns=@@pth=nil def initialize(opt) @opt=opt - @cX||=SiSU_Screen::Ansi.new(opt.cmd) + @cX||=SiSU_Screen::Ansi.new(@opt.act[:color_state][:set]) @cmd,@mod=opt.cmd,opt.mod @fns=if @opt.cmd =~/P/ #revisit CHECK opt.fns @@ -86,7 +87,7 @@ module SiSU_Param end SiSU_Param::Instantiate.new.param_instantiate @env=SiSU_Env::InfoEnv.new(@fns) - @pstorefile="#{@env.processing_path.dal}/#{@fns}.pstore" + @pstorefile="#{@env.processing_path.ao}/#{@fns}.pstore" end def get if @opt.f_pth \ @@ -105,7 +106,7 @@ module SiSU_Param @@md=nil end if @@md.nil? \ - or @opt.cmd =~/M/ #not particularly helpful, as current cycle is through output types, with files changing, only helpful if deal with a file all output types before going to next file + or @opt.act[:maintenance][:set]==:on #not particularly helpful, as current cycle is through output types, with files changing, only helpful if deal with a file all output types before going to next file if File.exist?(@pstorefile) param_msg='Parameters from pstore' store=PStore.new(@pstorefile) @@ -120,7 +121,11 @@ module SiSU_Param @md end if defined? @md.title.main # on removal check problems with -U - SiSU_Screen::Ansi.new(@opt.cmd,param_msg,@md.title.main).txt_grey if @opt.cmd =~/[MVv]/ + if (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],param_msg,@md.title.main).txt_grey + end end @@md=@md else @@md @@ -178,7 +183,7 @@ module SiSU_Param STDERR.puts "#{n} is #{s.class}: programming error, String expected #{__FILE__}:#{__LINE__}" s else - SiSU_Screen::Ansi.new('v',"*WARN* #{n} length #{s.length} exceeds set db field length #{l}, metadata dropped",@opt.fns).warn unless @opt.cmd =~/q/ + SiSU_Screen::Ansi.new('v',"*WARN* #{n} length #{s.length} exceeds set db field length #{l}, metadata dropped",@opt.fns).warn unless @opt.act[:quiet][:set]==:on nil end end @@ -499,7 +504,7 @@ module SiSU_Param elsif @h['main'] @h['main'] else - SiSU_Screen::Ansi.new(@opt.cmd,'WARNING Document Copyright missing; provide @rights: :copyright:').warn unless @opt.cmd =~/q/ + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'WARNING Document Copyright missing; provide @rights: :copyright:').warn unless @opt.act[:quiet][:set]==:on '' end l,n=Db[:col_info_note],'rights.copyright.text' @@ -598,7 +603,7 @@ module SiSU_Param s +='\\\\ License: ' + copyright.license end if s.empty? - SiSU_Screen::Ansi.new(@opt.cmd,'WARNING Document Rights information missing; provide @rights: :copyright:').warn unless @opt.cmd =~/q/ + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'WARNING Document Rights information missing; provide @rights: :copyright:').warn unless @opt.act[:quiet][:set]==:on else l,n=Db[:col_info_note],'rights.all' validate_length(s,l,n) @@ -827,9 +832,9 @@ module SiSU_Param @doc={ lv: [] } @doc[:fns],@doc[:fnb],@doc[:scr_suffix]='','','' @@publisher='SiSU scribe' - attr_accessor :make,:env,:path,:file,:fn,:fns,:fno,:fnb,:fnn,:fnt,:fnl,:flv,:fnz,:fnstex,:ocn,:sfx_src,:pdf,:file_type,:dir_out,:dir_tex,:dir_lout,:txt_path,:sisu,:sisu_version,:ruby_version,:title,:subtitle,:full_title,:html_title,:subtitle_tex,:creator,:classify,:author_home,:author,:author_title,:author_nationality,:authors,:authorship,:translator,:illustrator,:prepared_by,:digitized_by,:subject,:description,:publisher,:current_publisher,:contributor,:date,:date_created,:date_issued,:date_available,:date_valid,:date_modified,:date_translated,:date_added_to_site,:date_scheme,:date_created_scheme,:date_issued_scheme,:date_available_scheme,:date_valid_scheme,:date_modified_scheme,:type,:format,:identifier,:source,:language,:language_original,:relation,:coverage,:rights,:keywords,:comments,:abstract,:cls_loc,:cls_dewey,:cls_pg,:cls_isbn,:papersize,:papersize_array,:toc,:lv1,:lv2,:lv3,:lv4,:lv5,:lv6,:lvs,:pagenew,:pagebreak,:pageline,:num_top,:bold_match_list,:italics_match_list,:substitution_match_list,:emphasis_set_to,:toc_lev_limit,:flag_endnotes,:flag_auto_endnotes,:flag_separate_endnotes,:flag_separate_endnotes_make,:markup,:markup_instruction,:flag_tables,:vocabulary,:doc_css,:yaml,:lnk,:links,:prefix_a,:prefix_b,:suffix,:information,:contact,:icon,:image,:ad_url,:ad_png,:ad_alt,:ad_began,:flag_promo,:promo,:ad_home,:stmp,:stmpd,:sc_filename,:sc_number,:sc_date,:sc_time,:sc_info,:yamladdr,:locale,:wc_lines,:wc_words,:wc_bytes,:file_encoding,:filesize,:user,:home,:hostname,:pwd,:firstseg,:programs,:author_copymark,:i18n,:lang,:lang_code_insert,:en,:notes,:dgst,:generated,:tags,:tag_array,:concord_make,:seg_names,:seg_autoname_safe,:set_header_title,:set_heading_top,:set_heading_seg,:heading_seg_first,:heading_seg_first_flag,:base_program,:ec,:opt,:sem_tag,:book_idx,:topic_register,:topic_register_array,:original,:writing_focus,:audio,:daisy,:home_button_image,:home_button_links,:footer_links,:cover_image,:man_section + attr_accessor :make,:env,:path,:file,:fn,:fns,:fno,:fnb,:fnn,:fnt,:fnl,:flv,:fnz,:fnstex,:ocn,:sfx_src,:pdf,:file_type,:dir_out,:dir_tex,:dir_lout,:txt_path,:sisu,:sisu_version,:ruby_version,:title,:subtitle,:full_title,:html_title,:subtitle_tex,:creator,:classify,:author_home,:author,:author_title,:author_nationality,:authors,:authorship,:translator,:illustrator,:prepared_by,:digitized_by,:subject,:description,:publisher,:current_publisher,:contributor,:date,:date_created,:date_issued,:date_available,:date_valid,:date_modified,:date_translated,:date_added_to_site,:date_scheme,:date_created_scheme,:date_issued_scheme,:date_available_scheme,:date_valid_scheme,:date_modified_scheme,:type,:format,:identifier,:source,:language,:language_original,:relation,:coverage,:rights,:keywords,:comments,:abstract,:cls_loc,:cls_dewey,:cls_pg,:cls_isbn,:papersize,:papersize_array,:toc,:lv0,:lv1,:lv2,:lv3,:lv4,:lv5,:lv6,:lvs,:pagenew,:pagebreak,:pageline,:num_top,:bold_match_list,:italics_match_list,:substitution_match_list,:emphasis_set_to,:toc_lev_limit,:flag_endnotes,:flag_auto_endnotes,:flag_separate_endnotes,:flag_separate_endnotes_make,:markup,:markup_instruction,:flag_tables,:vocabulary,:doc_css,:yaml,:lnk,:links,:prefix_a,:prefix_b,:suffix,:information,:contact,:icon,:image,:ad_url,:ad_png,:ad_alt,:ad_began,:flag_promo,:promo,:ad_home,:stmp,:stmpd,:sc_filename,:sc_number,:sc_date,:sc_time,:sc_info,:yamladdr,:locale,:wc_lines,:wc_words,:wc_bytes,:file_encoding,:filesize,:user,:home,:hostname,:pwd,:firstseg,:programs,:author_copymark,:i18n,:lang,:lang_code_insert,:en,:notes,:dgst,:generated,:tags,:tag_array,:concord_make,:seg_names,:seg_autoname_safe,:set_header_title,:set_heading_top,:set_heading_seg,:heading_seg_first,:heading_seg_first_flag,:base_program,:ec,:opt,:sem_tag,:book_idx,:topic_register,:topic_register_array,:original,:writing_focus,:audio,:daisy,:home_button_image,:home_button_links,:footer_links,:cover_image,:man_section def initialize(fns_array,opt) - @env=@path,@file=@fn=@fns=@fno=@fnb=@fnn=@fnt=@fnl=@flv=@fnz=@fnstex=@ocn=@sfx_src=@pdf=@file_type=@dir_out=@dir_tex=@dir_lout=@txt_path=@make=@flag_endnotes=@flag_auto_endnotes=@flag_separate_endnotes=@flag_separate_endnotes_make=@sisu=@sisu_version=@ruby_version=@title=@subtitle=@full_title=@html_title=@subtitle_tex=@creator=@classify=@author_home=@author=@author_title=@author_nationality=@translator=@illustrator=@prepared_by=@digitized_by=@subject=@description=@publisher=@current_publisher=@contributor=@date=@date_created=@date_issued=@date_available=@date_valid=@date_modified=@date_translated=@date_added_to_site=@date_scheme=@date_created_scheme=@date_issued_scheme=@date_available_scheme=@date_valid_scheme=@date_modified_scheme=@type=@format=@identifier=@source=@language=@language_original=@relation=@coverage=@rights=@keywords=@comments=@abstract=@cls_loc=@cls_dewey=@cls_pg=@cls_isbn=@papersize=@toc=@lv1=@lv2=@lv3=@lv4=@lv5=@lv6=@pagenew=@pagebreak=@pageline=@num_top=@bold_match_list=@italics_match_list=@substitution_match_list=@emphasis_set_to=@toc_lev_limit=@flag_tables=@vocabulary=@doc_css=@yaml=@lnk=@links=@prefix_a=@prefix_b=@suffix=@information=@contact=@icon=@ad_url=@ad_png=@ad_alt=@ad_began=@promo=@ad_home=@stmp=@stmpd=@sc_filename=@sc_number=@sc_date=@sc_time=@sc_info=@yamladdr=@locale=@wc_lines=@wc_words=@wc_bytes=@file_encoding=@filesize=@firstseg=@programs=@author_copymark=@i18n=@lang=@lang_code_insert=@en=@notes=@dgst=@generated=@heading_seg_first=@base_program=@topic_register=@original=@writing_focus=@audio=@home_button_image=@home_button_links=@cover_image=@man_section=nil + @env=@path,@file=@fn=@fns=@fno=@fnb=@fnn=@fnt=@fnl=@flv=@fnz=@fnstex=@ocn=@sfx_src=@pdf=@file_type=@dir_out=@dir_tex=@dir_lout=@txt_path=@make=@flag_endnotes=@flag_auto_endnotes=@flag_separate_endnotes=@flag_separate_endnotes_make=@sisu=@sisu_version=@ruby_version=@title=@subtitle=@full_title=@html_title=@subtitle_tex=@creator=@classify=@author_home=@author=@author_title=@author_nationality=@translator=@illustrator=@prepared_by=@digitized_by=@subject=@description=@publisher=@current_publisher=@contributor=@date=@date_created=@date_issued=@date_available=@date_valid=@date_modified=@date_translated=@date_added_to_site=@date_scheme=@date_created_scheme=@date_issued_scheme=@date_available_scheme=@date_valid_scheme=@date_modified_scheme=@type=@format=@identifier=@source=@language=@language_original=@relation=@coverage=@rights=@keywords=@comments=@abstract=@cls_loc=@cls_dewey=@cls_pg=@cls_isbn=@papersize=@toc=@lv0=@lv1=@lv2=@lv3=@lv4=@lv5=@lv6=@pagenew=@pagebreak=@pageline=@num_top=@bold_match_list=@italics_match_list=@substitution_match_list=@emphasis_set_to=@toc_lev_limit=@flag_tables=@vocabulary=@doc_css=@yaml=@lnk=@links=@prefix_a=@prefix_b=@suffix=@information=@contact=@icon=@ad_url=@ad_png=@ad_alt=@ad_began=@promo=@ad_home=@stmp=@stmpd=@sc_filename=@sc_number=@sc_date=@sc_time=@sc_info=@yamladdr=@locale=@wc_lines=@wc_words=@wc_bytes=@file_encoding=@filesize=@firstseg=@programs=@author_copymark=@i18n=@lang=@lang_code_insert=@en=@notes=@dgst=@generated=@heading_seg_first=@base_program=@topic_register=@original=@writing_focus=@audio=@home_button_image=@home_button_links=@cover_image=@man_section=nil @data,@path,@fns,@fno,@opt=fns_array,opt.pth,opt.fns,opt.fno,opt #@data used as data @flag_tables,@set_header_title,@set_heading_top,@set_heading_seg,@heading_seg_first_flag,@flag_promo,@book_idx=false,false,false,false,false,false,false @seg_autoname_safe=true @@ -865,6 +870,7 @@ module SiSU_Param @pagebreak=common_makes[:pagebreak] @pageline=common_makes[:pageline] @toc=common_makes[:toc] + @lv0=common_makes[:lv0] @lv1=common_makes[:lv1] @lv2=common_makes[:lv2] @lv3=common_makes[:lv3] @@ -894,7 +900,10 @@ module SiSU_Param @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 (@opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) + puts 'system locale: ' + @sys.locale + end if @prog.wc \ and @sys.wc wc=%x{wc #{fns}} @@ -950,9 +959,9 @@ module SiSU_Param raise "Old markup style in file #{@fns}, current version #{@sisu_version[:project]} #{@sisu_version[:version]} #{@sisu_version[:date_stamp]} #{@sisu_version[:date]}:\n\t\t#{para}\n\n" end @code_flag=case para - when /^code\{\s*$/; true - when /^\}code\s*$/; false - else @code_flag + when /^code\{\s*$/ then true + when /^\}code\s*$/ then false + else @code_flag end regx_header=/^@\S+?:[+-]?\s/ if para =~regx_header \ @@ -1004,6 +1013,7 @@ module SiSU_Param ? (makes[:pageline]) \ : @pageline @toc=(makes[:toc]) ? (makes[:toc]) : @toc + @lv0=(makes[:lv0]) ? (makes[:lv0]) : @lv0 @lv1=(makes[:lv1]) ? (makes[:lv1]) : @lv1 @lv2=(makes[:lv2]) ? (makes[:lv2]) : @lv2 @lv3=(makes[:lv3]) ? (makes[:lv3]) : @lv3 @@ -1044,6 +1054,7 @@ module SiSU_Param ? (makes[:cover_image]) \ : @cover_image end + @lv0 ||=/^0~/ @lv1 ||=/^1~/ @lv2 ||=/^2~/ @lv3 ||=/^3~/ @@ -1079,11 +1090,12 @@ module SiSU_Param end end case para - when /^:?A~#{l_0}/ + #when /^:?A~/ + when /^:?B~#{l_0}/ @lvs[1]=1 - when /^:?B~#{l_1}/ + when /^:?C~#{l_1}/ @lvs[2]=1 - when /^:?C~#{l_2}/ + when /^:?D~#{l_2}/ @lvs[3]=1 when /^1~#{l_3}/ @lvs[4]=1 @@ -1092,7 +1104,7 @@ module SiSU_Param when /^3~#{l_5}/ @lvs[6]=1 end - if para =~ /^:A~/ #% processing + if para =~ /^:?A~/ #% processing if not defined? @title.full.nil? tf=para[/^:A~\S*(.+)$/m,1] tf="@title: #{tf}" @@ -1104,7 +1116,7 @@ module SiSU_Param ? " #{@creator.author}" : '' title=%{"#{@title.full.gsub(/(<p>|<p \/>|<br>|<br \/>)/,'')}",} - SiSU_Screen::Ansi.new(@opt.cmd,'Parameters',%{#{title}#{creator}}).txt_grey if @opt.cmd =~/v/ + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Parameters',%{#{title}#{creator}}).txt_grey if @opt.act[:verbose][:set]==:on end if not @book_idx \ and para =~/^=\{(.+?)\}\s*$/ @@ -1118,7 +1130,7 @@ module SiSU_Param when /~\^(?:\s|$)/m #% processing mk=para.scan(/~\^(?:\s|$)/) mk.each { |e| @en[:mark] +=1 } - when /^\^~\s+\S/; @en[:note] +=1 #% processing + when /^\^~\s+\S/ then @en[:note] +=1 #% processing end end if para =~/~\{|\^~ |~\^|\{.+?\[[1-6]\]\}\S+?\.ss[tm]/m @@ -1163,8 +1175,9 @@ module SiSU_Param end end #% here endeth the document loop unless @make - if @opt.cmd =~/[VM]/ - SiSU_Screen::Ansi.new(@opt.cmd,'@make:','header absent').warn + if (@opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'@make:','header absent').warn end @make=SiSU_Param::Parameters::MdMake.new('@make: ',@opt,@env).make end @@ -1295,13 +1308,13 @@ module SiSU_Param if @en[:note] > 0 \ and @en[:sum] > 0 if @en[:sum] > 0 - else SiSU_Screen::Ansi.new(@opt.cmd,'*WARN* both endnote styles used',"~{ #{@en[:sum]} }~ and ^~ #{@en[:mark]}").warn if @opt.cmd !~/q/ + else SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'*WARN* both endnote styles used',"~{ #{@en[:sum]} }~ and ^~ #{@en[:mark]}").warn unless @opt.act[:unless][:set]==:on end end if @en[:mark] != @en[:note] \ and @en[:note] > 0 @en[:mismatch]=@en[:note] - @en[:mark] - SiSU_Screen::Ansi.new(@opt.cmd,'*WARN* endnote number mismatch',"endnotes: #{@en[:note]} != endnote reference marks: #{@en[:mark]} (difference = #{@en[:mismatch]})").warn if @opt.cmd !~/q/ + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'*WARN* endnote number mismatch',"endnotes: #{@en[:note]} != endnote reference marks: #{@en[:mark]} (difference = #{@en[:mismatch]})").warn unless @opt.act[:quiet][:set]==:on footnote_conversion_errors=File.new("#{Dir.pwd}/footnote_conversion_errors.txt",'a') footnote_conversion_errors << "#{@fns}:\n\tendnotes: #{@en[:note]} != endnote reference marks: #{@en[:mark]} (difference = #{@en[:mismatch]})\n" end @@ -1312,7 +1325,7 @@ module SiSU_Param and @opt.inspect =~/P/ #@title=Md.new('Text Insert',@opt,@env).title else - SiSU_Screen::Ansi.new(@opt.cmd,'WARNING: Document Title missing','please provide @title:').warn unless @opt.cmd =~/q/ + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'WARNING: Document Title missing','please provide @title:').warn unless @opt.act[:unless][:set]==:on end end if @author !~/[\S]/ @@ -1320,7 +1333,7 @@ module SiSU_Param and @opt.inspect =~/P/ #@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/ + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'WARNING: Document Author missing','please provide @creator: :author:').warn unless @opt.act[:unless][:set]==:on end end @struct={} @@ -1380,6 +1393,7 @@ module SiSU_Param end end @lnk=@lnk.compact if @lnk + @lv0 ||=/^0~/ @lv1 ||=/^1~/ @lv2 ||=/^2~/ @lv3 ||=/^3~/ @@ -1398,9 +1412,12 @@ module SiSU_Param end def store begin - pstorefile="#{@env.processing_path.dal}/#{@md.fns}.pstore" + pstorefile="#{@env.processing_path.ao}/#{@md.fns}.pstore" File.unlink(pstorefile) if FileTest.file?(pstorefile) - SiSU_Screen::Ansi.new(@md.opt.cmd,"PStore -> #{pstorefile}").txt_grey if @md.opt.cmd =~/[MV]/ + if (@md.opt.act[:verbose_plus][:set]==:on \ + || @md.opt.act[:maintenance][:set]==:on) + SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],"PStore -> #{pstorefile}").txt_grey + end store=PStore.new(pstorefile) store.transaction do store['md']=@md diff --git a/lib/sisu/v4/param_identify_markup.rb b/lib/sisu/v6/param_identify_markup.rb index 66252af2..87879e79 100644 --- a/lib/sisu/v4/param_identify_markup.rb +++ b/lib/sisu/v6/param_identify_markup.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/param_identify_markup.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/param_identify_markup.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -150,8 +151,8 @@ module SiSU_MarkupType end def series s=case identify.version[:determined].to_s - when /^[01]\./; '1.0' - when /^[2]\./; '2.0' + when /^[01]\./ then '1.0' + when /^[2]\./ then '2.0' else '2.0' end "series #{s}" diff --git a/lib/sisu/v4/param_make.rb b/lib/sisu/v6/param_make.rb index 32576fb8..7a93e703 100644 --- a/lib/sisu/v4/param_make.rb +++ b/lib/sisu/v6/param_make.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/param_make.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/param_make.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -76,7 +77,7 @@ module SiSU_Param_Make STDERR.puts "#{n} is #{s.class}: programming error, String expected #{__FILE__}:#{__LINE__}" s else - SiSU_Screen::Ansi.new('v',"*WARN* #{n} length #{s.length} exceeds set db field length #{l}, metadata dropped",@opt.fns).warn unless @opt.cmd =~/q/ + SiSU_Screen::Ansi.new('v',"*WARN* #{n} length #{s.length} exceeds set db field length #{l}, metadata dropped",@opt.fns).warn unless @opt.act[:quiet][:set]==:on nil end end @@ -146,17 +147,18 @@ module SiSU_Param_Make x=@h['headings'] x=((x =~/;/) ? (x.split(/;\s*/)) : [ x ]) lv[0]=x - lv1=x[0] ||='1~ ' #some arbitrary changes made + lv0 ||='A~ ' #root level, single document apex, document title + lv1=x[0] ||='B~ ' lv[1]=/^#{lv1}/ - lv2=x[1] ||='2~ ' + lv2=x[1] ||='C~ ' lv[2]=/^#{lv2}/ - lv3=x[2] ||='3~ ' + lv3=x[2] ||='D~ ' lv[3]=/^#{lv3}/ - lv4=x[3] ||='4~ ' + lv4=x[3] ||='1~ ' lv[4]=/^#{lv4}/ - lv5=x[4] ||='5~ ' + lv5=x[4] ||='2~ ' lv[5]=/^#{lv5}/ - lv6=x[5] ||='6~ ' + lv6=x[5] ||='3~ ' lv[6]=/^#{lv6}/ lv end diff --git a/lib/sisu/v4/particulars.rb b/lib/sisu/v6/particulars.rb index f7979197..44fa536a 100644 --- a/lib/sisu/v4/particulars.rb +++ b/lib/sisu/v6/particulars.rb @@ -9,7 +9,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -51,7 +52,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/v4/particulars.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/particulars.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -66,14 +67,14 @@ module SiSU_Particulars include SiSU_Env require_relative 'param' # param.rb include SiSU_Param - require_relative 'dal' # dal.rb + require_relative 'ao' # ao.rb class CombinedSingleton include Singleton def get_all(opt) set_env(opt) set_file(opt) set_md(opt) - set_dal(opt) #needs @md + set_ao(opt) #needs @md end def get_env(opt) set_env(opt) @@ -84,8 +85,8 @@ module SiSU_Particulars def get_md(opt) set_md(opt) end - def get_dal_array(opt) - set_dal(opt) #needs @md + def get_ao_array(opt) + set_ao(opt) #needs @md end def get_env_md(opt) set_env(opt) @@ -149,10 +150,10 @@ module SiSU_Particulars end end end - attr_accessor :opt,:dal_array - def set_dal(opt) + attr_accessor :opt,:ao_array + def set_ao(opt) begin - @dal_array=SiSU_DAL::Source.new(opt).get + @ao_array=SiSU_AO::Source.new(opt).get self rescue SiSU_Errors::Rescued.new($!,$@,opt.cmd,opt.fnl).location do @@ -162,7 +163,7 @@ module SiSU_Particulars end def set_sst_idx(opt) begin - @sst_idx=SiSU_DAL::Source.new(opt).get_idx_sst + @sst_idx=SiSU_AO::Source.new(opt).get_idx_sst self rescue SiSU_Errors::Rescued.new($!,$@,opt.cmd,opt.fnl).location do @@ -172,7 +173,7 @@ module SiSU_Particulars end def set_raw_idx(opt) begin - @raw_idx=SiSU_DAL::Source.new(opt).get_idx_raw + @raw_idx=SiSU_AO::Source.new(opt).get_idx_raw self rescue SiSU_Errors::Rescued.new($!,$@,opt.cmd,opt.fnl).location do @@ -182,7 +183,7 @@ module SiSU_Particulars end def set_html_idx(opt) begin - @html_idx=SiSU_DAL::Source.new(opt).get_idx_html + @html_idx=SiSU_AO::Source.new(opt).get_idx_html self rescue SiSU_Errors::Rescued.new($!,$@,opt.cmd,opt.fnl).location do @@ -192,7 +193,7 @@ module SiSU_Particulars end def set_xhtml_idx(opt) begin - @xhtml_idx=SiSU_DAL::Source.new(opt).get_idx_xhtml + @xhtml_idx=SiSU_AO::Source.new(opt).get_idx_xhtml self rescue SiSU_Errors::Rescued.new($!,$@,opt.cmd,opt.fnl).location do @@ -204,7 +205,7 @@ module SiSU_Particulars def set_nametags_map(opt) begin opt=@md ? @md : opt - @nametags_map=SiSU_DAL::Source.new(opt).get_map_nametags + @nametags_map=SiSU_AO::Source.new(opt).get_map_nametags self rescue if @md @@ -221,7 +222,7 @@ module SiSU_Particulars attr_accessor :ocn_htmlseg_map def set_ocn_htmlseg_map(opt) begin - @ocn_htmlseg_map=SiSU_DAL::Source.new(@md).get_map_ocn_htmlseg + @ocn_htmlseg_map=SiSU_AO::Source.new(@md).get_map_ocn_htmlseg self rescue SiSU_Errors::Rescued.new($!,$@,opt.cmd,opt.fnl).location do diff --git a/lib/sisu/v4/po4a.rb b/lib/sisu/v6/po4a.rb index 5a74a7d0..3f890cec 100644 --- a/lib/sisu/v4/po4a.rb +++ b/lib/sisu/v6/po4a.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/po4a.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/po4a.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -61,7 +62,7 @@ =end module SiSU_Po4a - require_relative 'dal' # dal.rb + require_relative 'ao' # ao.rb require_relative 'sysenv' # sysenv.rb include SiSU_Env require_relative 'composite' # composite.rb @@ -101,24 +102,32 @@ module SiSU_Po4a end md=SiSU_Param::Parameters.new(@opt).get src[:files].each do |fn| - SiSU_DAL::Source.new(@opt,fn).read # -m + SiSU_AO::Source.new(@opt,fn).read # -m 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/ + unless @opt.act[:quiet][:set]==:on path=env.path.output_tell - tool=(@opt.cmd =~/[MVv]/) \ + tool=(@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) \ ? "#{env.program.text_editor} #{path}/#{md.fnb}/#{md.fn[:plain]}" : @opt.fns - @opt.cmd=~/[MVvz]/ \ - ? SiSU_Screen::Ansi.new(@opt.cmd,'Pot po4a',tool).green_hi_blue - : SiSU_Screen::Ansi.new(@opt.cmd,'Pot po4a',tool).green_title_hi - SiSU_Screen::Ansi.new(@opt.cmd,@opt.fns,"#{path}/#{md.fnb}/#{md.fn[:plain]}").flow if @opt.cmd =~/[MV]/ + (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) \ + ? SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Pot po4a',tool).green_hi_blue + : SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Pot po4a',tool).green_title_hi + if (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],@opt.fns,"#{path}/#{md.fnb}/#{md.fn[:plain]}").flow + end end if @opt.fns =~/\S+?~#{@lang_regx}\.ss[mti]/ \ or @opt.f_pth[:lng] !=@opt.lng_base opt_lang_trn_fn=fn - @dal_array_lang_translation=SiSU_DAL::Source.new(@opt,opt_lang_trn_fn).get # dal file drawn here + @ao_array_lang_translation=SiSU_AO::Source.new(@opt,opt_lang_trn_fn).get # ao file drawn here opt_lang_src_fn=if fn =~/\S+?~\S{2}(?:_\S{2})?\.ss[mti]/ fn.gsub(/(\S+?)~\S{2}(?:_\S{2})?(\.ss[mti])/,'\1\2') #check i else fn @@ -133,15 +142,15 @@ module SiSU_Po4a else nil end if FileTest.file?("#{srcdir}/#{opt_lang_src_fn}") - @dal_array_lang_src=SiSU_DAL::Source.new(@@opt_src,opt_lang_src_fn).get # dal file drawn here + @ao_array_lang_src=SiSU_AO::Source.new(@@opt_src,opt_lang_src_fn).get # ao file drawn here else puts "no identified source document" exit end Dir.chdir(transdir) if transdir else - @dal_array_lang_src=SiSU_DAL::Source.new(@opt,fn).get # dal file drawn here - @dal_array_lang_translation=nil + @ao_array_lang_src=SiSU_AO::Source.new(@opt,fn).get # ao file drawn here + @ao_array_lang_translation=nil end wrap_width=if defined? md.make.plaintext_wrap \ and md.make.plaintext_wrap @@ -151,7 +160,7 @@ 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_Po4a::Source::Scroll.new(fn,@ao_array_lang_src,@ao_array_lang_translation,@@md_src,@@md_trn,wrap_width).songsheet end rescue SiSU_Errors::Rescued.new($!,$@,@opt.cmd,@opt.fns).location do @@ -210,7 +219,7 @@ module SiSU_Po4a d="#{nt} #{@fn}" mark="^~ " instruct=s_mark='' - if @md.opt.cmd=~/M/ + if @md.opt.act[:maintenance][:set]==:on instruct=%{\n# footnotes, the preferred sisu markup for a footnote is~{this is a footnote}~ however, for translation a footnote reference marker in the text~^ with a set of notes following the paragraph starting on a newline with "^~ this is a footnote", is easier to deal with, if possible these should be converted back to~{inline notes}~} s_mark="\n# " + %{"\\n\\n#{mark}...\\n\\n"} end @@ -509,7 +518,7 @@ GSUB mark="#{dob_src.lv}~#{fn} " d="#{dob_src.is.to_s} (level #{dob_src.lv})" instruct=s_mark='' - if @md.opt.cmd=~/M/ + if @md.opt.act[:maintenance][:set]==:on 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}"} s_mark="\n# " + %{"\\n\\n#{mark}...\\n\\n"} end @@ -538,7 +547,7 @@ GSUB mark="_#{dob_src.indent}* " d="#{dob_src.is.to_s}: indent #{dob_src.indent}, bullet" instruct=s_mark='' - if @md.opt.cmd=~/M/ + if @md.opt.act[:maintenance][:set]==:on 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}"} s_mark="\n# " + %{"\\n\\n#{mark}...\\n\\n"} end @@ -547,7 +556,7 @@ GSUB mark="_#{dob_src.indent} " d="#{dob_src.is.to_s}: indent #{dob_src.indent}" instruct=s_mark='' - if @md.opt.cmd=~/M/ + if @md.opt.act[:maintenance][:set]==:on instruct=%{\n# markup for indented text is at the start of the line/object, an underscore followed by the indent level "#{mark}"} s_mark="\n# " + %{"\\n\\n#{mark}...\\n\\n"} end @@ -562,7 +571,7 @@ GSUB mark="_#{dob_src.hang}_#{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/ + if @md.opt.act[:maintenance][:set]==:on 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}"} s_mark="\n# " + %{"\\n\\n#{mark}...\\n\\n"} end @@ -576,7 +585,7 @@ GSUB mark='_* ' d="#{dob_src.is.to_s}: bullet" instruct=s_mark='' - if @md.opt.cmd=~/M/ + if @md.opt.act[:maintenance][:set]==:on instruct=%{\n# markup for indented text is at the start of the line/object, an underscore followed by an asterisk "#{mark}"} s_mark="\n# " + %{"\\n\\n#{mark}...\\n\\n"} end @@ -587,7 +596,7 @@ GSUB mark='' d=dob_src.is.to_s instruct=%{\n# regular paragraph, no special markup} - if @md.opt.cmd=~/M/ + if @md.opt.act[:maintenance][:set]==:on instruct="\n# " s_mark="\n# " + %{"\\n\\n#{mark}...\\n\\n"} end @@ -613,7 +622,7 @@ GSUB mark="block{\\n\\n...\\n\\n}block" d=dob_src.is.to_s instruct=s_mark='' - if @md.opt.cmd=~/M/ + if @md.opt.act[:maintenance][:set]==:on instruct="\n# block text is a text block with an opening and closing marker, the content of which may be wrapped" s_mark="\n# " + %{"\\n\\n#{mark}\\n\\n"} end @@ -628,7 +637,7 @@ GSUB mark="group{\\n\\n...\\n\\n}group" d=dob_src.is.to_s instruct=s_mark='' - if @md.opt.cmd=~/M/ + if @md.opt.act[:maintenance][:set]==:on instruct="\n# group text is a text block with an opening and closing marker, the content of which may be wrapped" s_mark="\n# " + %{"\\n\\n#{mark}\\n\\n"} end @@ -643,7 +652,7 @@ GSUB mark="poem{\n\nverse\n\nverse\n\n...\n\n}poem" d=dob_src.is.to_s instruct=s_mark='' - if @md.opt.cmd=~/M/ + 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 @@ -658,7 +667,7 @@ GSUB mark="code{\\n\\n...\\n\\n}code" d=dob_src.is.to_s instruct=s_mark='' - if @md.opt.cmd=~/M/ + if @md.opt.act[:maintenance][:set]==:on instruct="\n# codeblocks are a text block with an opening and closing marker, the content of which should remain unwrapped" s_mark="\n# " + %{"\\n\\n#{mark}\\n\\n"} end @@ -673,7 +682,7 @@ GSUB mark="table{\\n\\n...\\n\\n}table" d=dob_src.is.to_s instruct=s_mark='' - if @md.opt.cmd=~/M/ + if @md.opt.act[:maintenance][:set]==:on instruct="\n# tables are a text block with an opening and closing marker, the content of which should remain unwrapped" s_mark="\n# " + %{"\\n\\n#{mark}\\n\\n"} end @@ -689,7 +698,7 @@ GSUB def pot_structure_idx(dob_src='',dob_trn='') #% Used to extract the structure of a document mark="={ ... }" instruct=s_mark='' - if @md.opt.cmd=~/M/ + if @md.opt.act[:maintenance][:set]==:on instruct="\n# the book index should be attached unwrapped to the preceding text block (there should be a new line, but no empty line)" s_mark="\n# " + %{"\\n#{mark}\\n\\n"} end @@ -736,11 +745,11 @@ GSUB 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 - puts "src (comment):\n\t" + data_src[s].obj if @md.opt.cmd =~/M/ + puts "src (comment):\n\t" + data_src[s].obj if @md.opt.act[:maintenance][:set]==:on s+=1 #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/ + puts "trans (comment):\n\t" + data_trn[t].obj if @md.opt.act[:maintenance][:set]==:on t+=1 #next if data_trn[t].is == :comment end @@ -812,13 +821,13 @@ GSUB @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 then pot_structure_heading(dob_src,notes_s,dob_trn,notes_t) + when :para then pot_structure_para(dob_src,notes_s,dob_trn,notes_t) + when :group then pot_structure_group(dob_src,notes_s,dob_trn,notes_t) + when :block then pot_structure_block(dob_src,notes_s,dob_trn,notes_t) + when :verse then pot_structure_verse(dob_src,notes_s,dob_trn,notes_t) + when :code then pot_structure_code(dob_src,notes_s,dob_trn,notes_t) + when :table then pot_structure_table(dob_src,notes_s,dob_trn,notes_t) end if defined? dob_src.idx \ and not dob_src.idx.nil? \ @@ -949,7 +958,7 @@ GSUB po4a_git end def po4a_git - unless @md.opt.cmd =~/M/ + unless @md.opt.act[:maintenance][:set]==:on require_relative 'git' # git.rb git=SiSU_Git::Source.new(@md.opt) git.create_file_structure_git unless FileTest.directory?(@file.output_path.pot_git.dir) diff --git a/lib/sisu/v4/po4a_set.rb b/lib/sisu/v6/po4a_set.rb index 306be0e9..67d2be0f 100644 --- a/lib/sisu/v4/po4a_set.rb +++ b/lib/sisu/v6/po4a_set.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/po4a_set.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/po4a_set.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -216,52 +217,52 @@ WOK end def start_is_match case @p - when /^#{Mx[:meta_o]}(title)#{Mx[:meta_c]}\s*(.+?)$/; header($1,@md.title.full,'meta','dc') #dc 1 - when /^#{Mx[:meta_o]}(creator|author)#{Mx[:meta_c]}\s*(.+?)$/; header('creator',$2,'meta','dc') #dc 2 - when /^#{Mx[:meta_o]}(subject)#{Mx[:meta_c]}\s*(.+?)$/; header($1,$2,'meta','dc') #dc 3 - when /^#{Mx[:meta_o]}(description)#{Mx[:meta_c]}\s*(.+?)$/; header($1,$2,'meta','dc') #dc 4 - when /^#{Mx[:meta_o]}(publisher)#{Mx[:meta_c]}\s*(.+?)$/; header($1,$2,'meta','dc') #dc 5 - when /^#{Mx[:meta_o]}(contributor)#{Mx[:meta_c]}\s*(.+?)$/; header($1,$2,'meta','dc') #dc 6 - when /^#{Mx[:meta_o]}(date)#{Mx[:meta_c]}\s*(.+?)$/; header($1,$2,'meta','dc') #dc 7 - when /^#{Mx[:meta_o]}(date\.created)#{Mx[:meta_c]}\s*(.+?)$/; header($1,$2,'meta','extra') - when /^#{Mx[:meta_o]}(date\.issued)#{Mx[:meta_c]}\s*(.+?)$/; header($1,$2,'meta','extra') - when /^#{Mx[:meta_o]}(date\.available)#{Mx[:meta_c]}\s*(.+?)$/; header($1,$2,'meta','extra') - when /^#{Mx[:meta_o]}(date\.valid)#{Mx[:meta_c]}\s*(.+?)$/; header($1,$2,'meta','extra') - when /^#{Mx[:meta_o]}(date\.modified)#{Mx[:meta_c]}\s*(.+?)$/; header($1,$2,'meta','extra') - when /^#{Mx[:meta_o]}(type)#{Mx[:meta_c]}\s*(.+?)$/; header($1,$2,'meta','dc') #dc 8 - when /^#{Mx[:meta_o]}(format)#{Mx[:meta_c]}\s*(.+?)$/; header($1,$2,'meta','dc') #dc 9 - when /^#{Mx[:meta_o]}(identifier)#{Mx[:meta_c]}\s*(.+?)$/; header($1,$2,'meta','dc') #dc 10 - when /^#{Mx[:meta_o]}(source)#{Mx[:meta_c]}\s*(.+?)$/; header($1,$2,'meta','dc') #dc 11 - when /^#{Mx[:meta_o]}(language)#{Mx[:meta_c]}\s*(.+?)$/; header($1,$2,'meta','dc') #dc 12 - when /^#{Mx[:meta_o]}(relation)#{Mx[:meta_c]}\s*(.+?)$/; header($1,$2,'meta','dc') #dc 13 - when /^#{Mx[:meta_o]}(coverage)#{Mx[:meta_c]}\s*(.+?)$/; header($1,$2,'meta','dc') #dc 14 - when /^#{Mx[:meta_o]}(rights)#{Mx[:meta_c]}\s*(.+?)$/; header($1,$2,'meta','dc') #dc 15 - when /^#{Mx[:meta_o]}(keywords)#{Mx[:meta_c]}\s*(.+?)$/; header($1,$2,'meta','extra') - when /^#{Mx[:meta_o]}(copyright)#{Mx[:meta_c]}\s*(.+?)$/; header($1,$2,'meta','extra') - when /^#{Mx[:meta_o]}(translator|translated_by)#{Mx[:meta_c]}\s*(.+?)$/; header('translator',$2) - when /^#{Mx[:meta_o]}(illustrator|illustrated_by)#{Mx[:meta_c]}\s*(.+?)$/; header('illustrator',$2) - when /^#{Mx[:meta_o]}(prepared_by)#{Mx[:meta_c]}\s*(.+?)$/; header($1,$2,'meta','extra') - when /^#{Mx[:meta_o]}(digitized_by)#{Mx[:meta_c]}\s*(.+?)$/; header($1,$2,'meta','extra') - when /^#{Mx[:meta_o]}(comments?)#{Mx[:meta_c]}\s*(.+?)$/; header($1,$2,'meta','extra') - when /^#{Mx[:meta_o]}(abstract)#{Mx[:meta_c]}\s*(.+?)$/; header($1,$2,'meta','extra') - when /^#{Mx[:meta_o]}(tags?)#{Mx[:meta_c]}\s*(.+?)$/; header($1,$2,'meta','extra') - when /^#{Mx[:meta_o]}(catalogue)#{Mx[:meta_c]}\s*(.+?)$/; header($1,$2,'meta','extra') - when /^#{Mx[:meta_o]}(class(?:ify)?_loc)#{Mx[:meta_c]}\s*(.+?)$/; header('classify_loc',$2,'meta','extra') - when /^#{Mx[:meta_o]}(class(?:ify)?_dewey)#{Mx[:meta_c]}\s*(.+?)$/; header('classify_dewey',$2,'meta','extra') - when /^#{Mx[:meta_o]}(class(?:ify)?_pg)#{Mx[:meta_c]}\s*(.+?)$/; header('classify_pg',$2,'meta','extra') - when /^#{Mx[:meta_o]}(class(?:ify)?_isbn)#{Mx[:meta_c]}\s*(.+?)$/; header('classify_isbn',$2,'meta','extra') - when /^#{Mx[:meta_o]}(toc|structure)#{Mx[:meta_c]}\s*(.+?)$/; header('structure',$2,'process','instruct') - when /^#{Mx[:meta_o]}(level|page|markup)#{Mx[:meta_c]}\s*(.+?)$/; header('markup',$2,'process','instruct') - when /^#{Mx[:meta_o]}(bold)#{Mx[:meta_c]}\s*(.+?)$/; header($1,$2,'process','instruct') - when /^#{Mx[:meta_o]}(italics|itali[sz]e)#{Mx[:meta_c]}\s*(.+?)$/; header('italicize',$2,'process','instruct') - when /^#{Mx[:meta_o]}(vocabulary|wordlist)#{Mx[:meta_c]}\s*(.+?)$/; header('vocabulary',$2,'process','instruct') - when /^#{Mx[:meta_o]}(css|stylesheet)#{Mx[:meta_c]}\s*(.+?)$/; header('css',$2,'process','instruct') - when /^#{Mx[:meta_o]}(links)#{Mx[:meta_c]}\s*(.+?)$/; header($1,$2,'process','instruct') - when /^#{Mx[:meta_o]}(prefix)#{Mx[:meta_c]}\s*(.+?)$/; header($1,$2,'process','instruct') #add a & b - when /^#{Mx[:meta_o]}(suffix)#{Mx[:meta_c]}\s*(.+?)$/; header($1,$2,'process','instruct') - when /^#{Mx[:meta_o]}(information)#{Mx[:meta_c]}\s*(.+?)$/; header($1,$2,'process','instruct') - when /^#{Mx[:meta_o]}(contact)#{Mx[:meta_c]}\s*(.+?)$/; header($1,$2,'process','instruct') - when /^#{Mx[:meta_o]}(rcs|cvs)#{Mx[:meta_c]}\s*(.+?)$/; header('version',$2,'process','instruct') + when /^#{Mx[:meta_o]}(title)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,@md.title.full,'meta','dc') #dc 1 + when /^#{Mx[:meta_o]}(creator|author)#{Mx[:meta_c]}\s*(.+?)$/ then header('creator',$2,'meta','dc') #dc 2 + when /^#{Mx[:meta_o]}(subject)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','dc') #dc 3 + when /^#{Mx[:meta_o]}(description)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','dc') #dc 4 + when /^#{Mx[:meta_o]}(publisher)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','dc') #dc 5 + when /^#{Mx[:meta_o]}(contributor)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','dc') #dc 6 + when /^#{Mx[:meta_o]}(date)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','dc') #dc 7 + when /^#{Mx[:meta_o]}(date\.created)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','extra') + when /^#{Mx[:meta_o]}(date\.issued)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','extra') + when /^#{Mx[:meta_o]}(date\.available)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','extra') + when /^#{Mx[:meta_o]}(date\.valid)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','extra') + when /^#{Mx[:meta_o]}(date\.modified)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','extra') + when /^#{Mx[:meta_o]}(type)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','dc') #dc 8 + when /^#{Mx[:meta_o]}(format)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','dc') #dc 9 + when /^#{Mx[:meta_o]}(identifier)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','dc') #dc 10 + when /^#{Mx[:meta_o]}(source)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','dc') #dc 11 + when /^#{Mx[:meta_o]}(language)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','dc') #dc 12 + when /^#{Mx[:meta_o]}(relation)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','dc') #dc 13 + when /^#{Mx[:meta_o]}(coverage)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','dc') #dc 14 + when /^#{Mx[:meta_o]}(rights)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','dc') #dc 15 + when /^#{Mx[:meta_o]}(keywords)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','extra') + when /^#{Mx[:meta_o]}(copyright)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','extra') + when /^#{Mx[:meta_o]}(translator|translated_by)#{Mx[:meta_c]}\s*(.+?)$/ then header('translator',$2) + when /^#{Mx[:meta_o]}(illustrator|illustrated_by)#{Mx[:meta_c]}\s*(.+?)$/ then header('illustrator',$2) + when /^#{Mx[:meta_o]}(prepared_by)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','extra') + when /^#{Mx[:meta_o]}(digitized_by)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','extra') + when /^#{Mx[:meta_o]}(comments?)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','extra') + when /^#{Mx[:meta_o]}(abstract)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','extra') + when /^#{Mx[:meta_o]}(tags?)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','extra') + when /^#{Mx[:meta_o]}(catalogue)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','extra') + when /^#{Mx[:meta_o]}(class(?:ify)?_loc)#{Mx[:meta_c]}\s*(.+?)$/ then header('classify_loc',$2,'meta','extra') + when /^#{Mx[:meta_o]}(class(?:ify)?_dewey)#{Mx[:meta_c]}\s*(.+?)$/ then header('classify_dewey',$2,'meta','extra') + when /^#{Mx[:meta_o]}(class(?:ify)?_pg)#{Mx[:meta_c]}\s*(.+?)$/ then header('classify_pg',$2,'meta','extra') + when /^#{Mx[:meta_o]}(class(?:ify)?_isbn)#{Mx[:meta_c]}\s*(.+?)$/ then header('classify_isbn',$2,'meta','extra') + when /^#{Mx[:meta_o]}(toc|structure)#{Mx[:meta_c]}\s*(.+?)$/ then header('structure',$2,'process','instruct') + when /^#{Mx[:meta_o]}(level|page|markup)#{Mx[:meta_c]}\s*(.+?)$/ then header('markup',$2,'process','instruct') + when /^#{Mx[:meta_o]}(bold)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'process','instruct') + when /^#{Mx[:meta_o]}(italics|itali[sz]e)#{Mx[:meta_c]}\s*(.+?)$/ then header('italicize',$2,'process','instruct') + when /^#{Mx[:meta_o]}(vocabulary|wordlist)#{Mx[:meta_c]}\s*(.+?)$/ then header('vocabulary',$2,'process','instruct') + when /^#{Mx[:meta_o]}(css|stylesheet)#{Mx[:meta_c]}\s*(.+?)$/ then header('css',$2,'process','instruct') + when /^#{Mx[:meta_o]}(links)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'process','instruct') + when /^#{Mx[:meta_o]}(prefix)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'process','instruct') #add a & b + when /^#{Mx[:meta_o]}(suffix)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'process','instruct') + when /^#{Mx[:meta_o]}(information)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'process','instruct') + when /^#{Mx[:meta_o]}(contact)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'process','instruct') + when /^#{Mx[:meta_o]}(rcs|cvs)#{Mx[:meta_c]}\s*(.+?)$/ then header('version',$2,'process','instruct') else nil end end diff --git a/lib/sisu/v4/prog_text_translation.rb b/lib/sisu/v6/prog_text_translation.rb index 0ecb17e8..177f17b9 100644 --- a/lib/sisu/v4/prog_text_translation.rb +++ b/lib/sisu/v6/prog_text_translation.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/prog_text_translation.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/prog_text_translation.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -66,35 +67,35 @@ module SiSU_Translate def initialize(md,doc_lang,trans_str='') @md,@doc_lang,@trans_str=md,doc_lang,trans_str @lang_class=case @doc_lang - when /American/i; English.new(md,doc_lang,trans_str) # tag depreciated, see iso 639-2 - when /English/i; English.new(md,doc_lang,trans_str) - when /French/i; French.new(md,doc_lang,trans_str) - when /German/i; German.new(md,doc_lang,trans_str) - when /Italian/i; Italian.new(md,doc_lang,trans_str) - when /Spanish/i; Spanish.new(md,doc_lang,trans_str) - when /Portuguese Brazil|Brazilian(?: Portuguese)?/i; - Portuguese.new(md,doc_lang,trans_str) # tag depreciated, see iso 639-2 - when /Portuguese/i; Portuguese.new(md,doc_lang,trans_str) - when /Swedish/i; Swedish.new(md,doc_lang,trans_str) - when /Danish/i; Danish.new(md,doc_lang,trans_str) - when /Finnish/i; Finnish.new(md,doc_lang,trans_str) - when /Norwegian/i; Norwegian.new(md,doc_lang,trans_str) - when /Icelandic/i; Icelandic.new(md,doc_lang,trans_str) - when /Dutch/i; Dutch.new(md,doc_lang,trans_str) - when /Estonian/i; Estonian.new(md,doc_lang,trans_str) - when /Hungarian/i; Hungarian.new(md,doc_lang,trans_str) - when /Polish/i; Polish.new(md,doc_lang,trans_str) - when /Romanian/i; Romanian.new(md,doc_lang,trans_str) - when /Russian/i; Russian.new(md,doc_lang,trans_str) - when /Greek/i; Greek.new(md,doc_lang,trans_str) - when /Ukranian/i; Ukranian.new(md,doc_lang,trans_str) - when /Turkish/i; Turkish.new(md,doc_lang,trans_str) - when /Slovenian/i; Slovenian.new(md,doc_lang,trans_str) - when /Croatian/i; Croatian.new(md,doc_lang,trans_str) - when /Slovak(?:ian)?/i; Slovak.new(md,doc_lang,trans_str) - when /Czech/i; Czech.new(md,doc_lang,trans_str) - when /Bulgarian/i; Bulgarian.new(md,doc_lang,trans_str) - else English.new(md,doc_lang,trans_str) + when /American/i then English.new(md,doc_lang,trans_str) # tag depreciated, see iso 639-2 + when /English/i then English.new(md,doc_lang,trans_str) + when /French/i then French.new(md,doc_lang,trans_str) + when /German/i then German.new(md,doc_lang,trans_str) + when /Italian/i then Italian.new(md,doc_lang,trans_str) + when /Spanish/i then Spanish.new(md,doc_lang,trans_str) + when /Portuguese Brazil|Brazilian(?: Portuguese)?/i + Portuguese.new(md,doc_lang,trans_str) # tag depreciated, see iso 639-2 + when /Portuguese/i then Portuguese.new(md,doc_lang,trans_str) + when /Swedish/i then Swedish.new(md,doc_lang,trans_str) + when /Danish/i then Danish.new(md,doc_lang,trans_str) + when /Finnish/i then Finnish.new(md,doc_lang,trans_str) + when /Norwegian/i then Norwegian.new(md,doc_lang,trans_str) + when /Icelandic/i then Icelandic.new(md,doc_lang,trans_str) + when /Dutch/i then Dutch.new(md,doc_lang,trans_str) + when /Estonian/i then Estonian.new(md,doc_lang,trans_str) + when /Hungarian/i then Hungarian.new(md,doc_lang,trans_str) + when /Polish/i then Polish.new(md,doc_lang,trans_str) + when /Romanian/i then Romanian.new(md,doc_lang,trans_str) + when /Russian/i then Russian.new(md,doc_lang,trans_str) + when /Greek/i then Greek.new(md,doc_lang,trans_str) + when /Ukranian/i then Ukranian.new(md,doc_lang,trans_str) + when /Turkish/i then Turkish.new(md,doc_lang,trans_str) + when /Slovenian/i then Slovenian.new(md,doc_lang,trans_str) + when /Croatian/i then Croatian.new(md,doc_lang,trans_str) + when /Slovak(?:ian)?/i then Slovak.new(md,doc_lang,trans_str) + when /Czech/i then Czech.new(md,doc_lang,trans_str) + when /Bulgarian/i then Bulgarian.new(md,doc_lang,trans_str) + else English.new(md,doc_lang,trans_str) end end def filename @@ -279,38 +280,38 @@ module SiSU_Translate end def language_list case @trans_str - when /American/i; 'American English' # tag depreciated, see iso 639-2 - when /English/i; 'English' - when /French/i; 'français' - when /German/i; 'Deutsch' - when /Italian/i; 'Italiano' - when /Spanish/i; 'español' - when /Portuguese Brazil|Brazilian(?: Portuguese)?/i; - 'Brazilian Português' # tag depreciated, see iso 639-2 - when /Portuguese/i; 'Português' - when /Swedish/i; 'svenska' - when /Danish/i; 'dansk' - when /Finnish/i; 'suomi' - when /Norwegian/i; 'norsk' - when /Icelandic/i; 'Icelandic' - when /Dutch/i; 'Nederlands' - when /Estonian/i; 'Estonian' - when /Hungarian/i; 'Hungarian' - when /Polish/i; 'polski' - when /Romanian/i; 'română' - when /Russian/i; 'Русский (Russkij)' - when /Greek/i; 'Ελληνικά (Ellinika)' - when /Ukranian/i; 'українська (ukrajins\'ka)' - when /Turkish/i; 'Türkçe' - when /Slovenian/i; 'Slovenian' - when /Croatian/i; 'Croatian' - when /Slovak(?:ian)?/i; 'slovensky' #slovensky ? - when /Czech/i; 'česky' - when /Bulgarian/i; 'Български (Bəlgarski)' - when /Japanese/i; '日本語 (Nihongo)' - when /Korean/i; '한국어 (Hangul)' - #when /Catalan/i; 'català' - else 'English' + when /American/i then 'American English' # tag depreciated, see iso 639-2 + when /English/i then 'English' + when /French/i then 'français' + when /German/i then 'Deutsch' + when /Italian/i then 'Italiano' + when /Spanish/i then 'español' + when /Portuguese Brazil|Brazilian(?: Portuguese)?/i + 'Brazilian Português' # tag depreciated, see iso 639-2 + when /Portuguese/i then 'Português' + when /Swedish/i then 'svenska' + when /Danish/i then 'dansk' + when /Finnish/i then 'suomi' + when /Norwegian/i then 'norsk' + when /Icelandic/i then 'Icelandic' + when /Dutch/i then 'Nederlands' + when /Estonian/i then 'Estonian' + when /Hungarian/i then 'Hungarian' + when /Polish/i then 'polski' + when /Romanian/i then 'română' + when /Russian/i then 'Русский (Russkij)' + when /Greek/i then 'Ελληνικά (Ellinika)' + when /Ukranian/i then 'українська (ukrajins\'ka)' + when /Turkish/i then 'Türkçe' + when /Slovenian/i then 'Slovenian' + when /Croatian/i then 'Croatian' + when /Slovak(?:ian)?/i then 'slovensky' #slovensky ? + when /Czech/i then 'česky' + when /Bulgarian/i then 'Български (Bəlgarski)' + when /Japanese/i then '日本語 (Nihongo)' + when /Korean/i then '한국어 (Hangul)' + #when /Catalan/i then 'català' + else 'English' end #check on 中文 and عربي end @@ -473,7 +474,7 @@ module SiSU_Translate 'Document (RCS/CVS) number' end def last_generated - 'Document (dal) last generated' + 'Document (ao) last generated' end def sisu_version 'Generated by' @@ -498,34 +499,34 @@ module SiSU_Translate end def language_list_translated case @trans_str - when /American/i; 'American English' # tag depreciated, see iso 639-2 - when /English/i; 'English' - when /French/i; 'French' - when /German/i; 'German' - when /Italian/i; 'Italian' - when /Spanish/i; 'Spanish' - when /Portuguese Brazil|Brazilian(?: Portuguese)?/i; - 'Brazilian Portuguese' # tag depreciated, see iso 639-2 - when /Portuguese/i; 'Portuguese' - when /Swedish/i; 'Swedish' - when /Danish/i; 'Danish' - when /Finnish/i; 'Finnish' - when /Norwegian/i; 'Norwegian' - when /Icelandic/i; 'Icelandic' - when /Dutch/i; 'Dutch' - when /Estonian/i; 'Estonian' - when /Hungarian/i; 'Hungarian' - when /Polish/i; 'Polish' - when /Romanian/i; 'Romanian' - when /Russian/i; 'Russian' - when /Greek/i; 'Greek' - when /Ukranian/i; 'Ukranian' - when /Turkish/i; 'Turkish' - when /Slovenian/i; 'Slovenian' - when /Croatian/i; 'Croatian' - when /Slovak(?:ian)?/i; 'Slovakian' - when /Czech/i; 'Czech' - when /Bulgarian/i; 'Bulgarian' + when /American/i then 'American English' # tag depreciated, see iso 639-2 + when /English/i then 'English' + when /French/i then 'French' + when /German/i then 'German' + when /Italian/i then 'Italian' + when /Spanish/i then 'Spanish' + when /Portuguese Brazil|Brazilian(?: Portuguese)?/i + 'Brazilian Portuguese' # tag depreciated, see iso 639-2 + when /Portuguese/i then 'Portuguese' + when /Swedish/i then 'Swedish' + when /Danish/i then 'Danish' + when /Finnish/i then 'Finnish' + when /Norwegian/i then 'Norwegian' + when /Icelandic/i then 'Icelandic' + when /Dutch/i then 'Dutch' + when /Estonian/i then 'Estonian' + when /Hungarian/i then 'Hungarian' + when /Polish/i then 'Polish' + when /Romanian/i then 'Romanian' + when /Russian/i then 'Russian' + when /Greek/i then 'Greek' + when /Ukranian/i then 'Ukranian' + when /Turkish/i then 'Turkish' + when /Slovenian/i then 'Slovenian' + when /Croatian/i then 'Croatian' + when /Slovak(?:ian)?/i then 'Slovakian' + when /Czech/i then 'Czech' + when /Bulgarian/i then 'Bulgarian' else @trans_str end end @@ -713,34 +714,34 @@ module SiSU_Translate end def language_list_translated case @trans_str - when /American/i; 'Anglais americain' # tag depreciated, see iso 639-2 - when /English/i; 'Anglais' - when /French/i; 'Français' - when /German/i; 'Allemand' - when /Italian/i; 'Italien' - when /Spanish/i; 'Espagnol' - when /Portuguese Brazil|Brazilian(?: Portuguese)?/i; - 'Portugais brésilien' # tag depreciated, see iso 639-2 - when /Portuguese/i; 'Portugais' - when /Swedish/i; 'Suédois' - when /Danish/i; 'Danois' - when /Finnish/i; 'Finnois' - when /Norwegian/i; 'Norvégien' - when /Icelandic/i; 'Islandais' - when /Dutch/i; 'Néerlandais' - when /Estonian/i; 'Estonien' - when /Hungarian/i; 'Hongrois' - when /Polish/i; 'Polonais' - when /Romanian/i; 'Roumain' - when /Russian/i; 'Russe' - when /Greek/i; 'Grec' - when /Ukranian/i; 'Ukrainien' - when /Turkish/i; 'Turc' - when /Slovenian/i; 'Slovène' - when /Croatian/i; 'Croate' - when /Slovak(?:ian)?/i; 'Slovaque' - when /Czech/i; 'Tcheque' - when /Bulgarian/i; 'Bulgare' + when /American/i then 'Anglais americain' # tag depreciated, see iso 639-2 + when /English/i then 'Anglais' + when /French/i then 'Français' + when /German/i then 'Allemand' + when /Italian/i then 'Italien' + when /Spanish/i then 'Espagnol' + when /Portuguese Brazil|Brazilian(?: Portuguese)?/i + 'Portugais brésilien' # tag depreciated, see iso 639-2 + when /Portuguese/i then 'Portugais' + when /Swedish/i then 'Suédois' + when /Danish/i then 'Danois' + when /Finnish/i then 'Finnois' + when /Norwegian/i then 'Norvégien' + when /Icelandic/i then 'Islandais' + when /Dutch/i then 'Néerlandais' + when /Estonian/i then 'Estonien' + when /Hungarian/i then 'Hongrois' + when /Polish/i then 'Polonais' + when /Romanian/i then 'Roumain' + when /Russian/i then 'Russe' + when /Greek/i then 'Grec' + when /Ukranian/i then 'Ukrainien' + when /Turkish/i then 'Turc' + when /Slovenian/i then 'Slovène' + when /Croatian/i then 'Croate' + when /Slovak(?:ian)?/i then 'Slovaque' + when /Czech/i then 'Tcheque' + when /Bulgarian/i then 'Bulgare' else @trans_str end end @@ -925,34 +926,34 @@ module SiSU_Translate end def language_list_translated case @trans_str - when /American/i; 'Amerikanisch-Englisch' # tag depreciated, see iso 639-2 - when /English/i; 'Englisch' - when /French/i; 'Französisch' - when /German/i; 'Deutsch' - when /Italian/i; 'Italienisch' - when /Spanish/i; 'Spanisch' - when /Portuguese Brazil|Brazilian(?: Portuguese)?/i; - 'Brasilianisch-Portugiesisch' # tag depreciated, see iso 639-2 - when /Portuguese/i; 'Portugiesisch' - when /Swedish/i; 'Schwedisch' - when /Danish/i; 'Dänisch' - when /Finnish/i; 'Finnisch' - when /Norwegian/i; 'Norwegisch' - when /Icelandic/i; 'Isländisch' - when /Dutch/i; 'Niederländisch' - when /Estonian/i; 'Estnisch' - when /Hungarian/i; 'Ungarisch' - when /Polish/i; 'Polnisch' - when /Romanian/i; 'Rumänisch' - when /Russian/i; 'Russisch' - when /Greek/i; 'Griechisch' - when /Ukranian/i; 'Ukrainisch' - when /Turkish/i; 'Türkisch' - when /Slovenian/i; 'Slovenisch' - when /Croatian/i; 'Kroatisch' - when /Slovak(?:ian)?/i; 'Slovakisch' - when /Czech/i; 'Tschechisch' - when /Bulgarian/i; 'Bulgarisch' + when /American/i then 'Amerikanisch-Englisch' # tag depreciated, see iso 639-2 + when /English/i then 'Englisch' + when /French/i then 'Französisch' + when /German/i then 'Deutsch' + when /Italian/i then 'Italienisch' + when /Spanish/i then 'Spanisch' + when /Portuguese Brazil|Brazilian(?: Portuguese)?/i + 'Brasilianisch-Portugiesisch' # tag depreciated, see iso 639-2 + when /Portuguese/i then 'Portugiesisch' + when /Swedish/i then 'Schwedisch' + when /Danish/i then 'Dänisch' + when /Finnish/i then 'Finnisch' + when /Norwegian/i then 'Norwegisch' + when /Icelandic/i then 'Isländisch' + when /Dutch/i then 'Niederländisch' + when /Estonian/i then 'Estnisch' + when /Hungarian/i then 'Ungarisch' + when /Polish/i then 'Polnisch' + when /Romanian/i then 'Rumänisch' + when /Russian/i then 'Russisch' + when /Greek/i then 'Griechisch' + when /Ukranian/i then 'Ukrainisch' + when /Turkish/i then 'Türkisch' + when /Slovenian/i then 'Slovenisch' + when /Croatian/i then 'Kroatisch' + when /Slovak(?:ian)?/i then 'Slovakisch' + when /Czech/i then 'Tschechisch' + when /Bulgarian/i then 'Bulgarisch' else @trans_str end end @@ -1137,34 +1138,34 @@ module SiSU_Translate end def language_list_translated case @trans_str - when /American/i; 'Inglés Americano' # tag depreciated, see iso 639-2 - when /English/i; 'Inglés' - when /French/i; 'Francés' - when /German/i; 'Alemán' - when /Italian/i; 'Italiano' - when /Spanish/i; 'Español' - when /Portuguese Brazil|Brazilian(?: Portuguese)?/i; - 'Portugués de Brasil' # tag depreciated, see iso 639-2 - when /Portuguese/i; 'Portugués' - when /Swedish/i; 'Sueco' - when /Danish/i; 'Danés' - when /Finnish/i; 'Finés' - when /Norwegian/i; 'Noruego' - when /Icelandic/i; 'Islandés' - when /Dutch/i; 'Holandés' - when /Estonian/i; 'Estonio' - when /Hungarian/i; 'Húngaro' - when /Polish/i; 'Polaco' - when /Romanian/i; 'Rumano' - when /Russian/i; 'Ruso' - when /Greek/i; 'Griego' - when /Ukranian/i; 'Ucraniano' - when /Turkish/i; 'Turco' - when /Slovenian/i; 'Eslovaco' - when /Croatian/i; 'Croata' - when /Slovak(?:ian)?/i; 'Eslovaco' - when /Czech/i; 'Checo' - when /Bulgarian/i; 'Búlgaro' + when /American/i then 'Inglés Americano' # tag depreciated, see iso 639-2 + when /English/i then 'Inglés' + when /French/i then 'Francés' + when /German/i then 'Alemán' + when /Italian/i then 'Italiano' + when /Spanish/i then 'Español' + when /Portuguese Brazil|Brazilian(?: Portuguese)?/i + 'Portugués de Brasil' # tag depreciated, see iso 639-2 + when /Portuguese/i then 'Portugués' + when /Swedish/i then 'Sueco' + when /Danish/i then 'Danés' + when /Finnish/i then 'Finés' + when /Norwegian/i then 'Noruego' + when /Icelandic/i then 'Islandés' + when /Dutch/i then 'Holandés' + when /Estonian/i then 'Estonio' + when /Hungarian/i then 'Húngaro' + when /Polish/i then 'Polaco' + when /Romanian/i then 'Rumano' + when /Russian/i then 'Ruso' + when /Greek/i then 'Griego' + when /Ukranian/i then 'Ucraniano' + when /Turkish/i then 'Turco' + when /Slovenian/i then 'Eslovaco' + when /Croatian/i then 'Croata' + when /Slovak(?:ian)?/i then 'Eslovaco' + when /Czech/i then 'Checo' + when /Bulgarian/i then 'Búlgaro' else @trans_str end end @@ -1324,7 +1325,7 @@ module SiSU_Translate 'Numero di revisione (RCS/CVS)' end def last_generated - 'Data di ultima generazione (dal metaverse)' + 'Data di ultima generazione (ao metaverse)' end def sisu_version 'Generato da' @@ -1349,34 +1350,34 @@ module SiSU_Translate end def language_list_translated case @trans_str - when /American/i; 'Inglese USA' # tag depreciated, see iso 639-2 - when /English/i; 'Inglese' - when /French/i; 'Francese' - when /German/i; 'Tedesco' - when /Italian/i; 'Italiano' - when /Spanish/i; 'Spagnolo' - when /Portuguese Brazil|Brazilian(?: Portuguese)?/i; - 'Portoguese (Brasile)' # tag depreciated, see iso 639-2 - when /Portuguese/i; 'Portoguese' - when /Swedish/i; 'Svedese' - when /Danish/i; 'Danese' - when /Finnish/i; 'Finlandese' - when /Norwegian/i; 'Norvegese' - when /Icelandic/i; 'Islandese' - when /Dutch/i; 'Olandese' - when /Estonian/i; 'Estone' - when /Hungarian/i; 'Ungherese' - when /Polish/i; 'Polacco' - when /Romanian/i; 'Romeno' - when /Russian/i; 'Russo' - when /Greek/i; 'Greco' - when /Ukranian/i; 'Ucraino' - when /Turkish/i; 'Turco' - when /Slovenian/i; 'Sloveno' - when /Croatian/i; 'Croato' - when /Slovak(?:ian)?/i; 'Slovacco' - when /Czech/i; 'Ceco' - when /Bulgarian/i; 'Bulgaro' + when /American/i then 'Inglese USA' # tag depreciated, see iso 639-2 + when /English/i then 'Inglese' + when /French/i then 'Francese' + when /German/i then 'Tedesco' + when /Italian/i then 'Italiano' + when /Spanish/i then 'Spagnolo' + when /Portuguese Brazil|Brazilian(?: Portuguese)?/i + 'Portoguese (Brasile)' # tag depreciated, see iso 639-2 + when /Portuguese/i then 'Portoguese' + when /Swedish/i then 'Svedese' + when /Danish/i then 'Danese' + when /Finnish/i then 'Finlandese' + when /Norwegian/i then 'Norvegese' + when /Icelandic/i then 'Islandese' + when /Dutch/i then 'Olandese' + when /Estonian/i then 'Estone' + when /Hungarian/i then 'Ungherese' + when /Polish/i then 'Polacco' + when /Romanian/i then 'Romeno' + when /Russian/i then 'Russo' + when /Greek/i then 'Greco' + when /Ukranian/i then 'Ucraino' + when /Turkish/i then 'Turco' + when /Slovenian/i then 'Sloveno' + when /Croatian/i then 'Croato' + when /Slovak(?:ian)?/i then 'Slovacco' + when /Czech/i then 'Ceco' + when /Bulgarian/i then 'Bulgaro' else @trans_str end end @@ -1561,34 +1562,34 @@ module SiSU_Translate end def language_list_translated case @trans_str - when /American/i; 'Amerikanenglanti' # tag depreciated, see iso 639-2 - when /English/i; 'Englanti' - when /French/i; 'Ranska' - when /German/i; 'Saksa' - when /Italian/i; 'Italia' - when /Spanish/i; 'Espanja' - when /Portuguese Brazil|Brazilian(?: Portuguese)?/i; - 'Brasilian portugali' # tag depreciated, see iso 639-2 - when /Portuguese/i; 'Portugali' - when /Swedish/i; 'Ruotsi' - when /Danish/i; 'Tanska' - when /Finnish/i; 'Suomi' - when /Norwegian/i; 'Norja' - when /Icelandic/i; 'Islanti' - when /Dutch/i; 'Hollanti' - when /Estonian/i; 'Viro' - when /Hungarian/i; 'Unkari' - when /Polish/i; 'Puola' - when /Romanian/i; 'Romania' - when /Russian/i; 'Venäjä' - when /Greek/i; 'Kreikka' - when /Ukranian/i; 'Ukraina' - when /Turkish/i; 'Turkki' - when /Slovenian/i; 'Slovenia' - when /Croatian/i; 'Kroatia' - when /Slovak(?:ian)?/i; 'Slovakki' - when /Czech/i; 'Tsekki' - when /Bulgarian/i; 'Bulgaria' + when /American/i then 'Amerikanenglanti' # tag depreciated, see iso 639-2 + when /English/i then 'Englanti' + when /French/i then 'Ranska' + when /German/i then 'Saksa' + when /Italian/i then 'Italia' + when /Spanish/i then 'Espanja' + when /Portuguese Brazil|Brazilian(?: Portuguese)?/i + 'Brasilian portugali' # tag depreciated, see iso 639-2 + when /Portuguese/i then 'Portugali' + when /Swedish/i then 'Ruotsi' + when /Danish/i then 'Tanska' + when /Finnish/i then 'Suomi' + when /Norwegian/i then 'Norja' + when /Icelandic/i then 'Islanti' + when /Dutch/i then 'Hollanti' + when /Estonian/i then 'Viro' + when /Hungarian/i then 'Unkari' + when /Polish/i then 'Puola' + when /Romanian/i then 'Romania' + when /Russian/i then 'Venäjä' + when /Greek/i then 'Kreikka' + when /Ukranian/i then 'Ukraina' + when /Turkish/i then 'Turkki' + when /Slovenian/i then 'Slovenia' + when /Croatian/i then 'Kroatia' + when /Slovak(?:ian)?/i then 'Slovakki' + when /Czech/i then 'Tsekki' + when /Bulgarian/i then 'Bulgaria' else @trans_str end end diff --git a/lib/sisu/v4/qrcode.rb b/lib/sisu/v6/qrcode.rb index a36d8973..067d3d64 100644 --- a/lib/sisu/v4/qrcode.rb +++ b/lib/sisu/v6/qrcode.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/qrcode.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/qrcode.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -83,12 +84,18 @@ module SiSU_QRcode @md=SiSU_Param::Parameters.new(@opt).get xbrowser=@env.program.web_browser browser=@env.program.console_web_browser - unless @opt.cmd =~/q/ + unless @opt.act[:quiet][:set]==:on url_html="file://#{@md.file.output_path.manifest.dir}/#{@md.file.base_filename.manifest}" - @opt.cmd=~/[MVvz]/ \ - ? SiSU_Screen::Ansi.new(@opt.cmd,'QR code',"#{xbrowser} #{url_html}").green_hi_blue - : 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 + (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) \ + ? SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'QR code',"#{xbrowser} #{url_html}").green_hi_blue + : SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'QR code',"[#{@opt.f_pth[:lng_is]}] #{@opt.fns}").green_title_hi + if (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"#{browser} #{url_html}").grey_tab + end end data=SiSU_HTML::Source::HTML_Environment.new(@particulars).tuned_file_instructions OutputInfo.new(@md).check_output(data) @@ -120,17 +127,17 @@ module SiSU_QRcode def output_metadata fn=@f.base_filename.manifest_txt mn='' - if @md.opt.cmd =~/M/ + if @md.opt.act[:maintenance][:set]==:on fn=@f.base_filename.manifest_txt manifest=@f.write_file.manifest_txt end @manifest[:txt].each do |x| x=x.gsub(/\\\\/m,"\n") - puts x if @md.opt.cmd =~/V/ - manifest << x if @md.opt.cmd =~/M/ + puts x if @md.opt.act[:verbose_plus][:set]==:on + manifest << x if @md.opt.act[:maintenance][:set]==:on mn += x end - manifest.close if @md.opt.cmd =~/M/ + manifest.close if @md.opt.act[:maintenance][:set]==:on cmd=SiSU_Env::SystemCall.new(mn,@f.place_file.qrcode_md.dir,@md.opt.cmd) cmd.qrencode end @@ -163,7 +170,11 @@ WOK dgst=(@dg =~/^sha(?:2|256)$/) \ ? (sys.sha256("#{pth}/#{file}")) : (sys.md5("#{pth}/#{file}")) - SiSU_Screen::Ansi.new(@md.opt.cmd,"#{dgst[1]} #{file}").warn if @md.opt.cmd =~/[vVM]/ + if (@md.opt.act[:verbose][:set]==:on \ + || @md.opt.act[:verbose_plus][:set]==:on \ + || @md.opt.act[:maintenance][:set]==:on) + SiSU_Screen::Ansi.new(@md.opt.cmd,"#{dgst[1]} #{file}").warn + end size=(File.size("#{pth}/#{file}")/1024.00).to_s kb=/([0-9]+\.[0-9]{0,1})/m.match(size)[1] @manifest[:txt] <<<<WOK diff --git a/lib/sisu/v4/relaxng.rb b/lib/sisu/v6/relaxng.rb index 0ca42817..1270ada3 100644 --- a/lib/sisu/v4/relaxng.rb +++ b/lib/sisu/v6/relaxng.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/relaxng.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/relaxng.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -327,9 +328,9 @@ element-external_space = } RELAXNG end - def rnc_sisu_object_dal + def rnc_sisu_object_ao @relaxng =<<RELAXNG -#%% sisu object model: dal +#%% sisu object model: ao #{gpl3_or_later} #%% definitions # dublin core: @@ -500,7 +501,7 @@ RELAXNG @relaxng =<<RELAXNG #% sax output model, part of SiSU and distributed under the same license default namespace = "" -namespace xlink = "http://www.w3.org/1999/xlink" +namespace xl = "http://www.w3.org/1999/xlink" start = element document { element head { @@ -510,8 +511,8 @@ start = attribute class { xsd:NCName }, (text | element link { - attribute xlink:href { xsd:anyURI }, - attribute xlink:type { xsd:NCName }, + attribute xl:href { xsd:anyURI }, + attribute xl:type { xsd:NCName }, xsd:anyURI })+ } @@ -603,10 +604,10 @@ start = attribute alt { text }?, attribute height { xsd:integer }?, attribute width { xsd:integer }?, - attribute xlink:actuate { xsd:NCName }, - attribute xlink:href { text }, - attribute xlink:show { xsd:NCName }, - attribute xlink:type { xsd:NCName } + attribute xl:actuate { xsd:NCName }, + attribute xl:href { text }, + attribute xl:show { xsd:NCName }, + attribute xl:type { xsd:NCName } })+ }?, element table { @@ -654,8 +655,8 @@ sub = element sub { xsd:NCName } sup = element sup { xsd:NCName } link = element link { - attribute xlink:href { xsd:anyURI }, - attribute xlink:type { xsd:NCName }, + attribute xl:href { xsd:anyURI }, + attribute xl:type { xsd:NCName }, (xsd:anyURI | text | b | i | sup)+ } u = element u { (text | b | i)+ } @@ -666,7 +667,7 @@ RELAXNG @relaxng =<<RELAXNG #% dom output model, part of SiSU and distributed under the same license default namespace = "" -namespace xlink = "http://www.w3.org/1999/xlink" +namespace xl = "http://www.w3.org/1999/xlink" start = element document { element head { @@ -770,10 +771,10 @@ object = | element image { attribute height { xsd:integer }, attribute width { xsd:integer }, - attribute xlink:actuate { xsd:NCName }, - attribute xlink:href { text }, - attribute xlink:show { xsd:NCName }, - attribute xlink:type { xsd:NCName } + attribute xl:actuate { xsd:NCName }, + attribute xl:href { text }, + attribute xl:show { xsd:NCName }, + attribute xl:type { xsd:NCName } } | element sub { text })+ }) @@ -786,8 +787,8 @@ sup = element sup { xsd:NCName } del = element del { (text | b | i | link)+ } link = element link { - attribute xlink:href { xsd:anyURI }, - attribute xlink:type { xsd:NCName }, + attribute xl:href { xsd:anyURI }, + attribute xl:type { xsd:NCName }, xsd:anyURI } endnote = @@ -814,7 +815,7 @@ RELAXNG @relaxng =<<RELAXNG #% xhtml output model, part of SiSU and distributed under the same license default namespace = "" -namespace xlink = "http://www.w3.org/1999/xlink" +namespace xl = "http://www.w3.org/1999/xlink" start = element document { element head { @@ -823,8 +824,8 @@ start = attribute class { xsd:NCName }, (text | element link { - attribute xlink:href { xsd:anyURI }, - attribute xlink:type { xsd:NCName }, + attribute xl:href { xsd:anyURI }, + attribute xl:type { xsd:NCName }, xsd:anyURI })+ } @@ -923,10 +924,10 @@ start = attribute alt { text }?, attribute height { xsd:integer }?, attribute width { xsd:integer }?, - attribute xlink:actuate { xsd:NCName }, - attribute xlink:href { text }, - attribute xlink:show { xsd:NCName }, - attribute xlink:type { xsd:NCName } + attribute xl:actuate { xsd:NCName }, + attribute xl:href { text }, + attribute xl:show { xsd:NCName }, + attribute xl:type { xsd:NCName } } | element sub { text })+ })+, @@ -954,8 +955,8 @@ sup = element sup { xsd:NCName } i = element i { (text | b | br | sup)+ } link = element link { - attribute xlink:href { xsd:anyURI }, - attribute xlink:type { xsd:NCName }, + attribute xl:href { xsd:anyURI }, + attribute xl:type { xsd:NCName }, (text | b | i | sup)+ } b = element b { (text | en | i | link | sup)+ } diff --git a/lib/sisu/v4/remote.rb b/lib/sisu/v6/remote.rb index 2a158e4b..3c4982c8 100644 --- a/lib/sisu/v4/remote.rb +++ b/lib/sisu/v6/remote.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/remote.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/remote.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -72,35 +73,35 @@ module SiSU_Remote @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/ + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Remote placement ->',@put).dark_grey_title_hi unless @opt.act[:quiet][:set]==:on @remote.rsync.document end def rsync_base - SiSU_Screen::Ansi.new(@opt.cmd,'Remote placement ->','rsync').dark_grey_title_hi unless @opt.cmd =~/q/ + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Remote placement ->','rsync').dark_grey_title_hi unless @opt.act[:quiet][:set]==:on @remote.rsync.site_base end def rsync_base_sync - SiSU_Screen::Ansi.new(@opt.cmd,'Remote placement ->','rsync and sync').dark_grey_title_hi unless @opt.cmd =~/q/ + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Remote placement ->','rsync and sync').dark_grey_title_hi unless @opt.act[:quiet][:set]==:on @remote.rsync.site_base_sync end def rsync_sitemaps - SiSU_Screen::Ansi.new(@opt.cmd,'Remote placement sitemaps ->','rsync').dark_grey_title_hi unless @opt.cmd =~/q/ + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Remote placement sitemaps ->','rsync').dark_grey_title_hi unless @opt.act[:quiet][:set]==:on @remote.rsync_sitemaps end def rsync_harvest - SiSU_Screen::Ansi.new(@opt.cmd,'Remote placement metadata harvest ->','rsync_harvest').dark_grey_title_hi unless @opt.cmd =~/q/ + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Remote placement metadata harvest ->','rsync_harvest').dark_grey_title_hi unless @opt.act[:quiet][:set]==:on @remote.rsync.site_harvest end def scp - SiSU_Screen::Ansi.new(@opt.cmd,'Remote placement ->',@put).dark_grey_title_hi unless @opt.cmd =~/q/ + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Remote placement ->',@put).dark_grey_title_hi unless @opt.act[:quiet][:set]==:on @remote.scp.document end def scp_base - SiSU_Screen::Ansi.new(@opt.cmd,'Remote placement of base site ->','excluding images').dark_grey_title_hi unless @opt.cmd =~/q/ + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Remote placement of base site ->','excluding images').dark_grey_title_hi unless @opt.act[:quiet][:set]==:on @remote.scp.site_base end def scp_base_all - SiSU_Screen::Ansi.new(@opt.cmd,'Remote placement ->','complete').dark_grey_title_hi unless @opt.cmd =~/q/ + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Remote placement ->','complete').dark_grey_title_hi unless @opt.act[:quiet][:set]==:on @remote.scp.site_base_all end end @@ -108,7 +109,7 @@ module SiSU_Remote def initialize(opt,get_s) @opt,@get_s=opt,get_s @msg,@msgs='',nil - @tell=lambda { SiSU_Screen::Ansi.new(@opt.cmd,@msg,"#{@msgs.inspect if @msgs}") } + @tell=lambda { SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],@msg,"#{@msgs.inspect if @msgs}") } end def fns require 'open-uri' @@ -141,12 +142,12 @@ module SiSU_Remote images.delete_if {|x| x =~/https?:\/\// } images=images.sort @msg,@msgs='downloading images:', [ images.join(',') ] - @tell.call.warn unless @opt.cmd =~/q/ + @tell.call.warn unless @opt.act[:quiet][:set]==:on image_info=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/ + @tell.call.warn unless @opt.act[:quiet][:set]==:on end downloaded_file.close end diff --git a/lib/sisu/v4/response.rb b/lib/sisu/v6/response.rb index 36aa94da..a67602f6 100644 --- a/lib/sisu/v4/response.rb +++ b/lib/sisu/v6/response.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/response.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/response.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> diff --git a/lib/sisu/v4/rexml.rb b/lib/sisu/v6/rexml.rb index b89fada7..f9b94cee 100644 --- a/lib/sisu/v4/rexml.rb +++ b/lib/sisu/v6/rexml.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/rexml.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/rexml.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -91,10 +92,11 @@ module SiSU_Rexml xmlfile=IO.readlines(@fnap,'').join begin @xmldoc=REXML::Document.new xmlfile - SiSU_Screen::Ansi.new(@md.opt.cmd,'invert','REXML',"XML document #{@fnap} loaded").colorize unless @md.opt.cmd =~/q/ #% tell - if @md.opt.cmd =~ /v/i #% substantive text + SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],'invert','REXML',"XML document #{@fnap} loaded").colorize unless @md.opt.act[:quiet][:set]==:on + if (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on) @xmldoc.elements.each(@e_head) do |e| - SiSU_Screen::Ansi.new(@md.opt.cmd,'brown',e).colorize unless @md.opt.cmd =~/q/ + SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],'brown',e).colorize unless @md.opt.act[:quiet][:set]==:on end end rescue REXML::ParseException @@ -102,7 +104,7 @@ module SiSU_Rexml end end else - SiSU_Screen::Ansi.new(@md.opt.cmd,'fuchsia',"File Not Found #{xmlfile}",'requested XML processing skipped').colorize unless @md.opt.cmd =~/q/ + SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],'fuchsia',"File Not Found #{xmlfile}",'requested XML processing skipped').colorize unless @md.opt.act[:quiet][:set]==:on exit end rescue diff --git a/lib/sisu/v4/screen_text_color.rb b/lib/sisu/v6/screen_text_color.rb index 304a677a..5c4a2f72 100644 --- a/lib/sisu/v4/screen_text_color.rb +++ b/lib/sisu/v6/screen_text_color.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/screen_text_color.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/screen_text_color.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -68,20 +69,10 @@ module SiSU_Screen end class Ansi < Color attr_reader :cX - def initialize(cmd,*txt) - @cmd,@txt=cmd,txt + def initialize(color_state,*txt) + @color_state,@txt=color_state,txt @color_instruct=txt[0] - flag=SiSU_Env::InfoProcessingFlag.new - if cmd - #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=(flag.color) \ - ? ((cmd =~/c/) ? false : true) - : ((cmd =~/c/) ? true : false) - if cmd =~/k/ then @use_color=false # useful color off switch, however, k may be used for something else in future - end - else @use_color=false - end - @cX=@@cX= unless @use_color + @cX=@@cX=if color_state==:on Color.new do self.off=self.white=self.white_bold=self.marker=self.bold=self.underline=self.invert=self.darkgrey_hi=self.grey_hi=self.pink_hi=self.fuchsia_hi=self.red_hi=self.orange_hi=self.yellow_hi=self.brown_hi=self.lightgreen_hi=self.green_hi=self.cyan_hi=self.blue_hi=self.navy_hi=self.grey=self.pink=self.fuchsia=self.ruby=self.red=self.orange=self.yellow=self.brown=self.green=self.darkgreen=self.cyan=self.blue=self.navy=self.black='' end @@ -130,69 +121,69 @@ module SiSU_Screen end def color case @color_instruct - when /invert/; @cX.invert - when /darkgrey_hi/; @cX.darkgrey_hi - when /grey_hi/; @cX.grey_hi - when /pink_hi/; @cX.pink_hi - when /fuchsia_hi/; @cX.fuchsia_hi - when /red_hi/; @cX.red_hi - when /orange_hi/; @cX.orange_hi - when /yellow_hi/; @cX.yellow_hi - when /brown_hi/; @cX.brown_hi - when /lightgreen_hi/; @cX.lightgreen_hi - when /green_hi/; @cX.green_hi - when /cyan_hi/; @cX.cyan_hi - when /blue_hi/; @cX.blue_hi - when /navy_hi/; @cX.navy_hi - when /white/; @cX.white - when /grey/; @cX.grey - when /pink/; @cX.pink - when /fuchsia/; @cX.fuchsia - when /ruby/; @cX.ruby - when /red/; @cX.red - when /orange/; @cX.orange - when /yellow/; @cX.yellow - when /brown/; @cX.brown - when /green/; @cX.green - when /darkgreen/; @cX.darkgreen - when /cyan/; @cX.cyan - when /blue/; @cX.blue - when /navy/; @cX.navy - when /close/; @cX.off - when /off/; @cX.off + when /invert/ then @cX.invert + when /darkgrey_hi/ then @cX.darkgrey_hi + when /grey_hi/ then @cX.grey_hi + when /pink_hi/ then @cX.pink_hi + when /fuchsia_hi/ then @cX.fuchsia_hi + when /red_hi/ then @cX.red_hi + when /orange_hi/ then @cX.orange_hi + when /yellow_hi/ then @cX.yellow_hi + when /brown_hi/ then @cX.brown_hi + when /lightgreen_hi/ then @cX.lightgreen_hi + when /green_hi/ then @cX.green_hi + when /cyan_hi/ then @cX.cyan_hi + when /blue_hi/ then @cX.blue_hi + when /navy_hi/ then @cX.navy_hi + when /white/ then @cX.white + when /grey/ then @cX.grey + when /pink/ then @cX.pink + when /fuchsia/ then @cX.fuchsia + when /ruby/ then @cX.ruby + when /red/ then @cX.red + when /orange/ then @cX.orange + when /yellow/ then @cX.yellow + when /brown/ then @cX.brown + when /green/ then @cX.green + when /darkgreen/ then @cX.darkgreen + when /cyan/ then @cX.cyan + when /blue/ then @cX.blue + when /navy/ then @cX.navy + when /close/ then @cX.off + when /off/ then @cX.off end end def colorize case @color_instruct - when /invert/; puts "#{@cX.invert}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" - when /darkgrey_hi/; puts "#{@cX.darkgrey_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" - when /grey_hi/; puts "#{@cX.grey_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" - when /pink_hi/; puts "#{@cX.pink_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" - when /fuchsia_hi/; puts "#{@cX.fuchsia_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" - when /red_hi/; puts "#{@cX.red_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" - when /orange_hi/; puts "#{@cX.orange_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" - when /yellow_hi/; puts "#{@cX.yellow_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" - when /brown_hi/; puts "#{@cX.brown_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" - when /lightgreen_hi/; puts "#{@cX.lightgreen_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" - when /green_hi/; puts "#{@cX.green_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" - when /cyan_hi/; puts "#{@cX.cyan_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" - when /blue_hi/; puts "#{@cX.blue_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" - when /navy_hi/; puts "#{@cX.navy_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" - when /bold/; puts "#{@cX.bold}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" - when /white/; puts "#{@cX.off}#{@txt[1]} #{@txt[2]}" - when /grey/; puts "#{@cX.grey}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" - when /pink/; puts "#{@cX.pink}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" - when /fuchsia/; puts "#{@cX.fuchsia}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" - when /ruby/; puts "#{@cX.ruby}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" - when /red/; puts "#{@cX.red}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" - when /orange/; puts "#{@cX.orange}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" - when /yellow/; puts "#{@cX.yellow}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" - when /brown/; puts "#{@cX.brown}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" - when /green/; puts "#{@cX.green}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" - when /darkgreen/; puts "#{@cX.darkgreen}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" - when /cyan/; puts "#{@cX.cyan}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" - when /blue/; puts "#{@cX.blue}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" - when /navy/; puts "#{@cX.navy}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" + when /invert/ then puts "#{@cX.invert}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" + when /darkgrey_hi/ then puts "#{@cX.darkgrey_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" + when /grey_hi/ then puts "#{@cX.grey_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" + when /pink_hi/ then puts "#{@cX.pink_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" + when /fuchsia_hi/ then puts "#{@cX.fuchsia_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" + when /red_hi/ then puts "#{@cX.red_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" + when /orange_hi/ then puts "#{@cX.orange_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" + when /yellow_hi/ then puts "#{@cX.yellow_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" + when /brown_hi/ then puts "#{@cX.brown_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" + when /lightgreen_hi/ then puts "#{@cX.lightgreen_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" + when /green_hi/ then puts "#{@cX.green_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" + when /cyan_hi/ then puts "#{@cX.cyan_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" + when /blue_hi/ then puts "#{@cX.blue_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" + when /navy_hi/ then puts "#{@cX.navy_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" + when /bold/ then puts "#{@cX.bold}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" + when /white/ then puts "#{@cX.off}#{@txt[1]} #{@txt[2]}" + when /grey/ then puts "#{@cX.grey}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" + when /pink/ then puts "#{@cX.pink}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" + when /fuchsia/ then puts "#{@cX.fuchsia}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" + when /ruby/ then puts "#{@cX.ruby}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" + when /red/ then puts "#{@cX.red}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" + when /orange/ then puts "#{@cX.orange}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" + when /yellow/ then puts "#{@cX.yellow}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" + when /brown/ then puts "#{@cX.brown}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" + when /green/ then puts "#{@cX.green}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" + when /darkgreen/ then puts "#{@cX.darkgreen}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" + when /cyan/ then puts "#{@cX.cyan}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" + when /blue/ then puts "#{@cX.blue}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" + when /navy/ then puts "#{@cX.navy}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" end end def sourcename(sourcefilename) diff --git a/lib/sisu/v4/shared_images.rb b/lib/sisu/v6/shared_images.rb index 92f0c894..536a2f21 100644 --- a/lib/sisu/v4/shared_images.rb +++ b/lib/sisu/v6/shared_images.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/shared_images.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/shared_images.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> diff --git a/lib/sisu/v4/shared_markup_alt.rb b/lib/sisu/v6/shared_markup_alt.rb index 27d968ca..b84d167a 100644 --- a/lib/sisu/v4/shared_markup_alt.rb +++ b/lib/sisu/v6/shared_markup_alt.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/shared_markup_alt.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/shared_markup_alt.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -262,7 +263,7 @@ module SiSU_TextRepresentation elsif FileTest.file?("#{@env.path.image_source_include}/#{i}") @env.path.image_source_include else - SiSU_Screen::Ansi.new(@md.opt.cmd,"ERROR - image:", %{"#{i}" missing}, "search locations: #{@env.path.image_source_include_local}, #{@env.path.image_source_include_remote} and #{@env.path.image_source_include}").error2 unless @md.opt.cmd =~/q/ + SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],"ERROR - image:", %{"#{i}" missing}, "search locations: #{@env.path.image_source_include_local}, #{@env.path.image_source_include_remote} and #{@env.path.image_source_include}").error2 unless @md.opt.act[:quiet][:set]==:on nil end img_type = /\S+\.(png|jpg|gif)/.match(i)[1] diff --git a/lib/sisu/v4/shared_metadata.rb b/lib/sisu/v6/shared_metadata.rb index f14ffb0a..546eb788 100644 --- a/lib/sisu/v4/shared_metadata.rb +++ b/lib/sisu/v6/shared_metadata.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/shared_metadata.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/shared_metadata.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -832,18 +833,18 @@ WOK @inf=inf_array.join(' ') end @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 + '<text:a xl:type="simple" xl: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 + '\1<text:a xl:type="simple" xl: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 + %{#{url_brace.xml_open}<text:a xl:type="simple" xl:href="\\1">\\1</text:a>#{url_brace.xml_close}}) #http ftp matches with decoration else @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 + %{#{url_brace.xml_open}<text:a xl:type="simple" xl:href="\\1">\\1</text:a>#{url_brace.xml_close}}) #http ftp matches with decoration end @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 + %{#{url_brace.xml_open}<text:a xl:type="simple" xl:href="mailto:\\1">\\1</text:a>#{url_brace.xml_close}}) if @inf !~/http:\/\// # improve upon, document crash where url contains '@' symbol end <<WOK <text:p text:style-name="P1">#{@tag.capitalize}: #{@inf}</text:p> diff --git a/lib/sisu/v4/shared_sem.rb b/lib/sisu/v6/shared_sem.rb index 89dab948..02c04a85 100644 --- a/lib/sisu/v4/shared_sem.rb +++ b/lib/sisu/v6/shared_sem.rb @@ -9,7 +9,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -51,7 +52,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/v4/shared_sem.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/shared_sem.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> diff --git a/lib/sisu/v4/sitemaps.rb b/lib/sisu/v6/sitemaps.rb index 194f1220..92e376ad 100644 --- a/lib/sisu/v4/sitemaps.rb +++ b/lib/sisu/v6/sitemaps.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/sitemaps.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/sitemaps.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -64,7 +65,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) @@ -78,7 +79,7 @@ module SiSU_Sitemaps @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/ + if @opt.act[:sitemap][:set]==:on @md=SiSU_Param::Parameters.new(@opt).get @trans=SiSU_XML_Munge::Trans.new(@md) #check @md is required @env=SiSU_Env::InfoEnv.new(@md.fns) @@ -91,7 +92,7 @@ module SiSU_Sitemaps @sitemap_idx_fn='sitemapindex.xml' @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/ + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"sitemap index:","#{@env.path.output}/#{@sitemap_idx_fn}").result unless @opt.act[:quiet][:set]==:on end rescue SiSU_Errors::Rescued.new($!,$@,@opt.cmd,@opt.fns).location do diff --git a/lib/sisu/v4/spell.rb b/lib/sisu/v6/spell.rb index df0f837e..a0f6e904 100644 --- a/lib/sisu/v4/spell.rb +++ b/lib/sisu/v6/spell.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/spell.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/spell.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> diff --git a/lib/sisu/v4/share_src_kdissert.rb b/lib/sisu/v6/src_kdissert_share.rb index 5b3365ff..ecf559fb 100644 --- a/lib/sisu/v4/share_src_kdissert.rb +++ b/lib/sisu/v6/src_kdissert_share.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/share_src_kdissert.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/src_share_kdissert.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -71,8 +72,8 @@ module SiSU_KdiSource @output_path="#{@env.path.output}/#{@opt.fnb}" end def read - SiSU_Screen::Ansi.new(@opt.cmd,'Share Kdissert Source Document!',@opt.fnb).green_hi_blue unless @opt.cmd =~/q/ - SiSU_Screen::Ansi.new(@opt.cmd,"Copy kdissert file to output directory","#{@opt.fnb} -> #{@output_path}").warn unless @opt.cmd =~/q/ + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Share Kdissert Source Document!',@opt.fnb).green_hi_blue unless @opt.act[:quiet][:set]==:on + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"Copy kdissert file to output directory","#{@opt.fnb} -> #{@output_path}").warn unless @opt.act[:quiet][:set]==:on FileUtils::mkdir_p(@env.path.output) unless FileTest.directory?(@env.path.output) FileUtils::mkdir_p(@output_path) unless FileTest.directory?(@output_path) if FileTest.directory?(@output_path) @@ -81,7 +82,7 @@ module SiSU_KdiSource FileUtils::cp(@opt.fnb,@output_path) end else - SiSU_Screen::Ansi.new(@opt.cmd,"Output directory does not exist","#{@opt.fnb} -> #{@output_path}").warn unless @opt.cmd =~/q/ + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"Output directory does not exist","#{@opt.fnb} -> #{@output_path}").warn unless @opt.act[:quiet][:set]==:on exit end end diff --git a/lib/sisu/v4/share_src.rb b/lib/sisu/v6/src_share.rb index 34c1d713..f2454550 100644 --- a/lib/sisu/v4/share_src.rb +++ b/lib/sisu/v6/src_share.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/share_src.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/src_share.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -60,7 +61,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 @@ -70,14 +71,17 @@ module SiSU_Markup @opt=opt end def read - unless @opt.cmd =~/q/ - @opt.cmd=~/[MVvz]/ \ - ? SiSU_Screen::Ansi.new(@opt.cmd,'Share document markup text source',@opt.fns).cyan_hi_blue - : SiSU_Screen::Ansi.new(@opt.cmd,'Share document markup text source',@opt.fns).cyan_title_hi + unless @opt.act[:quiet][:set]==:on + (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) \ + ? SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Share document markup text source',@opt.fns).cyan_hi_blue + : SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Share document markup text source',@opt.fns).cyan_title_hi end if FileTest.directory?(@path_pod[:fnb]) FileUtils::mkdir_p(@file.output_path.src.dir) unless FileTest.directory?(@file.output_path.src.dir) - v=(@opt.cmd =~/M/) ? 'v' : '' + v=(@opt.act[:maintenance][:set]==:on) \ + ? 'v' : '' system(%{ rsync -a#{v} #{@path_pod[:fnb]} #{@file.output_path.sisupod.dir} chbk=`pwd` @@ -87,7 +91,11 @@ module SiSU_Markup cd ${chbk} }) else - SiSU_Screen::Ansi.new('',"#{@opt.fno} not available").blue_tab if @opt.cmd=~/[MVv]/ + if (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) + SiSU_Screen::Ansi.new('',"#{@opt.fno} not available").blue_tab + end end end end diff --git a/lib/sisu/v4/shared_sisupod_source.rb b/lib/sisu/v6/src_shared.rb index b53c9eb2..4ce34473 100644 --- a/lib/sisu/v4/shared_sisupod_source.rb +++ b/lib/sisu/v6/src_shared.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/shared_sisupod_source.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/src_shared.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -69,7 +70,9 @@ module SiSU_Source @date=SiSU_Env::InfoDate.new.dt @env=SiSU_Env::InfoEnv.new(opt.fns) @ver=SiSU_Env::InfoVersion.instance.get_version - @v=(opt.cmd =~/[VM]/) ? 'v' : '' + @v=(@opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) \ + ? 'v' : '' @particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt) @file=@particulars.file @local_path="#{@file.output_path.sisupod.dir}" @@ -91,9 +94,11 @@ module SiSU_Source } end def read - unless @opt.cmd =~/q/ - @opt.cmd=~/[MVv]/ \ - ? SiSU_Screen::Ansi.new(@opt.cmd,'Assemble SiSU source',"[#{@opt.f_pth[:lng_is]}] #{@opt.fno}").green_hi_blue + unless @opt.act[:quiet][:set]==:on + (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) \ + ? SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Assemble SiSU source',"[#{@opt.f_pth[:lng_is]}] #{@opt.fno}").green_hi_blue : '' end unless @opt.fns.empty? @@ -296,7 +301,7 @@ sisu standard_terms/ image processing - dal/ + ao/ tex/ texinfo/ tune/ diff --git a/lib/sisu/v4/sisupod_make.rb b/lib/sisu/v6/src_sisupod_make.rb index 57c12049..ad58453d 100644 --- a/lib/sisu/v4/sisupod_make.rb +++ b/lib/sisu/v6/src_sisupod_make.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/sisupod_make.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/src_sisupod_make.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -60,7 +61,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 @@ -69,17 +70,21 @@ module SiSU_Doc def initialize(opt,build=nil,place=nil) super(opt,build,place) @zipfile=@opt.fno.gsub(/(?:\~\S{2,3})?(\.ss[tm])$/,'\1') - unless @opt.cmd =~/q/ + unless @opt.act[:quiet][:set]==:on pthinfo="#{@file.output_path.sisupod.dir}/#{@zipfile}.txz" - @opt.cmd=~/[MVv]/ \ - ? SiSU_Screen::Ansi.new(@opt.cmd,'Assemble source for sisu document',"#{@opt.fns} -> file://#{pthinfo}").cyan_hi_blue - : SiSU_Screen::Ansi.new(@opt.cmd,'Assemble source for sisu document',pthinfo).cyan_title_hi + (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) \ + ? SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Assemble source for sisu document',"#{@opt.fns} -> file://#{pthinfo}").cyan_hi_blue + : SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Assemble source for sisu document',pthinfo).cyan_title_hi end end def sisupod_tar_xz begin FileUtils::mkdir_p(@file.output_path.sisupod.dir) unless FileTest.directory?(@file.output_path.sisupod.dir) - tree=(@opt.cmd =~/[vVM]/ \ + tree=((@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) \ && SiSU_Env::SystemCall.new.program_found?('tree')) \ ? 'tree sisupod' : '' @@ -92,9 +97,17 @@ module SiSU_Doc }) FileUtils::mv("#{@zipfile}.txz",@file.place_file.sisupod.dir) Dir.chdir(@env.path.pwd) - SiSU_Screen::Ansi.new('',"#{@opt.fns}.txz").blue_tab if @opt.cmd=~/[MVv]/ + if (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) + SiSU_Screen::Ansi.new('',"#{@opt.fns}.txz").blue_tab + end else - SiSU_Screen::Ansi.new('',"#{@opt.fns}.txz not built").blue_tab if @opt.cmd=~/[MVv]/ + if (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) + SiSU_Screen::Ansi.new('',"#{@opt.fns}.txz not built").blue_tab + end end rescue ensure @@ -143,7 +156,7 @@ sisu standard_terms/ image processing - dal/ + ao/ tex/ texinfo/ tune/ diff --git a/lib/sisu/v4/sst_convert_markup.rb b/lib/sisu/v6/sst_convert_markup.rb index 23016d69..0b749fc5 100644 --- a/lib/sisu/v4/sst_convert_markup.rb +++ b/lib/sisu/v6/sst_convert_markup.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/sst_convert_markup.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/sst_convert_markup.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -79,7 +80,7 @@ module SiSU_Modify def message(text) response='' unless @opt.cmd=~/QQ/ \ - or @opt.cmd=~/q/ + or @opt.act[:quiet][:set]==:on response=@ask.response?(%{#{ text}\nProceed? }) end end @@ -160,9 +161,9 @@ WOK def convert_filename_36_to_37 @opt.files.each do |f| s=case f - when /(\.s[1-3])$/; f.sub($1,'.sst') - when /(\.r[1-3])$/; f.sub($1,'.ssm') - when /(\.ri)$/; f.sub($1,'.ssi') + when /(\.s[1-3])$/ then f.sub($1,'.sst') + when /(\.r[1-3])$/ then f.sub($1,'.ssm') + when /(\.ri)$/ then f.sub($1,'.ssi') else f end pwd=Dir.pwd @@ -203,26 +204,26 @@ WOK if @opt.mod.inspect =~/--help/ then help elsif @opt.mod.inspect =~/(?:convert|to)[=-](?:xml |sxs|sax|sxd|dom|sxn|node)/ ext=case @opt.mod.inspect - when /(?:convert|to)[=-](?:xml|sxs|sax)/; '.sxs.xml' - when /(?:convert|to)[=-](?:sxd|dom)/; '.sxd.xml' - when /(?:convert|to)[=-](?:sxn|node)/; '.sxn.xml' + when /(?:convert|to)[=-](?:xml|sxs|sax)/ then '.sxs.xml' + when /(?:convert|to)[=-](?:sxd|dom)/ then '.sxd.xml' + when /(?:convert|to)[=-](?:sxn|node)/ then '.sxn.xml' end message("#{@opt.files.inspect}\n\nWARNING, PROCEED AT YOUR OWN RISK,\noverwriting any equivalent file with the extension #{ext}") mr=case @opt.mod.inspect - when /(?:convert|to)[=-](?:sxs|sax|xml )/; convert_to_simple_xml_model_sax - when /(?:convert|to)[=-](?:sxd|dom)/; convert_to_simple_xml_model_dom - when /(?:convert|to)[=-](?:sxn|node)/; convert_to_simple_xml_model_node + when /(?:convert|to)[=-](?:sxs|sax|xml )/ then convert_to_simple_xml_model_sax + when /(?:convert|to)[=-](?:sxd|dom)/ then convert_to_simple_xml_model_dom + when /(?:convert|to)[=-](?:sxn|node)/ then convert_to_simple_xml_model_node else help end else mr=case @opt.mod.inspect - when /(?:(?:37)?to-?38|--(?:convert|to)[=-](?:current|0.38))/; convert_37_to_38 - when /(?:(?:38)?to-?37|--(?:convert|to)[=-](?:0.37))/; convert_38_to_37 - when /(?:36to37)/; convert_filename_36_to_37 - when /(?:convert|from)[=-]kdi/; convert_kdi_to_sst - when /(?:(?:convert|from)[=-])?(?:xml_to_sst|xml2sst|sxml|sxs|sxd|sxd)/; convert_s_xml_to_sst - when /(?:convert|to)[=-]footnotes/; convert_footnotes - when /convert|default/; current_match_and_replace + when /(?:(?:37)?to-?38|--(?:convert|to)[=-](?:current|0.38))/ then convert_37_to_38 + when /(?:(?:38)?to-?37|--(?:convert|to)[=-](?:0.37))/ then convert_38_to_37 + when /(?:36to37)/ then convert_filename_36_to_37 + when /(?:convert|from)[=-]kdi/ then convert_kdi_to_sst + when /(?:(?:convert|from)[=-])?(?:xml_to_sst|xml2sst|sxml|sxs|sxd|sxd)/ then convert_s_xml_to_sst + when /(?:convert|to)[=-]footnotes/ then convert_footnotes + when /convert|default/ then current_match_and_replace else help end end @@ -258,7 +259,7 @@ WOK end end if @matched - puts "conversion match in #{i}" unless @opt.cmd=~/q/ + puts "conversion match in #{i}" unless @opt.act[:quiet][:set]==:on @flag_start=true cont.each do |y| if y =~end_processing @@ -269,10 +270,18 @@ WOK match_and_replace.each do |m,r,w| if y =~m \ and y =~w - puts m.inspect + ' -> ' + r unless @opt.cmd=~/q/ - puts "in: #{y}" if @opt.cmd=~/[vVM]/ + puts m.inspect + ' -> ' + r unless @opt.act[:quiet][:set]==:on + if (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) + puts "in: #{y}" + end y.gsub!(m,r) if m and r - puts "out: #{y}" if @opt.cmd=~/[vVM]/ + if (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) + puts "out: #{y}" + end end end end @@ -285,9 +294,14 @@ WOK : false end @file.close - else puts "NO conversion match in #{i}" unless @opt.cmd=~/q/ + else puts "NO conversion match in #{i}" unless @opt.act[:quiet][:set]==:on + end + else + if (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) + puts "Requested conversion #{@opt.mod.inspect} markup #{markup_version} identified in #{i}" end - else puts "Requested conversion #{@opt.mod.inspect} markup #{markup_version} identified in #{i}" if @opt.cmd=~/[vVM]/ end end end diff --git a/lib/sisu/v4/sst_do_inline_footnotes.rb b/lib/sisu/v6/sst_do_inline_footnotes.rb index b65c99af..6349a717 100644 --- a/lib/sisu/v4/sst_do_inline_footnotes.rb +++ b/lib/sisu/v6/sst_do_inline_footnotes.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/set_do_inline_footnotes.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/set_do_inline_footnotes.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -67,8 +68,8 @@ module SiSU_ConvertFootnotes include SiSU_Env require_relative 'param' # param.rb include SiSU_Param - require_relative 'dal_syntax' # dal_syntax.rb - include SiSU_DAL_Syntax + require_relative 'ao_syntax' # ao_syntax.rb + include SiSU_AO_Syntax require_relative 'i18n' # i18n.rb class Instantiate < SiSU_Param::Parameters::Instructions @@flag={} #Beware!! @@ -82,19 +83,19 @@ module SiSU_ConvertFootnotes end end class Source <Instantiate - @@dal_array=[] + @@ao_array=[] @@fns=nil def initialize(opt) @opt=opt @@fns||@opt.fns @my_make=SiSU_Env::CreateFile.new(@opt.fns) - @fnm=SiSU_Env::InfoFile.new(@opt.fns).marshal.dal_content + @fnm=SiSU_Env::InfoFile.new(@opt.fns).marshal.ao_content end - def read #creates dal + def read #creates ao begin - @@dal_array=[] + @@ao_array=[] @@fns=@opt.fns - create_dal + create_ao rescue SiSU_Errors::Rescued.new($!,$@,@opt.cmd,@opt.fns).location do __LINE__.to_s + ':' + __FILE__ @@ -103,16 +104,16 @@ module SiSU_ConvertFootnotes Instantiate.new end end - def get #reads dal, unless does not exist then creates first + def get #reads ao, unless does not exist then creates first begin - dal=[] + ao=[] unless @@fns==@opt.fns @@fns=@opt.fns - @@dal_array=[] + @@ao_array=[] end - dal=(@@dal_array.empty?) \ + ao=(@@ao_array.empty?) \ ? read_fnm - : @@dal_array.dup #check + : @@ao_array.dup #check rescue SiSU_Errors::Rescued.new($!,$@,@opt.cmd,@opt.fns).location do __LINE__.to_s + ':' + __FILE__ @@ -122,9 +123,9 @@ module SiSU_ConvertFootnotes end end protected - def create_dal - dal_array=[] - SiSU_Screen::Ansi.new(@opt.cmd,'convert footnotes').green_title_hi unless @opt.cmd =~/q/ + def create_ao + ao_array=[] + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'convert footnotes').green_title_hi unless @opt.act[:quiet][:set]==:on file_array=IO.readlines(@opt.fns,'') file_array.each do |l| if l =~/\r\n/ then l.gsub!(/\r\n/,"\n") @@ -136,21 +137,21 @@ module SiSU_ConvertFootnotes if @md.en[:mismatch]==0 \ or @md.opt.mod.inspect =~/=footnotes-force/ meta=nil - 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?} - dal_array + ao=SiSU_ConvertFootnotes::Make.new(@md,file_array).song + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],@opt.fns,"#{@md.fns}.fn").output if @md.opt.act[:verbose][:set]==:on + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"#{@md.fns}.fn -> #{@md.fns}.fn").txt_red unless @md.opt.act[:quiet][:set]==:on + ao.each {|s| ao_array << "#{s.strip}\n\n" unless s.strip.empty?} + ao_array else - SiSU_Screen::Ansi.new(@md.opt.cmd,'*WARN* no footnote conversion done, problem with source file','to override use --convert=footnote-force (this is not advised)').warn if @cmd !~/q/ + SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],'*WARN* no footnote conversion done, problem with source file','to override use --convert=footnote-force (this is not advised)').warn unless @md.opt.act[:quiet][:set]==:on '' end end def read_fnm - dal=[] - dal=(FileTest.file?(@fnm)) \ - ? (File.open(@fnm){ |f| dal=Marshal.load(f)}) - : (SiSU_ConvertFootnotes::Source.new(@opt).create_dal) #watch + ao=[] + ao=(FileTest.file?(@fnm)) \ + ? (File.open(@fnm){ |f| ao=Marshal.load(f)}) + : (SiSU_ConvertFootnotes::Source.new(@opt).create_ao) #watch end end class Output @@ -189,7 +190,7 @@ module SiSU_ConvertFootnotes def song reset data=@data - @metafile="#{@env.processing_path.dal}/#{@md.fns}.meta" + @metafile="#{@env.processing_path.ao}/#{@md.fns}.meta" SiSU_Env::CreateFile.new(@md.fns) data=data.join.split("\n\n") data_new=[] @@ -339,8 +340,8 @@ module SiSU_ConvertFootnotes end def number_sub_heading(para,num,title_no) case para - when /#{num}~- /; para.gsub!(/#{num}~- /,"#{title_no} ") - when /^#{num}~#\s*/; para.gsub!(/^#{num}~#\s*/,"#{title_no} ") + when /#{num}~- / then para.gsub!(/#{num}~- /,"#{title_no} ") + when /^#{num}~#\s*/ then para.gsub!(/^#{num}~#\s*/,"#{title_no} ") when /^#{num}~[a-z_\.]+ / para.gsub!(/^#{num}~([a-z_\.]+)\s+(.+)/i,%{#{num}~\\1 #{title_no} \\2 <:name##{title_no}>}) else para.gsub!(/^#{num}~ /,"#{num}~#{title_no} #{title_no} ") #main @@ -353,7 +354,10 @@ module SiSU_ConvertFootnotes end def set_heading_top #% make sure no false positives unless @md.set_heading_top - puts "\tdocument contains no top level heading, (will have to manufacture one)" if @md.opt.cmd =~/[MV]/ + if (@md.opt.act[:verbose_plus][:set]==:on \ + || @md.opt.act[:maintenance][:set]==:on) + puts "\tdocument contains no top level heading, (will have to manufacture one)" + end data=@data @tuned_file=[] data.each do |para| @@ -374,7 +378,10 @@ module SiSU_ConvertFootnotes end def set_heading_seg #% make sure no false positives unless @md.set_heading_seg - puts "\tdocument contains no segment level, (will have to manufacture one)" if @md.opt.cmd =~/[MV]/ + if (@md.opt.act[:verbose_plus][:set]==:on \ + || @md.opt.act[:maintenance][:set]==:on) + puts "\tdocument contains no segment level, (will have to manufacture one)" + end data=@data @tuned_file=[] data.each do |para| @@ -396,7 +403,10 @@ module SiSU_ConvertFootnotes end def set_header_title #% make sure no false positives unless @md.set_header_title - puts "\t no document title provided, (will have to manufacture one)" if @md.opt.cmd =~/[MV]/ + if (@md.opt.act[:verbose_plus][:set]==:on \ + || @md.opt.act[:maintenance][:set]==:on) + puts "\t no document title provided, (will have to manufacture one)" + end data=@data @tuned_file=[] data.each do |para| @@ -449,7 +459,7 @@ module SiSU_ConvertFootnotes end end end - def strip_clean_extra_spaces(s) # dal output tuned + def strip_clean_extra_spaces(s) # ao output tuned s=s.dup s=s.gsub(/[ ]+([,.;:?](?:$|\s))/,'\1') s=s.gsub(/ [ ]+/,' ') @@ -473,4 +483,4 @@ module SiSU_ConvertFootnotes end __END__ @particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt) -dal_array=@particulars.dal_array # dal file drawn here +ao_array=@particulars.ao_array # ao file drawn here diff --git a/lib/sisu/v4/sst_from_xml.rb b/lib/sisu/v6/sst_from_xml.rb index 0eacb048..728f3f54 100644 --- a/lib/sisu/v4/sst_from_xml.rb +++ b/lib/sisu/v6/sst_from_xml.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/sst_from_xml.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/sst_from_xml.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -71,7 +72,7 @@ module SiSU_sstFromXML @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 + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"XML #{type} to SiSU sst","#{filename} --> #{filename}.sst").green_hi_blue end def read xml_to_sisu @@ -148,17 +149,17 @@ module SiSU_sstFromXML end end if xml =~/\.sxs\.xml$/ - unless @opt.cmd =~/q/ + unless @opt.act[:quiet][:set]==:on tell(xml,'sax') end sax elsif xml =~/\.sxd\.xml$/ - unless @opt.cmd =~/q/ + unless @opt.act[:quiet][:set]==:on tell(xml,'dom') end dom elsif xml =~/\.sxn\.xml$/ - unless @opt.cmd =~/q/ + unless @opt.act[:quiet][:set]==:on tell(xml,'node') end node diff --git a/lib/sisu/v4/sst_identify_markup.rb b/lib/sisu/v6/sst_identify_markup.rb index dcd60e0d..51af46c4 100644 --- a/lib/sisu/v4/sst_identify_markup.rb +++ b/lib/sisu/v6/sst_identify_markup.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/sst_identify_markup.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/sst_identify_markup.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -226,7 +227,7 @@ WOK if @opt.fns =~/\.(?:sst|ssm|ssi|s[123i]|r[123])/ markup=identify #(@opt.fns) if defined? markup.version - unless @opt.cmd =~/q/ + unless @opt.act[:quiet][:set]==:on message=unless markup.declared_version.empty? "#{@opt.fns}\n markup Type Declared as SiSU #{markup.declared_version} #{markup.declared_type}\n appears to be SiSU #{markup.version}" else diff --git a/lib/sisu/v4/sst_to_s_xml_sax.rb b/lib/sisu/v6/sst_to_s_xml_sax.rb index bbf81c5a..a82ce5cc 100644 --- a/lib/sisu/v4/sst_to_s_xml_sax.rb +++ b/lib/sisu/v6/sst_to_s_xml_sax.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/sst_to_s_xml_sax.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/sst_to_s_xml_sax.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -68,8 +69,8 @@ module SiSU_SimpleXML_ModelSax include SiSU_Param require_relative 'sysenv' # sysenv.rb include SiSU_Env - require_relative 'dal_doc_str' # dal_doc_str.rb - require_relative 'shared_xml' # shared_xml.rb + require_relative 'ao_doc_str' # ao_doc_str.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 @@ -88,8 +89,11 @@ module SiSU_SimpleXML_ModelSax begin @md=@particulars.md #bug, relies on info persistence, assumes -m has previously been run @env=@particulars.env - SiSU_Screen::Ansi.new(@opt.cmd,'invert','XML SAX',"#{@md.fns} -> #{@md.fn[:sxs]}").colorize unless @opt.cmd =~/q/ - SiSU_Screen::Ansi.new(@opt.cmd,@opt.fns,"#{Dir.pwd}/#{@md.fn[:sxs]}").flow if @opt.cmd =~/[MV]/ + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'invert','XML SAX',"#{@md.fns} -> #{@md.fn[:sxs]}").colorize unless @opt.act[:quiet][:set]==:on + if (@opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],@opt.fns,"#{Dir.pwd}/#{@md.fn[:sxs]}").flow + end unless @@fns==@opt.fns @@fns=@opt.fns @@fns_array=[] @@ -106,9 +110,9 @@ module SiSU_SimpleXML_ModelSax end end def read_fnm - dal=[] + ao=[] if FileTest.file?("#{Dir.pwd}/#{@opt.fns}") - dal=IO.readlines("#{Dir.pwd}/#{@opt.fns}","\n\n") + ao=IO.readlines("#{Dir.pwd}/#{@opt.fns}","\n\n") else STDERR.puts 'Error' end end @@ -120,8 +124,12 @@ module SiSU_SimpleXML_ModelSax def songsheet begin 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 + if (@md.opt.act[:verbose][:set]==:on \ + || @md.opt.act[:verbose_plus][:set]==:on \ + || @md.opt.act[:maintenance][:set]==:on) + SiSU_SimpleXML_ModelSax::Convert::Tidy.new(@md,@env).xml # test wellformedness, comment out when not in use + end + SiSU_Rexml::Rexml.new(@md,@md.fn[:sxs]).xml if @md.opt.act[:maintenance][:set]==:on # test rexml parsing, comment out when not in use #debug rescue SiSU_Errors::Rescued.new($!,$@,@md.opt.cmd,@md.fns).location do __LINE__.to_s + ':' + __FILE__ @@ -131,7 +139,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: [] } @@ -269,7 +277,7 @@ WOK (0..6).each { |x| @cont[x]=@level[x]=false } (4..6).each { |x| @xml_contents_close[x]='' } @data.each do |para| - data << SiSU_DAL_DocumentStructureExtract::Structure.new(@md,para).structure #takes on Mx marks + data << SiSU_AO_DocumentStructureExtract::Structure.new(@md,para).structure #takes on Mx marks end data.each do |para| if para !~/^\s*(?:%+ |<:code>)/ @@ -435,14 +443,15 @@ WOK end def xml if @prog.tidy !=false #note values can be other than true - if @md.opt.cmd =~/[VM]/ - SiSU_Screen::Ansi.new(@md.opt.cmd,'invert','Using XML Tidy','check document structure').colorize unless @md.opt.cmd =~/q/ - SiSU_Screen::Ansi.new(@md.opt.cmd,'','','check document structure') - tell.grey_open unless @md.opt.cmd =~/q/ + if (@md.opt.act[:verbose_plus][:set]==:on \ + || @md.opt.act[:maintenance][:set]==:on) + SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],'invert','Using XML Tidy','check document structure').colorize unless @md.opt.act[:quiet][:set]==:on + SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],'','','check document structure') + tell.grey_open unless @md.opt.act[:quiet][:set]==:on tidyfile='/dev/null' #don't want one or screen output, check for alternative flags tidy =SiSU_Env::SystemCall.new("#{Dir.pwd}/#{@md.fn[:sxs]}",tidyfile) tidy.well_formed? - tell.p_off unless @md.opt.cmd =~/q/ + tell.p_off unless @md.opt.act[:quiet][:set]==:on end end end diff --git a/lib/sisu/v4/sysenv.rb b/lib/sisu/v6/sysenv.rb index eda1ad46..46bb30ca 100644 --- a/lib/sisu/v4/sysenv.rb +++ b/lib/sisu/v6/sysenv.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/sysenv.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/sysenv.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -116,7 +117,7 @@ module SiSU_Env processing_pth=tmp_processing_individual processing_dir=prcss_dir processing_git="#{Dir.pwd}/#{Gt[:grotto]}" - user=ENV['USER'] + #user=ENV['USER'] port_pgsql=if defined? ENV['PGPORT'] \ and not (ENV['PGPORT'].nil? \ || ENV['PGPORT'].empty?) \ @@ -142,7 +143,7 @@ module SiSU_Env PROCESSING_PATH=:processing_path PROCESSING_DIR_TMP_ROOT=:processing_dir_tmp_root PROCESSING_PATH_TMP_BASE=:processing_path_tmp_base - PROCESSING_DAL=:processing_dal + PROCESSING_AO=:processing_ao PROCESSING_TUNE=:processing_tune PROCESSING_LATEX=:processing_latex PROCESSING_TEXINFO=:processing_texinfo @@ -186,7 +187,7 @@ module SiSU_Env PROCESSING_PATH => processing_pth, PROCESSING_DIR_TMP_ROOT => prcss_dir_tmp_root, PROCESSING_PATH_TMP_BASE => processing_pth, - PROCESSING_DAL => 'dal', + PROCESSING_AO => 'ao', PROCESSING_TUNE => 'tune', PROCESSING_LATEX => 'tex', PROCESSING_TEXINFO => 'texinfo', @@ -935,63 +936,63 @@ module SiSU_Env def language lng={} case @language - when /^am$|Amharic/i; d,c,l=false,lang_lst['am'][:c], lang_lst['am'][:n] - when /^bg$|Bulgarian/i; d,c,l=false,lang_lst['bg'][:c], lang_lst['bg'][:n] - when /^bn$|Bengali/i; d,c,l=false,lang_lst['bn'][:c], lang_lst['bn'][:n] - when /^br$|Breton/i; d,c,l=false,lang_lst['br'][:c], lang_lst['br'][:n] - when /^ca$|Catalan/i; d,c,l=false,lang_lst['ca'][:c], lang_lst['ca'][:n] - when /^cs$|Czech/i; d,c,l=false,lang_lst['cs'][:c], lang_lst['cs'][:n] - when /^cy$|Welsh/i; d,c,l=false,lang_lst['cy'][:c], lang_lst['cy'][:n] - when /^da$|Danish|Dansk/i; d,c,l=false,lang_lst['da'][:c], lang_lst['da'][:n] - when /^de$|German/i; d,c,l=false,lang_lst['de'][:c], lang_lst['de'][:n] - when /^el$|Greek/i; d,c,l=false,lang_lst['el'][:c], lang_lst['el'][:n] - when /^en$|English/i; d,c,l=false,lang_lst['en'][:c], lang_lst['en'][:n] - when /^eo$|Esperanto/i; d,c,l=false,lang_lst['eo'][:c], lang_lst['eo'][:n] - when /^es$|Spanish|Espanol/i; d,c,l=false,lang_lst['es'][:c], lang_lst['es'][:n] - when /^et$|Estonian/i; d,c,l=false,lang_lst['et'][:c], lang_lst['et'][:n] - when /^eu$|Basque/i; d,c,l=false,lang_lst['eu'][:c], lang_lst['eu'][:n] - when /^fi$|Finnish|Finsk|Suomi/i; d,c,l=false,lang_lst['fi'][:c], lang_lst['fi'][:n] - when /^fr$|French|Francais/i; d,c,l=false,lang_lst['fr'][:c], lang_lst['fr'][:n] - when /^ga$|Irish/i; d,c,l=false,lang_lst['ga'][:c], lang_lst['ga'][:n] - when /^gl$|Galician/i; d,c,l=false,lang_lst['gl'][:c], lang_lst['gl'][:n] - when /^he$|Hebrew/i; d,c,l=false,lang_lst['he'][:c], lang_lst['he'][:n] - when /^hi$|Hindi/i; d,c,l=false,lang_lst['hi'][:c], lang_lst['hi'][:n] - when /^hr$|Croatian/i; d,c,l=false,lang_lst['hr'][:c], lang_lst['hr'][:n] - when /^hy$|Armenian/i; d,c,l=false,lang_lst['hy'][:c], lang_lst['hy'][:n] - when /^ia$|Interlingua/i; d,c,l=false,lang_lst['ia'][:c], lang_lst['ia'][:n] - when /^is$|Icelandic/i; d,c,l=false,lang_lst['is'][:c], lang_lst['is'][:n] - when /^it$|Italian/i; d,c,l=false,lang_lst['it'][:c], lang_lst['it'][:n] - when /^la$|Latin/i; d,c,l=false,lang_lst['la'][:c], lang_lst['la'][:n] - when /^lo$|Lao/i; d,c,l=false,lang_lst['lo'][:c], lang_lst['lo'][:n] - when /^lt$|Lithuanian/i; d,c,l=false,lang_lst['lt'][:c], lang_lst['lt'][:n] - when /^lv$|Latvian/i; d,c,l=false,lang_lst['lv'][:c], lang_lst['lv'][:n] - when /^ml$|Malayalam/i; d,c,l=false,lang_lst['ml'][:c], lang_lst['ml'][:n] - when /^mr$|Marathi/i; d,c,l=false,lang_lst['mr'][:c], lang_lst['mr'][:n] - when /^nl$|Dutch/i; d,c,l=false,lang_lst['nl'][:c], lang_lst['nl'][:n] - when /^no$|Norwegian|Norsk/i; d,c,l=false,lang_lst['no'][:c], lang_lst['no'][:n] - when /^nn$|Norwegian Nynorsk/i; d,c,l=false,lang_lst['nn'][:c], lang_lst['nn'][:n] - when /^oc$|Occitan/i; d,c,l=false,lang_lst['oc'][:c], lang_lst['oc'][:n] - when /^pl$|Polish/i; d,c,l=false,lang_lst['pl'][:c], lang_lst['pl'][:n] - when /^pt$|Portuguese/i; d,c,l=false,lang_lst['pt'][:c], lang_lst['pt'][:n] - when /^pt_BR$|Portuguese Brazil/i; d,c,l=false,lang_lst['pt_BR'][:c], lang_lst['pt_BR'][:n] - when /^ro$|Romanian/i; d,c,l=false,lang_lst['ro'][:c], lang_lst['ro'][:n] - when /^ru$|Russian/i; d,c,l=false,lang_lst['ru'][:c], lang_lst['ru'][:n] - when /^sa$|Sanskrit/i; d,c,l=false,lang_lst['sa'][:c], lang_lst['sa'][:n] - when /^se$|Sami/i; d,c,l=false,lang_lst['se'][:c], lang_lst['se'][:n] - when /^sk$|Slovak/i; d,c,l=false,lang_lst['sk'][:c], lang_lst['sk'][:n] - when /^sl$|Slovenian/i; d,c,l=false,lang_lst['sl'][:c], lang_lst['sl'][:n] - when /^sq$|Albanian/i; d,c,l=false,lang_lst['sq'][:c], lang_lst['sq'][:n] - when /^sr$|Serbian/i; d,c,l=false,lang_lst['sr'][:c], lang_lst['sr'][:n] - when /^sv$|Swedish|Svensk/i; d,c,l=false,lang_lst['sv'][:c], lang_lst['sv'][:n] - when /^ta$|Tamil/i; d,c,l=false,lang_lst['ta'][:c], lang_lst['ta'][:n] - when /^te$|Telugu/i; d,c,l=false,lang_lst['te'][:c], lang_lst['te'][:n] - when /^th$|Thai/i; d,c,l=false,lang_lst['th'][:c], lang_lst['th'][:n] - when /^tk$|Turkmen/i; d,c,l=false,lang_lst['tk'][:c], lang_lst['tk'][:n] - when /^tr$|Turkish/i; d,c,l=false,lang_lst['tr'][:c], lang_lst['tr'][:n] - when /^uk$|Ukranian/i; d,c,l=false,lang_lst['uk'][:c], lang_lst['uk'][:n] - when /^ur$|Urdu/i; d,c,l=false,lang_lst['ur'][:c], lang_lst['ur'][:n] - when /^us|American$|/i; d,c,l=false,lang_lst['en'][:c], lang_lst['en'][:n] - when /^vi$|Vietnamese/i; d,c,l=false,lang_lst['vi'][:c], lang_lst['vi'][:n] + when /^am$|Amharic/i then d,c,l=false,lang_lst['am'][:c], lang_lst['am'][:n] + when /^bg$|Bulgarian/i then d,c,l=false,lang_lst['bg'][:c], lang_lst['bg'][:n] + when /^bn$|Bengali/i then d,c,l=false,lang_lst['bn'][:c], lang_lst['bn'][:n] + when /^br$|Breton/i then d,c,l=false,lang_lst['br'][:c], lang_lst['br'][:n] + when /^ca$|Catalan/i then d,c,l=false,lang_lst['ca'][:c], lang_lst['ca'][:n] + when /^cs$|Czech/i then d,c,l=false,lang_lst['cs'][:c], lang_lst['cs'][:n] + when /^cy$|Welsh/i then d,c,l=false,lang_lst['cy'][:c], lang_lst['cy'][:n] + when /^da$|Danish|Dansk/i then d,c,l=false,lang_lst['da'][:c], lang_lst['da'][:n] + when /^de$|German/i then d,c,l=false,lang_lst['de'][:c], lang_lst['de'][:n] + when /^el$|Greek/i then d,c,l=false,lang_lst['el'][:c], lang_lst['el'][:n] + when /^en$|English/i then d,c,l=false,lang_lst['en'][:c], lang_lst['en'][:n] + when /^eo$|Esperanto/i then d,c,l=false,lang_lst['eo'][:c], lang_lst['eo'][:n] + when /^es$|Spanish|Espanol/i then d,c,l=false,lang_lst['es'][:c], lang_lst['es'][:n] + when /^et$|Estonian/i then d,c,l=false,lang_lst['et'][:c], lang_lst['et'][:n] + when /^eu$|Basque/i then d,c,l=false,lang_lst['eu'][:c], lang_lst['eu'][:n] + when /^fi$|Finnish|Finsk|Suomi/i then d,c,l=false,lang_lst['fi'][:c], lang_lst['fi'][:n] + when /^fr$|French|Francais/i then d,c,l=false,lang_lst['fr'][:c], lang_lst['fr'][:n] + when /^ga$|Irish/i then d,c,l=false,lang_lst['ga'][:c], lang_lst['ga'][:n] + when /^gl$|Galician/i then d,c,l=false,lang_lst['gl'][:c], lang_lst['gl'][:n] + when /^he$|Hebrew/i then d,c,l=false,lang_lst['he'][:c], lang_lst['he'][:n] + when /^hi$|Hindi/i then d,c,l=false,lang_lst['hi'][:c], lang_lst['hi'][:n] + when /^hr$|Croatian/i then d,c,l=false,lang_lst['hr'][:c], lang_lst['hr'][:n] + when /^hy$|Armenian/i then d,c,l=false,lang_lst['hy'][:c], lang_lst['hy'][:n] + when /^ia$|Interlingua/i then d,c,l=false,lang_lst['ia'][:c], lang_lst['ia'][:n] + when /^is$|Icelandic/i then d,c,l=false,lang_lst['is'][:c], lang_lst['is'][:n] + when /^it$|Italian/i then d,c,l=false,lang_lst['it'][:c], lang_lst['it'][:n] + when /^la$|Latin/i then d,c,l=false,lang_lst['la'][:c], lang_lst['la'][:n] + when /^lo$|Lao/i then d,c,l=false,lang_lst['lo'][:c], lang_lst['lo'][:n] + when /^lt$|Lithuanian/i then d,c,l=false,lang_lst['lt'][:c], lang_lst['lt'][:n] + when /^lv$|Latvian/i then d,c,l=false,lang_lst['lv'][:c], lang_lst['lv'][:n] + when /^ml$|Malayalam/i then d,c,l=false,lang_lst['ml'][:c], lang_lst['ml'][:n] + when /^mr$|Marathi/i then d,c,l=false,lang_lst['mr'][:c], lang_lst['mr'][:n] + when /^nl$|Dutch/i then d,c,l=false,lang_lst['nl'][:c], lang_lst['nl'][:n] + when /^no$|Norwegian|Norsk/i then d,c,l=false,lang_lst['no'][:c], lang_lst['no'][:n] + when /^nn$|Norwegian Nynorsk/i then d,c,l=false,lang_lst['nn'][:c], lang_lst['nn'][:n] + when /^oc$|Occitan/i then d,c,l=false,lang_lst['oc'][:c], lang_lst['oc'][:n] + when /^pl$|Polish/i then d,c,l=false,lang_lst['pl'][:c], lang_lst['pl'][:n] + when /^pt$|Portuguese/i then d,c,l=false,lang_lst['pt'][:c], lang_lst['pt'][:n] + when /^pt_BR$|Portuguese Brazil/i then d,c,l=false,lang_lst['pt_BR'][:c], lang_lst['pt_BR'][:n] + when /^ro$|Romanian/i then d,c,l=false,lang_lst['ro'][:c], lang_lst['ro'][:n] + when /^ru$|Russian/i then d,c,l=false,lang_lst['ru'][:c], lang_lst['ru'][:n] + when /^sa$|Sanskrit/i then d,c,l=false,lang_lst['sa'][:c], lang_lst['sa'][:n] + when /^se$|Sami/i then d,c,l=false,lang_lst['se'][:c], lang_lst['se'][:n] + when /^sk$|Slovak/i then d,c,l=false,lang_lst['sk'][:c], lang_lst['sk'][:n] + when /^sl$|Slovenian/i then d,c,l=false,lang_lst['sl'][:c], lang_lst['sl'][:n] + when /^sq$|Albanian/i then d,c,l=false,lang_lst['sq'][:c], lang_lst['sq'][:n] + when /^sr$|Serbian/i then d,c,l=false,lang_lst['sr'][:c], lang_lst['sr'][:n] + when /^sv$|Swedish|Svensk/i then d,c,l=false,lang_lst['sv'][:c], lang_lst['sv'][:n] + when /^ta$|Tamil/i then d,c,l=false,lang_lst['ta'][:c], lang_lst['ta'][:n] + when /^te$|Telugu/i then d,c,l=false,lang_lst['te'][:c], lang_lst['te'][:n] + when /^th$|Thai/i then d,c,l=false,lang_lst['th'][:c], lang_lst['th'][:n] + when /^tk$|Turkmen/i then d,c,l=false,lang_lst['tk'][:c], lang_lst['tk'][:n] + when /^tr$|Turkish/i then d,c,l=false,lang_lst['tr'][:c], lang_lst['tr'][:n] + when /^uk$|Ukranian/i then d,c,l=false,lang_lst['uk'][:c], lang_lst['uk'][:n] + when /^ur$|Urdu/i then d,c,l=false,lang_lst['ur'][:c], lang_lst['ur'][:n] + when /^us|American$|/i then d,c,l=false,lang_lst['en'][:c], lang_lst['en'][:n] + when /^vi$|Vietnamese/i then d,c,l=false,lang_lst['vi'][:c], lang_lst['vi'][:n] else d,c,l=true, lang_lst['en'][:c], lang_lst['en'][:n] #default end lng[:d],lng[:c],lng[:n]=d,c,l @@ -1058,17 +1059,10 @@ module SiSU_Env @fixed_websev_root='' # @home @pwd=@@pwd=Dir.pwd m=/.+\/(?:src\/)?(\S+)/m # m=/.+?\/(?:src\/)?([^\/]+)$/im # m=/.+\/(\S+)/m - @stub_pwd=@@pwd[m,1] - @stub_txt= @stub_pwd + '/txt' - @stub_html= @stub_pwd + '/html' - @stub_epub= @stub_pwd + '/epub' - @stub_odt= @stub_pwd + '/odt' - @stub_pdf= @stub_pwd + '/pdf' - @stub_manifest=@stub_pwd + '/manifest' - @stub_odt= @stub_pwd + '/odt' + @stub_pwd=@@pwd[m,1] || '' #; p __LINE__; #p @pwd; #p m; #p @stub_pwd @stub_src= @stub_pwd + '/src' @stub_pod= @stub_pwd + '/pod' - @stub_md= @stub_pwd + '/sisu_site_metadata' + @stub_epub= @stub_pwd + '/epub' pt=Pathname.new(Dir.pwd) stub=if output_dir_structure.by_language_code? r=Px[:lng_lst_rgx] @@ -1473,14 +1467,56 @@ module SiSU_Env end def odt_ocn? ((defined? @rc['odt']['ocn']) \ - && @rc['odt']['ocn']==true) \ + && @rc['odt']['ocn']==false) \ ? @rc['odt']['ocn'] - : false + : true + end + def xml_docbook_ocn? + ((defined? @rc['xml_docbook']['ocn']) \ + && @rc['xml_docbook']['ocn']==false) \ + ? @rc['xml_docbook']['ocn'] + : true + end + def xml_fictionbook_ocn? + ((defined? @rc['xml_fictionbook']['ocn']) \ + && @rc['xml_fictionbook']['ocn']==false) \ + ? @rc['xml_fictionbook']['ocn'] + : true + end + def xml_scaffold_ocn? + ((defined? @rc['xml_scaffold']['ocn']) \ + && @rc['xml_scaffold']['ocn']==false) \ + ? @rc['xml_scaffold']['ocn'] + : true end def plaintext_ocn? ((defined? @rc['plaintext']['ocn']) \ - && @rc['plaintext']['ocn']==true) \ + && @rc['plaintext']['ocn']==false) \ ? @rc['plaintext']['ocn'] + : true + end + def textile_ocn? + ((defined? @rc['textile']['ocn']) \ + && @rc['textile']['ocn']==true) \ + ? @rc['textile']['ocn'] + : false + end + def asciidoc_ocn? + ((defined? @rc['asciidoc']['ocn']) \ + && @rc['asciidoc']['ocn']==true) \ + ? @rc['asciidoc']['ocn'] + : false + end + def markdown_ocn? + ((defined? @rc['markdown']['ocn']) \ + && @rc['markdown']['ocn']==true) \ + ? @rc['markdown']['ocn'] + : false + end + def rst_ocn? + ((defined? @rc['rst']['ocn']) \ + && @rc['rst']['ocn']==true) \ + ? @rc['rst']['ocn'] : false end def widget #needs (md) #move @@ -1902,36 +1938,15 @@ WOK def stub_pwd @stub_pwd end - def stub_txt - @stub_txt - end - def stub_html - @stub_html - end def stub_epub @stub_epub end - def stub_odt - @stub_odt - end - def stub_pdf - @stub_pdf - end - def stub_manifest - @stub_manifest - end - def stub_set_manifest - @stub_set_manifest - end def stub_src @stub_src end def stub_pod @stub_pod end - def stub_md_harvest - @stub_set_manifest - end def etc defaults[:sisu_etc] #live/dynamic end @@ -1945,7 +1960,7 @@ WOK @sys.dir_bin end def share #shared data repository source directory - defaults[:sisu_share] + defaults[:sisu_share] #; p __LINE__.to_s + ':' + __FILE__ + ' ' + defaults[:sisu_share] end def style if @md \ @@ -2140,8 +2155,8 @@ WOK end def usr_dir? case root_dir - when /^\/home/; false - else true + when /^\/home/ then false + else true end end def stub_dir @@ -2154,7 +2169,7 @@ WOK ? ("#{root_dir}/#{user}/#{stub_pwd}") : ("#{root_dir}/#{stub_pwd}") # see defaults[:processing_path] end - def processing_sisupod(opt=nil) #processing directory, used/needed for sisu work files, has sub-directories (dal,tex etc) + def processing_sisupod(opt=nil) #processing directory, used/needed for sisu work files, has sub-directories (ao,tex etc) @opt=opt def paths processing_path_usr="#{root_dir}/#{user}" @@ -2188,7 +2203,7 @@ WOK end self end - def processing #processing directory, used/needed for sisu work files, has sub-directories (dal,tex etc) + def processing #processing directory, used/needed for sisu work files, has sub-directories (ao,tex etc) unless FileTest.directory?(root_dir) FileUtils::mkdir_p(root_dir) File.chmod(0777,root_dir) @@ -2212,11 +2227,11 @@ WOK end processing end - def dal + def ao pth=if defined? @rc['processing']['dal'] \ and @rc['processing']['dal'].is_a?(String) "#{processing}/#{@rc['processing']['dal']}" - else "#{processing}/#{defaults[:processing_dal]}" + else "#{processing}/#{defaults[:processing_ao]}" end FileUtils::mkdir_p(pth) unless FileTest.directory?(pth) pth @@ -2231,7 +2246,7 @@ WOK pth end def composite_file - pth=processing_path.dal #"#{processing}/composite" + pth=processing_path.ao #"#{processing}/composite" FileUtils::mkdir_p(pth) unless FileTest.directory?(pth) pth end @@ -2413,11 +2428,11 @@ WOK def webserv_host_base(opt=nil) if defined? @rc['webserv']['host'] case @rc['webserv']['host'] - when /https?:\/\//; @rc['webserv']['host'] - when /\S+/; "http://#{@rc['webserv']['host']}" - else defaults[:webserv_host_cgi] + when /https?:\/\// then @rc['webserv']['host'] + when /\S+/ then "http://#{@rc['webserv']['host']}" + else defaults[:webserv_host_cgi] end - else defaults[:webserv_host_cgi] + else defaults[:webserv_host_cgi] end end def webserv_cgi(opt=nil) #web url for local webserv (localhost, or hostname) @@ -2511,11 +2526,11 @@ WOK else '' end m=case show_output_on - when /webserv_cgi/; url.webserv_base_cgi(opt) - when /webserv/; @rc['webserv']['url_root'] - when /https?:\/\//; @rc['webserv_cgi']['file_links'] - when /\S+/; "http://#{@rc['webserv_cgi']['file_links']}" - else webserv_base_cgi(opt) + when /webserv_cgi/ then url.webserv_base_cgi(opt) + when /webserv/ then @rc['webserv']['url_root'] + when /https?:\/\// then @rc['webserv_cgi']['file_links'] + when /\S+/ then "http://#{@rc['webserv_cgi']['file_links']}" + else webserv_base_cgi(opt) end end end @@ -2549,15 +2564,15 @@ WOK else 'filesystem' end case output_type - when /^filesystem(?:_url)?/; url.dir_url - when /^remote(?:_webserv)?/; url.remote - when /^(?:webserv|local_webserv)/; url.local - when /^local(:\d+)/; url.hostname + $1 + '/' + stub_pwd - when /^localhost(:\d+)/; url.localhost + $1 + '/' + stub_pwd - when /^localhost/; url.localhost - when /^webrick/; url.webrick - when /^path/; url.webserv_map_pwd - else url.webserv_map_pwd + when /^filesystem(?:_url)?/ then url.dir_url + when /^remote(?:_webserv)?/ then url.remote + when /^(?:webserv|local_webserv)/ then url.local + when /^local(:\d+)/ then url.hostname + $1 + '/' + stub_pwd + when /^localhost(:\d+)/ then url.localhost + $1 + '/' + stub_pwd + when /^localhost/ then url.localhost + when /^webrick/ then url.webrick + when /^path/ then url.webserv_map_pwd + else url.webserv_map_pwd end end def images @@ -2655,18 +2670,18 @@ WOK if defined? @rc['default']['digest'] \ and @rc['default']['digest'] != nil case @rc['default']['digest'] - when /^sha(?:2|256)?$/; 'sha256' - when /^md5$/; 'md5' - else 'sha256' + when /^sha(?:2|256)?$/ then 'sha256' + when /^md5$/ then 'md5' + else 'sha256' end - else 'sha256' + else 'sha256' end end def length case digest.type - when /sha256/; 64 - when /md5/; 32 - else 64 + when /sha256/ then 64 + when /md5/ then 32 + else 64 end end def pattern @@ -2729,6 +2744,18 @@ WOK ? @rc['program_select']['xml_viewer'] : text_editor end + def docbook_viewer + ((defined? @rc['program_select']['xml_viewer']) \ + && @rc['program_select']['xml_viewer'] =~/\S\S+/) \ + ? @rc['program_select']['xml_viewer'] + : text_editor + end + def fictionbook_viewer + ((defined? @rc['program_select']['xml_viewer']) \ + && @rc['program_select']['xml_viewer'] =~/\S\S+/) \ + ? @rc['program_select']['xml_viewer'] + : text_editor + end def xml_editor xml_viewer end @@ -2971,93 +2998,144 @@ WOK ? (SiSU_Env::InfoEnv.new(@opt.fns)) : (SiSU_Env::InfoEnv.new('dummy.sst'))) ft=[] - if @opt.act[:dal][:set]==:on + if @opt.act[:ao][:set]==:on @md=SiSU_Param::Parameters.new(@opt).get if @md \ and defined? @md.fn \ and @md.fn # used for by_language_code? - if @md.opt.cmd =~ /[hH]/ + if @md.opt.act[:html][:set]==:on #% --html, -h -H ft << @md.fn[:html] end - if @md.opt.cmd =~ /w/ \ - and @md.opt.cmd !~ /[hH]/ + if @md.opt.act[:concordance][:set]==:on #% --concordance, -w ft << @md.fn[:concordance] end - if @md.opt.cmd =~ /y/ \ - and @md.opt.cmd !~ /[hH]/ + if @md.opt.act[:manifest][:set]==:on #% --manifest, -y ft << @md.fn[:manifest] end - if @md.opt.cmd =~ /[at]/; ft << @md.fn[:plain] + if @md.opt.act[:txt][:set]==:on #% --txt, -t -a + ft << @md.fn[:plain] + end + if @md.opt.act[:txt_textile][:set]==:on #% --textile + ft << @md.fn[:txt_textile] end - if @md.opt.cmd =~ /b/; ft << @md.fn[:xhtml] + if @md.opt.act[:txt_asciidoc][:set]==:on #% --asciidoc + ft << @md.fn[:txt_asciidoc] end - if @md.opt.cmd =~ /e/; ft << @md.fn[:epub] + if @md.opt.act[:txt_markdown][:set]==:on #% --markdown + ft << @md.fn[:txt_markdown] end - if @md.opt.cmd =~ /g/; ft << @md.fn[:wiki] + if @md.opt.act[:txt_rst][:set]==:on #% --rst, --rest + ft << @md.fn[:txt_rst] end - if @md.opt.cmd =~ /i/; ft << @md.fn[:manpage] + if @md.opt.act[:xhtml][:set]==:on #% --xhtml, -b xhtml + ft << @md.fn[:xhtml] end - if @md.opt.cmd =~ /N/; ft << @md.fn[:digest] + if @md.opt.act[:epub][:set]==:on #% --epub, -e + ft << @md.fn[:epub] end - if @md.opt.cmd =~ /o/; ft << @md.fn[:odf] + if @md.opt.act[:manpage][:set]==:on #% --manpage, -i + ft << @md.fn[:manpage] end - if @md.opt.cmd =~ /O/; ft << @md.fn[:oai_pmh] + if @md.opt.act[:hash_digests][:set]==:on #% --hash-digests, -N digest tree + ft << @md.fn[:digest] end - if @md.opt.cmd =~ /p/; ft << @md.fn[:pdf_l] << @md.fn[:pdf_p] + if @md.opt.act[:odt][:set]==:on #% --odt, -o opendocument + ft << @md.fn[:odf] end - if @md.opt.cmd =~ /s/; ft << @md.fns + if @md.opt.act[:pdf][:set]==:on #% --pdf-l --pdf, -p latex/ texpdf + ft << @md.fn[:pdf_l] << @md.fn[:pdf_p] end - if @md.opt.cmd =~ /S/; ft << @md.fn[:sisupod] << '.kdi' + if @md.opt.act[:share_source][:set]==:on + ft << @md.fns end - if @md.opt.cmd =~ /x/; ft << @md.fn[:sax] + if @md.opt.act[:sisupod][:set]==:on #% --sisupod, -S make sisupod + ft << @md.fn[:sisupod] end - if @md.opt.cmd =~ /X/; ft << @md.fn[:dom] + if @md.opt.act[:xml_sax][:set]==:on #% --xml-sax, -x xml sax type + ft << @md.fn[:sax] end - if @md.opt.cmd =~ /G/; ft << @md.fn[:pot] + if @md.opt.act[:xml_dom][:set]==:on #% --xml-dom, -X xml dom type + ft << @md.fn[:dom] + end + if @md.opt.act[:xml_docbook_book][:set]==:on #% --xml-docbook-book + ft << @md.fn[:xml_docbook_book] + end + if @md.opt.act[:xml_fictionbook][:set]==:on #% --xml-fictionbook + ft << @md.fn[:xml_fictionbook] + end + if @md.opt.act[:xml_scaffold_structure_sisu][:set]==:on #% --xml-scaffold --xml-scaffold-sisu + ft << @md.fn[:xml_scaffold_structure_sisu] + end + if @md.opt.act[:xml_scaffold_structure_collapse][:set]==:on #% --xml-scaffold-collapse + ft << @md.fn[:xml_scaffold_structure_collapse] end @fnb=@md.fnb else # still needed where/when param is not parsed - if @opt.cmd =~ /[hH]/; ft << '.html' << '.html.??' + if @opt.act[:html][:set]==:on #% --html, -h -H + ft << '.html' << '.html.??' end - if @opt.cmd =~ /w/ \ - and @opt.cmd !~ /[hH]/ + if @opt.act[:concordance][:set]==:on #% --concordance, -w ft << 'concordance.html' << '??.concordance.html' << 'concordance.??.html' end - if @opt.cmd =~ /y/ \ - and @opt.cmd !~ /[hH]/ + if @opt.act[:manifest][:set]==:on #% --manifest, -y ft << 'sisu_manifest.html' << '??.sisu_manifest.html' << 'sisu_manifest.??.html' end - if @opt.cmd =~ /a/; ft << 'plain.txt' << '??.plain.txt' << 'plain.??.txt' + if @opt.act[:txt][:set]==:on #% --txt, -t -a + ft << 'plain.txt' << '??.plain.txt' << 'plain.??.txt' + end + if @opt.act[:txt_textile][:set]==:on #% --textile + ft << 'plain.txt' << '??.plain.txt' << 'plain.??.txt' + end + if @opt.act[:txt_asciidoc][:set]==:on #% --asciidoc + ft << 'plain.txt' << '??.plain.txt' << 'plain.??.txt' + end + if @opt.act[:txt_markdown][:set]==:on #% --markdown + ft << 'plain.txt' << '??.plain.txt' << 'plain.??.txt' end - if @opt.cmd =~ /b/; ft << 'scroll.xhtml' << '??.scroll.xhtml' << 'scroll.??.xhtml' + if @opt.act[:txt_rst][:set]==:on #% --rst, --rest + ft << 'plain.txt' << '??.plain.txt' << 'plain.??.txt' end - if @opt.cmd =~ /e/; ft << @fnb << '.epub' + if @opt.act[:xhtml][:set]==:on #% --xhtml, -b xhtml + ft << 'scroll.xhtml' << '??.scroll.xhtml' << 'scroll.??.xhtml' end - if @opt.cmd =~ /g/; ft << 'wiki.txt' << '??.wiki.txt' << 'wiki.??.txt' + if @opt.act[:epub][:set]==:on #% --epub, -e + ft << @fnb << '.epub' end - if @opt.cmd =~ /i/; ft << '.1' << '??.man.1' << 'man.??.1' + if @opt.act[:manpage][:set]==:on #% --manpage, -i + ft << '.1' << '??.man.1' << 'man.??.1' end - if @opt.cmd =~ /N/; ft << 'digest.txt' << '??.digest.txt' << 'digest.??.txt' + if @opt.act[:hash_digests][:set]==:on #% --hash-digests, -N digest tree + ft << 'digest.txt' << '??.digest.txt' << 'digest.??.txt' end - if @opt.cmd =~ /o/; ft << 'opendocument.odt' << '??.opendocument.odt' << 'opendocument.??.odt' + if @opt.act[:odt][:set]==:on #% --odt, -o opendocument + ft << 'opendocument.odt' << '??.opendocument.odt' << 'opendocument.??.odt' end - if @opt.cmd =~ /O/; ft << 'oai_pmh.xml' + if @opt.act[:pdf][:set]==:on #% --pdf-l --pdf, -p latex/ texpdf + ft << 'landscape.pdf' << 'portrait.pdf' << '.pdf' end - if @opt.cmd =~ /p/; ft << 'landscape.pdf' << 'portrait.pdf' << '.pdf' + if @opt.act[:share_source][:set]==:on + ft << '.sst' << '.ssi' << '.ssm' end - if @opt.cmd =~ /s/; ft << '.sst' << '.ssi' << '.ssm' + if @opt.act[:sisupod][:set]==:on #% --sisupod, -S make sisupod + ft << '.zip' end - if @opt.cmd =~ /S/; ft << '.zip' << '.kdi' + if @opt.act[:xml_sax][:set]==:on #% --xml-sax, -x xml sax type + ft << 'sax.xml' << '??.sax.xml' << 'sax.??.xml' end - if @opt.cmd =~ /x/; ft << 'sax.xml' << '??.sax.xml' << 'sax.??.xml' + if @opt.act[:xml_dom][:set]==:on #% --xml-dom, -X xml dom type + ft << 'dom.xml' << '??.dom.xml' << 'dom.??.xml' end - if @opt.cmd =~ /X/; ft << 'dom.xml' << '??.dom.xml' << 'dom.??.xml' + if @opt.act[:xml_docbook_book][:set]==:on #% --xml-docbook-book + ft << 'docbook.xml' << '??.docbook.xml' << 'docbook.??.xml' end - if @opt.mod.inspect =~ /sxm|sxs|xml/; ft << @fnb << '.sxs.xml' + if @opt.act[:xml_fictionbook][:set]==:on #% --xml-fictionbook + ft << 'fictionbook.xml' << '??.fictionbook.xml' << 'fictionbook.??.xml' end - if @opt.mod.inspect =~ /sxd/; ft << @fnb << '.sxd.xml' + if @opt.act[:xml_scaffold_structure_sisu][:set]==:on #% --xml-scaffold --xml-scaffold-sisu + ft << 'scaffold.xml' << '??.scaffold.xml' << 'scaffold.??.xml' end - if @opt.mod.inspect =~ /sxn/; ft << @fnb << '.sxn.xml' + if @opt.act[:xml_scaffold_structure_collapse][:set]==:on #% --xml-scaffold-collapse + ft << 'scaffold.xml' << '??.scaffold.xml' << 'scaffold.??.xml' end end ft=ft.uniq @@ -3117,16 +3195,16 @@ WOK def remove_output if @opt.act[:maintenance][:set] == :on m=InfoFile.new(@opt.fnc) - tell=SiSU_Screen::Ansi.new(@opt.cmd,@opt.fns, 'remove maintenance files from: ' + @env.processing_path.dal) + tell=SiSU_Screen::Ansi.new(@opt.cmd,@opt.fns, 'remove maintenance files from: ' + @env.processing_path.ao) tell.warn unless @opt.cmd =~/q/ - deletion(m.marshal.dal_content) - deletion(m.marshal.dal_idx_sst_rel_html_seg) - deletion(m.dal_idx_sst_rel) - deletion(m.dal_idx_html) - deletion(m.dal_idx_xhtml) - deletion(m.dal_metadata) - deletion(m.dal_map_nametags) - deletion(m.dal_map_ocn_htmlseg) + deletion(m.marshal.ao_content) + deletion(m.marshal.ao_idx_sst_rel_html_seg) + deletion(m.ao_idx_sst_rel) + deletion(m.ao_idx_html) + deletion(m.ao_idx_xhtml) + deletion(m.ao_metadata) + deletion(m.ao_map_nametags) + deletion(m.ao_map_ocn_htmlseg) deletion(m.html_tune) end md=SiSU_Param::Parameters.new(@opt).get @@ -3150,6 +3228,8 @@ WOK deletion(f.place_file.xhtml.dir) deletion(f.place_file.xml_sax.dir) deletion(f.place_file.xml_dom.dir) + deletion(f.place_file.xml_scaffold_structure_sisu.dir) + deletion(f.place_file.xml_scaffold_structure_collapse.dir) deletion(f.place_file.info.dir) deletion(f.place_file.manpage.dir) deletion(f.place_file.sqlite_discrete.dir) @@ -3266,9 +3346,9 @@ WOK self.remote_host_base.each do |remote_conn| local_gen=@source_path remote_gen=case @opt.cmd - when /u/; "#{remote_conn[:name]}/#{@env.path.stub_pwd}/." #creates remote directory tree, this is not the usual function of u - when /[abhHNopwxXy]/; "#{remote_conn[:name]}/#{@env.path.stub_pwd}/#{@fnb}/." - else "#{remote_conn[:name]}/#{@env.path.stub_pwd}/." + when /u/ then "#{remote_conn[:name]}/#{@env.path.stub_pwd}/." #creates remote directory tree, this is not the usual function of u + when /[abhHNopwxXy]/ then "#{remote_conn[:name]}/#{@env.path.stub_pwd}/#{@fnb}/." + else "#{remote_conn[:name]}/#{@env.path.stub_pwd}/." end local_epub=@source_path_epub local_src=@source_path_src @@ -3354,7 +3434,7 @@ WOK end def rsync def document - f=(@opt.act[:dal][:set]==:on) \ + f=(@opt.act[:ao][:set]==:on) \ ? SiSU_Env::FileOp.new(@md) : nil if f @@ -3409,6 +3489,16 @@ WOK && FileTest.file?(f.place_file.xml_dom.dir) inp << f.place_file.xml_dom.rel end + if (@opt.act[:xml_scaffold_structure_sisu][:set]==:on \ + || @opt.cmd =~/^-[mqvVM]*R[mqvVM]*$/) \ + && FileTest.file?(f.place_file.xml_scaffold_structure_sisu.dir) + inp << f.place_file.xml_scaffold_structure_sisu.rel + end + if (@opt.act[:xml_scaffold_structure_collapse][:set]==:on \ + || @opt.cmd =~/^-[mqvVM]*R[mqvVM]*$/) \ + && FileTest.file?(f.place_file.xml_scaffold_structure_collapse.dir) + inp << f.place_file.xml_scaffold_structure_collapse.rel + end if (@opt.act[:txt][:set]==:on \ || @opt.cmd =~/^-[mqvVM]*R[mqvVM]*$/) \ && FileTest.file?(f.place_file.txt.dir) @@ -3590,13 +3680,10 @@ WOK def get_version @version={} @pwd=ENV['PWD'] - yst_ver=SiSU_is[:version_info_path] \ - ? SiSU_is[:version_info_path] - : "#{defaults[:sisu_share]}/#{SiSU_is[:version_dir]}/v/version.yml" lib_path=@@lib_path ? @@lib_path : `echo $RUBYLIB`.split(':') @@lib_path ||=lib_path - if File.exist?(yst_ver) - @version=YAML::load(File::open(yst_ver)) #unless @@noyaml + if File.exist?(SiSU_is[:version_info_path]) + @version=YAML::load(File::open(SiSU_is[:version_info_path])) #unless @@noyaml end @version[:install_method]=if SiSU_is[:run_from]==:gem_install spec = Gem::Specification.find_by_name("sisu") @@ -3677,29 +3764,29 @@ WOK FileUtils::mkdir_p(path) unless FileTest.directory?(path) end def marshal - def dal_content - "#{@env.processing_path.dal}/#{@fns}.content.rbm" + def ao_content + "#{@env.processing_path.ao}/#{@fns}.content.rbm" end - def dal_idx_sst_rel_html_seg - "#{@env.processing_path.dal}/#{@fns}.idx_sst.rbm" + def ao_idx_sst_rel_html_seg + "#{@env.processing_path.ao}/#{@fns}.idx_sst.rbm" end - def dal_idx_sst_rel #used by tex & odf - "#{@env.processing_path.dal}/#{@fns}.idx_raw.rbm" + def ao_idx_sst_rel #used by tex & odf + "#{@env.processing_path.ao}/#{@fns}.idx_raw.rbm" end - def dal_idx_html - "#{@env.processing_path.dal}/#{@fns}.idx_html.rbm" + def ao_idx_html + "#{@env.processing_path.ao}/#{@fns}.idx_html.rbm" end - def dal_idx_xhtml - "#{@env.processing_path.dal}/#{@fns}.idx_xhtml.rbm" + def ao_idx_xhtml + "#{@env.processing_path.ao}/#{@fns}.idx_xhtml.rbm" end - def dal_metadata - "#{@env.processing_path.dal}/#{@fns}.metadata.rbm" + def ao_metadata + "#{@env.processing_path.ao}/#{@fns}.metadata.rbm" end - def dal_map_nametags - "#{@env.processing_path.dal}/#{@fns}.map_name_tags.rbm" + def ao_map_nametags + "#{@env.processing_path.ao}/#{@fns}.map_name_tags.rbm" end - def dal_map_ocn_htmlseg - "#{@env.processing_path.dal}/#{@fns}.map_ocn_htmlseg.rbm" + def ao_map_ocn_htmlseg + "#{@env.processing_path.ao}/#{@fns}.map_ocn_htmlseg.rbm" end def html_tune "#{@env.processing_path.tune}/#{@fns}.marshal_tune" @@ -3714,8 +3801,8 @@ WOK end 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) + def ao + FileUtils::mkdir_p(@env.processing_path.ao) unless FileTest.directory?(@env.processing_path.ao) end def tune FileUtils::mkdir_p(@env.processing_path.tune) unless FileTest.directory?(@env.processing_path.tune) @@ -4228,7 +4315,7 @@ WOK 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}") FileUtils::mkdir_p("#{output_path.base.dir}/#{@env.path.style}") unless FileTest.directory?("#{output_path.base.dir}/#{@env.path.style}") - FileUtils::mkdir_p(@env.processing_path.dal) unless FileTest.directory?(@env.processing_path.dal) + FileUtils::mkdir_p(@env.processing_path.ao) unless FileTest.directory?(@env.processing_path.ao) FileUtils::mkdir_p(@env.processing_path.tune) unless FileTest.directory?(@env.processing_path.tune) end def path_rel_links @@ -4345,6 +4432,30 @@ WOK fn=base_filename.txt make_file(path,fn) end + def textile + path=output_path.textile.dir + make_path(path) + fn=base_filename.textile + make_file(path,fn) + end + def asciidoc + path=output_path.asciidoc.dir + make_path(path) + fn=base_filename.asciidoc + make_file(path,fn) + end + def markdown + path=output_path.markdown.dir + make_path(path) + fn=base_filename.markdown + make_file(path,fn) + end + def rst + path=output_path.rst.dir + make_path(path) + fn=base_filename.rst + make_file(path,fn) + end def html_scroll pth=output_path.html.dir make_path(pth) @@ -4388,6 +4499,30 @@ WOK fn=base_filename.xml_dom make_file(path,fn) end + def xml_docbook_book + path=output_path.xml_docbook_book.dir + make_path(path) + fn=base_filename.xml_docbook_book + make_file(path,fn) + end + def xml_fictionbook + path=output_path.xml_fictionbook.dir + make_path(path) + fn=base_filename.xml_fictionbook + make_file(path,fn) + end + def xml_scaffold_structure_sisu + path=output_path.xml_scaffold_structure_sisu.dir + make_path(path) + fn=base_filename.xml_scaffold_structure_sisu + make_file(path,fn) + end + def xml_scaffold_structure_collapse + path=output_path.xml_scaffold_structure_collapse.dir + make_path(path) + fn=base_filename.xml_scaffold_structure_collapse + make_file(path,fn) + end def manpage path=output_path.manpage.dir make_path(path) @@ -4454,6 +4589,42 @@ WOK end self end + def textile + def dir + output_path.textile.dir + '/' + base_filename.textile + end + def rel + output_path.textile.rel + '/' + base_filename.textile + end + self + end + def asciidoc + def dir + output_path.asciidoc.dir + '/' + base_filename.asciidoc + end + def rel + output_path.asciidoc.rel + '/' + base_filename.asciidoc + end + self + end + def markdown + def dir + output_path.markdown.dir + '/' + base_filename.markdown + end + def rel + output_path.markdown.rel + '/' + base_filename.markdown + end + self + end + def rst + def dir + output_path.rst.dir + '/' + base_filename.rst + end + def rel + output_path.rst.rel + '/' + base_filename.rst + end + self + end def html_scroll def dir output_path.html_scroll.dir + '/' + base_filename.html_scroll @@ -4550,6 +4721,42 @@ WOK end self end + def xml_docbook_book + def dir + output_path.xml_docbook.dir + '/' + base_filename.xml_docbook_book + end + def rel + output_path.xml_docbook.rel + '/' + base_filename.xml_docbook_book + end + self + end + def xml_fictionbook + def dir + output_path.xml_fictionbook.dir + '/' + base_filename.xml_fictionbook + end + def rel + output_path.xml_fictionbook.rel + '/' + base_filename.xml_fictionbook + end + self + end + def xml_scaffold_structure_sisu + def dir + output_path.xml.dir + '/' + base_filename.xml_scaffold_structure_sisu + end + def rel + output_path.xml.rel + '/' + base_filename.xml_scaffold_structure_sisu + end + self + end + def xml_scaffold_structure_collapse + def dir + output_path.xml.dir + '/' + base_filename.xml_scaffold_structure_collapse + end + def rel + output_path.xml.rel + '/' + base_filename.xml_scaffold_structure_collapse + end + self + end def sqlite_discrete def dir output_path.sqlite_discrete.dir + '/' + base_filename.sqlite_discrete @@ -4727,6 +4934,78 @@ WOK end i18n(fnh) end + def textile(fh=nil) + fh=default_hash_build(fh,Sfx[:txt_textile]) + fh[:lng]=lang_code?(fh[:lng]) + fnh=if output_dir_structure.by_filename? + { + fn: 'plain', + ft: fh[:ft], + lng: fh[:lng], + } + else + { + fn: fh[:fn], + ft: fh[:ft], + lng: fh[:lng], + } + end + i18n(fnh) + end + def asciidoc(fh=nil) + fh=default_hash_build(fh,Sfx[:txt_asciidoc]) + fh[:lng]=lang_code?(fh[:lng]) + fnh=if output_dir_structure.by_filename? + { + fn: 'plain', + ft: fh[:ft], + lng: fh[:lng], + } + else + { + fn: fh[:fn], + ft: fh[:ft], + lng: fh[:lng], + } + end + i18n(fnh) + end + def markdown(fh=nil) + fh=default_hash_build(fh,Sfx[:txt_markdown]) + fh[:lng]=lang_code?(fh[:lng]) + fnh=if output_dir_structure.by_filename? + { + fn: 'plain', + ft: fh[:ft], + lng: fh[:lng], + } + else + { + fn: fh[:fn], + ft: fh[:ft], + lng: fh[:lng], + } + end + i18n(fnh) + end + def rst(fh=nil) + fh=default_hash_build(fh,Sfx[:txt_rst]) + fh[:lng]=lang_code?(fh[:lng]) + fnh=if output_dir_structure.by_filename? + { + fn: 'plain', + ft: fh[:ft], + lng: fh[:lng], + } + else + { + fn: fh[:fn], + ft: fh[:ft], + lng: fh[:lng], + } + end + i18n(fnh) + end def html_scroll(fh=nil) fh=default_hash_build(fh,Sfx[:html]) fh[:lng]=lang_code?(fh[:lng]) @@ -4895,6 +5174,78 @@ WOK end i18n(fnh) end + def xml_docbook_book(fh=nil) + fh=default_hash_build(fh,Sfx[:xml_docbook_book]) + fh[:lng]=lang_code?(fh[:lng]) + fnh=if output_dir_structure.by_filename? + { + fn: 'scroll', + ft: fh[:ft], + lng: fh[:lng], + } + else + { + fn: fh[:fn], + ft: fh[:ft], + lng: fh[:lng], + } + end + i18n(fnh) + end + def xml_fictionbook(fh=nil) + fh=default_hash_build(fh,Sfx[:xml_fictionbook]) + fh[:lng]=lang_code?(fh[:lng]) + fnh=if output_dir_structure.by_filename? + { + fn: 'scroll', + ft: fh[:ft], + lng: fh[:lng], + } + else + { + fn: fh[:fn], + ft: fh[:ft], + lng: fh[:lng], + } + end + i18n(fnh) + end + def xml_scaffold_structure_sisu(fh=nil) + fh=default_hash_build(fh,Sfx[:xml_scaffold_structure_sisu]) + fh[:lng]=lang_code?(fh[:lng]) + fnh=if output_dir_structure.by_filename? + { + fn: 'scroll', + ft: fh[:ft], + lng: fh[:lng], + } + else + { + fn: fh[:fn], + ft: fh[:ft], + lng: fh[:lng], + } + end + i18n(fnh) + end + def xml_scaffold_structure_collapse(fh=nil) + fh=default_hash_build(fh,Sfx[:xml_scaffold_structure_collapse]) + fh[:lng]=lang_code?(fh[:lng]) + fnh=if output_dir_structure.by_filename? + { + fn: 'scroll', + ft: fh[:ft], + lng: fh[:lng], + } + else + { + fn: fh[:fn], + ft: fh[:ft], + lng: fh[:lng], + } + end + i18n(fnh) + end def pdf_p(fh=nil) fh=default_hash_build(fh,Sfx[:pdf]) fh[:lng]=lang_code?(fh[:lng]) @@ -5467,6 +5818,90 @@ WOK end self end + def textile + def ft + 'textile_CONSTRUCTION_ZONE' + end + def dir + set_path(ft).dir.abc + end + def url + set_path(ft).url.abc + end + def rel + set_path(ft).rel.abc + end + def rcp + set_path(ft).rcp.abc + end + def rel_sm + set_path(ft).rel_sm.ab + end + self + end + def asciidoc + def ft + 'asciidoc_CONSTRUCTION_ZONE' + end + def dir + set_path(ft).dir.abc + end + def url + set_path(ft).url.abc + end + def rel + set_path(ft).rel.abc + end + def rcp + set_path(ft).rcp.abc + end + def rel_sm + set_path(ft).rel_sm.ab + end + self + end + def markdown + def ft + 'markdown_CONSTRUCTION_ZONE' + end + def dir + set_path(ft).dir.abc + end + def url + set_path(ft).url.abc + end + def rel + set_path(ft).rel.abc + end + def rcp + set_path(ft).rcp.abc + end + def rel_sm + set_path(ft).rel_sm.ab + end + self + end + def rst + def ft + 'rst_CONSTRUCTION_ZONE' + end + def dir + set_path(ft).dir.abc + end + def url + set_path(ft).url.abc + end + def rel + set_path(ft).rel.abc + end + def rcp + set_path(ft).rcp.abc + end + def rel_sm + set_path(ft).rel_sm.ab + end + self + end def html_scroll def ft 'html' @@ -5666,6 +6101,152 @@ WOK xml self end + def xml_docbook + def ft + 'docbook_CONSTRUCTION_ZONE' + end + def dir + set_path(ft).dir.abc + end + def url + set_path(ft).url.abc + end + def rel + set_path(ft).rel.abc + end + def rcp + set_path(ft).rcp.abc + end + def rel_sm + set_path(ft).rel_sm.ab + end + def rel_image + '../../_sisu/image' + end + self + end + def xml_docbook_article + def ft + 'docbook' + end + def dir + set_path(ft).dir.abc + end + def url + set_path(ft).url.abc + end + def rel + set_path(ft).rel.abc + end + def rcp + set_path(ft).rcp.abc + end + def rel_sm + set_path(ft).rel_sm.ab + end + def rel_image + '../../_sisu/image' + end + self + end + def xml_docbook_book + def ft + 'docbook_CONSTRUCTION_ZONE' + end + def dir + set_path(ft).dir.abc + end + def url + set_path(ft).url.abc + end + def rel + set_path(ft).rel.abc + end + def rcp + set_path(ft).rcp.abc + end + def rel_sm + set_path(ft).rel_sm.ab + end + def rel_image + '../../_sisu/image' + end + self + end + def xml_fictionbook + def ft + 'fictionbook_CONSTRUCTION_ZONE' + end + def dir + set_path(ft).dir.abc + end + def url + set_path(ft).url.abc + end + def rel + set_path(ft).rel.abc + end + def rcp + set_path(ft).rcp.abc + end + def rel_sm + set_path(ft).rel_sm.ab + end + def rel_image + '../../_sisu/image' + end + self + end + def xml_scaffold_structure_sisu + def ft + 'sisu.scaffold.xml' + #'xml' + end + def dir + set_path(ft).dir.abc + end + def url + set_path(ft).url.abc + end + def rel + set_path(ft).rel.abc + end + def rcp + set_path(ft).rcp.abc + end + def rel_sm + set_path(ft).rel_sm.ab + end + def rel_image + '../../_sisu/image' + end + self + end + def xml_scaffold_structure_collapse + def ft + 'collapsed.scaffold.xml' + #'xml' + end + def dir + set_path(ft).dir.abc + end + def url + set_path(ft).url.abc + end + def rel + set_path(ft).rel.abc + end + def rcp + set_path(ft).rcp.abc + end + def rel_sm + set_path(ft).rel_sm.ab + end + def rel_image + '../../_sisu/image' + end + self + end def pdf def ft 'pdf' @@ -5987,17 +6568,17 @@ WOK File.new('/tmp/errorlog.sisu','w+') end def file_txt - File.new("#{@env.processing_path.dal}/#{@fns}.txt",'w+') + File.new("#{@env.processing_path.ao}/#{@fns}.txt",'w+') end def file_debug - File.new("#{@env.processing_path.dal}/#{@fns}.debug.txt",'w+') + File.new("#{@env.processing_path.ao}/#{@fns}.debug.txt",'w+') end def metaverse def file_meta - File.new("#{@env.processing_path.dal}/#{@fns}.meta",'w+') + File.new("#{@env.processing_path.ao}/#{@fns}.meta",'w+') end def file_meta_idx_html - File.new("#{@env.processing_path.dal}/#{@fns}.idx.html",'w+') + File.new("#{@env.processing_path.ao}/#{@fns}.idx.html",'w+') end self end @@ -6005,7 +6586,7 @@ WOK File.new("#{Dir.pwd}/#{@fns}.fn",'w+') end def meta - "#{@env.processing_path.dal}/#{@fns}.meta" + "#{@env.processing_path.ao}/#{@fns}.meta" end def file_semantic filename_semantic="./semantic.yaml" @@ -6061,9 +6642,9 @@ WOK @md=operation end case operation #watch - when /pdf/; @env_out='' + when /pdf/ then @env_out='' when /sql/ - when /xml|plaintext|ascii/; @env_out="#{@env.path.output}/#{@fnb}" #check change of name to plaintext from ascii + when /xml|plaintext|ascii/ then @env_out="#{@env.path.output}/#{@fnb}" #check change of name to plaintext from ascii else if defined? @md.sfx_src \ and @md.sfx_src =~/ss[ftsumc]/ diff --git a/lib/sisu/v4/termsheet.rb b/lib/sisu/v6/termsheet.rb index 83207018..834ca819 100644 --- a/lib/sisu/v4/termsheet.rb +++ b/lib/sisu/v6/termsheet.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/termsheet.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/termsheet.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> diff --git a/lib/sisu/v4/texinfo.rb b/lib/sisu/v6/texinfo.rb index f48ecebe..1f3df4e3 100644 --- a/lib/sisu/v4/texinfo.rb +++ b/lib/sisu/v6/texinfo.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/texinfo.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/texinfo.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -103,16 +104,20 @@ module SiSU_TexInfo end def song begin - tool=(@opt.cmd =~/[MVv]/) \ - ? "#{@env.program.texinfo} #{@md.file.output_path.texinfo.dir}/#{@md.file.base_filename.info}" + tool=(@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) \ + ? "cd #{@md.file.output_path.texinfo.dir} && #{@env.program.texinfo} #{@md.file.base_filename.info}; cd -" : "[#{@opt.f_pth[:lng_is]}] #{@opt.fno}" - @opt.cmd=~/[MVvz]/ \ - && @opt.cmd !~/q/ \ - ? SiSU_Screen::Ansi.new(@opt.cmd,'TexInfo',tool).green_hi_blue - : SiSU_Screen::Ansi.new(@opt.cmd,'TexInfo',tool).green_title_hi + (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) \ + && ! @opt.act[:quiet][:set]==:on \ + ? SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'TexInfo',tool).green_hi_blue + : SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'TexInfo',tool).green_title_hi @md=SiSU_Param::Parameters.new(@opt).get directories - @marshalfile=SiSU_Env::InfoFile.new(@opt.fns).marshal.dal_content + @marshalfile=SiSU_Env::InfoFile.new(@opt.fns).marshal.ao_content if FileTest.file?(@marshalfile)==true File.open(@marshalfile) { |f| @@tuned_file=Marshal.load(f)} #tell.meta_verse_skipped if @opt.cmd =~/[vVM]/ @@ -123,7 +128,7 @@ module SiSU_TexInfo tex_array=@@tuned_file TeXinfoMake.new(@md,tex_array).songsheet tex_array='' - rescue; STDERR.puts SiSU_Screen::Ansi.new(@opt.cmd,$!,$@).rescue + rescue; STDERR.puts SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],$!,$@).rescue ensure end end @@ -151,7 +156,7 @@ module SiSU_TexInfo output(doc_txt) makeinfo #KEEP reinstate when fixed #% place_info - rescue; STDERR.puts SiSU_Screen::Ansi.new(@md.opt.cmd,$!,$@).rescue + rescue; STDERR.puts SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],$!,$@).rescue ensure end end @@ -267,7 +272,7 @@ module SiSU_TexInfo @submenu,@subsubmenu={},{} data.each do |dob| if dob.is ==:heading \ - && (dob.ln.to_s =~ /^[1-3]$/) + && (dob.ln.to_s =~ /^[0-3]$/) toc=SiSU_TexInfoFormat::Texinfo.new(@md,dob) texinfo_menu << toc.menu elsif dob.is ==:heading \ @@ -308,9 +313,10 @@ module SiSU_TexInfo end if dob.is==:heading case dob.ln - when 1; dob=mono.level1 - when 2; dob=mono.level2 - when 3; dob=mono.level3 + when 0 then dob=mono.level0 + when 1 then dob=mono.level1 + when 2 then dob=mono.level2 + when 3 then dob=mono.level3 when 4; @@n4_txt=dob.obj dob=mono.level4 @@ -340,8 +346,9 @@ module SiSU_TexInfo dob.obj=nil else if dob.is==:para \ - && (dob.obj !~/##{dob.ocn}/) - dob.obj="#{dob.obj} ##{dob.ocn}\n\n" + && (dob.obj !~/#{Dx[:ocn_o]}#{dob.ocn}#{Dx[:ocn_c]}/) + dob.obj=dob.ocn.is_a?(Fixnum) \ + ? "#{dob.obj} #{Dx[:ocn_o]}#{dob.ocn}#{Dx[:ocn_c]}\n\n" : "#{dob.obj}\n\n" end end end @@ -388,7 +395,7 @@ module SiSU_TexInfo 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/ + puts filename_texinfo if @md.opt.act[:maintenance][:set]==:on data.each {|s| (file_texinfo.puts s,"\n") if s} file_texinfo.close end @@ -411,7 +418,9 @@ module SiSU_TexInfo FileUtils::mkdir_p(@f.output_path.texinfo.dir) end info_src=%{#{@env.processing_path.texi}/#{@md.fnb}.info} - FileUtils::cp(info_src, @f.place_file.info.dir) + Dir.glob("#{info_src}*").sort.each do |f| + FileUtils::cp(f, File.dirname(@f.place_file.info.dir)) # bug should provide dir without need to extract it! + end end end end diff --git a/lib/sisu/v4/texinfo_format.rb b/lib/sisu/v6/texinfo_format.rb index 7bfa4e39..884abfcb 100644 --- a/lib/sisu/v4/texinfo_format.rb +++ b/lib/sisu/v6/texinfo_format.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/texinfo_format.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/texinfo_format.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -281,11 +282,11 @@ WOK end def clean(dob) if dob.is==:heading \ - and dob.obj !~/##{dob.ocn}/ - dob.obj="#{dob.obj} ##{dob.ocn}" + and dob.obj !~/#{Dx[:ocn_o]}#{dob.ocn}#{Dx[:ocn_c]}/ + dob.obj=dob.ocn.is_a?(Fixnum) \ + ? "#{dob.obj} #{Dx[:ocn_o]}#{dob.ocn}#{Dx[:ocn_c]}" : dob.obj end dob.obj=dob.obj.gsub(/\n/m,' '). - gsub(/<:#>/,''). gsub(/,\s+/,' - '). strip dob @@ -310,6 +311,9 @@ WOK dob.obj="@node #{nd}, #{up}\n@comment node-name, up\n@unnumbered #{nd}\n@cindex chapter, #{nd}\n\n" dob end + def level0 + level_common + end def level1 level_common end @@ -521,10 +525,11 @@ WOK end def clean(dob,txt) if dob.is==:heading \ - and txt !~/##{dob.ocn}/ - txt="#{dob.obj} ##{dob.ocn}" + and txt !~/#{Dx[:ocn_o]}#{dob.ocn}#{Dx[:ocn_c]}/ + txt=dob.ocn.is_a?(Fixnum) \ + ? "#{dob.obj} #{Dx[:ocn_o]}#{dob.ocn}#{Dx[:ocn_c]}" : dob.obj end - txt=txt.gsub(/<:#>/,'').strip + txt.strip end def submenu txt=@txt.join("\n") diff --git a/lib/sisu/v4/texpdf.rb b/lib/sisu/v6/texpdf.rb index edefac31..496f77fe 100644 --- a/lib/sisu/v4/texpdf.rb +++ b/lib/sisu/v6/texpdf.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/texpdf.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/texpdf.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -81,8 +82,8 @@ module SiSU_TeX require_relative 'sysenv' # sysenv.rb include SiSU_Env include SiSU_Viz - require_relative 'dal' # dal.rb - include SiSU_DAL + require_relative 'ao' # ao.rb + include SiSU_AO include SiSU_TeX def initialize(opt) @opt=opt @@ -110,23 +111,25 @@ module SiSU_TeX def song begin @md=@particulars.md - SiSU_Screen::Ansi.new(@opt.cmd,'LaTeX/PDF',"[#{@opt.f_pth[:lng_is]}] #{@opt.fno}").green_title_hi unless @opt.cmd =~/q/ - if @opt.cmd =~/[MVv]/ + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'LaTeX/PDF',"[#{@opt.f_pth[:lng_is]}] #{@opt.fno}").green_title_hi unless @opt.act[:quiet][:set]==:on + if (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) @env.url.output_tell if @md.opt.act[:pdf_l][:set]==:on - SiSU_Screen::Ansi.new(@opt.cmd,@opt.fns,"#{@env.program.pdf_viewer} #{@md.file.output_path.pdf.dir}/#{@md.file.base_filename.pdf_l}#{@md.papersize_array[0]}.pdf").flow + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],@opt.fns,"#{@env.program.pdf_viewer} #{@md.file.output_path.pdf.dir}/#{@md.file.base_filename.pdf_l}#{@md.papersize_array[0]}.pdf").flow end if @md.opt.act[:pdf_p][:set]==:on - SiSU_Screen::Ansi.new(@opt.cmd,@opt.fns,"#{@opt.fns} #{@env.program.pdf_viewer} #{@md.file.output_path.pdf.dir}/#{@md.file.base_filename.pdf_p}#{@md.papersize_array[0]}.pdf").flow + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],@opt.fns,"#{@opt.fns} #{@env.program.pdf_viewer} #{@md.file.output_path.pdf.dir}/#{@md.file.base_filename.pdf_p}#{@md.papersize_array[0]}.pdf").flow end end @md=@particulars.md $flag=@md.opt.cmd #introduced to pass 0 for no object citation numbers... to texpdf_format directories #% needed needs to be reprogrammed !!! - dal_array=SiSU_DAL::Source.new(@opt).get # dal file drawn here + ao_array=SiSU_AO::Source.new(@opt).get # ao file drawn here SiSU_TeX::Source::LaTeXcreate.new(@particulars).songsheet - dal_array='' + ao_array='' pwd=Dir.pwd SiSU_TeX::Source::LaTeXtoPdf.new(@md,@particulars.env).latexrun_selective Dir.chdir(pwd) @@ -135,7 +138,8 @@ module SiSU_TeX __LINE__.to_s + ':' + __FILE__ end ensure - unless @opt.cmd =~/[MV]/ #check maintenance flag + unless (@opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) texfiles=Dir["#{@env.processing_path.tex}/#{@opt.fns}*"] texfiles.each do |f| if FileTest.file?(f) @@ -168,7 +172,11 @@ module SiSU_TeX tex_fn_base=@texfilename.gsub(/\.tex$/,'') tell=SiSU_Screen::Ansi.new(@md.opt.cmd) if @md.opt.act[:pdf_p][:set]==:on - SiSU_Screen::Ansi.new(@md.opt.cmd,"#{papersize} portrait ->").dark_grey_title_hi if @md.opt.cmd =~/[MVv]/ + if (@md.opt.act[:verbose][:set]==:on \ + || @md.opt.act[:verbose_plus][:set]==:on \ + || @md.opt.act[:maintenance][:set]==:on) + SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],"#{papersize} portrait ->").dark_grey_title_hi + end cmd=SiSU_Env::SystemCall.new("#{tex_fn_base}.tex",'',@md.opt.cmd) tell.grey_open if @md.opt.cmd =~/[MVv]/ if "#{tex_fn_base}" =~/\w+/ \ @@ -178,14 +186,26 @@ module SiSU_TeX tell.p_off if @md.opt.cmd =~/[MVv]/ end if @md.opt.act[:pdf_l][:set]==:on - SiSU_Screen::Ansi.new(@md.opt.cmd,"#{papersize} landscape ->").dark_grey_title_hi if @md.opt.cmd =~/[MVv]/ + if (@md.opt.act[:verbose][:set]==:on \ + || @md.opt.act[:verbose_plus][:set]==:on \ + || @md.opt.act[:maintenance][:set]==:on) + SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],"#{papersize} landscape ->").dark_grey_title_hi + end cmd=SiSU_Env::SystemCall.new("#{tex_fn_base}.landscape.tex",'',@md.opt.cmd) - tell.grey_open if @md.opt.cmd =~/[MVv]/ + if (@md.opt.act[:verbose][:set]==:on \ + || @md.opt.act[:verbose_plus][:set]==:on \ + || @md.opt.act[:maintenance][:set]==:on) + tell.grey_open + end if "#{tex_fn_base}" =~/\w+/ \ and "#{papersize}" =~/\w+/ 2.times { |i| cmd.latex2pdf(@md,papersize) } #comment out to skip processing of latex landscape end - tell.p_off if @md.opt.cmd =~/[MVv]/ + if (@md.opt.act[:verbose][:set]==:on \ + || @md.opt.act[:verbose_plus][:set]==:on \ + || @md.opt.act[:maintenance][:set]==:on) + tell.p_off + end end pwd=Dir.pwd if @md.opt.act[:pdf_p][:set]==:on @@ -195,22 +215,22 @@ module SiSU_TeX landscape_pdf="#{pwd}/#{tex_fn_base}.landscape.pdf" end case papersize - when /a4/; pdf_p=@f.pdf_p_a4; pdf_l=@f.pdf_l_a4 - when /a5/; pdf_p=@f.pdf_p_a5; pdf_l=@f.pdf_l_a5 - when /b5/; pdf_p=@f.pdf_p_b5; pdf_l=@f.pdf_l_b5 - when /letter/; pdf_p=@f.pdf_p_letter; pdf_l=@f.pdf_l_letter - when /legal/; pdf_p=@f.pdf_p_legal; pdf_l=@f.pdf_l_legal - else pdf_p=@f.pdf_p_a4; pdf_l=@f.pdf_l_a4 + when /a4/ then pdf_p=@f.pdf_p_a4; pdf_l=@f.pdf_l_a4 + when /a5/ then pdf_p=@f.pdf_p_a5; pdf_l=@f.pdf_l_a5 + when /b5/ then pdf_p=@f.pdf_p_b5; pdf_l=@f.pdf_l_b5 + when /letter/ then pdf_p=@f.pdf_p_letter; pdf_l=@f.pdf_l_letter + when /legal/ then pdf_p=@f.pdf_p_legal; pdf_l=@f.pdf_l_legal + else pdf_p=@f.pdf_p_a4; pdf_l=@f.pdf_l_a4 end FileUtils::mkdir_p(@md.file.output_path.pdf.dir) unless FileTest.directory?(@md.file.output_path.pdf.dir) - cX=SiSU_Screen::Ansi.new(@md.opt.cmd).cX + cX=SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set]).cX if @md.opt.act[:pdf_p][:set]==:on if FileTest.file?(portrait_pdf) FileUtils::cp(portrait_pdf,"#{@md.file.output_path.pdf.dir}/#{pdf_p}") FileUtils::rm(portrait_pdf) else STDERR.puts "#{cX.fuchsia}pdf file not generated#{cX.off} <#{cX.blue}#{portrait_pdf.gsub(/.+?([^\/]+?\.pdf)$/,'\1')}#{cX.off}> (check texlive dependencies)" - STDERR.puts "#{__FILE__}:#{__LINE__} NOT FOUND: #{portrait_pdf}" if @md.opt.cmd.inspect =~/M/ + STDERR.puts "#{__FILE__}:#{__LINE__} NOT FOUND: #{portrait_pdf}" if @md.opt.act[:maintenance][:set]==:on end end if @md.opt.act[:pdf_l][:set]==:on @@ -219,10 +239,14 @@ module SiSU_TeX FileUtils::rm(landscape_pdf) else STDERR.puts "#{cX.fuchsia}pdf file not generated#{cX.off} <#{cX.blue}#{landscape_pdf.gsub(/.+?([^\/]+?\.pdf)$/,'\1')}#{cX.off}> (check texlive dependencies)" - STDERR.puts "#{__FILE__}:#{__LINE__} NOT FOUND: #{landscape_pdf}" if @md.opt.cmd.inspect =~/M/ + STDERR.puts "#{__FILE__}:#{__LINE__} NOT FOUND: #{landscape_pdf}" if @md.opt.act[:maintenance][:set]==:on end end - SiSU_Screen::Ansi.new(@md.opt.cmd,@@n_lpdf,'processed (SiSU LaTeX to pdf - using pdfetex aka. pdftex or pdflatex)').generic_number if @md.opt.cmd =~/[MVv]/ + if (@md.opt.act[:verbose][:set]==:on \ + || @md.opt.act[:verbose_plus][:set]==:on \ + || @md.opt.act[:maintenance][:set]==:on) + SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],@@n_lpdf,'processed (SiSU LaTeX to pdf - using pdfetex aka. pdftex or pdflatex)').generic_number + end end def latexrun_selective begin @@ -255,12 +279,12 @@ module SiSU_TeX end end case @md.papersize_array[0] #default pdf - when /a4/; pdf_p=@f.pdf_p_a4; pdf_l=@f.pdf_l_a4 - when /a5/; pdf_p=@f.pdf_p_a5; pdf_l=@f.pdf_l_a5 - when /b5/; pdf_p=@f.pdf_p_b5; pdf_l=@f.pdf_l_b5 - when /letter/; pdf_p=@f.pdf_p_letter; pdf_l=@f.pdf_l_letter - when /legal/; pdf_p=@f.pdf_p_legal; pdf_l=@f.pdf_l_legal - else pdf_p=@f.pdf_p_a4; pdf_l=@f.pdf_l_a4 + when /a4/ then pdf_p=@f.pdf_p_a4; pdf_l=@f.pdf_l_a4 + when /a5/ then pdf_p=@f.pdf_p_a5; pdf_l=@f.pdf_l_a5 + when /b5/ then pdf_p=@f.pdf_p_b5; pdf_l=@f.pdf_l_b5 + when /letter/ then pdf_p=@f.pdf_p_letter; pdf_l=@f.pdf_l_letter + when /legal/ then pdf_p=@f.pdf_p_legal; pdf_l=@f.pdf_l_legal + else pdf_p=@f.pdf_p_a4; pdf_l=@f.pdf_l_a4 end if @md.opt.act[:pdf_p][:set]==:on if FileTest.file?("#{@md.file.output_path.pdf.dir}/#{pdf_p}") @@ -291,7 +315,7 @@ module SiSU_TeX end end else - SiSU_Screen::Ansi.new(@md.opt.cmd,"*WARN* FILE NOT FOUND: << #{@md.fns} >> - requested latex system processing skipped").warn + SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],"*WARN* FILE NOT FOUND: << #{@md.fns} >> - requested latex system processing skipped").warn end lst=Dir["*.{aux,log,out}"] lst.each {|file| File.unlink(file)} if lst @@ -316,7 +340,7 @@ module SiSU_TeX @particulars=particulars @md=@particulars.md @env=SiSU_Env::InfoEnv.new(@md.fns) #@env=@particulars.env - @data=@particulars.dal_array # dal file drawn here + @data=@particulars.ao_array # ao file drawn here @st={ tex: {} } @tex_ml=SiSU_TeX_Pdf::UseTeX.new(@md) @vz=SiSU_Viz::Defaults.new @@ -343,7 +367,11 @@ module SiSU_TeX else SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).mark('error: neither landscape nor portrait') end - SiSU_Screen::Ansi.new(@md.opt.cmd,txt_gen).txt_grey if @md.opt.cmd=~/[MVvz]/ + if (@md.opt.act[:verbose][:set]==:on \ + || @md.opt.act[:verbose_plus][:set]==:on \ + || @md.opt.act[:maintenance][:set]==:on) + SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],txt_gen).txt_grey + end if defined? @md.rights.all \ and not @md.rights.all.empty? rght=@md.rights #.author.dup #dup is necessary, else contents of :rights changed @@ -853,7 +881,7 @@ module SiSU_TeX p: markup_common(dob.tmp[ps][:p]), l: markup_common(dob.tmp[ps][:l]) } - else p "#{__FILE__}:#{__LINE__}" if @md.opt.cmd.inspect =~/M/ + else p "#{__FILE__}:#{__LINE__}" if @md.opt.act[:maintenance][:set]==:on end end end @@ -863,7 +891,7 @@ module SiSU_TeX p: markup_common(dob.tmp[:p]), l: markup_common(dob.tmp[:l]) } - else p "#{__FILE__}:#{__LINE__}" if @md.opt.cmd.inspect =~/M/ + else p "#{__FILE__}:#{__LINE__}" if @md.opt.act[:maintenance][:set]==:on end end @tex_file << dob @@ -918,7 +946,7 @@ module SiSU_TeX l: number_paras_numbering(dob.tmp[ps][:l]) } dob.tmp=para_hash - else p "#{__FILE__}:#{__LINE__}" if @md.opt.cmd.inspect =~/M/ + else p "#{__FILE__}:#{__LINE__}" if @md.opt.act[:maintenance][:set]==:on end end end @@ -927,7 +955,7 @@ module SiSU_TeX p: number_paras_numbering(dob.tmp[:p]), l: number_paras_numbering(dob.tmp[:l]) } - else p "#{__FILE__}:#{__LINE__}" if @md.opt.cmd.inspect =~/M/ + else p "#{__FILE__}:#{__LINE__}" if @md.opt.act[:maintenance][:set]==:on end else dob=if dob.of !=:comment \ @@ -981,7 +1009,7 @@ module SiSU_TeX fn[:landscape].puts h[:l],"\n" end end - else p "#{__FILE__}:#{__LINE__}" if @md.opt.cmd.inspect =~/M/ + else p "#{__FILE__}:#{__LINE__}" if @md.opt.act[:maintenance][:set]==:on end end def output(array) @@ -1015,7 +1043,7 @@ module SiSU_TeX file[:landscape].puts morph,"\n" end end - elsif morph.class.inspect =~ /SiSU_DAL_DocumentStructure/ \ + elsif morph.class.inspect =~ /SiSU_AO_DocumentStructure/ \ and morph.tmp \ and morph.tmp.is_a?(String) if morph.is !=:code \ diff --git a/lib/sisu/v4/texpdf_format.rb b/lib/sisu/v6/texpdf_format.rb index d87a457e..97007d17 100644 --- a/lib/sisu/v4/texpdf_format.rb +++ b/lib/sisu/v6/texpdf_format.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/texpdf_format.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/texpdf_format.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -133,11 +134,11 @@ module SiSU_TeX_Pdf row_break='\\\\\\' 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 - when /legal/i; @tx.legal.landscape.w #U.S. alternative - when /book|b5/i; @tx.b5.landscape.w #book default - larger - when /a5/i; @tx.a5.landscape.w + when /a4/i then @tx.a4.landscape.w #European default, SiSU default + when /letter/i then @tx.letter.landscape.w #U.S. default + when /legal/i then @tx.legal.landscape.w #U.S. alternative + when /book|b5/i then @tx.b5.landscape.w #book default - larger + when /a5/i then @tx.a5.landscape.w else @tx.a4.landscape.w #default currently A4 end textwidth=(tw.to_i/2) - 24 @@ -168,7 +169,7 @@ module SiSU_TeX_Pdf end rows_new << r end - table=rows_new.join #@dob[:dal].obj=rows.join + table=rows_new.join #@dob[:ao].obj=rows.join ocn_display(@dob) + start_table + table + " #{end_table}\n\\end{tiny}" else '' end @@ -178,11 +179,11 @@ module SiSU_TeX_Pdf row_break='\\\\\\' 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 - when /legal/i; @tx.legal.portrait.w #U.S. alternative - when /book|b5/i; @tx.b5.portrait.w #book default - larger - when /a5/i; @tx.a5.portrait.w + when /a4/i then @tx.a4.portrait.w #European default, SiSU default + when /letter/i then @tx.letter.portrait.w #U.S. default + when /legal/i then @tx.legal.portrait.w #U.S. alternative + when /book|b5/i then @tx.b5.portrait.w #book default - larger + when /a5/i then @tx.a5.portrait.w else @tx.a4.portrait.w #default currently A4 end textwidth=tw.to_i - 20 @@ -213,7 +214,7 @@ module SiSU_TeX_Pdf end rows_new << r end - table=rows_new.join #@dob[:dal].obj=rows.join + table=rows_new.join #@dob[:ao].obj=rows.join ocn_display(@dob) + start_table + table + " #{end_table}\n\\end{tiny}" else '' end @@ -311,163 +312,163 @@ module SiSU_TeX_Pdf case @dob.indent when /0/ case @dob.hang - when /0/; indent,hang='0mm', '0mm' - when /1/; indent,hang='0mm','10mm' - when /2/; indent,hang='0mm','20mm' - when /3/; indent,hang='0mm','30mm' - when /4/; indent,hang='0mm','40mm' - when /5/; indent,hang='0mm','50mm' - when /6/; indent,hang='0mm','60mm' - when /7/; indent,hang='0mm','70mm' - when /8/; indent,hang='0mm','80mm' - when /9/; indent,hang='0mm','90mm' + when /0/ then indent,hang='0mm', '0mm' + when /1/ then indent,hang='0mm','10mm' + when /2/ then indent,hang='0mm','20mm' + when /3/ then indent,hang='0mm','30mm' + when /4/ then indent,hang='0mm','40mm' + when /5/ then indent,hang='0mm','50mm' + when /6/ then indent,hang='0mm','60mm' + when /7/ then indent,hang='0mm','70mm' + when /8/ then indent,hang='0mm','80mm' + when /9/ then indent,hang='0mm','90mm' end when /1/ case @dob.hang - when /0/; indent,hang='10mm','-10mm' - when /1/; indent,hang='10mm', '0mm' - when /2/; indent,hang='10mm', '10mm' - when /3/; indent,hang='10mm', '20mm' - when /4/; indent,hang='10mm', '30mm' - when /5/; indent,hang='10mm', '40mm' - when /6/; indent,hang='10mm', '50mm' - when /7/; indent,hang='10mm', '60mm' - when /8/; indent,hang='10mm', '70mm' - when /9/; indent,hang='10mm', '80mm' + when /0/ then indent,hang='10mm','-10mm' + when /1/ then indent,hang='10mm', '0mm' + when /2/ then indent,hang='10mm', '10mm' + when /3/ then indent,hang='10mm', '20mm' + when /4/ then indent,hang='10mm', '30mm' + when /5/ then indent,hang='10mm', '40mm' + when /6/ then indent,hang='10mm', '50mm' + when /7/ then indent,hang='10mm', '60mm' + when /8/ then indent,hang='10mm', '70mm' + when /9/ then indent,hang='10mm', '80mm' end when /2/ case @dob.hang - when /0/; indent,hang='20mm','-20mm' - when /1/; indent,hang='20mm','-10mm' - when /2/; indent,hang='20mm', '0mm' - when /3/; indent,hang='20mm', '10mm' - when /4/; indent,hang='20mm', '20mm' - when /5/; indent,hang='20mm', '30mm' - when /6/; indent,hang='20mm', '40mm' - when /7/; indent,hang='20mm', '50mm' - when /8/; indent,hang='20mm', '60mm' - when /9/; indent,hang='20mm', '70mm' + when /0/ then indent,hang='20mm','-20mm' + when /1/ then indent,hang='20mm','-10mm' + when /2/ then indent,hang='20mm', '0mm' + when /3/ then indent,hang='20mm', '10mm' + when /4/ then indent,hang='20mm', '20mm' + when /5/ then indent,hang='20mm', '30mm' + when /6/ then indent,hang='20mm', '40mm' + when /7/ then indent,hang='20mm', '50mm' + when /8/ then indent,hang='20mm', '60mm' + when /9/ then indent,hang='20mm', '70mm' end when /3/ case @dob.hang - when /0/; indent,hang='30mm','-30mm' - when /1/; indent,hang='30mm','-20mm' - when /2/; indent,hang='30mm','-10mm' - when /3/; indent,hang='30mm', '0mm' - when /4/; indent,hang='30mm', '10mm' - when /5/; indent,hang='30mm', '20mm' - when /6/; indent,hang='30mm', '30mm' - when /7/; indent,hang='30mm', '40mm' - when /8/; indent,hang='30mm', '50mm' - when /9/; indent,hang='30mm', '60mm' + when /0/ then indent,hang='30mm','-30mm' + when /1/ then indent,hang='30mm','-20mm' + when /2/ then indent,hang='30mm','-10mm' + when /3/ then indent,hang='30mm', '0mm' + when /4/ then indent,hang='30mm', '10mm' + when /5/ then indent,hang='30mm', '20mm' + when /6/ then indent,hang='30mm', '30mm' + when /7/ then indent,hang='30mm', '40mm' + when /8/ then indent,hang='30mm', '50mm' + when /9/ then indent,hang='30mm', '60mm' end when /4/ case @dob.hang - when /0/; indent,hang='40mm','-40mm' - when /1/; indent,hang='40mm','-30mm' - when /2/; indent,hang='40mm','-20mm' - when /3/; indent,hang='40mm','-10mm' - when /4/; indent,hang='40mm', '0mm' - when /5/; indent,hang='40mm', '10mm' - when /6/; indent,hang='40mm', '20mm' - when /7/; indent,hang='40mm', '30mm' - when /8/; indent,hang='40mm', '40mm' - when /9/; indent,hang='40mm', '50mm' + when /0/ then indent,hang='40mm','-40mm' + when /1/ then indent,hang='40mm','-30mm' + when /2/ then indent,hang='40mm','-20mm' + when /3/ then indent,hang='40mm','-10mm' + when /4/ then indent,hang='40mm', '0mm' + when /5/ then indent,hang='40mm', '10mm' + when /6/ then indent,hang='40mm', '20mm' + when /7/ then indent,hang='40mm', '30mm' + when /8/ then indent,hang='40mm', '40mm' + when /9/ then indent,hang='40mm', '50mm' end when /5/ case @dob.hang - when /0/; indent,hang='50mm','-50mm' - when /1/; indent,hang='50mm','-40mm' - when /2/; indent,hang='50mm','-30mm' - when /3/; indent,hang='50mm','-20mm' - when /4/; indent,hang='50mm','-10mm' - when /5/; indent,hang='50mm', '0mm' - when /6/; indent,hang='50mm', '10mm' - when /7/; indent,hang='50mm', '20mm' - when /8/; indent,hang='50mm', '30mm' - when /9/; indent,hang='50mm', '40mm' + when /0/ then indent,hang='50mm','-50mm' + when /1/ then indent,hang='50mm','-40mm' + when /2/ then indent,hang='50mm','-30mm' + when /3/ then indent,hang='50mm','-20mm' + when /4/ then indent,hang='50mm','-10mm' + when /5/ then indent,hang='50mm', '0mm' + when /6/ then indent,hang='50mm', '10mm' + when /7/ then indent,hang='50mm', '20mm' + when /8/ then indent,hang='50mm', '30mm' + when /9/ then indent,hang='50mm', '40mm' end when /6/ case @dob.hang - when /0/; indent,hang='60mm','-60mm' - when /1/; indent,hang='60mm','-50mm' - when /2/; indent,hang='60mm','-40mm' - when /3/; indent,hang='60mm','-30mm' - when /4/; indent,hang='60mm','-20mm' - when /5/; indent,hang='60mm','-10mm' - when /6/; indent,hang='60mm', '0mm' - when /7/; indent,hang='60mm', '10mm' - when /8/; indent,hang='60mm', '20mm' - when /9/; indent,hang='60mm', '30mm' + when /0/ then indent,hang='60mm','-60mm' + when /1/ then indent,hang='60mm','-50mm' + when /2/ then indent,hang='60mm','-40mm' + when /3/ then indent,hang='60mm','-30mm' + when /4/ then indent,hang='60mm','-20mm' + when /5/ then indent,hang='60mm','-10mm' + when /6/ then indent,hang='60mm', '0mm' + when /7/ then indent,hang='60mm', '10mm' + when /8/ then indent,hang='60mm', '20mm' + when /9/ then indent,hang='60mm', '30mm' end when /7/ case @dob.hang - when /0/; indent,hang='70mm','-70mm' - when /1/; indent,hang='70mm','-60mm' - when /2/; indent,hang='70mm','-50mm' - when /3/; indent,hang='70mm','-40mm' - when /4/; indent,hang='70mm','-30mm' - when /5/; indent,hang='70mm','-20mm' - when /6/; indent,hang='70mm','-10mm' - when /7/; indent,hang='70mm', '0mm' - when /8/; indent,hang='70mm', '10mm' - when /9/; indent,hang='70mm', '20mm' + when /0/ then indent,hang='70mm','-70mm' + when /1/ then indent,hang='70mm','-60mm' + when /2/ then indent,hang='70mm','-50mm' + when /3/ then indent,hang='70mm','-40mm' + when /4/ then indent,hang='70mm','-30mm' + when /5/ then indent,hang='70mm','-20mm' + when /6/ then indent,hang='70mm','-10mm' + when /7/ then indent,hang='70mm', '0mm' + when /8/ then indent,hang='70mm', '10mm' + when /9/ then indent,hang='70mm', '20mm' end when /8/ case @dob.hang - when /0/; indent,hang='80mm','-80mm' - when /1/; indent,hang='80mm','-70mm' - when /2/; indent,hang='80mm','-60mm' - when /3/; indent,hang='80mm','-50mm' - when /4/; indent,hang='80mm','-40mm' - when /5/; indent,hang='80mm','-30mm' - when /6/; indent,hang='80mm','-20mm' - when /7/; indent,hang='80mm','-10mm' - when /8/; indent,hang='80mm', '0mm' - when /9/; indent,hang='80mm', '10mm' + when /0/ then indent,hang='80mm','-80mm' + when /1/ then indent,hang='80mm','-70mm' + when /2/ then indent,hang='80mm','-60mm' + when /3/ then indent,hang='80mm','-50mm' + when /4/ then indent,hang='80mm','-40mm' + when /5/ then indent,hang='80mm','-30mm' + when /6/ then indent,hang='80mm','-20mm' + when /7/ then indent,hang='80mm','-10mm' + when /8/ then indent,hang='80mm', '0mm' + when /9/ then indent,hang='80mm', '10mm' end when /9/ case @dob.hang - when /0/; indent,hang='90mm','-90mm' - when /1/; indent,hang='90mm','-80mm' - when /2/; indent,hang='90mm','-70mm' - when /3/; indent,hang='90mm','-60mm' - when /4/; indent,hang='90mm','-50mm' - when /5/; indent,hang='90mm','-40mm' - when /6/; indent,hang='90mm','-30mm' - when /7/; indent,hang='90mm','-20mm' - when /8/; indent,hang='90mm','-10mm' - when /9/; indent,hang='90mm', '0mm' + when /0/ then indent,hang='90mm','-90mm' + when /1/ then indent,hang='90mm','-80mm' + when /2/ then indent,hang='90mm','-70mm' + when /3/ then indent,hang='90mm','-60mm' + when /4/ then indent,hang='90mm','-50mm' + when /5/ then indent,hang='90mm','-40mm' + when /6/ then indent,hang='90mm','-30mm' + when /7/ then indent,hang='90mm','-20mm' + when /8/ then indent,hang='90mm','-10mm' + when /9/ then indent,hang='90mm', '0mm' end end "\\begin{ParagraphHang}{#{indent}}{#{hang}}#{@dob.tmp} \\end{ParagraphHang}}" end def indent indent=case @dob.indent - when /1/; '0mm' - when /2/; '10mm' - when /3/; '20mm' - when /4/; '30mm' - when /5/; '40mm' - when /6/; '50mm' - when /7/; '60mm' - when /8/; '70mm' - when /9/; '80mm' + when /1/ then '0mm' + when /2/ then '10mm' + when /3/ then '20mm' + when /4/ then '30mm' + when /5/ then '40mm' + when /6/ then '50mm' + when /7/ then '60mm' + when /8/ then '70mm' + when /9/ then '80mm' end "\\begin{ParagraphIndent}{#{indent}}#{@dob.tmp} \\end{ParagraphIndent}}" end def bullet blt=if @dob.indent indent=case @dob.indent - when /1/; '0em' - when /2/; '1.0em' - when /3/; '2.0em' - when /4/; '3.0em' - when /5/; '4.0em' - when /6/; '5.0em' - when /7/; '6.0em' - when /8/; '7.0em' - when /9/; '8.0em' + when /1/ then '0em' + when /2/ then '1.0em' + when /3/ then '2.0em' + when /4/ then '3.0em' + when /5/ then '4.0em' + when /6/ then '5.0em' + when /7/ then '6.0em' + when /8/ then '7.0em' + when /9/ then '8.0em' else '-1.0em' end "\\begin{Bullet}{#{indent}}$\\txtbullet$\\hspace{\\enspace}#{@dob.tmp}\\end{Bullet}" @@ -483,7 +484,7 @@ module SiSU_TeX_Pdf @txt.gsub!(/<:=\s*(\S+?)\s*>/, "\\includegraphics*[width=11pt]{#{dir.path.image_source_include}/c_\\1.png}") else - SiSU_Screen::Ansi.new(@md.opt.cmd,"ERROR - image:",%{"#{image}" missing},"search path: #{dir.path.image_source_include}").error2 unless @md.opt.cmd =~/q/ + SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],"ERROR - image:",%{"#{image}" missing},"search path: #{dir.path.image_source_include}").error2 unless @md.opt.act[:quiet][:set]==:on @txt.gsub!(/#{Mx[:lnk_o]}\S+\.(png|jpg|gif).+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/,'') # fragile match operator\\ fragile ! end end @@ -626,7 +627,7 @@ module SiSU_TeX_Pdf hsp="\n{\\color{mywhite} .}&~\n" # ~ character for hardspace caption=(c ? "{\\\\\ \n\\begin{scriptsize}#{hsp*3}#{c}\\end{scriptsize}&}" : '') elsif images_hash[ps] =~/#{Mx[:lnk_o]}\s*(\S+\.?\.(?:png|jpg|gif))/m - SiSU_Screen::Ansi.new(@md.opt.cmd,%{document built without image: "#{$1}" as image dimensions not provided (either image not found or neither imagemagick nor graphicsmagick is installed)?\n}).print_grey #unless @opt.cmd =~/q/ + SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],%{document built without image: "#{$1}" as image dimensions not provided (either image not found or neither imagemagick nor graphicsmagick is installed)?\n}).print_grey #unless @md.opt.act[:quiet][:set]==:on images_hash[ps].gsub!(/#{Mx[:lnk_o]}\s*(\S+\.?\.(?:png|jpg|gif))/,'[image]') end if image #most images fc etc. #% clean up ! @@ -678,7 +679,7 @@ module SiSU_TeX_Pdf end images_hash[ps] else - SiSU_Screen::Ansi.new(@md.opt.cmd,"ERROR - image:",%{"#{image}" missing},"search locations: #{dir.path.image_source_include_local},#{dir.path.image_source_include_remote} and #{dir.path.image_source_include}").error2 unless @md.opt.cmd =~/q/ + SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],"ERROR - image:",%{"#{image}" missing},"search locations: #{dir.path.image_source_include_local},#{dir.path.image_source_include_remote} and #{dir.path.image_source_include}").error2 unless @md.opt.act[:quiet][:set]==:on if images_hash[ps] =~url_image_rgx \ or images_hash[ps] =~image_rgx images_hash[ps]='' @@ -816,9 +817,9 @@ module SiSU_TeX_Pdf @md.make.texpdf_font.cjk else case @md.opt.lng - when /zh/; @env.font.texpdf.cjk_zh - when /ja/; @env.font.texpdf.cjk_ja - when /ko/; @env.font.texpdf.cjk_ko + when /zh/ then @env.font.texpdf.cjk_zh + when /ja/ then @env.font.texpdf.cjk_ja + when /ko/ then @env.font.texpdf.cjk_ko else @env.font.texpdf.cjk end end @@ -1497,7 +1498,7 @@ module SiSU_TeX_Pdf 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" + when /kdissert/i then "\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" else '' end else '' @@ -1560,7 +1561,7 @@ Generated by \\href{http://www.jus.uio.no/sisu}{SiSU www.jus.uio.no/sisu } \\\\ sisu_ico=if FileTest.file?("#{dir.path.image_source_include}/sisu.png") "\\includegraphics*[width=60pt]{#{dir.path.image_source_include}/sisu.png}" else - SiSU_Screen::Ansi.new(@md.opt.cmd,'WARNING - image directory or image(s) missing:', %{"#{dir.path.image_source_include}"} ).warn unless @md.opt.cmd =~/q/ + SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],'WARNING - image directory or image(s) missing:', %{"#{dir.path.image_source_include}"} ).warn unless @md.opt.act[:quiet][:set]==:on " SiSU " end url=@md.fnb.gsub(/(?:\\)*([$&~%_#}{^])/,'\\\\\1') diff --git a/lib/sisu/v6/txt_asciidoc.rb b/lib/sisu/v6/txt_asciidoc.rb new file mode 100644 index 00000000..e8780ced --- /dev/null +++ b/lib/sisu/v6/txt_asciidoc.rb @@ -0,0 +1,556 @@ +# 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, 2014 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/v6/plaintext_asciidoc.rb;hb=HEAD> + + * Ralph Amissah + <ralph@amissah.com> + <ralph.amissah@gmail.com> + + ** Description: plaintext (smarttext) generation, asciidoc + +=end +module SiSU_Txt_AsciiDoc + require_relative 'ao' # ao.rb + require_relative 'sysenv' # sysenv.rb + include SiSU_Env + require_relative 'shared_metadata' # shared_metadata.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 + @@tablefoot='' + class Source + def initialize(opt) + @opt=opt + unless @opt.fns =~/(.+?)\.(?:-|ssm\.)?sst$/ + puts "#{sf} not a processed file type" + end + end + def read + begin + md=SiSU_Param::Parameters.new(@opt).get + env=SiSU_Env::InfoEnv.new(@opt.fns) + unless @opt.act[:quiet][:set]==:on + tool=(@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) \ + ? "#{env.program.text_editor} #{md.file.output_path.asciidoc.dir}/#{md.file.base_filename.asciidoc}" + : "[#{@opt.f_pth[:lng_is]}] #{@opt.fno}" + (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) \ + ? SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'AsciiDoc (plaintext utf-8)',tool).green_hi_blue + : SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'AsciiDoc (plaintext utf-8)',tool).green_title_hi + if (@opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],@opt.fns,"#{md.file.output_path.asciidoc.dir}/#{md.file.base_filename.asciidoc}").flow + end + end + ao_array=SiSU_AO::Source.new(@opt).get # ao file drawn here + wrap_width=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 + else 78 + end + #wrap_width=(defined? md.make.plaintext_wrap) ? md.make.plaintext_wrap : 78 + SiSU_Txt_AsciiDoc::Source::Scroll.new(md,ao_array,wrap_width).songsheet + rescue + SiSU_Errors::Rescued.new($!,$@,@opt.cmd,@opt.fns).location do + __LINE__.to_s + ':' + __FILE__ + end + ensure + end + end + private + class Scroll <Source + require_relative 'defaults' # defaults.rb + require_relative 'txt_shared' # txt_shared.rb + include SiSU_TextUtils + @@endnotes={ para: [], end: [] } + def initialize(md,data,wrap_width) + @md,@data,@wrap_width=md,data,wrap_width + @env=SiSU_Env::InfoEnv.new(@md.fns) + @brace_url=SiSU_Viz::Defaults.new.url_decoration + @tab="\t" + @@endnotes_=case md.opt.mod.inspect + when /--footnote/ then false + when /--endnote/ then true + else true + end + @plaintext={ body: [], open: [], close: [], head: [], metadata: [], tail: [] } + end + def songsheet + plaintext=markup(@data) + publish(plaintext) + end + def break_line + "\n" + end + # Used for extraction of endnotes from paragraphs + def 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_TextUtils::Wrap.new(inf,@wrap_width,15,1) + txt=util.line_wrap + @plaintext[:metadata] <<<<WOK + +#{@tab}#{tag}#{txt} +WOK + end + end + end + def plaintext_tail +# env=SiSU_Env::InfoEnv.new(@md.fns) + vz=SiSU_Viz::Defaults.new + 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}" + sc=if @md.sc_info + "Source file: #{@md.sc_filename}#{break_line}Version number: #{@md.sc_number}#{break_line}Version date: #{@md.sc_date}#{break_line}" + else '' + end + @plaintext[:tail] <<<<WOK +#{break_line} +plaintext (plain text): + #{@md.file.output_path.asciidoc.url}/#{@md.file.base_filename.asciidoc}#{break_line} +Other versions of this document: #{break_line} +manifest: + #{@md.file.output_path.manifest.url}/#{@md.file.base_filename.manifest}#{break_line} +at: + #{@md.file.output_path.base.url}#{break_line} + +#{sc} +* #{generator} +* #{rubyv} +* #{lastdone} +* SiSU #{vz.url_sisu} +WOK + end + def decorate + def heading + def inline + def l0 + '=' + end + def l1 + '==' + end + def l2 + '===' + end + def l3 + '====' + end + def l4 + '=====' + end + def l5 + '' #'======' #logical + end + self + end + def underscore + def l0 + '=' + end + def l1 + '-' + end + def l2 + '~' + end + def l3 + '^' + end + def l4 + '+' + end + def l5 + '.' #'.' #proposed + end + self + end + self + end + def bold + def open + '*' + end + def close + '*' + end + self + end + def italics + def open + '_' + end + def close + '_' + end + self + end + def underscore + def open + '' + end + def close + '' + end + self + end + #def emphasis + # def open + # '' + # end + # def close + # '' + # end + # self + #end + def cite + def open + '"' + end + def close + '"' + end + self + end + def insert + def open + '' + end + def close + '' + end + self + end + def strike + def open + '-' + end + def close + '-' + end + self + end + def superscript + def open + '^' + end + def close + '^' + end + self + end + def subscript + def open + '~' + end + def close + '~' + end + self + end + def hilite #bold + def open + '*' + end + def close + '*' + end + self + end + def monospace + def open + '+' + end + def close + '+' + end + self + end + self + end + def heading_decorated_inline(dob) + if dob.is==:heading + heading_inline = case dob.lc + when 0 then decorate.heading.inline.l0 + when 1 then decorate.heading.inline.l1 + when 2 then decorate.heading.inline.l2 + when 3 then decorate.heading.inline.l3 + when 4 then decorate.heading.inline.l4 + when 5 then decorate.heading.inline.l5 + when 6 then decorate.heading.inline.l6 + end + heading_inline + ' ' + dob.obj + ' ' + heading_inline + end + end + def heading_decorated_underscore(dob,times,p_num) + if dob.is==:heading + #times=@wrap_width if times > @wrap_width + case dob.lc + when 0 then decorate.heading.underscore.l0*times + p_num << break_line*2 + when 1 then decorate.heading.underscore.l1*times + p_num << break_line*2 + when 2 then decorate.heading.underscore.l2*times + p_num << break_line*2 + when 3 then decorate.heading.underscore.l3*times + p_num << break_line*2 + when 4 then decorate.heading.underscore.l4*times + p_num << break_line*2 + when 5 then decorate.heading.underscore.l5*times + p_num << break_line*2 + when 6 then decorate.heading.underscore.l6*times + p_num << break_line*2 + end + end + end + def plaintext_structure(dob='',p_num='') #% Used to extract the structure of a document + heading_decoration=:inline #(:inline|:underscore) #switch heading decoration between inline & underscore options + util=nil + wrapped=if dob.is==:para \ + || dob.is==:heading + if dob.is==:heading + util=(heading_decoration== :inline) \ + ? (SiSU_TextUtils::Wrap.new(heading_decorated_inline(dob),@wrap_width,0)) + : (SiSU_TextUtils::Wrap.new(dob.obj,@wrap_width,0)) + elsif dob.is==:para + if dob.hang \ + and dob.hang =~/[0-9]/ \ + and dob.indent != dob.hang + 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_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_TextUtils::Wrap.new("* #{dob.obj}",@wrap_width,0) + else SiSU_TextUtils::Wrap.new(dob.obj,@wrap_width,0) + end + end + else util=SiSU_TextUtils::Wrap.new(dob.obj,@wrap_width,0) + end + dob.is==:heading ? util.no_wrap_no_breaks : util.line_wrap + end + if heading_decoration== :underscore \ + and dob.is==:heading + @plaintext[:body] << wrapped + p_num # main text, contents, body KEEP + @plaintext[:body] << heading_decorated_underscore(dob,wrapped.length,p_num) + else + @plaintext[:body] << wrapped + p_num << break_line # main text, contents, body KEEP + end + if @@endnotes[:para] \ + and not @@endnotes_ + @@endnotes[:para].each {|e| @plaintext[:body] << e << break_line} + elsif @@endnotes[:para] \ + and @@endnotes_ + end + @@endnotes[:para]=[] + end + def markup(data) # Used for major markup instructions + 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]='' } + plaintext_tail #($1,$2) + plaintext_metadata + table_message='[table conversion awaited, see other document formats]' + data.each do |dob| + dob.obj=dob.obj.gsub(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}.+/um,"#{break_line}#{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]}/, + "#{decorate.bold.open}\\1#{decorate.bold.close}"). + gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/, + "#{decorate.italics.open}\\1#{decorate.italics.close}"). + gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/, + "#{decorate.underscore.open}\\1#{decorate.underscore.close}"). + gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/, + "#{decorate.subscript.open}\\1#{decorate.subscript.close}"). + gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/, + "#{decorate.superscript.open}\\1#{decorate.superscript.close}"). + gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/, + "#{decorate.insert.open}\\1#{decorate.insert.close}"). + gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/, + "#{decorate.cite.open}\\1#{decorate.cite.close}"). + gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/, + "#{decorate.strike.open}\\1#{decorate.strike.close}"). + gsub(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/, + "#{decorate.monospace.open}\\1#{decorate.monospace.close}") + 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}") + dob.obj=dob.obj.gsub(/\s*#{Mx[:en_a_o]}([\d*+]+)\s+(.+?)#{Mx[:en_a_c]}/,' footnote:[note\1,\2]'). + gsub(/\s*#{Mx[:en_b_o]}([\d*+]+\s+.+?)#{Mx[:en_b_c]}/,' footnote:[\1]') + 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 + dob.obj=if dob.of==:block # watch + dob.obj.gsub(/#{Mx[:gl_o]}●#{Mx[:gl_c]}/m,"* "). + gsub(/\n?#{Mx[:br_line]}\n?|\n?#{Mx[:br_nl]}\n?/m,break_line) + else dob.obj.gsub(/\n?#{Mx[:br_line]}\n?|\n?#{Mx[:br_nl]}\n?/m,break_line*2) + end + if dob.is==:code + dob.obj=dob.obj.gsub(/(^|[^}])_([<>])/m,'\1\2'). # _> _< + gsub(/(^|[^}])_([<>])/m,'\1\2') # _<_< + end + 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"]') + if dob.obj !~/(^#{Rx[:meta]}|#{Mx[:br_eof]}|#{Mx[:br_endnotes]})/ + p_num='' + #ocn + 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 + @plaintext[:body] << dob.obj + p_num << break_line + elsif dob.is==:break + sp=' ' + ln='<' #ln='-' + @plaintext[:body] <<=if dob.obj==Mx[:br_page] \ + or dob.obj==Mx[:br_page_new] \ + or dob.obj==Mx[:br_page_line] + "#{break_line}#{ln*40}#{break_line*2}" + elsif dob.obj ==Mx[:br_obj] + "#{break_line}#{sp*20}* * *#{break_line*2}" + end # following empty line (break_line) missing, fix + end + dob='' if (dob.obj =~/<a name="n\d+">/ \ + and dob.obj =~/^(-\{{2}~\d+|<!e[:_]\d+!>)/) # -endnote + if dob ## Clean Prepared Text + dob.obj=dob.obj.gsub(/<!.+!>/,' '). + gsub(/<:\S+>/,' ') + end + end + end + @plaintext + end + def publish(plaintext) + divider='=' + content=[] + content << plaintext[:open] + content << plaintext[:head] + content << plaintext[:body] + content << @@endnotes[:end] if @@endnotes_ + content << "#{break_line}#{divider*@wrap_width}#{break_line}" + content << plaintext[:metadata] + content << "#{break_line}#{divider*@wrap_width}#{break_line}" if @md.stmp =~/\w+/ #not used? + content << plaintext[:tail] + Output.new(content,@md).asciidoc + @@endnotes={ para: [], end: [] } + end + end + class Output <Source + include SiSU_Param + include SiSU_Env + def initialize(content,md) + @content,@md=content,md + end + def asciidoc + file_plaintext=SiSU_Env::FileOp.new(@md).write_file.asciidoc + @sisu=[] + emptyline=0 + @content.each do |para| # this is a hack + if para.is_a?(Array) \ + and para.length > 0 + para.each do |line| + if line + line=line.gsub(/[ \t]+$/m,''). + gsub(/^\A[ ]*\Z/m,'') + (line=~/^\A\Z/) \ + ? (emptyline+=1) + : emptyline=0 + if emptyline < 2 #remove additional empty lines + file_plaintext.puts line + end + end + end + else file_plaintext.puts para #unix plaintext # /^([*=-]|\.){5}/ + end + end + file_plaintext.close + end + end + end +end +__END__ diff --git a/lib/sisu/v6/txt_markdown.rb b/lib/sisu/v6/txt_markdown.rb new file mode 100644 index 00000000..2cab47fd --- /dev/null +++ b/lib/sisu/v6/txt_markdown.rb @@ -0,0 +1,591 @@ +# 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, 2014 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/v6/plaintext_markdown.rb;hb=HEAD> + + * Ralph Amissah + <ralph@amissah.com> + <ralph.amissah@gmail.com> + + ** Description: plaintext (smarttext) generation, markdown + +=end +module SiSU_Txt_Markdown + require_relative 'ao' # ao.rb + require_relative 'sysenv' # sysenv.rb + include SiSU_Env + require_relative 'shared_metadata' # shared_metadata.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 + @@tablefoot='' + class Source + def initialize(opt) + @opt=opt + unless @opt.fns =~/(.+?)\.(?:-|ssm\.)?sst$/ + puts "#{sf} not a processed file type" + end + end + def read + begin + md=SiSU_Param::Parameters.new(@opt).get + env=SiSU_Env::InfoEnv.new(@opt.fns) + unless @opt.act[:quiet][:set]==:on + tool=(@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) \ + ? "#{env.program.text_editor} #{md.file.output_path.markdown.dir}/#{md.file.base_filename.markdown}" + : "[#{@opt.f_pth[:lng_is]}] #{@opt.fno}" + (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) \ + ? SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Markdown (plaintext utf-8)',tool).green_hi_blue + : SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Markdown (plaintext utf-8)',tool).green_title_hi + if (@opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],@opt.fns,"#{md.file.output_path.markdown.dir}/#{md.file.base_filename.markdown}").flow + end + end + ao_array=SiSU_AO::Source.new(@opt).get # ao file drawn here + wrap_width=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 + else 78 + end + #wrap_width=(defined? md.make.plaintext_wrap) ? md.make.plaintext_wrap : 78 + SiSU_Txt_Markdown::Source::Scroll.new(md,ao_array,wrap_width).songsheet + rescue + SiSU_Errors::Rescued.new($!,$@,@opt.cmd,@opt.fns).location do + __LINE__.to_s + ':' + __FILE__ + end + ensure + end + end + private + class Scroll <Source + require_relative 'defaults' # defaults.rb + require_relative 'txt_shared' # txt_shared.rb + include SiSU_TextUtils + @@endnotes={ para: [], end: [] } + def initialize(md,data,wrap_width) + @md,@data,@wrap_width=md,data,wrap_width + @env=SiSU_Env::InfoEnv.new(@md.fns) + @brace_url=SiSU_Viz::Defaults.new.url_decoration + @tab="\t" + @@endnotes_=case md.opt.mod.inspect + when /--footnote/ then false + when /--endnote/ then true + else true + end + @plaintext={ body: [], open: [], close: [], head: [], metadata: [], tail: [] } + end + def songsheet + plaintext=markup(@data) + publish(plaintext) + end + def break_line + "\n" + end + # Used for extraction of endnotes from paragraphs + 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]})/) + @n=[] + notes.flatten.each do |n| #high cost to deal with <br> appropriately within plaintext, consider + n=n.dup.to_s + if n =~/#{Mx[:br_line]}|#{Mx[:br_nl]}/ + fix = n.split(/#{Mx[:br_line]}|#{Mx[:br_nl]}/) #watch #added + fix.each do |x| + unless x.empty?; @n << x + end + end + else @n << n + end + end + notes=@n.flatten + notes.each do |e| + util=(e.to_s =~/^\[[\d*+]+\]:/) \ + ? (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 + 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 +\\1 + GSUB + ) + end + @@endnotes[:para] << "-#{wrap}" + @@endnotes[:end] << '' << wrap + end + @@endnotes + end + def 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_TextUtils::Wrap.new(inf,@wrap_width,15,1) + txt=util.line_wrap + @plaintext[:metadata] <<<<WOK + +#{@tab}#{tag}#{txt} +WOK + end + end + end + def plaintext_tail +# env=SiSU_Env::InfoEnv.new(@md.fns) + vz=SiSU_Viz::Defaults.new + 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}" + sc=if @md.sc_info + "Source file: #{@md.sc_filename}#{break_line}Version number: #{@md.sc_number}#{break_line}Version date: #{@md.sc_date}#{break_line}" + else '' + end + @plaintext[:tail] <<<<WOK +#{break_line} +plaintext (plain text): + #{@md.file.output_path.markdown.url}/#{@md.file.base_filename.markdown}#{break_line} +Other versions of this document: #{break_line} +manifest: + #{@md.file.output_path.manifest.url}/#{@md.file.base_filename.manifest}#{break_line} +at: + #{@md.file.output_path.base.url}#{break_line} + +#{sc} +* #{generator} +* #{rubyv} +* #{lastdone} +* SiSU #{vz.url_sisu} +WOK + end + def decorate + def heading + def inline #atx + def l0 + '#' + end + def l1 + '##' + end + def l2 + '###' + end + def l3 + '####' + end + def l4 + '#####' + end + def l5 + '######' + end + self + end + def underscore #Setext + def l1 + '=' + end + def l2 + '-' + end + def l3 + '' + end + def l4 + '' + end + def l5 + '' + end + def l6 + '' + end + self + end + self + end + def bold + def open + '**' + end + def close + '**' + end + self + end + def italics + def open + '*' + end + def close + '*' + end + self + end + def underscore + def open + '_' + end + def close + '_' + end + self + end + #def emphasis + # def open + # '' + # end + # def close + # '' + # end + # self + #end + def cite + def open + '"' + end + def close + '"' + end + self + end + def insert + def open + '+' + end + def close + '+' + end + self + end + def strike + def open + '-' + end + def close + '-' + end + self + end + def superscript + def open + '^' + end + def close + '^' + end + self + end + def subscript + def open + '[' + end + def close + ']' + end + self + end + def hilite + def open + '**' + end + def close + '**' + end + self + end + def monospace + def open + '`' + end + def close + '`' + end + self + end + self + end + def heading_decorated_inline(dob) + if dob.is==:heading + heading_inline = case dob.lc + when 0 then decorate.heading.inline.l0 + when 1 then decorate.heading.inline.l1 + when 2 then decorate.heading.inline.l2 + when 3 then decorate.heading.inline.l3 + when 4 then decorate.heading.inline.l4 + when 5 then decorate.heading.inline.l5 + when 6 then decorate.heading.inline.l6 + end + heading_inline + ' ' + dob.obj + ' ' + heading_inline + end + end + def heading_decorated_underscore(dob,times,p_num) + if dob.is==:heading + #times=@wrap_width if times > @wrap_width + case dob.lc + when 0 then decorate.heading.underscore.l0*times + p_num << break_line*2 + when 1 then decorate.heading.underscore.l1*times + p_num << break_line*2 + when 2 then decorate.heading.underscore.l2*times + p_num << break_line*2 + when 3 then decorate.heading.underscore.l3*times + p_num << break_line*2 + when 4 then decorate.heading.underscore.l4*times + p_num << break_line*2 + when 5 then decorate.heading.underscore.l5*times + p_num << break_line*2 + when 6 then decorate.heading.underscore.l6*times + p_num << break_line*2 + end + end + end + def plaintext_structure(dob='',p_num='') #% Used to extract the structure of a document + heading_decoration=:inline #(:inline|:underscore) #switch heading decoration between inline & underscore options + util=nil + wrapped=if dob.is==:para \ + || dob.is==:heading + if dob.is==:heading + util=(heading_decoration== :inline) \ + ? (SiSU_TextUtils::Wrap.new(heading_decorated_inline(dob),@wrap_width,0)) + : (SiSU_TextUtils::Wrap.new(dob.obj,@wrap_width,0)) + elsif dob.is==:para + if dob.hang \ + and dob.hang =~/[0-9]/ \ + and dob.indent != dob.hang + 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_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_TextUtils::Wrap.new("* #{dob.obj}",@wrap_width,0) + else SiSU_TextUtils::Wrap.new(dob.obj,@wrap_width,0) + end + end + else util=SiSU_TextUtils::Wrap.new(dob.obj,@wrap_width,0) + end + dob.is==:heading ? util.no_wrap_no_breaks : util.line_wrap + end + if heading_decoration== :underscore \ + and dob.is==:heading + @plaintext[:body] << wrapped + p_num # main text, contents, body KEEP + @plaintext[:body] << heading_decorated_underscore(dob,wrapped.length,p_num) + else + @plaintext[:body] << wrapped + p_num << break_line # main text, contents, body KEEP + end + if @@endnotes[:para] \ + and not @@endnotes_ + @@endnotes[:para].each {|e| @plaintext[:body] << e << break_line} + elsif @@endnotes[:para] \ + and @@endnotes_ + end + @@endnotes[:para]=[] + end + def markup(data) # Used for major markup instructions + 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]='' } + plaintext_tail #($1,$2) + plaintext_metadata + table_message='[table conversion awaited, see other document formats]' + data.each do |dob| + dob.obj=dob.obj.gsub(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}.+/um,"#{break_line}#{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]}/, + "#{decorate.bold.open}\\1#{decorate.bold.close}"). + gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/, + "#{decorate.italics.open}\\1#{decorate.italics.close}"). + gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/, + "#{decorate.underscore.open}\\1#{decorate.underscore.close}"). + gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/, + "#{decorate.subscript.open}\\1#{decorate.subscript.close}"). + gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/, + "#{decorate.superscript.open}\\1#{decorate.superscript.close}"). + gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/, + "#{decorate.insert.open}\\1#{decorate.insert.close}"). + gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/, + "#{decorate.cite.open}\\1#{decorate.cite.close}"). + gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/, + "#{decorate.strike.open}\\1#{decorate.strike.close}"). + gsub(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/, + "#{decorate.monospace.open}\\1#{decorate.monospace.close}") + 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=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 + dob.obj=if dob.of==:block # watch + dob.obj.gsub(/#{Mx[:gl_o]}●#{Mx[:gl_c]}/m,"* "). + gsub(/\n?#{Mx[:br_line]}\n?|\n?#{Mx[:br_nl]}\n?/m,break_line) + else dob.obj.gsub(/\n?#{Mx[:br_line]}\n?|\n?#{Mx[:br_nl]}\n?/m,break_line*2) + end + if dob.is==:code + dob.obj=dob.obj.gsub(/(^|[^}])_([<>])/m,'\1\2'). # _> _< + gsub(/(^|[^}])_([<>])/m,'\1\2') # _<_< + end + 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"]') + if dob.obj !~/(^#{Rx[:meta]}|#{Mx[:br_eof]}|#{Mx[:br_endnotes]})/ + p_num='' + #ocn + 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 + @plaintext[:body] << dob.obj + p_num << break_line + elsif dob.is==:break + sp=' ' + ln='-' + @plaintext[:body] <<=if dob.obj==Mx[:br_page] \ + or dob.obj==Mx[:br_page_new] \ + or dob.obj==Mx[:br_page_line] + "#{break_line}#{ln*40}#{break_line*2}" + elsif dob.obj ==Mx[:br_obj] + "#{break_line}#{sp*20}* * *#{break_line*2}" + end # following empty line (break_line) missing, fix + end + dob='' if (dob.obj =~/<a name="n\d+">/ \ + and dob.obj =~/^(-\{{2}~\d+|<!e[:_]\d+!>)/) # -endnote + if dob ## Clean Prepared Text + dob.obj=dob.obj.gsub(/<!.+!>/,' '). + gsub(/<:\S+>/,' ') + end + end + end + @plaintext + end + def publish(plaintext) + divider='=' + content=[] + content << plaintext[:open] + content << plaintext[:head] + content << plaintext[:body] + content << @@endnotes[:end] if @@endnotes_ + content << "#{break_line}#{divider*@wrap_width}#{break_line}" + content << plaintext[:metadata] + content << "#{break_line}#{divider*@wrap_width}#{break_line}" if @md.stmp =~/\w+/ #not used? + content << plaintext[:tail] + Output.new(content,@md).markdown + @@endnotes={ para: [], end: [] } + end + end + class Output <Source + include SiSU_Param + include SiSU_Env + def initialize(content,md) + @content,@md=content,md + end + def markdown + file_plaintext=SiSU_Env::FileOp.new(@md).write_file.markdown + @sisu=[] + emptyline=0 + @content.each do |para| # this is a hack + if para.is_a?(Array) \ + and para.length > 0 + para.each do |line| + if line + line=line.gsub(/[ \t]+$/m,''). + gsub(/^\A[ ]*\Z/m,'') + (line=~/^\A\Z/) \ + ? (emptyline+=1) + : emptyline=0 + if emptyline < 2 #remove additional empty lines + file_plaintext.puts line + end + end + end + else file_plaintext.puts para #unix plaintext # /^([*=-]|\.){5}/ + end + end + file_plaintext.close + end + end + end +end +__END__ diff --git a/lib/sisu/v6/txt_plain.rb b/lib/sisu/v6/txt_plain.rb new file mode 100644 index 00000000..bb97f679 --- /dev/null +++ b/lib/sisu/v6/txt_plain.rb @@ -0,0 +1,583 @@ +# 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, 2014 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/v6/plaintext.rb;hb=HEAD> + + * Ralph Amissah + <ralph@amissah.com> + <ralph.amissah@gmail.com> + + ** Description: plaintext text generation, stripped plaintext output (unix, + linefeed) + +=end +module SiSU_Txt_Plain + require_relative 'ao' # ao.rb + require_relative 'sysenv' # sysenv.rb + include SiSU_Env + require_relative 'shared_metadata' # shared_metadata.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 + @@tablefoot='' + class Source + def initialize(opt) + @opt=opt + unless @opt.fns =~/(.+?)\.(?:-|ssm\.)?sst$/ + puts "#{sf} not a processed file type" + end + end + def read + begin + md=SiSU_Param::Parameters.new(@opt).get + env=SiSU_Env::InfoEnv.new(@opt.fns) + unless @opt.act[:quiet][:set]==:on + tool=(@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) \ + ? "#{env.program.text_editor} #{md.file.output_path.txt.dir}/#{md.file.base_filename.txt}" + : "[#{@opt.f_pth[:lng_is]}] #{@opt.fno}" + (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) \ + ? SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Plaintext',tool).green_hi_blue + : SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Plaintext',tool).green_title_hi + if (@opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],@opt.fns,"#{md.file.output_path.txt.dir}/#{md.file.base_filename.txt}").flow + end + end + ao_array=SiSU_AO::Source.new(@opt).get # ao file drawn here + wrap_width=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 + else 78 + end + #wrap_width=(defined? md.make.plaintext_wrap) ? md.make.plaintext_wrap : 78 + 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__ + end + ensure + end + end + private + class Scroll <Source + require_relative 'defaults' # defaults.rb + require_relative 'txt_shared' # txt_shared.rb + include SiSU_TextUtils + @@endnotes={ para: [], end: [] } + def initialize(md,data,wrap_width) + @md,@data,@wrap_width=md,data,wrap_width + @env=SiSU_Env::InfoEnv.new(@md.fns) + @brace_url=SiSU_Viz::Defaults.new.url_decoration + @tab="\t" + @@endnotes_=case md.opt.mod.inspect + when /--footnote/ then false + when /--endnote/ then true + else true + end + @plaintext={ body: [], open: [], close: [], head: [], metadata: [], tail: [] } + end + def songsheet + plaintext=markup(@data) + publish(plaintext) + end + def break_line + "\n" + end + # Used for extraction of endnotes from paragraphs + 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]})/) + @n=[] + notes.flatten.each do |n| #high cost to deal with <br> appropriately within plaintext, consider + n=n.dup.to_s + if n =~/#{Mx[:br_line]}|#{Mx[:br_nl]}/ + fix = n.split(/#{Mx[:br_line]}|#{Mx[:br_nl]}/) #watch #added + fix.each do |x| + unless x.empty?; @n << x + end + end + else @n << n + end + end + notes=@n.flatten + notes.each do |e| + util=(e.to_s =~/^\[[\d*+]+\]:/) \ + ? (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 + 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 +\\1 + GSUB + ) + end + @@endnotes[:para] << "-#{wrap}" + @@endnotes[:end] << '' << wrap + end + @@endnotes + end + def 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_TextUtils::Wrap.new(inf,@wrap_width,15,1) + txt=util.line_wrap + @plaintext[:metadata] <<<<WOK + +#{@tab}#{tag}#{txt} +WOK + end + end + end + def plaintext_tail +# env=SiSU_Env::InfoEnv.new(@md.fns) + vz=SiSU_Viz::Defaults.new + 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}" + sc=if @md.sc_info + "Source file: #{@md.sc_filename}#{break_line}Version number: #{@md.sc_number}#{break_line}Version date: #{@md.sc_date}#{break_line}" + else '' + end + @plaintext[:tail] <<<<WOK +#{break_line} +plaintext (plain text): + #{@md.file.output_path.txt.url}/#{@md.file.base_filename.txt}#{break_line} +Other versions of this document: #{break_line} +manifest: + #{@md.file.output_path.manifest.url}/#{@md.file.base_filename.manifest}#{break_line} +at: + #{@md.file.output_path.base.url}#{break_line} + +#{sc} +* #{generator} +* #{rubyv} +* #{lastdone} +* SiSU #{vz.url_sisu} +WOK + end + def decorate + def heading_underscore + def l0 + '=' + end + def l1 + '*' + end + def l2 + '+' + end + def l3 + '~' + end + def l4 + '-' + end + def l5 + '.' + end + def l6 + '.' + end + self + end + def bold + def open + '*' + end + def close + '*' + end + self + end + def italics + def open + '/' + end + def close + '/' + end + self + end + def underscore + def open + '_' + end + def close + '_' + end + self + end + #def emphasis + # def open + # '' + # end + # def close + # '' + # end + # self + #end + def cite + def open + '"' + end + def close + '"' + end + self + end + def insert + def open + '+' + end + def close + '+' + end + self + end + def strike + def open + '-' + end + def close + '-' + end + self + end + def superscript + def open + '^' + end + def close + '^' + end + self + end + def subscript + def open + '[' + end + def close + ']' + end + self + end + def hilite + def open + '*' + end + def close + '*' + end + self + end + def monospace + def open + '#' + end + def close + '#' + end + self + end + self + end + def plaintext_structure(dob='',p_num='') #% Used to extract the structure of a document + lv=n=n3=nil + if dob.is==:heading + lv=dob.ln + n=lv - 1 + n3=lv + 2 + end + util=nil + wrapped=if dob.is==:para \ + || dob.is==:heading + if dob.is==:para + if dob.hang \ + and dob.hang =~/[0-9]/ \ + and dob.indent != dob.hang + 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_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_TextUtils::Wrap.new("* #{dob.obj}",@wrap_width,0) + else SiSU_TextUtils::Wrap.new(dob.obj,@wrap_width,0) + end + end + else util=SiSU_TextUtils::Wrap.new(dob.obj,@wrap_width,0) + end + util.line_wrap + end + if lv + times=wrapped.length + times=@wrap_width if times > @wrap_width + @plaintext[:body] << case lv + when 0 then wrapped.upcase << break_line << decorate.heading_underscore.l0*times + p_num << break_line*2 + when 1 then wrapped.upcase << break_line << decorate.heading_underscore.l1*times + p_num << break_line*2 + when 2 then wrapped.upcase << break_line << decorate.heading_underscore.l2*times + p_num << break_line*2 + when 3 then wrapped.upcase << break_line << decorate.heading_underscore.l3*times + p_num << break_line*2 + when 4 then wrapped.upcase << break_line << decorate.heading_underscore.l4*times + p_num << break_line*2 + when 5 then wrapped.upcase << break_line << decorate.heading_underscore.l5*times + p_num << break_line*2 + when 6 then wrapped.upcase << break_line << decorate.heading_underscore.l6*times + p_num << break_line*2 + end + else + @plaintext[:body] << wrapped + p_num << break_line # main text, contents, body KEEP + end + if @@endnotes[:para] \ + and not @@endnotes_ + @@endnotes[:para].each {|e| @plaintext[:body] << e << break_line} + elsif @@endnotes[:para] \ + and @@endnotes_ + end + @@endnotes[:para]=[] + end + def ocn_display(dob) + if @env.plaintext_ocn? + if defined? dob.ocn \ + and dob.ocn.is_a?(Fixnum) + (defined? dob.ocn) ? "\n#{Dx[:ocn_o]}#{dob.ocn}#{Dx[:ocn_c]}" : '' + else '' + end + else '' + end + end + def markup(data) # Used for major markup instructions + 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]='' } + plaintext_tail #($1,$2) + plaintext_metadata + table_message='[table omitted, see other document formats]' + data.each do |dob| + dob.obj=dob.obj.gsub(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}.+/um,"#{break_line}#{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]}/, + "#{decorate.bold.open}\\1#{decorate.bold.close}"). + gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/, + "#{decorate.italics.open}\\1#{decorate.italics.close}"). + gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/, + "#{decorate.underscore.open}\\1#{decorate.underscore.close}"). + gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/, + "#{decorate.subscript.open}\\1#{decorate.subscript.close}"). + gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/, + "#{decorate.superscript.open}\\1#{decorate.superscript.close}"). + gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/, + "#{decorate.insert.open}\\1#{decorate.insert.close}"). + gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/, + "#{decorate.cite.open}\\1#{decorate.cite.close}"). + gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/, + "#{decorate.strike.open}\\1#{decorate.strike.close}"). + gsub(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/, + "#{decorate.monospace.open}\\1#{decorate.monospace.close}") + 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=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 + dob.obj=if dob.of==:block # watch + dob.obj.gsub(/#{Mx[:gl_o]}●#{Mx[:gl_c]}/m,"* "). + gsub(/\n?#{Mx[:br_line]}\n?|\n?#{Mx[:br_nl]}\n?/m,break_line) + else dob.obj.gsub(/\n?#{Mx[:br_line]}\n?|\n?#{Mx[:br_nl]}\n?/m,break_line*2) + end + if dob.is==:code + dob.obj=dob.obj.gsub(/(^|[^}])_([<>])/m,'\1\2'). # _> _< + gsub(/(^|[^}])_([<>])/m,'\1\2') # _<_< + end + 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"]') + if dob.obj !~/(^#{Rx[:meta]}|#{Mx[:br_eof]}|#{Mx[:br_endnotes]})/ + p_num=ocn_display(dob) + 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 + @plaintext[:body] << dob.obj + p_num << break_line + elsif dob.is==:break + sp=' ' + ln='-' + @plaintext[:body] <<=if dob.obj==Mx[:br_page] \ + or dob.obj==Mx[:br_page_new] \ + or dob.obj==Mx[:br_page_line] + "#{break_line}#{ln*40}#{break_line*2}" + elsif dob.obj ==Mx[:br_obj] + "#{break_line}#{sp*20}* * *#{break_line*2}" + end # following empty line (break_line) missing, fix + end + dob='' if (dob.obj =~/<a name="n\d+">/ \ + and dob.obj =~/^(-\{{2}~\d+|<!e[:_]\d+!>)/) # -endnote + if dob ## Clean Prepared Text + dob.obj=dob.obj.gsub(/<!.+!>/,' '). + gsub(/<:\S+>/,' ') + end + end + end + @plaintext + end + def publish(plaintext) + divider='=' + content=[] + content << plaintext[:open] + content << plaintext[:head] + content << plaintext[:body] + content << @@endnotes[:end] if @@endnotes_ + content << "#{break_line}#{divider*@wrap_width}#{break_line}" + content << plaintext[:metadata] + content << "#{break_line}#{divider*@wrap_width}#{break_line}" if @md.stmp =~/\w+/ #not used? + content << plaintext[:tail] + Output.new(content,@md).plaintext + @@endnotes={ para: [], end: [] } + end + end + class Output <Source + include SiSU_Param + include SiSU_Env + def initialize(content,md) + @content,@md=content,md + end + def plaintext #%plaintext output + file_plaintext=SiSU_Env::FileOp.new(@md).write_file.txt + @sisu=[] + emptyline=0 + @content.each do |para| # this is a hack + if para.is_a?(Array) \ + and para.length > 0 + para.each do |line| + if line + line=line.gsub(/[ \t]+$/m,''). + gsub(/^\A[ ]*\Z/m,'') + (line=~/^\A\Z/) \ + ? (emptyline+=1) + : emptyline=0 + if emptyline < 2 #remove additional empty lines + file_plaintext.puts line + end + end + end + else file_plaintext.puts para #unix plaintext # /^([*=-]|\.){5}/ + end + end + file_plaintext.close + end + end + end +end +__END__ + bold_o: '*', bold_c: '*', + #bold_o: '!', bold_c: '!', + #emphasis_o: '*', emphasis_c: '*', + italics_o: '/', italics_c: '/', + underscore_o: '_', underscore_c: '_', + cite_o: '"', cite_c: '"', + insert_o: '+', insert_c: '+', + strike_o: '-', strike_c: '-', + superscript_o: '^', superscript_c: '^', + subscript_o: '[', subscript_c: ']', + hilite_o: '*', hilite_c: '*', + monospace_o: '', monospace_c: '', + po_bold_o: '!{', po_bold_c: '}!', + po_italics_o: '/{', po_italics_c: '}/', + po_underscore_o: '_{', po_underscore_c: '}_', + po_cite_o: '"{', po_cite_c: '}"', + po_insert_o: '+{', po_insert_c: '}+', + po_strike_o: '-{', po_strike_c: '}-', + po_superscript_o: '^{', po_superscript_c: '}^', + po_subscript_o: ',{', po_subscript_c: '},', + po_hilite_o: '*{', po_hilite_c: '}*', + po_monospace_o: '#{', po_monospace_c: '}#', diff --git a/lib/sisu/v6/txt_rst.rb b/lib/sisu/v6/txt_rst.rb new file mode 100644 index 00000000..6bfcd139 --- /dev/null +++ b/lib/sisu/v6/txt_rst.rb @@ -0,0 +1,552 @@ +# 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, 2014 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/v6/plaintext_rst.rb;hb=HEAD> + + * Ralph Amissah + <ralph@amissah.com> + <ralph.amissah@gmail.com> + + ** Description: plaintext (smarttext) generation, rST + +=end +module SiSU_Txt_rST + require_relative 'ao' # ao.rb + require_relative 'sysenv' # sysenv.rb + include SiSU_Env + require_relative 'shared_metadata' # shared_metadata.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 + @@tablefoot='' + class Source + def initialize(opt) + @opt=opt + unless @opt.fns =~/(.+?)\.(?:-|ssm\.)?sst$/ + puts "#{sf} not a processed file type" + end + end + def read + begin + md=SiSU_Param::Parameters.new(@opt).get + env=SiSU_Env::InfoEnv.new(@opt.fns) + unless @opt.act[:quiet][:set]==:on + tool=(@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) \ + ? "#{env.program.text_editor} #{md.file.output_path.rst.dir}/#{md.file.base_filename.rst}" + : "[#{@opt.f_pth[:lng_is]}] #{@opt.fno}" + (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) \ + ? SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'rST (plaintext utf-8)',tool).green_hi_blue + : SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'rST (plaintext utf-8)',tool).green_title_hi + if (@opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],@opt.fns,"#{md.file.output_path.rst.dir}/#{md.file.base_filename.rst}").flow + end + end + ao_array=SiSU_AO::Source.new(@opt).get # ao file drawn here + wrap_width=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 + else 78 + end + #wrap_width=(defined? md.make.plaintext_wrap) ? md.make.plaintext_wrap : 78 + SiSU_Txt_rST::Source::Scroll.new(md,ao_array,wrap_width).songsheet + rescue + SiSU_Errors::Rescued.new($!,$@,@opt.cmd,@opt.fns).location do + __LINE__.to_s + ':' + __FILE__ + end + ensure + end + end + private + class Scroll <Source + require_relative 'defaults' # defaults.rb + require_relative 'txt_shared' # txt_shared.rb + include SiSU_TextUtils + @@endnotes={ para: [], end: [] } + def initialize(md,data,wrap_width) + @md,@data,@wrap_width=md,data,wrap_width + @env=SiSU_Env::InfoEnv.new(@md.fns) + @brace_url=SiSU_Viz::Defaults.new.url_decoration + @tab="\t" + @@endnotes_=case md.opt.mod.inspect + when /--footnote/ then false + when /--endnote/ then true + else true + end + @plaintext={ body: [], open: [], close: [], head: [], metadata: [], tail: [] } + end + def songsheet + plaintext=markup(@data) + publish(plaintext) + end + def break_line + "\n" + end + # Used for extraction of endnotes from paragraphs + 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]})/) + @n=[] + notes.flatten.each do |n| #high cost to deal with <br> appropriately within plaintext, consider + n=n.dup.to_s + if n =~/#{Mx[:br_line]}|#{Mx[:br_nl]}/ + fix = n.split(/#{Mx[:br_line]}|#{Mx[:br_nl]}/) #watch #added + fix.each do |x| + unless x.empty?; @n << x + end + end + else @n << n + end + end + notes=@n.flatten + notes.each do |e| + util=(e.to_s =~/^\[[\d*+]+\]:/) \ + ? (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 + 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 +\\1 + GSUB + ) + end + @@endnotes[:para] << "-#{wrap}" + @@endnotes[:end] << '' << wrap + end + @@endnotes + end + def 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_TextUtils::Wrap.new(inf,@wrap_width,15,1) + txt=util.line_wrap + @plaintext[:metadata] <<<<WOK + +#{@tab}#{tag}#{txt} +WOK + end + end + end + def plaintext_tail +# env=SiSU_Env::InfoEnv.new(@md.fns) + vz=SiSU_Viz::Defaults.new + 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}" + sc=if @md.sc_info + "Source file: #{@md.sc_filename}#{break_line}Version number: #{@md.sc_number}#{break_line}Version date: #{@md.sc_date}#{break_line}" + else '' + end + @plaintext[:tail] <<<<WOK +#{break_line} +plaintext (plain text): + #{@md.file.output_path.rst.url}/#{@md.file.base_filename.rst}#{break_line} +Other versions of this document: #{break_line} +manifest: + #{@md.file.output_path.manifest.url}/#{@md.file.base_filename.manifest}#{break_line} +at: + #{@md.file.output_path.base.url}#{break_line} + +#{sc} +* #{generator} +* #{rubyv} +* #{lastdone} +* SiSU #{vz.url_sisu} +WOK + end + def decorate + def heading + def underscore + def l0 + '=' + end + def l1 + '-' + end + def l2 + '`' + end + def l3 + ':' + end + def l4 + "'" + end + def l5 + '"' + end + self + end + self + end + def bold + def open + '*' + end + def close + '*' + end + self + end + def italics + def open + '/' + end + def close + '/' + end + self + end + def underscore + def open + '_' + end + def close + '_' + end + self + end + #def emphasis + # def open + # '' + # end + # def close + # '' + # end + # self + #end + def cite + def open + '"' + end + def close + '"' + end + self + end + def insert + def open + '+' + end + def close + '+' + end + self + end + def strike + def open + '-' + end + def close + '-' + end + self + end + def superscript + def open + '^' + end + def close + '^' + end + self + end + def subscript + def open + '[' + end + def close + ']' + end + self + end + def hilite + def open + '*' + end + def close + '*' + end + self + end + def monospace + def open + '#' + end + def close + '#' + end + self + end + self + end + def heading_decorated_underscore(dob,times,p_num) + if dob.is==:heading + #times=@wrap_width if times > @wrap_width + case dob.lc + when 0 then decorate.heading.underscore.l0*times + p_num << break_line*2 + when 1 then decorate.heading.underscore.l1*times + p_num << break_line*2 + when 2 then decorate.heading.underscore.l2*times + p_num << break_line*2 + when 3 then decorate.heading.underscore.l3*times + p_num << break_line*2 + when 4 then decorate.heading.underscore.l4*times + p_num << break_line*2 + when 5 then decorate.heading.underscore.l5*times + p_num << break_line*2 + when 6 then decorate.heading.underscore.l6*times + p_num << break_line*2 + end + end + end + def plaintext_structure(dob='',p_num='') #% Used to extract the structure of a document + util=nil + wrapped=if dob.is==:para \ + || dob.is==:heading + if dob.is==:heading + util=SiSU_TextUtils::Wrap.new(dob.obj,@wrap_width,0) + elsif dob.is==:para + if dob.hang \ + and dob.hang =~/[0-9]/ \ + and dob.indent != dob.hang + 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_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_TextUtils::Wrap.new("* #{dob.obj}",@wrap_width,0) + else SiSU_TextUtils::Wrap.new(dob.obj,@wrap_width,0) + end + end + else util=SiSU_TextUtils::Wrap.new(dob.obj,@wrap_width,0) + end + dob.is==:heading ? util.no_wrap_no_breaks : util.line_wrap + end + if dob.is==:heading + @plaintext[:body] << wrapped + p_num # main text, contents, body KEEP + @plaintext[:body] << heading_decorated_underscore(dob,wrapped.length,p_num) + else + @plaintext[:body] << wrapped + p_num << break_line # main text, contents, body KEEP + end + if @@endnotes[:para] \ + and not @@endnotes_ + @@endnotes[:para].each {|e| @plaintext[:body] << e << break_line} + elsif @@endnotes[:para] \ + and @@endnotes_ + end + @@endnotes[:para]=[] + end + def markup(data) # Used for major markup instructions + 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]='' } + plaintext_tail #($1,$2) + plaintext_metadata + table_message='[table conversion awaited, see other document formats]' + data.each do |dob| + dob.obj=dob.obj.gsub(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}.+/um,"#{break_line}#{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]}/, + "#{decorate.bold.open}\\1#{decorate.bold.close}"). + gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/, + "#{decorate.italics.open}\\1#{decorate.italics.close}"). + gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/, + "#{decorate.underscore.open}\\1#{decorate.underscore.close}"). + gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/, + "#{decorate.subscript.open}\\1#{decorate.subscript.close}"). + gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/, + "#{decorate.superscript.open}\\1#{decorate.superscript.close}"). + gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/, + "#{decorate.insert.open}\\1#{decorate.insert.close}"). + gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/, + "#{decorate.cite.open}\\1#{decorate.cite.close}"). + gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/, + "#{decorate.strike.open}\\1#{decorate.strike.close}"). + gsub(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/, + "#{decorate.monospace.open}\\1#{decorate.monospace.close}") + 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=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 + dob.obj=if dob.of==:block # watch + dob.obj.gsub(/#{Mx[:gl_o]}●#{Mx[:gl_c]}/m,"* "). + gsub(/\n?#{Mx[:br_line]}\n?|\n?#{Mx[:br_nl]}\n?/m,break_line) + else dob.obj.gsub(/\n?#{Mx[:br_line]}\n?|\n?#{Mx[:br_nl]}\n?/m,break_line*2) + end + if dob.is==:code + dob.obj=dob.obj.gsub(/(^|[^}])_([<>])/m,'\1\2'). # _> _< + gsub(/(^|[^}])_([<>])/m,'\1\2') # _<_< + end + 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"]') + if dob.obj !~/(^#{Rx[:meta]}|#{Mx[:br_eof]}|#{Mx[:br_endnotes]})/ + p_num='' + #ocn + 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 + @plaintext[:body] << dob.obj + p_num << break_line + elsif dob.is==:break + sp=' ' + ln='-' + @plaintext[:body] <<=if dob.obj==Mx[:br_page] \ + or dob.obj==Mx[:br_page_new] \ + or dob.obj==Mx[:br_page_line] + "#{break_line}#{ln*40}#{break_line*2}" + elsif dob.obj ==Mx[:br_obj] + "#{break_line}#{sp*20}* * *#{break_line*2}" + end # following empty line (break_line) missing, fix + end + dob='' if (dob.obj =~/<a name="n\d+">/ \ + and dob.obj =~/^(-\{{2}~\d+|<!e[:_]\d+!>)/) # -endnote + if dob ## Clean Prepared Text + dob.obj=dob.obj.gsub(/<!.+!>/,' '). + gsub(/<:\S+>/,' ') + end + end + end + @plaintext + end + def publish(plaintext) + divider='=' + content=[] + content << plaintext[:open] + content << plaintext[:head] + content << plaintext[:body] + content << @@endnotes[:end] if @@endnotes_ + content << "#{break_line}#{divider*@wrap_width}#{break_line}" + content << plaintext[:metadata] + content << "#{break_line}#{divider*@wrap_width}#{break_line}" if @md.stmp =~/\w+/ #not used? + content << plaintext[:tail] + Output.new(content,@md).rst + @@endnotes={ para: [], end: [] } + end + end + class Output <Source + include SiSU_Param + include SiSU_Env + def initialize(content,md) + @content,@md=content,md + end + def rst + file_plaintext=SiSU_Env::FileOp.new(@md).write_file.rst + @sisu=[] + emptyline=0 + @content.each do |para| # this is a hack + if para.is_a?(Array) \ + and para.length > 0 + para.each do |line| + if line + line=line.gsub(/[ \t]+$/m,''). + gsub(/^\A[ ]*\Z/m,'') + (line=~/^\A\Z/) \ + ? (emptyline+=1) + : emptyline=0 + if emptyline < 2 #remove additional empty lines + file_plaintext.puts line + end + end + end + else file_plaintext.puts para #unix plaintext # /^([*=-]|\.){5}/ + end + end + file_plaintext.close + end + end + end +end +__END__ diff --git a/lib/sisu/v4/shared_txt.rb b/lib/sisu/v6/txt_shared.rb index 11c7a4ee..8d2a09b7 100644 --- a/lib/sisu/v4/shared_txt.rb +++ b/lib/sisu/v6/txt_shared.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/shared_txt.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/txt_shared.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -64,12 +65,14 @@ module SiSU_TextUtils 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 @n_char_max_extend = n_char_max - @br="\n" @n_hang=n_hang ? n_hang : @n_indent end + def break_line + "\n" + end def line_wrap space=' ' - spaces_indent,spaces_hang="#{@br}#{space*@n_indent}",space*@n_hang + spaces_indent,spaces_hang="#{break_line}#{space*@n_indent}",space*@n_hang line=0 out=[] out[line]='' @@ -126,6 +129,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) @@ -168,52 +177,52 @@ module SiSU_TextUtils end def start_is_match case @p - when /^#{Mx[:meta_o]}(title)#{Mx[:meta_c]}\s*(.+?)$/; header($1,@md.title.full,'meta','dc') #dc 1 - when /^#{Mx[:meta_o]}(creator|author)#{Mx[:meta_c]}\s*(.+?)$/; header('creator',$2,'meta','dc') #dc 2 - when /^#{Mx[:meta_o]}(subject)#{Mx[:meta_c]}\s*(.+?)$/; header($1,$2,'meta','dc') #dc 3 - when /^#{Mx[:meta_o]}(description)#{Mx[:meta_c]}\s*(.+?)$/; header($1,$2,'meta','dc') #dc 4 - when /^#{Mx[:meta_o]}(publisher)#{Mx[:meta_c]}\s*(.+?)$/; header($1,$2,'meta','dc') #dc 5 - when /^#{Mx[:meta_o]}(contributor)#{Mx[:meta_c]}\s*(.+?)$/; header($1,$2,'meta','dc') #dc 6 - when /^#{Mx[:meta_o]}(date)#{Mx[:meta_c]}\s*(.+?)$/; header($1,$2,'meta','dc') #dc 7 - when /^#{Mx[:meta_o]}(date\.created)#{Mx[:meta_c]}\s*(.+?)$/; header($1,$2,'meta','extra') - when /^#{Mx[:meta_o]}(date\.issued)#{Mx[:meta_c]}\s*(.+?)$/; header($1,$2,'meta','extra') - when /^#{Mx[:meta_o]}(date\.available)#{Mx[:meta_c]}\s*(.+?)$/; header($1,$2,'meta','extra') - when /^#{Mx[:meta_o]}(date\.valid)#{Mx[:meta_c]}\s*(.+?)$/; header($1,$2,'meta','extra') - when /^#{Mx[:meta_o]}(date\.modified)#{Mx[:meta_c]}\s*(.+?)$/; header($1,$2,'meta','extra') - when /^#{Mx[:meta_o]}(type)#{Mx[:meta_c]}\s*(.+?)$/; header($1,$2,'meta','dc') #dc 8 - when /^#{Mx[:meta_o]}(format)#{Mx[:meta_c]}\s*(.+?)$/; header($1,$2,'meta','dc') #dc 9 - when /^#{Mx[:meta_o]}(identifier)#{Mx[:meta_c]}\s*(.+?)$/; header($1,$2,'meta','dc') #dc 10 - when /^#{Mx[:meta_o]}(source)#{Mx[:meta_c]}\s*(.+?)$/; header($1,$2,'meta','dc') #dc 11 - when /^#{Mx[:meta_o]}(language)#{Mx[:meta_c]}\s*(.+?)$/; header($1,$2,'meta','dc') #dc 12 - when /^#{Mx[:meta_o]}(relation)#{Mx[:meta_c]}\s*(.+?)$/; header($1,$2,'meta','dc') #dc 13 - when /^#{Mx[:meta_o]}(coverage)#{Mx[:meta_c]}\s*(.+?)$/; header($1,$2,'meta','dc') #dc 14 - when /^#{Mx[:meta_o]}(rights)#{Mx[:meta_c]}\s*(.+?)$/; header($1,$2,'meta','dc') #dc 15 - when /^#{Mx[:meta_o]}(keywords)#{Mx[:meta_c]}\s*(.+?)$/; header($1,$2,'meta','extra') - when /^#{Mx[:meta_o]}(copyright)#{Mx[:meta_c]}\s*(.+?)$/; header($1,$2,'meta','extra') - when /^#{Mx[:meta_o]}(translator|translated_by)#{Mx[:meta_c]}\s*(.+?)$/; header('translator',$2) - when /^#{Mx[:meta_o]}(illustrator|illustrated_by)#{Mx[:meta_c]}\s*(.+?)$/; header('illustrator',$2) - when /^#{Mx[:meta_o]}(prepared_by)#{Mx[:meta_c]}\s*(.+?)$/; header($1,$2,'meta','extra') - when /^#{Mx[:meta_o]}(digitized_by)#{Mx[:meta_c]}\s*(.+?)$/; header($1,$2,'meta','extra') - when /^#{Mx[:meta_o]}(comments?)#{Mx[:meta_c]}\s*(.+?)$/; header($1,$2,'meta','extra') - when /^#{Mx[:meta_o]}(abstract)#{Mx[:meta_c]}\s*(.+?)$/; header($1,$2,'meta','extra') - when /^#{Mx[:meta_o]}(tags?)#{Mx[:meta_c]}\s*(.+?)$/; header($1,$2,'meta','extra') - when /^#{Mx[:meta_o]}(catalogue)#{Mx[:meta_c]}\s*(.+?)$/; header($1,$2,'meta','extra') - when /^#{Mx[:meta_o]}(class(?:ify)?_loc)#{Mx[:meta_c]}\s*(.+?)$/; header('classify_loc',$2,'meta','extra') - when /^#{Mx[:meta_o]}(class(?:ify)?_dewey)#{Mx[:meta_c]}\s*(.+?)$/; header('classify_dewey',$2,'meta','extra') - when /^#{Mx[:meta_o]}(class(?:ify)?_pg)#{Mx[:meta_c]}\s*(.+?)$/; header('classify_pg',$2,'meta','extra') - when /^#{Mx[:meta_o]}(class(?:ify)?_isbn)#{Mx[:meta_c]}\s*(.+?)$/; header('classify_isbn',$2,'meta','extra') - when /^#{Mx[:meta_o]}(toc|structure)#{Mx[:meta_c]}\s*(.+?)$/; header('structure',$2,'process','instruct') - when /^#{Mx[:meta_o]}(level|page|markup)#{Mx[:meta_c]}\s*(.+?)$/; header('markup',$2,'process','instruct') - when /^#{Mx[:meta_o]}(bold)#{Mx[:meta_c]}\s*(.+?)$/; header($1,$2,'process','instruct') - when /^#{Mx[:meta_o]}(italics|itali[sz]e)#{Mx[:meta_c]}\s*(.+?)$/; header('italicize',$2,'process','instruct') - when /^#{Mx[:meta_o]}(vocabulary|wordlist)#{Mx[:meta_c]}\s*(.+?)$/; header('vocabulary',$2,'process','instruct') - when /^#{Mx[:meta_o]}(css|stylesheet)#{Mx[:meta_c]}\s*(.+?)$/; header('css',$2,'process','instruct') - when /^#{Mx[:meta_o]}(links)#{Mx[:meta_c]}\s*(.+?)$/; header($1,$2,'process','instruct') - when /^#{Mx[:meta_o]}(prefix)#{Mx[:meta_c]}\s*(.+?)$/; header($1,$2,'process','instruct') #add a & b - when /^#{Mx[:meta_o]}(suffix)#{Mx[:meta_c]}\s*(.+?)$/; header($1,$2,'process','instruct') - when /^#{Mx[:meta_o]}(information)#{Mx[:meta_c]}\s*(.+?)$/; header($1,$2,'process','instruct') - when /^#{Mx[:meta_o]}(contact)#{Mx[:meta_c]}\s*(.+?)$/; header($1,$2,'process','instruct') - when /^#{Mx[:meta_o]}(rcs|cvs)#{Mx[:meta_c]}\s*(.+?)$/; header('version',$2,'process','instruct') + when /^#{Mx[:meta_o]}(title)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,@md.title.full,'meta','dc') #dc 1 + when /^#{Mx[:meta_o]}(creator|author)#{Mx[:meta_c]}\s*(.+?)$/ then header('creator',$2,'meta','dc') #dc 2 + when /^#{Mx[:meta_o]}(subject)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','dc') #dc 3 + when /^#{Mx[:meta_o]}(description)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','dc') #dc 4 + when /^#{Mx[:meta_o]}(publisher)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','dc') #dc 5 + when /^#{Mx[:meta_o]}(contributor)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','dc') #dc 6 + when /^#{Mx[:meta_o]}(date)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','dc') #dc 7 + when /^#{Mx[:meta_o]}(date\.created)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','extra') + when /^#{Mx[:meta_o]}(date\.issued)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','extra') + when /^#{Mx[:meta_o]}(date\.available)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','extra') + when /^#{Mx[:meta_o]}(date\.valid)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','extra') + when /^#{Mx[:meta_o]}(date\.modified)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','extra') + when /^#{Mx[:meta_o]}(type)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','dc') #dc 8 + when /^#{Mx[:meta_o]}(format)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','dc') #dc 9 + when /^#{Mx[:meta_o]}(identifier)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','dc') #dc 10 + when /^#{Mx[:meta_o]}(source)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','dc') #dc 11 + when /^#{Mx[:meta_o]}(language)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','dc') #dc 12 + when /^#{Mx[:meta_o]}(relation)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','dc') #dc 13 + when /^#{Mx[:meta_o]}(coverage)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','dc') #dc 14 + when /^#{Mx[:meta_o]}(rights)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','dc') #dc 15 + when /^#{Mx[:meta_o]}(keywords)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','extra') + when /^#{Mx[:meta_o]}(copyright)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','extra') + when /^#{Mx[:meta_o]}(translator|translated_by)#{Mx[:meta_c]}\s*(.+?)$/ then header('translator',$2) + when /^#{Mx[:meta_o]}(illustrator|illustrated_by)#{Mx[:meta_c]}\s*(.+?)$/ then header('illustrator',$2) + when /^#{Mx[:meta_o]}(prepared_by)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','extra') + when /^#{Mx[:meta_o]}(digitized_by)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','extra') + when /^#{Mx[:meta_o]}(comments?)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','extra') + when /^#{Mx[:meta_o]}(abstract)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','extra') + when /^#{Mx[:meta_o]}(tags?)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','extra') + when /^#{Mx[:meta_o]}(catalogue)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','extra') + when /^#{Mx[:meta_o]}(class(?:ify)?_loc)#{Mx[:meta_c]}\s*(.+?)$/ then header('classify_loc',$2,'meta','extra') + when /^#{Mx[:meta_o]}(class(?:ify)?_dewey)#{Mx[:meta_c]}\s*(.+?)$/ then header('classify_dewey',$2,'meta','extra') + when /^#{Mx[:meta_o]}(class(?:ify)?_pg)#{Mx[:meta_c]}\s*(.+?)$/ then header('classify_pg',$2,'meta','extra') + when /^#{Mx[:meta_o]}(class(?:ify)?_isbn)#{Mx[:meta_c]}\s*(.+?)$/ then header('classify_isbn',$2,'meta','extra') + when /^#{Mx[:meta_o]}(toc|structure)#{Mx[:meta_c]}\s*(.+?)$/ then header('structure',$2,'process','instruct') + when /^#{Mx[:meta_o]}(level|page|markup)#{Mx[:meta_c]}\s*(.+?)$/ then header('markup',$2,'process','instruct') + when /^#{Mx[:meta_o]}(bold)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'process','instruct') + when /^#{Mx[:meta_o]}(italics|itali[sz]e)#{Mx[:meta_c]}\s*(.+?)$/ then header('italicize',$2,'process','instruct') + when /^#{Mx[:meta_o]}(vocabulary|wordlist)#{Mx[:meta_c]}\s*(.+?)$/ then header('vocabulary',$2,'process','instruct') + when /^#{Mx[:meta_o]}(css|stylesheet)#{Mx[:meta_c]}\s*(.+?)$/ then header('css',$2,'process','instruct') + when /^#{Mx[:meta_o]}(links)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'process','instruct') + when /^#{Mx[:meta_o]}(prefix)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'process','instruct') #add a & b + when /^#{Mx[:meta_o]}(suffix)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'process','instruct') + when /^#{Mx[:meta_o]}(information)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'process','instruct') + when /^#{Mx[:meta_o]}(contact)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'process','instruct') + when /^#{Mx[:meta_o]}(rcs|cvs)#{Mx[:meta_c]}\s*(.+?)$/ then header('version',$2,'process','instruct') else nil end end diff --git a/lib/sisu/v4/plaintext.rb b/lib/sisu/v6/txt_textile.rb index 13e93e9a..4e137b3a 100644 --- a/lib/sisu/v4/plaintext.rb +++ b/lib/sisu/v6/txt_textile.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,24 +51,21 @@ * 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/v4/plaintext.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/plaintext_textile.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> <ralph.amissah@gmail.com> - ** Description: plaintext text generation, stripped plaintext output (unix, - linefeed) + ** Description: plaintext (smarttext) generation, textile =end -module SiSU_Plaintext - require_relative 'dal' # dal.rb +module SiSU_Txt_Textile + require_relative 'ao' # ao.rb require_relative 'sysenv' # sysenv.rb include SiSU_Env - require_relative 'plaintext_format' # plaintext_format.rb - include SiSU_PlaintextFormat 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 @@ -83,16 +81,23 @@ module SiSU_Plaintext begin md=SiSU_Param::Parameters.new(@opt).get env=SiSU_Env::InfoEnv.new(@opt.fns) - unless @opt.cmd =~/q/ - tool=(@opt.cmd =~/[MVv]/) \ - ? "#{env.program.text_editor} #{md.file.output_path.txt.dir}/#{md.file.base_filename.txt}" + unless @opt.act[:quiet][:set]==:on + tool=(@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) \ + ? "#{env.program.text_editor} #{md.file.output_path.textile.dir}/#{md.file.base_filename.textile}" : "[#{@opt.f_pth[:lng_is]}] #{@opt.fno}" - @opt.cmd=~/[MVvz]/ \ - ? SiSU_Screen::Ansi.new(@opt.cmd,'Plaintext',tool).green_hi_blue - : SiSU_Screen::Ansi.new(@opt.cmd,'Plaintext',tool).green_title_hi - SiSU_Screen::Ansi.new(@opt.cmd,@opt.fns,"#{md.file.output_path.txt.dir}/#{md.file.base_filename.txt}").flow if @opt.cmd =~/[MV]/ + (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) \ + ? SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Textile (plaintext utf-8)',tool).green_hi_blue + : SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Textile (plaintext utf-8)',tool).green_title_hi + if (@opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],@opt.fns,"#{md.file.output_path.textile.dir}/#{md.file.base_filename.textile}").flow + end end - dal_array=SiSU_DAL::Source.new(@opt).get # dal file drawn here + ao_array=SiSU_AO::Source.new(@opt).get # ao file drawn here wrap_width=if defined? md.make.plaintext_wrap \ and md.make.plaintext_wrap md.make.plaintext_wrap @@ -102,7 +107,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,dal_array,wrap_width).songsheet + SiSU_Txt_Textile::Source::Scroll.new(md,ao_array,wrap_width).songsheet rescue SiSU_Errors::Rescued.new($!,$@,@opt.cmd,@opt.fns).location do __LINE__.to_s + ':' + __FILE__ @@ -113,7 +118,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) @@ -122,17 +127,19 @@ module SiSU_Plaintext @brace_url=SiSU_Viz::Defaults.new.url_decoration @tab="\t" @@endnotes_=case md.opt.mod.inspect - when /--footnote/; false - when /--endnote/; true - else true + when /--footnote/ then false + when /--endnote/ then true + else true end - @br="\n" @plaintext={ body: [], open: [], close: [], head: [], metadata: [], tail: [] } end def songsheet plaintext=markup(@data) publish(plaintext) end + def break_line + "\n" + end # Used for extraction of endnotes from paragraphs 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]})/) @@ -155,15 +162,15 @@ module SiSU_Plaintext : (SiSU_TextUtils::Wrap.new(e.to_s,@wrap_width,1,1)) wrap=util.line_wrap wrap=if wrap =~ /^\s*[\d*+]+\s+.+?\s*\Z/m - wrap.gsub(/^(\s*)([\d*+]+)\s+(.+?)\s*\Z/m, <<GSUB + wrap.gsub(/^(\s*)([\d*+]+)\s+(.+?)\s*\Z/m, <<-GSUB \\1[\\2]: \\3 -GSUB - ) + GSUB + ) else - wrap.gsub(/^(.+)\Z/m, <<GSUB + wrap.gsub(/^(.+)\Z/m, <<-GSUB \\1 -GSUB - ) + GSUB + ) end @@endnotes[:para] << "-#{wrap}" @@endnotes[:end] << '' << wrap @@ -191,18 +198,18 @@ WOK lastdone="Last Generated on: #{Time.now}" rubyv="Ruby version: #{@md.ruby_version}" sc=if @md.sc_info - "Source file: #{@md.sc_filename}#{@br}Version number: #{@md.sc_number}#{@br}Version date: #{@md.sc_date}#{@br}" + "Source file: #{@md.sc_filename}#{break_line}Version number: #{@md.sc_number}#{break_line}Version date: #{@md.sc_date}#{break_line}" else '' end @plaintext[:tail] <<<<WOK -#{@br} +#{break_line} plaintext (plain text): - #{@md.file.output_path.txt.url}/#{@md.file.base_filename.txt}#{@br} -Other versions of this document: #{@br} + #{@md.file.output_path.textile.url}/#{@md.file.base_filename.textile}#{break_line} +Other versions of this document: #{break_line} manifest: - #{@md.file.output_path.manifest.url}/#{@md.file.base_filename.manifest}#{@br} + #{@md.file.output_path.manifest.url}/#{@md.file.base_filename.manifest}#{break_line} at: - #{@md.file.output_path.base.url}#{@br} + #{@md.file.output_path.base.url}#{break_line} #{sc} * #{generator} @@ -211,17 +218,151 @@ at: * SiSU #{vz.url_sisu} WOK end - def plaintext_structure(dob='',p_num='') #% Used to extract the structure of a document - lv=n=n3=nil - if dob.is==:heading - lv=dob.ln - n=lv - 1 - n3=lv + 2 + def decorate + def heading + def inline + def l0 + 'h1. ' + end + def l1 + 'h2. ' + end + def l2 + 'h3. ' + end + def l3 + 'h4. ' + end + def l4 + 'h5. ' + end + def l5 + 'h6. ' + end + self + end + self + end + def bold + def open + '*' + end + def close + '*' + end + self + end + def italics + def open + '_' + end + def close + '_' + end + self + end + def underscore + def open + '+' + end + def close + '+' + end + self + end + #def emphasis + # def open + # '' + # end + # def close + # '' + # end + # self + #end + def cite + def open + '"' + end + def close + '"' + end + self + end + def insert + def open + '' + end + def close + '' + end + self + end + def strike + def open + '-' + end + def close + '-' + end + self + end + def superscript + def open + '^' + end + def close + '^' + end + self + end + def subscript + def open + '~' + end + def close + '~' + end + self + end + def hilite + def open + '*' + end + def close + '*' + end + self + end + def monospace + def open + '' + end + def close + '' + end + self + end + self + end + def heading_decorated_inline(dob) + heading_inline = case dob.lc + when 0 then decorate.heading.inline.l0 + when 1 then decorate.heading.inline.l1 + when 2 then decorate.heading.inline.l2 + when 3 then decorate.heading.inline.l3 + when 4 then decorate.heading.inline.l4 + when 5 then decorate.heading.inline.l5 + when 6 then decorate.heading.inline.l6 end + heading_inline + ' ' + dob.obj + end + def plaintext_structure(dob='',p_num='') #% Used to extract the structure of a document util=nil wrapped=if dob.is==:para \ || dob.is==:heading - if dob.is==:para + if dob.is==:heading + util=SiSU_TextUtils::Wrap.new(heading_decorated_inline(dob),@wrap_width,0,0) + elsif dob.is==:para if dob.hang \ and dob.hang =~/[0-9]/ \ and dob.indent != dob.hang @@ -240,25 +381,12 @@ WOK end else util=SiSU_TextUtils::Wrap.new(dob.obj,@wrap_width,0) end - util.line_wrap - end - if lv - times=wrapped.length - times=@wrap_width if times > @wrap_width - @plaintext[:body] << case lv - when 1; wrapped.upcase << @br << Px[:lv1]*times + p_num << @br*2 - when 2; wrapped.upcase << @br << Px[:lv2]*times + p_num << @br*2 - when 3; wrapped.upcase << @br << Px[:lv3]*times + p_num << @br*2 - when 4; wrapped.upcase << @br << Px[:lv4]*times + p_num << @br*2 - when 5; wrapped.upcase << @br << Px[:lv5]*times + p_num << @br*2 - when 6; wrapped.upcase << @br << Px[:lv6]*times + p_num << @br*2 - end - else - @plaintext[:body] << wrapped + p_num << @br # main text, contents, body KEEP + dob.is==:heading ? util.no_wrap_no_breaks : util.line_wrap end + @plaintext[:body] << wrapped + p_num << break_line # main text, contents, body KEEP if @@endnotes[:para] \ and not @@endnotes_ - @@endnotes[:para].each {|e| @plaintext[:body] << e << @br} + @@endnotes[:para].each {|e| @plaintext[:body] << e << break_line} elsif @@endnotes[:para] \ and @@endnotes_ end @@ -271,28 +399,28 @@ WOK (4..6).each { |x| @plaintext_contents_close[x]='' } plaintext_tail #($1,$2) plaintext_metadata - table_message='[table omitted, see other document formats]' + table_message='[table conversion awaited, see other document formats]' data.each do |dob| - dob.obj=dob.obj.gsub(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}.+/um,"#{@br}#{table_message}"). #fix + dob.obj=dob.obj.gsub(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}.+/um,"#{break_line}#{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]}"). + "#{decorate.bold.open}\\1#{decorate.bold.close}"). gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/, - "#{Px[:italics_o]}\\1#{Px[:italics_c]}"). + "#{decorate.italics.open}\\1#{decorate.italics.close}"). gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/, - "#{Px[:underscore_o]}\\1#{Px[:underscore_c]}"). + "#{decorate.underscore.open}\\1#{decorate.underscore.close}"). gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/, - "#{Px[:subscript_o]}\\1#{Px[:subscript_c]}"). + "#{decorate.subscript.open}\\1#{decorate.subscript.close}"). gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/, - "#{Px[:superscript_o]}\\1#{Px[:superscript_c]}"). + "#{decorate.superscript.open}\\1#{decorate.superscript.close}"). gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/, - "#{Px[:insert_o]}\\1#{Px[:insert_c]}"). + "#{decorate.insert.open}\\1#{decorate.insert.close}"). gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/, - "#{Px[:cite_o]}\\1#{Px[:cite_c]}"). + "#{decorate.cite.open}\\1#{decorate.cite.close}"). gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/, - "#{Px[:strike_o]}\\1#{Px[:strike_c]}"). + "#{decorate.strike.open}\\1#{decorate.strike.close}"). gsub(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/, - "#{Px[:monospace_o]}\\1#{Px[:monospace_c]}") + "#{decorate.monospace.open}\\1#{decorate.monospace.close}") 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'). @@ -319,8 +447,8 @@ WOK end dob.obj=if dob.of==:block # watch dob.obj.gsub(/#{Mx[:gl_o]}●#{Mx[:gl_c]}/m,"* "). - gsub(/\n?#{Mx[:br_line]}\n?|\n?#{Mx[:br_nl]}\n?/m,@br) - else dob.obj.gsub(/\n?#{Mx[:br_line]}\n?|\n?#{Mx[:br_nl]}\n?/m,@br*2) + gsub(/\n?#{Mx[:br_line]}\n?|\n?#{Mx[:br_nl]}\n?/m,break_line) + else dob.obj.gsub(/\n?#{Mx[:br_line]}\n?|\n?#{Mx[:br_nl]}\n?/m,break_line*2) end if dob.is==:code dob.obj=dob.obj.gsub(/(^|[^}])_([<>])/m,'\1\2'). # _> _< @@ -334,17 +462,8 @@ WOK gsub(/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}image/,' [ \1 ]'). gsub(/(?:^|[^_\\])\{\s*\S+?\.(?:png|jpg|gif)\s+.+?"(.*?)"\s*\}\S+/,'[image: "\1"]') 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_PlaintextFormat::ParagraphNumber.new(paranum) - #end p_num='' - if @env.plaintext_ocn? - if defined? dob.ocn \ - and dob.ocn.is_a?(Fixnum) - p_num=SiSU_PlaintextFormat::ParagraphNumber.new(dob.ocn).display - end - end + #ocn if dob.is==:heading \ or dob.is==:para plaintext_structure(dob,p_num) @@ -353,17 +472,17 @@ WOK or dob.is==:verse \ or dob.is==:code \ or dob.is==:table - @plaintext[:body] << dob.obj + p_num << @br + @plaintext[:body] << dob.obj + p_num << break_line elsif dob.is==:break sp=' ' ln='-' @plaintext[:body] <<=if dob.obj==Mx[:br_page] \ or dob.obj==Mx[:br_page_new] \ or dob.obj==Mx[:br_page_line] - "#{@br}#{ln*40}#{@br*2}" + "#{break_line}#{ln*40}#{break_line*2}" elsif dob.obj ==Mx[:br_obj] - "#{@br}#{sp*20}* * *#{@br*2}" - end # following empty line (@br) missing, fix + "#{break_line}#{sp*20}* * *#{break_line*2}" + end # following empty line (break_line) missing, fix end dob='' if (dob.obj =~/<a name="n\d+">/ \ and dob.obj =~/^(-\{{2}~\d+|<!e[:_]\d+!>)/) # -endnote @@ -382,11 +501,11 @@ WOK content << plaintext[:head] content << plaintext[:body] content << @@endnotes[:end] if @@endnotes_ - content << "#{@br}#{divider*@wrap_width}#{@br}" + content << "#{break_line}#{divider*@wrap_width}#{break_line}" content << plaintext[:metadata] - content << "#{@br}#{divider*@wrap_width}#{@br}" if @md.stmp =~/\w+/ #not used? + content << "#{break_line}#{divider*@wrap_width}#{break_line}" if @md.stmp =~/\w+/ #not used? content << plaintext[:tail] - Output.new(content,@md).plaintext + Output.new(content,@md).textile @@endnotes={ para: [], end: [] } end end @@ -396,8 +515,8 @@ WOK def initialize(content,md) @content,@md=content,md end - def plaintext #%plaintext output - file_plaintext=SiSU_Env::FileOp.new(@md).write_file.txt + def textile + file_plaintext=SiSU_Env::FileOp.new(@md).write_file.textile @sisu=[] emptyline=0 @content.each do |para| # this is a hack @@ -424,4 +543,3 @@ WOK end end __END__ -!\|#\|&*\|-\|/\|_\|{\|}\|~\|&# diff --git a/lib/sisu/v4/update.rb b/lib/sisu/v6/update.rb index 1d7e1cff..7366e471 100644 --- a/lib/sisu/v4/update.rb +++ b/lib/sisu/v6/update.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/update.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/update.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -73,7 +74,7 @@ module SiSU_UpdateControlFlag @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/ + SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],'Checking previous output',base_path).green_hi_blue unless @md.opt.act[:quiet][:set]==:on SetCF.new(@md).set_flags rescue SiSU_Errors::Rescued.new($!,$@,@md.opt.cmd,@md.fns).location do diff --git a/lib/sisu/v4/urls.rb b/lib/sisu/v6/urls.rb index 2af3a5b6..5327a9bb 100644 --- a/lib/sisu/v4/urls.rb +++ b/lib/sisu/v6/urls.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/urls.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/urls.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -105,7 +106,7 @@ module SiSU_Urls 'h --html (HTML scroll)'=>@fn[:doc], 'I --texinfo (Info file)'=>'info', 'i --manpage (manpage)'=>'manpage', - 'm --dal (Document Abstraction)'=>'dal', + 'm --ao (Document Abstraction)'=>'ao', 'N --hash-digests (Digests md5/sha256)'=>@fn[:digest], 'o --odt (ODF:ODT - Open Document)'=>@fn[:odf], 'p --pdf (PDF landscape)'=>@fn[:pdf_l], @@ -114,8 +115,16 @@ module SiSU_Urls 's --source (sisu markup)'=>@opt.fno, 'S --sisupod (sisupod)'=>@fn[:sisupod], 't --txt (Plain-text (endnotes))'=>@fn[:plain], + ' --textile (textile txt)'=>@fn[:txt_textile], + ' --asciidoc (AsciiDoc txt)'=>@fn[:txt_asciidoc], + ' --markdown (markdown txt)'=>@fn[:txt_markdown], + ' --rst (rST restructured-text)'=>@fn[:txt_rst], + ' --docbook-book (DocBook Book)'=>@fn[:xml_docbook_book], + ' --fictionbook (Fictionbook)'=>@fn[:xml_fictionbook], 'x --xml-sax (XML sax type)'=>@fn[:sax], 'X --xml-dom (XML dom type)'=>@fn[:dom], + ' --xml-scaffold-sisu (XML scaffold)'=>@fn[:xml_scaffold_structure_sisu], + ' --xml-scaffold-collapse (XML scaffold)'=>@fn[:xml_scaffold_structure_collapse], 'Q --qrcode (QR Code jpg)'=>@fn[:qrcode], 'y --manifest (Manifest, html)'=>@fn[:manifest], 'Y (Sitemap, xml)'=>@fn[:sitemap], @@ -124,7 +133,7 @@ module SiSU_Urls end def songsheet begin - @opt.cmd=~/U/ ? urls_all : (urls_select unless @opt.cmd=~/q/) + @opt.cmd=~/U/ ? urls_all : (urls_select unless @opt.act[:quiet][:set]==:on) rescue SiSU_Errors::Rescued.new($!,$@,@opt.cmd,@opt.fns).location do __LINE__.to_s + ':' + __FILE__ @@ -135,97 +144,121 @@ module SiSU_Urls def show def source def src(x,y) - SiSU_Screen::Ansi.new(@opt.cmd,"[#{@opt.f_pth[:lng_is]}] -#{x}","#{@prog.text_editor} #{@md.file.output_path.src.dir}/#{y}").result + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"[#{@opt.f_pth[:lng_is]}] -#{x}","#{@prog.text_editor} #{@md.file.output_path.src.dir}/#{y}").result end def pod(x,y) - SiSU_Screen::Ansi.new(@opt.cmd,"[#{@opt.f_pth[:lng_is]}] -#{x}","#{@prog.web_browser} file://#{@md.file.output_path.sisupod.dir}/#{y}").result + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"[#{@opt.f_pth[:lng_is]}] -#{x}","#{@prog.web_browser} file://#{@md.file.output_path.sisupod.dir}/#{y}").result end self end def generic(x,y) - SiSU_Screen::Ansi.new(@opt.cmd,"[#{@opt.f_pth[:lng_is]}] -#{x}","#{@prog.web_browser} #{@env.url.output_tell}/#{@fnb}/#{y}").result + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"[#{@opt.f_pth[:lng_is]}] -#{x}","#{@prog.web_browser} #{@env.url.output_tell}/#{@fnb}/#{y}").result end def meta(x,y) - SiSU_Screen::Ansi.new(@opt.cmd,"[#{@opt.f_pth[:lng_is]}] -#{x}","#{@prog.text_editor} ~#{y}/#{@fnb}.#{y}").result + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"[#{@opt.f_pth[:lng_is]}] -#{x}","#{@prog.text_editor} ~#{y}/#{@fnb}.#{y}").result end def text(x) - SiSU_Screen::Ansi.new(@opt.cmd,"[#{@opt.f_pth[:lng_is]}] -#{x}","#{@prog.web_browser} file://#{@md.file.output_path.txt.dir}/#{@md.file.base_filename.txt}").result + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"[#{@opt.f_pth[:lng_is]}] -#{x}","#{@prog.web_browser} file://#{@md.file.output_path.txt.dir}/#{@md.file.base_filename.txt}").result + end + def textile(x) + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"[#{@opt.f_pth[:lng_is]}] -#{x}","#{@prog.web_browser} file://#{@md.file.output_path.textile.dir}/#{@md.file.base_filename.textile}").result + end + def asciidoc(x) + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"[#{@opt.f_pth[:lng_is]}] -#{x}","#{@prog.web_browser} file://#{@md.file.output_path.asciidoc.dir}/#{@md.file.base_filename.asciidoc}").result + end + def markdown(x) + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"[#{@opt.f_pth[:lng_is]}] -#{x}","#{@prog.web_browser} file://#{@md.file.output_path.markdown.dir}/#{@md.file.base_filename.markdown}").result + end + def rst(x) + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"[#{@opt.f_pth[:lng_is]}] -#{x}","#{@prog.web_browser} file://#{@md.file.output_path.rst.dir}/#{@md.file.base_filename.rst}").result end def epub(x) - SiSU_Screen::Ansi.new(@opt.cmd,"[#{@opt.f_pth[:lng_is]}] -#{x}","#{@prog.epub_viewer} #{@md.file.output_path.epub.dir}/#{@md.file.base_filename.epub}").result + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"[#{@opt.f_pth[:lng_is]}] -#{x}","#{@prog.epub_viewer} #{@md.file.output_path.epub.dir}/#{@md.file.base_filename.epub}").result end def html def scroll(x) - SiSU_Screen::Ansi.new(@opt.cmd,"[#{@opt.f_pth[:lng_is]}] -#{x}","#{@prog.web_browser} file://#{@md.file.output_path.html_scroll.dir}/#{@md.file.base_filename.html_scroll}").result + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"[#{@opt.f_pth[:lng_is]}] -#{x}","#{@prog.web_browser} file://#{@md.file.output_path.html_scroll.dir}/#{@md.file.base_filename.html_scroll}").result end def toc(x) - SiSU_Screen::Ansi.new(@opt.cmd,"[#{@opt.f_pth[:lng_is]}] -#{x}","#{@prog.web_browser} file://#{@md.file.output_path.html_seg.dir}/#{@md.file.base_filename.html_segtoc}").result + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"[#{@opt.f_pth[:lng_is]}] -#{x}","#{@prog.web_browser} file://#{@md.file.output_path.html_seg.dir}/#{@md.file.base_filename.html_segtoc}").result end def concordance(x) - SiSU_Screen::Ansi.new(@opt.cmd,"[#{@opt.f_pth[:lng_is]}] -#{x}","#{@prog.web_browser} file://#{@md.file.output_path.html_concordance.dir}/#{@md.file.base_filename.html_concordance}").result + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"[#{@opt.f_pth[:lng_is]}] -#{x}","#{@prog.web_browser} file://#{@md.file.output_path.html_concordance.dir}/#{@md.file.base_filename.html_concordance}").result end def manifest(x) - SiSU_Screen::Ansi.new(@opt.cmd,"[#{@opt.f_pth[:lng_is]}] -#{x}","#{@prog.web_browser} file://#{@md.file.output_path.manifest.dir}/#{@md.file.base_filename.manifest}").result + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"[#{@opt.f_pth[:lng_is]}] -#{x}","#{@prog.web_browser} file://#{@md.file.output_path.manifest.dir}/#{@md.file.base_filename.manifest}").result end self end def qrcode(x) - SiSU_Screen::Ansi.new(@opt.cmd,"[#{@opt.f_pth[:lng_is]}] -#{x}","#{@prog.web_browser} file://#{@md.file.output_path.manifest.dir}/#{@md.file.base_filename.manifest}").result + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"[#{@opt.f_pth[:lng_is]}] -#{x}","#{@prog.web_browser} file://#{@md.file.output_path.manifest.dir}/#{@md.file.base_filename.manifest}").result end def odt(x) - SiSU_Screen::Ansi.new(@opt.cmd,"[#{@opt.f_pth[:lng_is]}] -#{x}","#{@prog.odf_viewer} file://#{@md.file.output_path.odt.dir}/#{@md.file.base_filename.odt}").result + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"[#{@opt.f_pth[:lng_is]}] -#{x}","#{@prog.odf_viewer} file://#{@md.file.output_path.odt.dir}/#{@md.file.base_filename.odt}").result end def pdf def portrait(x) - SiSU_Screen::Ansi.new(@opt.cmd,"[#{@opt.f_pth[:lng_is]}] -#{x}","#{@prog.pdf_viewer} #{@md.file.output_path.pdf.dir}/#{@md.file.base_filename.pdf_p}#{@md.papersize_array[0]}.pdf").result + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"[#{@opt.f_pth[:lng_is]}] -#{x}","#{@prog.pdf_viewer} #{@md.file.output_path.pdf.dir}/#{@md.file.base_filename.pdf_p}#{@md.papersize_array[0]}.pdf").result end def landscape(x) - SiSU_Screen::Ansi.new(@opt.cmd,"[#{@opt.f_pth[:lng_is]}] -#{x}","#{@prog.pdf_viewer} #{@md.file.output_path.pdf.dir}/#{@md.file.base_filename.pdf_l}#{@md.papersize_array[0]}.pdf").result + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"[#{@opt.f_pth[:lng_is]}] -#{x}","#{@prog.pdf_viewer} #{@md.file.output_path.pdf.dir}/#{@md.file.base_filename.pdf_l}#{@md.papersize_array[0]}.pdf").result end self end def manpage(x) - SiSU_Screen::Ansi.new(@opt.cmd,"[#{@opt.f_pth[:lng_is]}] -#{x}","#{@prog.manpage_viewer} #{@md.file.output_path.manpage.dir}/#{@md.file.base_filename.manpage}").result + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"[#{@opt.f_pth[:lng_is]}] -#{x}","#{@prog.manpage_viewer} #{@md.file.output_path.manpage.dir}/#{@md.file.base_filename.manpage}").result end def pinfo(x,y) - SiSU_Screen::Ansi.new(@opt.cmd,"[#{@opt.f_pth[:lng_is]}] -#{x}","pinfo -f #{@md.file.output_path.texinfo.dir}/#{@md.file.base_filename.info}").result + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"[#{@opt.f_pth[:lng_is]}] -#{x}","cd #{@md.file.output_path.texinfo.dir} && #{@env.program.texinfo} #{@md.file.base_filename.info}; cd -").result end def po4a def po(x,y) - SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","#{@prog.text_editor} #{@md.file.output_path.po.dir}/#{y}").result + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"-#{x}","#{@prog.text_editor} #{@md.file.output_path.po.dir}/#{y}").result end def pot(x,y) - SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","#{@prog.text_editor} #{@md.file.output_path.pot.dir}/#{y}").result + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"-#{x}","#{@prog.text_editor} #{@md.file.output_path.pot.dir}/#{y}").result end self end def xhtml(x) - SiSU_Screen::Ansi.new(@opt.cmd,"[#{@opt.f_pth[:lng_is]}] -#{x}","#{@prog.web_browser} file://#{@md.file.output_path.xhtml.dir}/#{@md.file.base_filename.xhtml}").result + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"[#{@opt.f_pth[:lng_is]}] -#{x}","#{@prog.web_browser} file://#{@md.file.output_path.xhtml.dir}/#{@md.file.base_filename.xhtml}").result end def xml def sax(x) - SiSU_Screen::Ansi.new(@opt.cmd,"[#{@opt.f_pth[:lng_is]}] -#{x}","#{@prog.web_browser} file://#{@md.file.output_path.xml_sax.dir}/#{@md.file.base_filename.xml_sax}").result + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"[#{@opt.f_pth[:lng_is]}] -#{x}","#{@prog.web_browser} file://#{@md.file.output_path.xml_sax.dir}/#{@md.file.base_filename.xml_sax}").result end def dom(x) - SiSU_Screen::Ansi.new(@opt.cmd,"[#{@opt.f_pth[:lng_is]}] -#{x}","#{@prog.web_browser} file://#{@md.file.output_path.xml_dom.dir}/#{@md.file.base_filename.xml_dom}").result + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"[#{@opt.f_pth[:lng_is]}] -#{x}","#{@prog.web_browser} file://#{@md.file.output_path.xml_dom.dir}/#{@md.file.base_filename.xml_dom}").result + end + def docbook_book(x) + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"[#{@opt.f_pth[:lng_is]}] -#{x}","#{@prog.web_browser} file://#{@md.file.output_path.xml_docbook_book.dir}/#{@md.file.base_filename.xml_docbook_book}").result + end + def fictionbook(x) + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"[#{@opt.f_pth[:lng_is]}] -#{x}","#{@prog.web_browser} file://#{@md.file.output_path.xml_fictionbook.dir}/#{@md.file.base_filename.xml_fictionbook}").result + end + def scaffold_structure_sisu(x) + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"[#{@opt.f_pth[:lng_is]}] -#{x}","#{@prog.web_browser} file://#{@md.file.output_path.xml_scaffold_structure_sisu.dir}/#{@md.file.base_filename.xml_scaffold_structure_sisu}").result + end + def scaffold_structure_collapse(x) + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"[#{@opt.f_pth[:lng_is]}] -#{x}","#{@prog.web_browser} file://#{@md.file.output_path.xml_scaffold_structure_collapse.dir}/#{@md.file.base_filename.xml_scaffold_structure_collapse}").result end def sitemap(x) #BROKEN - SiSU_Screen::Ansi.new(@opt.cmd,"[#{@opt.f_pth[:lng_is]}] -#{x}","#{@prog.web_browser} file://#{@md.file.output_path.sitemaps.dir}/#{@md.file.base_filename.sitemap}").result + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"[#{@opt.f_pth[:lng_is]}] -#{x}","#{@prog.web_browser} file://#{@md.file.output_path.sitemaps.dir}/#{@md.file.base_filename.sitemap}").result end self end def hash_digest(x) - SiSU_Screen::Ansi.new(@opt.cmd,"[#{@opt.f_pth[:lng_is]}] -#{x}","#{@prog.web_browser} file://#{@md.file.output_path.hash_digest.dir}/#{@md.file.base_filename.hash_digest}").result + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"[#{@opt.f_pth[:lng_is]}] -#{x}","#{@prog.web_browser} file://#{@md.file.output_path.hash_digest.dir}/#{@md.file.base_filename.hash_digest}").result end def db def psql(x,y) - SiSU_Screen::Ansi.new(@opt.cmd,"[#{@opt.f_pth[:lng_is]}] -#{x} DBI psql","#{@pwd_stub}::#{@opt.fns}",y).result + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"[#{@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").result + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"[#{@opt.f_pth[:lng_is]}] -#{x} DBI sqlite","sqlite3 #{@env.path.webserv}/#{@md.opt.f_pth[:pth_stub]}/sisu_sqlite.db").result end def sqlite_discrete(x,y) - SiSU_Screen::Ansi.new(@opt.cmd,"[#{@opt.f_pth[:lng_is]}] -#{x}","sqlite3 #{@md.file.output_path.sqlite_discrete.dir}/#{@md.file.base_filename.sqlite_discrete}").result + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"[#{@opt.f_pth[:lng_is]}] -#{x}","sqlite3 #{@md.file.output_path.sqlite_discrete.dir}/#{@md.file.base_filename.sqlite_discrete}").result end self end @@ -235,18 +268,19 @@ module SiSU_Urls if x=~/^([abcehHmNoptwxXy])/ \ and opt.cmd =~/[abcehHmNoptwxXy]/ \ and x=~/^[#{opt.cmd}]/ \ - and opt.cmd =~/[MV]/ + and (@opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) tool=@prog.text_editor if x =~/^m/ \ and @opt.cmd=~/m/ \ and x=~/^[#{opt.cmd}]/ - SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","#{@prog.text_editor} #{@env.processing_path.dal}/#{@opt.fns}.meta").maintenance + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"-#{x}","#{@prog.text_editor} #{@env.processing_path.ao}/#{@opt.fns}.meta").maintenance end if x=~/^([hw])/ \ and @opt.cmd=~/[hw]/ \ and x=~/^[#{@opt.cmd}]/ \ and x !~/segmented/ - SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","#{@prog.text_editor} #{@env.processing_path.tune}/#{@md.fns}.tune").maintenance + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"-#{x}","#{@prog.text_editor} #{@env.processing_path.tune}/#{@md.fns}.tune").maintenance end if x=~/^p/ \ and @opt.cmd=~/p/ \ @@ -255,8 +289,8 @@ module SiSU_Urls fns=@opt.fns.gsub(/~/,'-') unless @opt.cmd =~/q/ tell=if x =~/landscape/ - SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","#{@prog.text_editor} #{@env.processing_path.tex}/#{fns}.landscape.tex") - else SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","#{@prog.text_editor} #{@env.processing_path.tex}/#{fns}.tex") + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"-#{x}","#{@prog.text_editor} #{@env.processing_path.tex}/#{fns}.landscape.tex") + else SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"-#{x}","#{@prog.text_editor} #{@env.processing_path.tex}/#{fns}.tex") end tell.maintenance end @@ -269,12 +303,12 @@ module SiSU_Urls if x=~/^e/ \ and @opt.cmd=~/e/ \ and x=~/^[#{@opt.cmd}]/ - SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","#{@prog.text_editor} #{@env.processing_path.epub}/#{Ep[:d_oebps]}/toc.xhtml").maintenance + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"-#{x}","#{@prog.text_editor} #{@env.processing_path.epub}/#{Ep[:d_oebps]}/toc.xhtml").maintenance end if x=~/^o/ \ and @opt.cmd=~/o/ \ and x=~/^[#{@opt.cmd}]/ - SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","#{@prog.text_editor} #{@env.processing_path.odf}/#{@opt.fns}/odt/content.xml").maintenance + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"-#{x}","#{@prog.text_editor} #{@env.processing_path.odf}/#{@opt.fns}/odt/content.xml").maintenance end end end @@ -282,21 +316,41 @@ module SiSU_Urls unless @opt.cmd =~/q/ i1="[#{@opt.f_pth[:lng_is]}]" i2="file://#{@md.file.output_path.manifest.dir}/#{@md.file.base_filename.manifest}" - @opt.cmd=~/[MVvz]/ \ - ? SiSU_Screen::Ansi.new(@opt.cmd,'URLs').green_title_hi - : SiSU_Screen::Ansi.new(@opt.cmd,'URL (output manifest)',i1, i2).grey_title_grey_blue - SiSU_Screen::Ansi.new(@opt.cmd,@opt.fns,"#{@md.file.output_path.manifest.dir}/#{@md.file.base_filename.manifest}").flow if @opt.cmd =~/[MVv]/ + (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) \ + ? SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'URLs').green_title_hi + : SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'URL (output manifest)',i1, i2).grey_title_grey_blue + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],@opt.fns,"#{@md.file.output_path.manifest.dir}/#{@md.file.base_filename.manifest}").flow if @opt.cmd =~/[MVv]/ end m=/.+\/(?:src\/)?(\S+)/im # m=/.+?\/(?:src\/)?([^\/]+)$/im # m=/.+\/(\S+)/m @pwd_stub="#{@env.url.output_tell}"[m,1] - unless @opt.cmd =~/q/ + unless @opt.act[:quiet][:set]==:on @u.each do |x,y| if @opt.fns =~ @m_regular - if @opt.cmd =~/[MVv]/ + if (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) if x=~/--txt\b/ \ and @opt.act[:txt][:set]==:on show.text(x) end + if x=~/--textile\b/ \ + and @opt.act[:txt_textile][:set]==:on + show.textile(x) + end + if x=~/--asciidoc\b/ \ + and @opt.act[:txt_asciidoc][:set]==:on + show.asciidoc(x) + end + if x=~/--markdown\b/ \ + and @opt.act[:txt_markdown][:set]==:on + show.markdown(x) + end + if x=~/--rst\b/ \ + and @opt.act[:txt_rst][:set]==:on + show.rst(x) + end if x=~/--xhtml\b/ \ and @opt.act[:xhtml][:set]==:on show.xhtml(x) @@ -393,6 +447,22 @@ module SiSU_Urls and @opt.act[:xml_sax][:set]==:on show.xml.sax(x) end + if x=~/--docbook-book\b/ \ + and @opt.act[:xml_docbook_book][:set]==:on + show.xml.docbook_book(x) + end + if x=~/--fictionbook\b/ \ + and @opt.act[:xml_fictionbook][:set]==:on + show.xml.fictionbook(x) + end + if x=~/--xml-scaffold-sisu\b/ \ + and @opt.act[:xml_scaffold_structure_sisu][:set]==:on + show.xml.scaffold_structure_sisu(x) + end + if x=~/--xml-scaffold-collapse\b/ \ + and @opt.act[:xml_scaffold_structure_collapse][:set]==:on + show.xml.scaffold_structure_collapse(x) + end if x=~/--qrcode\b/ \ and @opt.act[:qrcode][:set]==:on show.qrcode(x) @@ -406,14 +476,17 @@ module SiSU_Urls show.html.manifest(x) end end - urls_maintenance(@opt,x,y) if @opt.cmd =~/[MV]/ + if (@opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) + urls_maintenance(@opt,x,y) + end end end end end def urls_all i="(output manifest) [#{@opt.f_pth[:lng_is]}] #{@env.url.output_tell}/#{@fnb}/sisu_manifest.html" - SiSU_Screen::Ansi.new(@opt.cmd,'URLs',i).grey_title_hi + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'URLs',i).grey_title_hi @u.each do |x,y| case x when /^m/ diff --git a/lib/sisu/v4/utils.rb b/lib/sisu/v6/utils.rb index d18e2180..b0efb3bc 100644 --- a/lib/sisu/v4/utils.rb +++ b/lib/sisu/v6/utils.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/utils.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/utils.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -68,25 +69,25 @@ module SiSU_Utils @color=color ? color : @color c={} c[:on]=case @color - when :red; ANSI_C[:red] - when :green; ANSI_C[:green] - when :yellow; ANSI_C[:yellow] - when :blue; ANSI_C[:blue] - when :fuchsia; ANSI_C[:fuchsia] - when :cyan; ANSI_C[:cyan] - when :inv_red; ANSI_C[:inv_red] - when :inv_green; ANSI_C[:inv_green] - when :inv_yellow; ANSI_C[:inv_yellow] - when :inv_blue; ANSI_C[:inv_blue] - when :inv_fuchsia; ANSI_C[:inv_fuchsia] - when :inv_cyan; ANSI_C[:inv_cyan] - when :b_red; ANSI_C[:b_red] - when :b_green; ANSI_C[:b_green] - when :b_yellow; ANSI_C[:b_yellow] - when :b_blue; ANSI_C[:b_blue] - when :b_fuchsia; ANSI_C[:b_fuchsia] - when :b_cyan; ANSI_C[:b_cyan] - else ANSI_C[:red] + when :red then ANSI_C[:red] + when :green then ANSI_C[:green] + when :yellow then ANSI_C[:yellow] + when :blue then ANSI_C[:blue] + when :fuchsia then ANSI_C[:fuchsia] + when :cyan then ANSI_C[:cyan] + when :inv_red then ANSI_C[:inv_red] + when :inv_green then ANSI_C[:inv_green] + when :inv_yellow then ANSI_C[:inv_yellow] + when :inv_blue then ANSI_C[:inv_blue] + when :inv_fuchsia then ANSI_C[:inv_fuchsia] + when :inv_cyan then ANSI_C[:inv_cyan] + when :b_red then ANSI_C[:b_red] + when :b_green then ANSI_C[:b_green] + when :b_yellow then ANSI_C[:b_yellow] + when :b_blue then ANSI_C[:b_blue] + when :b_fuchsia then ANSI_C[:b_fuchsia] + when :b_cyan then ANSI_C[:b_cyan] + else ANSI_C[:red] end c[:off]= ANSI_C[:off] #ansi_color + @line.to_s + ansi_color_off + ' ' + @file.gsub(/([^\/]+$)/,"#{ansi_color}\\1#{ansi_color_off}") diff --git a/lib/sisu/v4/webrick.rb b/lib/sisu/v6/webrick.rb index 15e86d87..7a66a1af 100644 --- a/lib/sisu/v4/webrick.rb +++ b/lib/sisu/v6/webrick.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/webrick.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/webrick.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> diff --git a/lib/sisu/v4/wikispeak.rb b/lib/sisu/v6/wikispeak.rb index fa2d9ddb..43313b11 100644 --- a/lib/sisu/v4/wikispeak.rb +++ b/lib/sisu/v6/wikispeak.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/wikispeak.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/wikispeak.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -60,14 +61,14 @@ =end module SiSU_Wikispeak - require_relative 'dal' # dal.rb + require_relative 'ao' # ao.rb require_relative 'sysenv' # sysenv.rb include SiSU_Env include SiSU_Param 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 @@ -80,13 +81,18 @@ module SiSU_Wikispeak @md=SiSU_Param::Parameters.new(@opt).get @env=SiSU_Env::InfoEnv.new(@opt.fns) path=@env.path.output_tell - tool=(@opt.cmd =~/[MVv]/) \ + tool=(@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) \ ? "#{@env.program.text_editor} #{path}/#{@md.fnb}/#{@md.fn[:wiki]}" : '' - SiSU_Screen::Ansi.new(@opt.cmd,'Wikispeak',tool).green_hi_blue unless @opt.cmd =~/q/ - 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_Screen::Ansi.new(@opt.act[:color_state][:set],'Wikispeak',tool).green_hi_blue unless @opt.act[:quiet][:set]==:on + if (@opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],@opt.fns,"#{@env.path.output_tell}/#{@md.fnb}/#{@md.fn[:wiki]}").flow + end + @ao_array=SiSU_AO::Source.new(@opt).get # ao file drawn here + SiSU_Wikispeak::Source::Scroll.new(@ao_array,@md).songsheet rescue SiSU_Errors::Rescued.new($!,$@,@opt.cmd,@opt.fns).location do __LINE__.to_s + ':' + __FILE__ @@ -144,7 +150,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: [] } @@ -217,10 +223,10 @@ WOK para.gsub!(/<\S+?>#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}/,'') # endnote marker marked up if lv @@wiki[:body] << case lv - when 1; '='*2 << para.strip << @br*2 - when 2..3; '='*2 << para.strip << @br*2 - when 4; '='*4 << para.strip << @br*2 - when 5..6; '='*4 << para.strip << @br*2 + when 1 then '='*2 << para.strip << @br*2 + when 2..3 then '='*2 << para.strip << @br*2 + when 4 then '='*4 << para.strip << @br*2 + when 5..6 then '='*4 << para.strip << @br*2 end else @@wiki[:body] << para << @br*2 # main text, contents, body KEEP end diff --git a/lib/sisu/v4/xhtml.rb b/lib/sisu/v6/xhtml.rb index c4c708ef..57962961 100644 --- a/lib/sisu/v4/xhtml.rb +++ b/lib/sisu/v6/xhtml.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/xhtml.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/xhtml.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -66,7 +67,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 @@ -82,18 +83,24 @@ module SiSU_XHTML end def read begin - @env,@md,@dal_array=@particulars.env,@particulars.md,@particulars.dal_array - unless @opt.cmd =~/q/ - tool=if @opt.cmd =~/[MV]/ + @env,@md,@ao_array=@particulars.env,@particulars.md,@particulars.ao_array + unless @opt.act[:quiet][:set]==:on + tool=if (@opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) "#{@env.program.web_browser} file://#{@md.file.output_path.xhtml.dir}/#{@md.file.base_filename.xhtml}" - elsif @opt.cmd =~/v/ + elsif @opt.act[:verbose][:set]==:on "#{@env.program.web_browser} file://#{@md.file.output_path.xhtml.dir}/#{@md.file.base_filename.xhtml}" else "[#{@opt.f_pth[:lng_is]}] #{@opt.fno}" end - @opt.cmd=~/[MVvz]/ \ - ? SiSU_Screen::Ansi.new(@opt.cmd,'XHTML',tool).green_hi_blue - : SiSU_Screen::Ansi.new(@opt.cmd,'XHTML',tool).green_title_hi - SiSU_Screen::Ansi.new(@opt.cmd,@opt.fns,"/#{@md.file.output_path.xhtml.dir}/#{@md.file.base_filename.xhtml}").flow if @opt.cmd =~/[MV]/ + (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) \ + ? SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'XHTML',tool).green_hi_blue + : SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'XHTML',tool).green_title_hi + if (@opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],@opt.fns,"/#{@md.file.output_path.xhtml.dir}/#{@md.file.base_filename.xhtml}").flow + end end SiSU_XHTML::Source::Songsheet.new(@particulars).song rescue @@ -107,14 +114,18 @@ module SiSU_XHTML private class Songsheet def initialize(particulars) - @env,@md,@dal_array,@particulars=particulars.env,particulars.md,particulars.dal_array,particulars + @env,@md,@ao_array,@particulars=particulars.env,particulars.md,particulars.ao_array,particulars @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 + if (@md.opt.act[:verbose][:set]==:on \ + || @md.opt.act[:verbose_plus][:set]==:on \ + || @md.opt.act[:maintenance][:set]==:on) + SiSU_XHTML::Source::Tidy.new(@md,@file.place_file.xhtml.dir).xml # test wellformedness, comment out when not in use + end + SiSU_Rexml::Rexml.new(@md,@file.place_file.xhtml.dir).xml if @md.opt.act[:maintenance][:set]==:on # test rexml parsing, comment out when not in use #debug rescue SiSU_Errors::Rescued.new($!,$@,@md.opt.cmd,@md.fns).location do __LINE__.to_s + ':' + __FILE__ @@ -124,13 +135,13 @@ 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: [] } def initialize(particulars) - @env,@md,@dal_array=particulars.env,particulars.md,particulars.dal_array + @env,@md,@ao_array=particulars.env,particulars.md,particulars.ao_array @vz=SiSU_Viz::Defaults.new @tab="\t" @trans=SiSU_XML_Munge::Trans.new(@md) @@ -138,7 +149,7 @@ module SiSU_XHTML end def songsheet pre - @data=markup(@dal_array) + @data=markup(@ao_array) post publish end @@ -306,12 +317,13 @@ WOK if dob.is==:heading xml_structure(dob) dob.obj=case dob.ln - when 1; x.heading_body1 - when 2; x.heading_body2 - when 3; x.heading_body3 - when 4; x.heading_body4 - when 5; x.heading_body5 - when 6; x.heading_body6 + when 0 then x.heading_body0 + when 1 then x.heading_body1 + when 2 then x.heading_body2 + when 3 then x.heading_body3 + when 4 then x.heading_body4 + when 5 then x.heading_body5 + when 6 then x.heading_body6 end else if dob.is ==:verse @@ -413,16 +425,17 @@ WOK end def xml if @prog.tidy !=false - if @md.opt.cmd =~/[VM]/ - unless @md.opt.cmd =~/q/ - SiSU_Screen::Ansi.new(@md.opt.cmd,'invert','Using XML Tidy','check document structure').colorize - tell=SiSU_Screen::Ansi.new(@md.opt.cmd,'invert','','') + if (@md.opt.act[:verbose_plus][:set]==:on \ + || @md.opt.act[:maintenance][:set]==:on) + unless @md.opt.act[:quiet][:set]==:on + SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],'invert','Using XML Tidy','check document structure').colorize + tell=SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],'invert','','') tell.grey_open end tidyfile='/dev/null' #don't want one or screen output, check for alternative flags tidy=SiSU_Env::SystemCall.new(@file,tidyfile) tidy.well_formed? - tell.p_off unless @md.opt.cmd =~/q/ + tell.p_off unless @md.opt.act[:quiet][:set]==:on end end end diff --git a/lib/sisu/v4/epub.rb b/lib/sisu/v6/xhtml_epub2.rb index d83e3aad..6447431f 100644 --- a/lib/sisu/v4/epub.rb +++ b/lib/sisu/v6/xhtml_epub2.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/epub.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/epub.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -59,20 +60,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 @@ -86,32 +87,40 @@ module SiSU_EPUB @md=@particulars.md @fnb=@md.fnb @env=@particulars.env - unless @opt.cmd =~/q/ - tool=(@opt.cmd =~/[MVvz]/) \ + unless @opt.act[:quiet][:set]==:on + tool=(@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) \ ? "#{@env.program.epub_viewer} #{@md.file.output_path.epub.dir}/#{@md.file.base_filename.epub}" : "[#{@opt.f_pth[:lng_is]}] #{@opt.fno}" - @opt.cmd=~/[MVvz]/ \ - ? SiSU_Screen::Ansi.new(@opt.cmd,'EPUB',tool).green_hi_blue - : SiSU_Screen::Ansi.new(@opt.cmd,'EPUB',tool).green_title_hi - SiSU_Screen::Ansi.new(@opt.cmd,@opt.fns,"#{@md.file.output_path.epub.dir}/#{@md.file.base_filename.epub}").flow if @opt.cmd =~/[MV]/ + (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) \ + ? SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'EPUB',tool).green_hi_blue + : SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'EPUB',tool).green_title_hi + if (@opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],@opt.fns,"#{@md.file.output_path.epub.dir}/#{@md.file.base_filename.epub}").flow + end end @env.processing_path.epub_bld #(@md) @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__ end ensure - unless @opt.cmd =~/[MV]/ #check maintenance flag + unless (@opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) texfiles=Dir["#{@env.processing_path.tune}/#{@opt.fns}*"] texfiles.each do |f| if FileTest.file?(f) @@ -139,15 +148,15 @@ module SiSU_EPUB SiSU_Env::FileOp.new(@md).mkdir.output.epub end def tuned_file_instructions - @tell=SiSU_Screen::Ansi.new(@md.opt.cmd) + @tell=SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set]) directories - dal_array=@particulars.dal_array # dal file drawn here - @tuned_file_array=SiSU_EPUB_Tune::Tune.new(dal_array,@md).songsheet + ao_array=@particulars.ao_array # ao file drawn here + @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 @@ -169,7 +178,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 @@ -185,18 +194,22 @@ module SiSU_EPUB def initialize(md=nil,data='') @md,@data=md,data @vz=SiSU_Viz::Defaults.new - @epub=SiSU_EPUB_Format::HeadInformation.new(@md) - @tell=SiSU_Screen::Ansi.new(@md.opt.cmd) if @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 def songsheet #extracts toc for scroll & seg - SiSU_Screen::Ansi.new(@md.opt.cmd,'Toc').txt_grey if @md.opt.cmd =~/[MVv]/ + if (@md.opt.act[:verbose][:set]==:on \ + || @md.opt.act[:verbose_plus][:set]==:on \ + || @md.opt.act[:maintenance][:set]==:on) + SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],'Toc').txt_grey + end toc=nil @@firstseg=nil @@toc={ seg: [], seg_mini: [], scr: [], ncx: [], opf: [] } md_opf_a_content,md_opf_a_spine,md_opf_a_guide=[],[],[] @nav_no=0 - @s_a_no,@s_b_no,@s_c_no,@lv5_no,@lv6_no=0,0,0,0,0 + @s_a_no,@s_b_no,@s_c_no,@s_d_no,@lv5_no,@lv6_no=0,0,0,0,0,0 @@toc[:ncx] << @epub.toc_ncx.open #epub ncx navmap @@toc[:ncx] << @epub.toc_ncx.head_open << @epub.toc_ncx.head << @epub.toc_ncx.head_close @@toc[:ncx] << @epub.toc_ncx.doc_title << @epub.toc_ncx.doc_author @@ -218,7 +231,7 @@ module SiSU_EPUB 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] + @ncxo=[false,false,false,false,false,false,false] @dob_toc2,@dob_toc3=nil,nil @ncx_cls=[] @level_a_first_occurrence=true @@ -227,7 +240,7 @@ module SiSU_EPUB || dob.is==:heading_insert dob_toc=dob.dup toc=case dob_toc.ln - when 1 + when 0 @s_a_no +=1 lv_name='section_a' + @s_a_no.to_s @nav_no+=1 @@ -238,20 +251,21 @@ module SiSU_EPUB @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[3] @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[2] @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[1] - @ncxo[1],@ncxo[2],@ncxo[3],@ncxo[4],@ncxo[5],@ncxo[6]=true,false,false,false,false,false + @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[0] + @ncxo[0],@ncxo[1],@ncxo[2],@ncxo[3],@ncxo[4],@ncxo[5],@ncxo[6]=true,false,false,false,false,false,false @epub.sections(dob_toc,lv_name) - @@toc[:ncx] << @epub.toc_ncx.navpoint(dob_toc,@nav_no,lv_name) if dob_toc 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 + @nav_no+=1 @level_a_first_occurrence=false end + @@toc[:ncx] << @epub.toc_ncx.navpoint(dob_toc,@nav_no,lv_name) if dob_toc 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 - when 2 + SiSU_XHTML_EPUB2::Source::Toc.new(@md,dob_toc).level_0 + when 1 @s_b_no +=1 lv_name='section_b' + @s_b_no.to_s @nav_no+=1 @@ -261,17 +275,35 @@ module SiSU_EPUB @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[4] @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[3] @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[2] - @ncxo[2],@ncxo[3],@ncxo[4],@ncxo[5],@ncxo[6]=true,false,false,false,false + @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[1] + @ncxo[1],@ncxo[2],@ncxo[3],@ncxo[4],@ncxo[5],@ncxo[6]=true,false,false,false,false,false @epub.sections(dob_toc,lv_name) @@toc[:ncx] << @epub.toc_ncx.navpoint(dob_toc,@nav_no,lv_name) if dob_toc 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 - when 3 + SiSU_XHTML_EPUB2::Source::Toc.new(@md,dob_toc).level_1 + when 2 @s_c_no +=1 lv_name='section_c' + @s_c_no.to_s @nav_no+=1 + @nav_no2=@nav_no + @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[6] + @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[5] + @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[4] + @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[3] + @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[2] + @ncxo[2],@ncxo[3],@ncxo[4],@ncxo[5],@ncxo[6]=true,false,false,false,false + @epub.sections(dob_toc,lv_name) + @@toc[:ncx] << @epub.toc_ncx.navpoint(dob_toc,@nav_no,lv_name) if dob_toc + 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_XHTML_EPUB2::Source::Toc.new(@md,dob_toc).level_2 + when 3 + @s_d_no +=1 + lv_name='section_d' + @s_d_no.to_s + @nav_no+=1 @nav_no3=@nav_no @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[6] @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[5] @@ -283,7 +315,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 @@ -297,7 +329,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 @@ -310,7 +342,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 @@ -322,7 +354,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| @@ -351,7 +383,8 @@ module SiSU_EPUB @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[3] @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[2] @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[1] - @ncxo[1],@ncxo[2],@ncxo[3],@ncxo[4],@ncxo[5],@ncxo[6]=false,false,false,false,false,false + @@toc[:ncx] << @epub.toc_ncx.navpoint_close if @ncxo[0] + @ncxo[0],@ncxo[1],@ncxo[2],@ncxo[3],@ncxo[4],@ncxo[5],@ncxo[6]=false,false,false,false,false,false,false md_opf_a_content << @epub.metadata_opf.manifest_images(@md.ec[:image]) @@toc[:seg] << "</div>\n</div>" @@toc[:scr] << "</div>\n</div>" @@ -362,15 +395,38 @@ 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 protected + def level_0 + dob=@data + linkname=dob.obj.gsub(/#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]}/,'').strip + link=dob.ocn + title=linkname + toc={} + txt_obj={ txt: title } + format_toc=SiSU_XHTML_EPUB2_Format::FormatToc.new(@md,txt_obj) + toc[:seg]=format_toc.lev1 + title=if dob.ocn ==0 then linkname + else + @@toc[:scr] << '<br />' + link=(dob.ln) \ + ? dob.ln + : '' + %{<b><a href="##{link}">#{linkname}</a></b>} + end + txt_obj={ txt: title } + format_toc=SiSU_XHTML_EPUB2_Format::FormatToc.new(@md,txt_obj) + toc[:scr]=format_toc.lev1 + toc + end def level_1 dob=@data - linkname,link=dob.obj.strip,dob.ocn + linkname=dob.obj.gsub(/#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]}/,'').strip + link=dob.ocn title=if dob.obj !~/Document Information/ linkname else @@ -379,7 +435,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 @@ -399,7 +455,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 @@ -409,46 +465,49 @@ module SiSU_EPUB end def level_2 dob=@data - linkname,ocn=dob.obj.strip,dob.ocn + linkname=dob.obj.gsub(/#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]}/,'').strip + ocn=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 end def level_3 dob=@data - linkname,ocn=dob.obj.strip,dob.ocn + linkname=dob.obj.gsub(/#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]}/,'').strip + ocn=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 end def level_4 dob=@data - linkname,ocn=dob.obj.strip,dob.ocn - p_num=SiSU_EPUB_Format::ParagraphNumber.new(@md,ocn) if ocn + linkname=dob.obj.gsub(/#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]}/,'').strip + ocn=dob.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} @@ -459,53 +518,55 @@ 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 def level_5 dob=@data - linkname,ocn=dob.obj.strip,dob.ocn + linkname=dob.obj.gsub(/#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]}/,'').strip + ocn=dob.ocn 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 end def level_6 dob=@data - linkname,ocn=dob.obj.strip,dob.ocn + linkname=dob.obj.gsub(/#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]}/,'').strip + ocn=dob.ocn 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 @@ -519,8 +580,12 @@ module SiSU_EPUB 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::HeadToc.new(@md) + if (@md.opt.act[:verbose][:set]==:on \ + || @md.opt.act[:verbose_plus][:set]==:on \ + || @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_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 @@ -528,18 +593,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 \ @@ -547,7 +612,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 @@ -583,8 +648,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 @@ -592,13 +657,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 @@ -622,7 +687,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 @@ -675,7 +740,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) @@ -687,7 +752,7 @@ module SiSU_EPUB ") FileUtils::mv(@epub_doc, @md.file.place_file.epub.dir) Dir.chdir(pwd) - unless @md.opt.cmd.inspect =~/M/ + unless @md.opt.act[:maintenance][:set]==:on FileUtils::rm_r(@md.env.processing_path.epub) end end @@ -712,8 +777,8 @@ module SiSU_EPUB <body bgcolor="#ffffff" text="#000000" link="#003090" lang="en" xml:lang="en"> <div class="svg_outer"> <div class="svg_inner"> - <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="100%" height="100%" viewBox="0 0 #{@md.make.cover_image[:w]} #{@md.make.cover_image[:h]}" preserveAspectRatio="xMidYMid meet"> - <image width="#{@md.make.cover_image[:w]}" height="#{@md.make.cover_image[:h]}" xlink:href="image/#{@md.make.cover_image[:cover]}" /> + <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xl="http://www.w3.org/1999/xlink" width="100%" height="100%" viewBox="0 0 #{@md.make.cover_image[:w]} #{@md.make.cover_image[:h]}" preserveAspectRatio="xMidYMid meet"> + <image width="#{@md.make.cover_image[:w]}" height="#{@md.make.cover_image[:h]}" xl:href="image/#{@md.make.cover_image[:cover]}" /> </svg> </div> </div> diff --git a/lib/sisu/v4/epub_concordance.rb b/lib/sisu/v6/xhtml_epub2_concordance.rb index 838e4595..80dd0c1b 100644 --- a/lib/sisu/v4/epub_concordance.rb +++ b/lib/sisu/v6/xhtml_epub2_concordance.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/epub_concordance.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/epub_concordance.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -60,15 +61,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 +81,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.cmd,"*WARN* concordance skipped, large document has over #{wordmax} words (#{@md.wc_words})").warn unless @md.opt.cmd =~/q/ + 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.cmd,"*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.cmd =~/q/ - SiSU_EPUB_Concordance::Source::Words.new(@particulars).songsheet + 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_XHTML_EPUB2_Concordance::Source::Words.new(@particulars).songsheet end rescue SiSU_Errors::Rescued.new($!,$@,@md.opt.cmd,@md.fns).location do @@ -98,11 +99,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 +113,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,22 +149,24 @@ 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) @particulars=particulars begin @vz=SiSU_Viz::Defaults.new - @env,@md,@dal_array=particulars.env,particulars.md,particulars.dal_array + @env,@md,@ao_array=particulars.env,particulars.md,particulars.ao_array @path="#{@env.processing_path.epub}" @freq=Hash.new(0) - @rxp_lv1=/^#{Mx[:lv_o]}1:/ #fix Mx[:lv_o] - @rxp_lv2=/^#{Mx[:lv_o]}2:/ #fix Mx[:lv_o] - @rxp_lv3=/^#{Mx[:lv_o]}3:/ #fix Mx[:lv_o] + @rxp_lv0=/^#{Mx[:lv_o]}0:/ + @rxp_lv1=/^#{Mx[:lv_o]}1:/ + @rxp_lv2=/^#{Mx[:lv_o]}2:/ + @rxp_lv3=/^#{Mx[:lv_o]}3:/ @rxp_seg=/^#{Mx[:lv_o]}4:(\S+?)#{Mx[:lv_c]}/ @rxp_title=Regexp.new("^#{Mx[:meta_o]}title#{Mx[:meta_c]}\s*(.+?)\s*$") + @rxp_t0=Regexp.new('^T0') @rxp_t1=Regexp.new('^T1') @rxp_t2=Regexp.new('^T2') @rxp_t3=Regexp.new('^T3') @@ -214,7 +217,7 @@ WOK def map_para @seg,toy=nil,nil @word_map={} - @dal_array.each do |line| + @ao_array.each do |line| if defined? line.ocn if (line.is ==:heading \ || line.is ==:heading_insert) \ @@ -270,15 +273,17 @@ WOK end @freq[word] +=1 @word_map[word] ||= [] - if line !~@rxp_lv1 \ + if line !~@rxp_lv0 \ + and line !~@rxp_lv1 \ and line !~@rxp_lv2 \ and line !~@rxp_lv3 @word_map[word] << location_seg("#{@seg}\##{toy}",toy) else @word_map[word] << case line - when @rxp_lv1; location_seg('T1',toy) - when @rxp_lv2; location_seg('T2',toy) - when @rxp_lv3; location_seg('T3',toy) + when @rxp_lv0 then location_seg('T0',toy) + when @rxp_lv1 then location_seg('T1',toy) + when @rxp_lv2 then location_seg('T2',toy) + when @rxp_lv3 then location_seg('T3',toy) end end end @@ -288,7 +293,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 +311,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/v4/epub_format.rb b/lib/sisu/v6/xhtml_epub2_format.rb index 4a060806..d5b7e85e 100644 --- a/lib/sisu/v4/epub_format.rb +++ b/lib/sisu/v6/xhtml_epub2_format.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/epub_format.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/epub_format.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -59,7 +60,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 +1242,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 @@ -1305,6 +1306,7 @@ application/epub+zip dir_epub_cont=@md.env.processing_path.epub + '/' + Ep[:d_oebps] segfilename=dir_epub_cont + '/' + name output_epub_cont_seg=File.new(segfilename,'w') + txt=dob.obj.gsub(/#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]}/,'') output_epub_cont_seg << %{#{doc_type} <head> <title> @@ -1319,7 +1321,7 @@ application/epub+zip <div class="substance"> <label class="ocn"><a href="#o#{dob.ocn}" class="lnkocn">#{dob.ocn}</a></label> <h1 class="norm" id="o#{dob.ocn}"> - #{dob.obj} + #{txt} </h1> </div> </div> @@ -1412,15 +1414,16 @@ output_epub_cont_seg.close WOK end def navpoint(dob,no,fn_base,hashtag=nil) - fn=fn_base + Sfx[:epub_xhtml] - name=hashtag ? fn + hashtag : fn + fn=fn_base + Sfx[:epub_xhtml] + name=hashtag ? fn + hashtag : fn id_u=DISABLE[:epub][:ncx_navpoint_unique_id] \ ? '' : "-#{no}" + txt=dob.obj.gsub(/#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]}/,'') <<-WOK <navPoint class="chapter" id="navpoint#{id_u}" playOrder="#{no}"> <navLabel> - <text>#{dob.obj}</text> + <text>#{txt}</text> </navLabel> <content src="#{name}" /> WOK @@ -1878,7 +1881,7 @@ output_epub_cont_seg.close @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) else - if @md.opt.cmd =~/M/ + if @md.opt.act[:maintenance][:set]==:on p __FILE__ << ':' << __LINE__.to_s p t_o.class p caller @@ -1988,6 +1991,11 @@ output_epub_cont_seg.close </div> } end + def title_heading0 + DISABLE[:epub][:per_section_title] \ + ? '' + : title_heading('h1','tiny') + end def title_heading1 DISABLE[:epub][:per_section_title] \ ? '' diff --git a/lib/sisu/v4/epub_segments.rb b/lib/sisu/v6/xhtml_epub2_segments.rb index 44db5fe9..2be4afd9 100644 --- a/lib/sisu/v4/epub_segments.rb +++ b/lib/sisu/v6/xhtml_epub2_segments.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/epub_segments.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/epub_segments.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -59,9 +60,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 +75,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 +102,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 @@ -123,8 +124,8 @@ WOK @@seg_name,@@seg_name_xhtml=[],[] @@seg_url=@@fn=@@get_hash_to=@@get_hash_fn='' @@loop_count=@@seg_total=@@tracker=0 - @@is4=@@is3=@@is2=@@is1=0 - @@heading1=@@heading2=@@heading3=@@heading4=0 + @@is4=@@is3=@@is2=@@is1=@@is0=0 + @@heading0=@@heading1=@@heading2=@@heading3=@@heading4=0 @@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 @@ -141,7 +142,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 @@ -154,7 +155,7 @@ WOK protected def articles(data) tracking,newfile=0,0 - @@is4=@@is3=@@is2=@@is1=0 + @@is4=@@is3=@@is2=@@is1=@@is0=0 printed_endnote_seg='n' idx_xhtml=nil if @md.book_idx @@ -173,7 +174,11 @@ WOK @@seg_name_xhtml=@@seg_name @@seg_total=@@seg_name.length testforartnum=@@seg_name_xhtml - SiSU_Screen::Ansi.new(@md.opt.cmd,@@seg_name.length) if @md.opt.cmd =~/[MVv]/ + if (@md.opt.act[:verbose][:set]==:on \ + || @md.opt.act[:verbose_plus][:set]==:on \ + || @md.opt.act[:maintenance][:set]==:on) + SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],@@seg_name.length) + end SiSU_Particulars::CombinedSingleton.instance.get_map_nametags(@md).nametags_map #p map_nametags data.each do |dob| #if defined? dob.obj \ @@ -191,35 +196,38 @@ WOK #end if (dob.is==:heading \ || dob.is==:heading_insert) \ - and dob.ln==4 - if dob.ocn==0 - @@heading4=dob.obj - else @@heading4=dob.obj - end + && dob.ln==4 + @@heading4=dob.obj @@is4=newfile=1 end if (dob.is==:heading \ || dob.is==:heading_insert) \ - and dob.ln==3 + && dob.ln==3 @@heading3=dob.obj @@is4,@@is3=0,1 end if (dob.is==:heading \ || dob.is==:heading_insert) \ - and dob.ln==2 + && dob.ln==2 @@heading2=dob.obj @@is4,@@is3,@@is2=0,0,1 end if (dob.is==:heading \ || dob.is==:heading_insert) \ - and dob.ln==1 + && dob.ln==1 @@heading1=dob.obj @@is4,@@is3,@@is2,@@is1=0,0,0,1 end - if (@@is1 && !@@is2 && !@@is3 && !@@is4) + if (dob.is==:heading \ + || dob.is==:heading_insert) \ + && dob.ln==0 + @@heading0=dob.obj + @@is4,@@is3,@@is2,@@is1,@@is0=0,0,0,0,1 + end + if (@@is0 && !@@is1 && !@@is2 && !@@is3 && !@@is4) if not (dob.is==:heading \ || dob.is==:heading_insert) \ - and dob.ln==1 + && dob.ln==0 $_ #; check end end @@ -230,34 +238,34 @@ WOK newfile=0 if (dob.is==:heading \ || dob.is==:heading_insert) \ - and dob.ln==4 + && 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 @@ -270,8 +278,8 @@ WOK end if (dob.is==:heading \ || dob.is==:heading_insert) \ - and dob.ln==4 \ - and dob.name + && dob.ln==4 \ + && dob.name @@get_hash_to=dob.name @@get_hash_fn=dob.name end @@ -292,55 +300,50 @@ 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=/<!.*?!>|<:.*?>$/ @p_num ||= '' - if @@is1==1 + if @@is0==1 if defined? @md.creator.author \ and @md.creator.author @author=%{<b>#{@md.creator.author}</b>\n} end - 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,dob.ocn) + txt_obj={ txt: @@heading0, ocn_display: @p_num.ocn_display } + format_seg=SiSU_XHTML_EPUB2_Format::FormatSeg.new(@md,txt_obj) + @@seg[:headings] << format_seg.title_heading0.gsub(clean,'') + @@heading0=@@heading0.gsub(/#{$ep[:hsp]}<a name="-[\d*+]+" href="#_[\d*+]+">#{$ep[:hsp]}<sup>[\d*+]+<\/sup>#{$ep[:hsp]}<\/a>/,'') + end + if @@is1==1 + @p_num=SiSU_XHTML_EPUB2_Format::ParagraphNumber.new(@md,dob.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 if @@is2==1 heading2=@@heading2 - 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,dob.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 if @@is3==1 heading3=@@heading3 - 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,dob.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 if @@is4==1 heading4=@@heading4 - 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,dob.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 @@ -351,9 +354,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 @@ -404,13 +407,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 \ @@ -426,7 +429,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} @@ -482,10 +485,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 @@ -512,7 +515,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 @@ -525,7 +528,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/v4/epub_tune.rb b/lib/sisu/v6/xhtml_epub2_tune.rb index dd9f478d..12f70fcf 100644 --- a/lib/sisu/v4/epub_tune.rb +++ b/lib/sisu/v6/xhtml_epub2_tune.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/epub_tune.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/epub_tune.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -60,10 +61,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 @@ -80,7 +81,7 @@ module SiSU_EPUB_Tune def initialize(data,md) @data,@md=data,md @file=SiSU_Env::FileOp.new(@md) - @cX=SiSU_Screen::Ansi.new(@md.opt.cmd).cX + @cX=SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set]).cX end def hard_output @filename_tune=@file.write_file_processing.html_tune @@ -121,17 +122,21 @@ module SiSU_EPUB_Tune 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=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 - if @md.opt.cmd =~/M/ #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 + @cX=SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set]).cX + if (@md.opt.act[:verbose][:set]==:on \ + || @md.opt.act[:verbose_plus][:set]==:on \ + || @md.opt.act[:maintenance][:set]==:on) + SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],'Tune').txt_grey end - SiSU_EPUB_Tune::Tune.new(@data,@md).output + 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_XHTML_EPUB2_Tune::Output.new(data,@md).hard_output + SiSU_XHTML_EPUB2_Tune::Output.new(data,@md).marshal + end + 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__ @@ -159,7 +164,7 @@ module SiSU_EPUB_Tune gsub(/#{Dx[:url_o]}/,Dx[:url_o_xml]).gsub(/#{Dx[:url_c]}/,Dx[:url_c_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/v4/shared_xhtml.rb b/lib/sisu/v6/xhtml_shared.rb index 0ba15894..a7c174dc 100644 --- a/lib/sisu/v4/shared_xhtml.rb +++ b/lib/sisu/v6/xhtml_shared.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/shared_xhtml.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/xhtml_shared.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> diff --git a/lib/sisu/v4/xhtml_table.rb b/lib/sisu/v6/xhtml_table.rb index 7c3925ae..0b862b2a 100644 --- a/lib/sisu/v4/xhtml_table.rb +++ b/lib/sisu/v6/xhtml_table.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/xhtml_table.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/xhtml_table.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> diff --git a/lib/sisu/v6/xml_docbook5.rb b/lib/sisu/v6/xml_docbook5.rb new file mode 100644 index 00000000..84c2181c --- /dev/null +++ b/lib/sisu/v6/xml_docbook5.rb @@ -0,0 +1,277 @@ +# 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, 2014 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/v6/xml_docbook_book.rb;hb=HEAD> + + * Ralph Amissah + <ralph@amissah.com> + <ralph.amissah@gmail.com> + + ** Description: Docbook book XML rendition + +=end +module SiSU_XML_Docbook_Book + require_relative 'particulars' # particulars.rb + include SiSU_Particulars + require_relative 'ao' # ao.rb + require_relative 'sysenv' # sysenv.rb + include SiSU_Env + require_relative 'txt_shared' # txt_shared.rb + include SiSU_TextUtils + require_relative 'xml_shared' # xml_shared.rb + include SiSU_XML_Munge + class Source + def initialize(opt) + @opt=opt + @particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt) + end + def read + begin + @md,@ao_array=@particulars.md,@particulars.ao_array + @env=@particulars.env + report + SiSU_XML_Docbook_Book::Source::Scroll.new(@ao_array,@md).songsheet + rescue + SiSU_Errors::Rescued.new($!,$@,@opt.cmd,@opt.fns).location do + __LINE__.to_s + ':' + __FILE__ + end + ensure + end + end + private + def report + unless @opt.act[:quiet][:set]==:on + tool=(@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) \ + ? "#{@env.program.docbook_viewer} #{@md.file.output_path.xml_docbook_book.dir}/#{@md.file.base_filename.xml_docbook_book}" + : "[#{@opt.f_pth[:lng_is]}] #{@opt.fno}" + (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) \ + ? SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'DocBook',tool).green_hi_blue + : SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'DocBook',tool).green_title_hi + if (@opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],@opt.fns,"#{@md.file.output_path.xml_docbook_book.dir}/#{@md.file.base_filename.xml_docbook_book}").flow + end + end + end + class Scroll <Source + def initialize(data='',md='') + @data,@md=data,md + @trans=SiSU_XML_Munge::Trans.new(@md) + @particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(md.opt) + @env=@particulars.env + end + def songsheet + @t='sisu' + data=@data + if @md.opt.act[:verbose_plus][:set]==:on + structure_collapsed(data) + end + #head + #extract_endnotes + data=markup_text(data) + structure_build_collapsed(data) + #tail + end + def space + ' ' + end + def tags + # collapsed --> + def collapsed + %w[ 0 1 2 3 4 5 ] + end + def docbook(lc,chlv='') + case lc + when 0 then 'book' + when 1 then lc==chlv ? 'chapter' : 'section' + when 2 then lc==chlv ? 'chapter' : 'section' + when 3 then lc==chlv ? 'chapter' : 'section' + when 4 then 'section' + when 5 then 'section' + when 6 then 'section' + end + end + self + end + def put(line) + #@file_docbook.puts line #look into and use perhaps + puts line if @md.opt.act[:verbose_plus][:set]==:on + end + def head + <<-WOK +<?xml version="1.0" encoding="utf-8"?> +<book xmlns="http://docbook.org/ns/docbook" + xmlns:xl="http://www.w3.org/1999/xlink" + version="5.0"> + WOK + end + def markup_text(data) + data.each_with_index do |o,i| + if o.is ==:heading || o.is ==:para + o=@trans.markup_docbook(o) #unless o.obj==nil + end + end + data + end + def tail + tail=<<-WOK +</book> + WOK + put(tail) + end + def output(o,comment='') + puts o.lc == (0..6) \ + ? "#{space*o.lc}<#{o.lc}>[#{o.ocn}] #{o.ln} #{o.obj}</#{o.lc}>#{comment}" + : "<#{o.lc}>[#{o.ocn}] #{o.ln} #{o.obj}</#{o.lc}>#{comment}" + end + def structure_collapsed(data) + puts "\ncollapsed structure, heading outline --->\n\n" + data.each_with_index do |o,i| + if (o.is ==:heading || o.is ==:heading_insert) + output(o) + end + end + end + #def chapterlevel + #end + def structure_build_collapsed(data) + #output_file=@md.file.output_path.xml_docbook_book.dir + '/' + @md.file.base_filename.xml_docbook_book + file=SiSU_Env::FileOp.new(@md) + filename_docbook=file.write_file.xml_docbook_book + h=0 + @chlv=chlv=0 + doc_position=:head + filename_docbook.puts head + data.each_with_index do |o,i| + if (defined? o.ocn and not o.ocn.nil?) + ocn="\n#{Dx[:ocn_o]}#{o.ocn}#{Dx[:ocn_c]}" + id=%{ id="o#{o.ocn}" } + else + ocn,id='','' + end + if (o.is ==:heading || o.is ==:heading_insert) + chlv=(o.lv.to_i == 1) \ + ? @chlv=o.lc.to_i + : 0 + @splv=o.lc + tag_id=o.tags[0] ? %{ id="#{o.tags[0]}" } : '' + if doc_position ==:head + filename_docbook.puts %{#{space*o.lc}<title#{id}>} + doc_position=:body_and_tail + else + filename_docbook.puts structure_build_tag_close(o.lc,h) + filename_docbook.puts %{#{space*(o.lc)}<#{tags.docbook(o.lc,chlv)}#{tag_id}> +#{space*o.lc}<title#{id}> +} + end + filename_docbook.puts SiSU_TextUtils::Wrap.new(o.obj + ocn,80,(@splv*2+2)).line_wrap + filename_docbook.puts %{#{space*o.lc}</title>} + h=o.lc + elsif (o.of ==:para or o.of ==:block) + filename_docbook.puts "#{space*(@splv)}<para#{id}>" + filename_docbook.puts SiSU_TextUtils::Wrap.new(o.obj + ocn,80,(@splv*2+2)).line_wrap + filename_docbook.puts "#{space*(@splv)}</para>" + end + end + filename_docbook.puts structure_build_tag_close(0,h) + filename_docbook.close + end + def structure_build_tag_close(lc,h) + x=[] + case h + when 0 + x << "#{space*0}</#{tags.docbook(0)}>" if (lc <= 0) + when 1 + x << "#{space*1}</#{tags.docbook(1,@chlv)}>" if (lc <= 1) + x << "#{space*0}</#{tags.docbook(0)}>" if (lc <= 0) + when 2 + x << "#{space*2}</#{tags.docbook(2,@chlv)}>" if (lc <= 2) + x << "#{space*1}</#{tags.docbook(1,@chlv)}>" if (lc <= 1) + x << "#{space*0}</#{tags.docbook(0)}>" if (lc <= 0) + when 3 + x << "#{space*3}</#{tags.docbook(3,@chlv)}>" if (lc <= 3) + x << "#{space*2}</#{tags.docbook(2,@chlv)}>" if (lc <= 2) + x << "#{space*1}</#{tags.docbook(1,@chlv)}>" if (lc <= 1) + x << "#{space*0}</#{tags.docbook(0)}>" if (lc <= 0) + when 4 + x << "#{space*4}</#{tags.docbook(4,@chlv)}>" if (lc <= 4) + x << "#{space*3}</#{tags.docbook(3,@chlv)}>" if (lc <= 3) + x << "#{space*2}</#{tags.docbook(2,@chlv)}>" if (lc <= 2) + x << "#{space*1}</#{tags.docbook(1,@chlv)}>" if (lc <= 1) + x << "#{space*0}</#{tags.docbook(0)}>" if (lc <= 0) + when 5 + x << "#{space*5}</#{tags.docbook(5)}>" if (lc <= 5) + x << "#{space*4}</#{tags.docbook(4,@chlv)}>" if (lc <= 4) + x << "#{space*5}</#{tags.docbook(3,@chlv)}>" if (lc <= 3) + x << "#{space*2}</#{tags.docbook(2,@chlv)}>" if (lc <= 2) + x << "#{space*1}</#{tags.docbook(1,@chlv)}>" if (lc <= 1) + x << "#{space*0}</#{tags.docbook(0)}>" if (lc <= 0) + when 6 + x << "#{space*6}</#{tags.docbook(6)}>" if (lc <= 6) + x << "#{space*5}</#{tags.docbook(5)}>" if (lc <= 5) + x << "#{space*4}</#{tags.docbook(4,@chlv)}>" if (lc <= 4) + x << "#{space*3}</#{tags.docbook(3,@chlv)}>" if (lc <= 3) + x << "#{space*2}</#{tags.docbook(2,@chlv)}>" if (lc <= 2) + x << "#{space*1}</#{tags.docbook(1,@chlv)}>" if (lc <= 1) + x << "#{space*0}</#{tags.docbook(0)}>" if (lc <= 0) + end + x.join("\n") + end + end + end +end +__END__ diff --git a/lib/sisu/v4/xml_dom.rb b/lib/sisu/v6/xml_dom.rb index 057f8532..ace9e800 100644 --- a/lib/sisu/v4/xml_dom.rb +++ b/lib/sisu/v6/xml_dom.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/xml_dom.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/xml_dom.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -66,8 +67,8 @@ module SiSU_XML_DOM include SiSU_Particulars require_relative 'sysenv' # sysenv.rb include SiSU_Env - require_relative 'dal' # dal.rb - require_relative 'shared_xml' # shared_xml.rb + require_relative 'ao' # ao.rb + require_relative 'xml_shared' # xml_shared.rb include SiSU_XML_Munge require_relative 'xml_format' # xml_format.rb include SiSU_XML_Format @@ -83,16 +84,24 @@ module SiSU_XML_DOM end def read begin - @env,@md,@dal_array=@particulars.env,@particulars.md,@particulars.dal_array - unless @opt.cmd =~/q/ - tool=if @opt.cmd =~/[MV]/; "#{@env.program.web_browser} file://#{@md.file.output_path.xml_dom.dir}/#{@md.file.base_filename.xml_dom}\n\t#{@env.program.xml_viewer} file://#{@md.file.output_path.xml_dom.dir}/#{@md.file.base_filename.xml_dom}" - elsif @opt.cmd =~/v/; "#{@env.program.web_browser} file://#{@md.file.output_path.xml_dom.dir}/#{@md.file.base_filename.xml_dom}" + @env,@md,@ao_array=@particulars.env,@particulars.md,@particulars.ao_array + unless @opt.act[:quiet][:set]==:on + tool=if (@opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) + "#{@env.program.web_browser} file://#{@md.file.output_path.xml_dom.dir}/#{@md.file.base_filename.xml_dom}\n\t#{@env.program.xml_viewer} file://#{@md.file.output_path.xml_dom.dir}/#{@md.file.base_filename.xml_dom}" + elsif @opt.act[:verbose][:set]==:on + "#{@env.program.web_browser} file://#{@md.file.output_path.xml_dom.dir}/#{@md.file.base_filename.xml_dom}" else "[#{@opt.f_pth[:lng_is]}] #{@opt.fno}" end - @opt.cmd=~/[MVvz]/ \ - ? SiSU_Screen::Ansi.new(@opt.cmd,'XML DOM',tool).green_hi_blue - : SiSU_Screen::Ansi.new(@opt.cmd,'XML DOM',tool).green_title_hi - 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]/ + (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) \ + ? SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'XML DOM',tool).green_hi_blue + : SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'XML DOM',tool).green_title_hi + if (@opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],@opt.fns,"file://#{@md.file.output_path.xml_dom.dir}/#{@md.file.base_filename.xml_dom}").flow + end end SiSU_XML_DOM::Source::Songsheet.new(@particulars).songsheet rescue @@ -106,14 +115,18 @@ module SiSU_XML_DOM private class Songsheet def initialize(particulars) - @env,@md,@dal_array,@particulars=particulars.env,particulars.md,particulars.dal_array,particulars + @env,@md,@ao_array,@particulars=particulars.env,particulars.md,particulars.ao_array,particulars @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 + if (@md.opt.act[:verbose][:set]==:on \ + || @md.opt.act[:verbose_plus][:set]==:on \ + || @md.opt.act[:maintenance][:set]==:on) + SiSU_XML_DOM::Source::Tidy.new(@md,@file.place_file.xml_dom.dir).xml # test wellformedness, comment out when not in use + end + SiSU_Rexml::Rexml.new(@md,@file.place_file.xml_dom.dir).xml if @md.opt.act[:maintenance][:set]==:on # test rexml parsing, comment out when not in use #debug rescue SiSU_Errors::Rescued.new($!,$@,@md.opt.cmd,@md.fns).location do __LINE__.to_s + ':' + __FILE__ @@ -123,19 +136,19 @@ 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,@dal_array=particulars.env,particulars.md,particulars.dal_array + @env,@md,@ao_array=particulars.env,particulars.md,particulars.ao_array @vz=SiSU_Viz::Defaults.new @trans=SiSU_XML_Munge::Trans.new(@md) @sys=SiSU_Env::SystemCall.new end def songsheet pre - @data=markup(@dal_array) + @data=markup(@ao_array) post publish end @@ -178,11 +191,10 @@ WOK n=n1=n2=n3=0 if dob.is==:heading lv=dob.ln - n=dob.ln - 1 + n=dob.ln n1=dob.ln - n2=dob.ln + 1 - n3=dob.ln + 2 - dob.ln - 3 + n2=dob.ln + 2 + n3=dob.ln + 3 else lv=nil end tag=if defined? dob.name and dob.name=~/\S+/ @@ -361,7 +373,12 @@ WOK 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 + if dob.ln==0 + type="heading_section_#{dob.ln.to_s}" + xml_markup(dob) + xml_structure(dob,type) + dob.obj=x.heading_body0 + elsif dob.ln==1 type="heading_section_#{dob.ln.to_s}" xml_markup(dob) xml_structure(dob,type) @@ -526,14 +543,15 @@ WOK end def xml if @prog.tidy !=false - if @md.opt.cmd =~/[VM]/ - SiSU_Screen::Ansi.new(@md.opt.cmd,'invert','Using XML Tidy','check document structure').colorize unless @md.opt.cmd =~/q/ - tell=SiSU_Screen::Ansi.new(@md.opt.cmd,'invert','','') - tell.grey_open unless @md.opt.cmd =~/q/ + if (@md.opt.act[:verbose_plus][:set]==:on \ + || @md.opt.act[:maintenance][:set]==:on) + SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],'invert','Using XML Tidy','check document structure').colorize unless @md.opt.act[:quiet][:set]==:on + tell=SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],'invert','','') + tell.grey_open unless @md.opt.act[:quiet][:set]==:on tidyfile='/dev/null' #don't want one or screen output, check for alternative flags tidy=SiSU_Env::SystemCall.new(@file,tidyfile) tidy.well_formed? - tell.p_off unless @md.opt.cmd =~/q/ + tell.p_off unless @md.opt.act[:quiet][:set]==:on end end end diff --git a/lib/sisu/v6/xml_fictionbook2.rb b/lib/sisu/v6/xml_fictionbook2.rb new file mode 100644 index 00000000..9cd7909e --- /dev/null +++ b/lib/sisu/v6/xml_fictionbook2.rb @@ -0,0 +1,372 @@ +# 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, 2014 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/v6/xml_fictionbook.rb;hb=HEAD> + + * Ralph Amissah + <ralph@amissah.com> + <ralph.amissah@gmail.com> + + ** Description: Fictionbook XML rendition + +=end +module SiSU_XML_Fictionbook + require_relative 'particulars' # particulars.rb + include SiSU_Particulars + require_relative 'ao' # ao.rb + require_relative 'sysenv' # sysenv.rb + include SiSU_Env + require_relative 'txt_shared' # txt_shared.rb + include SiSU_TextUtils + require_relative 'xml_shared' # xml_shared.rb + include SiSU_XML_Munge + class Source + def initialize(opt) + @opt=opt + @particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt) + end + def read + begin + @md,@ao_array=@particulars.md,@particulars.ao_array + @env=@particulars.env + report + SiSU_XML_Fictionbook::Source::Scroll.new(@ao_array,@md).songsheet + rescue + SiSU_Errors::Rescued.new($!,$@,@opt.cmd,@opt.fns).location do + __LINE__.to_s + ':' + __FILE__ + end + ensure + end + end + private + def report + unless @opt.act[:quiet][:set]==:on + tool=(@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) \ + ? "#{@env.program.fictionbook_viewer} #{@md.file.output_path.xml_fictionbook.dir}/#{@md.file.base_filename.xml_fictionbook}" + : "[#{@opt.f_pth[:lng_is]}] #{@opt.fno}" + (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) \ + ? SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Fictionbook',tool).green_hi_blue + : SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Fictionbook',tool).green_title_hi + if (@opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],@opt.fns,"#{@md.file.output_path.xml_fictionbook.dir}/#{@md.file.base_filename.xml_fictionbook}").flow + end + end + end + class Scroll <Source + def initialize(data='',md='') + @data,@md=data,md + @trans=SiSU_XML_Munge::Trans.new(@md) + @particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(md.opt) + @env=@particulars.env + end + def songsheet + @t='sisu' + data=@data + if @md.opt.act[:verbose_plus][:set]==:on + structure_collapsed(data) + end + head + endnotes=extract_endnotes + images_base64=extract_images + data=markup_text(data) + structure_build_collapsed(data,endnotes,images_base64) + end + def space + ' ' + end + def tags + # collapsed --> + def collapsed + %w[ 0 1 2 3 4 5 ] + end + def fictionbook + [ + 'section', + 'section', + 'section', + 'section', + 'section', + 'section', + 'section' + ] + end + self + end + def put(line) + puts line if @md.opt.act[:verbose_plus][:set]==:on + 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 + coverpageimage=if defined? @md.make.cover_image[:cover] + %{\n <coverpage><image href="##{@md.make.cover_image[:cover]}" /></coverpage>} + else '' + end + if defined? @md.authors \ + and @md.authors.length > 0 + authors=[] + @md.authors.each do |author| + authors << ' <author>' + if not author[:others].empty? + authors << %{ <first-name>#{author[:others]}</first-name>} + end + if not author[:the].empty? + authors << %{ <last-name>#{author[:the]}</last-name>} + end + authors << ' </author>' + end + authors=authors.join("\n") + end + <<-WOK +<?xml version="1.0" encoding="UTF-8"?> +<FictionBook xmlns:xl="http://www.w3.org/1999/xlink" + xmlns="http://www.gribuser.ru/xml/fictionbook/2.0"> +<description> + <title-info> + <genre match="100">***</genre> +#{authors} + <book-title>#{@md.title.full}</book-title>#{coverpageimage} + <annotation> + </annotation> + <date value="#{@md.date.published}">#{@md.date.published}</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-url>#{@md.file.output_path.manifest.url}/#{@md.file.base_filename.manifest}</src-url> + <id></id> + <version>1.0</version> + <history>#{date_available}#{date_modified} + </history> + </document-info> +</description> +<body> + WOK + end + def extract_endnotes #work on + endnotes,endnotes_raw,endnotes_b=[],[],[] + @data.each do |para| + endnotes_raw << para.obj.scan(/#{Mx[:en_a_o]}(.+?)#{Mx[:en_a_c]}/m) + endnotes_b << para.obj.scan(/#{Mx[:en_b_o]}(.+?)#{Mx[:en_b_c]}/m) + end + endnotes_raw.flatten.each do |en| + en=@trans.markup_fictionbook(en) + endnotes << en.gsub(/([\d+*]+)\s+(.+)/m, + %{<section id="footnote\\1">\n +<title><p>\\1.</p></title>\n +<p>\\2</p>\n +</section>}) + end + endnotes_raw=[] + endnotes + end + def extract_images #work on + require "base64" + images_raw,images_base64_fb2=[],[] + images_base64={} + if defined? @md.make.cover_image[:cover] + images_raw << @md.make.cover_image[:cover] + end + @data.each do |para| + images_raw << para.obj.scan(/#{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) + end + images_raw.flatten.sort.each do |img| + imgpth=@env.url.images_local + '/' + img + open(imgpth) + if FileTest.file?(imgpth) + images_base64[img]=Base64.encode64(File.read(imgpth)) + end + end + images_raw=[] + images_base64.each_key do |k| + imgtype=case k + when /\.jpg/ then 'jpeg' + when /\.png/ then 'png' + when /\.gif/ then 'gif' + else 'jpeg' + end + images_base64_fb2 << %{<binary content-type="image/#{imgtype}" id="#{k}">#{images_base64[k]} +</binary> +} + end + images_base64_fb2.join("\n") + end + def markup_text(data) + data.each_with_index do |o,i| + if o.is ==:heading || o.is ==:para + o.obj=@trans.markup_fictionbook(o.obj,o.is) #unless o.obj==nil + end + end + data + end + def tail(images_base64_fb2) + <<-WOK +</body> +#{images_base64_fb2} +</FictionBook> + WOK + end + def output(o,comment='') + puts o.lc == 0..6 \ + ? "#{space*o.lc}<#{o.lc}>[#{o.ocn}] #{o.ln} #{o.obj}</#{o.lc}>#{comment}" + : "<#{o.lc}>[#{o.ocn}] #{o.ln} #{o.obj}</#{o.lc}>#{comment}" + end + def structure_collapsed(data) + puts "\ncollapsed structure, heading outline --->\n\n" + data.each_with_index do |o,i| + if (o.is ==:heading || o.is ==:heading_insert) + output(o) + end + end + end + def endnotes_build(endnotes,filename_fictionbook) + if endnotes.length > 0 + filename_fictionbook.puts %{</body><body name="notes">} + endnotes.each do |en| + filename_fictionbook.puts SiSU_TextUtils::Wrap.new(en,80,6).line_wrap + end + end + end + def structure_build_collapsed(data,endnotes,images_base64) + file=SiSU_Env::FileOp.new(@md) + filename_fictionbook=file.write_file.xml_fictionbook + h=0 + doc_position=:head + filename_fictionbook.puts head + data.each_with_index do |o,i| + ocn=(defined? o.ocn and not o.ocn.nil?) ? "\n#{Dx[:ocn_o]}#{o.ocn}#{Dx[:ocn_c]}" : '' + if o.is ==:heading + unless doc_position==:head + filename_fictionbook.puts structure_build_tag_close(o.lc,h) + end + doc_position=:body_and_tail + filename_fictionbook.puts %{#{space*o.lc}<#{tags.fictionbook[o.lc]}> +#{space*o.lc}<title> +} + filename_fictionbook.puts SiSU_TextUtils::Wrap.new("<p>#{o.obj}#{ocn}</p>",80,(o.lc*2+2)).line_wrap + filename_fictionbook.puts %{#{space*o.lc}</title>} + h=o.lc + elsif o.is ==:heading_insert \ + and o.obj =~/Endnotes/ \ + and o.ln == 1 + break + elsif (o.of ==:para or o.of ==:block) + filename_fictionbook.puts SiSU_TextUtils::Wrap.new("<p>#{o.obj}#{ocn}</p>",80,6).line_wrap + end + end + filename_fictionbook.puts structure_build_tag_close(0,h) + endnotes_build(endnotes,filename_fictionbook) + filename_fictionbook.puts tail(images_base64) + filename_fictionbook.close + end + def structure_build_tag_close(lc,h) + x=[] + case h + when 0 + x << "#{space*0}</#{tags.fictionbook[0]}>" if (lc <= 0) + when 1 + x << "#{space*1}</#{tags.fictionbook[1]}>" if (lc <= 1) + x << "#{space*0}</#{tags.fictionbook[0]}>" if (lc <= 0) + when 2 + x << "#{space*2}</#{tags.fictionbook[2]}>" if (lc <= 2) + x << "#{space*1}</#{tags.fictionbook[1]}>" if (lc <= 1) + x << "#{space*0}</#{tags.fictionbook[0]}>" if (lc <= 0) + when 3 + x << "#{space*3}</#{tags.fictionbook[3]}>" if (lc <= 3) + x << "#{space*2}</#{tags.fictionbook[2]}>" if (lc <= 2) + x << "#{space*1}</#{tags.fictionbook[1]}>" if (lc <= 1) + x << "#{space*0}</#{tags.fictionbook[0]}>" if (lc <= 0) + when 4 + x << "#{space*4}</#{tags.fictionbook[4]}>" if (lc <= 4) + x << "#{space*3}</#{tags.fictionbook[3]}>" if (lc <= 3) + x << "#{space*2}</#{tags.fictionbook[2]}>" if (lc <= 2) + x << "#{space*1}</#{tags.fictionbook[1]}>" if (lc <= 1) + x << "#{space*0}</#{tags.fictionbook[0]}>" if (lc <= 0) + when 5 + x << "#{space*5}</#{tags.fictionbook[5]}>" if (lc <= 5) + x << "#{space*4}</#{tags.fictionbook[4]}>" if (lc <= 4) + x << "#{space*3}</#{tags.fictionbook[3]}>" if (lc <= 3) + x << "#{space*2}</#{tags.fictionbook[2]}>" if (lc <= 2) + x << "#{space*1}</#{tags.fictionbook[1]}>" if (lc <= 1) + x << "#{space*0}</#{tags.fictionbook[0]}>" if (lc <= 0) + when 6 + x << "#{space*6}</#{tags.fictionbook[6]}>" if (lc <= 6) + x << "#{space*5}</#{tags.fictionbook[5]}>" if (lc <= 5) + x << "#{space*4}</#{tags.fictionbook[4]}>" if (lc <= 4) + x << "#{space*3}</#{tags.fictionbook[3]}>" if (lc <= 3) + x << "#{space*2}</#{tags.fictionbook[2]}>" if (lc <= 2) + x << "#{space*1}</#{tags.fictionbook[1]}>" if (lc <= 1) + x << "#{space*0}</#{tags.fictionbook[0]}>" if (lc <= 0) + end + x.join("\n") + end + end + end +end +__END__ diff --git a/lib/sisu/v4/xml_format.rb b/lib/sisu/v6/xml_format.rb index 316a4102..d310d0ca 100644 --- a/lib/sisu/v4/xml_format.rb +++ b/lib/sisu/v6/xml_format.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/xml_format.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/xml_format.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -297,30 +298,34 @@ WOK %{<p class="norm">#{@p_num.name}#{@headname}#{@dob.obj} </p>} + %{<p class="paranum"><font size="1" color="#777777"> #{@dob.ocn}</font></p>\n} end - def heading_body1 + def heading_body0 %{<h1 class="norm">#{@p_num.name}#{@headname}#{@dob.obj}</h1>} + %{<p class="paranum"><font size="1" color="#777777"> #{@dob.ocn}</font></p>\n} end - def heading_body2 + def heading_body1 %{<h2 class="norm">#{@p_num.name}#{@headname}#{@dob.obj}</h2>} + %{<p class="paranum"><font size="1" color="#777777"> #{@dob.ocn}</font></p>\n} end - def heading_body3 + def heading_body2 %{<h3 class="norm">#{@p_num.name}#{@headname}#{@dob.obj}</h3>} + %{<p class="paranum"><font size="1" color="#777777"> #{@dob.ocn}</font></p>\n} end - def heading_body4 + def heading_body3 %{<h4 class="norm">#{@p_num.name}#{@headname}#{@dob.obj}</h4>} + %{<p class="paranum"><font size="1" color="#777777"> #{@dob.ocn}</font></p>\n} end - def heading_body5 + def heading_body4 %{<h5 class="norm">#{@p_num.name}#{@headname}#{@dob.obj}</h5>} + %{<p class="paranum"><font size="1" color="#777777"> #{@dob.ocn}</font></p>\n} end - def heading_body6 + def heading_body5 %{<h6 class="norm">#{@p_num.name}#{@headname}#{@dob.obj}</h6>} + %{<p class="paranum"><font size="1" color="#777777"> #{@dob.ocn}</font></p>\n} end + def heading_body6 + %{<h7 class="norm">#{@p_num.name}#{@headname}#{@dob.obj}</h7>} + + %{<p class="paranum"><font size="1" color="#777777"> #{@dob.ocn}</font></p>\n} + end end class ParagraphNumber def initialize(md,ocn) @@ -1001,7 +1006,7 @@ WOK else nil end else - if @md.opt.cmd =~/M/ + if @md.opt.act[:maintenance][:set]==:on p __FILE__ << ':' << __LINE__.to_s p t_o.class p caller @@ -1089,6 +1094,9 @@ WOK def heading_body heading_normal('p','norm') end + def heading_body0 + heading_normal('h1','norm') + end def heading_body1 heading_normal('h1','norm') end diff --git a/lib/sisu/v4/xml_md_oai_pmh_dc.rb b/lib/sisu/v6/xml_md_oai_pmh_dc.rb index 1df57ccc..f3a6fae7 100644 --- a/lib/sisu/v4/xml_md_oai_pmh_dc.rb +++ b/lib/sisu/v6/xml_md_oai_pmh_dc.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/xml_md_oai_pmh_dc.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/xml_md_oai_pmh_dc.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> diff --git a/lib/sisu/v4/odf.rb b/lib/sisu/v6/xml_odf_odt.rb index adaaea87..bf9d8df8 100644 --- a/lib/sisu/v4/odf.rb +++ b/lib/sisu/v6/xml_odf_odt.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/odf.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/odf.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -59,17 +60,17 @@ ** Description: opendocument text generation =end -module SiSU_ODF +module SiSU_XML_ODF_ODT require_relative 'particulars' # particulars.rb include SiSU_Particulars - require_relative 'dal' # dal.rb + 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' @@ -81,17 +82,24 @@ module SiSU_ODF end def read begin - @md,@env,@dal_array=@particulars.md,@particulars.env,@particulars.dal_array - unless @opt.cmd =~/q/ - tool=(@opt.cmd =~/[MVv]/) \ + @md,@env,@ao_array=@particulars.md,@particulars.env,@particulars.ao_array + unless @opt.act[:quiet][:set]==:on + tool=(@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) \ ? "#{@env.program.odf_viewer} file://#{@md.file.output_path.odt.dir}/#{@md.file.base_filename.odt}" : "[#{@opt.f_pth[:lng_is]}] #{@opt.fno}" - @opt.cmd=~/[MVvz]/ \ - ? SiSU_Screen::Ansi.new(@opt.cmd,'Opendocument (ODF:ODT)',tool).green_hi_blue - : SiSU_Screen::Ansi.new(@opt.cmd,'Opendocument (ODF:ODT)',tool).green_title_hi - 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]/ + (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) \ + ? SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Opendocument (ODF:ODT)',tool).green_hi_blue + : SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Opendocument (ODF:ODT)',tool).green_title_hi + if (@opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) + 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__ @@ -102,26 +110,27 @@ 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 @@fns=nil def initialize(particulars) - @md,@env,@dal_array=particulars.md,particulars.env,particulars.dal_array + @md,@env,@ao_array=particulars.md,particulars.env,particulars.ao_array @vz=SiSU_Viz::Defaults.new @tab="\t" @brace_url=SiSU_Viz::Defaults.new.url_decoration - @br=(@md.opt.cmd =~/M/) ? '' : '' - #@br=(@md.opt.cmd =~/M/) ? "\n" : '' + @br=(@md.opt.act[:maintenance][:set]==:on) \ + ? '' : '' end def songsheet begin pre - @data=markup(@dal_array) + @data=markup(@ao_array) publish ensure - unless @md.opt.cmd =~/[MV]/ #check maintenance flag + unless (@md.opt.act[:verbose_plus][:set]==:on \ + || @md.opt.act[:maintenance][:set]==:on) if @env.processing_path.odt =~/od[ft]/ #p "rm -r #{@env.processing_path.odt}" if @md.opt.cmd =~/v/ FileUtils::rm_r(@env.processing_path.odf_pth) @@ -130,6 +139,10 @@ module SiSU_ODF end end end + def break_line + (@md.opt.act[:maintenance][:set]==:on) \ + ? "\n" : '' + end # Used for extraction of endnotes from paragraphs def extract_endnotes(dob='') notes=dob.obj.scan(/#{Mx[:en_a_o]}(\d+\s+.+?)#{Mx[:en_a_c]}/)[1] #FIX @@ -151,7 +164,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) @@ -164,12 +177,12 @@ module SiSU_ODF end def odf_tail manifest="#{@md.file.output_path.manifest.url}/#{@md.file.base_filename.manifest}" - @@odf[:tail] << %{<text:p text:style-name="P_normal">Available document outputs: <br /> <<text:a xlink:type="simple" xlink:href="#{manifest}">#{manifest}</text:a>></text:p>} - @@odf[:tail] << %{\n<text:p text:style-name="P_normal">SiSU: <<text:a xlink:type="simple" xlink:href="http://www.jus.uio.no/lm">www.jus.uio.no/sisu</text:a>> and <<text:a xlink:type="simple" xlink:href="http://www.sisudoc.org">www.sisudoc.org</text:a>></text:p>} + @@odf[:tail] << %{<text:p text:style-name="P_normal">Available document outputs: <br /> <<text:a xl:type="simple" xl:href="#{manifest}">#{manifest}</text:a>></text:p>} + @@odf[:tail] << %{\n<text:p text:style-name="P_normal">SiSU: <<text:a xl:type="simple" xl:href="http://www.jus.uio.no/lm">www.jus.uio.no/sisu</text:a>> and <<text:a xl:type="simple" xl:href="http://www.sisudoc.org">www.sisudoc.org</text:a>></text:p>} @@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) @@ -215,7 +228,7 @@ module SiSU_ODF if FileTest.file?("#{img_src}/#{i}") img_src else - SiSU_Screen::Ansi.new(@md.opt.cmd,"ERROR - image:",%{"#{i}" missing},"search locations: #{@env.path.image_source_include_local},#{@env.path.image_source_include_remote} and #{@env.path.image_source_include}").error2 unless @md.opt.cmd =~/q/ + SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],"ERROR - image:",%{"#{i}" missing},"search locations: #{@env.path.image_source_include_local},#{@env.path.image_source_include_remote} and #{@env.path.image_source_include}").error2 unless @md.opt.act[:quiet][:set]==:on nil end elsif @md.fns =~/\.ss[tm]$/ \ @@ -228,7 +241,7 @@ module SiSU_ODF and FileTest.file?("#{@env.path.image_source_include_remote}/#{i}") @env.path.image_source_include_remote else - SiSU_Screen::Ansi.new(@md.opt.cmd,"ERROR - image:",%{"#{i}" missing},"search locations: #{@env.path.image_source_include_local},#{@env.path.image_source_include_remote} and #{@env.path.image_source_include}").error2 unless @md.opt.cmd =~/q/ + SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],"ERROR - image:",%{"#{i}" missing},"search locations: #{@env.path.image_source_include_local},#{@env.path.image_source_include_remote} and #{@env.path.image_source_include}").error2 unless @md.opt.act[:quiet][:set]==:on nil end end @@ -254,7 +267,7 @@ module SiSU_ODF and h.to_s =~/\d/ \ and w.to_s =~/\d/ @@img_count +=1 - %{<draw:frame draw:style-name="fr1" draw:name="graphics#{@@img_count}" text:anchor-type="as-char" svg:width="#{w}cm" svg:height="#{h}cm" draw:z-index="2"><draw:image xlink:href="Pictures/#{i}" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/></draw:frame>#{c}} #anchor-type: as-char or paragraph or char or ... + %{<draw:frame draw:style-name="fr1" draw:name="graphics#{@@img_count}" text:anchor-type="as-char" svg:width="#{w}cm" svg:height="#{h}cm" draw:z-index="2"><draw:image xl:href="Pictures/#{i}" xl:type="simple" xl:show="embed" xl:actuate="onLoad"/></draw:frame>#{c}} #anchor-type: as-char or paragraph or char or ... else %{<text:p text:style-name="P_normal">[image omitted]</text:p>} end end @@ -284,13 +297,13 @@ module SiSU_ODF 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}} + %{<text:a xl:type="simple" xl:href="#{url}">#{txt.strip}</text:a>#{trail}} when /^:/ # site same document collection html link url=url.gsub(/^:/,"#{@env.url.root}/") - %{<text:a xlink:type="simple" xlink:href="#{url}">#{txt.strip}</text:a>#{trail}} + %{<text:a xl:type="simple" xl:href="#{url}">#{txt.strip}</text:a>#{trail}} when /^\.\.\// # site same document collection html link url=url.gsub(/^\.\.\//,"#{@env.url.root}/") - %{<text:a xlink:type="simple" xlink:href="#{url}">#{txt.strip}</text:a>#{trail}} + %{<text:a xl:type="simple" xl:href="#{url}">#{txt.strip}</text:a>#{trail}} else # document internal link if map_nametags[url] \ and map_nametags[url][:segname] @@ -298,7 +311,7 @@ module SiSU_ODF end t=map_nametags[url] \ && map_nametags[url][:segname] \ - ? %{<text:a xlink:type="simple" xlink:href="#{@env.url.root}/#{@md.fnb}/#{map_nametags[url][:segname]}#{Sfx[:html]}##{url}">#{txt.strip}</text:a>#{trail}} + ? %{<text:a xl:type="simple" xl:href="#{@env.url.root}/#{@md.fnb}/#{map_nametags[url][:segname]}#{Sfx[:html]}##{url}">#{txt.strip}</text:a>#{trail}} : %{#{txt.strip}#{trail}} end t @@ -353,11 +366,11 @@ module SiSU_ODF def normal(dob,p_num) #P1 - P3 dob=footnote(dob) 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 + '<text:a xl:type="simple" xl: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}}). + %{#{@brace_url.xml_open}<text:a xl:type="simple" xl: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 + %{#{@brace_url.xml_open}<text:a xl:type="simple" xl: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 @@ -374,7 +387,7 @@ module SiSU_ODF end def footnote_urls(str) 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}}) + %{#{@brace_url.xml_open}<text:a xl:type="simple" xl: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]}/ str @@ -443,15 +456,15 @@ module SiSU_ODF def group(dob,p_num) #P4 #same as verse parray=[] 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 + '<text:a xl:type="simple" xl: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}}). + %{#{@brace_url.xml_open}<text:a xl:type="simple" xl: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 + %{#{@brace_url.xml_open}<text:a xl:type="simple" xl:href="\\1">\\1</text:a>#{@brace_url.xml_close}}) #http ftp matches with decoration dob.obj.split(/#{Mx[:br_line]}|#{Mx[:br_nl]}/).each_with_index do |parablock,i| set_ref=(i==0) ? "#{p_num[:set_ref]}#{set_bookmark_tag(dob)}" : '' parablock=group_clean(parablock) - parablock=parablock.gsub(/<text:a xlink:type="simple" xlink:href="(.+?)">/m,'<text:a xlink:type="simple" xlink:href="\1">'). + parablock=parablock.gsub(/<text:a xl:type="simple" xl:href="(.+?)">/m,'<text:a xl:type="simple" xl:href="\1">'). gsub(/<(\/text:a)>/,'<\1>'). gsub(/<(text:note text:id=.+?)>/,'<\1>'). gsub(/<(text:p text:style-name="Footnote")>/,'<\1>'). @@ -467,15 +480,15 @@ module SiSU_ODF def block(dob,p_num) #P4 #same as verse parray=[] 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 + '<text:a xl:type="simple" xl: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}}). + %{#{@brace_url.xml_open}<text:a xl:type="simple" xl: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 + %{#{@brace_url.xml_open}<text:a xl:type="simple" xl:href="\\1">\\1</text:a>#{@brace_url.xml_close}}) #http ftp matches with decoration dob.obj.split(/#{Mx[:br_line]}|#{Mx[:br_nl]}/).each_with_index do |parablock,i| set_ref=(i==0) ? "#{p_num[:set_ref]}#{set_bookmark_tag(dob)}" : '' parablock=group_clean(parablock) - parablock=parablock.gsub(/<text:a xlink:type="simple" xlink:href="(.+?)">/m,'<text:a xlink:type="simple" xlink:href="\1">'). + parablock=parablock.gsub(/<text:a xl:type="simple" xl:href="(.+?)">/m,'<text:a xl:type="simple" xl:href="\1">'). gsub(/<(\/text:a)>/,'<\1>'). gsub(/<(text:note text:id=.+?)>/,'<\1>'). gsub(/<(text:p text:style-name="Footnote")>/,'<\1>'). @@ -497,7 +510,7 @@ module SiSU_ODF parablock=group_clean(parablock) 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 + '<text:a xl:type="simple" xl:href="\1">\1</text:a>') #http ftp matches escaped, no decoration parray << %{<text:p text:style-name="P_code">#{set_ref}#{parablock}</text:p>} if parablock =~/\S+/ end dob.obj=parray.join \ @@ -509,14 +522,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 @@ -539,33 +552,34 @@ module SiSU_ODF end p_num={ display: '', set_ref: '' } if dob.is !~/(^#{Rx[:meta]}|#{Mx[:br_eof]}|#{Mx[:br_endnotes]})/ - 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_ODF_Format::ParagraphNumber.new(dob.ocn).set_ref_and_display + if @env.odt_ocn? + if defined? dob.ocn \ + and dob.ocn.is_a?(Fixnum) + p_num=SiSU_XML_ODF_ODT_Format::ParagraphNumber.new(dob.ocn).set_bookmark_and_display + end end end if dob.is==:heading - @@odf[:body] << heading(dob,p_num).obj << @br*2 + @@odf[:body] << heading(dob,p_num).obj << break_line*2 if SiSU_Env::ProcessingSettings.new(md).build.toc? if dob.lv =~/[A-C1]/i @@odf[:toc] << toc(dob,p_num).obj end end elsif dob.is ==:verse - @@odf[:body] << poem(dob,p_num).obj << @br*2 + @@odf[:body] << poem(dob,p_num).obj << break_line*2 elsif dob.is==:group - @@odf[:body] << group(dob,p_num).obj << @br*2 + @@odf[:body] << group(dob,p_num).obj << break_line*2 elsif dob.is==:block - @@odf[:body] << block(dob,p_num).obj << @br*2 + @@odf[:body] << block(dob,p_num).obj << break_line*2 elsif dob.is==:code - @@odf[:body] << code(dob,p_num).obj << @br*2 + @@odf[:body] << code(dob,p_num).obj << break_line*2 elsif dob.is==:table #elsif dob.obj =~ /<!Th?¡/u - @@odf[:body] << table(dob,p_num).obj << @br*2 + @@odf[:body] << table(dob,p_num).obj << break_line*2 elsif dob.is==:break - @@odf[:body] << obj_break(dob).obj << @br*2 + @@odf[:body] << obj_break(dob).obj << break_line*2 else - @@odf[:body] << normal(dob,p_num).obj << @br*2 # main text, contents, body KEEP + @@odf[:body] << normal(dob,p_num).obj << break_line*2 # main text, contents, body KEEP end @@endnotes_para=[] end @@ -629,7 +643,7 @@ module SiSU_ODF 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='<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 xl:href="Pictures/bullet_09.png" xl:type="simple" xl:show="embed" xl:actuate="onLoad"/></draw:frame> ' + dob.obj end dob.obj=dob.obj.gsub(/#{Mx[:br_line]}/,'<br />'). @@ -664,7 +678,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 \ @@ -712,13 +726,13 @@ module SiSU_ODF <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=x.strip - x=x.gsub(/\n+/m,'') unless @md.opt.cmd=~/M/ + x=x.gsub(/\n+/m,'') unless @md.opt.act[:maintenance][:set]==:on x else '' end x=<<WOK <?xml version="1.0" encoding="UTF-8"?> -<office:document-content xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rpt="http://openoffice.org/2005/report" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:grddl="http://www.w3.org/2003/g/data-view#" xmlns:tableooo="http://openoffice.org/2009/table" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:css3t="http://www.w3.org/TR/css3-text/" office:version="1.2"><office:scripts/> +<office:document-content xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xl="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rpt="http://openoffice.org/2005/report" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:grddl="http://www.w3.org/2003/g/data-view#" xmlns:tableooo="http://openoffice.org/2009/table" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:css3t="http://www.w3.org/TR/css3-text/" office:version="1.2"><office:scripts/> <office:font-face-decls><style:font-face style:name="DejaVu Sans Mono" svg:font-family="'DejaVu Sans Mono'" style:font-adornments="Book" style:font-family-generic="modern" style:font-pitch="fixed"/><style:font-face style:name="Inconsolata" svg:font-family="Inconsolata" style:font-adornments="Regular" style:font-pitch="fixed"/><style:font-face style:name="Liberation Mono" svg:font-family="'Liberation Mono'" style:font-adornments="Regular" style:font-family-generic="modern" style:font-pitch="fixed"/><style:font-face style:name="DejaVu Sans" svg:font-family="'DejaVu Sans'" style:font-adornments="ExtraLight" style:font-family-generic="swiss" style:font-pitch="variable"/><style:font-face style:name="Nimbus Sans L" svg:font-family="'Nimbus Sans L'" style:font-pitch="variable"/><style:font-face style:name="Tahoma" svg:font-family="Tahoma, Lucidasans, 'Lucida Sans', 'Arial Unicode MS'" style:font-pitch="variable"/><style:font-face style:name="Nimbus Roman No9 L" svg:font-family="'Nimbus Roman No9 L'" style:font-family-generic="roman" style:font-pitch="variable"/><style:font-face style:name="Bitstream Vera Sans" svg:font-family="'Bitstream Vera Sans'" style:font-family-generic="swiss" style:font-pitch="variable"/></office:font-face-decls> <office:automatic-styles> #{table} @@ -730,7 +744,7 @@ WOK <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=x.strip - x=x.gsub(/\n+/m,'') unless @md.opt.cmd=~/M/ + x=x.gsub(/\n+/m,'') unless @md.opt.act[:maintenance][:set]==:on @@odf[:head] << x end def publish @@ -745,7 +759,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 @@ -756,7 +770,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/v4/odf_format.rb b/lib/sisu/v6/xml_odf_odt_format.rb index 79f68478..bc7fadea 100644 --- a/lib/sisu/v4/odf_format.rb +++ b/lib/sisu/v6/xml_odf_odt_format.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/odf_format.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/odf_format.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -59,7 +60,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 @@ -170,30 +171,34 @@ module SiSU_ODF_Format @@fns=@md.fns end end + def break_line + (@md.opt.act[:maintenance][:set]==:on) \ + ? "\n" : '' + end def table_head_open(count) type=(@dob.head_) \ ? 1 : 2 alpha=case @dob.cols - when 1; 'A' - when 2; 'B' - when 3; 'C' - when 4; 'D' - when 5; 'E' - when 6; 'F' - when 7; 'G' - when 8; 'H' - when 9; 'I' - when 10; 'J' - when 11; 'K' - when 12; 'L' - when 13; 'M' - when 14; 'N' - else 'D' + when 1 then 'A' + when 2 then 'B' + when 3 then 'C' + when 4 then 'D' + when 5 then 'E' + when 6 then 'F' + when 7 then 'G' + when 8 then 'H' + when 9 then 'I' + when 10 then 'J' + when 11 then 'K' + when 12 then 'L' + when 13 then 'M' + when 14 then 'N' + else 'D' end - tag=SiSU_ODF_Format::Tags.new.set_bookmark_tag(@dob) - %{<table:table table:name="Table#{count}" table:style-name="Table#{type}">#{@p_num[:set_ref]}#{tag}#{@br}} + - %{<table:table-column table:style-name="Table#{type}.#{alpha}" table:number-columns-repeated="#{@dob.cols}"/>#{@br}} + 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 def table_close(tablefoot='') '</table:table>' \ @@ -206,16 +211,16 @@ module SiSU_ODF_Format else 'P_table_cell' end str=str.gsub(/^~$/,'') # tilde / empty cell - %{<table:table-cell office:value-type="string">#{@br}} + - %{<text:p text:style-name="#{txt_name_cell}">#{@br}} + + %{<table:table-cell office:value-type="string">#{break_line}} + + %{<text:p text:style-name="#{txt_name_cell}">#{break_line}} + %{#{str}} + - %{</text:p>#{@br}} + - %{</table:table-cell>#{@br}} + %{</text:p>#{break_line}} + + %{</table:table-cell>#{break_line}} end def table_tag_row(str,i) - %{<table:table-row>#{@br}} + + %{<table:table-row>#{break_line}} + %{#{str}} + - %{</table:table-row>#{@br}} + %{</table:table-row>#{break_line}} end def table_tag_row_dump(str,i) txt_name_row=if i==0 \ @@ -223,13 +228,13 @@ module SiSU_ODF_Format 'Table_Heading' else 'P_table_cell' end - %{<table:table-row>#{@br}} + - %{<table:table-cell office:value-type="string">#{@br}} + - %{<text:p text:style-name="#{txt_name_row}">#{@br}} + + %{<table:table-row>#{break_line}} + + %{<table:table-cell office:value-type="string">#{break_line}} + + %{<text:p text:style-name="#{txt_name_row}">#{break_line}} + %{#{str}} + - %{</text:p>#{@br}} + - %{</table:table-cell>#{@br}} + - %{</table:table-row>#{@br}} + %{</text:p>#{break_line}} + + %{</table:table-cell>#{break_line}} + + %{</table:table-row>#{break_line}} end def table_row(row,i) row='' if row =~/^<!$/ @@ -282,7 +287,7 @@ module SiSU_ODF_Format </rdf:RDF> WOK x=x.strip - x=x.gsub(/\n+/m,'') unless @md.opt.cmd=~/M/ + x=x.gsub(/\n+/m,'') unless @md.opt.act[:maintenance][:set]==:on x end def meta_inf_manifest_xml(md) @@ -312,13 +317,13 @@ WOK </manifest:manifest> WOK x=x.strip - x=x.gsub(/\n+/m,'') unless @md.opt.cmd=~/M/ + x=x.gsub(/\n+/m,'') unless @md.opt.act[:maintenance][:set]==:on x end def meta_xml x=<<WOK <?xml version="1.0" encoding="UTF-8"?> -<office:document-meta xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:grddl="http://www.w3.org/2003/g/data-view#" office:version="1.2"> +<office:document-meta xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:xl="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:grddl="http://www.w3.org/2003/g/data-view#" office:version="1.2"> <office:meta> <meta:generator>#{@generator}</meta:generator> <meta:creation-date>#{@md.generated}</meta:creation-date> @@ -328,13 +333,13 @@ WOK </office:document-meta> WOK x=x.strip - x=x.gsub(/\n+/m,'') unless @md.opt.cmd=~/M/ + x=x.gsub(/\n+/m,'') unless @md.opt.act[:maintenance][:set]==:on x end def settings_xml x=<<WOK <?xml version="1.0" encoding="UTF-8"?> -<office:document-settings xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:ooo="http://openoffice.org/2004/office" office:version="1.2"> +<office:document-settings xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:xl="http://www.w3.org/1999/xlink" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:ooo="http://openoffice.org/2004/office" office:version="1.2"> <office:settings> <config:config-item-set config:name="ooo:view-settings"> <config:config-item config:name="ViewAreaTop" config:type="int">0</config:config-item> @@ -431,13 +436,13 @@ WOK </office:document-settings> WOK x=x.strip - x=x.gsub(/\n+/m,'') unless @md.opt.cmd=~/M/ + x=x.gsub(/\n+/m,'') unless @md.opt.act[:maintenance][:set]==:on x end def styles_xml x=<<WOK <?xml version="1.0" encoding="UTF-8"?> -<office:document-styles xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:rpt="http://openoffice.org/2005/report" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:grddl="http://www.w3.org/2003/g/data-view#" xmlns:tableooo="http://openoffice.org/2009/table" xmlns:css3t="http://www.w3.org/TR/css3-text/" office:version="1.2"> +<office:document-styles xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xl="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:rpt="http://openoffice.org/2005/report" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:grddl="http://www.w3.org/2003/g/data-view#" xmlns:tableooo="http://openoffice.org/2009/table" xmlns:css3t="http://www.w3.org/TR/css3-text/" office:version="1.2"> <office:font-face-decls> <style:font-face style:name="DejaVu Sans Mono" svg:font-family="'DejaVu Sans Mono'" style:font-adornments="Book" style:font-family-generic="modern" style:font-pitch="fixed"/> <style:font-face style:name="Nimbus Sans L" svg:font-family="'Nimbus Sans L'" style:font-pitch="variable"/> @@ -632,7 +637,7 @@ WOK </office:document-styles> WOK x=x.strip - x=x.gsub(/\n+/m,'') unless @md.opt.cmd=~/M/ + x=x.gsub(/\n+/m,'') unless @md.opt.act[:maintenance][:set]==:on x end def mimetype diff --git a/lib/sisu/v4/xml.rb b/lib/sisu/v6/xml_sax.rb index 106b1ed3..53a258dc 100644 --- a/lib/sisu/v4/xml.rb +++ b/lib/sisu/v6/xml_sax.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/xml.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/xml.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -66,7 +67,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 @@ -82,16 +83,24 @@ module SiSU_XML_SAX end def read begin - @env,@md,@dal_array=@particulars.env,@particulars.md,@particulars.dal_array - unless @opt.cmd =~/q/ - tool=if @opt.cmd =~/[MV]/; "#{@env.program.web_browser} file://#{@md.file.output_path.xml_sax.dir}/#{@md.file.base_filename.xml_sax}\n\t#{@env.program.xml_viewer} file://#{@md.file.output_path.xml_sax.dir}/#{@md.file.base_filename.xml_sax}" - elsif @opt.cmd =~/v/; "#{@env.program.web_browser} file://#{@md.file.output_path.xml_sax.dir}/#{@md.file.base_filename.xml_sax}" + @env,@md,@ao_array=@particulars.env,@particulars.md,@particulars.ao_array + unless @opt.act[:quiet][:set]==:on + tool=if (@opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) + "#{@env.program.web_browser} file://#{@md.file.output_path.xml_sax.dir}/#{@md.file.base_filename.xml_sax}\n\t#{@env.program.xml_viewer} file://#{@md.file.output_path.xml_sax.dir}/#{@md.file.base_filename.xml_sax}" + elsif @opt.act[:verbose][:set]==:on + "#{@env.program.web_browser} file://#{@md.file.output_path.xml_sax.dir}/#{@md.file.base_filename.xml_sax}" else "[#{@opt.f_pth[:lng_is]}] #{@opt.fno}" end - @opt.cmd=~/[MVvz]/ \ - ? SiSU_Screen::Ansi.new(@opt.cmd,'XML SAX',tool).green_hi_blue - : SiSU_Screen::Ansi.new(@opt.cmd,'XML SAX',tool).green_title_hi - 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]/ + (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) \ + ? SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'XML SAX',tool).green_hi_blue + : SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'XML SAX',tool).green_title_hi + if (@opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],@opt.fns,"file://#{@md.file.output_path.xml_sax.dir}/#{@md.file.base_filename.xml_sax}").flow + end end SiSU_XML_SAX::Source::Songsheet.new(@particulars).song rescue @@ -106,14 +115,18 @@ module SiSU_XML_SAX private class Songsheet def initialize(particulars) - @env,@md,@dal_array,@particulars=particulars.env,particulars.md,particulars.dal_array,particulars + @env,@md,@ao_array,@particulars=particulars.env,particulars.md,particulars.ao_array,particulars @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 + if (@md.opt.act[:verbose][:set]==:on \ + || @md.opt.act[:verbose_plus][:set]==:on \ + || @md.opt.act[:maintenance][:set]==:on) + SiSU_XML_SAX::Source::Tidy.new(@md,@file.place_file.xml_sax.dir).xml # test wellformedness, comment out when not in use + end + SiSU_Rexml::Rexml.new(@md,@file.place_file.xml_sax.dir).xml if @md.opt.act[:maintenance][:set]==:on # test rexml parsing, comment out when not in use #debug rescue SiSU_Errors::Rescued.new($!,$@,@md.opt.cmd,@md.fns).location do __LINE__.to_s + ':' + __FILE__ @@ -123,20 +136,20 @@ 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,@dal_array=particulars.env,particulars.md,particulars.dal_array + @env,@md,@ao_array=particulars.env,particulars.md,particulars.ao_array @vz=SiSU_Viz::Defaults.new @trans=SiSU_XML_Munge::Trans.new(@md) @sys=SiSU_Env::SystemCall.new end def songsheet pre - @data=markup(@dal_array) + @data=markup(@ao_array) post publish end @@ -329,12 +342,12 @@ WOK if dob.is==:heading xml_structure(dob) dob.obj=case dob.ln - when 1; x.heading_body1 - when 2; x.heading_body2 - when 3; x.heading_body3 - when 4; x.heading_body4 - when 5; x.heading_body5 - when 6; x.heading_body6 + when 1 then x.heading_body1 + when 2 then x.heading_body2 + when 3 then x.heading_body3 + when 4 then x.heading_body4 + when 5 then x.heading_body5 + when 6 then x.heading_body6 end else if dob.is==:verse @@ -453,16 +466,17 @@ WOK end def xml if @prog.tidy !=false #note values can be other than true - if @md.opt.cmd =~/[VM]/ - unless @md.opt.cmd =~/q/ - SiSU_Screen::Ansi.new(@md.opt.cmd,'invert','Using XML Tidy','check document structure').colorize - tell=SiSU_Screen::Ansi.new(@md.opt.cmd,'invert','','') + if (@md.opt.act[:verbose_plus][:set]==:on \ + || @md.opt.act[:maintenance][:set]==:on) + unless @md.opt.act[:quiet][:set]==:on + SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],'invert','Using XML Tidy','check document structure').colorize + tell=SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],'invert','','') tell.grey_open end tidyfile='/dev/null' #don't want one or screen output, check for alternative flags tidy=SiSU_Env::SystemCall.new(@file,tidyfile) tidy.well_formed? - tell.p_off unless @md.opt.cmd =~/q/ + tell.p_off unless @md.opt.act[:quiet][:set]==:on end end end diff --git a/lib/sisu/v6/xml_scaffold_structure_collapsed.rb b/lib/sisu/v6/xml_scaffold_structure_collapsed.rb new file mode 100644 index 00000000..23bc4f4c --- /dev/null +++ b/lib/sisu/v6/xml_scaffold_structure_collapsed.rb @@ -0,0 +1,203 @@ +# 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, 2014 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/v6/xml_scaffold.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_Scaffold_Structure_Collapse + require_relative 'particulars' # particulars.rb + include SiSU_Particulars + require_relative 'ao' # ao.rb + require_relative 'sysenv' # sysenv.rb + include SiSU_Env + class Source + def initialize(opt) + @opt=opt + @particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt) + @sp=' ' + end + def read + begin + @md,@ao_array=@particulars.md,@particulars.ao_array + SiSU_XML_Scaffold_Structure_Collapse::Source::Scroll.new(@ao_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 + @sp=' ' + end + def songsheet + @t='sisu' + data=@data + if @md.opt.act[:verbose_plus][:set]==:on + structure_collapsed(data) + end + structure_build_collapsed(data) + end + def tags + # collapsed --> + def collapsed + [ '0', + '1', + '2', + '3', + '4', + '5', + '6' + ] + end + def docbook + end + def fictionbook + end + self + end + def output(o,lev=nil,comment='') + puts lev == 0..6 \ + ? "#{@sp*lev}<#{lev}>[#{o.ocn}] #{o.ln} #{o.obj}</#{lev}>#{comment}" + : "<#{lev}>[#{o.ocn}] #{o.ln} #{o.obj}</#{lev}>#{comment}" + end + def structure_collapsed(data) + puts "\ncollapsed structure, heading outline --->\n\n" + data.each_with_index do |o,i| + if (o.is ==:heading || o.is ==:heading_insert) + output(o,o.lc) + end + end + end + def structure_build_collapsed(data) + @s=tags.collapsed + puts "\nXML [#{@t} type] structure outline --->\n\n" + h=[0,false,false,false] + puts "<#{@s[0]}>" + data.each_with_index do |o,i| + if (o.is ==:heading || o.is ==:heading_insert) + lev=o.lc + structure_build_tag_close(lev,h) + puts "#{@sp*lev}<#{@s[lev]}>\n#{@sp*lev} [#{o.ocn}] #{lev} {#{o.node}}" + h[0]=lev + end + end + structure_build_tag_close(0,h) + end + def structure_build_tag_close(lev,h) + case h[0] + when 1 + puts "#{@sp*1}</#{@s[1]}>" if (lev <= 1) + puts "</#{@s[0]}>" if (lev==0) + when 2 + puts "#{@sp*2}</#{@s[2]}>" if (lev <= 2) + puts "#{@sp*1}</#{@s[1]}>" if (lev <= 1) + puts "</#{@s[0]}>" if (lev==0) + when 3 + puts "#{@sp*3}</#{@s[3]}>" if (lev <= 3) + puts "#{@sp*2}</#{@s[2]}>" if (lev <= 2) + puts "#{@sp*1}</#{@s[1]}>" if (lev <= 1) + puts "</#{@s[0]}>" if (lev==0) + when 4 + puts "#{@sp*4}</#{@s[4]}>" if (lev <= 4) + puts "#{@sp*3}</#{@s[3]}>" if (lev <= 3) + puts "#{@sp*2}</#{@s[2]}>" if (lev <= 2) + puts "#{@sp*1}</#{@s[1]}>" if (lev <= 1) + puts "</#{@s[0]}>" if (lev==0) + when 5 + puts "#{@sp*5}</#{@s[5]}>" if (lev <= 5) + puts "#{@sp*4}</#{@s[4]}>" if (lev <= 4) + puts "#{@sp*3}</#{@s[3]}>" if (lev <= 3) + puts "#{@sp*2}</#{@s[2]}>" if (lev <= 2) + puts "#{@sp*1}</#{@s[1]}>" if (lev <= 1) + puts "</#{@s[0]}>" if (lev==0) + when 6 + puts "#{@sp*6}</#{@s[6]}>" if (lev <= 6) + puts "#{@sp*5}</#{@s[5]}>" if (lev <= 5) + puts "#{@sp*4}</#{@s[4]}>" if (lev <= 4) + puts "#{@sp*3}</#{@s[3]}>" if (lev <= 3) + puts "#{@sp*2}</#{@s[2]}>" if (lev <= 2) + puts "#{@sp*1}</#{@s[1]}>" if (lev <= 1) + puts "</#{@s[0]}>" if (lev==0) + end + end + end + end +end +__END__ +@s=['0', + 'A', + 'B', + 'C', + '1', + '2', + '3' +] +#@t='docbook' #@t='fictionbook' +#@s=['book', #@s=['body', +# 'part', # 'section', +# 'subpart N/A', # 'section', +# 'sub-subpart N/A', # 'section', +# 'chapter', # 'section', +# 'sect1', # 'section', +# 'sect2' # 'section' +#] #] diff --git a/lib/sisu/v4/xml_scaffold.rb b/lib/sisu/v6/xml_scaffold_structure_sisu.rb index 0608a17f..075a00ee 100644 --- a/lib/sisu/v4/xml_scaffold.rb +++ b/lib/sisu/v6/xml_scaffold_structure_sisu.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/xml_scaffold.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/xml_scaffold.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -59,10 +60,10 @@ ** Description: extract and print an XML rendition of document structure to screen =end -module SiSU_XML_Scaffold +module SiSU_XML_Scaffold_Structure_Sisu require_relative 'particulars' # particulars.rb include SiSU_Particulars - require_relative 'dal' # dal.rb + require_relative 'ao' # ao.rb require_relative 'sysenv' # sysenv.rb include SiSU_Env class Source @@ -73,8 +74,8 @@ module SiSU_XML_Scaffold end def read begin - @md,@dal_array=@particulars.md,@particulars.dal_array - SiSU_XML_Scaffold::Source::Scroll.new(@dal_array,@md).songsheet + @md,@ao_array=@particulars.md,@particulars.ao_array + SiSU_XML_Scaffold_Structure_Sisu::Source::Scroll.new(@ao_array,@md).songsheet rescue SiSU_Errors::Rescued.new($!,$@,@opt.cmd,@opt.fns).location do __LINE__.to_s + ':' + __FILE__ @@ -90,72 +91,56 @@ module SiSU_XML_Scaffold end def songsheet @t='sisu' - @s=['0', - 'A', - 'B', - 'C', - '1', - '2', - '3' - ] - #@t='docbook' #@t='fictionbook' - #@s=['book', #@s=['body', - # 'part', # 'section', - # 'subpart N/A', # 'section', - # 'sub-subpart N/A', # 'section', - # 'chapter', # 'section', - # 'sect1', # 'section', - # 'sect2' # 'section' - #] #] data=@data - structure_outline(data) if @md.opt.cmd =~/V/ - structure_simple(data) if @md.opt.cmd =~/V/ - structure_build(data) + if @md.opt.act[:verbose_plus][:set]==:on + structure_sisu_simple(data) + end + structure_build_sisu(data) end - def structure_outline(data) - puts "\ninfo outline --->\n\n" - data.each do |o| - puts "#{o.ocn} #{o.ln} #{o.obj}" if (o.is ==:heading || o.is ==:heading_insert) + def tags + def sisu + [ '0', + 'A', + 'B', + 'C', + '1', + '2', + '3' + ] end + self end - def structure_simple(data) - puts "\nheading outline --->\n\n" + def structure_sisu_simple(data) + puts "\nsisu structure, heading outline --->\n\n" data.each_with_index do |o,i| - if (o.is ==:heading || o.is ==:heading_insert); puts "<#{@s[o.ln]}>#{o.ocn} #{o.ln} #{o.obj}</#{@s[o.ln]}>" + if (o.is ==:heading || o.is ==:heading_insert) + puts "#{@sp*o.ln}<#{tags.sisu[o.ln]}>[#{o.ocn}] #{o.ln} #{o.obj}</#{tags.sisu[o.ln]}>" end end end - def structure_build(data) + def output(o,lev=nil,comment='') + puts lev == 0..6 \ + ? "#{@sp*lev}<#{lev}>[#{o.ocn}] #{o.ln} #{o.obj}</#{lev}>#{comment}" + : "<#{lev}>[#{o.ocn}] #{o.ln} #{o.obj}</#{lev}>#{comment}" + end + def structure_build_sisu(data) + @s=tags.sisu puts "\nXML [#{@t} type] structure outline --->\n\n" h=[0,false,false,false] puts "<#{@s[0]}>" data.each_with_index do |o,i| if (o.is ==:heading || o.is ==:heading_insert) + structure_build_tag_close(o.ln,h) + puts "#{@sp*o.ln}<#{@s[o.ln]}>\n#{@sp*o.ln} [#{o.ocn}] #{o.ln} {#{o.node}}" case o.ln when 1 - structure_build_tag_close(o.ln,h) - puts "#{@sp*1}<#{@s[1]}>\n#{@sp*1} #{o.ocn} #{o.ln} #{o.node}" - h=[1,true,false,false] + h=[o.ln,true,false,false] when 2 - structure_build_tag_close(o.ln,h) - puts "#{@sp*2}<#{@s[2]}>\n#{@sp*2} #{o.ocn} #{o.ln} #{o.node}" - h=[2,true,true,false] + h=[o.ln,true,true,false] when 3 - structure_build_tag_close(o.ln,h) - puts "#{@sp*3}<#{@s[3]}>\n#{@sp*3} #{o.ocn} #{o.ln} #{o.node}" - h=[3,true,true,true] - when 4 - structure_build_tag_close(o.ln,h) - puts "#{@sp*4}<#{@s[4]}>\n#{@sp*4} #{o.ocn} #{o.ln} #{o.node}" - h[0]=4 - when 5 - structure_build_tag_close(o.ln,h) - puts "#{@sp*5}<#{@s[5]}>\n#{@sp*5} #{o.ocn} #{o.ln} #{o.node}" - h[0]=5 - when 6 - structure_build_tag_close(o.ln,h) - puts "#{@sp*6}<#{@s[6]}>\n#{@sp*6} #{o.ocn} #{o.ln} #{o.node}" - h[0]=6 + h=[o.ln,true,true,true] + when 4..6 + h[0]=o.ln end end end @@ -164,37 +149,37 @@ module SiSU_XML_Scaffold def structure_build_tag_close(lev,h) case h[0] when 1 - puts "#{@sp*1}</#{@s[1]}>" if (lev <= 1) and h[1] + puts "#{@sp*1}</#{@s[1]}>" if (lev <= 1) && h[1] puts "</#{@s[0]}>" if (lev==0) when 2 - puts "#{@sp*2}</#{@s[2]}>" if (lev <= 2) and h[2] - puts "#{@sp*1}</#{@s[1]}>" if (lev <= 1) and h[1] + puts "#{@sp*2}</#{@s[2]}>" if (lev <= 2) && h[2] + puts "#{@sp*1}</#{@s[1]}>" if (lev <= 1) && h[1] puts "</#{@s[0]}>" if (lev==0) when 3 - puts "#{@sp*3}</#{@s[3]}>" if (lev <= 3) and h[3] - puts "#{@sp*2}</#{@s[2]}>" if (lev <= 2) and h[2] - puts "#{@sp*1}</#{@s[1]}>" if (lev <= 1) and h[1] + puts "#{@sp*3}</#{@s[3]}>" if (lev <= 3) && h[3] + puts "#{@sp*2}</#{@s[2]}>" if (lev <= 2) && h[2] + puts "#{@sp*1}</#{@s[1]}>" if (lev <= 1) && h[1] puts "</#{@s[0]}>" if (lev==0) when 4 puts "#{@sp*4}</#{@s[4]}>" if (lev <= 4) - puts "#{@sp*3}</#{@s[3]}>" if (lev <= 3) and h[3] - puts "#{@sp*2}</#{@s[2]}>" if (lev <= 2) and h[2] - puts "#{@sp*1}</#{@s[1]}>" if (lev <= 1) and h[1] + puts "#{@sp*3}</#{@s[3]}>" if (lev <= 3) && h[3] + puts "#{@sp*2}</#{@s[2]}>" if (lev <= 2) && h[2] + puts "#{@sp*1}</#{@s[1]}>" if (lev <= 1) && h[1] puts "</#{@s[0]}>" if (lev==0) when 5 puts "#{@sp*5}</#{@s[5]}>" if (lev <= 5) puts "#{@sp*4}</#{@s[4]}>" if (lev <= 4) - puts "#{@sp*3}</#{@s[3]}>" if (lev <= 3) and h[3] - puts "#{@sp*2}</#{@s[2]}>" if (lev <= 2) and h[2] - puts "#{@sp*1}</#{@s[1]}>" if (lev <= 1) and h[1] + puts "#{@sp*3}</#{@s[3]}>" if (lev <= 3) && h[3] + puts "#{@sp*2}</#{@s[2]}>" if (lev <= 2) && h[2] + puts "#{@sp*1}</#{@s[1]}>" if (lev <= 1) && h[1] puts "</#{@s[0]}>" if (lev==0) when 6 puts "#{@sp*6}</#{@s[6]}>" if (lev <= 6) puts "#{@sp*5}</#{@s[5]}>" if (lev <= 5) puts "#{@sp*4}</#{@s[4]}>" if (lev <= 4) - puts "#{@sp*3}</#{@s[3]}>" if (lev <= 3) and h[3] - puts "#{@sp*2}</#{@s[2]}>" if (lev <= 2) and h[2] - puts "#{@sp*1}</#{@s[1]}>" if (lev <= 1) and h[1] + puts "#{@sp*3}</#{@s[3]}>" if (lev <= 3) && h[3] + puts "#{@sp*2}</#{@s[2]}>" if (lev <= 2) && h[2] + puts "#{@sp*1}</#{@s[1]}>" if (lev <= 1) && h[1] puts "</#{@s[0]}>" if (lev==0) end end @@ -202,3 +187,20 @@ module SiSU_XML_Scaffold end end __END__ +@s=['0', + 'A', + 'B', + 'C', + '1', + '2', + '3' +] +#@t='docbook' #@t='fictionbook' +#@s=['book', #@s=['body', +# 'part', # 'section', +# 'subpart N/A', # 'section', +# 'sub-subpart N/A', # 'section', +# 'chapter', # 'section', +# 'sect1', # 'section', +# 'sect2' # 'section' +#] #] diff --git a/lib/sisu/v4/shared_xml.rb b/lib/sisu/v6/xml_shared.rb index 390689c7..033659f0 100644 --- a/lib/sisu/v4/shared_xml.rb +++ b/lib/sisu/v6/xml_shared.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/shared_xml.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/xml_shared.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -381,25 +382,25 @@ module SiSU_XML_Munge 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>'). + '<link xmlns:xl="http://www.w3.org/1999/xlink" xl:type="simple" xl: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>'). + '<link xmlns:xl="http://www.w3.org/1999/xlink" xl:type="simple" xl: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>'). + '<link xmlns:xl="http://www.w3.org/1999/xlink" xl:type="simple" xl: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}). + %{<image xmlns:xl="http://www.w3.org/1999/xlink" xl:type="simple" xl:actuate="onLoad" xl:show="embed" xl: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}). + %{<image xmlns:xl="http://www.w3.org/1999/xlink" xl:type="simple" xl:actuate="onLoad" xl:show="embed" xl: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}). + %{<image xmlns:xl="http://www.w3.org/1999/xlink" xl:type="simple" xl:actuate="onLoad" xl:show="embed" xl: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}). + %{<image xmlns:xl="http://www.w3.org/1999/xlink" xl:type="simple" xl:actuate="onLoad" xl:show="embed" xl: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 + '<link xmlns:xl="http://www.w3.org/1999/xlink" xl:type="simple" xl: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}}). + %{#{@brace_url.xml_open}<link xmlns:xl="http://www.w3.org/1999/xlink" xl:type="simple" xl: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 + '<link xmlns:xl="http://www.w3.org/1999/xlink" xl:type="simple" xl:href="\1">\1</link>') #escaped urls not linked, deal with later else dob.obj=dob.obj.gsub(/</m,'<').gsub(/>/m,'>') end @@ -430,32 +431,63 @@ 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 xl: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 xl: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,'● '). # not available + gsub(/#{Mx[:nbsp]}/,' '). # not available + 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[: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 xl:href="../../_sisu/image/\1" />'). #taken unmodified except path from fictionbook + 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,'● '). # not available + gsub(/#{Mx[:nbsp]}/,' '). # not available + gsub(/<(p|br)>/,'<\1 />') + dob.obj=clean(dob.obj) dob end def markup_group(dob='') dob.obj=dob.obj.gsub(/</,'<').gsub(/>/,'>'). gsub(/<:?br(?:\s+\/)?>/,'<br />'). - gsub(/<(link xmlns:xlink=".+?")>/,'<\1>'). + gsub(/<(link xmlns:xl=".+?")>/,'<\1>'). gsub(/<(\/link)>/,'<\1>'). gsub(/<(\/?en)>/,'<\1>') dob @@ -463,7 +495,7 @@ module SiSU_XML_Munge def markup_block(dob='') dob.obj=dob.obj.gsub(/</,'<').gsub(/>/,'>'). gsub(/<:?br(?:\s+\/)?>/,'<br />'). - gsub(/<(link xmlns:xlink=".+?")>/,'<\1>'). + gsub(/<(link xmlns:xl=".+?")>/,'<\1>'). gsub(/<(\/link)>/,'<\1>'). gsub(/<(\/?en)>/,'<\1>') dob diff --git a/lib/sisu/v4/xml_tables.rb b/lib/sisu/v6/xml_tables.rb index 27845aac..a994e402 100644 --- a/lib/sisu/v4/xml_tables.rb +++ b/lib/sisu/v6/xml_tables.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/xml_tables.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/xml_tables.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> diff --git a/lib/sisu/v4/zap.rb b/lib/sisu/v6/zap.rb index 2890cfef..6d200159 100644 --- a/lib/sisu/v4/zap.rb +++ b/lib/sisu/v6/zap.rb @@ -8,7 +8,8 @@ * 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. + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. * License: GPL 3 or later: @@ -50,7 +51,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/v4/zap.rb;hb=HEAD> + <http://sources.sisudoc.org/?p=code/sisu.git;a=blob;f=lib/sisu/v6/zap.rb;hb=HEAD> * Ralph Amissah <ralph@amissah.com> @@ -71,14 +72,14 @@ module SiSU_Zap zap_path="#{@env.path.output}/#{@env.fnb}" z=SiSU_Env::CleanOutput.new(@opt) if SiSU_Env::InfoSettings.new.permission?('zap') - unless @opt.cmd =~/q/ - tell=SiSU_Screen::Ansi.new(@opt.cmd,"Clean files related to processing #{@opt.cmd} ->","#{@opt.fns} -> #{zap_path}") + unless @opt.act[:quiet][:set]==:on + tell=SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"Clean files related to processing #{@opt.cmd} ->","#{@opt.fns} -> #{zap_path}") tell.warn end z.zap.remove_output else - unless @opt.cmd =~/q/ - tell=SiSU_Screen::Ansi.new(@opt.cmd,'use of -Z (zap) has not enabled in sisurc.yml') + unless @opt.act[:quiet][:set]==:on + tell=SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'use of -Z (zap) has not enabled in sisurc.yml') tell.warn end end diff --git a/man/man1/sisu4.1 b/man/man1/sisu6.1 index 09708b31..09708b31 120000 --- a/man/man1/sisu4.1 +++ b/man/man1/sisu6.1 |