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,322 @@
1
+ # encoding: utf-8
2
+ =begin
3
+
4
+ * Name: SiSU
5
+
6
+ ** Description: documents, structuring, processing, publishing, search
7
+ *** epub concordance file (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/xhtml_epub2_concordance.rb;hb=HEAD>
55
+
56
+ =end
57
+ module SiSU_XHTML_EPUB2_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 'xhtml_parts' # xhtml_parts.rb
63
+ require_relative 'xhtml_epub2_format' # xhtml_epub2_format.rb
64
+ include SiSU_XHTML_EPUB2_Format
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
+ wordmax=@env.concord_max
74
+ unless @md.wc_words.nil?
75
+ if @md.wc_words < wordmax
76
+ SiSU_XHTML_EPUB2_Concordance::Source::Words.new(@particulars).songsheet
77
+ else
78
+ SiSU_Screen::Ansi.new(
79
+ @md.opt.act[:color_state][:set],
80
+ "*WARN* concordance skipped, large document has over #{wordmax} words (#{@md.wc_words})"
81
+ ).warn unless @md.opt.act[:quiet][:set]==:on
82
+ end
83
+ else
84
+ SiSU_Screen::Ansi.new(
85
+ @md.opt.act[:color_state][:set],
86
+ "*WARN* wc (word count) is off, concordance will be processed for all files including those over the max set size of: #{wordmax} words"
87
+ ).warn unless @md.opt.act[:quiet][:set]==:on
88
+ SiSU_XHTML_EPUB2_Concordance::Source::Words.new(@particulars).songsheet
89
+ end
90
+ rescue
91
+ SiSU_Errors::Rescued.new($!,$@,@md.opt.selections.str,@md.fns).location do
92
+ __LINE__.to_s + ':' + __FILE__
93
+ end
94
+ ensure
95
+ end
96
+ end
97
+ private
98
+ class DocTitle
99
+ #revisit, both requires (html & xml_shared) needed for stand alone operation (sisu -w [filename])
100
+ require_relative 'xhtml_epub2' # xhtml_epub2.rb
101
+ def initialize(particulars)
102
+ @particulars,@md=particulars,particulars.md
103
+ @data=SiSU_XHTML_EPUB2::Source::XHTML_Environment.new(particulars).tuned_file_instructions
104
+ @fnb=@md.fnb
105
+ @lex_button=%{<a href="http://www.jus.uio.no/sisu/" target="_top"><img border="0" height="44" width="144" valign="center" src="../_sisu/image/sisu.png" alt="SiSU home"></a>}
106
+ @doc_details =<<WOK
107
+ <table summary="links to text related to this rudimentary index" width="96%" border="0" bgcolor="white" cellpadding="0" align="center"><tr><td width="2%" align="right">#{$ep[:hsp]}</td><td width="94%" valign="top" align="justify"><h1 class="small"><a href="#{@md.file.base_filename.epub}"><b>#{@md.title.full}</b></a></h1><p class="bold">#{@md.creator.author}</p></td></tr></table>
108
+ WOK
109
+ end
110
+ def create
111
+ @css=SiSU_Env::CSS_Stylesheet.new(@particulars.md)
112
+ format_head_toc=SiSU_XHTML_EPUB2_Format::HeadToc.new(@md)
113
+ dochead=format_head_toc.head
114
+ <<WOK
115
+ #{dochead}
116
+ <div class="content">
117
+ #{@doc_details}
118
+ <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>
119
+ <p>(The word listing/index is Case sensitive: Capitalized words appear before lower case)</p>
120
+ <p>
121
+ <b>word</b> (number of occurences)<br />linked references to word within document <br />
122
+ [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.]
123
+ </p>
124
+ <p>
125
+ (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 # [#{$ep[:hsp]}http://[web host]/#{@fnb}/concordance.html#your_word#{$ep[:hsp]}]
126
+ </p>
127
+ WOK
128
+ end
129
+ end
130
+ class Word
131
+ @@word_previous=''
132
+ def initialize(word,freq)
133
+ @word,@freq=word,freq
134
+ end
135
+ def html
136
+ w=if @word.capitalize==@@word_previous
137
+ %{\n<p class="concordance_word">#{@word}</p><p class="concordance_count">(#{@freq})</p>\n\t<p class="concordance_object"> }
138
+ else n=@word.strip.gsub(/\s+/,'_') #also need to convert extended character set to html
139
+ %{\n<p class="concordance_word"><a name="#{n}">#{@word}</a></p><p class="concordance_count">(#{@freq})</p>\n\t<p class="concordance_object"> }
140
+ end
141
+ @@word_previous=@word.capitalize
142
+ w
143
+ end
144
+ end
145
+ class Words
146
+ require_relative 'xhtml_epub2_format' # xhtml_epub2_format.rb
147
+ include SiSU_XHTML_EPUB2_Format
148
+ require_relative 'se' # se.rb
149
+ include SiSU_Screen
150
+ def initialize(particulars)
151
+ @particulars=particulars
152
+ begin
153
+ @env,@md,@ao_array=particulars.env,particulars.md,particulars.ao_array
154
+ @path="#{@env.processing_path.epub}"
155
+ @freq=Hash.new(0)
156
+ @rxp_lv0=/^#{Mx[:lv_o]}0:/
157
+ @rxp_lv1=/^#{Mx[:lv_o]}1:/
158
+ @rxp_lv2=/^#{Mx[:lv_o]}2:/
159
+ @rxp_lv3=/^#{Mx[:lv_o]}3:/
160
+ @rxp_seg=/^#{Mx[:lv_o]}4:(\S+?)#{Mx[:lv_c]}/
161
+ @rxp_title=Regexp.new("^#{Mx[:meta_o]}title#{Mx[:meta_c]}\s*(.+?)\s*$")
162
+ @rxp_t0=Regexp.new('^T0')
163
+ @rxp_t1=Regexp.new('^T1')
164
+ @rxp_t2=Regexp.new('^T2')
165
+ @rxp_t3=Regexp.new('^T3')
166
+ @rxp_excluded1=/(?:https?|file|ftp):\/\/\S+/
167
+ @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?|[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 !!!
168
+ @rgx_splitlist=%r{[—.,;:-]+|#{Mx[:nbsp]}+}mi
169
+ @rgx_scanlist=%r{#{Mx[:fa_italics_o]}[a-zA-Z0-9"\s]{2,12}#{Mx[:fa_italics_c]}|#{Mx[:fa_bold_o]}[a-zA-Z0-9"\s]{2,12}#{Mx[:fa_bold_c]}|#{Mx[:url_o]}https?://\S+?#{Mx[:url_c]}|file://\S+|<\S+?>|\w+|[a-zA-Z]+}mi
170
+ rescue
171
+ SiSU_Errors::Rescued.new($!,$@,@md.opt.selections.str,@md.fns).location do
172
+ __LINE__.to_s + ':' + __FILE__
173
+ end
174
+ end
175
+ end
176
+ def songsheet
177
+ begin
178
+ #fix to use
179
+ p __LINE__.to_s + ':' + __FILE__
180
+ p "#{@path}/content/#{@md.fn[:epub_concord]}"
181
+ p "#{@md.file.output_path.epub.dir}/#{@md.file.base_filename.epub}"
182
+ @file_concordance=File.open("#{@path}/content/#{@md.fn[:epub_concord]}",'w')
183
+ map_para
184
+ rescue
185
+ SiSU_Errors::Rescued.new($!,$@,@md.opt.selections.str,@md.fns).location do
186
+ __LINE__.to_s + ':' + __FILE__
187
+ end
188
+ ensure
189
+ @file_concordance.close
190
+ end
191
+ end
192
+ protected
193
+ def location_scroll(wordlocation,show)
194
+ @wordlocation=wordlocation
195
+ %{<a href="doc#{Sfx[:epub_xhtml]}\##{@wordlocation}">#{@wordlocation}</a>; }
196
+ end
197
+ def location_seg(wordlocation,show)
198
+ @wordlocation,@show=wordlocation,show
199
+ @word_location_seg=wordlocation.gsub(/(.+?)\#(\d+)/,"\\1#{Sfx[:epub_xhtml]}#o\\2") unless wordlocation.nil?
200
+ case @wordlocation
201
+ when @rxp_t1
202
+ %{[<a href="doc#{Sfx[:epub_xhtml]}##{@show}">H</a>]#{@show}, }
203
+ when @rxp_t2
204
+ %{[<a href="doc#{Sfx[:epub_xhtml]}##{@show}">H</a>]#{@show}, }
205
+ when @rxp_t3
206
+ %{[<a href="doc#{Sfx[:epub_xhtml]}##{@show}">H</a>]#{@show}, }
207
+ else %{<a href="#{@word_location_seg}">#{@show}</a>, }
208
+ end
209
+ end
210
+ def map_para
211
+ @seg,toy=nil,nil
212
+ @word_map={}
213
+ @ao_array.each do |line|
214
+ if defined? line.ocn
215
+ if (line.is ==:heading \
216
+ || line.is ==:heading_insert) \
217
+ && line.ln==4
218
+ @seg=line.name
219
+ end
220
+ if line.ocn.to_s =~/\d+/ then toy=line.ocn.to_s
221
+ end
222
+ if toy =~/\d+/ \
223
+ and toy !~/^0$/
224
+ line.obj=line.obj.split(@rgx_splitlist).join(' ') #%take in word or other match
225
+ for word in line.obj.scan(@rgx_scanlist) #%take in word or other match
226
+ word=word.gsub(/#{Mx[:lnk_o]}|#{Mx[:lnk_c]}|#{Mx[:url_o]}|#{Mx[:url_c]}/,'').
227
+ gsub(/#{Mx[:fa_o]}\S+?#{Mx[:fa_o_c]}/,'').
228
+ gsub(/#{Mx[:fa_c_o]}\S+?#{Mx[:fa_c]}/,'').
229
+ gsub(/#{Mx[:gl_o]}#[a-z]+#{Mx[:gl_c]}/,'').
230
+ gsub(/#{Mx[:gl_o]}#[0-9]+#{Mx[:gl_c]}/,'').
231
+ gsub(/^\S$/,'')
232
+ word=nil if word.empty?
233
+ word=nil if word =~@rxp_excluded0 #watch
234
+ word=nil if word =~@rxp_excluded1 #watch
235
+ word=nil if word =~/^\S$/
236
+ if word
237
+ word=word.gsub(/#{Mx[:br_nl]}|#{Mx[:br_line]}/,' ').
238
+ gsub(/#{Mx[:fa_o]}[a-z]{1,7}#{Mx[:fa_o_c]}|#{Mx[:fa_c_o]}[a-z]{1,7}#{Mx[:fa_c]}/,'').
239
+ gsub(/#{Mx[:mk_o]}(?:[0-9a-f]{32}:[0-9a-f]{32}|[0-9a-f]{64}:[0-9a-f]{64})#{Mx[:mk_c]}/,'').
240
+ gsub(/#{Mx[:mk_o]}(?:[0-9a-f]{32}|[0-9a-f]{64})#{Mx[:mk_c]}/,'').
241
+ gsub(/#{Mx[:en_a_o]}(?:\d|[*+])*|#{Mx[:en_b_o]}(?:\d|[*+])*|#{Mx[:en_a_c]}|#{Mx[:en_b_c]}/mi,'').
242
+ gsub(/#{Mx[:fa_o]}\S+?#{Mx[:fa_o_c]}/,'').gsub(/#{Mx[:fa_c_o]}\S+?#{Mx[:fa_c]}/,'').
243
+ gsub(/<\/?\S+?>/,'').
244
+ gsub(/^\@+/,'').
245
+ strip.
246
+ gsub(/#{Mx[:tc_p]}.+/,'').
247
+ gsub(/[\.,;:"]$/,'').
248
+ gsub(/["]/,'').
249
+ gsub(/^\s*[\(]/,'').
250
+ gsub(/[\(]\s*$/,'').
251
+ gsub(/^(?:See|e\.?g\.?).+/,'').
252
+ gsub(/^\s*[.,;:]\s*/,'').
253
+ strip.
254
+ gsub(/^\(?[a-zA-Z]\)$/,'').
255
+ gsub(/^\d+(st|nd|rd|th)$/,'').
256
+ gsub(/^(\d+\.?)+$/, '').
257
+ gsub(/#{Mx[:mk_o]}|#{Mx[:mk_c]}/,'').
258
+ gsub(/:name#\S+/,'').
259
+ gsub(/^\S$/,'')
260
+ word=nil if word =~/^\S$/
261
+ word=nil if word =~/^\s*$/ #watch
262
+ if word
263
+ unless word =~/[A-Z][A-Z]/ \
264
+ or word =~/\w+\s\w+/
265
+ word=word.capitalize
266
+ end
267
+ @freq[word] +=1
268
+ @word_map[word] ||= []
269
+ if line !~@rxp_lv0 \
270
+ and line !~@rxp_lv1 \
271
+ and line !~@rxp_lv2 \
272
+ and line !~@rxp_lv3
273
+ @word_map[word] << location_seg("#{@seg}\##{toy}",toy)
274
+ else
275
+ @word_map[word] << case line
276
+ when @rxp_lv0 then location_seg('T0',toy)
277
+ when @rxp_lv1 then location_seg('T1',toy)
278
+ when @rxp_lv2 then location_seg('T2',toy)
279
+ when @rxp_lv3 then location_seg('T3',toy)
280
+ end
281
+ end
282
+ end
283
+ end
284
+ end
285
+ end
286
+ end
287
+ end
288
+ seg=''
289
+ @file_concordance << SiSU_XHTML_EPUB2_Concordance::Source::DocTitle.new(@particulars).create
290
+ alph=%W[A B C D E F G H I J K L M N O P Q R S T U V W X Y Z]
291
+ @file_concordance << '<p>'
292
+ alph.each {|x| @file_concordance << %{<a href="##{x}">#{x}</a>,#{$ep[:hsp]}}}
293
+ @file_concordance << '</p>'
294
+ letter=alph.shift
295
+ @file_concordance << %{\n<p class="letter"><a name="A">A</a></p>}
296
+ for word in @freq.keys.sort! {|a,b| a.downcase<=>b.downcase}
297
+ f=/^(\S)/.match(word)[1]
298
+ if letter < f.upcase
299
+ while letter < f.upcase
300
+ if alph.length > 0
301
+ letter=alph.shift
302
+ @file_concordance << %{\n<p class="letter"><a name="#{letter}">#{letter}</a></p>}
303
+ else break
304
+ end
305
+ end
306
+ end
307
+ keyword=SiSU_XHTML_EPUB2_Concordance::Source::Word.new(word,@freq[word]).html
308
+ if keyword !~ @rxp_excluded0
309
+ if @word_map[word][0] =~ /\d+/
310
+ @file_concordance << %{#{keyword}#{seg}#{@word_map[word].uniq.compact.join}}
311
+ end
312
+ @file_concordance << '</p>'
313
+ end
314
+ # special cases endnotes and header levels 1 - 3
315
+ end
316
+ credits=SiSU_Proj_XHTML::Bits.new.credits_sisu_epub
317
+ @file_concordance << %{</div>>#{credits}</body>\n</html>} # footer
318
+ end
319
+ end
320
+ end
321
+ end
322
+ __END__
@@ -0,0 +1,2272 @@
1
+ # encoding: utf-8
2
+ =begin
3
+
4
+ * Name: SiSU
5
+
6
+ ** Description: documents, structuring, processing, publishing, search
7
+ *** epub 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/xhtml_epub2_format.rb;hb=HEAD>
55
+
56
+ =end
57
+ module SiSU_XHTML_EPUB2_Format
58
+ class ParagraphNumber
59
+ def initialize(md,ocn)
60
+ @md,@ocn=md,ocn.to_s
61
+ @ocn ||=''
62
+ end
63
+ def ocn_display
64
+ make=SiSU_Env::ProcessingSettings.new(@md)
65
+ if make.build.ocn?
66
+ ocn_class='ocn'
67
+ if @ocn==nil \
68
+ or @ocn.to_i==0 \
69
+ or @ocn.empty?
70
+ %{<label class="ocn_off"></label>}
71
+ else
72
+ @ocn.gsub(/^(\d+|)$/,
73
+ %{<label class="#{ocn_class}"><a href="#o\\1" class="lnk#{ocn_class}">\\1</a></label>})
74
+ end
75
+ else
76
+ %{<label class="ocn_off"></label>}
77
+ end
78
+ end
79
+ def name
80
+ (@ocn==nil || @ocn.empty?) ? '' : %{<a name="#{@ocn}"></a>}
81
+ end
82
+ def id #w3c? "tidy" complains about numbers as identifiers ! annoying
83
+ (@ocn==nil || @ocn.empty?) ? '' : %{id="o#{@ocn}"}
84
+ end
85
+ def goto
86
+ (@ocn==nil || @ocn.empty?) ? '' : %{<a href="##{@ocn}">}
87
+ end
88
+ end
89
+ class CSS
90
+ def css_epub_xhtml
91
+ <<-WOK
92
+ /* SiSU epub css default stylesheet */
93
+ body {
94
+ color: black;
95
+ background: #ffffff;
96
+ background-color: #ffffff;
97
+ }
98
+ /*
99
+ table {
100
+ margin-left: 5%;
101
+ display: block;
102
+ }
103
+ tr {
104
+ display: block;
105
+ }
106
+ th,td {
107
+ display: inline;
108
+ vertical-align: top;
109
+ }
110
+ */
111
+ a:link {
112
+ color: #003399;
113
+ text-decoration: none;
114
+ }
115
+ a:visited {
116
+ color: #003399;
117
+ text-decoration: none;
118
+ }
119
+ a:hover {
120
+ color: #000000;
121
+ background-color: #f9f9aa;
122
+ }
123
+ /*
124
+ a:hover {
125
+ border-bottom: 2px solid #777777;
126
+ background-color: #fff3b6;
127
+ }
128
+ */
129
+ a:hover img {
130
+ background-color: #ffffff;
131
+ }
132
+ a:active {
133
+ color: #003399;
134
+ text-decoration: underline;
135
+ }
136
+ a.lnkocn:link {
137
+ color: #777777;
138
+ text-decoration: none;
139
+ }
140
+ div {
141
+ margin-left: 0;
142
+ margin-right: 0;
143
+ }
144
+ div.p {
145
+ margin-left: 5%;
146
+ margin-right: 1%;
147
+ }
148
+
149
+ .norm, .bold, .verse, .group, .block, .alt {
150
+ line-height: 133%;
151
+ margin-left: 0em;
152
+ margin-right: 2em;
153
+ margin-top: 12px;
154
+ margin-bottom: 0px;
155
+ padding-left: 0em;
156
+ text-indent: 0mm;
157
+ }
158
+ p, h0, h1, h2, h3, h4, h5, h6, h7 {
159
+ display: block;
160
+ font-family: verdana, arial, georgia, tahoma, sans-serif, helvetica, times, roman;
161
+ font-size: 100%;
162
+ font-weight: normal;
163
+ line-height: 133%;
164
+ text-align: justify;
165
+ margin-left: 0em;
166
+ margin-right: 2em;
167
+ text-indent: 0mm;
168
+ margin-top: 0.8em;
169
+ margin-bottom: 0.8em;
170
+ }
171
+ p.norm { }
172
+ p.i1 {padding-left: 1em;}
173
+ p.i2 {padding-left: 2em;}
174
+ p.i3 {padding-left: 3em;}
175
+ p.i4 {padding-left: 4em;}
176
+ p.i5 {padding-left: 5em;}
177
+ p.i6 {padding-left: 6em;}
178
+ p.i7 {padding-left: 7em;}
179
+ p.i8 {padding-left: 8em;}
180
+ p.i9 {padding-left: 9em;}
181
+
182
+ p.h0i0 {
183
+ padding-left: 0em;
184
+ text-indent: 0em;
185
+ }
186
+ p.h0i1 {
187
+ padding-left: 1em;
188
+ text-indent: -1em;
189
+ }
190
+ p.h0i2 {
191
+ padding-left: 2em;
192
+ text-indent: -2em;
193
+ }
194
+ p.h0i3 {
195
+ padding-left: 3em;
196
+ text-indent: -3em;
197
+ }
198
+ p.h0i4 {
199
+ padding-left: 4em;
200
+ text-indent: -4em;
201
+ }
202
+ p.h0i5 {
203
+ padding-left: 5em;
204
+ text-indent: -5em;
205
+ }
206
+ p.h0i6 {
207
+ padding-left: 6em;
208
+ text-indent: -6em;
209
+ }
210
+ p.h0i7 {
211
+ padding-left: 7em;
212
+ text-indent: -7em;
213
+ }
214
+ p.h0i8 {
215
+ padding-left: 8em;
216
+ text-indent: -8em;
217
+ }
218
+ p.h0i9 {
219
+ padding-left: 9em;
220
+ text-indent: -9em;
221
+ }
222
+
223
+ p.h1i0 {
224
+ padding-left: 0em;
225
+ text-indent: 1em;
226
+ }
227
+ p.h1i1 {
228
+ padding-left: 1em;
229
+ text-indent: 0em;
230
+ }
231
+ p.h1i2 {
232
+ padding-left: 2em;
233
+ text-indent: -1em;
234
+ }
235
+ p.h1i3 {
236
+ padding-left: 3em;
237
+ text-indent: -2em;
238
+ }
239
+ p.h1i4 {
240
+ padding-left: 4em;
241
+ text-indent: -3em;
242
+ }
243
+ p.h1i5 {
244
+ padding-left: 5em;
245
+ text-indent: -4em;
246
+ }
247
+ p.h1i6 {
248
+ padding-left: 6em;
249
+ text-indent: -5em;
250
+ }
251
+ p.h1i7 {
252
+ padding-left: 7em;
253
+ text-indent: -6em;
254
+ }
255
+ p.h1i8 {
256
+ padding-left: 8em;
257
+ text-indent: -7em;
258
+ }
259
+ p.h1i9 {
260
+ padding-left: 9em;
261
+ text-indent: -8em;
262
+ }
263
+
264
+ p.h2i0 {
265
+ padding-left: 0em;
266
+ text-indent: 2em;
267
+ }
268
+ p.h2i1 {
269
+ padding-left: 1em;
270
+ text-indent: 1em;
271
+ }
272
+ p.h2i2 {
273
+ padding-left: 2em;
274
+ text-indent: 0em;
275
+ }
276
+ p.h2i3 {
277
+ padding-left: 3em;
278
+ text-indent: -1em;
279
+ }
280
+ p.h2i4 {
281
+ padding-left: 4em;
282
+ text-indent: -2em;
283
+ }
284
+ p.h2i5 {
285
+ padding-left: 5em;
286
+ text-indent: -3em;
287
+ }
288
+ p.h2i6 {
289
+ padding-left: 6em;
290
+ text-indent: -4em;
291
+ }
292
+ p.h2i7 {
293
+ padding-left: 7em;
294
+ text-indent: -5em;
295
+ }
296
+ p.h2i8 {
297
+ padding-left: 8em;
298
+ text-indent: -6em;
299
+ }
300
+ p.h2i9 {
301
+ padding-left: 9em;
302
+ text-indent: -7em;
303
+ }
304
+
305
+ p.h3i0 {
306
+ padding-left: 0em;
307
+ text-indent: 3em;
308
+ }
309
+ p.h3i1 {
310
+ padding-left: 1em;
311
+ text-indent: 2em;
312
+ }
313
+ p.h3i2 {
314
+ padding-left: 2em;
315
+ text-indent: 1em;
316
+ }
317
+ p.h3i3 {
318
+ padding-left: 3em;
319
+ text-indent: 0em;
320
+ }
321
+ p.h3i4 {
322
+ padding-left: 4em;
323
+ text-indent: -1em;
324
+ }
325
+ p.h3i5 {
326
+ padding-left: 5em;
327
+ text-indent: -2em;
328
+ }
329
+ p.h3i6 {
330
+ padding-left: 6em;
331
+ text-indent: -3em;
332
+ }
333
+ p.h3i7 {
334
+ padding-left: 7em;
335
+ text-indent: -4em;
336
+ }
337
+ p.h3i8 {
338
+ padding-left: 8em;
339
+ text-indent: -5em;
340
+ }
341
+ p.h3i9 {
342
+ padding-left: 9em;
343
+ text-indent: -6em;
344
+ }
345
+
346
+ p.h4i0 {
347
+ padding-left: 0em;
348
+ text-indent: 4em;
349
+ }
350
+ p.h4i1 {
351
+ padding-left: 1em;
352
+ text-indent: 3em;
353
+ }
354
+ p.h4i2 {
355
+ padding-left: 2em;
356
+ text-indent: 2em;
357
+ }
358
+ p.h4i3 {
359
+ padding-left: 3em;
360
+ text-indent: 1em;
361
+ }
362
+ p.h4i4 {
363
+ padding-left: 4em;
364
+ text-indent: 0em;
365
+ }
366
+ p.h4i5 {
367
+ padding-left: 5em;
368
+ text-indent: -1em;
369
+ }
370
+ p.h4i6 {
371
+ padding-left: 6em;
372
+ text-indent: -2em;
373
+ }
374
+ p.h4i7 {
375
+ padding-left: 7em;
376
+ text-indent: -3em;
377
+ }
378
+ p.h4i8 {
379
+ padding-left: 8em;
380
+ text-indent: -4em;
381
+ }
382
+ p.h4i9 {
383
+ padding-left: 9em;
384
+ text-indent: -5em;
385
+ }
386
+
387
+ p.h5i0 {
388
+ padding-left: 0em;
389
+ text-indent: 5em;
390
+ }
391
+ p.h5i1 {
392
+ padding-left: 1em;
393
+ text-indent: 4em;
394
+ }
395
+ p.h5i2 {
396
+ padding-left: 2em;
397
+ text-indent: 3em;
398
+ }
399
+ p.h5i3 {
400
+ padding-left: 3em;
401
+ text-indent: 2em;
402
+ }
403
+ p.h5i4 {
404
+ padding-left: 4em;
405
+ text-indent: 1em;
406
+ }
407
+ p.h5i5 {
408
+ padding-left: 5em;
409
+ text-indent: 0em;
410
+ }
411
+ p.h5i6 {
412
+ padding-left: 6em;
413
+ text-indent: -1em;
414
+ }
415
+ p.h5i7 {
416
+ padding-left: 7em;
417
+ text-indent: -2em;
418
+ }
419
+ p.h5i8 {
420
+ padding-left: 8em;
421
+ text-indent: -3em;
422
+ }
423
+ p.h5i9 {
424
+ padding-left: 9em;
425
+ text-indent: -4em;
426
+ }
427
+
428
+ p.h6i0 {
429
+ padding-left: 0em;
430
+ text-indent: 6em;
431
+ }
432
+ p.h6i1 {
433
+ padding-left: 1em;
434
+ text-indent: 5em;
435
+ }
436
+ p.h6i2 {
437
+ padding-left: 2em;
438
+ text-indent: 4em;
439
+ }
440
+ p.h6i3 {
441
+ padding-left: 3em;
442
+ text-indent: 3em;
443
+ }
444
+ p.h6i4 {
445
+ padding-left: 4em;
446
+ text-indent: 2em;
447
+ }
448
+ p.h6i5 {
449
+ padding-left: 5em;
450
+ text-indent: 1em;
451
+ }
452
+ p.h6i6 {
453
+ padding-left: 6em;
454
+ text-indent: 0em;
455
+ }
456
+ p.h6i7 {
457
+ padding-left: 7em;
458
+ text-indent: -1em;
459
+ }
460
+ p.h6i8 {
461
+ padding-left: 8em;
462
+ text-indent: -2em;
463
+ }
464
+ p.h6i9 {
465
+ padding-left: 9em;
466
+ text-indent: -3em;
467
+ }
468
+
469
+ p.h7i0 {
470
+ padding-left: 0em;
471
+ text-indent: 7em;
472
+ }
473
+ p.h7i1 {
474
+ padding-left: 1em;
475
+ text-indent: 6em;
476
+ }
477
+ p.h7i2 {
478
+ padding-left: 2em;
479
+ text-indent: 5em;
480
+ }
481
+ p.h7i3 {
482
+ padding-left: 3em;
483
+ text-indent: 4em;
484
+ }
485
+ p.h7i4 {
486
+ padding-left: 4em;
487
+ text-indent: 3em;
488
+ }
489
+ p.h7i5 {
490
+ padding-left: 5em;
491
+ text-indent: 2em;
492
+ }
493
+ p.h7i6 {
494
+ padding-left: 6em;
495
+ text-indent: 1em;
496
+ }
497
+ p.h7i7 {
498
+ padding-left: 7em;
499
+ text-indent: 0em;
500
+ }
501
+ p.h7i8 {
502
+ padding-left: 8em;
503
+ text-indent: -1em;
504
+ }
505
+ p.h7i9 {
506
+ padding-left: 9em;
507
+ text-indent: -2em;
508
+ }
509
+
510
+ p.h8i0 {
511
+ padding-left: 0em;
512
+ text-indent: 8em;
513
+ }
514
+ p.h8i1 {
515
+ padding-left: 1em;
516
+ text-indent: 7em;
517
+ }
518
+ p.h8i2 {
519
+ padding-left: 2em;
520
+ text-indent: 6em;
521
+ }
522
+ p.h8i3 {
523
+ padding-left: 3em;
524
+ text-indent: 5em;
525
+ }
526
+ p.h8i4 {
527
+ padding-left: 4em;
528
+ text-indent: 4em;
529
+ }
530
+ p.h8i5 {
531
+ padding-left: 5em;
532
+ text-indent: 3em;
533
+ }
534
+ p.h8i6 {
535
+ padding-left: 6em;
536
+ text-indent: 2em;
537
+ }
538
+ p.h8i7 {
539
+ padding-left: 7em;
540
+ text-indent: 1em;
541
+ }
542
+ p.h8i8 {
543
+ padding-left: 8em;
544
+ text-indent: 0em;
545
+ }
546
+ p.h8i9 {
547
+ padding-left: 9em;
548
+ text-indent: -1em;
549
+ }
550
+
551
+ p.h9i0 {
552
+ padding-left: 0em;
553
+ text-indent: 9em;
554
+ }
555
+ p.h9i1 {
556
+ padding-left: 1em;
557
+ text-indent: 8em;
558
+ }
559
+ p.h9i2 {
560
+ padding-left: 2em;
561
+ text-indent: 7em;
562
+ }
563
+ p.h9i3 {
564
+ padding-left: 3em;
565
+ text-indent: 6em;
566
+ }
567
+ p.h9i4 {
568
+ padding-left: 4em;
569
+ text-indent: 5em;
570
+ }
571
+ p.h9i5 {
572
+ padding-left: 5em;
573
+ text-indent: 4em;
574
+ }
575
+ p.h9i6 {
576
+ padding-left: 6em;
577
+ text-indent: 3em;
578
+ }
579
+ p.h9i7 {
580
+ padding-left: 7em;
581
+ text-indent: 2em;
582
+ }
583
+ p.h9i8 {
584
+ padding-left: 8em;
585
+ text-indent: 1em;
586
+ }
587
+ p.h9i9 {
588
+ padding-left: 9em;
589
+ text-indent: 0em;
590
+ }
591
+
592
+ p.it0 {
593
+ margin-left: 0em;
594
+ margin-top: 6px;
595
+ margin-bottom: 0px;
596
+ line-height: 100%;
597
+ }
598
+ p.it1 {
599
+ margin-left: 1em;
600
+ margin-top: 0px;
601
+ margin-bottom: 0px;
602
+ line-height: 100%;
603
+ }
604
+ p.it2 {
605
+ margin-left: 2em;
606
+ margin-top: 0px;
607
+ margin-bottom: 0px;
608
+ line-height: 100%;
609
+ }
610
+ p.it3 {
611
+ margin-left: 3em;
612
+ margin-top: 0px;
613
+ margin-bottom: 0px;
614
+ line-height: 100%;
615
+ }
616
+ p.it4 {
617
+ margin-left: 4em;
618
+ margin-top: 0px;
619
+ margin-bottom: 0px;
620
+ line-height: 100%;
621
+ }
622
+ p.it5 {
623
+ margin-left: 5em;
624
+ margin-top: 0px;
625
+ margin-bottom: 0px;
626
+ line-height: 100%;
627
+ }
628
+ p.it6 {
629
+ margin-left: 6em;
630
+ margin-top: 0px;
631
+ margin-bottom: 0px;
632
+ line-height: 100%;
633
+ }
634
+ p.it7 {
635
+ margin-left: 7em;
636
+ margin-top: 0px;
637
+ margin-bottom: 0px;
638
+ line-height: 100%;
639
+ }
640
+ p.it8 {
641
+ margin-left: 8em;
642
+ margin-top: 0px;
643
+ margin-bottom: 0px;
644
+ line-height: 100%;
645
+ }
646
+ p.it9 {
647
+ margin-left: 9em;
648
+ margin-bottom: 0px;
649
+ margin-top: 0px;
650
+ line-height: 100%;
651
+ }
652
+
653
+ p.group { }
654
+
655
+ p.block { }
656
+
657
+ p.alt { }
658
+
659
+ p.verse {
660
+ margin-bottom: 6px;
661
+ }
662
+
663
+ p.code {
664
+ font-family: inconsolata, andale mono, courier new, courier, monospace;
665
+ font-size: 90%;
666
+ text-align: left;
667
+ background-color: #eeeeee;
668
+ }
669
+
670
+ p.caption {
671
+ text-align: left;
672
+ font-size: 80%;
673
+ display: inline;
674
+ }
675
+
676
+ p.endnote {
677
+ font-size: 96%;
678
+ line-height: 120%;
679
+ text-align: left;
680
+ margin-right: 2em;
681
+ }
682
+ p.endnote_indent {
683
+ font-size: 96%;
684
+ line-height: 120%;
685
+ text-align: left;
686
+ margin-left: 2em;
687
+ margin-right: 2em;
688
+ }
689
+
690
+ p.center {
691
+ text-align: center;
692
+ }
693
+ p.align_right {
694
+ text-align: right;
695
+ }
696
+ p.bold {
697
+ font-weight: bold;
698
+ }
699
+ p.bold_left {
700
+ font-weight: bold;
701
+ text-align: left;
702
+ }
703
+ p.centerbold {
704
+ text-align: center;
705
+ font-weight: bold;
706
+ }
707
+ p.em {
708
+ font-weight: bold;
709
+ font-style: normal;
710
+ background: #fff3b6;
711
+ }
712
+
713
+ p.small {
714
+ font-size: 80%;
715
+ margin-top: 0px;
716
+ margin-bottom: 0px;
717
+ margin-right: 6px;
718
+ text-align: left;
719
+ }
720
+
721
+ .tiny, .tiny_left, .tiny_right, .tiny_center {
722
+ font-size: 10px;
723
+ margin-top: 0px;
724
+ margin-bottom: 0px;
725
+ color: #777777;
726
+ margin-right: 6px;
727
+ text-align: left;
728
+ }
729
+ p.tiny { }
730
+ p.tiny_left {
731
+ margin-left: 0px;
732
+ margin-right: 0px;
733
+ text-align: left;
734
+ }
735
+ p.tiny_right {
736
+ margin-right: 1em;
737
+ text-align: right;
738
+ }
739
+ p.tiny_center {
740
+ margin-left: 0px;
741
+ margin-right: 0px;
742
+ text-align: center;
743
+ }
744
+
745
+ p.concordance_word {
746
+ line-height: 150%;
747
+ font-weight: bold;
748
+ display: inline;
749
+ margin-top: 4px;
750
+ margin-bottom: 1px;
751
+ }
752
+ p.concordance_count {
753
+ font-size: 80%;
754
+ color: #777777;
755
+ display: inline;
756
+ margin-left: 0em;
757
+ }
758
+ p.concordance_object {
759
+ font-size: 80%;
760
+ line-height: 120%;
761
+ text-align: left;
762
+ margin-left: 3em;
763
+ margin-top: 1px;
764
+ margin-bottom: 3px;
765
+ }
766
+ p.book_index_lev1 {
767
+ line-height: 100%;
768
+ margin-top: 4px;
769
+ margin-bottom: 1px;
770
+ }
771
+ p.book_index_lev2 {
772
+ line-height: 100%;
773
+ text-align: left;
774
+ margin-left: 3em;
775
+ margin-top: 1px;
776
+ margin-bottom: 3px;
777
+ }
778
+
779
+ p.quickref {
780
+ font-size: 10px;
781
+ font-style: italic;
782
+ margin-top: 0px;
783
+ margin-bottom: 0px;
784
+ color: #777777;
785
+ margin-right: 5px;
786
+ text-align: left;
787
+ }
788
+ p.bigref {
789
+ font-size: 11px;
790
+ font-weight: bold;
791
+ margin-top: 0px;
792
+ margin-bottom: 0px;
793
+ color: #777777;
794
+ margin-right: 5px;
795
+ text-align: center;
796
+ }
797
+
798
+ p.letter {
799
+ font-weight: bold;
800
+ font-size: 80%;
801
+ margin-left: 0em;
802
+ margin-top: 2px;
803
+ margin-bottom: 2px;
804
+ margin-right: 6px;
805
+ text-align: left;
806
+ color: white;
807
+ background: #880000;
808
+ }
809
+
810
+ tt {
811
+ font-family: inconsolata, andale mono, courier new, courier, monospace;
812
+ background-color: #eeeeee;
813
+ }
814
+
815
+ label.ocn {
816
+ width: 2%;
817
+ float: right;
818
+ top: 0;
819
+ font-size: 10px;
820
+ margin-top: 0px;
821
+ margin-bottom: 5px;
822
+ color: #777777;
823
+ margin-right: 5px;
824
+ text-align: right;
825
+ background-color: #ffffff;
826
+ }
827
+
828
+ table { }
829
+ tr { }
830
+ th,td {
831
+ vertical-align: top;
832
+ text-align: left;
833
+ }
834
+ th {
835
+ font-weight: bold;
836
+ }
837
+
838
+ p.left, th.left, td.left {
839
+ text-align: left;
840
+ }
841
+ p.small_left, th.small_left, td.small_left {
842
+ text-align: left;
843
+ font-size: 80%;
844
+ }
845
+ p.right, th.right, td.right {
846
+ text-align: right;
847
+ }
848
+
849
+ #horizontal_links {
850
+ background: #eeeeee;
851
+ margin-left: 5%;
852
+ margin-right: 5%;
853
+ }
854
+ #horizontal {
855
+ margin: 0;
856
+ padding: 0 0 0 10px;
857
+ border-top: 1px solid #000077;
858
+ border-bottom: 1px solid #000077;
859
+ }
860
+ #horizontal li {
861
+ margin: 0 0 0 0;
862
+ padding: 0 16px 0 0;
863
+ display: inline;
864
+ list-style-type: none;
865
+ text-align: left;
866
+ background: none;
867
+ }
868
+ #horizontal a {
869
+ line-height: 12px;
870
+ margin: 0 0 0 0;
871
+ text-decoration: none;
872
+ color: #000077;
873
+ }
874
+ #horizontal a.active, #horizontal a:hover {
875
+ border-bottom: 2px solid #777777;
876
+ padding-bottom: 2px;
877
+ color: #000077;
878
+ }
879
+ #horizontal a:hover {
880
+ color: #000077;
881
+ }
882
+
883
+ #document_versions {
884
+ position: absolute;
885
+ top: 10mm;
886
+ right: 2%;
887
+ width: 12%;
888
+ float: right;
889
+ }
890
+
891
+ #vertical_links {
892
+ position: absolute;
893
+ top: 10mm;
894
+ right: 0px;
895
+ width: 20%;
896
+ background: #dddddd;
897
+ float: right;
898
+ }
899
+ #vertical {
900
+ padding: 0 12px 0px 0px;
901
+ margin-left: 2%;
902
+ margin-right: 2%;
903
+ }
904
+ #vertical li {
905
+ display: block;
906
+ list-style-type: none;
907
+ }
908
+ #vertical a {
909
+ line-height: 12px;
910
+ text-decoration: none;
911
+ color: #000077;
912
+ }
913
+ #vertical a.active, #vertical a:hover {
914
+ border-bottom: 2px solid #777777;
915
+ padding-bottom: 2px;
916
+ color: #000077;
917
+ }
918
+
919
+ ul, li {
920
+ list-style-type: none;
921
+ list-style: none;
922
+ padding-left: 20px;
923
+ display: block;
924
+ font-family: verdana, arial, georgia, tahoma, sans-serif, helvetica, times, roman;
925
+ font-weight: normal;
926
+ line-height: 150%;
927
+ text-align: justify;
928
+ text-indent: 0mm;
929
+ margin-left: 1em;
930
+ margin-right: 2em;
931
+ margin-top: 3px;
932
+ margin-bottom: 3px;
933
+ }
934
+
935
+ li {
936
+ background: url(../image/bullet_09.png) no-repeat 0px 6px;
937
+ }
938
+
939
+ ul {
940
+ }
941
+ li.bullet { margin-left: 0em; }
942
+ li.i1 { margin-left: 1em; }
943
+ li.i2 { margin-left: 2em; }
944
+ li.i3 { margin-left: 3em; }
945
+ li.i4 { margin-left: 4em; }
946
+ li.i5 { margin-left: 5em; }
947
+ li.i6 { margin-left: 6em; }
948
+ li.i7 { margin-left: 7em; }
949
+ li.i8 { margin-left: 8em; }
950
+ li.i9 { margin-left: 9em; }
951
+
952
+ li.doc, li.ref, li.refcenter {
953
+ margin-top: 0px;
954
+ margin-bottom: 0px;
955
+ margin-right: 0px;
956
+ font-size: 8px;
957
+ font-style: normal;
958
+ text-align: left;
959
+ }
960
+ li.doc {
961
+ background: url(../image/bullet_09.png) no-repeat 0px 6px;
962
+ padding-left: 16px;
963
+ margin-left: 10px;
964
+ margin-right: 0px;
965
+ }
966
+ li.ref {
967
+ background: none;
968
+ padding-left: 0;
969
+ margin-left: 0;
970
+ color: #777777;
971
+ }
972
+ li.refcenter {
973
+ background: url(../image/bullet_09.png) no-repeat 0px 6px;
974
+ padding-left: 20px;
975
+ margin-left: 10%;
976
+ font-size: 9px;
977
+ color: #777777;
978
+ text-align: center;
979
+ }
980
+ li.refbold {
981
+ list-style-type: none;
982
+ padding-left: 16px;
983
+ margin-left: 0;
984
+ margin-right: 10mm;
985
+ font-weight: bold;
986
+ }
987
+
988
+ h0, h1, h2, h3, h4, h5, h6, h7 {
989
+ font-weight: bold;
990
+ line-height: 120%;
991
+ text-align: left;
992
+ margin-top: 20px;
993
+ margin-bottom: 10px;
994
+ }
995
+ h4.norm, h5.norm, h6.norm, h7.norm {
996
+ margin-top: 10px;
997
+ margin-bottom: 0px;
998
+ }
999
+ h1.center, h2.center, h3.center, h4.center, h5.center, h6.center, h7.center {
1000
+ text-align: center;
1001
+ }
1002
+ h1 { font-size: 120%; }
1003
+ h2 { font-size: 115%; }
1004
+ h3 { font-size: 110%; }
1005
+ h4 { font-size: 105%; }
1006
+ h5 { font-size: 100%; }
1007
+ h6 { font-size: 100%; }
1008
+ h7 { font-size: 100%; }
1009
+ h0 { font-size: 80%; }
1010
+
1011
+ h1.i {margin-left: 2em;}
1012
+ h2.i {margin-left: 3em;}
1013
+ h3.i {margin-left: 4em;}
1014
+ h4.i {margin-left: 5em;}
1015
+ h5.i {margin-left: 6em;}
1016
+ h6.i {margin-left: 7em;}
1017
+ h7.i {margin-left: 8em;}
1018
+ h8.i {margin-left: 9em;}
1019
+ h9.i {margin-left: 10em;}
1020
+
1021
+ .toc {
1022
+ font-weight: normal;
1023
+ margin-top: 6px;
1024
+ margin-bottom: 6px;
1025
+ }
1026
+ h1.toc {
1027
+ margin-left: 1em;
1028
+ font-size: 115%;
1029
+ line-height: 150%;
1030
+ }
1031
+ h2.toc {
1032
+ margin-left: 2em;
1033
+ font-size: 110%;
1034
+ line-height: 140%;
1035
+ }
1036
+ h3.toc {
1037
+ margin-left: 3em;
1038
+ font-size: 105%;
1039
+ line-height: 120%;
1040
+ }
1041
+ h4.toc {
1042
+ margin-left: 4em;
1043
+ font-size: 100%;
1044
+ line-height: 120%;
1045
+ }
1046
+ h5.toc {
1047
+ margin-left: 5em;
1048
+ font-size: 95%;
1049
+ line-height: 110%;
1050
+ }
1051
+ h6.toc {
1052
+ margin-left: 6em;
1053
+ font-size: 90%;
1054
+ line-height: 110%;
1055
+ }
1056
+ h7.toc {
1057
+ margin-left: 7em;
1058
+ font-size: 90%;
1059
+ line-height: 105%;
1060
+ }
1061
+
1062
+ .microtoc {
1063
+ margin-top: 2px;
1064
+ margin-bottom: 2px;
1065
+ }
1066
+
1067
+ h1.microtoc {
1068
+ margin-left: 0mm;
1069
+ font-size: 115%;
1070
+ }
1071
+ h2.microtoc {
1072
+ margin-left: 5mm;
1073
+ font-size: 110%;
1074
+ }
1075
+ h3.microtoc {
1076
+ margin-left: 10mm;
1077
+ font-size: 105%;
1078
+ }
1079
+ h4.microtoc {
1080
+ margin-left: 15mm;
1081
+ font-weight: normal;
1082
+ font-size: 100%;
1083
+ }
1084
+ h5.microtoc {
1085
+ margin-left: 20mm;
1086
+ font-weight: normal;
1087
+ font-size: 95%;
1088
+ }
1089
+ h6.microtoc {
1090
+ margin-left: 25mm;
1091
+ font-weight: normal;
1092
+ font-size: 90%;
1093
+ }
1094
+ h7.microtoc {
1095
+ margin-left: 30mm;
1096
+ font-weight: normal;
1097
+ font-size: 85%;
1098
+ }
1099
+
1100
+ .subtoc {
1101
+ margin-right: 34%;
1102
+ font-weight: normal;
1103
+ }
1104
+ h5.subtoc {
1105
+ margin-left: 2em;
1106
+ font-size: 80%;
1107
+ margin-top: 2px;
1108
+ margin-bottom: 2px;
1109
+ }
1110
+ h6.subtoc {
1111
+ margin-left: 3em;
1112
+ font-size: 75%;
1113
+ margin-top: 0px;
1114
+ margin-bottom: 0px;
1115
+ }
1116
+ h7.subtoc {
1117
+ margin-left: 4em;
1118
+ font-size: 70%;
1119
+ margin-top: 0px;
1120
+ margin-bottom: 0px;
1121
+ }
1122
+
1123
+ div.substance {
1124
+ width: 100%;
1125
+ background-color: #ffffff;
1126
+ }
1127
+ div.ocn {
1128
+ width: 5%;
1129
+ float: right;
1130
+ top: 0;
1131
+ background-color: #ffffff;
1132
+ }
1133
+ div.endnote {
1134
+ width: 100%;
1135
+ background-color: #fffffff;
1136
+ }
1137
+ div.toc {
1138
+ position: absolute;
1139
+ float: left;
1140
+ margin: 0;
1141
+ padding: 0;
1142
+ padding-top: 0.5em;
1143
+ border: 0;
1144
+ width: 5%;
1145
+ background-color: #eeeeee;
1146
+ margin-right:1em;
1147
+ }
1148
+ div.summary {
1149
+ margin: 0;
1150
+ padding: 0;
1151
+ border-left: 2em solid #eeeeee;
1152
+ padding-left: 0em;
1153
+ background-color: #eeeeee;
1154
+ }
1155
+ div.content, div.main_column {
1156
+ margin: 0;
1157
+ padding: 0;
1158
+ border-left: 0% solid #ffffff;
1159
+ padding-left: 5%;
1160
+ }
1161
+ div.content:after {
1162
+ content:' ';
1163
+ clear:both;
1164
+ display:block;
1165
+ height:0;
1166
+ overflow:hidden
1167
+ }
1168
+ div.footer {
1169
+ clear:left;
1170
+ padding: 0.5em;
1171
+ font-size: 80%;
1172
+ margin: 0;
1173
+ }
1174
+ div.toc ul {
1175
+ list-style: none;
1176
+ padding: 0;
1177
+ margin: 0;
1178
+ }
1179
+ div.toc li ul a, li ul span.currentlink
1180
+ {
1181
+ font-weight: normal;
1182
+ font-size: 90%;
1183
+ padding-left: 2em;
1184
+ background-color: #eeeeee;
1185
+ }
1186
+ div.toc a, span.currentlink{
1187
+ display:block;
1188
+ text-decoration: none;
1189
+ padding-left: 0.5em;
1190
+ color: #0000aa;
1191
+ }
1192
+ hr {
1193
+ width: 90%;
1194
+ }
1195
+
1196
+ span.currentlink {
1197
+ text-decoration: none;
1198
+ background-color: #aaaaf9;
1199
+ }
1200
+
1201
+ div.toc a:visited {
1202
+ color: #0000aa;
1203
+ }
1204
+ div.toc a:hover {
1205
+ color: #000000;
1206
+ background-color: #f9f9aa;
1207
+ }
1208
+
1209
+ h1.c, h2.c, h3.c, h4.c, h5.c, h6.c, h7.c, p.c {
1210
+ text-align: center
1211
+ }
1212
+ h1.red, h2.red, h3.red, h4.red, h5.red, h6.red, h7.red {
1213
+ text-align: center;
1214
+ color: #ff0000;
1215
+ margin-left: 5mm;
1216
+ text-indent: 5mm;
1217
+ margin-top: 30px;
1218
+ margin-bottom: 20px;
1219
+ margin-right: 15mm;
1220
+ }
1221
+ h1.ruby, h2.ruby, h3.ruby, h4.ruby, h5.ruby, h6.ruby, h7.ruby {
1222
+ text-align: center;
1223
+ color: #990000;
1224
+ margin-left: 5mm;
1225
+ text-indent: 5mm;
1226
+ margin-top: 30px;
1227
+ margin-bottom: 20px;
1228
+ margin-right: 15mm;
1229
+ }
1230
+ WOK
1231
+ end
1232
+ end
1233
+ module SanitizeXML
1234
+ require_relative 'xhtml_parts' # xhtml_parts.rb
1235
+ def self.xml(x)
1236
+ if x.is_a?(String)
1237
+ x=x.gsub(/&nbsp;/,' ') if Ep[:alt]==:on
1238
+ x.gsub(/&/,'&amp;').
1239
+ gsub(/</,"&lt;").gsub(/>/,"&gt;").
1240
+ gsub(/#{Dx[:url_o]}/,Dx[:url_o_xml]).gsub(/#{Dx[:url_c]}/,Dx[:url_c_xml]).
1241
+ #gsub(/</,'&#60;').gsub(/>/,'&#62;').
1242
+ gsub(/\\\\/,'<br />').
1243
+ gsub(/&lt;br(?: \/)?&gt;/,'<br />')
1244
+ else x
1245
+ end
1246
+ end
1247
+ end
1248
+ class HeadInformation
1249
+ attr_reader :md,:rdf
1250
+ def initialize(md)
1251
+ @md=md
1252
+ # DublinCore 1 - title
1253
+ @css=SiSU_Env::CSS_Stylesheet.new(md)
1254
+ @per=SiSU_XHTML_EPUB2_Persist::Persist.new
1255
+ @per.seg_name_x=SiSU_XHTML_EPUB2::Seg.new.seg_name_x
1256
+ @per.seg_name_x_tracker=SiSU_XHTML_EPUB2::Seg.new.seg_name_x_tracker
1257
+ @tocband_scroll,@tocband_segtoc=nil,nil
1258
+ @index,@metalink='index','#metadata'
1259
+ end
1260
+ def doc_type_xhtml
1261
+ <<-WOK
1262
+ <?xml version='1.0' encoding='utf-8'?>
1263
+ <html xmlns="http://www.w3.org/1999/xhtml">
1264
+ WOK
1265
+ end
1266
+ =begin
1267
+ ~/epub
1268
+ |-- META-INF
1269
+ | `-- container.xml # simple, make sure full-path of rootfile points to metadata.opf
1270
+ |-- content
1271
+ | |-- 1.xhtml
1272
+ | |-- 2.xhtml
1273
+ | |-- 3.xhtml
1274
+ | |-- ... .xhtml
1275
+ | |-- concordance.xhtml
1276
+ | |-- css
1277
+ | | `-- xhtml.css
1278
+ | |-- endnotes.xhtml
1279
+ | |-- image
1280
+ | | |-- arrow_next_red.png
1281
+ | | |-- arrow_prev_red.png
1282
+ | | |-- arrow_up_red.png
1283
+ | | `-- bullet_09.png
1284
+ | |-- index.xhtml
1285
+ | |-- meta.xhtml
1286
+ | |-- metadata.xhtml
1287
+ | `-- toc.xhtml
1288
+ |-- metadata.opf #(i) metadata dc; (ii) manifest (contents); (iii) spine (mimetypes)
1289
+ |-- mimetype # application/epub+zip
1290
+ `-- toc.ncx #(i) head (ii) doc title (iii) navmap, list of navigation points (like chapters)
1291
+ =end
1292
+ def doc_type
1293
+ doc_type_xhtml
1294
+ end
1295
+ def mimetype
1296
+ <<-WOK
1297
+ application/epub+zip
1298
+ WOK
1299
+ end
1300
+ def metainf_container #container.xml file in META-INF directory
1301
+ #simple, make sure full-path of rootfile points to metadata.opf
1302
+ #epub_metadata.opf content.opf
1303
+ <<-WOK
1304
+ <?xml version='1.0' encoding='utf-8'?>
1305
+ <container version="1.0"
1306
+ xmlns="urn:oasis:names:tc:opendocument:xmlns:container">
1307
+ <rootfiles>
1308
+ <rootfile full-path="#{Ep[:d_oebps]}/#{Ep[:f_opf]}"
1309
+ media-type="application/oebps-package+xml" />
1310
+ </rootfiles>
1311
+ </container>
1312
+ WOK
1313
+ end
1314
+ def sections(dob,fn_base)
1315
+ name=fn_base + Sfx[:epub_xhtml]
1316
+ dir_epub_cont=@md.env.processing_path.epub + '/' + Ep[:d_oebps]
1317
+ segfilename=dir_epub_cont + '/' + name
1318
+ output_epub_cont_seg=File.new(segfilename,'w')
1319
+ txt=dob.obj.gsub(/#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]}/,'')
1320
+ output_epub_cont_seg << %{#{doc_type}
1321
+ <head>
1322
+ <title>
1323
+ #{dob.obj} -
1324
+ #{@md.html_title}
1325
+ </title>
1326
+ <meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
1327
+ #{@css.xhtml_epub}
1328
+ </head>
1329
+ <body lang="#{@md.opt.lng}">
1330
+ <div class="content">
1331
+ <div class="substance">
1332
+ <label class="ocn"><a href="#o#{dob.ocn}" class="lnkocn">#{dob.ocn}</a></label>
1333
+ <h1 class="norm" id="o#{dob.ocn}">
1334
+ #{txt}
1335
+ </h1>
1336
+ </div>
1337
+ </div>
1338
+ </body>
1339
+ </html>}
1340
+ output_epub_cont_seg.close
1341
+ end
1342
+ def toc_ncx #list of navigation points (like chapters), table of contents, listing each navigation point (chapters and such) under the navigation map
1343
+ def structure
1344
+ open
1345
+ head_open
1346
+ head
1347
+ head_close
1348
+ doc_title
1349
+ doc_author
1350
+ navmap_open
1351
+ #navmap ...
1352
+ navmap_close
1353
+ close
1354
+ end
1355
+ def open
1356
+ <<-WOK
1357
+ <?xml version='1.0' encoding='utf-8'?>
1358
+ <ncx xmlns="http://www.daisy.org/z3986/2005/ncx/" version="2005-1">
1359
+ WOK
1360
+ end
1361
+ def close
1362
+ <<-WOK
1363
+ </ncx>
1364
+ WOK
1365
+ end
1366
+ def head_open
1367
+ <<-WOK
1368
+ <head>
1369
+ WOK
1370
+ end
1371
+ def head
1372
+ depth=@md.lvs[1] + @md.lvs[2] + @md.lvs[3] + @md.lvs[4]
1373
+ title=SanitizeXML.xml(@md.title.full)
1374
+ author=SanitizeXML.xml(@md.author)
1375
+ dgst=(@md.dgst.is_a?(Array) and @md.dgst.length > 1) ? @md.dgst[1] : 'na'
1376
+ <<-WOK
1377
+ <!-- four required metadata items (for all NCX documents,
1378
+ (including the relaxed constraints of OPS 2.0) -->
1379
+ <title>#{title} by #{author}</title>
1380
+ <link href="css/xhtml.css" rel="stylesheet" type="text/css" id="main-css" />
1381
+ <meta name="dtb:uid" content="urn:uuid:#{dgst}" />
1382
+ <!-- <meta name="epub-creator" content="#{@md.publisher}" /> -->
1383
+ <meta name="dtb:depth" content="#{depth}" />
1384
+ <meta name="dtb:totalPageCount" content="0" />
1385
+ <meta name="dtb:maxPageNumber" content="0" />
1386
+ WOK
1387
+ end
1388
+ def head_close
1389
+ <<-WOK
1390
+ </head>
1391
+ WOK
1392
+ end
1393
+ def doc_title
1394
+ txt=SanitizeXML.xml(@md.title.full)
1395
+ <<-WOK
1396
+ <docTitle>
1397
+ <text>#{txt}</text>
1398
+ </docTitle>
1399
+ WOK
1400
+ end
1401
+ def doc_author
1402
+ txt=SanitizeXML.xml(@md.author)
1403
+ <<-WOK
1404
+ <docAuthor>
1405
+ <text>#{txt}</text>
1406
+ </docAuthor>
1407
+ WOK
1408
+ end
1409
+ def navmap_open
1410
+ <<-WOK
1411
+ <navMap>
1412
+ WOK
1413
+ end
1414
+ def navmap_sisu_toc(no)
1415
+ id_u=DISABLE[:epub][:ncx_navpoint_unique_id] \
1416
+ ? ''
1417
+ : "-#{no}"
1418
+ <<-WOK
1419
+ <navPoint id="navpoint#{id_u}" playOrder="#{no}">
1420
+ <navLabel>
1421
+ <text>Table of Contents</text>
1422
+ </navLabel>
1423
+ <content src="index#{Sfx[:epub_xhtml]}" />
1424
+ </navPoint>
1425
+ WOK
1426
+ end
1427
+ def navpoint(dob,no,fn_base,hashtag=nil)
1428
+ fn=fn_base + Sfx[:epub_xhtml]
1429
+ name=hashtag ? fn + hashtag : fn
1430
+ id_u=DISABLE[:epub][:ncx_navpoint_unique_id] \
1431
+ ? ''
1432
+ : "-#{no}"
1433
+ txt=dob.obj.gsub(/#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]}/,'')
1434
+ <<-WOK
1435
+ <navPoint class="chapter" id="navpoint#{id_u}" playOrder="#{no}">
1436
+ <navLabel>
1437
+ <text>#{txt}</text>
1438
+ </navLabel>
1439
+ <content src="#{name}" />
1440
+ WOK
1441
+ end
1442
+ def navpoint_close
1443
+ <<-WOK
1444
+ </navPoint>
1445
+ WOK
1446
+ end
1447
+ def navmap_close
1448
+ <<-WOK
1449
+ </navMap>
1450
+ WOK
1451
+ end
1452
+ self
1453
+ end
1454
+ def metadata_opf #(i) metadata dc; (ii) manifest (contents); (iii) spine (mimetypes)
1455
+ def structure
1456
+ package_open
1457
+ metadata_open
1458
+ metadata_close
1459
+ manifest_open
1460
+ manifest_close
1461
+ spine_open
1462
+ spine_close
1463
+ guide_open
1464
+ guide_close
1465
+ package_close
1466
+ end
1467
+ def package_open
1468
+ <<-WOK
1469
+ <?xml version='1.0' encoding='utf-8'?>
1470
+ <package xmlns="http://www.idpf.org/2007/opf" version="2.0" unique-identifier="EPB-UUID">
1471
+ WOK
1472
+ end
1473
+ def package_close
1474
+ <<-WOK
1475
+ </package>
1476
+ WOK
1477
+ end
1478
+ def metadata #metadata dc
1479
+ cover_image=if defined? @md.make.cover_image \
1480
+ and @md.make.cover_image.is_a?(Hash) \
1481
+ and @md.make.cover_image[:cover] =~/\S+/
1482
+ %{\n <#{$ep[:o]}meta name="cover" content="cover_image" />}
1483
+ else ''
1484
+ end
1485
+ author=if defined? @md.creator.author \
1486
+ and @md.creator.author =~/\S+/
1487
+ m=''
1488
+ @md.creator.author_detail.each do |i|
1489
+ surname=i[:the] \
1490
+ ? i[:the]
1491
+ : ''
1492
+ other_names=i[:others] \
1493
+ ? ', ' + i[:others]
1494
+ : ''
1495
+ m=(m.empty?) \
1496
+ ? (surname + other_names)
1497
+ : (m + '; ' + surname + ', ' + other_names)
1498
+ m=SanitizeXML.xml(m)
1499
+ end
1500
+ x=@md.creator.author.dup
1501
+ x=SanitizeXML.xml(x)
1502
+ %{\n <dc:creator opf:file-as="#{m}" opf:role="aut">#{x}</dc:creator>}
1503
+ else ''
1504
+ end
1505
+ editor=if defined? @md.creator.editor \
1506
+ and @md.creator.editor =~/\S+/
1507
+ m=''
1508
+ @md.creator.editor_detail.each do |i|
1509
+ surname=i[:the] \
1510
+ ? i[:the]
1511
+ : ''
1512
+ other_names=i[:others] \
1513
+ ? ', ' + i[:others]
1514
+ : ''
1515
+ m=(m.empty?) \
1516
+ ? (surname + other_names)
1517
+ : (m + '; ' + surname + ', ' + other_names)
1518
+ m=SanitizeXML.xml(m)
1519
+ end
1520
+ x=@md.creator.editor.dup
1521
+ x=SanitizeXML.xml(x)
1522
+ %{\n <dc:creator opf:file-as="#{m}" opf:role="edt">#{x}</dc:creator>}
1523
+ else ''
1524
+ end
1525
+ translator=if defined? @md.creator.translator \
1526
+ and @md.creator.translator =~/\S+/
1527
+ m=''
1528
+ @md.creator.translator_detail.each do |i|
1529
+ surname=i[:the] \
1530
+ ? i[:the]
1531
+ : ''
1532
+ other_names=i[:others] \
1533
+ ? ', ' + i[:others]
1534
+ : ''
1535
+ m=(m.empty?) \
1536
+ ? (surname + other_names)
1537
+ : (m + '; ' + surname + ', ' + other_names)
1538
+ m=SanitizeXML.xml(m)
1539
+ end
1540
+ x=@md.creator.translator.dup
1541
+ x=SanitizeXML.xml(x)
1542
+ %{\n <dc:creator opf:file-as="#{m}" opf:role="trl">#{x}</dc:creator>}
1543
+ else ''
1544
+ end
1545
+ illustrator=if defined? @md.creator.illustrator \
1546
+ and @md.creator.illustrator =~/\S+/
1547
+ m=''
1548
+ @md.creator.illustrator_detail.each do |i|
1549
+ surname=i[:the] \
1550
+ ? i[:the]
1551
+ : ''
1552
+ other_names=i[:others] \
1553
+ ? ', ' + i[:others]
1554
+ : ''
1555
+ m=(m.empty?) \
1556
+ ? (surname + other_names)
1557
+ : (m + '; ' + surname + ', ' + other_names)
1558
+ m=SanitizeXML.xml(m)
1559
+ end
1560
+ x=@md.creator.illustrator.dup
1561
+ x=SanitizeXML.xml(x)
1562
+ %{\n <dc:creator opf:file-as="#{m}" opf:role="ill">#{x}</dc:creator>}
1563
+ else ''
1564
+ end
1565
+ date_published=if defined? @md.date.published \
1566
+ and @md.date.published =~/\S+/
1567
+ x=@md.date.published.dup
1568
+ x=SanitizeXML.xml(x)
1569
+ %{\n <dc:date opf:event="published">#{x}</dc:date>}
1570
+ else ''
1571
+ end
1572
+ subject=if defined? @md.classify.subject \
1573
+ and @md.classify.subject =~/\S+/
1574
+ x=@md.classify.subject.dup
1575
+ x=SanitizeXML.xml(x)
1576
+ %{\n <dc:subject>#{x}</dc:subject>}
1577
+ else ''
1578
+ end
1579
+ language=if defined? @md.opt.lng \
1580
+ and @md.opt.lng =~/\S+/
1581
+ language=@md.opt.lng.gsub(/<br>/,'<br />')
1582
+ %{\n <dc:language>#{language}</dc:language>}
1583
+ else ''
1584
+ end
1585
+ rights=if defined? @md.rights.all \
1586
+ and @md.rights.all =~/\S+/
1587
+ rights=SanitizeXML.xml(@md.rights.all)
1588
+ rights=rights.gsub(/<br\s*\/?>/,' ')
1589
+ %{\n <dc:rights>#{rights}</dc:rights>}
1590
+ else ''
1591
+ end
1592
+ f=SiSU_Env::FileOp.new(@md)
1593
+ dgst=(@md.dgst.is_a?(Array) and @md.dgst.length > 1) ? @md.dgst[1] : 'na'
1594
+ <<-WOK
1595
+ <#{$ep[:o]}metadata
1596
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1597
+ xmlns:opf="http://www.idpf.org/2007/opf"
1598
+ xmlns:dcterms="http://purl.org/dc/terms/"
1599
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
1600
+ unique-identifier="urn:uuid:#{dgst}" version="2.0">
1601
+ <dc:title>#{@md.title.full}</dc:title>
1602
+ #{cover_image}#{author}#{editor}#{translator}#{illustrator}#{language}#{date_published}#{subject}#{rights}
1603
+ <dc:identifier opf:scheme="URI">#{f.output_path.epub.url.gsub(/http:\/\//,'')}/#{f.base_filename.epub}</dc:identifier>
1604
+ <dc:identifier id="bookid">urn:uuid:#{dgst}</dc:identifier>
1605
+ <!-- <dc:identifier id="EPB-UUID">urn:uuid:#{dgst}</dc:identifier> -->
1606
+ </#{$ep[:o]}metadata>
1607
+ WOK
1608
+ end
1609
+ def manifest_open
1610
+ <<-WOK
1611
+ <manifest>
1612
+ <!-- NCX -->
1613
+ <item id="ncx" href="#{Ep[:f_ncx]}" media-type="application/x-dtbncx+xml" />
1614
+ <!-- CSS Style Sheets -->
1615
+ <item id="main-css" href="css/xhtml.css" media-type="text/css" />
1616
+ <!-- Content Documents -->
1617
+ WOK
1618
+ end
1619
+ def manifest_content_sisu_toc
1620
+ <<-WOK
1621
+ <item id="index#{Sfx[:epub_xhtml]}" href="index#{Sfx[:epub_xhtml]}" media-type="application/xhtml+xml" />
1622
+ WOK
1623
+ end
1624
+ def manifest_cover_image_information(md)
1625
+ if defined? md.make.cover_image \
1626
+ and @md.make.cover_image.is_a?(Hash) \
1627
+ and md.make.cover_image[:cover] =~/\S+/
1628
+ <<-WOK
1629
+ <item id="cover_image#{Sfx[:epub_xhtml]}" href="cover_image#{Sfx[:epub_xhtml]}" media-type="application/xhtml+xml" />
1630
+ WOK
1631
+ else ''
1632
+ end
1633
+ end
1634
+ def manifest_content(dob,fn_base,hashtag=nil)
1635
+ fn=fn_base + Sfx[:epub_xhtml]
1636
+ name=hashtag ? fn + hashtag : fn
1637
+ <<-WOK
1638
+ <item id="#{name}" href="#{name}" media-type="application/xhtml+xml" />
1639
+ WOK
1640
+ end
1641
+ def manifest_images(imgs)
1642
+ imgs=imgs + ['arrow_next_red.png','arrow_prev_red.png','arrow_up_red.png','bullet_09.png']
1643
+ images=[" <!-- Images -->\n"]
1644
+ imgs.each do |i|
1645
+ image,type=/(\S+?)\.(png|jpg|gif)/.match(i)[1,2]
1646
+ type=type.sub(/jpg/,'jpeg')
1647
+ images<<<<-WOK
1648
+ <item id="#{image}" href="image/#{image}.#{type}" media-type="image/#{type}" />
1649
+ WOK
1650
+ end
1651
+ images=images.join('')
1652
+ images
1653
+ end
1654
+ def manifest_close
1655
+ <<-WOK
1656
+ </manifest>
1657
+ WOK
1658
+ end
1659
+ def spine_open
1660
+ #spine: reading order of XHTML files from manifest, idref attribute refers back to id in manifest (exclude images, CSS etc.).
1661
+ <<-WOK
1662
+ <spine toc="ncx">
1663
+ WOK
1664
+ end
1665
+ def spine_cover_image
1666
+ <<-WOK
1667
+ <itemref idref="cover_image#{Sfx[:epub_xhtml]}" />
1668
+ WOK
1669
+ end
1670
+ def spine_sisu_toc
1671
+ <<-WOK
1672
+ <itemref idref="index#{Sfx[:epub_xhtml]}" linear="yes" />
1673
+ WOK
1674
+ end
1675
+ def spine(dob,fn_base,hashtag=nil)
1676
+ fn=fn_base + Sfx[:epub_xhtml]
1677
+ name=hashtag ? fn + hashtag : fn
1678
+ <<-WOK
1679
+ <itemref idref="#{name}" linear="yes" />
1680
+ WOK
1681
+ end
1682
+ def spine_close
1683
+ <<-WOK
1684
+ </spine>
1685
+ WOK
1686
+ end
1687
+ def guide_open
1688
+ #guide: presentation order of XHTML files by reader).
1689
+ <<-WOK
1690
+ <guide>
1691
+ WOK
1692
+ end
1693
+ def guide_cover_image
1694
+ <<-WOK
1695
+ <reference type="cover" title="Cover of #{SanitizeXML.xml(@md.title.full)}" href="cover_image#{Sfx[:epub_xhtml]}" />
1696
+ WOK
1697
+ end
1698
+ def guide_sisu_toc
1699
+ <<-WOK
1700
+ <reference type="index#{Sfx[:epub_xhtml]}" href="index#{Sfx[:epub_xhtml]}" />
1701
+ WOK
1702
+ end
1703
+ def guide(dob,fn_base,hashtag=nil)
1704
+ fn=fn_base + Sfx[:epub_xhtml]
1705
+ name=hashtag ? fn + hashtag : fn
1706
+ name=name ? name : dob.name
1707
+ guide_name=(name =~/#{Sfx[:epub_xhtml]}/) ? name : (name + Sfx[:epub_xhtml])
1708
+ <<-WOK
1709
+ <reference type="text" href="#{guide_name}" />
1710
+ WOK
1711
+ end
1712
+ def guide_close
1713
+ <<-WOK
1714
+ </guide>
1715
+ WOK
1716
+ end
1717
+ self
1718
+ end
1719
+ def table_close
1720
+ %{ </font>
1721
+ #{the_table_close}}
1722
+ end
1723
+ def xhtml_close
1724
+ %{#{SiSU_Proj_XHTML::Bits.new.credits_sisu_epub}
1725
+ </body>
1726
+ </html>}
1727
+ end
1728
+ end
1729
+ class HeadToc < HeadInformation
1730
+ include SiSU_Parts_XHTML
1731
+ def initialize(md)
1732
+ super(md)
1733
+ @md=md
1734
+ @tocband_segtoc=make_seg
1735
+ end
1736
+ def manifest_link(text)
1737
+ %{ <a href="#{@md.file.output_path.manifest.url}/#{@md.file.base_filename.manifest}" target="_top">#{text}</a>}
1738
+ end
1739
+ def concordance_link(text)
1740
+ if @md.concord_make
1741
+ %{<a href="#{@md.file.base_filename.html_concordance}" target="_top">
1742
+ #{text}
1743
+ </a>}
1744
+ else ''
1745
+ end
1746
+ end
1747
+ def head
1748
+ %{#{doc_type}
1749
+ <head>
1750
+ <meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
1751
+ #{@css.xhtml_epub}
1752
+ </head>
1753
+ <body lang="#{@md.opt.lng}">}
1754
+ end
1755
+ def concordance
1756
+ if @md.concord_make
1757
+ %{#{the_margin.css}
1758
+ <h4 class="toc">
1759
+ <a href="./#{@md.file.base_filename.html_concordance}">
1760
+ <i>Concordance</i>
1761
+ </a>
1762
+ </h4>
1763
+ #{the_table_close}}
1764
+ else
1765
+ %{#{the_margin.css}
1766
+ #{the_table_close}}
1767
+ end
1768
+ end
1769
+ def links_guide_open(type='horizontal')
1770
+ (type=='vertical') \
1771
+ ? links_guide_vertical_open
1772
+ : links_guide_horizontal_open
1773
+ end
1774
+ def prefix_a
1775
+ end
1776
+ def rights
1777
+ def all
1778
+ rights=SanitizeXML.xml(@md.rights.all)
1779
+ %{<p class="small_left">Rights: #{rights}</p>}
1780
+ end
1781
+ self
1782
+ end
1783
+ def prefix_b
1784
+ %{<p class="small_left">Prefix: #{@md.prefix_b}}
1785
+ end
1786
+ def make_seg
1787
+ concord=concordance_link(the_nav.txt_concordance)
1788
+ %{<table summary="toc segment" border="0" cellpadding="3" cellspacing="0">
1789
+ <tr><td align="center" bgcolor="white">
1790
+ #{the_nav.txt_toc_link}
1791
+ </td>
1792
+ <td align="center" bgcolor="white">
1793
+ <font size=2>
1794
+ #{concord}
1795
+ #{the_table_close}}
1796
+ end
1797
+ def manifest #check structure
1798
+ manifest=manifest_link(the_nav.txt_manifest)
1799
+ %{#{the_margin.txt_3}
1800
+ #{the_font.paragraph_font_small}
1801
+ #{manifest}
1802
+ </font>
1803
+ #{the_table_close}}
1804
+ end
1805
+ def concordance #check structure
1806
+ concord=concordance_link(the_nav.txt_concordance)
1807
+ %{#{the_margin.txt_3}
1808
+ #{the_font.paragraph_font_small}
1809
+ #{concord}
1810
+ </font>
1811
+ #{the_table_close}}
1812
+ end
1813
+ def metadata
1814
+ %{#{the_margin.css}
1815
+ <h4 class="toc">
1816
+ <a href="#{@metalink}">
1817
+ <i>MetaData</i>
1818
+ </a>
1819
+ </h4>
1820
+ #{the_table_close}}
1821
+ end
1822
+ end
1823
+ class HeadSeg < HeadInformation
1824
+ def initialize(md)
1825
+ super(md)
1826
+ end
1827
+ def head
1828
+ %{#{doc_type}
1829
+ <head>
1830
+ <title>
1831
+ #{@per.seg_name_x[@per.seg_name_x_tracker]} -
1832
+ #{@md.html_title}
1833
+ </title>
1834
+ <meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
1835
+ #{@css.xhtml_epub}
1836
+ </head>
1837
+ <body lang="#{@md.opt.lng}">}
1838
+ end
1839
+ def endnote_mark
1840
+ %{
1841
+ <hr class="endnote" />
1842
+ }
1843
+ end
1844
+ end
1845
+ class HeadScroll < HeadToc
1846
+ def initialize(md)
1847
+ super(md)
1848
+ end
1849
+ def toc_owner_details
1850
+ %{#{the_margin.txt_3}
1851
+ #{the_font.paragraph_font_small}
1852
+ <a href="#owner.details">
1853
+ Owner Details
1854
+ <font size="1" color="#777777">
1855
+ #{$ep[:hsp]*3}
1856
+ </font>
1857
+ </a>
1858
+ </font>
1859
+ #{the_table_close}}
1860
+ end
1861
+ end
1862
+ class FormatTextObject
1863
+ include SiSU_Parts_XHTML
1864
+ attr_accessor :md,:t_o,:txt,:ocn,:format,:table,:link,:linkname,:paranum,:p_num,:headname,:banner,:url
1865
+ def initialize(md,t_o)
1866
+ @md,@t_o=md,t_o
1867
+ if t_o.is_a?(Hash)
1868
+ @txt =t_o[:txt] || nil
1869
+ @ocn =t_o[:ocn] || nil
1870
+ @ocn_display =t_o[:ocn_display] || nil
1871
+ @headname =t_o[:headname] || nil
1872
+ @trailer =t_o[:trailer] || nil
1873
+ @endnote_part_a =t_o[:endnote_part_a] || nil
1874
+ @endnote_part_b =t_o[:endnote_part_b] || nil
1875
+ @lnk_url =t_o[:lnk_url] || nil
1876
+ @lnk_txt =t_o[:lnk_txt] || nil
1877
+ @format =t_o[:format] || nil
1878
+ @target =t_o[:target] || nil #occasionally passed but not used
1879
+ if @format and not @format.empty?
1880
+ if @format=~/^\d:(\S+)/ #need more reliable marker #if @format =~ /#{Rx[:lv]}/
1881
+ headname=$1 #format[/\d~(\S+)/m,1]
1882
+ @headname=(headname =~/^[a-zA-Z]/) \
1883
+ ? %{<id="#{headname}">}
1884
+ : %{<id="h#{headname}"></a>}
1885
+ @headname=(headname =~/^[a-zA-Z]/) \
1886
+ ? %{<a name="#{headname}" id="#{headname}"></a>}
1887
+ : %{<a name="h#{headname}" id="h#{headname}"></a>}
1888
+ end
1889
+ end
1890
+ elsif t_o.class.inspect =~/Object/
1891
+ @dob=t_o if defined? t_o.is
1892
+ @named=nametags_seg(@dob)
1893
+ @txt=((defined? t_o.obj) ? t_o.obj : nil)
1894
+ @ocn=((defined? t_o.ocn) ? t_o.ocn.to_s : nil)
1895
+ @headname=((t_o.is==:heading and defined? t_o.name) ? t_o.name : nil)
1896
+ else
1897
+ if @md.opt.act[:maintenance][:set]==:on
1898
+ p __FILE__ << ':' << __LINE__.to_s
1899
+ p t_o.class
1900
+ p caller
1901
+ end
1902
+ end
1903
+ if @txt and not @txt.empty?
1904
+ @txt=@txt.gsub(/#{Mx[:mk_o]}[-~]##{Mx[:mk_c]}/,'')
1905
+ end
1906
+ @p_num=ParagraphNumber.new(@md,@ocn)
1907
+ end
1908
+ def nametags_seg(dob) #FIX
1909
+ tags=''
1910
+ if defined? dob.tags \
1911
+ and dob.tags.length > 0 # insert tags "hypertargets"
1912
+ dob.tags.each do |t|
1913
+ tags=tags << %{<a name="#{t}" />}
1914
+ end
1915
+ end
1916
+ tags
1917
+ end
1918
+ def endnote_body
1919
+ %{
1920
+ <p class="endnote">
1921
+ #{@txt}
1922
+ </p>
1923
+ }
1924
+ end
1925
+ def endnote_body_indent
1926
+ %{
1927
+ <p class="endnote_indent">
1928
+ #{@txt}
1929
+ </p>
1930
+ }
1931
+ end
1932
+ def no_paranum
1933
+ %{
1934
+ <div class="substance">
1935
+ <label class="ocn">#{$ep[:hsp]}</label>
1936
+ <p class="norm">
1937
+ #{@txt}
1938
+ </p>
1939
+ </div>
1940
+ }
1941
+ end
1942
+ def para_form_css(tag,attrib,txt) # regular paragraphs shaped here
1943
+ ul=ulc=''
1944
+ ul,ulc="<ul>\n ","\n </ul>" if @tag =~/li/
1945
+ %{
1946
+ <div class="substance">
1947
+ #{@p_num.ocn_display}
1948
+ #{ul}<#{tag} class="#{attrib}" #{@p_num.id}>
1949
+ #{@named}#{txt}
1950
+ </#{tag}>#{ulc}
1951
+ </div>
1952
+ }
1953
+ end
1954
+ def para
1955
+ para_form_css('p','norm',@txt)
1956
+ end
1957
+ def group
1958
+ para_form_css('p','group',@txt)
1959
+ end
1960
+ def block
1961
+ para_form_css('p','block',@txt)
1962
+ end
1963
+ def alt
1964
+ para_form_css('p','alt',@txt)
1965
+ end
1966
+ def verse
1967
+ para_form_css('p','verse',@txt)
1968
+ end
1969
+ def code
1970
+ para_form_css('p','code',@txt)
1971
+ end
1972
+ def center
1973
+ para_form_css('p','center',@txt)
1974
+ end
1975
+ def bold
1976
+ para_form_css('p','bold',@txt)
1977
+ end
1978
+ def bullet
1979
+ para_form_css('li','bullet',@txt)
1980
+ end
1981
+ def table
1982
+ @txt=if @t_o.obj !~/^<table\s/
1983
+ table=SiSU_XHTML_Shared::TableXHTML.new(@t_o) #move, make happen earlier
1984
+ table.table.obj
1985
+ else @txt
1986
+ end
1987
+ para_form_css('p','norm',@txt)
1988
+ end
1989
+ def break
1990
+ @txt=@txt.gsub(/#{Mx[:br_page_new]}|#{Mx[:br_page]}|#{Mx[:br_page_line]}/,'<hr /><br />').
1991
+ gsub(/#{Mx[:br_obj]}/,'<hr style="width:30%" /><br />')
1992
+ para_form_css('p','norm',@txt)
1993
+ end
1994
+ def format(tag,attrib)
1995
+ para_form_css(tag,attrib,@txt)
1996
+ end
1997
+ def title_heading(tag,attrib)
1998
+ %{
1999
+ <div class="content">
2000
+ <#{tag} class="#{attrib}">
2001
+ #{@named}#{@txt}
2002
+ </#{tag}>
2003
+ </div>
2004
+ }
2005
+ end
2006
+ def title_heading0
2007
+ DISABLE[:epub][:per_section_title] \
2008
+ ? ''
2009
+ : title_heading('h1','tiny')
2010
+ end
2011
+ def title_heading1
2012
+ DISABLE[:epub][:per_section_title] \
2013
+ ? ''
2014
+ : title_heading('h1','tiny')
2015
+ end
2016
+ def title_heading2
2017
+ DISABLE[:epub][:per_section_title] \
2018
+ ? ''
2019
+ : title_heading('h2','tiny')
2020
+ end
2021
+ def title_heading3
2022
+ DISABLE[:epub][:per_section_title] \
2023
+ ? ''
2024
+ : title_heading('h3','tiny')
2025
+ end
2026
+ def title_heading4
2027
+ ''
2028
+ end
2029
+ def seg_heading_sub(tag,attrib,txt)
2030
+ txt=txt.gsub(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ')
2031
+ %{
2032
+ <div class="substance">
2033
+ #{@p_num.ocn_display}
2034
+ <#{tag} class="#{attrib}" #{@p_num.id}>#{@p_num.name}
2035
+ #{@named}#{@txt}
2036
+ </#{tag}>
2037
+ </div>
2038
+ }
2039
+ end
2040
+ def seg_heading4
2041
+ %{
2042
+ <div class="substance">
2043
+ #{@p_num.ocn_display}
2044
+ <h1 class="norm" #{@p_num.id}>
2045
+ #{@txt}
2046
+ </h1>
2047
+ </div>
2048
+ }
2049
+ end
2050
+ def seg_heading5
2051
+ seg_heading_sub('p','bold',@txt)
2052
+ end
2053
+ def seg_heading6
2054
+ seg_heading_sub('p','bold',@txt)
2055
+ end
2056
+ def seg_heading7
2057
+ seg_heading_sub('p','bold',@txt)
2058
+ end
2059
+ def dl #check :trailer
2060
+ "<dl><b>#{@txt}</b> #{@trailer}</dl>"
2061
+ end
2062
+ def table_css_end
2063
+ '</table>
2064
+ </p>
2065
+ </div>'
2066
+ end
2067
+ def gsub_body #unused
2068
+ @txt=case @txt
2069
+ when /^(?:#{Mx[:pa_o]}i[1-9]#{Mx[:pa_c]}\s*)?\((i+|iv|v|vi+|ix|x|xi+)\)/
2070
+ @txt.gsub(/^\((i+|iv|v|vi+|ix|x|xi+)\)/,'<b>(\1)</b>').
2071
+ gsub(/^(#{Mx[:pa_o]}i[1-9]#{Mx[:pa_c]})\s*\((i+|iv|v|vi+|ix|x|xi+)\)/,'\1<b>(\2)</b>')
2072
+ when /^(?:#{Mx[:pa_o]}i[1-9]#{Mx[:pa_c]}\s*)?\(?(\d|[a-z])+\)/
2073
+ @txt.gsub(/^\((\d+|[a-z])+\)/,'<b>(\1)</b>').
2074
+ gsub(/^(#{Mx[:pa_o]}i[1-9]#{Mx[:pa_c]})\s*\((\d+|[a-z])+\)/,'\1<b>(\2)</b>')
2075
+ when /^\s*\d{1,3}\.\s/
2076
+ @txt.gsub(/^\s*(\d+\.)/,'<b>\1</b>')
2077
+ when /^\s*[A-Z]\.\s/
2078
+ @txt.gsub(/^\s*([A-Z]\.)/,'<b>\1</b>')
2079
+ else @txt
2080
+ end
2081
+ end
2082
+ def bold_para
2083
+ %{#{the_margin.txt_0}
2084
+ <p class="bold">
2085
+ #{@txt}
2086
+ </p>
2087
+ #{the_margin.num_css}
2088
+ #{$ep[:hsp]*3}
2089
+ #{the_table_close}}
2090
+ end
2091
+ def bold_heading #unused
2092
+ @txt=@txt.gsub(/[1-9]~\S+/,'').
2093
+ gsub(/[1-9]~/,'')
2094
+ %{<p class="bold">
2095
+ #{@txt}
2096
+ </p>
2097
+ #{the_margin.num_css}
2098
+ #{$ep[:hsp]*3}
2099
+ #{the_table_close}}
2100
+ end
2101
+ def toc_head_copy_at
2102
+ @txt=SanitizeXML.xml(@txt)
2103
+ %{<p class="center">#{@txt}</p>\n}
2104
+ end
2105
+ def center
2106
+ @txt=SanitizeXML.xml(@txt)
2107
+ %{<p class="center">#{@txt}</p>\n}
2108
+ end
2109
+ def bold
2110
+ @txt=SanitizeXML.xml(@txt)
2111
+ %{<p class="bold">#{@txt}</p>\n}
2112
+ end
2113
+ def center_bold
2114
+ @txt=SanitizeXML.xml(@txt)
2115
+ %{<p class="centerbold">#{@txt}</p>\n}
2116
+ end
2117
+ end
2118
+ class FormatScroll < FormatTextObject
2119
+ def initialize(md,txt)
2120
+ super(md,txt)
2121
+ end
2122
+ end
2123
+ class FormatSeg < FormatTextObject
2124
+ def initialize(md,txt)
2125
+ super(md,txt)
2126
+ end
2127
+ def endnote_seg_body(fn='') #FIX #url construction keep within single line... BUG WATCH 200408
2128
+ fn='doc' if fn.to_s.empty? #you may wish to reconsider, sends to 'doc' where no segment info
2129
+ %{
2130
+ <p class="endnote">
2131
+ #{@endnote_part_a}#{fn}#{Sfx[:epub_xhtml]}#{@endnote_part_b}
2132
+ </p>
2133
+ }
2134
+ end
2135
+ def clean(txt)
2136
+ txt=txt.gsub(/#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}/,'').
2137
+ gsub(/#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]}/,'')
2138
+ end
2139
+ def subtoc_lev(tag,attrib)
2140
+ @txt=clean(@txt)
2141
+ txt=if @txt \
2142
+ and @txt =~/<\/?i>|<a\s+name="\S+?">/mi
2143
+ @txt.gsub(/<\/?i>|<a\s+name="\S+?">/mi,'') #removes name markers from subtoc, go directly to substantive text
2144
+ else @txt
2145
+ end
2146
+ note=''
2147
+ if txt =~/(#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})/m # had \s* at end
2148
+ note=$1
2149
+ note=note.gsub(/[\s]+/m,' ')
2150
+ txt=txt.gsub(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ').
2151
+ gsub(/<a[\n\s]+"[\n\s]+href="##{Mx[:note_ref]}\d+">#{$ep[:hsp]}<sup id="#{Mx[:note]}\d+">\d+<\/sup>#{$ep[:hsp]}/m,'').
2152
+ gsub(/<a[\n\s]+"[\n\s]+href="##{Mx[:note_ref]}\d+">#{$ep[:hsp]}<sup id="#{Mx[:note]}\d+">\d+<\/sup>#{$ep[:hsp]}/m,'') #remove
2153
+ end
2154
+ %{<#{tag} class="#{attrib}">
2155
+ <a href="#o#{@ocn}"><i>#{txt}</i></a> #{note}
2156
+ </#{tag}>}
2157
+ end
2158
+ def subtoc_lev5
2159
+ subtoc_lev('h5','subtoc') if @txt
2160
+ end
2161
+ def subtoc_lev6
2162
+ subtoc_lev('h6','subtoc') if @txt
2163
+ end
2164
+ def subtoc_lev7
2165
+ subtoc_lev('h7','subtoc') if @txt
2166
+ end
2167
+ def heading_sub(tag,attrib,txt)
2168
+ txt=txt.gsub(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ')
2169
+ %{
2170
+ <div class="substance">
2171
+ #{@p_num.ocn_display}
2172
+ <#{tag} class="#{attrib}" #{@p_num.id}> #{@headname}
2173
+ #{@txt}
2174
+ </#{tag}>
2175
+ </div>
2176
+ }
2177
+ end
2178
+ def heading4
2179
+ %{
2180
+ <div class="substance">
2181
+ #{@p_num.ocn_display}
2182
+ <h1 class="norm" #{@p_num.id}>
2183
+ #{@t_o[:format]}
2184
+ #{@txt}
2185
+ </h1>
2186
+ </div>
2187
+ }
2188
+ end
2189
+ def heading5
2190
+ heading_sub('p','bold',@txt)
2191
+ end
2192
+ def heading6
2193
+ heading_sub('p','bold',@txt)
2194
+ end
2195
+ def heading7
2196
+ heading_sub('h7','bold',@txt)
2197
+ end
2198
+ def navigation_heading4
2199
+ %{<table summary="navigation segment heading 4" width=100% bgcolor="#08163f" border="0">
2200
+ <tr><td align="center">
2201
+ <p class="bold">
2202
+ #{@txt}
2203
+ </p>
2204
+ #{the_table_close}}
2205
+ end
2206
+ def navigation_heading5
2207
+ %{<p class="bold">
2208
+ #{@txt}
2209
+ </p>}
2210
+ end
2211
+ def navigation_heading6
2212
+ %{<p class="bold">
2213
+ #{@txt}
2214
+ </p>}
2215
+ end
2216
+ def navigation_heading7
2217
+ %{<p class="bold">
2218
+ #{@txt}
2219
+ </p>}
2220
+ end
2221
+ def navigation_center
2222
+ %{<p class="centerbold">#{@txt}</p>}
2223
+ end
2224
+ end
2225
+ class FormatToc < FormatTextObject
2226
+ def initialize(md,txt)
2227
+ super(md,txt)
2228
+ end
2229
+ def links_guide
2230
+ %{ <li class="doc">
2231
+ <a href="#{@lnk_url}" target="_top">
2232
+ #{@lnk_txt}
2233
+ </a>
2234
+ </li>
2235
+ }
2236
+ end
2237
+ def lev(tag,attrib)
2238
+ if @txt
2239
+ %{<#{tag} class="#{attrib}">
2240
+ #{@txt}
2241
+ </#{tag}>
2242
+ }
2243
+ else ''
2244
+ end
2245
+ end
2246
+ def lev1
2247
+ lev('h1','toc')
2248
+ end
2249
+ def lev2
2250
+ lev('h2','toc')
2251
+ end
2252
+ def lev3
2253
+ lev('h3','toc')
2254
+ end
2255
+ def lev4
2256
+ lev('h4','toc')
2257
+ end
2258
+ def lev5
2259
+ lev('h5','toc')
2260
+ end
2261
+ def lev6
2262
+ lev('h6','toc')
2263
+ end
2264
+ def lev7
2265
+ lev('h7','toc')
2266
+ end
2267
+ def lev0 #docinfo
2268
+ lev('h0','toc')
2269
+ end
2270
+ end
2271
+ end
2272
+ __END__