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,171 @@
1
+ # encoding: utf-8
2
+ =begin
3
+
4
+ * Name: SiSU
5
+
6
+ ** Description: documents, structuring, processing, publishing, search
7
+ *** create sisupod filetype and copy it to output directory!
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/src_sisupod_make.rb;hb=HEAD>
55
+
56
+ =end
57
+ module SiSU_Doc
58
+ require_relative 'src_shared' # scr_shared.rb
59
+ include SiSU_Source
60
+ require_relative 'se' # se.rb
61
+ include SiSU_Env
62
+ class Source < SiSU_Source::SiSUpodSource
63
+ require_relative 'utils_response' # utils_response.rb
64
+ def initialize(opt,build=nil,place=nil)
65
+ super(opt,build,place)
66
+ @zipfile=@opt.fno.gsub(/(?:\~\S{2,3})?(\.ss[tm])$/,'\1')
67
+ unless @opt.act[:quiet][:set]==:on
68
+ pthinfo="#{@file.output_path.sisupod.dir}/#{@zipfile}.txz"
69
+ (@opt.act[:verbose][:set]==:on \
70
+ || @opt.act[:verbose_plus][:set]==:on \
71
+ || @opt.act[:maintenance][:set]==:on) \
72
+ ? SiSU_Screen::Ansi.new(
73
+ @opt.act[:color_state][:set],
74
+ 'Assemble source for sisu document',
75
+ "#{@opt.fns} -> file://#{pthinfo}"
76
+ ).cyan_hi_blue
77
+ : SiSU_Screen::Ansi.new(
78
+ @opt.act[:color_state][:set],
79
+ 'Assemble source for sisu document',
80
+ pthinfo
81
+ ).cyan_title_hi
82
+ end
83
+ end
84
+ def sisupod_tar_xz
85
+ begin
86
+ FileUtils::mkdir_p(@file.output_path.sisupod.dir) \
87
+ unless FileTest.directory?(@file.output_path.sisupod.dir)
88
+ tree=((@opt.act[:verbose][:set]==:on \
89
+ || @opt.act[:verbose_plus][:set]==:on \
90
+ || @opt.act[:maintenance][:set]==:on) \
91
+ && SiSU_Env::SystemCall.new.program_found?('tree')) \
92
+ ? 'tree sisupod'
93
+ : ''
94
+ if FileTest.directory?(@path_pod[:fnb])
95
+ Dir.chdir(@path_pod[:fnb])
96
+ system(%{
97
+ #{tree}
98
+ tar -cJf #{@zipfile}.txz sisupod
99
+ #echo "#{@file.place_file.sisupod.dir}"
100
+ })
101
+ FileUtils::mv("#{@zipfile}.txz",@file.place_file.sisupod.dir)
102
+ Dir.chdir(@env.path.pwd)
103
+ if (@opt.act[:verbose][:set]==:on \
104
+ || @opt.act[:verbose_plus][:set]==:on \
105
+ || @opt.act[:maintenance][:set]==:on)
106
+ SiSU_Screen::Ansi.new('',"#{@opt.fns}.txz").blue_tab
107
+ end
108
+ else
109
+ if (@opt.act[:verbose][:set]==:on \
110
+ || @opt.act[:verbose_plus][:set]==:on \
111
+ || @opt.act[:maintenance][:set]==:on)
112
+ SiSU_Screen::Ansi.new('',"#{@opt.fns}.txz not built").blue_tab
113
+ end
114
+ end
115
+ rescue
116
+ ensure
117
+ end
118
+ end
119
+ end
120
+ end
121
+ __END__
122
+ question?: should you permit the packing of multiple documents in single .xz ?
123
+
124
+ open @opt.fns, parse file
125
+ extract from file content:
126
+ images and copy each image from whatever image source to _sisu/sisupod/sisu/_sisu/image
127
+
128
+ remove previously existing contents of _/sisu/sisupod &
129
+ make directory structure:
130
+
131
+ v3 -->
132
+ _sisu
133
+ sisupod
134
+ doc
135
+ manifest.txt
136
+ en/content.sst [file content]
137
+ fr/content.sst
138
+ _sisu
139
+ conf
140
+ image (ln -s ../../image)
141
+ audio (ln -s ../../audio)
142
+ video (ln -s ../../video)
143
+ image [all images for specific document gathered here]
144
+ audio
145
+ video
146
+
147
+ v2 -->
148
+ _sisu
149
+ sisupod
150
+ content.sst [file content]
151
+ filename.sst [link to content.sst]
152
+ _sisu/
153
+ image/ [all images for specific document gathered here]
154
+
155
+ sisu
156
+ _sisu
157
+ sisurc.yml
158
+ convert/
159
+ standard_terms/
160
+ image
161
+ processing
162
+ ao/
163
+ tex/
164
+ texinfo/
165
+ tune/
166
+ sisupod
167
+
168
+ special case
169
+
170
+ composite file (master), e.g.
171
+ SiSU.ssm
@@ -0,0 +1,109 @@
1
+ # encoding: utf-8
2
+ =begin
3
+
4
+ * Name: SiSU
5
+
6
+ ** Description: documents, structuring, processing, publishing, search
7
+ *** share sisu source markup file, copy it to output directory!
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/src_sisupod_sstm.rb;hb=HEAD>
55
+
56
+ =end
57
+ module SiSU_Markup
58
+ require_relative 'src_shared' # src_shared.rb
59
+ include SiSU_Source
60
+ require_relative 'se' # se.rb
61
+ include SiSU_Env
62
+ class Source_Sisupod < SiSU_Source::SiSUpodSource
63
+ def initialize(opt,build=nil,place=nil)
64
+ super(opt,build,place)
65
+ @opt=opt
66
+ end
67
+ def read
68
+ unless @opt.act[:quiet][:set]==:on
69
+ (@opt.act[:verbose][:set]==:on \
70
+ || @opt.act[:verbose_plus][:set]==:on \
71
+ || @opt.act[:maintenance][:set]==:on) \
72
+ ? SiSU_Screen::Ansi.new(
73
+ @opt.act[:color_state][:set],
74
+ 'Share document markup text source',
75
+ @opt.fns
76
+ ).cyan_hi_blue
77
+ : SiSU_Screen::Ansi.new(
78
+ @opt.act[:color_state][:set],
79
+ 'Share document markup text source',
80
+ @opt.fns
81
+ ).cyan_title_hi
82
+ end
83
+ if FileTest.directory?(@path_pod[:fnb])
84
+ FileUtils::mkdir_p(@file.output_path.src.dir) \
85
+ unless FileTest.directory?(@file.output_path.src.dir)
86
+ v=(@opt.act[:maintenance][:set]==:on) \
87
+ ? 'v' : ''
88
+ system(%{
89
+ rsync -a#{v} #{@path_pod[:fnb]} #{@file.output_path.sisupod.dir}
90
+ chbk=`pwd`
91
+ cd #{@file.output_path.sisupod.dir}
92
+ for I in `find -type d` ; do chmod 755 $I ; done
93
+ for I in `find -type f` ; do chmod 644 $I ; done
94
+ cd ${chbk}
95
+ })
96
+ else
97
+ if (@opt.act[:verbose][:set]==:on \
98
+ || @opt.act[:verbose_plus][:set]==:on \
99
+ || @opt.act[:maintenance][:set]==:on)
100
+ SiSU_Screen::Ansi.new(
101
+ '',
102
+ "#{@opt.fno} not available"
103
+ ).blue_tab
104
+ end
105
+ end
106
+ end
107
+ end
108
+ end
109
+ __END__
@@ -0,0 +1,323 @@
1
+ # encoding: utf-8
2
+ =begin
3
+
4
+ * Name: SiSU
5
+
6
+ ** Description: documents, structuring, processing, publishing, search
7
+ *** A conversion script for canned substitutions, a fairly generic
8
+ simple tool that can be used to store other canned conversions, used here for
9
+ altering SiSU markup
10
+
11
+ ** Author: Ralph Amissah
12
+ <ralph@amissah.com>
13
+ <ralph.amissah@gmail.com>
14
+
15
+ ** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
16
+ 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah,
17
+ All Rights Reserved.
18
+
19
+ ** License: GPL 3 or later:
20
+
21
+ SiSU, a framework for document structuring, publishing and search
22
+
23
+ Copyright (C) Ralph Amissah
24
+
25
+ This program is free software: you can redistribute it and/or modify it
26
+ under the terms of the GNU General Public License as published by the Free
27
+ Software Foundation, either version 3 of the License, or (at your option)
28
+ any later version.
29
+
30
+ This program is distributed in the hope that it will be useful, but WITHOUT
31
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
32
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
33
+ more details.
34
+
35
+ You should have received a copy of the GNU General Public License along with
36
+ this program. If not, see <http://www.gnu.org/licenses/>.
37
+
38
+ If you have Internet connection, the latest version of the GPL should be
39
+ available at these locations:
40
+ <http://www.fsf.org/licensing/licenses/gpl.html>
41
+ <http://www.gnu.org/licenses/gpl.html>
42
+
43
+ <http://www.sisudoc.org/sisu/en/manifest/gpl.fsf.html>
44
+
45
+ ** SiSU uses:
46
+ * Standard SiSU markup syntax,
47
+ * Standard SiSU meta-markup syntax, and the
48
+ * Standard SiSU object citation numbering and system
49
+
50
+ ** Hompages:
51
+ <http://www.jus.uio.no/sisu>
52
+ <http://www.sisudoc.org>
53
+
54
+ ** Git
55
+ <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=summary>
56
+ <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=blob;f=lib/sisu/sst_convert_markup.rb;hb=HEAD>
57
+
58
+ =end
59
+ module SiSU_Modify
60
+ require_relative 'sst_identify_markup' # sst_identify_markup.rb
61
+ require_relative 'sst_from_xml' # sst_from_xml.rb
62
+ require_relative 'utils_response' # utils_response.rb
63
+ class ConvertMarkup
64
+ include SiSU_Response
65
+ def initialize(opt)
66
+ @opt=opt
67
+ @description='This is a script that contains canned text conversions for reuse'
68
+ @warn='WARNING, PROCEED AT YOUR OWN RISK, will make file changes.'
69
+ end
70
+ def current_match_and_replace
71
+ convert_37_to_38
72
+ end
73
+ def message(text)
74
+ response=''
75
+ unless @opt.cmd=~/QQ/ \
76
+ or @opt.act[:quiet][:set]==:on
77
+ response=response?(%{#{ text}\nProceed? })
78
+ end
79
+ end
80
+ def help
81
+ print <<WOK
82
+
83
+ #{@description}
84
+
85
+ sisu --convert --to38 [filename/wildcard]
86
+ converts pre 0.37 sisu markup to 0.38 experimental
87
+ [--37to38]
88
+
89
+ sisu --convert --to37 [filename/wildcard]
90
+ converts pre 0.37 sisu markup to 0.38 experimental
91
+ [--38to37]
92
+
93
+ sisu --convert --36to37 [filename/wildcard]
94
+ converts pre 0.36 file-name, to 0.37 file-name
95
+ [--36to37]
96
+
97
+ sisu --identify [filename]
98
+ attempts to identify markup version used in file
99
+
100
+ sisu --query [version number]
101
+ gives short summary of distinguishing characteristic
102
+ of that version of markup
103
+
104
+ WOK
105
+ exit
106
+ end
107
+ #%% substitutions to be made
108
+ def convert_37_to_38
109
+ message("#{@warn}\nConvert sisu markup from 0.37 to 0.38")
110
+ [
111
+ [/^0~(\S+?)([+-])\s+/, '@\1:\2 ', //],
112
+ [/^0~(\S+)\s+/, '@\1: ', //],
113
+ [/^@toc:\s+/, '@structure: ', //],
114
+ [/^1~/, ':A~', //],
115
+ [/^2~/, ':B~', //],
116
+ [/^3~/, ':C~', //],
117
+ [/^4~/, '1~', //],
118
+ [/^5~/, '2~', //],
119
+ [/^6~/, '3~', //],
120
+ [/^7~/, '4~', //],
121
+ [/^8~/, '5~', //],
122
+ [/^9~/, '6~', //],
123
+ [/1/, ':A', /^@(?:level|markup):\s/],
124
+ [/2/, ':B', /^@(?:level|markup):\s/],
125
+ [/3/, ':C', /^@(?:level|markup):\s/],
126
+ [/4/, '1', /^@(?:level|markup):\s/],
127
+ [/5/, '2', /^@(?:level|markup):\s/],
128
+ [/6/, '3', /^@(?:level|markup):\s/]
129
+ ]
130
+ end
131
+ def convert_38_to_37
132
+ message("#{@warn}\nConvert sisu markup from 0.38 to 0.37")
133
+ [
134
+ [/^@(\S+?):([+-])\s+/, '0~\1\2 ', //],
135
+ [/^@(\S+?):\s+/, '0~\1 ', //],
136
+ [/^0~structure\s+/, '0~toc ', //],
137
+ [/^1~/, '4~', //],
138
+ [/^2~/, '5~', //],
139
+ [/^3~/, '6~', //],
140
+ [/^4~/, '7~', //],
141
+ [/^5~/, '8~', //],
142
+ [/^6~/, '9~', //],
143
+ [/^:?A~/, '1~', //],
144
+ [/^:?B~/, '2~', //],
145
+ [/^:?C~/, '3~', //],
146
+ [/1/, '4', /^0~(?:level|markup)\s/],
147
+ [/2/, '5', /^0~(?:level|markup)\s/],
148
+ [/3/, '6', /^0~(?:level|markup)\s/],
149
+ [/:?A/, '1', /^0~(?:level|markup)\s/],
150
+ [/:?B/, '2', /^0~(?:level|markup)\s/],
151
+ [/:?C/, '3', /^0~(?:level|markup)\s/]
152
+ ]
153
+ end
154
+ def convert_filename_36_to_37
155
+ @opt.files.each do |f|
156
+ s=case f
157
+ when /(\.s[1-3])$/ then f.sub($1,'.sst')
158
+ when /(\.r[1-3])$/ then f.sub($1,'.ssm')
159
+ when /(\.ri)$/ then f.sub($1,'.ssi')
160
+ else f
161
+ end
162
+ pwd=Dir.pwd
163
+ unless f==s
164
+ unless File.exist?("#{pwd}/#{s}")
165
+ puts "./#{f} -> ./#{s}"
166
+ FileUtils::cp("#{pwd}/#{f}","#{pwd}/#{s}")
167
+ else "File already exists, < #{s} > will not overwrite"
168
+ end
169
+ end
170
+ end
171
+ end
172
+ def convert_to_simple_xml_model_sax
173
+ SiSU_SimpleXML_ModelSax::Convert.new(@opt).read
174
+ end
175
+ def convert_to_simple_xml_model_dom
176
+ SiSU_simple_xml_model_dom::Convert.new(@opt).read
177
+ end
178
+ def convert_to_simple_xml_model_node
179
+ SiSU_simple_xml_model_node::Convert.new(@opt).read
180
+ end
181
+ def convert_kdi_to_sst
182
+ SiSU_Kdissert::Convert.new(@opt).read
183
+ end
184
+ def convert_s_xml_to_sst
185
+ SiSU_sstFromXML::Convert.new(@opt).read
186
+ end
187
+ def convert_footnotes
188
+ require_relative 'sst_do_inline_footnotes'
189
+ SiSU_ConvertFootnotes::Source.new(@opt).read
190
+ end
191
+ def conversion
192
+ #%% do it -------------------------->
193
+ if @opt.files \
194
+ and @opt.files.length > 0
195
+ mr=nil
196
+ #%% changes to make m match, r replace -------------------------->
197
+ if @opt.selections.str =~/--help/ then help
198
+ elsif @opt.selections.str =~/(?:convert|to)[=-](?:xml |sxs|sax|sxd|dom|sxn|node)/
199
+ ext=case @opt.selections.str
200
+ when /(?:convert|to)[=-](?:xml|sxs|sax)/ then '.sxs.xml'
201
+ when /(?:convert|to)[=-](?:sxd|dom)/ then '.sxd.xml'
202
+ when /(?:convert|to)[=-](?:sxn|node)/ then '.sxn.xml'
203
+ end
204
+ message("#{@opt.files.inspect}\n\nWARNING, PROCEED AT YOUR OWN RISK,\noverwriting any equivalent file with the extension #{ext}")
205
+ mr=case @opt.selections.str
206
+ when /(?:convert|to)[=-](?:sxs|sax|xml )/ then convert_to_simple_xml_model_sax
207
+ when /(?:convert|to)[=-](?:sxd|dom)/ then convert_to_simple_xml_model_dom
208
+ when /(?:convert|to)[=-](?:sxn|node)/ then convert_to_simple_xml_model_node
209
+ else help
210
+ end
211
+ else
212
+ mr=case @opt.selections.str
213
+ when /(?:(?:37)?to-?38|--(?:convert|to)[=-](?:current|0.38))/ then convert_37_to_38
214
+ when /(?:(?:38)?to-?37|--(?:convert|to)[=-](?:0.37))/ then convert_38_to_37
215
+ when /(?:36to37)/ then convert_filename_36_to_37
216
+ when /(?:convert|from)[=-]kdi/ then convert_kdi_to_sst
217
+ when /(?:(?:convert|from)[=-])?(?:xml_to_sst|xml2sst|sxml|sxs|sxd|sxd)/ then convert_s_xml_to_sst
218
+ when /(?:convert|to)[=-]footnotes/ then convert_footnotes
219
+ when /convert|default/ then current_match_and_replace
220
+ else help
221
+ end
222
+ end
223
+ unless @opt.selections.str =~/kdi/
224
+ match_and_replace=mr
225
+ #start_processing =/not used in this example/i
226
+ end_processing =/END\s+OF\s+FILE/
227
+ i=@opt.fns
228
+ if i =~/(?:\.sst|\.ssm|\.ssi)$/
229
+ @new,@matched,@flag_start,@flag_end,@empty1,@empty2=true,false,false,false,false,false
230
+ o="#{i}.bk" #o is for old
231
+ markup_version=SiSU_Markup::MarkupIdentify.new(@opt).markup_version?
232
+ if (@opt.selections.str=~/37/ and markup_version=~/0.38/) \
233
+ or (@opt.selections.str=~/current|38/ and markup_version=~/0.37/)
234
+ puts "#{i} #{markup_version}"
235
+ file=File.open(i,'r')
236
+ cont=file.readlines
237
+ file.close
238
+ cont.each do |y|
239
+ match_and_replace.each do |m,r,w|
240
+ if y =~m \
241
+ and y =~w
242
+ if @new
243
+ @new=false
244
+ File.unlink(o) if File.exist?(o)
245
+ File.rename(i,o)
246
+ File.unlink(i) if File.exist?(i)
247
+ @file=File.new(i,'w')
248
+ @matched=true
249
+ break
250
+ end
251
+ end
252
+ end
253
+ end
254
+ if @matched
255
+ puts "conversion match in #{i}" unless @opt.act[:quiet][:set]==:on
256
+ @flag_start=true
257
+ cont.each do |y|
258
+ if y =~end_processing
259
+ @flag_end=true
260
+ end
261
+ if @flag_start \
262
+ and not @flag_end
263
+ match_and_replace.each do |m,r,w|
264
+ if y =~m \
265
+ and y =~w
266
+ puts m.inspect + ' -> ' + r unless @opt.act[:quiet][:set]==:on
267
+ if (@opt.act[:verbose][:set]==:on \
268
+ || @opt.act[:verbose_plus][:set]==:on \
269
+ || @opt.act[:maintenance][:set]==:on)
270
+ puts "in: #{y}"
271
+ end
272
+ y.gsub!(m,r) if m and r
273
+ if (@opt.act[:verbose][:set]==:on \
274
+ || @opt.act[:verbose_plus][:set]==:on \
275
+ || @opt.act[:maintenance][:set]==:on)
276
+ puts "out: #{y}"
277
+ end
278
+ end
279
+ end
280
+ end
281
+ @empty1=(y=~/^\s*$/) \
282
+ ? true
283
+ : false
284
+ @file.puts y unless (@empty1==true and @empty2==true)
285
+ @empty2=(y=~/^\s*$/) \
286
+ ? true
287
+ : false
288
+ end
289
+ @file.close
290
+ else puts "NO conversion match in #{i}" unless @opt.act[:quiet][:set]==:on
291
+ end
292
+ else
293
+ if (@opt.act[:verbose][:set]==:on \
294
+ || @opt.act[:verbose_plus][:set]==:on \
295
+ || @opt.act[:maintenance][:set]==:on)
296
+ puts "Requested conversion #{@opt.selections.str} markup #{markup_version} identified in #{i}"
297
+ end
298
+ end
299
+ end
300
+ end
301
+ else puts 'this routine makes permanent changes to the contents of the files matched, as instructed within [no matches]'
302
+ end
303
+ end
304
+ end
305
+ end
306
+ #%% files to match for this conversion set ------------------------->
307
+ require_relative 'hub_options' # hub_options.rb
308
+ argv=$*
309
+ base_path=Dir.pwd
310
+ @opt=SiSU_Commandline::Options.new(argv,base_path)
311
+ case @opt.selections.str
312
+ when /=kdi/
313
+ SiSU_Modify::ConvertMarkup.new(@opt).conversion
314
+ when /(?:36|37|38)?to-?(?:37|38)|--convert|--to|--from|default/
315
+ @opt.files.each do |fns|
316
+ @opt.fns=fns
317
+ SiSU_Modify::ConvertMarkup.new(@opt).conversion
318
+ end
319
+ else
320
+ @opt.selections.str='--help'
321
+ SiSU_Modify::ConvertMarkup.new(@opt).help
322
+ end
323
+ __END__