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.
Files changed (207) hide show
  1. checksums.yaml +7 -0
  2. data/bin/sisu +367 -0
  3. data/bin/sisugem +367 -0
  4. data/data/sisu/image/arrow_next_red.png +0 -0
  5. data/data/sisu/image/arrow_prev_red.png +0 -0
  6. data/data/sisu/image/arrow_up_red.png +0 -0
  7. data/data/sisu/image/b_bluebell.png +0 -0
  8. data/data/sisu/image/b_doc.png +0 -0
  9. data/data/sisu/image/b_epub.png +0 -0
  10. data/data/sisu/image/b_home.png +0 -0
  11. data/data/sisu/image/b_info.png +0 -0
  12. data/data/sisu/image/b_odf.png +0 -0
  13. data/data/sisu/image/b_pdf.png +0 -0
  14. data/data/sisu/image/b_search.png +0 -0
  15. data/data/sisu/image/b_toc.png +0 -0
  16. data/data/sisu/image/bullet_08.png +0 -0
  17. data/data/sisu/image/bullet_09.png +0 -0
  18. data/data/sisu/image/bullet_10.png +0 -0
  19. data/data/sisu/image/bullet_11.png +0 -0
  20. data/data/sisu/image/bullet_12.png +0 -0
  21. data/data/sisu/image/bullet_doc.png +0 -0
  22. data/data/sisu/image/bullet_red.png +0 -0
  23. data/data/sisu/image/dot_clear.png +0 -0
  24. data/data/sisu/image/dot_white.png +0 -0
  25. data/data/sisu/image/gplv3.png +0 -0
  26. data/data/sisu/image/gplv3_free_software.png +0 -0
  27. data/data/sisu/image/next.png +0 -0
  28. data/data/sisu/image/previous.png +0 -0
  29. data/data/sisu/image/rb7.ico +0 -0
  30. data/data/sisu/image/sisu.png +0 -0
  31. data/data/sisu/image/toctoc.png +0 -0
  32. data/data/sisu/version.yml +5 -0
  33. data/lib/sisu.rb +94 -0
  34. data/lib/sisu/air.rb +80 -0
  35. data/lib/sisu/ao.rb +590 -0
  36. data/lib/sisu/ao_character_check.rb +102 -0
  37. data/lib/sisu/ao_composite.rb +286 -0
  38. data/lib/sisu/ao_doc_objects.rb +565 -0
  39. data/lib/sisu/ao_doc_str.rb +2269 -0
  40. data/lib/sisu/ao_endnotes.rb +136 -0
  41. data/lib/sisu/ao_expand_insertions.rb +514 -0
  42. data/lib/sisu/ao_hash_digest.rb +174 -0
  43. data/lib/sisu/ao_idx.rb +422 -0
  44. data/lib/sisu/ao_images.rb +187 -0
  45. data/lib/sisu/ao_metadata.rb +86 -0
  46. data/lib/sisu/ao_misc_arrange.rb +207 -0
  47. data/lib/sisu/ao_numbering.rb +720 -0
  48. data/lib/sisu/ao_persist.rb +194 -0
  49. data/lib/sisu/ao_references.rb +502 -0
  50. data/lib/sisu/ao_syntax.rb +640 -0
  51. data/lib/sisu/cgi.rb +84 -0
  52. data/lib/sisu/cgi_pgsql.rb +270 -0
  53. data/lib/sisu/cgi_sql_common.rb +986 -0
  54. data/lib/sisu/cgi_sqlite.rb +244 -0
  55. data/lib/sisu/conf.rb +287 -0
  56. data/lib/sisu/constants.rb +388 -0
  57. data/lib/sisu/css.rb +3484 -0
  58. data/lib/sisu/db_columns.rb +1997 -0
  59. data/lib/sisu/db_create.rb +689 -0
  60. data/lib/sisu/db_dbi.rb +90 -0
  61. data/lib/sisu/db_drop.rb +207 -0
  62. data/lib/sisu/db_import.rb +877 -0
  63. data/lib/sisu/db_indexes.rb +146 -0
  64. data/lib/sisu/db_load_tuple.rb +323 -0
  65. data/lib/sisu/db_remove.rb +182 -0
  66. data/lib/sisu/db_select.rb +230 -0
  67. data/lib/sisu/db_sqltxt.rb +173 -0
  68. data/lib/sisu/db_tests.rb +114 -0
  69. data/lib/sisu/dbi.rb +166 -0
  70. data/lib/sisu/dbi_discrete.rb +206 -0
  71. data/lib/sisu/digests.rb +306 -0
  72. data/lib/sisu/dp.rb +1606 -0
  73. data/lib/sisu/dp_identify_markup.rb +161 -0
  74. data/lib/sisu/dp_make.rb +668 -0
  75. data/lib/sisu/embedded.rb +149 -0
  76. data/lib/sisu/errors.rb +84 -0
  77. data/lib/sisu/generic_parts.rb +131 -0
  78. data/lib/sisu/git.rb +277 -0
  79. data/lib/sisu/html.rb +775 -0
  80. data/lib/sisu/html_concordance.rb +391 -0
  81. data/lib/sisu/html_format.rb +1348 -0
  82. data/lib/sisu/html_harvest.rb +109 -0
  83. data/lib/sisu/html_harvest_author_format.rb +111 -0
  84. data/lib/sisu/html_harvest_authors.rb +466 -0
  85. data/lib/sisu/html_harvest_topics.rb +893 -0
  86. data/lib/sisu/html_lite_shared.rb +324 -0
  87. data/lib/sisu/html_manifest.rb +1032 -0
  88. data/lib/sisu/html_minitoc.rb +230 -0
  89. data/lib/sisu/html_parts.rb +437 -0
  90. data/lib/sisu/html_persist.rb +237 -0
  91. data/lib/sisu/html_promo.rb +440 -0
  92. data/lib/sisu/html_scroll.rb +235 -0
  93. data/lib/sisu/html_segments.rb +716 -0
  94. data/lib/sisu/html_shared.rb +62 -0
  95. data/lib/sisu/html_table.rb +64 -0
  96. data/lib/sisu/html_tune.rb +301 -0
  97. data/lib/sisu/hub.rb +277 -0
  98. data/lib/sisu/hub_actions.rb +1122 -0
  99. data/lib/sisu/hub_loop_markup_files.rb +170 -0
  100. data/lib/sisu/hub_options.rb +1695 -0
  101. data/lib/sisu/i18n.rb +702 -0
  102. data/lib/sisu/manpage.rb +377 -0
  103. data/lib/sisu/manpage_format.rb +85 -0
  104. data/lib/sisu/object_munge.rb +307 -0
  105. data/lib/sisu/prog_text_translation.rb +1702 -0
  106. data/lib/sisu/qrcode.rb +754 -0
  107. data/lib/sisu/relaxng.rb +1153 -0
  108. data/lib/sisu/remote.rb +246 -0
  109. data/lib/sisu/rexml.rb +148 -0
  110. data/lib/sisu/se.rb +158 -0
  111. data/lib/sisu/se_cleanoutput.rb +145 -0
  112. data/lib/sisu/se_clear.rb +105 -0
  113. data/lib/sisu/se_createsite.rb +273 -0
  114. data/lib/sisu/se_css.rb +221 -0
  115. data/lib/sisu/se_date.rb +92 -0
  116. data/lib/sisu/se_db.rb +214 -0
  117. data/lib/sisu/se_envcall.rb +326 -0
  118. data/lib/sisu/se_file_op.rb +2758 -0
  119. data/lib/sisu/se_filemap.rb +247 -0
  120. data/lib/sisu/se_get_init.rb +238 -0
  121. data/lib/sisu/se_hub_particulars.rb +234 -0
  122. data/lib/sisu/se_info_env.rb +2179 -0
  123. data/lib/sisu/se_info_port.rb +70 -0
  124. data/lib/sisu/se_info_system.rb +202 -0
  125. data/lib/sisu/se_load.rb +108 -0
  126. data/lib/sisu/se_processing.rb +659 -0
  127. data/lib/sisu/se_programs.rb +394 -0
  128. data/lib/sisu/se_remotes.rb +553 -0
  129. data/lib/sisu/se_standardise_lang.rb +176 -0
  130. data/lib/sisu/se_version.rb +174 -0
  131. data/lib/sisu/shared_images.rb +137 -0
  132. data/lib/sisu/shared_markup_alt.rb +336 -0
  133. data/lib/sisu/shared_metadata.rb +1361 -0
  134. data/lib/sisu/shared_sem.rb +156 -0
  135. data/lib/sisu/sisu_thor_lib.rb +407 -0
  136. data/lib/sisu/sitemaps.rb +224 -0
  137. data/lib/sisu/src_kdissert_share.rb +102 -0
  138. data/lib/sisu/src_po4a_share.rb +309 -0
  139. data/lib/sisu/src_po4a_shelf.rb +1217 -0
  140. data/lib/sisu/src_po4a_shelf_set.rb +297 -0
  141. data/lib/sisu/src_po4a_sst_ao_sst.rb +893 -0
  142. data/lib/sisu/src_po4a_sst_ao_sst_set.rb +284 -0
  143. data/lib/sisu/src_po4a_sstm.rb +135 -0
  144. data/lib/sisu/src_shared.rb +347 -0
  145. data/lib/sisu/src_sisupod_make.rb +171 -0
  146. data/lib/sisu/src_sisupod_sstm.rb +109 -0
  147. data/lib/sisu/sst_convert_markup.rb +323 -0
  148. data/lib/sisu/sst_do_inline_footnotes.rb +440 -0
  149. data/lib/sisu/sst_from_xml.rb +178 -0
  150. data/lib/sisu/sst_identify_markup.rb +482 -0
  151. data/lib/sisu/sst_to_s_xml_sax.rb +471 -0
  152. data/lib/sisu/termsheet.rb +163 -0
  153. data/lib/sisu/texinfo.rb +430 -0
  154. data/lib/sisu/texinfo_format.rb +541 -0
  155. data/lib/sisu/texpdf.rb +1162 -0
  156. data/lib/sisu/texpdf_format.rb +1689 -0
  157. data/lib/sisu/texpdf_parts.rb +235 -0
  158. data/lib/sisu/txt_asciidoc.rb +354 -0
  159. data/lib/sisu/txt_asciidoc_decorate.rb +207 -0
  160. data/lib/sisu/txt_markdown.rb +389 -0
  161. data/lib/sisu/txt_markdown_decorate.rb +207 -0
  162. data/lib/sisu/txt_orgmode.rb +376 -0
  163. data/lib/sisu/txt_orgmode_decorate.rb +186 -0
  164. data/lib/sisu/txt_output.rb +86 -0
  165. data/lib/sisu/txt_plain.rb +410 -0
  166. data/lib/sisu/txt_plain_decorate.rb +189 -0
  167. data/lib/sisu/txt_read.rb +109 -0
  168. data/lib/sisu/txt_rst.rb +371 -0
  169. data/lib/sisu/txt_rst_decorate.rb +186 -0
  170. data/lib/sisu/txt_shared.rb +241 -0
  171. data/lib/sisu/txt_textile.rb +367 -0
  172. data/lib/sisu/txt_textile_decorate.rb +186 -0
  173. data/lib/sisu/update.rb +141 -0
  174. data/lib/sisu/urls.rb +696 -0
  175. data/lib/sisu/utils.rb +232 -0
  176. data/lib/sisu/utils_composite.rb +115 -0
  177. data/lib/sisu/utils_response.rb +114 -0
  178. data/lib/sisu/utils_screen_text_color.rb +472 -0
  179. data/lib/sisu/utils_spell.rb +99 -0
  180. data/lib/sisu/webrick.rb +191 -0
  181. data/lib/sisu/wikispeak.rb +375 -0
  182. data/lib/sisu/xhtml.rb +472 -0
  183. data/lib/sisu/xhtml_epub2.rb +890 -0
  184. data/lib/sisu/xhtml_epub2_concordance.rb +322 -0
  185. data/lib/sisu/xhtml_epub2_format.rb +2272 -0
  186. data/lib/sisu/xhtml_epub2_persist.rb +278 -0
  187. data/lib/sisu/xhtml_epub2_segments.rb +599 -0
  188. data/lib/sisu/xhtml_epub2_tune.rb +330 -0
  189. data/lib/sisu/xhtml_parts.rb +183 -0
  190. data/lib/sisu/xhtml_shared.rb +62 -0
  191. data/lib/sisu/xhtml_table.rb +97 -0
  192. data/lib/sisu/xml_docbook5.rb +376 -0
  193. data/lib/sisu/xml_dom.rb +624 -0
  194. data/lib/sisu/xml_fictionbook2.rb +389 -0
  195. data/lib/sisu/xml_format.rb +865 -0
  196. data/lib/sisu/xml_md_oai_pmh_dc.rb +229 -0
  197. data/lib/sisu/xml_odf_odt.rb +887 -0
  198. data/lib/sisu/xml_odf_odt_format.rb +674 -0
  199. data/lib/sisu/xml_parts.rb +191 -0
  200. data/lib/sisu/xml_persist.rb +126 -0
  201. data/lib/sisu/xml_sax.rb +521 -0
  202. data/lib/sisu/xml_scaffold_structure_collapsed.rb +198 -0
  203. data/lib/sisu/xml_scaffold_structure_sisu.rb +201 -0
  204. data/lib/sisu/xml_shared.rb +665 -0
  205. data/lib/sisu/xml_tables.rb +261 -0
  206. data/lib/sisu/zap.rb +90 -0
  207. metadata +251 -0
@@ -0,0 +1,330 @@
1
+ # encoding: utf-8
2
+ =begin
3
+
4
+ * Name: SiSU
5
+
6
+ ** Description: documents, structuring, processing, publishing, search
7
+ *** epub generation, epub pre-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/xhtml_epub2_tune.rb;hb=HEAD>
55
+
56
+ =end
57
+ require_relative 'dp' # dp.rb
58
+ module SiSU_XHTML_EPUB2_Tune
59
+ require_relative 'se' # se.rb
60
+ include SiSU_Env; include SiSU_Screen
61
+ require_relative 'xhtml_parts' # xhtml_parts.rb
62
+ require_relative 'xhtml_epub2_format' # xhtml_epub2_format.rb #watch
63
+ @@line_mode=''
64
+ @@endnote_array=[]
65
+ @@endnote_call_counter=1
66
+ @@table_align='<table summary='' width="96%" border="0" bgcolor="white" cellpadding="0" col="3">
67
+ <tr ...><td width="2%" align="right">
68
+ &nbsp\;</td>
69
+ <td width="94%" valign="top" align="justify">'
70
+ @@table_align_close='</td>
71
+ <td width="4%" align="right" valign="top">
72
+ <font size="1" color="#777777">
73
+ &nbsp;&nbsp;&nbsp;</font> </td></tr></table>'
74
+ @@counter,@@column,@columns=0,0,0
75
+ class Output
76
+ def initialize(data,md)
77
+ @data,@md=data,md
78
+ @file=SiSU_Env::InfoFile.new(@md.fns)
79
+ @cX=SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set]).cX
80
+ end
81
+ def hard_output
82
+ @filename_tune=@file.write_file_processing.html_tune
83
+ data=[]
84
+ @data.each {|x| x.obj.strip; data << x if not x.obj.empty?} #1.9 array?
85
+ data.each do |dob|
86
+ @filename_tune.puts dob, "\n" #check
87
+ end
88
+ end
89
+ def marshal
90
+ File.open(@file.marshal.xhtml_tune,'w') {|f| Marshal.dump(@data.to_a,f)}
91
+ end
92
+ end
93
+ class CleanXHTML
94
+ def initialize(html='')
95
+ @html=html
96
+ end
97
+ def clean
98
+ html=@html
99
+ str=if html.is_a?(String)
100
+ html
101
+ else html.obj
102
+ end
103
+ str=str.gsub(/#{Mx[:gl_o]}(#[0-9]{3})#{Mx[:gl_c]}/u,'&\1;').
104
+ gsub(/#{Mx[:gl_o]}#([a-z]{2,4})#{Mx[:gl_c]}/u,'&\1;').
105
+ gsub(/<br>/u,'<br />').
106
+ gsub(/#{Mx[:nbsp]}/u,$ep[:hsp])
107
+ end
108
+ end
109
+ class Tune
110
+ include SiSU_Parts_XHTML
111
+ def initialize(data,md)
112
+ @data,@md=data,md
113
+ @sys=SiSU_Env::SystemCall.new
114
+ @env=SiSU_Env::InfoEnv.new(@md.fns)
115
+ end
116
+ def songsheet
117
+ begin
118
+ @cX=SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set]).cX
119
+ if (@md.opt.act[:verbose][:set]==:on \
120
+ || @md.opt.act[:verbose_plus][:set]==:on \
121
+ || @md.opt.act[:maintenance][:set]==:on)
122
+ SiSU_Screen::Ansi.new(
123
+ @md.opt.act[:color_state][:set],
124
+ 'Tune'
125
+ ).txt_grey
126
+ end
127
+ data=SiSU_XHTML_EPUB2_Tune::Tune.new(@data,@md).amp_angle_brackets
128
+ data=SiSU_XHTML_EPUB2_Tune::Tune.new(data,@md).endnotes_html
129
+ data=SiSU_XHTML_EPUB2_Tune::Tune.new(data,@md).url_markup
130
+ data=SiSU_XHTML_EPUB2_Tune::Tune.new(data,@md).markup
131
+ if @md.opt.act[:maintenance][:set]==:on #Hard Output Tune Optional on/off here
132
+ data=SiSU_XHTML_EPUB2_Tune::Output.new(data,@md).hard_output
133
+ SiSU_XHTML_EPUB2_Tune::Output.new(data,@md).marshal
134
+ end
135
+ SiSU_XHTML_EPUB2_Tune::Tune.new(@data,@md).output
136
+ rescue
137
+ SiSU_Errors::Rescued.new($!,$@,@md.opt.selections.str,@md.fns).location do
138
+ __LINE__.to_s + ':' + __FILE__
139
+ end
140
+ ensure
141
+ end
142
+ end
143
+ def markup
144
+ @tuned_file=[]
145
+ @data.each do |dob|
146
+ dob.obj=dob.obj.gsub(/#{Mx[:mk_o]}#([a-zA-Z]+)#{Mx[:mk_c]}/,'&\1;').
147
+ gsub(/#{Mx[:mk_o]}(#[0-9]+)#{Mx[:mk_c]}/,'&\1;')
148
+ dob.obj=dob.obj.gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,'<br />') unless dob.is==:table
149
+ dob.obj=dob.obj.gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'<b>\1</b>').
150
+ gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'<i>\1</i>').
151
+ gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'<u>\1</u>').
152
+ gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,'<sup>\1</sup>').
153
+ gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,'<sub>\1</sub>').
154
+ gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'<ins>\1</ins>').
155
+ gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'<cite>\1</cite>').
156
+ gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'<del>\1</del>').
157
+ gsub(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/,'<tt>\1</tt>'). # tt, kbd
158
+ gsub(/#{Mx[:mk_o]}:name#(\S+?)#{Mx[:mk_c]}/,'').
159
+ gsub(/#{Mx[:gl_bullet]}/m,"●#{$ep[:hsp]*2}").
160
+ gsub(/#{Dx[:url_o]}/,Dx[:url_o_xml]).gsub(/#{Dx[:url_c]}/,Dx[:url_c_xml]).
161
+ gsub(/#{Mx[:nbsp]}/,$ep[:hsp]).
162
+ gsub(/<(p|br)>/,'<\1 />')
163
+ dob.obj=SiSU_XHTML_EPUB2_Tune::CleanXHTML.new(dob.obj).clean
164
+ @tuned_file << dob
165
+ end
166
+ end
167
+ def urls(data)
168
+ @words=[]
169
+ map_nametags=SiSU_Particulars::CombinedSingleton.instance.get_map_nametags(@md).nametags_map #p map_nametags
170
+ data.each do |word|
171
+ @words << if word=~/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}|image)/
172
+ http_=true
173
+ if word =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/
174
+ m,u=/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/.match(word).captures
175
+ elsif word =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/
176
+ http_=false
177
+ m,u=/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:rel_o]}(\S+?)#{Mx[:rel_c]}/.match(word).captures
178
+ elsif word =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}image/
179
+ m,u=/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}(image)/.match(word).captures
180
+ end
181
+ case m
182
+ when /\.png|\.jpg|\.gif|c=|\s\d+x\d+/
183
+ w,h=/\s(\d+)x(\d+)/.match(m).captures if m =~/\s\d+x\d+/
184
+ w=%{width="#{w}"} if w
185
+ h=%{height="#{h}"} if h
186
+ c=m[/"(.+?)"/m,1]
187
+ caption=%{<br /><p class="caption">#{c}</p>} if c
188
+ png=m.scan(/\S+/)[0]
189
+ image_path=@md.file.output_path.epub.rel_image #image_path=@env.url.images_epub
190
+ ins=if u \
191
+ and u.strip !~/^image$/
192
+ %{<a href="#{u}"><img src="#{image_path}/#{png}" #{w} #{h} naturalsizeflag="0" align="bottom" border="0" /></a>#{caption}}
193
+ else %{<img src="#{image_path}/#{png}" #{w} #{h} naturalsizeflag="0" align="bottom" border="0" />#{caption}}
194
+ end
195
+ word=word.gsub(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/,ins)
196
+ else
197
+ link=m[/(.+)/m]
198
+ png=m.scan(/\S+/)[0].strip
199
+ link=link.strip
200
+ u=u.sub(/^#*/,'') #make neater
201
+ if map_nametags[u] \
202
+ and map_nametags[u][:segname]
203
+ u=unless http_
204
+ u=if u=~/^\d+$/
205
+ u.gsub(/^(\d+)$/,"#{map_nametags[u][:segname]}#{Sfx[:xhtml]}#o\\1") if u !~/\//
206
+ else
207
+ u.gsub(/(\S+)/,"#{map_nametags[u][:segname]}#{Sfx[:xhtml]}#\\1") if u !~/\//
208
+ end
209
+ else u
210
+ end
211
+ elsif u =~/^:/
212
+ u=u.gsub(/^:/,"#{@env.url.root}/")
213
+ elsif u =~/^\.\.\//
214
+ u=u.gsub(/^\.\.\//,"#{@env.url.root}/")
215
+ elsif u =~/https?:\/\//
216
+ else p "NOT FOUND name_tags: #{u}"
217
+ end
218
+ ins=%{<a href="#{u}">#{link}</a>}
219
+ word=word.gsub(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/,ins).
220
+ gsub(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/,ins)
221
+ end
222
+ word
223
+ else word
224
+ end
225
+ word
226
+ end
227
+ @words=@words.join(' ')
228
+ end
229
+ def url_markup
230
+ data=@data
231
+ @tuned_file=[]
232
+ data.each do |dob|
233
+ unless dob.is==:code
234
+ if dob.obj =~/<::\s+/ #watch
235
+ dob.obj=dob.obj.gsub(/<::\s+(\S+?)\s+!>/,
236
+ %{<img src="#{@env.url.images_epub}/c_\\1.png" alt="\\1" width="14" height="14" align="bottom" border="0" />})
237
+ end
238
+ if dob.obj =~/<:image\s+/
239
+ dob.obj=dob.obj.gsub(/<:image\s+(http\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+>/,
240
+ %{<a href="\\1"><img src="#{@env.url.images_epub}/\\2" \\3 \\4 naturalsizeflag="0" align="bottom" border="0" /></a>}).
241
+ gsub(/<:image\s+(http\S+)\s+(\S+)\s+>/,
242
+ %{<a href="\\1"><img src="#{@env.url.images_epub}/\\2" naturalsizeflag="0" align="bottom" border="0" /></a>}).
243
+ gsub(/<:image\s+(\S+)\s+(\S+)\s+(\S+)\s+>/,
244
+ %{<img src="#{@env.url.images_epub}/\\1" \\2 \\3 naturalsizeflag="0" align="bottom" border="0" />}).
245
+ gsub(/<:image\s+(\S+)\s+>/,
246
+ %{<img src="#{@env.url.images_epub}/\\1" naturalsizeflag="0" align="bottom" border="0" />})
247
+ end
248
+ if dob.obj =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}|image)/
249
+ @word_mode=dob.obj.scan(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}|image)[()\[\]]*[,.;:!?'"]{0,2}|(?:#{Mx[:gl_o]}\S+?#{Mx[:gl_c]})+|[^#{Mx[:lnk_o]}#{Mx[:lnk_c]}]+/mu)
250
+ words=urls(@word_mode)
251
+ dob.obj=dob.obj.gsub(/.+/m,words)
252
+ end
253
+ dob.obj=dob.obj.gsub(/\\copyright/i,%{<sup>&copy;</sup>})
254
+ dob.obj=if (dob.obj !~/\<:ad\s+\.\.\//)
255
+ dob.obj.gsub(/\<:ad\s+(\S+)?\s+(\S+\.png)\s+(.+)?\;\s+(.+)?\;\s*!\>/,
256
+ %{\n<center><a href="http:\/\/\\1" target="external"><img src="#{@env.url.images_epub}/\\2" alt="\\3" /></a></center>\n})
257
+ else
258
+ dob.obj.gsub(/\<:ad\s+(\S+)?\s+(\S+\.png)\s+(.+)?\;\s+(.+)?\;\s*\>/,
259
+ %{\n<center><a href="\\1" target="_top"><img src="#{@env.url.images_epub}/\\2" alt="\\3" /></a></center>\n})
260
+ end
261
+ dob.obj=dob.obj.gsub(/!pick/,%{<img border="0" height="15" width="15" src="#{@env.url.images_epub}/#{the_icon.i_choice}" alt="stellar" />}).
262
+ gsub(/!new/,%{#{$ep[:hsp]}<img border="0" height="15" width="15" src="#{@env.url.images_epub}/#{the_icon.i_new}" alt="new" />}).
263
+ gsub(/<:h(.{1,7}?)>/,'<a href="#h\1">\1</a>').
264
+ gsub(/<:to(\d{1,7}?)>/,%{<a href="#to\\1">to#{$ep[:hsp]}\{#{$ep[:hsp]}\\1#{$ep[:hsp]}\}</a> }).
265
+ gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'<a href="\1" target="_top">\1</a>'). #http ftp matches escaped, no decoration
266
+ gsub(/#{Mx[:url_o]}([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)#{Mx[:url_c]}/,%{#{the_url_decoration.xml_open}<a href="mailto:\\1">\\1</a>#{the_url_decoration.xml_close}}).
267
+ gsub(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,%{#{the_url_decoration.xml_open}<a href="\\1" target="_top">\\1</a>#{the_url_decoration.xml_close}}) #http ftp matches with decoration
268
+ if dob.obj =~/..\/\S+/ \
269
+ and dob.obj !~/(\"..\/\S+?\"|>\s*..\/\S+<)/
270
+ dob.obj=dob.obj.gsub(/(\.\.\/\S+)/,'<a href="\1">\1</a>')
271
+ end
272
+ dob.obj=dob.obj.gsub(/<a href="\.\.\//,%{<a href="#{the_url.site}/})
273
+ else
274
+ dob.obj=dob.obj.gsub(/</m,'&lt;').gsub(/>/m,'&gt;')
275
+ end
276
+ @tuned_file << dob
277
+ end
278
+ end
279
+ def amp_angle_brackets
280
+ data,data_new=@data,[]
281
+ data.each do |dob|
282
+ dob.obj=dob.obj.
283
+ gsub(/&/u,'&amp;').
284
+ gsub(/</u,'&lt;').gsub(/>/u,'&gt;')
285
+ data_new << dob
286
+ end
287
+ data_new
288
+ end
289
+ def endnotes_html
290
+ data=@data
291
+ @tuned_file=[]
292
+ a,s='_a','_s'
293
+ ast,pls='&#042;','&#043;'
294
+ data.each do |dob|
295
+ unless dob.is ==:code
296
+ dob.obj=dob.obj.gsub(/(#{Mx[:en_a_o]}|#{Mx[:en_b_o]})(\d+)\s+(.+?)(#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/,
297
+ %{#{Mx[:nbsp]}<a href="##{Mx[:note]}\\2">#{Mx[:nbsp]}<sup id="#{Mx[:note_ref]}\\2">\\2</sup>#{Mx[:nbsp]}</a> } + #note- endnote-
298
+ %{\\1\\2 <a href="##{Mx[:note_ref]}\\2">#{Mx[:nbsp]}<sup id="#{Mx[:note]}\\2">\\2.</sup></a> \\3 \\4}). #endnote- note- (careful may have switched)
299
+ gsub(/(#{Mx[:en_b_o]})[*](\d+)\s+(.+?)(#{Mx[:en_b_c]})/,
300
+ %{#{Mx[:nbsp]}<a href="##{Mx[:note_astx]}\\2">#{Mx[:nbsp]}<sup id="#{Mx[:note_ref_astx]}\\2">#{ast}\\2</sup>#{Mx[:nbsp]}</a> } + #note- endnote-
301
+ %{\\1#{ast}\\2 <a href="##{Mx[:note_ref_astx]}\\2">#{Mx[:nbsp]}<sup id="#{Mx[:note_astx]}\\2">#{ast}\\2.</sup></a> \\3 \\4}). #endnote- note- (careful may have switched)
302
+ gsub(/(#{Mx[:en_b_o]})[+](\d+)\s+(.+?)(#{Mx[:en_b_c]})/,
303
+ %{#{Mx[:nbsp]}<a href="##{Mx[:note_plus]}\\2">#{Mx[:nbsp]}<sup id="#{Mx[:note_ref_plus]}\\2">#{pls}\\2</sup>#{Mx[:nbsp]}</a> } + #note- endnote-
304
+ %{\\1#{pls}\\2 <a href="##{Mx[:note_ref_plus]}\\2">#{Mx[:nbsp]}<sup id="#{Mx[:note_plus]}\\2">#{pls}\\2.</sup></a> \\3 \\4}) #endnote- note- (careful may have switched) # double-check there may here be a bug
305
+ if dob.obj =~/#{Mx[:en_a_o]}([*+]+)\s+.+?#{Mx[:en_a_c]}/
306
+ m=$1.length.to_i
307
+ dob.obj=dob.obj.gsub(/(#{Mx[:en_a_o]})[*]+\s+(.+?)(#{Mx[:en_a_c]})/,
308
+ %{#{Mx[:nbsp]}<a href="##{Mx[:note]}#{a*m}">#{Mx[:nbsp]}<sup id="#{Mx[:note_ref]}#{a*m}">#{ast*m}</sup>#{Mx[:nbsp]}</a> } + #note- endnote-
309
+ %{\\1#{ast*m} <a href="##{Mx[:note_ref]}#{a*m}">#{Mx[:nbsp]}<sup id="#{Mx[:note]}#{a*m}">#{ast*m}</sup></a> \\2 \\3}). #endnote- note- (careful may have switched)
310
+ gsub(/(#{Mx[:en_a_o]})([+]+)\s+(.+?)(#{Mx[:en_a_c]})/,
311
+ %{#{Mx[:nbsp]}<a href="##{Mx[:note]}#{s*m}">#{Mx[:nbsp]}<sup id="#{Mx[:note_ref]}#{s*m}">#{pls*m}</sup>#{Mx[:nbsp]}</a> } + #note- endnote-
312
+ %{\\1#{pls*m} <a href="##{Mx[:note_ref]}#{s*m}">#{Mx[:nbsp]}<sup id="#{Mx[:note]}#{s*m}">#{pls*m}</sup></a> \\2 \\3}) #endnote- note- (careful may have switched)
313
+ end
314
+ end
315
+ @tuned_file << dob
316
+ end
317
+ end
318
+ def output
319
+ data=@data
320
+ @tuned_file=[]
321
+ data.each do |dob|
322
+ dob.obj=dob.obj.strip.chomp
323
+ @tuned_file << dob
324
+ end
325
+ @tuned_file << "\n<EOF>" if (@md.fns =~/\.sst0/) #remove
326
+ @tuned_file
327
+ end
328
+ end
329
+ end
330
+ __END__
@@ -0,0 +1,183 @@
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_XHTML
58
+ require_relative 'generic_parts' # generic_parts.rb
59
+ include SiSU_Parts_Generic
60
+ def the_line_break
61
+ '<br />'
62
+ end
63
+ def the_table_close
64
+ '</td></tr>
65
+ </table>'
66
+ end
67
+ def the_url
68
+ def home
69
+ 'http://www.sisudoc.org/' # used in pdf header
70
+ end
71
+ def site #used as stub... where there are subdirectories and is different from home
72
+ home
73
+ end
74
+ self
75
+ end
76
+ def the_url_decoration
77
+ def xml_open #'&lt;'
78
+ Dx[:url_o]
79
+ end
80
+ def xml_close #'&gt;'
81
+ Dx[:url_c]
82
+ end
83
+ def txt_open
84
+ '<'
85
+ end
86
+ def txt_close
87
+ '>'
88
+ end
89
+ self
90
+ end
91
+ def the_margin
92
+ def txt_0
93
+ %{<table summary="" width=#{the_width.table_txt} border="0" cellpadding="2" align="center">
94
+ <tr><td width=#{indent_level_0} align="right">
95
+ </td><td valign="top" align="justify">}
96
+ end
97
+ def txt_1
98
+ %{<table summary="" width=#{the_width.table_txt} border="0" cellpadding="2" align="center">
99
+ <tr><td width=#{indent_level_1} align="right"></td><td valign="top" align="justify">}
100
+ end
101
+ def txt_2
102
+ %{<table summary="" width=#{the_width.table_txt} border="0" cellpadding="2" align="center">
103
+ <tr><td width=#{indent_level_2} align="right">
104
+ </td>
105
+ <td valign="top" align="justify">}
106
+ end
107
+ def txt_3
108
+ %{<table summary="" width=#{the_width.table_txt} border="0" cellpadding="2" align="center">
109
+ <tr><td width=#{indent_level_3} align="right">
110
+ </td>
111
+ <td valign="top" align="justify">}
112
+ end
113
+ def css
114
+ '<table summary="normal text css" width="100%" border="0" cellpadding="2" align="center">
115
+ <tr><td valign="top" align="justify"> '
116
+ end
117
+ def num_css
118
+ '</td>
119
+ <td width="2%" align="right" valign="top"> '
120
+ end
121
+ self
122
+ end
123
+ def the_font
124
+ def set_fonts
125
+ 'verdana, arial, georgia, tahoma, sans-serif, helvetica, times, roman'
126
+ #'verdana, arial, georgia, tahoma, sans-serif, helvetica, "times new roman", times, roman'
127
+ end
128
+ def set_small
129
+ 'size="3"'
130
+ end
131
+ def set_tiny
132
+ 'size="2"'
133
+ end
134
+ def paragraph_font_tiny
135
+ %{<font #{set_tiny} #{set_face}>}
136
+ end
137
+ def paragraph_font_small
138
+ %{<font #{set_small} #{set_face}>}
139
+ end
140
+ self
141
+ end
142
+ def the_nav
143
+ def txt_concordance
144
+ %{ <font face="#{the_font.set_fonts}" size="2">
145
+ &nbsp;&nbsp;A-Z&nbsp;
146
+ </font> }
147
+ end
148
+ def txt_toc_link
149
+ %{ <font face="#{the_font.set_fonts}" size="2">
150
+ &nbsp;&nbsp;toc&nbsp;
151
+ </font> }
152
+ end
153
+ def txt_manifest
154
+ #{png_manifest}&nbsp;document&nbsp;manifest
155
+ %{ <font face="#{the_font.set_fonts}" size="2">
156
+ [&nbsp;document&nbsp;manifest&nbsp;]
157
+ </font> }
158
+ end
159
+ def txt_concordance
160
+ %{ <font face="#{the_font.set_fonts}" size="2">
161
+ &nbsp;&nbsp;A-Z&nbsp;
162
+ </font> }
163
+ end
164
+ self
165
+ end
166
+ end
167
+ module SiSU_Proj_XHTML
168
+ require_relative 'se' # se.rb
169
+ include SiSU_Env
170
+ class Bits
171
+ include SiSU_Parts_HTML
172
+ def initialize
173
+ @v=SiSU_Env::InfoVersion.instance.get_version
174
+ end
175
+ def credits_sisu_epub
176
+ %{<div class="substance">
177
+ <p class="center"><a href="http://www.openebook.org"><b>EPUB</b></a> generated by <a href="http://www.sisudoc.org"><b>#{@v.project}</b></a> v#{@v.version}, GPL3</p>
178
+ </div>}
179
+ ''
180
+ end
181
+ end
182
+ end
183
+ __END__