sisu 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,235 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
=begin
|
|
3
|
+
|
|
4
|
+
* Name: SiSU
|
|
5
|
+
|
|
6
|
+
** Description: documents, structuring, processing, publishing, search
|
|
7
|
+
*** shared html parts
|
|
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/xhtml_parts.rb;hb=HEAD>
|
|
55
|
+
|
|
56
|
+
=end
|
|
57
|
+
module SiSU_Parts_TeXpdf
|
|
58
|
+
require_relative 'generic_parts' # generic_parts.rb
|
|
59
|
+
include SiSU_Parts_Generic
|
|
60
|
+
def the_line_break
|
|
61
|
+
' \\ '
|
|
62
|
+
end
|
|
63
|
+
def url_decoration
|
|
64
|
+
def tex_open #'{\UseTextSymbol{OML}{<}}'
|
|
65
|
+
Dx[:url_o]
|
|
66
|
+
end
|
|
67
|
+
def tex_close #'{\UseTextSymbol{OML}{>}}'
|
|
68
|
+
Dx[:url_c]
|
|
69
|
+
end
|
|
70
|
+
def txt_open
|
|
71
|
+
'<'
|
|
72
|
+
end
|
|
73
|
+
def txt_close
|
|
74
|
+
'>'
|
|
75
|
+
end
|
|
76
|
+
self
|
|
77
|
+
end
|
|
78
|
+
def the_font
|
|
79
|
+
def set_fonts
|
|
80
|
+
'verdana, arial, georgia, tahoma, sans-serif, helvetica, times, roman'
|
|
81
|
+
end
|
|
82
|
+
self
|
|
83
|
+
end
|
|
84
|
+
class TeX
|
|
85
|
+
def initialize(papersize='')
|
|
86
|
+
@papersize=papersize
|
|
87
|
+
end
|
|
88
|
+
def a4
|
|
89
|
+
def portrait
|
|
90
|
+
def w
|
|
91
|
+
160
|
|
92
|
+
end
|
|
93
|
+
def h
|
|
94
|
+
228
|
|
95
|
+
end
|
|
96
|
+
def img_px
|
|
97
|
+
450
|
|
98
|
+
end
|
|
99
|
+
self
|
|
100
|
+
end
|
|
101
|
+
def landscape
|
|
102
|
+
def w
|
|
103
|
+
238
|
|
104
|
+
end
|
|
105
|
+
def h
|
|
106
|
+
160
|
|
107
|
+
end
|
|
108
|
+
def img_px
|
|
109
|
+
300
|
|
110
|
+
end
|
|
111
|
+
self
|
|
112
|
+
end
|
|
113
|
+
self
|
|
114
|
+
end
|
|
115
|
+
def letter
|
|
116
|
+
def portrait
|
|
117
|
+
def w
|
|
118
|
+
166
|
|
119
|
+
end
|
|
120
|
+
def h
|
|
121
|
+
212
|
|
122
|
+
end
|
|
123
|
+
def img_px
|
|
124
|
+
468
|
|
125
|
+
end
|
|
126
|
+
self
|
|
127
|
+
end
|
|
128
|
+
def landscape
|
|
129
|
+
def w
|
|
130
|
+
226
|
|
131
|
+
end
|
|
132
|
+
def h
|
|
133
|
+
166
|
|
134
|
+
end
|
|
135
|
+
def img_px
|
|
136
|
+
290
|
|
137
|
+
end
|
|
138
|
+
self
|
|
139
|
+
end
|
|
140
|
+
self
|
|
141
|
+
end
|
|
142
|
+
def legal
|
|
143
|
+
def portrait
|
|
144
|
+
def w
|
|
145
|
+
168
|
|
146
|
+
end
|
|
147
|
+
def h
|
|
148
|
+
286
|
|
149
|
+
end
|
|
150
|
+
def img_px
|
|
151
|
+
474
|
|
152
|
+
end
|
|
153
|
+
self
|
|
154
|
+
end
|
|
155
|
+
def landscape
|
|
156
|
+
def w
|
|
157
|
+
296
|
|
158
|
+
end
|
|
159
|
+
def h
|
|
160
|
+
166
|
|
161
|
+
end
|
|
162
|
+
def img_px
|
|
163
|
+
420
|
|
164
|
+
end
|
|
165
|
+
self
|
|
166
|
+
end
|
|
167
|
+
self
|
|
168
|
+
end
|
|
169
|
+
def b5
|
|
170
|
+
def portrait
|
|
171
|
+
def w
|
|
172
|
+
140
|
|
173
|
+
end
|
|
174
|
+
def h
|
|
175
|
+
204
|
|
176
|
+
end
|
|
177
|
+
def img_px
|
|
178
|
+
356
|
|
179
|
+
end
|
|
180
|
+
self
|
|
181
|
+
end
|
|
182
|
+
def landscape
|
|
183
|
+
def w
|
|
184
|
+
200
|
|
185
|
+
end
|
|
186
|
+
def h
|
|
187
|
+
130
|
|
188
|
+
end
|
|
189
|
+
def img_px
|
|
190
|
+
260
|
|
191
|
+
end
|
|
192
|
+
self
|
|
193
|
+
end
|
|
194
|
+
self
|
|
195
|
+
end
|
|
196
|
+
def a5
|
|
197
|
+
def portrait
|
|
198
|
+
def w
|
|
199
|
+
112
|
|
200
|
+
end
|
|
201
|
+
def h
|
|
202
|
+
162
|
|
203
|
+
end
|
|
204
|
+
def img_px
|
|
205
|
+
280
|
|
206
|
+
end
|
|
207
|
+
self
|
|
208
|
+
end
|
|
209
|
+
def landscape
|
|
210
|
+
def w
|
|
211
|
+
152
|
|
212
|
+
end
|
|
213
|
+
def h
|
|
214
|
+
100
|
|
215
|
+
end
|
|
216
|
+
def img_px
|
|
217
|
+
190
|
|
218
|
+
end
|
|
219
|
+
self
|
|
220
|
+
end
|
|
221
|
+
self
|
|
222
|
+
end
|
|
223
|
+
def dimensions
|
|
224
|
+
case @papersize
|
|
225
|
+
when /a4/ then a4
|
|
226
|
+
when /letter/ then letter
|
|
227
|
+
when /legal/ then legal
|
|
228
|
+
when /b5/ then b5
|
|
229
|
+
when /a5/ then a5
|
|
230
|
+
else a4
|
|
231
|
+
end
|
|
232
|
+
end
|
|
233
|
+
end
|
|
234
|
+
end
|
|
235
|
+
__END__
|
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
=begin
|
|
3
|
+
|
|
4
|
+
* Name: SiSU
|
|
5
|
+
|
|
6
|
+
** Description: documents, structuring, processing, publishing, search
|
|
7
|
+
*** plaintext (smarttext) generation, asciidoc
|
|
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/txt_asciidoc.rb;hb=HEAD>
|
|
55
|
+
|
|
56
|
+
=end
|
|
57
|
+
module SiSU_Txt_AsciiDoc
|
|
58
|
+
require_relative 'ao' # ao.rb
|
|
59
|
+
require_relative 'se' # se.rb
|
|
60
|
+
include SiSU_Env
|
|
61
|
+
require_relative 'shared_metadata' # shared_metadata.rb
|
|
62
|
+
require_relative 'generic_parts' # generic_parts.rb
|
|
63
|
+
require_relative 'txt_read' # txt_read.rb
|
|
64
|
+
require_relative 'txt_shared' # txt_shared.rb
|
|
65
|
+
require_relative 'txt_asciidoc_decorate' # txt_decorate.rb
|
|
66
|
+
require_relative 'txt_output' # txt_output.rb
|
|
67
|
+
include SiSU_Param
|
|
68
|
+
@@alt_id_count,@@alt_id_count=0,0
|
|
69
|
+
@@tablefoot=''
|
|
70
|
+
class Source
|
|
71
|
+
include SiSU_Txt_Read
|
|
72
|
+
def initialize(opt)
|
|
73
|
+
@opt=opt
|
|
74
|
+
unless @opt.fns =~/(.+?)\.(?:-|ssm\.)?sst$/
|
|
75
|
+
puts "#{sf} not a processed file type"
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
def read
|
|
79
|
+
begin
|
|
80
|
+
md=SiSU_Param::Parameters.new(@opt).get
|
|
81
|
+
specific={
|
|
82
|
+
description: 'AsciiDoc (plaintext utf-8)',
|
|
83
|
+
output_path: md.file.output_path.asciidoc.dir,
|
|
84
|
+
output_file: md.file.base_filename.asciidoc,
|
|
85
|
+
}
|
|
86
|
+
read_generic(@opt,specific)
|
|
87
|
+
SiSU_Txt_AsciiDoc::Source::Scroll.new(md,@ao_array,@wrap_width).songsheet
|
|
88
|
+
rescue
|
|
89
|
+
SiSU_Errors::Rescued.new($!,$@,@opt.selections.str,@opt.fns).location do
|
|
90
|
+
__LINE__.to_s + ':' + __FILE__
|
|
91
|
+
end
|
|
92
|
+
ensure
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
private
|
|
96
|
+
class Scroll <Source
|
|
97
|
+
include SiSU_Parts_Generic
|
|
98
|
+
include SiSU_TextUtils
|
|
99
|
+
include SiSU_Decorate_Txt_AsciiDoc
|
|
100
|
+
@@endnotes={ para: [], end: [] }
|
|
101
|
+
def initialize(md,data,wrap_width)
|
|
102
|
+
@md,@data,@wrap_width=md,data,wrap_width
|
|
103
|
+
@env=SiSU_Env::InfoEnv.new(@md.fns)
|
|
104
|
+
@tab="\t"
|
|
105
|
+
@@endnotes_=case md.opt.selections.str
|
|
106
|
+
when /--footnote/ then false
|
|
107
|
+
when /--endnote/ then true
|
|
108
|
+
else true
|
|
109
|
+
end
|
|
110
|
+
@plaintext={ body: [], open: [], close: [], head: [], metadata: [], tail: [] }
|
|
111
|
+
end
|
|
112
|
+
def songsheet
|
|
113
|
+
plaintext=markup(@data)
|
|
114
|
+
publish(plaintext)
|
|
115
|
+
end
|
|
116
|
+
def break_line
|
|
117
|
+
"\n"
|
|
118
|
+
end
|
|
119
|
+
# Used for extraction of endnotes from paragraphs
|
|
120
|
+
def plaintext_metadata
|
|
121
|
+
array=SiSU_Metadata::Summary.new(@md).plaintext.metadata
|
|
122
|
+
array.each do |meta|
|
|
123
|
+
tag,inf=meta.scan(/^.+?:\s|.+/)
|
|
124
|
+
if tag and inf
|
|
125
|
+
util=SiSU_TextUtils::Wrap.new(inf,@wrap_width,15,1)
|
|
126
|
+
txt=util.line_wrap
|
|
127
|
+
@plaintext[:metadata] <<<<WOK
|
|
128
|
+
|
|
129
|
+
#{@tab}#{tag}#{txt}
|
|
130
|
+
WOK
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
def plaintext_tail
|
|
135
|
+
# env=SiSU_Env::InfoEnv.new(@md.fns)
|
|
136
|
+
generator="Generated by: #{@md.project_details.project} #{@md.project_details.version} of #{@md.project_details.date_stamp} (#{@md.project_details.date})" if @md.project_details.version
|
|
137
|
+
lastdone="Last Generated on: #{Time.now}"
|
|
138
|
+
rubyv="Ruby version: #{@md.ruby_version}"
|
|
139
|
+
sc=if @md.sc_info
|
|
140
|
+
"Source file: #{@md.sc_filename}#{break_line}Version number: #{@md.sc_number}#{break_line}Version date: #{@md.sc_date}#{break_line}"
|
|
141
|
+
else ''
|
|
142
|
+
end
|
|
143
|
+
@plaintext[:tail] <<<<WOK
|
|
144
|
+
#{break_line}
|
|
145
|
+
plaintext (plain text):
|
|
146
|
+
#{@md.file.output_path.asciidoc.url}/#{@md.file.base_filename.asciidoc}#{break_line}
|
|
147
|
+
Other versions of this document: #{break_line}
|
|
148
|
+
manifest:
|
|
149
|
+
#{@md.file.output_path.manifest.url}/#{@md.file.base_filename.manifest}#{break_line}
|
|
150
|
+
at:
|
|
151
|
+
#{@md.file.output_path.base.url}#{break_line}
|
|
152
|
+
|
|
153
|
+
#{sc}
|
|
154
|
+
* #{generator}
|
|
155
|
+
* #{rubyv}
|
|
156
|
+
* #{lastdone}
|
|
157
|
+
* SiSU #{the_url.sisu_txt}
|
|
158
|
+
WOK
|
|
159
|
+
end
|
|
160
|
+
def heading_decorated_inline(dob)
|
|
161
|
+
if dob.is==:heading
|
|
162
|
+
heading_inline = case dob.lc
|
|
163
|
+
when 0 then decorate.heading.inline.l0
|
|
164
|
+
when 1 then decorate.heading.inline.l1
|
|
165
|
+
when 2 then decorate.heading.inline.l2
|
|
166
|
+
when 3 then decorate.heading.inline.l3
|
|
167
|
+
when 4 then decorate.heading.inline.l4
|
|
168
|
+
when 5 then decorate.heading.inline.l5
|
|
169
|
+
when 6 then decorate.heading.inline.l6
|
|
170
|
+
end
|
|
171
|
+
heading_inline + ' ' + dob.obj + ' ' + heading_inline
|
|
172
|
+
end
|
|
173
|
+
end
|
|
174
|
+
def heading_decorated_underscore(dob,times,p_num)
|
|
175
|
+
if dob.is==:heading
|
|
176
|
+
#times=@wrap_width if times > @wrap_width
|
|
177
|
+
case dob.lc
|
|
178
|
+
when 0 then decorate.heading.underscore.l0*times + p_num << break_line*2
|
|
179
|
+
when 1 then decorate.heading.underscore.l1*times + p_num << break_line*2
|
|
180
|
+
when 2 then decorate.heading.underscore.l2*times + p_num << break_line*2
|
|
181
|
+
when 3 then decorate.heading.underscore.l3*times + p_num << break_line*2
|
|
182
|
+
when 4 then decorate.heading.underscore.l4*times + p_num << break_line*2
|
|
183
|
+
when 5 then decorate.heading.underscore.l5*times + p_num << break_line*2
|
|
184
|
+
when 6 then decorate.heading.underscore.l6*times + p_num << break_line*2
|
|
185
|
+
end
|
|
186
|
+
end
|
|
187
|
+
end
|
|
188
|
+
def plaintext_structure(dob='',p_num='') #% Used to extract the structure of a document
|
|
189
|
+
heading_decoration=:inline #(:inline|:underscore) #switch heading decoration between inline & underscore options
|
|
190
|
+
util=nil
|
|
191
|
+
wrapped=if dob.is==:para \
|
|
192
|
+
|| dob.is==:heading
|
|
193
|
+
if dob.is==:heading
|
|
194
|
+
util=(heading_decoration== :inline) \
|
|
195
|
+
? (SiSU_TextUtils::Wrap.new(heading_decorated_inline(dob),@wrap_width,0))
|
|
196
|
+
: (SiSU_TextUtils::Wrap.new(dob.obj,@wrap_width,0))
|
|
197
|
+
elsif dob.is==:para
|
|
198
|
+
if dob.hang \
|
|
199
|
+
and dob.hang =~/[0-9]/ \
|
|
200
|
+
and dob.indent != dob.hang
|
|
201
|
+
util=SiSU_TextUtils::Wrap.new(dob.obj,@wrap_width,dob.indent.to_i*2,dob.hang.to_i*2)
|
|
202
|
+
#util=SiSU_TextUtils::Wrap.new(dob.obj,@wrap_width,dob.hang.to_i*2,0)
|
|
203
|
+
elsif dob.indent =~/[1-9]/
|
|
204
|
+
util=if dob.bullet_
|
|
205
|
+
SiSU_TextUtils::Wrap.new("* #{dob.obj}",@wrap_width,dob.indent.to_i*2)
|
|
206
|
+
else SiSU_TextUtils::Wrap.new(dob.obj,@wrap_width,dob.indent.to_i*2)
|
|
207
|
+
end
|
|
208
|
+
else
|
|
209
|
+
util=if dob.bullet_
|
|
210
|
+
SiSU_TextUtils::Wrap.new("* #{dob.obj}",@wrap_width,0)
|
|
211
|
+
else SiSU_TextUtils::Wrap.new(dob.obj,@wrap_width,0)
|
|
212
|
+
end
|
|
213
|
+
end
|
|
214
|
+
else util=SiSU_TextUtils::Wrap.new(dob.obj,@wrap_width,0)
|
|
215
|
+
end
|
|
216
|
+
dob.is==:heading ? util.no_wrap_no_breaks : util.line_wrap
|
|
217
|
+
end
|
|
218
|
+
if heading_decoration== :underscore \
|
|
219
|
+
and dob.is==:heading
|
|
220
|
+
@plaintext[:body] << wrapped + p_num # main text, contents, body KEEP
|
|
221
|
+
@plaintext[:body] << heading_decorated_underscore(dob,wrapped.length,p_num)
|
|
222
|
+
else
|
|
223
|
+
@plaintext[:body] << wrapped + p_num << break_line # main text, contents, body KEEP
|
|
224
|
+
end
|
|
225
|
+
if @@endnotes[:para] \
|
|
226
|
+
and not @@endnotes_
|
|
227
|
+
@@endnotes[:para].each {|e| @plaintext[:body] << e << break_line}
|
|
228
|
+
elsif @@endnotes[:para] \
|
|
229
|
+
and @@endnotes_
|
|
230
|
+
end
|
|
231
|
+
@@endnotes[:para]=[]
|
|
232
|
+
end
|
|
233
|
+
def markup(data) # Used for major markup instructions
|
|
234
|
+
SiSU_Env::InfoEnv.new(@md.fns)
|
|
235
|
+
@data_mod,@endnotes,@level,@cont,@copen,@plaintext_contents_close=Array.new(6){[]}
|
|
236
|
+
(0..6).each { |x| @cont[x]=@level[x]=false }
|
|
237
|
+
(4..6).each { |x| @plaintext_contents_close[x]='' }
|
|
238
|
+
plaintext_tail #($1,$2)
|
|
239
|
+
plaintext_metadata
|
|
240
|
+
table_message='[table conversion awaited, see other document formats]'
|
|
241
|
+
data.each do |dob|
|
|
242
|
+
dob.obj=dob.obj.gsub(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}.+/um,"#{break_line}#{table_message}"). #fix
|
|
243
|
+
gsub(/.+?#{Mx[:gl_o]}-##{Mx[:gl_c]}/,''). # remove dummy headings (used by html) #check also [~-]#
|
|
244
|
+
gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,
|
|
245
|
+
"#{decorate.bold.open}\\1#{decorate.bold.close}").
|
|
246
|
+
gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,
|
|
247
|
+
"#{decorate.italics.open}\\1#{decorate.italics.close}").
|
|
248
|
+
gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,
|
|
249
|
+
"#{decorate.underscore.open}\\1#{decorate.underscore.close}").
|
|
250
|
+
gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,
|
|
251
|
+
"#{decorate.subscript.open}\\1#{decorate.subscript.close}").
|
|
252
|
+
gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,
|
|
253
|
+
"#{decorate.superscript.open}\\1#{decorate.superscript.close}").
|
|
254
|
+
gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,
|
|
255
|
+
"#{decorate.insert.open}\\1#{decorate.insert.close}").
|
|
256
|
+
gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,
|
|
257
|
+
"#{decorate.cite.open}\\1#{decorate.cite.close}").
|
|
258
|
+
gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,
|
|
259
|
+
"#{decorate.strike.open}\\1#{decorate.strike.close}").
|
|
260
|
+
gsub(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/,
|
|
261
|
+
"#{decorate.monospace.open}\\1#{decorate.monospace.close}")
|
|
262
|
+
unless dob.is==:code
|
|
263
|
+
dob.obj=dob.obj.gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/,'\1').
|
|
264
|
+
gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'\1').
|
|
265
|
+
gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,'\1 [link: <\2>]').
|
|
266
|
+
gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}image/,'\1 [link: local image]').
|
|
267
|
+
gsub(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,"#{the_text.url_open}\\1#{the_text.url_close}")
|
|
268
|
+
dob.obj=dob.obj.gsub(/\s*#{Mx[:en_a_o]}([\d*+]+)\s+(.+?)#{Mx[:en_a_c]}/,' footnote:[note\1,\2]').
|
|
269
|
+
gsub(/\s*#{Mx[:en_b_o]}([\d*+]+\s+.+?)#{Mx[:en_b_c]}/,' footnote:[\1]')
|
|
270
|
+
dob.obj=dob.obj.gsub(/#{Mx[:en_a_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_a_c]}/,'[^\1]'). # endnote marker marked up
|
|
271
|
+
gsub(/#{Mx[:en_b_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_b_c]}/,'[^\1]'). # endnote marker marked up
|
|
272
|
+
gsub(/#{Mx[:gl_o]}(?:#lt|#060)#{Mx[:gl_c]}/,'<').
|
|
273
|
+
gsub(/#{Mx[:gl_o]}(?:#gt|#062)#{Mx[:gl_c]}/,'>').
|
|
274
|
+
gsub(/#{Mx[:gl_o]}#(?:038|amp)#{Mx[:gl_c]}/,'&').
|
|
275
|
+
gsub(/#{Mx[:gl_o]}#033#{Mx[:gl_c]}/,'!').
|
|
276
|
+
gsub(/#{Mx[:gl_o]}#035#{Mx[:gl_c]}/,'#').
|
|
277
|
+
gsub(/#{Mx[:gl_o]}#042#{Mx[:gl_c]}/,'*').
|
|
278
|
+
gsub(/#{Mx[:gl_o]}#045#{Mx[:gl_c]}/,'-').
|
|
279
|
+
gsub(/#{Mx[:gl_o]}#047#{Mx[:gl_c]}/,'/').
|
|
280
|
+
gsub(/#{Mx[:gl_o]}#095#{Mx[:gl_c]}/,'_').
|
|
281
|
+
gsub(/#{Mx[:gl_o]}#123#{Mx[:gl_c]}/,'{').
|
|
282
|
+
gsub(/#{Mx[:gl_o]}#125#{Mx[:gl_c]}/,'}').
|
|
283
|
+
gsub(/#{Mx[:gl_o]}#126#{Mx[:gl_c]}/,'~').
|
|
284
|
+
gsub(/#{Mx[:gl_o]}#169#{Mx[:gl_c]}/,'©').
|
|
285
|
+
gsub(/#{Mx[:gl_o]}#092#{Mx[:gl_c]}/,'\\')
|
|
286
|
+
end
|
|
287
|
+
dob.obj=if dob.of==:block # watch
|
|
288
|
+
dob.obj.gsub(/#{Mx[:gl_o]}●#{Mx[:gl_c]}/m,"* ").
|
|
289
|
+
gsub(/\n?#{Mx[:br_line]}\n?|\n?#{Mx[:br_nl]}\n?/m,break_line)
|
|
290
|
+
else dob.obj.gsub(/\n?#{Mx[:br_line]}\n?|\n?#{Mx[:br_nl]}\n?/m,break_line*2)
|
|
291
|
+
end
|
|
292
|
+
if dob.is==:code
|
|
293
|
+
dob.obj=dob.obj.gsub(/(^|[^}])_([<>])/m,'\1\2'). # _> _<
|
|
294
|
+
gsub(/(^|[^}])_([<>])/m,'\1\2') # _<_<
|
|
295
|
+
end
|
|
296
|
+
dob.obj=dob.obj.gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'\1').
|
|
297
|
+
gsub(/<a href=".+?">(.+?)<\/a>/m,'\1').
|
|
298
|
+
gsub(/#{Mx[:mk_o]}:name#(\S+?)#{Mx[:mk_c]}/,''). # remove name links
|
|
299
|
+
gsub(/ |#{Mx[:nbsp]}/,' '). # decide on
|
|
300
|
+
gsub(/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/,' [ \1 ]'). #"[ #{dir.url.images_local}\/\\1 ]")
|
|
301
|
+
gsub(/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}image/,' [ \1 ]').
|
|
302
|
+
gsub(/(?:^|[^_\\])\{\s*\S+?\.(?:png|jpg|gif)\s+.+?"(.*?)"\s*\}\S+/,'[image: "\1"]')
|
|
303
|
+
if dob.obj !~/(^#{Rx[:meta]}|#{Mx[:br_eof]}|#{Mx[:br_endnotes]})/
|
|
304
|
+
p_num=''
|
|
305
|
+
#ocn
|
|
306
|
+
if dob.is==:heading \
|
|
307
|
+
or dob.is==:para
|
|
308
|
+
plaintext_structure(dob,p_num)
|
|
309
|
+
elsif dob.is==:group \
|
|
310
|
+
or dob.is==:block \
|
|
311
|
+
or dob.is==:verse \
|
|
312
|
+
or dob.is==:code \
|
|
313
|
+
or dob.is==:table
|
|
314
|
+
@plaintext[:body] << dob.obj + p_num << break_line
|
|
315
|
+
elsif dob.is==:break
|
|
316
|
+
sp=' '
|
|
317
|
+
ln='<' #ln='-'
|
|
318
|
+
@plaintext[:body] <<=if dob.obj==Mx[:br_page] \
|
|
319
|
+
or dob.obj==Mx[:br_page_new] \
|
|
320
|
+
or dob.obj==Mx[:br_page_line]
|
|
321
|
+
"#{break_line}#{ln*40}#{break_line*2}"
|
|
322
|
+
elsif dob.obj ==Mx[:br_obj]
|
|
323
|
+
"#{break_line}#{sp*20}* * *#{break_line*2}"
|
|
324
|
+
end # following empty line (break_line) missing, fix
|
|
325
|
+
end
|
|
326
|
+
dob='' if (dob.obj =~/<a name="n\d+">/ \
|
|
327
|
+
and dob.obj =~/^(-\{{2}~\d+|<!e[:_]\d+!>)/) # -endnote
|
|
328
|
+
if dob ## Clean Prepared Text
|
|
329
|
+
dob.obj=dob.obj.gsub(/<!.+!>/,' ').
|
|
330
|
+
gsub(/<:\S+>/,' ')
|
|
331
|
+
end
|
|
332
|
+
end
|
|
333
|
+
end
|
|
334
|
+
@plaintext
|
|
335
|
+
end
|
|
336
|
+
def publish(plaintext)
|
|
337
|
+
divider='='
|
|
338
|
+
content=[]
|
|
339
|
+
content << plaintext[:open]
|
|
340
|
+
content << plaintext[:head]
|
|
341
|
+
content << plaintext[:body]
|
|
342
|
+
content << @@endnotes[:end] if @@endnotes_
|
|
343
|
+
content << "#{break_line}#{divider*@wrap_width}#{break_line}"
|
|
344
|
+
content << plaintext[:metadata]
|
|
345
|
+
content << "#{break_line}#{divider*@wrap_width}#{break_line}" if @md.stmp =~/\w+/ #not used?
|
|
346
|
+
content << plaintext[:tail]
|
|
347
|
+
outputfile=SiSU_Env::FileOp.new(@md).write_file.asciidoc
|
|
348
|
+
Txt_Output::Output.new.document(content,outputfile)
|
|
349
|
+
@@endnotes={ para: [], end: [] }
|
|
350
|
+
end
|
|
351
|
+
end
|
|
352
|
+
end
|
|
353
|
+
end
|
|
354
|
+
__END__
|