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,391 @@
1
+ # encoding: utf-8
2
+ =begin
3
+
4
+ * Name: SiSU
5
+
6
+ ** Description: documents, structuring, processing, publishing, search
7
+ *** concordance file (html, wordmap, linked index of words in document)
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/html_concordance.rb;hb=HEAD>
55
+
56
+ =end
57
+ module SiSU_Concordance
58
+ require_relative 'se_hub_particulars' # se_hub_particulars.rb
59
+ include SiSU_Particulars
60
+ require_relative 'se' # se.rb
61
+ include SiSU_Env
62
+ require_relative 'html_format' # html_format.rb
63
+ include SiSU_HTML_Format
64
+ require_relative 'html_minitoc' # html_minitoc.rb
65
+ class Source
66
+ def initialize(opt)
67
+ @opt=opt
68
+ @particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt)
69
+ end
70
+ def read
71
+ begin
72
+ @env,@md=@particulars.env,@particulars.md
73
+ @env.url.output_tell
74
+ unless @md.opt.act[:quiet][:set]==:on
75
+ tool=(@md.opt.act[:verbose][:set]==:on \
76
+ || @md.opt.act[:verbose_plus][:set]==:on \
77
+ || @md.opt.act[:maintenance][:set]==:on) \
78
+ ? "#{@env.program.web_browser} #{@md.file.output_path.html_concordance.dir}/#{@md.file.base_filename.html_concordance}"
79
+ : "[#{@opt.f_pth[:lng_is]}] #{@opt.fno}"
80
+ (@md.opt.act[:verbose][:set]==:on \
81
+ || @md.opt.act[:verbose_plus][:set]==:on \
82
+ || @md.opt.act[:maintenance][:set]==:on) \
83
+ ? SiSU_Screen::Ansi.new(
84
+ @opt.act[:color_state][:set],
85
+ "Concordance",
86
+ tool
87
+ ).green_hi_blue
88
+ : SiSU_Screen::Ansi.new(
89
+ @opt.act[:color_state][:set],
90
+ 'Concordance',
91
+ tool
92
+ ).green_title_hi
93
+ end
94
+ wordmax=@env.concord_max
95
+ unless @md.wc_words.nil?
96
+ if @md.wc_words < wordmax
97
+ SiSU_Concordance::Source::Words.new(@particulars).songsheet
98
+ else
99
+ SiSU_Screen::Ansi.new(
100
+ @md.opt.act[:color_state][:set],
101
+ "concordance skipped, large document has over #{wordmax} words (#{@md.wc_words})"
102
+ ).warn unless @md.opt.act[:quiet][:set]==:on
103
+ end
104
+ else
105
+ SiSU_Screen::Ansi.new(
106
+ @md.opt.act[:color_state][:set],
107
+ "wc (word count) is off, concordance will be processed for all files including those over the max set size of: #{wordmax} words"
108
+ ).warn unless @md.opt.act[:quiet][:set]==:on
109
+ SiSU_Concordance::Source::Words.new(@particulars).songsheet
110
+ end
111
+ rescue
112
+ SiSU_Errors::Rescued.new($!,$@,@md.opt.selections.str,@md.fns).location do
113
+ __LINE__.to_s + ':' + __FILE__
114
+ end
115
+ ensure
116
+ SiSU_Env::CreateSite.new(@opt).cp_css
117
+ Dir.chdir(@opt.f_pth[:pth])
118
+ end
119
+ end
120
+ private
121
+ class DocTitle
122
+ #revisit, both requires (html & xml_shared) needed for stand alone operation (sisu -w [filename])
123
+ require_relative 'xml_shared' # xml_shared.rb
124
+ require_relative 'html' # html.rb
125
+ def initialize(particulars)
126
+ @particulars,@md=particulars,particulars.md
127
+ @data=SiSU_HTML::Source::HTML_Environment.new(particulars).tuned_file_instructions
128
+ @file=SiSU_Env::FileOp.new(@md)
129
+ @fnb=@md.fnb
130
+ @lex_button=%{<a href="http://www.jus.uio.no/sisu/" target="_top"><img border="0" height="44" width="144" valign="center" src="#{@file.path_rel_links.html_seg_2}_sisu/image/sisu.png" alt="SiSU home --&gt;"></a>}
131
+ @doc_details =<<WOK
132
+ <table summary="links to text related to this rudimentary index" width="96%" border="0" cellpadding="0" align="center"><tr><td width="2%" align="right">&nbsp;</td><td width="94%" valign="top" align="justify"><h1 class="small"><a href="#{@md.file.base_filename.html_segtoc}"><b>#{@md.title.full}</b></a></h1><p class="bold">#{@md.author}</p></td></tr></table>
133
+ WOK
134
+ @make=SiSU_Env::ProcessingSettings.new(@md)
135
+ end
136
+ def create
137
+ head_banner=SiSU_HTML_Format::HeadToc.new(@md)
138
+ minitoc=SiSU_HTML_MiniToc::TocMini.new(@md,@data).songsheet.join("\n")
139
+ stylesheet=SiSU_Style::CSS_HeadInfo.new(@md).stylesheet
140
+ if @make.build.manifest_minitoc?
141
+ toc='<div class="toc">' + minitoc + '</div>'
142
+ div_class='content'
143
+ else
144
+ toc=''
145
+ div_class='content0'
146
+ end
147
+ top_band=if @make.build.html_top_band?
148
+ head_banner.concordance_navigation_band
149
+ else ''
150
+ end
151
+ <<WOK
152
+ <!DOCTYPE html>
153
+ <html>
154
+ <head>
155
+ <meta charset="utf-8">
156
+ <title>
157
+ SiSU created WordIndex for: #{@md.title.full}
158
+ </title>
159
+ <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
160
+ <meta name="Description" content="&nbsp;SiSU created">
161
+ <meta name="keywords" content="word index for #{@md.title.full}">
162
+ <meta name="generator" content="SiSU (Linux &amp; Ruby!)">
163
+ <link rel="generator" href="http://www.jus.uio.no/sisu" />
164
+ <link rel="shortcut icon" href="../_sisu/image/rb7.ico" />
165
+ #{stylesheet.css_head_seg}
166
+ </head>
167
+ <body>
168
+ #{top_band}
169
+ #{toc}
170
+ <div class="#{div_class}">
171
+ #{@doc_details}
172
+ <p>Word index links are to html versions of the text the segmented version followed by the scroll (single document) version.<br>[For segmented text references [T1], [T2] or [T3] appearing without a link, indicates that the word appears in a title (or subtitle) of the text (that is identifiable by the appended object citation number).]</p>
173
+ <p>(The word listing/index is Case sensitive: Capitalized words appear before lower case)</p>
174
+ <p>
175
+ <b>word</b> (number of occurences)<br>linked references to word within document <br>
176
+ [if number of occurences exceed number of references - word occurs more than once in at least one reference. Footnote/endnotes are either assigned to the paragraph from which they are referenced or ignored, so it is relevant to check the footnotes referenced from within a paragraph as well.]
177
+ </p>
178
+ <p>
179
+ (After the page is fully loaded) you can jump directly to a word by appending a hash (#) and the word to the url for this text, (do not forget that words are case sensitive, and may be listed twice (starting with and without an upper case letter)), #your_word # [&nbsp;http://[web host]/#{@fnb}/concordance.html#your_word&nbsp;]
180
+ </p>
181
+ WOK
182
+ end
183
+ end
184
+ class Word
185
+ @@word_previous=''
186
+ def initialize(word,freq)
187
+ @word,@freq=word,freq
188
+ end
189
+ def html
190
+ w=if @word.capitalize==@@word_previous
191
+ %{\n<p class="concordance_word">#{@word}</p><p class="concordance_count">(#{@freq})</p>\n\t<p class="concordance_object"> }
192
+ else n=@word.strip.gsub(/\s+/,'_') #also need to convert extended character set to html
193
+ %{\n<p class="concordance_word"><a name="#{n}">#{@word}</a></p><p class="concordance_count">(#{@freq})</p>\n\t<p class="concordance_object"> }
194
+ end
195
+ @@word_previous=@word.capitalize
196
+ w
197
+ end
198
+ end
199
+ class Words
200
+ require_relative 'i18n' # i18n.rb
201
+ include SiSU_i18n
202
+ require_relative 'html_format' # html_format.rb
203
+ include SiSU_HTML_Format
204
+ require_relative 'se' # se.rb
205
+ include SiSU_Screen
206
+ @@dp=nil
207
+ def initialize(particulars)
208
+ @particulars=particulars
209
+ begin
210
+ @env,@md,@ao_array=particulars.env,particulars.md,particulars.ao_array
211
+ @file=SiSU_Env::FileOp.new(@md)
212
+ @freq=Hash.new(0)
213
+ @dp=@@dp ||=SiSU_Env::InfoEnv.new.digest.pattern
214
+ @rxp_lv1=/^#{Mx[:lv_o]}1:/ #fix @rxp_lv # Mx[:lv_o]
215
+ @rxp_lv2=/^#{Mx[:lv_o]}2:/ #fix @rxp_lv # Mx[:lv_o]
216
+ @rxp_lv3=/^#{Mx[:lv_o]}3:/ #fix @rxp_lv # Mx[:lv_o]
217
+ @rxp_title=Regexp.new("^#{Mx[:meta_o]}title#{Mx[:meta_c]}\s*(.+?)\s*$")
218
+ @rxp_t1=Regexp.new('^T1')
219
+ @rxp_t2=Regexp.new('^T2')
220
+ @rxp_t3=Regexp.new('^T3')
221
+ @rxp_excluded1=/#{Mx[:url_o]}\S+?#{Mx[:url_c]}|#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/
222
+ @rxp_excluded0=/^(?:#{Mx[:fa_bold_o]}|#{Mx[:fa_italics_o]})?(?:to\d+|\d+|&nbsp;|#{Mx[:br_endnotes]}|EOF|#{Mx[:br_eof]}|thumb_\S+|snap_\S+|_+|-+|[(]?(?:ii+|iv|vi+|ix|xi+|xiv|xv|xvi+|xix|xx)[).]?|\S+?_\S+|[\d_]+\w\S+|[\w\d]{1,2}|\d{1,3}\w?|#{@dp}|[0-9a-f]{16,64}|\d{2,3}x\d{2,3}|\S{0,2}sha\d|\S{0,3}\d{4}w\d\d|\b\w\d+|\d_all\b|e\.?g\.?)(?:#{Mx[:fa_bold_c]}|#{Mx[:fa_italics_c]})?$/mi #this regex causes and cures a stack dump in ruby 1.9 !!!
223
+ @rgx_splitlist=%r{[—.,;:#{Mx[:nbsp]}-]}mi
224
+ @alph=SiSU_i18n::Alphabet.new(@md.opt.lng).hash_arrays
225
+ @alphlst=SiSU_i18n::Alphabet.new(@md.opt.lng).hash_strings
226
+ @rgx_scanlist=%r{#{Mx[:fa_italics_o]}[#{@alphlst[:l]}#{@alphlst[:u]}0-9"\s]{2,12}#{Mx[:fa_italics_c]}|#{Mx[:fa_bold_o]}[#{@alphlst[:l]}#{@alphlst[:u]}0-9"\s]{2,12}#{Mx[:fa_bold_c]}|(?:https?|file)://\S+|<\S+?>|[#{@alphlst[:l]}#{@alphlst[:u]}]+|\w+}mi
227
+ rescue
228
+ SiSU_Errors::Rescued.new($!,$@,@md.opt.selections.str,@md.fns).location do
229
+ __LINE__.to_s + ':' + __FILE__
230
+ end
231
+ end
232
+ end
233
+ def songsheet
234
+ begin
235
+ FileUtils::mkdir_p(@file.output_path.html_concordance.dir) \
236
+ unless FileTest.directory?(@file.output_path.html_concordance.dir)
237
+ @file_concordance=File.open(@file.place_file.html_concordance.dir,'w')
238
+ map_para
239
+ rescue
240
+ SiSU_Errors::Rescued.new($!,$@,@md.opt.selections.str,@md.fns).location do
241
+ __LINE__.to_s + ':' + __FILE__
242
+ end
243
+ ensure
244
+ @file_concordance.close
245
+ end
246
+ end
247
+ protected
248
+ def location_scroll(wordlocation,show) # not used
249
+ %{<a href="doc#{@md.lang_code_insert}#{Sfx[:html]}\##{Mx[:ocn_id_char]}#{wordlocation}">#{wordlocation}</a>; }
250
+ end
251
+ def location_seg(wordlocation,show)
252
+ unless wordlocation.nil?
253
+ wl=wordlocation.gsub(/(.+?)\#(\d+)/,
254
+ "\\1#{@md.lang_code_insert}#{Sfx[:html]}##{Mx[:ocn_id_char]}\\2") # id="o\d+" always available; a name="\d+" not available if html strict used
255
+ case wordlocation
256
+ when /#{@rxp_t1}|@rxp_t2}|#{@rxp_t3}/
257
+ %{[<a href="doc#{@md.lang_code_insert}#{Sfx[:html]}##{show}">H</a>]#{show}, }
258
+ when /(.+?)\#(\d+)/
259
+ %{<a href="#{wl}">#{show}</a>, }
260
+ end
261
+ end
262
+ end
263
+ def map_para
264
+ @seg,ocn=nil,nil
265
+ @word_map={}
266
+ @ao_array.each do |line|
267
+ if defined? line.ocn \
268
+ and line.ocn.to_s =~/\d/
269
+ if (line.is ==:heading \
270
+ || line.is ==:heading_insert) \
271
+ && line.ln==4
272
+ @seg=line.name
273
+ end
274
+ ocn=line.ocn.to_s
275
+ if ocn =~/\d+/ \
276
+ and ocn !~/^0$/
277
+ line.obj=line.obj.gsub(/#{@rxp_excluded1}/,' ')
278
+ line.obj=line.obj.split(@rgx_splitlist).join(' ') #%take in word or other match
279
+ for word in line.obj.scan(@rgx_scanlist) #%take in word or other match
280
+ if word =~ /^([#{@alphlst[:l]}])/
281
+ firstletter=$1
282
+ flu=firstletter.tr(@alphlst[:l],@alphlst[:u])
283
+ word=word.gsub(/^#{firstletter}/,flu )
284
+ end
285
+ word=word.gsub(/#{Mx[:lnk_o]}|#{Mx[:lnk_c]}|#{Mx[:url_o]}|#{Mx[:url_c]}/,'').
286
+ gsub(/#{Mx[:fa_o]}\S+?#{Mx[:fa_o_c]}/,'').
287
+ gsub(/#{Mx[:fa_c_o]}\S+?#{Mx[:fa_c]}/,'').
288
+ gsub(/#{Mx[:gl_o]}#[a-z]+#{Mx[:gl_c]}/,'').
289
+ gsub(/#{Mx[:gl_o]}#[0-9]+#{Mx[:gl_c]}/,'')
290
+ word=word.gsub(/[0-9a-f]{10,}/,' ') if word =~/[0-9]/
291
+ word=word.gsub(/#{Mx[:br_line]}/,' ').
292
+ gsub(/^ +/,'').
293
+ gsub(/^\S$/,'')
294
+ word=nil if word.empty?
295
+ word=nil if word =~@rxp_excluded0 #watch
296
+ word=nil if word =~/^\S$/
297
+ if word
298
+ word=word.gsub(/#{Mx[:br_nl]}|#{Mx[:br_line]}/,' ').
299
+ gsub(/#{Mx[:fa_o]}[a-z]{1,7}#{Mx[:fa_o_c]}|#{Mx[:fa_c_o]}[a-z]{1,7}#{Mx[:fa_c]}/,'').
300
+ gsub(/#{Mx[:en_a_o]}(?:\d|[*+])*|#{Mx[:en_b_o]}(?:\d|[*+])*|#{Mx[:en_a_c]}|#{Mx[:en_b_c]}/mi,'').
301
+ gsub(/#{Mx[:fa_o]}\S+?#{Mx[:fa_o_c]}/,'').
302
+ gsub(/#{Mx[:fa_c_o]}\S+?#{Mx[:fa_c]}/,'').
303
+ gsub(/<\/?\S+?>/,'').
304
+ gsub(/^\@+/,'').
305
+ strip.
306
+ gsub(/#{Mx[:tc_p]}.+/,'').
307
+ gsub(/[\.,;:"]$/,'').
308
+ gsub(/["]/,'').
309
+ gsub(/^\s*[\(]/,'').
310
+ gsub(/[\(]\s*$/,'').
311
+ gsub(/^(?:See|e\.?g\.?).+/,'').
312
+ gsub(/^\s*[.,;:]\s*/,'').
313
+ strip.
314
+ gsub(/^\(?[a-zA-Z]\)$/,'').
315
+ gsub(/^\d+(st|nd|rd|th)$/,'').
316
+ gsub(/^(\d+\.?)+$/, '').
317
+ gsub(/#{Mx[:mk_o]}|#{Mx[:mk_c]}/,'').
318
+ gsub(/:name#\S+/,'').
319
+ gsub(/^\S$/,'')
320
+ word=nil if word =~/^\S$/
321
+ word=nil if word =~/^\s*$/ #watch
322
+ if word
323
+ unless word =~/[A-Z][A-Z]/ \
324
+ or word =~/\w+\s\w+/
325
+ word=word.capitalize
326
+ end
327
+ @freq[word] +=1
328
+ @word_map[word] ||= []
329
+ if line !~ /#{@rxp_lv1}|#{@rxp_lv2}|#{@rxp_lv3}/
330
+ loc_=%{#{location_seg("#{@seg}\##{ocn}",ocn).to_s}}
331
+ unless loc_.empty?
332
+ @word_map[word] << loc_
333
+ end
334
+ else
335
+ @word_map[word] << case line
336
+ when @rxp_lv1 then location_seg('T1',ocn) #fix @rxp_lv # Mx[:lv_o]
337
+ when @rxp_lv2 then location_seg('T2',ocn) #fix @rxp_lv # Mx[:lv_o]
338
+ when @rxp_lv3 then location_seg('T3',ocn) #fix @rxp_lv # Mx[:lv_o]
339
+ end
340
+ end
341
+ end
342
+ end
343
+ end
344
+ end
345
+ end
346
+ end
347
+ seg=''
348
+ head=SiSU_Concordance::Source::DocTitle.new(@particulars).create
349
+ head=head.gsub(/#{Xx[:html_relative2]}/m,@file.path_rel_links.html_seg_2).
350
+ gsub(/#{Xx[:html_relative1]}/m,@file.path_rel_links.html_seg_1)
351
+ @file_concordance << head
352
+ @file_concordance << '<p>'
353
+ alph=@alph[:u]
354
+ alph.each {|x| @file_concordance << %{<a href="##{x}">#{x}</a>,&nbsp;}}
355
+ @file_concordance << '</p>'
356
+ letter=alph.shift
357
+ @file_concordance << %{\n<p class="letter"><a name="A">A</a></p>}
358
+ for word in @freq.keys.sort! {|a,b| a.downcase<=>b.downcase}
359
+ f=/^(\S)/.match(word)[1]
360
+ if letter < f.upcase
361
+ while letter < f.upcase
362
+ if alph.length > 0
363
+ letter=alph.shift
364
+ @file_concordance << %{\n<p class="letter"><a name="#{letter}">#{letter}</a></p>}
365
+ else break
366
+ end
367
+ end
368
+ end
369
+ keyword=SiSU_Concordance::Source::Word.new(word,@freq[word]).html
370
+ if keyword !~ @rxp_excluded0
371
+ if @word_map[word][0] =~ /\d+/
372
+ @file_concordance << %{#{keyword}#{seg}#{@word_map[word].uniq.compact.join}}
373
+ end
374
+ @file_concordance << '</p>'
375
+ end
376
+ # special cases endnotes and header levels 1 - 3
377
+ end
378
+ @file_concordance << %{</div></body>\n</html>} # footer
379
+ if @md.opt.act[:verbose_plus][:set]==:on \
380
+ || @md.opt.act[:maintenance][:set]==:on
381
+ SiSU_Screen::Ansi.new(
382
+ @md.opt.act[:color_state][:set],
383
+ @md.fns,
384
+ "#{@md.file.output_path.html_concordance.dir}/#{@md.file.base_filename.html_concordance}"
385
+ ).flow
386
+ end
387
+ end
388
+ end
389
+ end
390
+ end
391
+ __END__
@@ -0,0 +1,1348 @@
1
+ # encoding: utf-8
2
+ =begin
3
+
4
+ * Name: SiSU
5
+
6
+ ** Description: documents, structuring, processing, publishing, search
7
+ *** html formating, css template
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/html_format.rb;hb=HEAD>
55
+
56
+ =end
57
+ module SiSU_HTML_Format
58
+ require_relative 'html_parts' # html_parts.rb
59
+ class ParagraphNumber
60
+ def initialize(md,ocn)
61
+ @md,@ocn=md,ocn.to_s
62
+ @ocn ||=''
63
+ @make=SiSU_Env::ProcessingSettings.new(@md)
64
+ end
65
+ def ocn_display
66
+ if @make.build.ocn?
67
+ if @ocn.to_i==0 \
68
+ or @ocn.empty?
69
+ ''
70
+ else
71
+ %{<label class="ocn"><a href="##{@ocn}" class="lnkocn">#{@ocn}</a></label>}
72
+ end
73
+ else
74
+ ''
75
+ end
76
+ end
77
+ def name
78
+ if @make.build.html_strict? \
79
+ or @ocn==(nil || @ocn.empty?)
80
+ ''
81
+ else
82
+ %{<a name="#{@ocn}"></a>}
83
+ end
84
+ end
85
+ def id #w3c? "tidy" complains about numbers as identifiers ! annoying
86
+ (@ocn==nil || @ocn.empty?) \
87
+ ? '' : %{id="#{Mx[:ocn_id_char]}#{@ocn}"}
88
+ end
89
+ def goto
90
+ (@ocn==nil || @ocn.empty?) \
91
+ ? '' : %{<a href="##{@ocn}">}
92
+ end
93
+ end
94
+ class HeadInformation
95
+ require_relative 'css' # css.rb
96
+ include SiSU_Parts_HTML
97
+ require_relative 'xml_shared' # xml_shared.rb
98
+ attr_reader :md,:rdf
99
+ def initialize(md)
100
+ @md=md
101
+ # DublinCore 1 - title
102
+ @bits=SiSU_Proj_HTML::Bits.new
103
+ @per=SiSU_HTML_Persist::Persist.new
104
+ @per.seg_name_x=SiSU_HTML::Seg.new.seg_name_x
105
+ @per.seg_name_x_tracker=SiSU_HTML::Seg.new.seg_name_x_tracker
106
+ @tocband_scroll,@tocband_segtoc=nil,nil
107
+ @stylesheet=SiSU_Style::CSS_HeadInfo.new(md).stylesheet
108
+ @o_str ||=SiSU_Env::ProcessingSettings.new(md).output_dir_structure
109
+ @index,@metalink='index','#metadata'
110
+ @toc=@md.file.base_filename.html_segtoc
111
+ end
112
+ def url_path_image_sys
113
+ (@o_str.dump_or_redirect?) \
114
+ ? './image'
115
+ : "#{Xx[:html_relative2]}_sisu/image_sys"
116
+ end
117
+ def icon
118
+ def up
119
+ 'arrow_up_red.png'
120
+ end
121
+ def next
122
+ 'arrow_next_red.png'
123
+ end
124
+ def previous
125
+ 'arrow_prev_red.png'
126
+ end
127
+ def dot_clear
128
+ 'dot_clear.png'
129
+ end
130
+ def dot_white
131
+ 'dot_white.png'
132
+ end
133
+ def dot
134
+ dot_white
135
+ end
136
+ self
137
+ end
138
+ def png_nav
139
+ def toc
140
+ %{<img border="0" width="22" height="22" src="#{url_path_image_sys}/#{icon.up}" alt="toc" />}
141
+ end
142
+ def pre
143
+ %{<img border="0" width="22" height="22" src="#{url_path_image_sys}/#{icon.previous}" alt="&lt;&lt;&nbsp;previous" />}
144
+ end
145
+ def nxt
146
+ %{<img border="0" width="22" height="22" src="#{url_path_image_sys}/#{icon.next}" alt="next&nbsp;&gt;&gt;" />}
147
+ end
148
+ def dot_toc
149
+ %{<img border="0" width="100%" height="20" src="#{url_path_image_sys}/#{icon.dot}" alt="&#094;" />}
150
+ end
151
+ def dot_pre
152
+ %{<img border="0" width="100%" height="20" src="#{url_path_image_sys}/#{icon.dot}" alt="&lt;" />}
153
+ end
154
+ def dot_nxt
155
+ %{<img border="0" width="100%" height="20" src="#{url_path_image_sys}/#{icon.dot}" alt="&gt;" />}
156
+ end
157
+ self
158
+ end
159
+ def doc_types(page=:seg) #used in toc & seg_nav_band
160
+ wgt=SiSU_HTML_Format::Widget.new(@md)
161
+ %{
162
+ <table summary="segment navigation available documents types: toc,doc,pdf,concordance" border="0" cellpadding="3" cellspacing="0">
163
+ <tr>
164
+ <td align="center" bgcolor=#{the_color.band2}>
165
+ #{wgt.manifest(page)}
166
+ #{wgt.search}
167
+ </tr></table>}
168
+ end
169
+ def rdf
170
+ SiSU_XML_Tags::RDF.new(md)
171
+ end
172
+ def button_home(page=:seg)
173
+ button=%{ <table summary="home button / home information" border="0" cellpadding="3" cellspacing="0">\n <tr><td align="left" bgcolor="#ffffff">\n}
174
+ if @md.make.home_button_image.is_a?(Hash)
175
+ image_path=if page==:manifest
176
+ @md.file.output_path.manifest.rel_image
177
+ elsif page==:scroll
178
+ @md.file.output_path.html_scroll.rel_image
179
+ else
180
+ @md.file.output_path.html_seg.rel_image
181
+ end
182
+ SiSU_Env::FileOp.new(@md)
183
+ button +=%{ <p class="tiny_left"><a href="#{@md.make.home_button_image[:link]}" target="_top"><img border="0" src="#{image_path}/#{@md.make.home_button_image[:home_button]}" width="#{@md.make.home_button_image[:w]}" height="#{@md.make.home_button_image[:h]}" alt="home icon --&gt;" /></a></p>\n}
184
+ elsif @md.home_button_links.is_a?(Array)
185
+ @md.home_button_links.each do |links|
186
+ button +=%{ <p class="tiny_left"><a href="#{links[:url]}" target="_top">\n #{links[:say]}\n </a></p>\n}
187
+ end
188
+ end
189
+ button +=%{ </td></tr>\n </table>}
190
+ button
191
+ end
192
+ def html_close #moved
193
+ %{</body>
194
+ </html>}
195
+ end
196
+ end
197
+ class Widget < HeadInformation
198
+ include SiSU_Parts_HTML
199
+ def initialize(md)
200
+ super(md)
201
+ @md=md
202
+ @cf_defaults=SiSU_Env::InfoProcessingFlag.new
203
+ @env=SiSU_Env::InfoEnv.new(md.fns)
204
+ @file=SiSU_Env::FileOp.new(md)
205
+ @o_str ||=SiSU_Env::ProcessingSettings.new(md).output_dir_structure
206
+ @make=SiSU_Env::ProcessingSettings.new(md)
207
+ end
208
+ def home
209
+ %{<td align="center" bgcolor=#{the_color.band2}>
210
+ <a href="../index.html" target="_top">
211
+ #{the_nav.txt_homepage}</a>
212
+ </td>
213
+ }
214
+ end
215
+ def scroll(text)
216
+ if @md.fns =~ /\.(?:-|ssm\.)?sst$/
217
+ %{<td align="center" bgcolor=#{the_color.band2}>
218
+ <a href="#{Xx[:html_relative1]}html/#{@file.base_filename.html_scroll}" target="_top">
219
+ #{text}
220
+ </a>
221
+ </td>
222
+ }
223
+ end
224
+ end
225
+ def seg(text)
226
+ %{<td align="center" bgcolor="#99CC66">
227
+ <a href="#{@md.file.base_filename.html_segtoc}" target="_top">
228
+ #{text}
229
+ </a>
230
+ </td>
231
+ }
232
+ end
233
+ def search
234
+ if @make.build.html_search_form?
235
+ env=SiSU_Env::InfoEnv.new(@md.fns,@md)
236
+ env.widget.search_form('sisusearch',nil,nil,true)
237
+ else ''
238
+ end
239
+ end
240
+ def manifest(page=:seg)
241
+ if @make.build.links_to_manifest? \
242
+ and not @o_str.dump_or_redirect?
243
+ manifest_lnk=if @file.output_dir_structure.by_language_code? \
244
+ or @file.output_dir_structure.by_filetype?
245
+ "#{Xx[:html_relative1]}manifest/#{@file.base_filename.manifest}"
246
+ else @file.base_filename.manifest
247
+ end
248
+ if page==:manifest
249
+ manifest_lnk="#{@md.file.output_path.manifest.url}/#{@file.base_filename.manifest}"
250
+ %{<td align="center" bgcolor=#{the_color.band2}>
251
+ <font face="#{the_font.set_fonts}" size="2">
252
+ #{the_url_decoration.xml_open}<a href="#{manifest_lnk}" target="_top">#{@md.file.output_path.manifest.url}/#{@file.base_filename.manifest}</a>#{the_url_decoration.xml_close}
253
+ </font>
254
+ </td>}
255
+ else
256
+ %{<td align="center" bgcolor=#{the_color.band2}>
257
+ <a href="#{manifest_lnk}" target="_top">
258
+ #{the_nav.txt_manifest}
259
+ </a>
260
+ </td>}
261
+ end
262
+ else ''
263
+ end
264
+ end
265
+ end
266
+ class XML
267
+ end
268
+ class HeadToc < HeadInformation
269
+ def initialize(md)
270
+ super(md)
271
+ @md=md
272
+ @o_str ||=SiSU_Env::ProcessingSettings.new(md).output_dir_structure
273
+ @make=SiSU_Env::ProcessingSettings.new(@md)
274
+ @file=SiSU_Env::FileOp.new(@md)
275
+ end
276
+ def scroll_head_navigation_band
277
+ if @make.build.html_top_band?
278
+ <<WOK
279
+ <td align="center" width="60%">
280
+ #{make_scroll_search_form_and_manifest_link}
281
+ </td>
282
+ WOK
283
+ %{<table summary="table of contents scroll navigation band" id="toc" width="100%" bgcolor=#{the_color.band1}>
284
+ <tr><td width="20%">
285
+ #{button_home(:scroll)}
286
+ </td>
287
+ <td width="75%" align="center">
288
+ #{doc_types}
289
+ </td>
290
+ <td width="20%">
291
+ &nbsp;
292
+ #{the_table_close}
293
+ <p>}
294
+ else ''
295
+ end
296
+ end
297
+ def concordance_navigation_band
298
+ up_button=if @make.build.html_navigation?
299
+ %{</td>
300
+ <td width="5%" align="right">
301
+ &nbsp;<a href="toc.html" target="_top" alt="-&gt;">
302
+ #{png_nav.toc}
303
+ </a>&nbsp;
304
+ }
305
+ else ''
306
+ end
307
+ if @make.build.html_top_band?
308
+ %{<table summary="concordance navigation band" id="toc" width="100%" bgcolor=#{the_color.band1}>
309
+ <tr><td width="20%">
310
+ #{button_home}
311
+ </td>
312
+ <td width="75%" align="center">
313
+ #{doc_types}
314
+ #{up_button}
315
+ #{the_table_close}
316
+ <p>}
317
+ else ''
318
+ end
319
+ end
320
+ def seg_head_navigation_band(page=:seg)
321
+ if @make.build.html_navigation?
322
+ if page==:manifest
323
+ nxt=(@file.output_dir_structure.by_language_code? \
324
+ || @file.output_dir_structure.by_filetype?) \
325
+ ? "../html/#{@md.fnb}/toc#{@md.lang_code_insert}#{Sfx[:html]}"
326
+ : "toc#{@md.lang_code_insert}#{Sfx[:html]}"
327
+ firstseg=%{<a href="#{nxt}" target="_top" alt="-&gt;">
328
+ #{png_nav.nxt}</a>}
329
+ elsif @md.firstseg =~/\S+/
330
+ firstseg=%{<a href="#{@md.firstseg}#{@md.lang_code_insert}#{Sfx[:html]}" target="_top" alt="-&gt;">
331
+ #{png_nav.nxt}</a>}
332
+ end
333
+ else ''
334
+ end
335
+ if @make.build.html_top_band?
336
+ %{<table summary="table of contents segment navigation band" id="toc" width="100%" bgcolor=#{the_color.band1}>
337
+ <tr><td width="20%">
338
+ #{button_home(page)}
339
+ </td>
340
+ <td width="75%" align="center">
341
+ #{doc_types(page)}
342
+ </td>
343
+ <td width="5%" align="right">
344
+ &nbsp;#{firstseg}&nbsp;
345
+ #{the_table_close}
346
+ <p>}
347
+ else ''
348
+ end
349
+ end
350
+ def manifest_link(text)
351
+ # @file=SiSU_Env::FileOp.new(@md) if @md
352
+ %{<font size=2>
353
+ <a href="#{@md.file.base_filename.manifest}" target="_top">#{text}</a>
354
+ </font>}
355
+ end
356
+ def concordance_link(text)
357
+ if @md.concord_make
358
+ %{<font size=2>
359
+ <a href="#{@md.file.base_filename.html_concordance}" target="_top">
360
+ #{text}
361
+ </a>
362
+ </font>}
363
+ else ''
364
+ end
365
+ end
366
+ def make_scroll_search_form_and_manifest_link
367
+ wgt=SiSU_HTML_Format::Widget.new(@md)
368
+ %{<td align="center" bgcolor=#{the_color.band2}>
369
+ #{the_nav.txt_doc_link}
370
+ </td>
371
+ }
372
+ %{<table summary="toc segment and scroll with pdf" border="0" cellpadding="3" cellspacing="0">
373
+ <tr>
374
+ #{wgt.manifest}
375
+ #{wgt.search}
376
+ </tr></table>}
377
+ end
378
+ def make_scroll_seg_pdf
379
+ seg=''
380
+ wgt=SiSU_HTML_Format::Widget.new(@md)
381
+ seg=%{<td align="center" bgcolor=#{the_color.band2}>
382
+ #{the_nav.txt_toc_link}
383
+ </td>
384
+ }
385
+ %{<table summary="toc scroll and segment with pdf" border="0" cellpadding="3" cellspacing="0">
386
+ <tr>
387
+ <td align="center" bgcolor=#{the_color.band2}>
388
+ #{wgt.manifest}
389
+ #{wgt.search}
390
+ </tr></table>}
391
+ end
392
+ def make_concordance
393
+ wgt=SiSU_HTML_Format::Widget.new(@md)
394
+ %{<table summary="toc scroll and segment with pdf" border="0" cellpadding="3" cellspacing="0">
395
+ <tr>
396
+ <td align="center" bgcolor=#{the_color.band2}>
397
+ #{wgt.manifest}
398
+ #{wgt.search}
399
+ </tr></table>}
400
+ end
401
+ def head
402
+ rdf=SiSU_XML_Tags::RDF.new(@md)
403
+ %{<!DOCTYPE html>
404
+ <html>
405
+ <head>
406
+ <meta charset="utf-8">
407
+ <title>
408
+ #{@md.title.full}
409
+ </title>
410
+ <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
411
+ #{rdf.metatag_html}
412
+ #{@stylesheet.css_head}
413
+ </head>
414
+ <body lang="#{@md.opt.lng}">
415
+ <a name="top" id="top"></a>}
416
+ end
417
+ def concordance
418
+ if @md.concord_make
419
+ %{#{the_margin.css}
420
+ <h4 class="toc">
421
+ <a href="./#{@md.file.base_filename.html_concordance}">
422
+ <i>Concordance</i>
423
+ </a>
424
+ </h4>
425
+ #{table_close}}
426
+ else
427
+ %{#{the_margin.css}
428
+ #{table_close}}
429
+ end
430
+ end
431
+ def links_guide_vertical_open
432
+ # @file=SiSU_Env::FileOp.new(@md) if @md
433
+ %{
434
+ <div id="vertical_links">
435
+ <ul id="vertical">
436
+ <li class="refbold">
437
+ <a href="#{the_url.home}">
438
+ #{the_text.txt_hp}
439
+ </a>
440
+ </li>
441
+ <li class="ref">
442
+ Quick Ref.:
443
+ </li>
444
+ <li class="ref">
445
+ <a href="#{@md.file.base_filename.manifest}" alt="Document Manifest" target="_top">
446
+ Manifest
447
+ </a>
448
+ </li>
449
+ <!- quick ref -!>}
450
+ end
451
+ def links_guide_horizontal_open
452
+ # @file=SiSU_Env::FileOp.new(@md) if @md
453
+ %{
454
+ <div id="horizontal_links">
455
+ <ul id="horizontal">
456
+ <li class="refbold">
457
+ <a href="#{the_url.home}">
458
+ #{the_text.txt_hp}
459
+ </a>
460
+ </li>
461
+ <li class="ref">
462
+ Quick Ref.:
463
+ </li>
464
+ <li class="ref">
465
+ <a href="#{@md.file.base_filename.manifest}" alt="Document Manifest" target="_top">
466
+ Manifest
467
+ </a>
468
+ </li>
469
+ <!- quick ref -!>}
470
+ end
471
+ def links_guide_open(type='horizontal')
472
+ (type=='vertical') \
473
+ ? links_guide_vertical_open
474
+ : links_guide_horizontal_open
475
+ end
476
+ def links_guide_close
477
+ insert=''
478
+ insert=if @md.sfx_src =~/s?/
479
+ link='http://sisudoc.org' #get from defaults
480
+ url='sisudoc.org'
481
+ name='SiSU electronic documents' #get from defaults
482
+ insert= %{
483
+ <li class="ref">
484
+ <a href="#{link}" alt="#{name}" target="_top">
485
+ #{url}
486
+ </a>
487
+ </li>
488
+ </ul>
489
+ </div>
490
+ }
491
+ end
492
+ %{ #{insert}
493
+ <!- quick ref -!>}
494
+ end
495
+ def prefix_a
496
+ end
497
+ def rights
498
+ def all
499
+ rights=SiSU_HTML_Tune::CleanHTML.new(@md.rights.all).clean_for_html
500
+ rights=rights.gsub(/^\s*Copyright\s+\(C\)/,'Copyright <sup>&copy;</sup>&nbsp;')
501
+ %{<p class="small_left">Rights: #{rights}</p>
502
+ <p>}
503
+ end
504
+ self
505
+ end
506
+ def prefix_b
507
+ %{<p class="small_left">Prefix: #{@md.prefix_b}<p />}
508
+ end
509
+ def scroll_head_title_banner_open
510
+ icon=@md.icon ? %{<center>\n#{@md.icon}\n</center>} : ''
511
+ %{#{icon}
512
+ #{the_banner.instrument_cover_band_scr}}
513
+ end
514
+ def seg_head_title_banner_open
515
+ icon=@md.icon ? %{<center>\n#{@md.icon}\n</center>} : ''
516
+ %{#{icon}
517
+ #{the_banner.instrument_cover_band_seg}}
518
+ end
519
+ def make_scroll
520
+ concord=concordance_link(the_nav.txt_concordance)
521
+ %{<table summary="toc scroll" border="0" cellpadding="3" cellspacing="0">
522
+ <tr><td align="center" bgcolor="white" border="0">
523
+ #{the_nav.txt_doc_link}
524
+ </td>
525
+ <td align="center" bgcolor="white">
526
+ #{concord}
527
+ #{the_table_close}}
528
+ end
529
+ def make_seg
530
+ concord=concordance_link(the_nav.txt_concordance)
531
+ %{<table summary="toc segment" border="0" cellpadding="3" cellspacing="0">
532
+ <tr><td align="center" bgcolor="white">
533
+ #{the_nav.txt_toc_link}
534
+ </td>
535
+ <td align="center" bgcolor="white">
536
+ <font size=2>
537
+ #{concord}
538
+ #{the_table_close}}
539
+ end
540
+ def manifest #check structure
541
+ if not @o_str.dump_or_redirect?
542
+ manifest=manifest_link(the_nav.txt_manifest)
543
+ %{#{the_margin.txt_3}
544
+ #{the_font.paragraph_font_small}
545
+ #{manifest}
546
+ </font>
547
+ #{the_table_close}}
548
+ else ''
549
+ end
550
+ end
551
+ def concordance #check structure
552
+ concord=concordance_link(the_nav.txt_concordance)
553
+ %{#{the_margin.txt_3}
554
+ #{the_font.paragraph_font_small}
555
+ #{concord}
556
+ </font>
557
+ #{the_table_close}}
558
+ end
559
+ def metadata
560
+ %{#{the_margin.css}
561
+ <h4 class="toc">
562
+ <a href="#{@metalink}">
563
+ <i>MetaData</i>
564
+ </a>
565
+ </h4>
566
+ #{the_table_close}}
567
+ end
568
+ def seg_tail
569
+ %{
570
+ <div class="main_column">
571
+ <p>&nbsp;<p>
572
+ <table summary="toc segment tail" bgcolor=#{the_color.band1}>
573
+ <tr><td width="20%">
574
+ #{the_banner.banner_band}
575
+ </td>
576
+ <td width="60%">
577
+ <center>
578
+ #{@tocband_segtoc}
579
+ </center>
580
+ </td></tr>
581
+ </table>
582
+ <p>&nbsp;</p>
583
+ #{@bits.credits_sisu}
584
+ <a name="bottom" id="bottom"></a>
585
+ <a name="end" id="end"></a>
586
+ </div>
587
+ </div>
588
+ </div>
589
+ }
590
+ end
591
+ def scroll_tail #debug
592
+ nav=scroll_head_navigation_band
593
+ %{
594
+ <div class="main_column">
595
+ #{nav}
596
+ #{@bits.credits_sisu}
597
+ <a name="bottom" id="bottom"></a>
598
+ <a name="end" id="end"></a>
599
+ </div>
600
+ }
601
+ end
602
+ def seg_navigation_tail #this is a bug area, look up and "tidy"
603
+ %{
604
+ <div class="main_column">
605
+ <p>&nbsp;</p>
606
+ #{@bits.credits_sisu}
607
+ <a name="bottom" id="bottom"></a>
608
+ <a name="end" id="end"></a>
609
+ </div>
610
+ </div>
611
+ </div>
612
+ }
613
+ end
614
+ end
615
+ class HeadSeg < HeadInformation
616
+ def initialize(md)
617
+ super(md)
618
+ end
619
+ def dot_control_pre_next
620
+ pre="#{@per.seg_name_x[@per.seg_name_x_tracker-1]}#{@md.lang_code_insert}#{Sfx[:html]}"
621
+ up=@toc
622
+ nxt="#{@per.seg_name_x[@per.seg_name_x_tracker+1]}#{@md.lang_code_insert}#{Sfx[:html]}"
623
+ if nxt=~/sisu_manifest\.html/
624
+ @file=SiSU_Env::FileOp.new(@md) if @md
625
+ if @file.output_dir_structure.by_language_code? \
626
+ or @file.output_dir_structure.by_filetype?
627
+ nxt=nxt.gsub(/sisu_manifest\.html/,"../../manifest/#{@file.base_filename.manifest}")
628
+ end
629
+ end
630
+ %{<table summary="segment hidden control pre and next" width="100%" border="0" cellpadding="0" bgcolor=#{the_color.grey_pale} align="center">
631
+ <tr><td align="left">
632
+ <a href="#{pre}" target="_top">
633
+ #{png_nav.dot_pre}
634
+ </a>
635
+ </td>
636
+ <td align="center">
637
+ <a href="#{up}" target="_top">
638
+ #{png_nav.dot_toc}
639
+ </a>
640
+ </td>
641
+ <td align="right">
642
+ <a href="#{nxt}" target="_top">
643
+ #{png_nav.dot_nxt}
644
+ </a>
645
+ #{the_table_close}}
646
+ end
647
+ def dot_control_pre
648
+ pre="#{@per.seg_name_x[@per.seg_name_x_tracker-2]}#{@md.lang_code_insert}#{Sfx[:html]}"
649
+ up=@toc
650
+ nxt="#{@md.file.base_filename.html_segtoc}"
651
+ %{<table summary="segment hidden control pre" width="100%" border="0" cellpadding="0" bgcolor=#{the_color.grey_pale} align="center">
652
+ <tr><td align="left">
653
+ <a href="#{pre}" target="_top">
654
+ #{png_nav.dot_pre}
655
+ </a>
656
+ </td>
657
+ <td align="center">
658
+ <a href="#{up}" target="_top">
659
+ #{png_nav.dot_toc}
660
+ </a>
661
+ </td>
662
+ <td align="right">
663
+ <a href="#{nxt}" target="_top">
664
+ #{png_nav.dot_nxt}
665
+ </a>
666
+ #{the_table_close}}
667
+ end
668
+ def toc_nav(f_pre=false,f_nxt=false,use=1)
669
+ pre=nxt=''
670
+ toc=%{<td align="center" bgcolor=#{the_color.band1}>
671
+ <a href="#{@toc}" target="_top">
672
+ #{png_nav.toc}
673
+ </a>
674
+ </td>}
675
+ pre=%{<td align="center" bgcolor=#{the_color.band1}>
676
+ <a href="#{@per.seg_name_x[@per.seg_name_x_tracker-use]}#{@md.lang_code_insert}#{Sfx[:html]}" target="_top">
677
+ #{png_nav.pre}
678
+ </a>
679
+ </td>} if f_pre==true
680
+ nxt=%{<td align="center" bgcolor=#{the_color.band1}>
681
+ <a href="#{@per.seg_name_x[@per.seg_name_x_tracker+1]}#{@md.lang_code_insert}#{Sfx[:html]}" target="_top">
682
+ #{png_nav.nxt}
683
+ </a>
684
+ </td>} if f_nxt==true
685
+ if nxt =~/sisu_manifest.html/
686
+ @file=SiSU_Env::FileOp.new(@md) if @md
687
+ if @file.output_dir_structure.by_language_code? \
688
+ or @file.output_dir_structure.by_filetype?
689
+ nxt=nxt.gsub(/sisu_manifest\.html/,"../../manifest/#{@file.base_filename.manifest}")
690
+ end
691
+ end
692
+ %{<table summary="segment navigation pre/next" border="0" cellpadding="3" cellspacing="0">
693
+ <tr>
694
+ #{pre}
695
+ #{toc}
696
+ #{nxt}
697
+ <td>
698
+ #{the_table_close}}
699
+ end
700
+ def toc_next2
701
+ toc_nav(false,true).dup
702
+ end
703
+ def toc_pre_next2
704
+ toc_nav(true,true).dup
705
+ end
706
+ def toc_pre2
707
+ toc_nav(true,false,2).dup
708
+ end
709
+ def manifest_link(text)
710
+ %{<font size=2>
711
+ <a href="#{@md.file.base_filename.manifest}" target="_top">
712
+ #{text}
713
+ </a>
714
+ </font>}
715
+ end
716
+ def concordance_link(text)
717
+ if @md.concord_make
718
+ %{<font size=2>
719
+ <a href="#{@md.file.base_filename.html_concordance}" target="_top">
720
+ #{text}
721
+ </a>
722
+ </font>}
723
+ else ''
724
+ end
725
+ end
726
+ def credit
727
+ %{
728
+ <div class="main_column">
729
+ #{@bits.credits_sisu}
730
+ <a name="bottom" id="bottom"></a>
731
+ <a name="end" id="end"></a>
732
+ </div></div>
733
+ }
734
+ end
735
+ def navigation_band(segtocband,seg_table_top_control) #change name to navigation_band_banner
736
+ %{<table summary="segment navigation band with banner" bgcolor=#{the_color.band1} width="100%"><tr>
737
+ <td width="20%" align="left">
738
+ #{button_home}
739
+ </td>
740
+ <td width="75%" align="center">
741
+ #{doc_types}
742
+ </td>
743
+ <td width="5%" align="right">
744
+ #{segtocband}
745
+ </td></tr>
746
+ </table>
747
+ #{seg_table_top_control}}
748
+ end
749
+ def navigation_band_bottom(segtocband,seg_table_top_control) #change name to navigation_band_bannerless
750
+ %{
751
+ <div class="main_column">
752
+ <table summary="segment navigation band" bgcolor=#{the_color.band1} width="100%"><tr>
753
+ <td width="70%" align="center">
754
+ #{doc_types}
755
+ </td>
756
+ <td width="5%" align="right">
757
+ #{segtocband}
758
+ </td></tr>
759
+ </table>
760
+ #{seg_table_top_control}
761
+ </div>
762
+ }
763
+ end
764
+ def endnote_mark
765
+ %{
766
+ <p class="center" id="endnotes">
767
+ <hr class="endnote" />
768
+ </p>}
769
+ end
770
+ def endnote_section_open
771
+ %{
772
+ <div class="endnote">
773
+ }
774
+ end
775
+ def endnote_section_close
776
+ %{
777
+ </div>
778
+ } #revisit
779
+ end
780
+ def head_seg
781
+ rdf=SiSU_XML_Tags::RDF.new(@md)
782
+ %{<!DOCTYPE html>
783
+ <html>
784
+ <head>
785
+ <meta charset="utf-8">
786
+ <title>
787
+ #{@per.seg_name_x[@per.seg_name_x_tracker]} -
788
+ #{@md.title.main}
789
+ </title>
790
+ <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
791
+ #{rdf.metatag_html}
792
+ #{@stylesheet.css_head_seg}
793
+ </head>
794
+ <body lang="#{@md.opt.lng}">
795
+ <a name="top" id="top"></a>}
796
+ end
797
+ def title_banner(title,subtitle,creator)
798
+ %{
799
+ <div class="summary">
800
+ <p class="tiny">
801
+ #{title}
802
+ </p>
803
+ <p class="tiny">
804
+ #{subtitle}
805
+ </p>
806
+ <p class="tiny">
807
+ #{creator}
808
+ </p>
809
+ <p class="tiny">
810
+ copy @
811
+ <a href="#{the_url.home}">
812
+ #{the_text.txt_home}
813
+ </a>
814
+ </p>
815
+ </div>
816
+ }
817
+ end
818
+ end
819
+ class HeadScroll < HeadToc
820
+ def initialize(md)
821
+ super(md)
822
+ end
823
+ def toc_owner_details
824
+ %{#{the_margin.txt_3}
825
+ #{the_font.paragraph_font_small}
826
+ <a href="#owner.details">
827
+ Owner Details
828
+ <font size="1" color="#777777">
829
+ &nbsp;&nbsp;&nbsp;
830
+ </font>
831
+ </a>
832
+ </font>
833
+ #{the_table_close}}
834
+ end
835
+ end
836
+ class FormatTextObject
837
+ include SiSU_Parts_HTML
838
+ attr_accessor :md,:t_o,:txt,:ocn,:format,:table,:link,:linkname,:paranum,:p_num,:headname,:banner,:url
839
+ def initialize(md,t_o)
840
+ @md,@t_o=md,t_o
841
+ @make=SiSU_Env::ProcessingSettings.new(@md)
842
+ if t_o.is_a?(Hash)
843
+ @txt =t_o[:txt] || nil
844
+ @ocn =t_o[:ocn] || nil
845
+ @ocn_display =t_o[:ocn_display] || nil
846
+ @headname =t_o[:headname] || nil
847
+ @trailer =t_o[:trailer] || nil
848
+ @endnote_part_a =t_o[:endnote_part_a] || nil
849
+ @endnote_part_b =t_o[:endnote_part_b] || nil
850
+ @lnk_url =t_o[:lnk_url] || nil
851
+ @lnk_txt =t_o[:lnk_txt] || nil
852
+ @format =t_o[:format] || nil
853
+ elsif t_o.class.inspect =~/^(?:#<)?SiSU_AO_DocumentStructure/
854
+ @dob=t_o if defined? t_o.is
855
+ @named=nametags_seg(@dob)
856
+ @txt=((defined? t_o.obj) ? t_o.obj : nil)
857
+ @ocn=((defined? t_o.ocn) ? t_o.ocn.to_s : nil)
858
+ @headname=((t_o.is==:heading and defined? t_o.name) ? t_o.name : nil)
859
+ else
860
+ if @md.opt.act[:maintenance][:set]==:on
861
+ p t_o.class
862
+ p caller
863
+ end
864
+ end
865
+ @headnamed=(@headname ? %{<a id="h#{@headname}"></a>} : nil)
866
+ if @txt and not @txt.empty?
867
+ @txt=@txt.gsub(/#{Mx[:mk_o]}[-~]##{Mx[:mk_c]}/,'')
868
+ end
869
+ @p_num=ParagraphNumber.new(@md,@ocn)
870
+ end
871
+ def nametags_scroll(dob)
872
+ tags=''
873
+ if defined? dob.tags \
874
+ and dob.tags.length > 0 # insert tags "hypertargets"
875
+ dob.tags.each do |t|
876
+ t=t.gsub(/[^a-z0-9._-]/,'') #use for all html tags? consider limiting to strict? or implementing earlier
877
+ tags=tags << %{<named id="#{t}" />}
878
+ end
879
+ end
880
+ tags
881
+ end
882
+ def nametags_seg(dob) #FIX
883
+ tags=''
884
+ if defined? dob.tags \
885
+ and dob.tags.length > 0 # insert tags "hypertargets"
886
+ dob.tags.each do |t|
887
+ t=t.gsub(/[^a-z0-9._-]/,'') #use for all html tags? consider limiting to strict? or implementing earlier
888
+ tags=(t =~/^[0-9.]+$/) \
889
+ ? tags #check what can be sorted in ao
890
+ : (tags << %{<a name="#{t}" ></a>})
891
+ end
892
+ end
893
+ tags
894
+ end
895
+ def headname #check whether used
896
+ hn=if @t_o.is ==:heading \
897
+ and not @t_o.name.empty? #determine use
898
+ hn=(@t_o.is ==:heading) \
899
+ ? (%{<a id="h#{@t_o.name}"></a>})
900
+ : (%{<a id="#{@t_o.name}"></a>})
901
+ else nil
902
+ end
903
+ hn
904
+ end
905
+ def endnote_body
906
+ %{
907
+ <p class="endnote">
908
+ #{@txt}
909
+ </p>
910
+ }
911
+ end
912
+ def endnote_body_indent
913
+ %{
914
+ <p class="endnote_indent">
915
+ #{@txt}
916
+ </p>
917
+ }
918
+ end
919
+ def no_paranum
920
+ %{
921
+ <div class="substance">
922
+ <label class="ocn">&nbsp;</label>
923
+ <p class="norm">
924
+ #{@txt}
925
+ </p>
926
+ </div>
927
+ }
928
+ end
929
+ def para_form_css(tag,attrib) # regular paragraphs shaped here
930
+ ul=ulc=''
931
+ if tag =~/li/
932
+ ul,ulc="<ul>\n ","\n </ul>"
933
+ end
934
+ %{
935
+ <div class="substance">
936
+ #{@p_num.ocn_display}
937
+ #{ul}<#{tag} class="#{attrib}" #{@p_num.id}>
938
+ #{@named}#{@txt}
939
+ </#{tag}>#{ulc}
940
+ </div>
941
+ }
942
+ end
943
+ def para
944
+ para_form_css('p','norm')
945
+ end
946
+ def block
947
+ para_form_css('p','block')
948
+ end
949
+ def group
950
+ para_form_css('p','group')
951
+ end
952
+ def alt
953
+ para_form_css('p','alt')
954
+ end
955
+ def verse
956
+ para_form_css('p','verse')
957
+ end
958
+ def code
959
+ para_form_css('p','code')
960
+ end
961
+ def center
962
+ para_form_css('p','center')
963
+ end
964
+ def bold
965
+ para_form_css('p','bold')
966
+ end
967
+ def bullet
968
+ para_form_css('li','bullet')
969
+ end
970
+ def table
971
+ @txt=if @t_o.obj !~/^<table\s/
972
+ table=SiSU_HTML_Shared::TableHTML.new(@t_o) #move, make happen earlier
973
+ @txt=table.table.obj
974
+ else @txt
975
+ end
976
+ para_form_css('p','norm')
977
+ end
978
+ def format(tag,attrib)
979
+ para_form_css(tag,attrib)
980
+ end
981
+ def heading_normal(tag,attrib)
982
+ section_break=(tag=~/h[1-5]/) \
983
+ ? '<br><hr width=90% /><br>'
984
+ : ''
985
+ %{#{section_break}
986
+ <div class="substance">
987
+ #{@p_num.ocn_display}
988
+ <#{tag} class="#{attrib}" #{@p_num.id}>#{@p_num.name}
989
+ #{@named}#{@txt}
990
+ </#{tag}>
991
+ </div>
992
+ }
993
+ end
994
+ def heading_body
995
+ heading_normal('p','norm')
996
+ end
997
+ def heading_body0
998
+ heading_normal('h1','norm')
999
+ end
1000
+ def heading_body1
1001
+ heading_normal('h1','norm')
1002
+ end
1003
+ def heading_body2
1004
+ heading_normal('h2','norm')
1005
+ end
1006
+ def heading_body3
1007
+ heading_normal('h3','norm')
1008
+ end
1009
+ def heading_body4
1010
+ heading_normal('h4','norm')
1011
+ end
1012
+ def heading_body5
1013
+ heading_normal('h5','norm')
1014
+ end
1015
+ def heading_body6
1016
+ heading_normal('h6','norm')
1017
+ end
1018
+ def heading_body7
1019
+ heading_normal('h7','norm')
1020
+ end
1021
+ def title_heading(tag,attrib)
1022
+ cl=(@make.build.html_minitoc?) \
1023
+ ? 'content'
1024
+ : 'content0'
1025
+ %{
1026
+ <div class="#{cl}">
1027
+ <#{tag} class="#{attrib}">
1028
+ #{@named}#{@txt}
1029
+ </#{tag}>
1030
+ </div>
1031
+ }
1032
+ end
1033
+ def title_heading0
1034
+ title_heading('h1','tiny')
1035
+ end
1036
+ def title_heading1
1037
+ title_heading('h1','tiny')
1038
+ end
1039
+ def title_heading2
1040
+ title_heading('h2','tiny')
1041
+ end
1042
+ def title_heading3
1043
+ title_heading('h3','tiny')
1044
+ end
1045
+ def title_heading4
1046
+ ''
1047
+ end
1048
+ def seg_heading_sub(tag,attrib)
1049
+ @txt=@txt.gsub(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ')
1050
+ %{
1051
+ <div class="substance">
1052
+ #{@p_num.ocn_display}
1053
+ <#{tag} class="#{attrib}" #{@p_num.id}>#{@p_num.name} #{@headnamed}
1054
+ #{@named}#{@txt}
1055
+ </#{tag}>
1056
+ </div>
1057
+ }
1058
+ end
1059
+ def seg_heading4
1060
+ %{
1061
+ <div class="substance">
1062
+ #{@p_num.ocn_display}
1063
+ <h1 class="norm" #{@p_num.id}>#{@p_num.name}
1064
+ #{@txt}
1065
+ </h1>
1066
+ </div>
1067
+ }
1068
+ end
1069
+ def seg_heading5
1070
+ seg_heading_sub('p','bold')
1071
+ end
1072
+ def seg_heading6
1073
+ seg_heading_sub('p','bold')
1074
+ end
1075
+ def dl #check :trailer
1076
+ "<dl><b>#{@txt}</b> #{@trailer}</dl>"
1077
+ end
1078
+ def table_css_end
1079
+ '</table>
1080
+ </p>
1081
+ </div>'
1082
+ end
1083
+ def gsub_body #fix
1084
+ @txt=case @txt
1085
+ when /^\((i+|iv|v|vi+|ix|x|xi+)\)/
1086
+ @txt.gsub(/^\((i+|iv|v|vi+|ix|x|xi+)\)/,'<b>(\1)</b>')
1087
+ when /^\(?(\d|[a-z])+\)/
1088
+ @txt.gsub(/^\((\d+|[a-z])+\)/,'<b>(\1)</b>')
1089
+ when /^\s*\d{1,3}\.\s/
1090
+ @txt.gsub(/^\s*(\d+\.)/,'<b>\1</b>')
1091
+ when /^\s*[A-Z]\.\s/
1092
+ @txt.gsub(/^\s*([A-Z]\.)/,'<b>\1</b>')
1093
+ else @txt
1094
+ end
1095
+ end
1096
+ def bold_para
1097
+ %{#{the_margin.txt_0}
1098
+ <p class="bold">
1099
+ #{@txt}
1100
+ </p>
1101
+ #{the_margin.num_css}
1102
+ &nbsp;&nbsp;&nbsp;
1103
+ #{the_table_close}}
1104
+ end
1105
+ def bold_heading
1106
+ %{<p class="bold">
1107
+ #{@txt}
1108
+ </p>
1109
+ #{the_margin.num_css}
1110
+ &nbsp;&nbsp;&nbsp;
1111
+ #{the_table_close}}
1112
+ end
1113
+ def toc_head_copy_at
1114
+ %{<p class="center">#{@txt}</p>\n}
1115
+ end
1116
+ def center
1117
+ %{<p class="center">#{@txt}</p>\n}
1118
+ end
1119
+ def bold
1120
+ %{<p class="bold">#{@txt}</p>\n}
1121
+ end
1122
+ def center_bold
1123
+ %{<p class="centerbold">#{@txt}</p>\n}
1124
+ end
1125
+ end
1126
+ class FormatScroll < FormatTextObject
1127
+ def initialize(md,txt)
1128
+ super(md,txt)
1129
+ end
1130
+ end
1131
+ class FormatSeg < FormatTextObject
1132
+ def initialize(md,txt)
1133
+ super(md,txt)
1134
+ end
1135
+ def endnote_seg_body(fn='')
1136
+ fn="../#{@md.fnb}" if fn.to_s.empty?
1137
+ %{
1138
+ <p class="endnote">
1139
+ #{@endnote_part_a}#{fn}#{@md.lang_code_insert}#{Sfx[:html]}#{@endnote_part_b}
1140
+ </p>
1141
+ }
1142
+ end
1143
+ def clean(txt)
1144
+ txt=txt.gsub(/#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}/,'').
1145
+ gsub(/#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]}/,'')
1146
+ end
1147
+ def subtoc_lev(tag,attrib)
1148
+ @txt=clean(@txt)
1149
+ txt=if @txt \
1150
+ and @txt =~/<\/?i>|<a\s+name="\S+?">/mi
1151
+ @txt.gsub(/<\/?i>|<a\s+name="\S+?">/mi,'') #removes name markers from subtoc, go directly to substantive text
1152
+ else @txt
1153
+ end
1154
+ note=''
1155
+ if txt =~/(#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})/m # had \s* at end
1156
+ note=$1
1157
+ note=note.gsub(/[\s]+/m,' ')
1158
+ txt=txt.gsub(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ').
1159
+ gsub(/<a[\s]+name="-\d+"[\s]+href="#_\d+">&nbsp;<sup>\d+<\/sup>&nbsp;/m,'')
1160
+ end
1161
+ %{<#{tag} class="#{attrib}">
1162
+ <a href="##{@ocn}"><i>#{txt}</i></a> #{note}
1163
+ </#{tag}>}
1164
+ end
1165
+ def subtoc_lev5
1166
+ subtoc_lev('h5','subtoc') if @txt
1167
+ end
1168
+ def subtoc_lev6
1169
+ subtoc_lev('h6','subtoc') if @txt
1170
+ end
1171
+ def subtoc_lev7
1172
+ subtoc_lev('h7','subtoc') if @txt
1173
+ end
1174
+ def heading_sub(tag,attrib)
1175
+ @txt=@txt.gsub(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ')
1176
+ %{
1177
+ <div class="substance">
1178
+ #{@p_num.ocn_display}
1179
+ <#{tag} class="#{attrib}" #{@p_num.id}>#{@p_num.name} #{@headnamed}
1180
+ #{@txt}
1181
+ </#{tag}>
1182
+ </div>
1183
+ }
1184
+ end
1185
+ def heading5
1186
+ heading_sub('p','bold')
1187
+ end
1188
+ def heading6
1189
+ heading_sub('p','bold')
1190
+ end
1191
+ def heading4
1192
+ %{
1193
+ <div class="substance">
1194
+ #{@p_num.ocn_display}
1195
+ <h1 class="norm" #{@p_num.id}>#{@p_num.name}
1196
+ #{@t_o[:format]}
1197
+ #{@txt}
1198
+ </h1>
1199
+ </div>
1200
+ }
1201
+ end
1202
+ def navigation_heading4
1203
+ %{<table summary="navigation segment heading 4" width=100% bgcolor="#08163f" border="0">
1204
+ <tr><td align="center">
1205
+ <p class="bold">
1206
+ #{@txt}
1207
+ </p>
1208
+ #{the_table_close}}
1209
+ end
1210
+ def navigation_heading5
1211
+ %{<p class="bold">
1212
+ #{@txt}
1213
+ </p>}
1214
+ end
1215
+ def navigation_heading6
1216
+ %{<p class="bold">
1217
+ #{@txt}
1218
+ </p>}
1219
+ end
1220
+ def navigation_center
1221
+ "<center>#{@txt}</center>"
1222
+ end
1223
+ end
1224
+ class FormatToc < FormatTextObject
1225
+ def initialize(md,txt)
1226
+ super(md,txt)
1227
+ end
1228
+ def links_guide
1229
+ %{ <li class="doc">
1230
+ <a href="#{@lnk_url}" target="_top">
1231
+ #{@lnk_txt}
1232
+ </a>
1233
+ </li>
1234
+ }
1235
+ end
1236
+ def lev(tag,attrib)
1237
+ if @txt
1238
+ %{<#{tag} class="#{attrib}">
1239
+ #{@txt}
1240
+ </#{tag}>
1241
+ }
1242
+ else ''
1243
+ end
1244
+ end
1245
+ def lev0 #docinfo
1246
+ lev('h1','toc')
1247
+ end
1248
+ def lev1
1249
+ lev('h1','toc')
1250
+ end
1251
+ def lev2
1252
+ lev('h2','toc')
1253
+ end
1254
+ def lev3
1255
+ lev('h3','toc')
1256
+ end
1257
+ def lev4
1258
+ lev('h4','toc')
1259
+ end
1260
+ def lev5
1261
+ lev('h5','toc')
1262
+ end
1263
+ def lev6
1264
+ lev('h6','toc')
1265
+ end
1266
+ def lev7
1267
+ lev('h7','toc')
1268
+ end
1269
+ def strip_endnotes(txt)
1270
+ txt=txt.gsub(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ')
1271
+ txt
1272
+ end
1273
+ def mini_lev0
1274
+ @txt=strip_endnotes(@txt)
1275
+ lev('h1','minitoc')
1276
+ end
1277
+ def mini_lev1
1278
+ @txt=strip_endnotes(@txt)
1279
+ lev('h1','minitoc')
1280
+ end
1281
+ def mini_lev2
1282
+ @txt=strip_endnotes(@txt)
1283
+ lev('h2','minitoc')
1284
+ end
1285
+ def mini_lev3
1286
+ @txt=strip_endnotes(@txt)
1287
+ lev('h3','minitoc')
1288
+ end
1289
+ def mini_lev4
1290
+ @txt=strip_endnotes(@txt)
1291
+ lev('h4','minitoc')
1292
+ end
1293
+ def mini_lev5
1294
+ @txt=strip_endnotes(@txt)
1295
+ lev('h5','minitoc')
1296
+ end
1297
+ def mini_lev6
1298
+ @txt=strip_endnotes(@txt)
1299
+ lev('h6','minitoc')
1300
+ end
1301
+ def mini_lev7
1302
+ @txt=strip_endnotes(@txt)
1303
+ lev('h7','minitoc')
1304
+ end
1305
+ def mini_lev0 #docinfo
1306
+ lev('h1','minitoc')
1307
+ end
1308
+ def mini_tail
1309
+ %{
1310
+ <h4 class="minitoc">
1311
+ <a href="sisu_manifest.html">Manifest (alternative outputs)</a>
1312
+ </h4>
1313
+ }
1314
+ end
1315
+ def mini_concord_tail
1316
+ %{
1317
+ <h4 class="minitoc">
1318
+ <a href="concordance.html">Concordance (wordlist)</a>
1319
+ </h4>
1320
+ <h4 class="minitoc">
1321
+ <a href="sisu_manifest.html">Manifest (alternative outputs)</a>
1322
+ </h4>
1323
+ }
1324
+ end
1325
+ end
1326
+ class FormatStr
1327
+ def initialize(md,str)
1328
+ @str=str
1329
+ end
1330
+ def center
1331
+ %{<p class="center">#{@str}</p>\n}
1332
+ end
1333
+ def bold
1334
+ %{<p class="bold">#{@str}</p>\n}
1335
+ end
1336
+ def center_bold
1337
+ %{<p class="centerbold">#{@str}</p>\n}
1338
+ end
1339
+ def endnote_body
1340
+ %{
1341
+ <p class="endnote">
1342
+ #{@str}
1343
+ </p>
1344
+ }
1345
+ end
1346
+ end
1347
+ end
1348
+ __END__