sisu 7.0.0

Sign up to get free protection for your applications and to get access to all the features.
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,186 @@
1
+ # encoding: utf-8
2
+ =begin
3
+
4
+ * Name: SiSU
5
+
6
+ ** Description: documents, structuring, processing, publishing, search
7
+ *** plaintext decoration
8
+
9
+ ** Author: Ralph Amissah
10
+ <ralph@amissah.com>
11
+ <ralph.amissah@gmail.com>
12
+
13
+ ** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
14
+ 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah,
15
+ All Rights Reserved.
16
+
17
+ ** License: GPL 3 or later:
18
+
19
+ SiSU, a framework for document structuring, publishing and search
20
+
21
+ Copyright (C) Ralph Amissah
22
+
23
+ This program is free software: you can redistribute it and/or modify it
24
+ under the terms of the GNU General Public License as published by the Free
25
+ Software Foundation, either version 3 of the License, or (at your option)
26
+ any later version.
27
+
28
+ This program is distributed in the hope that it will be useful, but WITHOUT
29
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
30
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
31
+ more details.
32
+
33
+ You should have received a copy of the GNU General Public License along with
34
+ this program. If not, see <http://www.gnu.org/licenses/>.
35
+
36
+ If you have Internet connection, the latest version of the GPL should be
37
+ available at these locations:
38
+ <http://www.fsf.org/licensing/licenses/gpl.html>
39
+ <http://www.gnu.org/licenses/gpl.html>
40
+
41
+ <http://www.sisudoc.org/sisu/en/manifest/gpl.fsf.html>
42
+
43
+ ** SiSU uses:
44
+ * Standard SiSU markup syntax,
45
+ * Standard SiSU meta-markup syntax, and the
46
+ * Standard SiSU object citation numbering and system
47
+
48
+ ** Hompages:
49
+ <http://www.jus.uio.no/sisu>
50
+ <http://www.sisudoc.org>
51
+
52
+ ** Git
53
+ <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=summary>
54
+ <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=blob;f=lib/sisu/txt_rst_decorate.rb;hb=HEAD>
55
+
56
+ =end
57
+
58
+ module SiSU_Decorate_Txt_rST
59
+ def decorate
60
+ def heading
61
+ def underscore
62
+ def l0
63
+ '='
64
+ end
65
+ def l1
66
+ '-'
67
+ end
68
+ def l2
69
+ '`'
70
+ end
71
+ def l3
72
+ ':'
73
+ end
74
+ def l4
75
+ "'"
76
+ end
77
+ def l5
78
+ '"'
79
+ end
80
+ self
81
+ end
82
+ self
83
+ end
84
+ def bold
85
+ def open
86
+ '*'
87
+ end
88
+ def close
89
+ '*'
90
+ end
91
+ self
92
+ end
93
+ def italics
94
+ def open
95
+ '/'
96
+ end
97
+ def close
98
+ '/'
99
+ end
100
+ self
101
+ end
102
+ def underscore
103
+ def open
104
+ '_'
105
+ end
106
+ def close
107
+ '_'
108
+ end
109
+ self
110
+ end
111
+ #def emphasis
112
+ # def open
113
+ # ''
114
+ # end
115
+ # def close
116
+ # ''
117
+ # end
118
+ # self
119
+ #end
120
+ def cite
121
+ def open
122
+ '"'
123
+ end
124
+ def close
125
+ '"'
126
+ end
127
+ self
128
+ end
129
+ def insert
130
+ def open
131
+ '+'
132
+ end
133
+ def close
134
+ '+'
135
+ end
136
+ self
137
+ end
138
+ def strike
139
+ def open
140
+ '-'
141
+ end
142
+ def close
143
+ '-'
144
+ end
145
+ self
146
+ end
147
+ def superscript
148
+ def open
149
+ '^'
150
+ end
151
+ def close
152
+ '^'
153
+ end
154
+ self
155
+ end
156
+ def subscript
157
+ def open
158
+ '['
159
+ end
160
+ def close
161
+ ']'
162
+ end
163
+ self
164
+ end
165
+ def hilite
166
+ def open
167
+ '*'
168
+ end
169
+ def close
170
+ '*'
171
+ end
172
+ self
173
+ end
174
+ def monospace
175
+ def open
176
+ '#'
177
+ end
178
+ def close
179
+ '#'
180
+ end
181
+ self
182
+ end
183
+ self
184
+ end
185
+ end
186
+ __END__
@@ -0,0 +1,241 @@
1
+ # encoding: utf-8
2
+ =begin
3
+
4
+ * Name: SiSU
5
+
6
+ ** Description: documents, structuring, processing, publishing, search
7
+ *** modules shared by flatfile output generators
8
+
9
+ ** Author: Ralph Amissah
10
+ <ralph@amissah.com>
11
+ <ralph.amissah@gmail.com>
12
+
13
+ ** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
14
+ 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah,
15
+ All Rights Reserved.
16
+
17
+ ** License: GPL 3 or later:
18
+
19
+ SiSU, a framework for document structuring, publishing and search
20
+
21
+ Copyright (C) Ralph Amissah
22
+
23
+ This program is free software: you can redistribute it and/or modify it
24
+ under the terms of the GNU General Public License as published by the Free
25
+ Software Foundation, either version 3 of the License, or (at your option)
26
+ any later version.
27
+
28
+ This program is distributed in the hope that it will be useful, but WITHOUT
29
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
30
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
31
+ more details.
32
+
33
+ You should have received a copy of the GNU General Public License along with
34
+ this program. If not, see <http://www.gnu.org/licenses/>.
35
+
36
+ If you have Internet connection, the latest version of the GPL should be
37
+ available at these locations:
38
+ <http://www.fsf.org/licensing/licenses/gpl.html>
39
+ <http://www.gnu.org/licenses/gpl.html>
40
+
41
+ <http://www.sisudoc.org/sisu/en/manifest/gpl.fsf.html>
42
+
43
+ ** SiSU uses:
44
+ * Standard SiSU markup syntax,
45
+ * Standard SiSU meta-markup syntax, and the
46
+ * Standard SiSU object citation numbering and system
47
+
48
+ ** Hompages:
49
+ <http://www.jus.uio.no/sisu>
50
+ <http://www.sisudoc.org>
51
+
52
+ ** Git
53
+ <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=summary>
54
+ <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=blob;f=lib/sisu/txt_shared.rb;hb=HEAD>
55
+
56
+ =end
57
+ module SiSU_TextUtils
58
+ require_relative 'generic_parts' # generic_parts.rb
59
+ class Wrap
60
+ def initialize(para='',n_char_max=76,n_indent=0,n_hang=nil,post='')
61
+ @para,@n_char_max,@n_indent,@post,=para,n_char_max,n_indent,post
62
+ @n_char_max_extend = n_char_max
63
+ @n_hang=n_hang ? n_hang : @n_indent
64
+ end
65
+ def break_line
66
+ "\n"
67
+ end
68
+ def line_wrap
69
+ space=' '
70
+ spaces_indent,spaces_hang="#{break_line}#{space*@n_indent}",space*@n_hang
71
+ line=0
72
+ out=[]
73
+ out[line]=''
74
+ @para=@para.gsub(/<br>/,' \\ ').
75
+ gsub(/#{Mx[:br_nl]}/,"\n\n")
76
+ words=@para.scan(/\n\n|\s+\\\s+|<br>|\S+/m)
77
+ while words != ''
78
+ word=words.shift
79
+ if not word
80
+ out[line] unless out[line].empty? #check
81
+ break
82
+ elsif word =~/<br>/
83
+ word=nil
84
+ out[line]=out[line].gsub(/<br>/,'')
85
+ line=line
86
+ elsif word =~/\n\n/
87
+ word="\n"
88
+ @n_char_max_extend = @n_char_max
89
+ line += 1
90
+ elsif (out[line].length + word.length) > (@n_char_max_extend - @n_indent) \
91
+ and out[line] =~/\S+/
92
+ @n_char_max_extend = @n_char_max
93
+ out[line].squeeze!(' ')
94
+ line += 1
95
+ end
96
+ if word
97
+ out[line]=if out[line] \
98
+ and out[line] !~/\S+$/m
99
+ "#{out[line]}#{word}"
100
+ elsif out[line] \
101
+ and out[line] =~/\S+/
102
+ "#{out[line]} #{word}"
103
+ else "#{word.strip}"
104
+ end
105
+ end
106
+ @oldword=word if word =~/\S+/
107
+ end
108
+ post=(@post.empty?) \
109
+ ? ''
110
+ : "\n" + (' '*@n_indent) +@post
111
+ spaces_hang + out.join(spaces_indent) + post
112
+ end
113
+ def line_wrap_indent1
114
+ @n_indent,@n_hang=2,2
115
+ line_wrap
116
+ end
117
+ def line_wrap_endnote
118
+ @n_indent,@n_hang=4,2
119
+ line_wrap
120
+ end
121
+ def array_wrap
122
+ if @para.is_a?(Array)
123
+ @arr=[]
124
+ @para.each do |line|
125
+ @arr << SiSU_TextUtils::Wrap.new(line,@n_char_max,@n_indent,@n_hang).line_wrap
126
+ end
127
+ end
128
+ @arr
129
+ end
130
+ def no_wrap
131
+ @para
132
+ end
133
+ def no_wrap_no_breaks
134
+ @para.gsub(/\n/m,' ').gsub(/\s\s+/,' ')
135
+ end
136
+ end
137
+ class HeaderScan
138
+ def initialize(md,para)
139
+ @md,@p=md,para
140
+ end
141
+ def extract(tag,tag_content,type,attrib)
142
+ if dc_tag \
143
+ and dc_content
144
+ [dc_tag,dc_content,{dc_tag=>dc_content}]
145
+ else nil
146
+ end
147
+ end
148
+ def header(tag,tag_content,type='',attrib='') #this will break stuff and must be tested thoroughly 20060825
149
+ @tag,@tag_content,@type,@attrib=tag,tag_content,type,attrib
150
+ def label #element
151
+ @tag
152
+ end
153
+ def type
154
+ @type
155
+ end
156
+ def text
157
+ @tag_content
158
+ end
159
+ def info #element text
160
+ @tag_content
161
+ end
162
+ def attribute
163
+ @attrib
164
+ end
165
+ def element
166
+ @tag
167
+ end
168
+ def attrib
169
+ @attrib
170
+ end
171
+ def el
172
+ @tag
173
+ end
174
+ self
175
+ end
176
+ def start_is_match
177
+ case @p
178
+ when /^#{Mx[:meta_o]}(title)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,@md.title.full,'meta','dc') #dc 1
179
+ when /^#{Mx[:meta_o]}(creator|author)#{Mx[:meta_c]}\s*(.+?)$/ then header('creator',$2,'meta','dc') #dc 2
180
+ when /^#{Mx[:meta_o]}(subject)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','dc') #dc 3
181
+ when /^#{Mx[:meta_o]}(description)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','dc') #dc 4
182
+ when /^#{Mx[:meta_o]}(publisher)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','dc') #dc 5
183
+ when /^#{Mx[:meta_o]}(contributor)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','dc') #dc 6
184
+ when /^#{Mx[:meta_o]}(date)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','dc') #dc 7
185
+ when /^#{Mx[:meta_o]}(date\.created)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','extra')
186
+ when /^#{Mx[:meta_o]}(date\.issued)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','extra')
187
+ when /^#{Mx[:meta_o]}(date\.available)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','extra')
188
+ when /^#{Mx[:meta_o]}(date\.valid)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','extra')
189
+ when /^#{Mx[:meta_o]}(date\.modified)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','extra')
190
+ when /^#{Mx[:meta_o]}(type)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','dc') #dc 8
191
+ when /^#{Mx[:meta_o]}(format)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','dc') #dc 9
192
+ when /^#{Mx[:meta_o]}(identifier)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','dc') #dc 10
193
+ when /^#{Mx[:meta_o]}(source)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','dc') #dc 11
194
+ when /^#{Mx[:meta_o]}(language)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','dc') #dc 12
195
+ when /^#{Mx[:meta_o]}(relation)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','dc') #dc 13
196
+ when /^#{Mx[:meta_o]}(coverage)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','dc') #dc 14
197
+ when /^#{Mx[:meta_o]}(rights)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','dc') #dc 15
198
+ when /^#{Mx[:meta_o]}(keywords)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','extra')
199
+ when /^#{Mx[:meta_o]}(copyright)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','extra')
200
+ when /^#{Mx[:meta_o]}(translator|translated_by)#{Mx[:meta_c]}\s*(.+?)$/ then header('translator',$2)
201
+ when /^#{Mx[:meta_o]}(illustrator|illustrated_by)#{Mx[:meta_c]}\s*(.+?)$/ then header('illustrator',$2)
202
+ when /^#{Mx[:meta_o]}(prepared_by)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','extra')
203
+ when /^#{Mx[:meta_o]}(digitized_by)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','extra')
204
+ when /^#{Mx[:meta_o]}(comments?)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','extra')
205
+ when /^#{Mx[:meta_o]}(abstract)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','extra')
206
+ when /^#{Mx[:meta_o]}(tags?)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','extra')
207
+ when /^#{Mx[:meta_o]}(catalogue)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'meta','extra')
208
+ when /^#{Mx[:meta_o]}(class(?:ify)?_loc)#{Mx[:meta_c]}\s*(.+?)$/ then header('classify_loc',$2,'meta','extra')
209
+ when /^#{Mx[:meta_o]}(class(?:ify)?_dewey)#{Mx[:meta_c]}\s*(.+?)$/ then header('classify_dewey',$2,'meta','extra')
210
+ when /^#{Mx[:meta_o]}(class(?:ify)?_pg)#{Mx[:meta_c]}\s*(.+?)$/ then header('classify_pg',$2,'meta','extra')
211
+ when /^#{Mx[:meta_o]}(class(?:ify)?_isbn)#{Mx[:meta_c]}\s*(.+?)$/ then header('classify_isbn',$2,'meta','extra')
212
+ when /^#{Mx[:meta_o]}(toc|structure)#{Mx[:meta_c]}\s*(.+?)$/ then header('structure',$2,'process','instruct')
213
+ when /^#{Mx[:meta_o]}(level|page|markup)#{Mx[:meta_c]}\s*(.+?)$/ then header('markup',$2,'process','instruct')
214
+ when /^#{Mx[:meta_o]}(bold)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'process','instruct')
215
+ when /^#{Mx[:meta_o]}(italics|itali[sz]e)#{Mx[:meta_c]}\s*(.+?)$/ then header('italicize',$2,'process','instruct')
216
+ when /^#{Mx[:meta_o]}(vocabulary|wordlist)#{Mx[:meta_c]}\s*(.+?)$/ then header('vocabulary',$2,'process','instruct')
217
+ when /^#{Mx[:meta_o]}(css|stylesheet)#{Mx[:meta_c]}\s*(.+?)$/ then header('css',$2,'process','instruct')
218
+ when /^#{Mx[:meta_o]}(links)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'process','instruct')
219
+ when /^#{Mx[:meta_o]}(prefix)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'process','instruct') #add a & b
220
+ when /^#{Mx[:meta_o]}(suffix)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'process','instruct')
221
+ when /^#{Mx[:meta_o]}(information)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'process','instruct')
222
+ when /^#{Mx[:meta_o]}(contact)#{Mx[:meta_c]}\s*(.+?)$/ then header($1,$2,'process','instruct')
223
+ when /^#{Mx[:meta_o]}(rcs|cvs)#{Mx[:meta_c]}\s*(.+?)$/ then header('version',$2,'process','instruct')
224
+ else nil
225
+ end
226
+ end
227
+ def dublin
228
+ if @p =~/^#{Mx[:meta_o]}\S+?#{Mx[:meta_c]}/
229
+ start_is_match
230
+ else nil
231
+ end
232
+ end
233
+ def meta
234
+ if @p =~/^#{Mx[:meta_o]}\S+?#{Mx[:meta_c]}/
235
+ start_is_match
236
+ else nil
237
+ end
238
+ end
239
+ end
240
+ end
241
+ __END__
@@ -0,0 +1,367 @@
1
+ # encoding: utf-8
2
+ =begin
3
+
4
+ * Name: SiSU
5
+
6
+ ** Description: documents, structuring, processing, publishing, search
7
+ *** plaintext (smarttext) generation, textile
8
+
9
+ ** Author: Ralph Amissah
10
+ <ralph@amissah.com>
11
+ <ralph.amissah@gmail.com>
12
+
13
+ ** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
14
+ 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah,
15
+ All Rights Reserved.
16
+
17
+ ** License: GPL 3 or later:
18
+
19
+ SiSU, a framework for document structuring, publishing and search
20
+
21
+ Copyright (C) Ralph Amissah
22
+
23
+ This program is free software: you can redistribute it and/or modify it
24
+ under the terms of the GNU General Public License as published by the Free
25
+ Software Foundation, either version 3 of the License, or (at your option)
26
+ any later version.
27
+
28
+ This program is distributed in the hope that it will be useful, but WITHOUT
29
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
30
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
31
+ more details.
32
+
33
+ You should have received a copy of the GNU General Public License along with
34
+ this program. If not, see <http://www.gnu.org/licenses/>.
35
+
36
+ If you have Internet connection, the latest version of the GPL should be
37
+ available at these locations:
38
+ <http://www.fsf.org/licensing/licenses/gpl.html>
39
+ <http://www.gnu.org/licenses/gpl.html>
40
+
41
+ <http://www.sisudoc.org/sisu/en/manifest/gpl.fsf.html>
42
+
43
+ ** SiSU uses:
44
+ * Standard SiSU markup syntax,
45
+ * Standard SiSU meta-markup syntax, and the
46
+ * Standard SiSU object citation numbering and system
47
+
48
+ ** Hompages:
49
+ <http://www.jus.uio.no/sisu>
50
+ <http://www.sisudoc.org>
51
+
52
+ ** Git
53
+ <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=summary>
54
+ <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=blob;f=lib/sisu/txt_textile.rb;hb=HEAD>
55
+
56
+ =end
57
+ module SiSU_Txt_Textile
58
+ require_relative 'ao' # ao.rb
59
+ require_relative 'se' # se.rb
60
+ include SiSU_Env
61
+ require_relative 'shared_metadata' # shared_metadata.rb
62
+ require_relative 'generic_parts' # generic_parts.rb
63
+ require_relative 'txt_read' # txt_read.rb
64
+ require_relative 'txt_shared' # txt_shared.rb
65
+ require_relative 'txt_textile_decorate' # txt_textile_decorate.rb
66
+ require_relative 'txt_output' # txt_output.rb
67
+ include SiSU_Param
68
+ @@alt_id_count,@@alt_id_count=0,0
69
+ @@tablefoot=''
70
+ class Source
71
+ include SiSU_Txt_Read
72
+ #include SiSU_Parts_Generic
73
+ def initialize(opt)
74
+ @opt=opt
75
+ unless @opt.fns =~/(.+?)\.(?:-|ssm\.)?sst$/
76
+ puts "#{sf} not a processed file type"
77
+ end
78
+ end
79
+ def read
80
+ begin
81
+ md=SiSU_Param::Parameters.new(@opt).get
82
+ specific={
83
+ description: 'Textile (plaintext utf-8)',
84
+ output_path: md.file.output_path.textile.dir,
85
+ output_file: md.file.base_filename.textile,
86
+ }
87
+ read_generic(@opt,specific)
88
+ SiSU_Txt_Textile::Source::Scroll.new(md,@ao_array,@wrap_width).songsheet
89
+ rescue
90
+ SiSU_Errors::Rescued.new($!,$@,@opt.selections.str,@opt.fns).location do
91
+ __LINE__.to_s + ':' + __FILE__
92
+ end
93
+ ensure
94
+ end
95
+ end
96
+ private
97
+ class Scroll <Source
98
+ include SiSU_Parts_Generic
99
+ include SiSU_TextUtils
100
+ include SiSU_Decorate_Txt_Textile
101
+ @@endnotes={ para: [], end: [] }
102
+ def initialize(md,data,wrap_width)
103
+ @md,@data,@wrap_width=md,data,wrap_width
104
+ @env=SiSU_Env::InfoEnv.new(@md.fns)
105
+ @tab="\t"
106
+ @@endnotes_=case md.opt.selections.str
107
+ when /--footnote/ then false
108
+ when /--endnote/ then true
109
+ else true
110
+ end
111
+ @plaintext={ body: [], open: [], close: [], head: [], metadata: [], tail: [] }
112
+ end
113
+ def songsheet
114
+ plaintext=markup(@data)
115
+ publish(plaintext)
116
+ end
117
+ def break_line
118
+ "\n"
119
+ end
120
+ # Used for extraction of endnotes from paragraphs
121
+ def extract_endnotes(dob='')
122
+ notes=dob.obj.scan(/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]})([\d*+]+\s+.+?)(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/)
123
+ @n=[]
124
+ notes.flatten.each do |n| #high cost to deal with <br> appropriately within plaintext, consider
125
+ n=n.dup.to_s
126
+ if n =~/#{Mx[:br_line]}|#{Mx[:br_nl]}/
127
+ fix = n.split(/#{Mx[:br_line]}|#{Mx[:br_nl]}/) #watch #added
128
+ fix.each do |x|
129
+ unless x.empty?; @n << x
130
+ end
131
+ end
132
+ else @n << n
133
+ end
134
+ end
135
+ notes=@n.flatten
136
+ notes.each do |e|
137
+ util=(e.to_s =~/^\[[\d*+]+\]:/) \
138
+ ? (SiSU_TextUtils::Wrap.new(e.to_s,@wrap_width,4,1))
139
+ : (SiSU_TextUtils::Wrap.new(e.to_s,@wrap_width,1,1))
140
+ wrap=util.line_wrap
141
+ wrap=if wrap =~ /^\s*[\d*+]+\s+.+?\s*\Z/m
142
+ wrap.gsub(/^(\s*)([\d*+]+)\s+(.+?)\s*\Z/m, <<-GSUB
143
+ \\1[\\2]: \\3
144
+ GSUB
145
+ )
146
+ else
147
+ wrap.gsub(/^(.+)\Z/m, <<-GSUB
148
+ \\1
149
+ GSUB
150
+ )
151
+ end
152
+ @@endnotes[:para] << "-#{wrap}"
153
+ @@endnotes[:end] << '' << wrap
154
+ end
155
+ @@endnotes
156
+ end
157
+ def plaintext_metadata
158
+ array=SiSU_Metadata::Summary.new(@md).plaintext.metadata
159
+ array.each do |meta|
160
+ tag,inf=meta.scan(/^.+?:\s|.+/)
161
+ if tag and inf
162
+ util=SiSU_TextUtils::Wrap.new(inf,@wrap_width,15,1)
163
+ txt=util.line_wrap
164
+ @plaintext[:metadata] <<<<WOK
165
+
166
+ #{@tab}#{tag}#{txt}
167
+ WOK
168
+ end
169
+ end
170
+ end
171
+ def plaintext_tail
172
+ # env=SiSU_Env::InfoEnv.new(@md.fns)
173
+ generator="Generated by: #{@md.project_details.project} #{@md.project_details.version} of #{@md.project_details.date_stamp} (#{@md.project_details.date})" if @md.project_details.version
174
+ lastdone="Last Generated on: #{Time.now}"
175
+ rubyv="Ruby version: #{@md.ruby_version}"
176
+ sc=if @md.sc_info
177
+ "Source file: #{@md.sc_filename}#{break_line}Version number: #{@md.sc_number}#{break_line}Version date: #{@md.sc_date}#{break_line}"
178
+ else ''
179
+ end
180
+ @plaintext[:tail] <<<<WOK
181
+ #{break_line}
182
+ plaintext (plain text):
183
+ #{@md.file.output_path.textile.url}/#{@md.file.base_filename.textile}#{break_line}
184
+ Other versions of this document: #{break_line}
185
+ manifest:
186
+ #{@md.file.output_path.manifest.url}/#{@md.file.base_filename.manifest}#{break_line}
187
+ at:
188
+ #{@md.file.output_path.base.url}#{break_line}
189
+
190
+ #{sc}
191
+ * #{generator}
192
+ * #{rubyv}
193
+ * #{lastdone}
194
+ * SiSU #{the_url.sisu_txt}
195
+ WOK
196
+ end
197
+ def heading_decorated_inline(dob)
198
+ if dob.is==:heading
199
+ heading_inline = case dob.lc
200
+ when 0 then decorate.heading.inline.l0
201
+ when 1 then decorate.heading.inline.l1
202
+ when 2 then decorate.heading.inline.l2
203
+ when 3 then decorate.heading.inline.l3
204
+ when 4 then decorate.heading.inline.l4
205
+ when 5 then decorate.heading.inline.l5
206
+ when 6 then decorate.heading.inline.l6
207
+ end
208
+ heading_inline + ' ' + dob.obj
209
+ end
210
+ end
211
+ def plaintext_structure(dob='',p_num='') #% Used to extract the structure of a document
212
+ util=nil
213
+ wrapped=if dob.is==:para \
214
+ || dob.is==:heading
215
+ if dob.is==:heading
216
+ util=SiSU_TextUtils::Wrap.new(heading_decorated_inline(dob),@wrap_width,0,0)
217
+ elsif dob.is==:para
218
+ if dob.hang \
219
+ and dob.hang =~/[0-9]/ \
220
+ and dob.indent != dob.hang
221
+ util=SiSU_TextUtils::Wrap.new(dob.obj,@wrap_width,dob.indent.to_i*2,dob.hang.to_i*2)
222
+ #util=SiSU_TextUtils::Wrap.new(dob.obj,@wrap_width,dob.hang.to_i*2,0)
223
+ elsif dob.indent =~/[1-9]/
224
+ util=if dob.bullet_
225
+ SiSU_TextUtils::Wrap.new("* #{dob.obj}",@wrap_width,dob.indent.to_i*2)
226
+ else SiSU_TextUtils::Wrap.new(dob.obj,@wrap_width,dob.indent.to_i*2)
227
+ end
228
+ else
229
+ util=if dob.bullet_
230
+ SiSU_TextUtils::Wrap.new("* #{dob.obj}",@wrap_width,0)
231
+ else SiSU_TextUtils::Wrap.new(dob.obj,@wrap_width,0)
232
+ end
233
+ end
234
+ else util=SiSU_TextUtils::Wrap.new(dob.obj,@wrap_width,0)
235
+ end
236
+ dob.is==:heading ? util.no_wrap_no_breaks : util.line_wrap
237
+ end
238
+ @plaintext[:body] << wrapped + p_num << break_line # main text, contents, body KEEP
239
+ if @@endnotes[:para] \
240
+ and not @@endnotes_
241
+ @@endnotes[:para].each {|e| @plaintext[:body] << e << break_line}
242
+ elsif @@endnotes[:para] \
243
+ and @@endnotes_
244
+ end
245
+ @@endnotes[:para]=[]
246
+ end
247
+ def markup(data) # Used for major markup instructions
248
+ SiSU_Env::InfoEnv.new(@md.fns)
249
+ @data_mod,@endnotes,@level,@cont,@copen,@plaintext_contents_close=Array.new(6){[]}
250
+ (0..6).each { |x| @cont[x]=@level[x]=false }
251
+ (4..6).each { |x| @plaintext_contents_close[x]='' }
252
+ plaintext_tail #($1,$2)
253
+ plaintext_metadata
254
+ table_message='[table conversion awaited, see other document formats]'
255
+ data.each do |dob|
256
+ dob.obj=dob.obj.gsub(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}.+/um,"#{break_line}#{table_message}"). #fix
257
+ gsub(/.+?#{Mx[:gl_o]}-##{Mx[:gl_c]}/,''). # remove dummy headings (used by html) #check also [~-]#
258
+ gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,
259
+ "#{decorate.bold.open}\\1#{decorate.bold.close}").
260
+ gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,
261
+ "#{decorate.italics.open}\\1#{decorate.italics.close}").
262
+ gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,
263
+ "#{decorate.underscore.open}\\1#{decorate.underscore.close}").
264
+ gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,
265
+ "#{decorate.subscript.open}\\1#{decorate.subscript.close}").
266
+ gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,
267
+ "#{decorate.superscript.open}\\1#{decorate.superscript.close}").
268
+ gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,
269
+ "#{decorate.insert.open}\\1#{decorate.insert.close}").
270
+ gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,
271
+ "#{decorate.cite.open}\\1#{decorate.cite.close}").
272
+ gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,
273
+ "#{decorate.strike.open}\\1#{decorate.strike.close}").
274
+ gsub(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/,
275
+ "#{decorate.monospace.open}\\1#{decorate.monospace.close}")
276
+ unless dob.is==:code
277
+ dob.obj=dob.obj.gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/,'\1').
278
+ gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'\1').
279
+ gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,'\1 [link: <\2>]').
280
+ gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}image/,'\1 [link: local image]').
281
+ gsub(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,"#{the_text.url_open}\\1#{the_text.url_close}")
282
+ extract_endnotes(dob)
283
+ dob.obj=dob.obj.gsub(/#{Mx[:en_a_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_a_c]}/,'[^\1]'). # endnote marker marked up
284
+ gsub(/#{Mx[:en_b_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_b_c]}/,'[^\1]'). # endnote marker marked up
285
+ gsub(/#{Mx[:gl_o]}(?:#lt|#060)#{Mx[:gl_c]}/,'<').
286
+ gsub(/#{Mx[:gl_o]}(?:#gt|#062)#{Mx[:gl_c]}/,'>').
287
+ gsub(/#{Mx[:gl_o]}#(?:038|amp)#{Mx[:gl_c]}/,'&').
288
+ gsub(/#{Mx[:gl_o]}#033#{Mx[:gl_c]}/,'!').
289
+ gsub(/#{Mx[:gl_o]}#035#{Mx[:gl_c]}/,'#').
290
+ gsub(/#{Mx[:gl_o]}#042#{Mx[:gl_c]}/,'*').
291
+ gsub(/#{Mx[:gl_o]}#045#{Mx[:gl_c]}/,'-').
292
+ gsub(/#{Mx[:gl_o]}#047#{Mx[:gl_c]}/,'/').
293
+ gsub(/#{Mx[:gl_o]}#095#{Mx[:gl_c]}/,'_').
294
+ gsub(/#{Mx[:gl_o]}#123#{Mx[:gl_c]}/,'{').
295
+ gsub(/#{Mx[:gl_o]}#125#{Mx[:gl_c]}/,'}').
296
+ gsub(/#{Mx[:gl_o]}#126#{Mx[:gl_c]}/,'~').
297
+ gsub(/#{Mx[:gl_o]}#169#{Mx[:gl_c]}/,'©').
298
+ gsub(/#{Mx[:gl_o]}#092#{Mx[:gl_c]}/,'\\')
299
+ end
300
+ dob.obj=if dob.of==:block # watch
301
+ dob.obj.gsub(/#{Mx[:gl_o]}●#{Mx[:gl_c]}/m,"* ").
302
+ gsub(/\n?#{Mx[:br_line]}\n?|\n?#{Mx[:br_nl]}\n?/m,break_line)
303
+ else dob.obj.gsub(/\n?#{Mx[:br_line]}\n?|\n?#{Mx[:br_nl]}\n?/m,break_line*2)
304
+ end
305
+ if dob.is==:code
306
+ dob.obj=dob.obj.gsub(/(^|[^}])_([<>])/m,'\1\2'). # _> _<
307
+ gsub(/(^|[^}])_([<>])/m,'\1\2') # _<_<
308
+ end
309
+ dob.obj=dob.obj.gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'\1').
310
+ gsub(/<a href=".+?">(.+?)<\/a>/m,'\1').
311
+ gsub(/#{Mx[:mk_o]}:name#(\S+?)#{Mx[:mk_c]}/,''). # remove name links
312
+ gsub(/&nbsp;|#{Mx[:nbsp]}/,' '). # decide on
313
+ gsub(/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/,' [ \1 ]'). #"[ #{dir.url.images_local}\/\\1 ]")
314
+ gsub(/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}image/,' [ \1 ]').
315
+ gsub(/(?:^|[^_\\])\{\s*\S+?\.(?:png|jpg|gif)\s+.+?"(.*?)"\s*\}\S+/,'[image: "\1"]')
316
+ if dob.obj !~/(^#{Rx[:meta]}|#{Mx[:br_eof]}|#{Mx[:br_endnotes]})/
317
+ p_num=''
318
+ #ocn
319
+ if dob.is==:heading \
320
+ or dob.is==:para
321
+ plaintext_structure(dob,p_num)
322
+ elsif dob.is==:group \
323
+ or dob.is==:block \
324
+ or dob.is==:verse \
325
+ or dob.is==:code \
326
+ or dob.is==:table
327
+ @plaintext[:body] << dob.obj + p_num << break_line
328
+ elsif dob.is==:break
329
+ sp=' '
330
+ ln='-'
331
+ @plaintext[:body] <<=if dob.obj==Mx[:br_page] \
332
+ or dob.obj==Mx[:br_page_new] \
333
+ or dob.obj==Mx[:br_page_line]
334
+ "#{break_line}#{ln*40}#{break_line*2}"
335
+ elsif dob.obj ==Mx[:br_obj]
336
+ "#{break_line}#{sp*20}* * *#{break_line*2}"
337
+ end # following empty line (break_line) missing, fix
338
+ end
339
+ dob='' if (dob.obj =~/<a name="n\d+">/ \
340
+ and dob.obj =~/^(-\{{2}~\d+|<!e[:_]\d+!>)/) # -endnote
341
+ if dob ## Clean Prepared Text
342
+ dob.obj=dob.obj.gsub(/<!.+!>/,' ').
343
+ gsub(/<:\S+>/,' ')
344
+ end
345
+ end
346
+ end
347
+ @plaintext
348
+ end
349
+ def publish(plaintext)
350
+ divider='='
351
+ content=[]
352
+ content << plaintext[:open]
353
+ content << plaintext[:head]
354
+ content << plaintext[:body]
355
+ content << @@endnotes[:end] if @@endnotes_
356
+ content << "#{break_line}#{divider*@wrap_width}#{break_line}"
357
+ content << plaintext[:metadata]
358
+ content << "#{break_line}#{divider*@wrap_width}#{break_line}" if @md.stmp =~/\w+/ #not used?
359
+ content << plaintext[:tail]
360
+ outputfile=SiSU_Env::FileOp.new(@md).write_file.textile
361
+ Txt_Output::Output.new.document(content,outputfile)
362
+ @@endnotes={ para: [], end: [] }
363
+ end
364
+ end
365
+ end
366
+ end
367
+ __END__