sisu 7.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/sisu +367 -0
- data/bin/sisugem +367 -0
- data/data/sisu/image/arrow_next_red.png +0 -0
- data/data/sisu/image/arrow_prev_red.png +0 -0
- data/data/sisu/image/arrow_up_red.png +0 -0
- data/data/sisu/image/b_bluebell.png +0 -0
- data/data/sisu/image/b_doc.png +0 -0
- data/data/sisu/image/b_epub.png +0 -0
- data/data/sisu/image/b_home.png +0 -0
- data/data/sisu/image/b_info.png +0 -0
- data/data/sisu/image/b_odf.png +0 -0
- data/data/sisu/image/b_pdf.png +0 -0
- data/data/sisu/image/b_search.png +0 -0
- data/data/sisu/image/b_toc.png +0 -0
- data/data/sisu/image/bullet_08.png +0 -0
- data/data/sisu/image/bullet_09.png +0 -0
- data/data/sisu/image/bullet_10.png +0 -0
- data/data/sisu/image/bullet_11.png +0 -0
- data/data/sisu/image/bullet_12.png +0 -0
- data/data/sisu/image/bullet_doc.png +0 -0
- data/data/sisu/image/bullet_red.png +0 -0
- data/data/sisu/image/dot_clear.png +0 -0
- data/data/sisu/image/dot_white.png +0 -0
- data/data/sisu/image/gplv3.png +0 -0
- data/data/sisu/image/gplv3_free_software.png +0 -0
- data/data/sisu/image/next.png +0 -0
- data/data/sisu/image/previous.png +0 -0
- data/data/sisu/image/rb7.ico +0 -0
- data/data/sisu/image/sisu.png +0 -0
- data/data/sisu/image/toctoc.png +0 -0
- data/data/sisu/version.yml +5 -0
- data/lib/sisu.rb +94 -0
- data/lib/sisu/air.rb +80 -0
- data/lib/sisu/ao.rb +590 -0
- data/lib/sisu/ao_character_check.rb +102 -0
- data/lib/sisu/ao_composite.rb +286 -0
- data/lib/sisu/ao_doc_objects.rb +565 -0
- data/lib/sisu/ao_doc_str.rb +2269 -0
- data/lib/sisu/ao_endnotes.rb +136 -0
- data/lib/sisu/ao_expand_insertions.rb +514 -0
- data/lib/sisu/ao_hash_digest.rb +174 -0
- data/lib/sisu/ao_idx.rb +422 -0
- data/lib/sisu/ao_images.rb +187 -0
- data/lib/sisu/ao_metadata.rb +86 -0
- data/lib/sisu/ao_misc_arrange.rb +207 -0
- data/lib/sisu/ao_numbering.rb +720 -0
- data/lib/sisu/ao_persist.rb +194 -0
- data/lib/sisu/ao_references.rb +502 -0
- data/lib/sisu/ao_syntax.rb +640 -0
- data/lib/sisu/cgi.rb +84 -0
- data/lib/sisu/cgi_pgsql.rb +270 -0
- data/lib/sisu/cgi_sql_common.rb +986 -0
- data/lib/sisu/cgi_sqlite.rb +244 -0
- data/lib/sisu/conf.rb +287 -0
- data/lib/sisu/constants.rb +388 -0
- data/lib/sisu/css.rb +3484 -0
- data/lib/sisu/db_columns.rb +1997 -0
- data/lib/sisu/db_create.rb +689 -0
- data/lib/sisu/db_dbi.rb +90 -0
- data/lib/sisu/db_drop.rb +207 -0
- data/lib/sisu/db_import.rb +877 -0
- data/lib/sisu/db_indexes.rb +146 -0
- data/lib/sisu/db_load_tuple.rb +323 -0
- data/lib/sisu/db_remove.rb +182 -0
- data/lib/sisu/db_select.rb +230 -0
- data/lib/sisu/db_sqltxt.rb +173 -0
- data/lib/sisu/db_tests.rb +114 -0
- data/lib/sisu/dbi.rb +166 -0
- data/lib/sisu/dbi_discrete.rb +206 -0
- data/lib/sisu/digests.rb +306 -0
- data/lib/sisu/dp.rb +1606 -0
- data/lib/sisu/dp_identify_markup.rb +161 -0
- data/lib/sisu/dp_make.rb +668 -0
- data/lib/sisu/embedded.rb +149 -0
- data/lib/sisu/errors.rb +84 -0
- data/lib/sisu/generic_parts.rb +131 -0
- data/lib/sisu/git.rb +277 -0
- data/lib/sisu/html.rb +775 -0
- data/lib/sisu/html_concordance.rb +391 -0
- data/lib/sisu/html_format.rb +1348 -0
- data/lib/sisu/html_harvest.rb +109 -0
- data/lib/sisu/html_harvest_author_format.rb +111 -0
- data/lib/sisu/html_harvest_authors.rb +466 -0
- data/lib/sisu/html_harvest_topics.rb +893 -0
- data/lib/sisu/html_lite_shared.rb +324 -0
- data/lib/sisu/html_manifest.rb +1032 -0
- data/lib/sisu/html_minitoc.rb +230 -0
- data/lib/sisu/html_parts.rb +437 -0
- data/lib/sisu/html_persist.rb +237 -0
- data/lib/sisu/html_promo.rb +440 -0
- data/lib/sisu/html_scroll.rb +235 -0
- data/lib/sisu/html_segments.rb +716 -0
- data/lib/sisu/html_shared.rb +62 -0
- data/lib/sisu/html_table.rb +64 -0
- data/lib/sisu/html_tune.rb +301 -0
- data/lib/sisu/hub.rb +277 -0
- data/lib/sisu/hub_actions.rb +1122 -0
- data/lib/sisu/hub_loop_markup_files.rb +170 -0
- data/lib/sisu/hub_options.rb +1695 -0
- data/lib/sisu/i18n.rb +702 -0
- data/lib/sisu/manpage.rb +377 -0
- data/lib/sisu/manpage_format.rb +85 -0
- data/lib/sisu/object_munge.rb +307 -0
- data/lib/sisu/prog_text_translation.rb +1702 -0
- data/lib/sisu/qrcode.rb +754 -0
- data/lib/sisu/relaxng.rb +1153 -0
- data/lib/sisu/remote.rb +246 -0
- data/lib/sisu/rexml.rb +148 -0
- data/lib/sisu/se.rb +158 -0
- data/lib/sisu/se_cleanoutput.rb +145 -0
- data/lib/sisu/se_clear.rb +105 -0
- data/lib/sisu/se_createsite.rb +273 -0
- data/lib/sisu/se_css.rb +221 -0
- data/lib/sisu/se_date.rb +92 -0
- data/lib/sisu/se_db.rb +214 -0
- data/lib/sisu/se_envcall.rb +326 -0
- data/lib/sisu/se_file_op.rb +2758 -0
- data/lib/sisu/se_filemap.rb +247 -0
- data/lib/sisu/se_get_init.rb +238 -0
- data/lib/sisu/se_hub_particulars.rb +234 -0
- data/lib/sisu/se_info_env.rb +2179 -0
- data/lib/sisu/se_info_port.rb +70 -0
- data/lib/sisu/se_info_system.rb +202 -0
- data/lib/sisu/se_load.rb +108 -0
- data/lib/sisu/se_processing.rb +659 -0
- data/lib/sisu/se_programs.rb +394 -0
- data/lib/sisu/se_remotes.rb +553 -0
- data/lib/sisu/se_standardise_lang.rb +176 -0
- data/lib/sisu/se_version.rb +174 -0
- data/lib/sisu/shared_images.rb +137 -0
- data/lib/sisu/shared_markup_alt.rb +336 -0
- data/lib/sisu/shared_metadata.rb +1361 -0
- data/lib/sisu/shared_sem.rb +156 -0
- data/lib/sisu/sisu_thor_lib.rb +407 -0
- data/lib/sisu/sitemaps.rb +224 -0
- data/lib/sisu/src_kdissert_share.rb +102 -0
- data/lib/sisu/src_po4a_share.rb +309 -0
- data/lib/sisu/src_po4a_shelf.rb +1217 -0
- data/lib/sisu/src_po4a_shelf_set.rb +297 -0
- data/lib/sisu/src_po4a_sst_ao_sst.rb +893 -0
- data/lib/sisu/src_po4a_sst_ao_sst_set.rb +284 -0
- data/lib/sisu/src_po4a_sstm.rb +135 -0
- data/lib/sisu/src_shared.rb +347 -0
- data/lib/sisu/src_sisupod_make.rb +171 -0
- data/lib/sisu/src_sisupod_sstm.rb +109 -0
- data/lib/sisu/sst_convert_markup.rb +323 -0
- data/lib/sisu/sst_do_inline_footnotes.rb +440 -0
- data/lib/sisu/sst_from_xml.rb +178 -0
- data/lib/sisu/sst_identify_markup.rb +482 -0
- data/lib/sisu/sst_to_s_xml_sax.rb +471 -0
- data/lib/sisu/termsheet.rb +163 -0
- data/lib/sisu/texinfo.rb +430 -0
- data/lib/sisu/texinfo_format.rb +541 -0
- data/lib/sisu/texpdf.rb +1162 -0
- data/lib/sisu/texpdf_format.rb +1689 -0
- data/lib/sisu/texpdf_parts.rb +235 -0
- data/lib/sisu/txt_asciidoc.rb +354 -0
- data/lib/sisu/txt_asciidoc_decorate.rb +207 -0
- data/lib/sisu/txt_markdown.rb +389 -0
- data/lib/sisu/txt_markdown_decorate.rb +207 -0
- data/lib/sisu/txt_orgmode.rb +376 -0
- data/lib/sisu/txt_orgmode_decorate.rb +186 -0
- data/lib/sisu/txt_output.rb +86 -0
- data/lib/sisu/txt_plain.rb +410 -0
- data/lib/sisu/txt_plain_decorate.rb +189 -0
- data/lib/sisu/txt_read.rb +109 -0
- data/lib/sisu/txt_rst.rb +371 -0
- data/lib/sisu/txt_rst_decorate.rb +186 -0
- data/lib/sisu/txt_shared.rb +241 -0
- data/lib/sisu/txt_textile.rb +367 -0
- data/lib/sisu/txt_textile_decorate.rb +186 -0
- data/lib/sisu/update.rb +141 -0
- data/lib/sisu/urls.rb +696 -0
- data/lib/sisu/utils.rb +232 -0
- data/lib/sisu/utils_composite.rb +115 -0
- data/lib/sisu/utils_response.rb +114 -0
- data/lib/sisu/utils_screen_text_color.rb +472 -0
- data/lib/sisu/utils_spell.rb +99 -0
- data/lib/sisu/webrick.rb +191 -0
- data/lib/sisu/wikispeak.rb +375 -0
- data/lib/sisu/xhtml.rb +472 -0
- data/lib/sisu/xhtml_epub2.rb +890 -0
- data/lib/sisu/xhtml_epub2_concordance.rb +322 -0
- data/lib/sisu/xhtml_epub2_format.rb +2272 -0
- data/lib/sisu/xhtml_epub2_persist.rb +278 -0
- data/lib/sisu/xhtml_epub2_segments.rb +599 -0
- data/lib/sisu/xhtml_epub2_tune.rb +330 -0
- data/lib/sisu/xhtml_parts.rb +183 -0
- data/lib/sisu/xhtml_shared.rb +62 -0
- data/lib/sisu/xhtml_table.rb +97 -0
- data/lib/sisu/xml_docbook5.rb +376 -0
- data/lib/sisu/xml_dom.rb +624 -0
- data/lib/sisu/xml_fictionbook2.rb +389 -0
- data/lib/sisu/xml_format.rb +865 -0
- data/lib/sisu/xml_md_oai_pmh_dc.rb +229 -0
- data/lib/sisu/xml_odf_odt.rb +887 -0
- data/lib/sisu/xml_odf_odt_format.rb +674 -0
- data/lib/sisu/xml_parts.rb +191 -0
- data/lib/sisu/xml_persist.rb +126 -0
- data/lib/sisu/xml_sax.rb +521 -0
- data/lib/sisu/xml_scaffold_structure_collapsed.rb +198 -0
- data/lib/sisu/xml_scaffold_structure_sisu.rb +201 -0
- data/lib/sisu/xml_shared.rb +665 -0
- data/lib/sisu/xml_tables.rb +261 -0
- data/lib/sisu/zap.rb +90 -0
- metadata +251 -0
@@ -0,0 +1,163 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
=begin
|
3
|
+
|
4
|
+
* Name: SiSU
|
5
|
+
|
6
|
+
** Description: documents, structuring, processing, publishing, search
|
7
|
+
*** specialised pre-processing wrapper
|
8
|
+
|
9
|
+
** Author: Ralph Amissah
|
10
|
+
<ralph@amissah.com>
|
11
|
+
<ralph.amissah@gmail.com>
|
12
|
+
|
13
|
+
** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
|
14
|
+
2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah,
|
15
|
+
All Rights Reserved.
|
16
|
+
|
17
|
+
** License: GPL 3 or later:
|
18
|
+
|
19
|
+
SiSU, a framework for document structuring, publishing and search
|
20
|
+
|
21
|
+
Copyright (C) Ralph Amissah
|
22
|
+
|
23
|
+
This program is free software: you can redistribute it and/or modify it
|
24
|
+
under the terms of the GNU General Public License as published by the Free
|
25
|
+
Software Foundation, either version 3 of the License, or (at your option)
|
26
|
+
any later version.
|
27
|
+
|
28
|
+
This program is distributed in the hope that it will be useful, but WITHOUT
|
29
|
+
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
30
|
+
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
31
|
+
more details.
|
32
|
+
|
33
|
+
You should have received a copy of the GNU General Public License along with
|
34
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
35
|
+
|
36
|
+
If you have Internet connection, the latest version of the GPL should be
|
37
|
+
available at these locations:
|
38
|
+
<http://www.fsf.org/licensing/licenses/gpl.html>
|
39
|
+
<http://www.gnu.org/licenses/gpl.html>
|
40
|
+
|
41
|
+
<http://www.sisudoc.org/sisu/en/manifest/gpl.fsf.html>
|
42
|
+
|
43
|
+
** SiSU uses:
|
44
|
+
* Standard SiSU markup syntax,
|
45
|
+
* Standard SiSU meta-markup syntax, and the
|
46
|
+
* Standard SiSU object citation numbering and system
|
47
|
+
|
48
|
+
** Hompages:
|
49
|
+
<http://www.jus.uio.no/sisu>
|
50
|
+
<http://www.sisudoc.org>
|
51
|
+
|
52
|
+
** Git
|
53
|
+
<http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=summary>
|
54
|
+
<http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=blob;f=lib/sisu/termsheet.rb;hb=HEAD>
|
55
|
+
|
56
|
+
=end
|
57
|
+
require_relative 'se' # se.rb
|
58
|
+
require_relative 'dp' # dp.rb
|
59
|
+
include SiSU_Param
|
60
|
+
@do,@done,@used,@html_output,@txt_input,@txt_output,@@report=Array.new(7){[]}
|
61
|
+
@@info=nil
|
62
|
+
@c=0
|
63
|
+
@cX=SiSU_Screen::Ansi.new('yes').cX
|
64
|
+
@done << "\n#{@cX.blue_hi}#{@cX.black}Summary#{@cX.off*2}"
|
65
|
+
def talent(termsheet,flag)
|
66
|
+
@@info=nil
|
67
|
+
@@info=termsheet.gsub(/(.+?)\.termsheet\.rb/,'../facility_data/\1.html')
|
68
|
+
@env=SiSU_Env::InfoEnv.new
|
69
|
+
@dir_fd="#{@env.path.output}/facility_data"
|
70
|
+
FileUtils::mkdir_p(@dir_fd) unless FileTest.directory?(@dir_fd)==true
|
71
|
+
html_output=[]
|
72
|
+
case termsheet
|
73
|
+
when /.+?\.(termsheet)\.rb$/
|
74
|
+
@basename=termsheet[/(.+?)\.termsheet\.rb/, 1]
|
75
|
+
@standard_form={}
|
76
|
+
require termsheet
|
77
|
+
include Termsheet
|
78
|
+
@standard_form=Termsheet::StandardForms.new.standardforms
|
79
|
+
puts %{\n#{@@cX.yellow_hi}#{@@cX.black}From#{@@cX.off*2}: #{@@cX.grey_hi}#{@@cX.black}#{@basename}.termsheet.rb#{@@cX.off*3}\n\n}
|
80
|
+
@standard_form.each do |k,v|
|
81
|
+
@c+=1
|
82
|
+
require v
|
83
|
+
puts %{\n#{@@cX.blue_hi}#{@@cX.black}Producing the following#{@@cX.off*2}: #{@@cX.green}#{@basename}.#{k}#{@@cX.off}\n\n}
|
84
|
+
@done << %{\n\t#{@@cX.grey}Documents generated#{@@cX.off}: #{@@cX.cyan}#{@basename}.#{k}#{@@cX.off}\n}
|
85
|
+
@used << %{\n\t#{@@cX.grey}Using#{@@cX.off}: #{@@cX.ruby}#{v}#{@@cX.off}\n}
|
86
|
+
html_output=<<WOK
|
87
|
+
<br /><a href="../#{@basename}.#{k}/landscape.pdf">
|
88
|
+
<img border="0" width="18" height="15" src="../_sisu/image/b_pdf.png" alt="pdf landscape"></a>
|
89
|
+
<a href="../#{@basename}.#{k}/portrait.pdf">
|
90
|
+
<img border="0" width="15" height="18" src="../_sisu/image/b_pdf.png" alt="pdf portrait"></a>
|
91
|
+
<a href="../#{@basename}.#{k}/sisu_manifest.html">#{@basename}.#{k}.sisu_manifest.html</a>
|
92
|
+
WOK
|
93
|
+
@html_output << html_output
|
94
|
+
@txt_input << %{\n\tForm #{@c}: <url:#{Dir.pwd}/#{v}>\n\t |#{Dir.pwd}/#{v}|@|^|\n}
|
95
|
+
@txt_output << %{\n\t#{k}: |../#{@basename}.#{k}/sisu_manifest.html|@|^|\n}
|
96
|
+
@report_file_i=File.new("#{@dir_fd}/#{@basename}.txt",'w+')
|
97
|
+
@report_file_o=File.new("#{@dir_fd}/#{@basename}.html",'w+')
|
98
|
+
@filename_new=File.new("#{@basename}.#{k}.sst",'w+')
|
99
|
+
@do << %{#{k}}
|
100
|
+
@filename_new << @document
|
101
|
+
# "require v" pulls in the composite @document
|
102
|
+
# "termsheet" having all the variables required to complete the standard form @document
|
103
|
+
@filename_new.close
|
104
|
+
end
|
105
|
+
@do.each do |x|
|
106
|
+
system %{sisu -Nhwpo #{@basename}.#{x}.sst\n}
|
107
|
+
end
|
108
|
+
else print "not processed --> ", termsheet, "\n"
|
109
|
+
end
|
110
|
+
@done << %{\n\t#{@@cX.green}Summary:#{@@cX.off} #{@@cX.blue}#{@env.path.output}/facility_data/#{@basename}.html#{@@cX.off}\n}
|
111
|
+
@done << %{\n\t#{@@cX.grey}From details provided in#{@@cX.off}: #{@@cX.green}#{termsheet}#{@@cX.off}\n}
|
112
|
+
terms=%{\nTermsheet: <url:#{Dir.pwd}/#{termsheet}>\n |#{Dir.pwd}/#{termsheet}|@|^|\n}
|
113
|
+
@report_file_i << "<url:all.txt>\n|all.txt|@|^|\n" << terms << "\nForms:\n" << @txt_input << "\nOutput Files\n" << @txt_output
|
114
|
+
@report_file_o << %{<a href="toc.html">^</a><br />\n} << @html_output
|
115
|
+
@@report << @done << @used << "\n"
|
116
|
+
@done,@used=[],[]
|
117
|
+
end
|
118
|
+
require_relative 'dp' # dp.rb
|
119
|
+
@argv=$*
|
120
|
+
@proc="#{@argv[0].to_s}"
|
121
|
+
if @proc =~ /^-?[wft]/
|
122
|
+
@argv.shift
|
123
|
+
@argv.each do |termsheet|
|
124
|
+
talent(termsheet,@proc)
|
125
|
+
end
|
126
|
+
end
|
127
|
+
@env=SiSU_Env::InfoEnv.new
|
128
|
+
@dir_fd="#{@env.path.output}/facility_data"
|
129
|
+
@url="#{@env.url.webserv}/facility_data"
|
130
|
+
@@report << %{\n#{@@cX.grey}See#{@@cX.off}: #{@@cX.blue}#{@dir_fd}/all.txt\t#{@dir_fd}/toc.html\t#{@dir_fd}/#{@@cX.off}\n\n#{@@cX.grey}See#{@@cX.off}: #{@@cX.blue}#{@url}/all.txt\t#{@url}/toc.html\t#{@url}/#{@@cX.off}\n\n}
|
131
|
+
puts @@report
|
132
|
+
File.unlink("#{@dir_fd}/all.txt") if FileTest.file?("#{@dir_fd}/all.txt")
|
133
|
+
File.unlink("#{@dir_fd}/toc.html") if FileTest.file?("#{@dir_fd}/toc.html")
|
134
|
+
summary_file=File.new("#{@dir_fd}/all.txt",'w+')
|
135
|
+
summary_html=File.new("#{@dir_fd}/toc.html",'w+')
|
136
|
+
ls_txt=%x{ls #{@dir_fd}/*.txt}
|
137
|
+
report_thlnk=[]
|
138
|
+
ls_txt.scan(/.+/)
|
139
|
+
ls_txt.each {|x| report_thlnk << x.gsub!(/#{@dir_fd}\/(.+)/,"<url:\\1>\n|\\1|@|^|")}
|
140
|
+
report_thlnk.join("\n")
|
141
|
+
ls_html=%x{ls #{@dir_fd}/*.html}
|
142
|
+
report_html=[]
|
143
|
+
ls_html.split(/.+/)
|
144
|
+
ls_html.each {|x| report_html << x.gsub!(/#{@dir_fd}\/(.+)/,'<a href="\1">\1</a><br />')}
|
145
|
+
report_html.join("\n")
|
146
|
+
summary_file << "#{report_thlnk}"
|
147
|
+
summary_html << "#{report_html}"
|
148
|
+
__END__
|
149
|
+
** NOTE wrapper makes little sense without additional components, additional
|
150
|
+
sample files must be provided - (saved till later as may confuse)
|
151
|
+
*** bits
|
152
|
+
sisu -t x_bank.and.*
|
153
|
+
e.g. sisu -t x_bank.and.*.termsheet.rb
|
154
|
+
e.g. sisu_termsheet.rb -t x_bank.and.c*.termsheet.rb
|
155
|
+
program calls upon termsheet file with extension termsheet.rb
|
156
|
+
termsheet.rb calls upon relevant standard form files (to be used) with extension .sForm.rb
|
157
|
+
there is also a standard_terms.rb file - with terms/details that are constant
|
158
|
+
the file produced is named after the termsheet.rb with that extension replaced with .er30
|
159
|
+
from there scribbler.rb is called upon its usual metaVerse html and pdf creation
|
160
|
+
! :-)
|
161
|
+
to test run
|
162
|
+
termsheet.rb -f dev.export.import.trade.facility.termsheet.rb
|
163
|
+
the term sheet calls the standard form or template that is to be run against it.
|
data/lib/sisu/texinfo.rb
ADDED
@@ -0,0 +1,430 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
=begin
|
3
|
+
|
4
|
+
* Name: SiSU
|
5
|
+
|
6
|
+
** Description: documents, structuring, processing, publishing, search
|
7
|
+
*** texinfo processing
|
8
|
+
|
9
|
+
** Author: Ralph Amissah
|
10
|
+
<ralph@amissah.com>
|
11
|
+
<ralph.amissah@gmail.com>
|
12
|
+
|
13
|
+
** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
|
14
|
+
2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah,
|
15
|
+
All Rights Reserved.
|
16
|
+
|
17
|
+
** License: GPL 3 or later:
|
18
|
+
|
19
|
+
SiSU, a framework for document structuring, publishing and search
|
20
|
+
|
21
|
+
Copyright (C) Ralph Amissah
|
22
|
+
|
23
|
+
This program is free software: you can redistribute it and/or modify it
|
24
|
+
under the terms of the GNU General Public License as published by the Free
|
25
|
+
Software Foundation, either version 3 of the License, or (at your option)
|
26
|
+
any later version.
|
27
|
+
|
28
|
+
This program is distributed in the hope that it will be useful, but WITHOUT
|
29
|
+
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
30
|
+
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
31
|
+
more details.
|
32
|
+
|
33
|
+
You should have received a copy of the GNU General Public License along with
|
34
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
35
|
+
|
36
|
+
If you have Internet connection, the latest version of the GPL should be
|
37
|
+
available at these locations:
|
38
|
+
<http://www.fsf.org/licensing/licenses/gpl.html>
|
39
|
+
<http://www.gnu.org/licenses/gpl.html>
|
40
|
+
|
41
|
+
<http://www.sisudoc.org/sisu/en/manifest/gpl.fsf.html>
|
42
|
+
|
43
|
+
** SiSU uses:
|
44
|
+
* Standard SiSU markup syntax,
|
45
|
+
* Standard SiSU meta-markup syntax, and the
|
46
|
+
* Standard SiSU object citation numbering and system
|
47
|
+
|
48
|
+
** Hompages:
|
49
|
+
<http://www.jus.uio.no/sisu>
|
50
|
+
<http://www.sisudoc.org>
|
51
|
+
|
52
|
+
** Git
|
53
|
+
<http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=summary>
|
54
|
+
<http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=blob;f=lib/sisu/texinfo.rb;hb=HEAD>
|
55
|
+
|
56
|
+
=end
|
57
|
+
module SiSU_TexInfo
|
58
|
+
require_relative 'html' # html.rb
|
59
|
+
require_relative 'dp' # dp.rb
|
60
|
+
include SiSU_Param
|
61
|
+
#include Stamp ... needed removed arbitrarily 2005w05/1 (warnings about undefined flags)
|
62
|
+
require_relative 'texinfo_format' # texinfo_format.rb
|
63
|
+
include SiSU_TexInfoFormat
|
64
|
+
@tex_file=[]
|
65
|
+
@@tabular="{tabular}"
|
66
|
+
@@table_pagebreak_counter,@@tex_endnote_call_counter,@@tex_table_flag,@@tex_counter,@@tex_column,@@tex_columns,@@counting=0,0,0,0,0,0,0
|
67
|
+
@@column_instruct,@@tex_line_mode,@@tex_word_mode,@@start_table,@@line_mode='','','','',''
|
68
|
+
@@n,@@copyright,@@tableheader=nil,nil,nil
|
69
|
+
@@tex_col_w=[]
|
70
|
+
@@tex_pattern_margin_number="\\\\marginpar.+?\s+"
|
71
|
+
class Source
|
72
|
+
include SiSU_Param
|
73
|
+
include SiSU_TexInfo
|
74
|
+
def initialize(opt)
|
75
|
+
@opt=opt
|
76
|
+
@md=SiSU_Param::Parameters.new(@opt).get
|
77
|
+
@env=SiSU_Env::InfoEnv.new(@opt.fns)
|
78
|
+
end
|
79
|
+
def directories
|
80
|
+
begin
|
81
|
+
case @opt.fns
|
82
|
+
when /\.(?:-|ssm\.)?sst$/
|
83
|
+
Dir.mkdir(@env.path.output) unless FileTest.directory?("#{@env.path.output}")
|
84
|
+
Dir.mkdir(@env.processing_path.texi) unless FileTest.directory?(@env.processing_path.texi)
|
85
|
+
end
|
86
|
+
rescue
|
87
|
+
SiSU_Screen::Ansi.new(opt,$!,$@).rescue do
|
88
|
+
__LINE__.to_s + ':' + __FILE__
|
89
|
+
end
|
90
|
+
ensure
|
91
|
+
end
|
92
|
+
end
|
93
|
+
def read
|
94
|
+
begin
|
95
|
+
song
|
96
|
+
ensure
|
97
|
+
Dir.chdir(@opt.f_pth[:pth])
|
98
|
+
end
|
99
|
+
end
|
100
|
+
def song
|
101
|
+
begin
|
102
|
+
tool=(@opt.act[:verbose][:set]==:on \
|
103
|
+
|| @opt.act[:verbose_plus][:set]==:on \
|
104
|
+
|| @opt.act[:maintenance][:set]==:on) \
|
105
|
+
? "cd #{@md.file.output_path.texinfo.dir} && #{@env.program.texinfo} #{@md.file.base_filename.info}; cd -"
|
106
|
+
: "[#{@opt.f_pth[:lng_is]}] #{@opt.fno}"
|
107
|
+
(@opt.act[:verbose][:set]==:on \
|
108
|
+
|| @opt.act[:verbose_plus][:set]==:on \
|
109
|
+
|| @opt.act[:maintenance][:set]==:on) \
|
110
|
+
&& ! @opt.act[:quiet][:set]==:on \
|
111
|
+
? SiSU_Screen::Ansi.new(
|
112
|
+
@opt.act[:color_state][:set],
|
113
|
+
'TexInfo',
|
114
|
+
tool
|
115
|
+
).green_hi_blue
|
116
|
+
: SiSU_Screen::Ansi.new(
|
117
|
+
@opt.act[:color_state][:set],
|
118
|
+
'TexInfo',
|
119
|
+
tool
|
120
|
+
).green_title_hi
|
121
|
+
@md=SiSU_Param::Parameters.new(@opt).get
|
122
|
+
directories
|
123
|
+
@marshalfile=SiSU_Env::InfoFile.new(@opt.fns).marshal.ao_content
|
124
|
+
if FileTest.file?(@marshalfile)==true
|
125
|
+
File.open(@marshalfile) { |f| @@tuned_file=Marshal.load(f)}
|
126
|
+
#tell.meta_verse_skipped if @opt.selections.str =~/[vVM]/
|
127
|
+
else
|
128
|
+
tex_array=IO.readlines(@opt.fns,'')
|
129
|
+
SiSU_Metaverse.songsheet(tex_array)
|
130
|
+
end
|
131
|
+
tex_array=@@tuned_file
|
132
|
+
TeXinfoMake.new(@md,tex_array).songsheet
|
133
|
+
tex_array=''
|
134
|
+
rescue; STDERR.puts SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],$!,$@).rescue
|
135
|
+
ensure
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
class TeXinfoMake
|
140
|
+
include SiSU_Param
|
141
|
+
include SiSU_TexInfoFormat
|
142
|
+
@@tex_1='(?:.+?)+~' #?? debug
|
143
|
+
@@tabular="{tabular}"
|
144
|
+
@@tex_pattern_margin_number="\\\\marginpar.+?\s+"
|
145
|
+
def initialize(md,data)
|
146
|
+
@md,@data=md,data
|
147
|
+
@env=SiSU_Env::InfoEnv.new(@md.fns)
|
148
|
+
@f=SiSU_Env::FileOp.new(@md)
|
149
|
+
end
|
150
|
+
def songsheet
|
151
|
+
begin
|
152
|
+
data=@data
|
153
|
+
data=pre(data)
|
154
|
+
data=endnote(data)
|
155
|
+
data,head=markup(data)
|
156
|
+
objs_txt=tail(data)
|
157
|
+
doc_txt=[head,objs_txt]
|
158
|
+
output(doc_txt)
|
159
|
+
makeinfo #KEEP reinstate when fixed #%
|
160
|
+
place_info
|
161
|
+
rescue; STDERR.puts SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],$!,$@).rescue
|
162
|
+
ensure
|
163
|
+
end
|
164
|
+
end
|
165
|
+
def pre(data)
|
166
|
+
data_new=[]
|
167
|
+
data.each do |dob|
|
168
|
+
# DEBUG 2003w16 this is a kludge, because i could not get parameters
|
169
|
+
# from param, Sort out ... revert to more elegant solution
|
170
|
+
if dob.is =='table'
|
171
|
+
@@flag['tables']='y' # KLUDGE get from param
|
172
|
+
end
|
173
|
+
dob.obj=dob.obj.gsub(/<:p[bn]>/,'').
|
174
|
+
gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,'\1(\2 [linked to:] \3)').
|
175
|
+
gsub(/(^|#{Mx[:gl_c]}|\s)\{(.+?)\}((?:https?|file):\/\/\S+)/,'\1(\2 [linked to:] \3)')
|
176
|
+
do_mono=SiSU_TexInfoFormat::Texinfo.new(@md,dob)
|
177
|
+
dob.obj=do_mono.spec_char(dob.obj)
|
178
|
+
data_new << dob
|
179
|
+
end
|
180
|
+
data_new
|
181
|
+
end
|
182
|
+
def endnote(data)
|
183
|
+
data_new=[]
|
184
|
+
data.each do |dob|
|
185
|
+
if dob.of==:para \
|
186
|
+
|| dob.of==:block
|
187
|
+
dob.obj=dob.obj.gsub(/\s*#{Mx[:en_a_o]}(?:\d+)\s+(.+?)#{Mx[:en_a_c]}/m,' @footnote{ \1} ').
|
188
|
+
gsub(/\s*#{Mx[:en_a_o]}(\*+)\s+(.+?)#{Mx[:en_a_c]}/m,' @footnote{ \1} ')
|
189
|
+
end
|
190
|
+
data_new << dob
|
191
|
+
end
|
192
|
+
data_new
|
193
|
+
end
|
194
|
+
def poem
|
195
|
+
data,data_new=@data,[]
|
196
|
+
@tex_file=[]
|
197
|
+
@@counting=0
|
198
|
+
data.each do |dob|
|
199
|
+
if dob.is ==:code
|
200
|
+
@@flag['code']=true
|
201
|
+
@@counting=1
|
202
|
+
end
|
203
|
+
if dob.is ==:verse
|
204
|
+
@@flag['poem']=1
|
205
|
+
end
|
206
|
+
if @@flag['code']
|
207
|
+
if @@flag['code'] \
|
208
|
+
&& (dob.obj =~ /#{Mx[:gr_o]}code[-_](?:end|close)#{Mx[:gr_c]}/) #watch change not tested 200501 #fix
|
209
|
+
@@flag['code']=false
|
210
|
+
end
|
211
|
+
if @@flag['code'] \
|
212
|
+
&& (dob.obj =~ /\S/)
|
213
|
+
sub_array=dob.obj.dup
|
214
|
+
@@line_mode=sub_array.scan(/.+/)
|
215
|
+
Tune.code_lines(@@line_mode)
|
216
|
+
dob.obj=@@line_mode.join
|
217
|
+
end
|
218
|
+
elsif @@flag['poem']==1
|
219
|
+
if @@flag['poem']==1 \
|
220
|
+
&& (dob.obj =~ /#{Mx[:gr_o]}verse[-_](?:end|close)#{Mx[:gr_c]}/) #watch change not tested 200501 #fix
|
221
|
+
@@flag['poem']=0
|
222
|
+
end
|
223
|
+
if @@flag['poem']==1 \
|
224
|
+
&& (dob.obj =~ /\S/)
|
225
|
+
sub_array=dob.obj.dup
|
226
|
+
@@line_mode=sub_array.scan(/.+/)
|
227
|
+
Tune.code_lines(@@line_mode)
|
228
|
+
dob.obj=@@line_mode.join
|
229
|
+
end
|
230
|
+
end
|
231
|
+
@tex_file << dob.obj
|
232
|
+
data_new << dob
|
233
|
+
end
|
234
|
+
data_new
|
235
|
+
end
|
236
|
+
def code_lines
|
237
|
+
data,data_new=@data,[]
|
238
|
+
data.each do |line|
|
239
|
+
if (line =~ /\S/) \
|
240
|
+
&& (line !~ /#{Mx[:gr_o]}(code|verse).+/) #fix
|
241
|
+
line=if @@flag['code']
|
242
|
+
line.gsub(/^\s*(.+)/m,"\\noindent \\marginpar\[left-text\]{\\begin{tiny}#{@@counting}\\end{tiny}}\\1\\")
|
243
|
+
@@counting+=1 if @@flag['code']
|
244
|
+
else line.gsub(/(.+)/m,'\noindent\1')
|
245
|
+
end
|
246
|
+
end
|
247
|
+
data_new << line
|
248
|
+
end
|
249
|
+
end
|
250
|
+
def tables
|
251
|
+
data,data_new=@data,[]
|
252
|
+
@tex_file=[]
|
253
|
+
@@tableheader=0
|
254
|
+
data.each do |dob|
|
255
|
+
if dob.obj =~ /#{Mx[:tc_p]}|#{Mx[:gr_o]}T/ui #fix
|
256
|
+
do_mono=SiSU_TexInfoFormat::Texinfo.new(@md,dob)
|
257
|
+
dob.obj=do_mono.longtable # using longtable latex package
|
258
|
+
end
|
259
|
+
@tex_file << dob.obj
|
260
|
+
data_new << dob
|
261
|
+
end
|
262
|
+
data_new
|
263
|
+
end
|
264
|
+
def markup(data)
|
265
|
+
data_new=[]
|
266
|
+
@tex_file=[]
|
267
|
+
@row_break='\\\\\\'
|
268
|
+
@break_page="#{@row_break}\n#{@row_break} \n"
|
269
|
+
@tex_file << SiSU_TexInfoFormat::Texinfo.new(@md).head
|
270
|
+
mono=SiSU_TexInfoFormat::Texinfo.new(@md)
|
271
|
+
@tex_file << mono.topnode(@md.title.full)
|
272
|
+
texinfo_menu=[]
|
273
|
+
n_menu,n_submenu=0,0
|
274
|
+
@submenu,@subsubmenu={},{}
|
275
|
+
data.each do |dob|
|
276
|
+
if dob.is ==:heading \
|
277
|
+
&& (dob.ln.to_s =~ /^[0-3]$/)
|
278
|
+
toc=SiSU_TexInfoFormat::Texinfo.new(@md,dob)
|
279
|
+
texinfo_menu << toc.menu
|
280
|
+
elsif dob.is ==:heading \
|
281
|
+
&& (dob.ln.to_s =~ /^[4-6]$/)
|
282
|
+
toc=SiSU_TexInfoFormat::Texinfo.new(@md,dob)
|
283
|
+
texinfo_menu << toc.menu
|
284
|
+
case dob.ln
|
285
|
+
when 4
|
286
|
+
n_menu+=1
|
287
|
+
@submenu[n_menu]=[]
|
288
|
+
when 5
|
289
|
+
n_submenu+=1
|
290
|
+
@subsubmenu[n_menu]=[]
|
291
|
+
@submenu[n_menu] << toc.menu
|
292
|
+
when 6
|
293
|
+
n_submenu+=1
|
294
|
+
@subsubmenu[n_submenu]=[]
|
295
|
+
@subsubmenu[n_submenu] << toc.menu
|
296
|
+
end
|
297
|
+
else
|
298
|
+
dob.obj=dob.obj.gsub(/\s*(?:<:?br>|<br \/>)\s*/,"\n\n")
|
299
|
+
end
|
300
|
+
data_new << dob
|
301
|
+
end
|
302
|
+
data=data_new
|
303
|
+
texinfo_menu=texinfo_menu.compact
|
304
|
+
texinfo_menu << "* Dublin Core::"
|
305
|
+
@tex_file << texinfo_menu
|
306
|
+
@tex_file << "* Index::\n" +
|
307
|
+
"@end menu\n\n" +
|
308
|
+
"@c %% 5\n\n"
|
309
|
+
n_menu,n_submenu=0,0
|
310
|
+
@@do_submenu,@@do_subsubmenu=1,1
|
311
|
+
data_new=[]
|
312
|
+
data.each do |dob|
|
313
|
+
unless defined? dob.ln and dob.ln == (5..6)
|
314
|
+
mono=SiSU_TexInfoFormat::Texinfo.new(@md,dob)
|
315
|
+
end
|
316
|
+
if dob.is==:heading
|
317
|
+
case dob.ln
|
318
|
+
when 0 then dob=mono.level0
|
319
|
+
when 1 then dob=mono.level1
|
320
|
+
when 2 then dob=mono.level2
|
321
|
+
when 3 then dob=mono.level3
|
322
|
+
when 4;
|
323
|
+
@@n4_txt=dob.obj
|
324
|
+
dob=mono.level4
|
325
|
+
n_menu+=1
|
326
|
+
@@do_submenu,@@do_subsubmenu=1,1
|
327
|
+
when 5;
|
328
|
+
n_submenu+=1
|
329
|
+
@@do_subsubmenu=1
|
330
|
+
@@n5_txt=dob.obj
|
331
|
+
if @@do_submenu==1
|
332
|
+
menu=SiSU_TexInfoFormat::TeXinfoTxt.new(@md,dob,@submenu[n_menu])
|
333
|
+
dob.obj="#{menu.submenu}#{SiSU_TexInfoFormat::Texinfo.new(@md,dob,@@n4_txt).level5.obj}"
|
334
|
+
@@do_submenu=0
|
335
|
+
else dob.obj="#{SiSU_TexInfoFormat::Texinfo.new(@md,dob,@@n4_txt).level5.obj}"
|
336
|
+
end
|
337
|
+
when 6;
|
338
|
+
if @@do_submenu==1
|
339
|
+
menu=SiSU_TexInfoFormat::TeXinfoTxt.new(@md,dob,@submenu[n_menu])
|
340
|
+
dob.obj="#{menu.submenu}#{SiSU_TexInfoFormat::Texinfo.new(@md,dob,@@n5_txt).level6.obj}"
|
341
|
+
dob.obj="#{menu.subsubmenu}#{mono.level6.obj}"
|
342
|
+
@@do_subsubmenu=0
|
343
|
+
else dob.obj="#{SiSU_TexInfoFormat::Texinfo.new(@md,dob,@@n5_txt).level6.obj}"
|
344
|
+
end
|
345
|
+
end
|
346
|
+
else
|
347
|
+
if dob.obj !~/\S/
|
348
|
+
dob.obj=nil
|
349
|
+
else
|
350
|
+
if dob.is==:para \
|
351
|
+
&& (dob.obj !~/#{Dx[:ocn_o]}#{dob.ocn}#{Dx[:ocn_c]}/)
|
352
|
+
dob.obj=dob.ocn.is_a?(Fixnum) \
|
353
|
+
? "#{dob.obj} #{Dx[:ocn_o]}#{dob.ocn}#{Dx[:ocn_c]}\n\n" : "#{dob.obj}\n\n"
|
354
|
+
end
|
355
|
+
end
|
356
|
+
end
|
357
|
+
#%case with endnotes
|
358
|
+
dob.obj=dob.obj.gsub(/\s*[0-8]\\+(\S+)?\s+/,' ') if dob.obj
|
359
|
+
data_new << dob
|
360
|
+
end
|
361
|
+
[data_new, @tex_file]
|
362
|
+
end
|
363
|
+
def number_titles
|
364
|
+
data,data_new=@data,[]
|
365
|
+
@tex_file=[]
|
366
|
+
data.each do |dob|
|
367
|
+
if (@md.markup =~ /num_top/i) \
|
368
|
+
&& (dob.obj !~ /#{Rx[:meta]}/)
|
369
|
+
if (dob.obj =~ /^[1-6]\\+(?:~\S+)?\s*<!h-.+?-!>/) \
|
370
|
+
&& (dob.obj !~ /<:\d-endnotes>/)
|
371
|
+
header=dob.obj[/<!h-(.+?)-!>/m, 1].gsub(/-/m,'.')
|
372
|
+
dob.obj=dob.obj.gsub(/^(?:[1-6]\\+(?:~\S+)|<:([12356]|4-.+?-)>)\s*<!h-.+?-!>/,
|
373
|
+
"\\1 #{header} ")
|
374
|
+
end
|
375
|
+
elsif dob.obj=~ /<!h!>|<!h\d!>|<!h.+?!>|<!!h.+?!>/
|
376
|
+
if dob.obj=~ /<!h-.+?-!>/
|
377
|
+
dob.obj=dob.obj.gsub(/<!h-(.+?)-!>/,'\1 ')
|
378
|
+
end
|
379
|
+
end
|
380
|
+
@tex_file << dob.obj
|
381
|
+
end
|
382
|
+
data_new << dob
|
383
|
+
end
|
384
|
+
def tail(data)
|
385
|
+
tex=SiSU_TexInfoFormat::Texinfo.new(@md)
|
386
|
+
objs_txt=[]
|
387
|
+
data.each do |dob|
|
388
|
+
if dob.obj \
|
389
|
+
&& (dob.is !=:structure \
|
390
|
+
&& dob.is !=:comment)
|
391
|
+
objs_txt << dob.obj if dob.obj
|
392
|
+
end
|
393
|
+
end
|
394
|
+
objs_txt << tex.dublincore << tex.tail
|
395
|
+
objs_txt
|
396
|
+
end
|
397
|
+
def output(data)
|
398
|
+
filename_texinfo=%{#{@env.processing_path.texi}/#{@md.fnb}.texinfo}
|
399
|
+
file_texinfo=File.new(filename_texinfo,'w+')
|
400
|
+
puts filename_texinfo if @md.opt.act[:maintenance][:set]==:on
|
401
|
+
data.each {|s| (file_texinfo.puts s,"\n") if s}
|
402
|
+
file_texinfo.close
|
403
|
+
end
|
404
|
+
def makeinfo
|
405
|
+
if @md.fns =~/\.(?:-|ssm\.)?sst$/
|
406
|
+
m=/(.+?)\.((?:-|ssm\.)?sst)$/.match(@md.fns)
|
407
|
+
fnb,sfx=m[1],m[2]
|
408
|
+
pwd=Dir.pwd
|
409
|
+
case sfx
|
410
|
+
when /(?:-|ssm\.)?sst$/
|
411
|
+
@env=SiSU_Env::InfoEnv.new(@md.fns,@md.opt.selections.str)
|
412
|
+
Dir.chdir(@env.processing_path.texi)
|
413
|
+
texinfo=SiSU_Env::SystemCall.new("#{fnb}.texinfo")
|
414
|
+
texinfo.makeinfo
|
415
|
+
end
|
416
|
+
Dir.chdir(pwd)
|
417
|
+
end
|
418
|
+
def place_info
|
419
|
+
unless FileTest.directory?(@f.output_path.texinfo.dir)
|
420
|
+
FileUtils::mkdir_p(@f.output_path.texinfo.dir)
|
421
|
+
end
|
422
|
+
info_src=%{#{@env.processing_path.texi}/#{@md.fnb}.info}
|
423
|
+
Dir.glob("#{info_src}*").sort.each do |f|
|
424
|
+
FileUtils::cp(f, File.dirname(@f.place_file.info.dir)) # bug should provide dir without need to extract it!
|
425
|
+
end
|
426
|
+
end
|
427
|
+
end
|
428
|
+
end
|
429
|
+
end
|
430
|
+
__END__
|