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,161 @@
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 simple tool
8
+ that can be used to store other canned conversions, used here for altering
9
+ 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/dp_identify_markup.rb;hb=HEAD>
57
+
58
+ =end
59
+ module SiSU_MarkupType
60
+ class MarkupIdentify
61
+ @@version={}
62
+ @@fns,@@version[:determined],@@version[:declared],@@declared_doc_type='','','','[text?]'
63
+ attr_accessor :version,:declared_doc_type
64
+ def initialize(content,opt)
65
+ @cont,@opt=content,opt
66
+ end
67
+ def identify
68
+ @version,@declared_doc_type=@@version,@@declared_doc_type
69
+ if @opt.fns != @@fns
70
+ if @cont[0] =~ /^(?:%\s+)?SiSU\s+(text|master|insert)\s+([0-9](?:\.[0-9]+){1,2})/ \
71
+ or @cont[0] =~ /^(?:%\s+)?sisu-([0-9](?:\.[0-9]+){1,2})/
72
+ @declared_doc_type,@version[:declared]=$1,$2
73
+ elsif @cont[0] =~ /^(?:%\s+)?SiSU\s+([0-9](?:\.[0-9]+){1,2})/ \
74
+ or @cont[0] =~ /^(?:%\s+)?sisu-([0-9](?:\.[0-9]+){1,2})/
75
+ @version[:declared]=$1
76
+ end
77
+ @flag_2_0,@flag_66,@flag_57,@flag_38=false,false,false,false
78
+ @cont.each_with_index do |y,i|
79
+ if y =~/^@make:|^@classify|^\s\s?:\S+?:\s+\S/
80
+ version=2.0.to_f
81
+ @version[:determined]=version
82
+ @flag_2_0=true
83
+ break
84
+ end
85
+ unless @flag_38
86
+ if y =~/^:?A~/
87
+ version=0.38.to_f
88
+ @version[:determined]=version
89
+ @flag_38=true
90
+ end
91
+ end
92
+ if @flag_38
93
+ if @flag_69 \
94
+ or y =~/^=\{.+?\}\s*$/
95
+ version=0.69.to_f
96
+ @flag_69=true
97
+ @version[:determined]=version
98
+ break
99
+ end
100
+ if @flag_66 \
101
+ or y =~/[:;]\{.+?\}[:;][a-z+]/
102
+ version=0.66.to_f
103
+ @flag_66=true
104
+ @version[:determined]=version
105
+ break
106
+ end
107
+ end
108
+ end
109
+ @flag_57,@flag_38=false,false
110
+ unless @flag_2_0 \
111
+ or @flag_66 \
112
+ or @flag_69
113
+ @cont.each_with_index do |y,i|
114
+ if @flag_57 \
115
+ or y =~/^:?A~\?? @title/
116
+ @version[:determined]=0.57.to_f
117
+ @flag_57=true
118
+ break
119
+ end
120
+ if @flag_38 \
121
+ or y =~/^:?A~/
122
+ @version[:determined]=0.38.to_f
123
+ @flag_38=true
124
+ break if i >= 200
125
+ if y =~ /(?:~{\*+|~\[\*|~\[\+)\s/
126
+ @version[:determined]=0.42 #0.38 can safely be treated as 0.42
127
+ break
128
+ end
129
+ end
130
+ if y =~/^0~/ \
131
+ and not @flag_38
132
+ @version[:determined]=0.16.to_f
133
+ break
134
+ end
135
+ end
136
+ end
137
+ @@fns=@opt.fns
138
+ @@version,@@declared_doc_type=@version,@declared_doc_type
139
+ end
140
+ self
141
+ end
142
+ def markup_version?
143
+ def determined
144
+ identify.version[:determined].to_f
145
+ end
146
+ def series
147
+ s=case identify.version[:determined].to_s
148
+ when /^[01]\./ then '1.0'
149
+ when /^[2]\./ then '2.0'
150
+ else '2.0'
151
+ end
152
+ "series #{s}"
153
+ end
154
+ def declared
155
+ identify.version[:declared].to_f
156
+ end
157
+ self
158
+ end
159
+ end
160
+ end
161
+ __END__
@@ -0,0 +1,668 @@
1
+ # encoding: utf-8
2
+ =begin
3
+
4
+ * Name: SiSU
5
+
6
+ ** Description: documents, structuring, processing, publishing, search
7
+ *** document parameters make extracted for program use
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 Lic/home/ralph/live-manual/build/manual/manifest/live-manual.ca.htmlense 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/dp_make.rb;hb=HEAD>
55
+
56
+ =end
57
+
58
+ module SiSU_Param_Make
59
+ class MdMake
60
+ def initialize(str,opt,env)
61
+ @s,@opt,@env=str,opt,env
62
+ end
63
+ def validate_length(s,l,n)
64
+ #s=(s.length <= l) ? s : nil
65
+ s=if s.is_a?(String) \
66
+ and s.length <= l
67
+ s
68
+ elsif s.is_a?(NilClass)
69
+ nil
70
+ elsif s.class !=String
71
+ STDERR.puts "#{n} is #{s.class}: programming error, String expected #{__FILE__}:#{__LINE__}"
72
+ s
73
+ else
74
+ SiSU_Screen::Ansi.new(
75
+ 'v',
76
+ "*WARN* #{n} length #{s.length} exceeds set db field length #{l}, metadata dropped",
77
+ @opt.fns
78
+ ).warn unless @opt.act[:quiet][:set]==:on
79
+ nil
80
+ end
81
+ end
82
+ def name_format(name)
83
+ if name
84
+ name=name.strip
85
+ @name_a_h=[]
86
+ authors=name.scan(/[^;]+/)
87
+ authors.each_with_index do |a,i|
88
+ b=((a =~/\s*\|\s*/) ? (a.split(/\|/)) : [a])
89
+ if b[0] =~/"(.+?)"/
90
+ @name_a_h << { the: $1 }
91
+ else
92
+ x=b[0].scan(/[^,]+/)
93
+ if x.length==1
94
+ @name_a_h << { the: x[0].strip }
95
+ elsif x.length==2
96
+ @name_a_h << { the: x[0].strip, others: x[1].strip }
97
+ else #p x.length
98
+ end
99
+ end
100
+ b.delete_at(0)
101
+ b.each do |d|
102
+ k,c=nil
103
+ k,c=/^(\S+)\s+(.*)/.match(d)[1,2] if d
104
+ @name_a_h[i][:hon]=c.strip if k=='hon'
105
+ @name_a_h[i][:affiliation]=c.strip if k=='affiliation'
106
+ @name_a_h[i][:nationality]=c.strip if k=='nationality'
107
+ end
108
+ end
109
+ l=@name_a_h.length
110
+ name_str=''
111
+ @name_a_h.each_with_index do |a,i|
112
+ name_str += if a[:others]
113
+ z=(((l - i) > 1) ? ', ' : '')
114
+ "#{a[:others].strip} #{a[:the].strip}" + z
115
+ else
116
+ z=(((l - i) > 2) ? ', ' : '')
117
+ "#{a[:the].strip}" + z
118
+ end
119
+ end
120
+ { name_a_h: @name_a_h, name_str: name_str }
121
+ else nil
122
+ end
123
+ end
124
+ def build_hash(arr)
125
+ @h={}
126
+ arr.each_with_index do |x,i|
127
+ a,b=nil,nil
128
+ if x =~/^%[:\s]/ #ignore comment
129
+ elsif x =~/:(\S+?):\s+(.+)/
130
+ a,b=/:(\S+?):\s+(.+)\Z/m.match(x)[1,2]
131
+ elsif i == 0
132
+ a='main'
133
+ b=x
134
+ else
135
+ end
136
+ @h[a]=b
137
+ end
138
+ @h
139
+ end
140
+ def make
141
+ a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m)
142
+ @h=build_hash(a)
143
+ def headings
144
+ lv=[]
145
+ x=@h['headings']
146
+ x=((x =~/;/) ? (x.split(/;\s*/)) : [ x ])
147
+ lv[0]=x
148
+ lv0 ||='A~ ' #root level, single document apex, document title
149
+ lv1=x[0] ||='B~ '
150
+ lv[1]=/^#{lv1}/
151
+ lv2=x[1] ||='C~ '
152
+ lv[2]=/^#{lv2}/
153
+ lv3=x[2] ||='D~ '
154
+ lv[3]=/^#{lv3}/
155
+ lv4=x[3] ||='1~ '
156
+ lv[4]=/^#{lv4}/
157
+ lv5=x[4] ||='2~ '
158
+ lv[5]=/^#{lv5}/
159
+ lv6=x[5] ||='3~ '
160
+ lv[6]=/^#{lv6}/
161
+ lv
162
+ end
163
+ def num_top
164
+ @h['num_top']
165
+ end
166
+ def breaks
167
+ pagebreaks=((@h['breaks'] =~/;/) \
168
+ ? (@h['breaks'].split(/;\s*/))
169
+ : [ @h['breaks'] ])
170
+ page_new,page_break,page_line=nil,nil,nil
171
+ pagebreaks.each do |x|
172
+ page_new=x[/(:?[\dA-C],?)+/] if x=~/new|clear/
173
+ page_break=x[/(:?[\dA-C],?)+/] if x =~/break/
174
+ page_line=x[/(:?[\dA-C],?)+/] if x =~/line/
175
+ end
176
+ { page_new: page_new, page_break: page_break, page_line: page_line }
177
+ end
178
+ def language
179
+ if @h['language'] && (@h['language']=~/\S{2,}/)
180
+ ((@h['language'] =~/,/) \
181
+ ? (@h['language'].split(/,\s*/))
182
+ : [ @h['language'] ])
183
+ else [ 'en' ]
184
+ end
185
+ end
186
+ def bold
187
+ m=@h['bold']
188
+ i=(m=~/\/i$/)? 'i' : ''
189
+ if m
190
+ x=m.gsub(/^\/(.+?)\/i?/,'\1').
191
+ gsub(/\((?:\?:)?/,'(?:') # avoid need to escape use of brackets within regex provided
192
+ rgx='\b(' + x + ')\b'
193
+ y=((i =~/i/) ? (/#{rgx}/i) : (/#{rgx}/))
194
+ { str: '\b(?:' + x + ')\b', regx: y, i: i }
195
+ else nil
196
+ end
197
+ end
198
+ def italics
199
+ m=@h['italics']
200
+ i=((m=~/\/i$/) ? 'i' : '')
201
+ if m
202
+ x=m.gsub(/^\/(.+?)\/i?/,'\1').
203
+ gsub(/\((?:\?:)?/,'(?:') # avoid need to escape use of brackets within regex provided
204
+ rgx='\b(' + x + ')\b'
205
+ y=((i =~/i/) ? (/#{rgx}/i) : (/#{rgx}/))
206
+ { str: '\b(?:' + x + ')\b', regx: y, i: i }
207
+ else nil
208
+ end
209
+ end
210
+ def emphasis
211
+ if @h['emphasis'] =~/bold/ then 'bold'
212
+ elsif @h['emphasis'] =~/italics?/ then 'italics'
213
+ elsif @h['emphasis'] =~/under(?:line|score)/ then 'underscore'
214
+ else nil
215
+ end
216
+ end
217
+ def substitute
218
+ m=@h['substitute']
219
+ if m
220
+ w=m.scan(/\/(.+?)\/(i?,)\s*'(.+?)'(?:\s+|\s*;\s*|$)/)
221
+ arr_hash=[]
222
+ matches=''
223
+ w.each do |x|
224
+ c=(x[1] =~/[i],/) ? :i : :s
225
+ matches=matches + x[0].gsub(/([${}])/,'\\\\\1') + '|'
226
+ arr_hash << {
227
+ match: x[0].gsub(/([${}])/,'\\\\\1'),
228
+ replace: x[2],
229
+ case_s: c
230
+ }
231
+ end
232
+ matches.chop!
233
+ { match_and_replace: arr_hash, matches: matches }
234
+ else nil
235
+ end
236
+ end
237
+ def plaintext_wrap
238
+ if @h['plaintext_wrap'].to_s =~/\d\d+/ \
239
+ and @h['plaintext_wrap'].to_i > 19 \
240
+ and @h['plaintext_wrap'].to_i < 201
241
+ @h['plaintext_wrap'].to_i
242
+ else nil
243
+ end
244
+ end
245
+ def omit
246
+ m=@h['omit']
247
+ @m=m ? (m.split(/,\s+/)) : nil
248
+ def list
249
+ @m
250
+ end
251
+ self
252
+ end
253
+ def ocn?
254
+ (omit.list.inspect =~/"ocn"/) \
255
+ ? :off
256
+ : :na
257
+ end
258
+ def toc?
259
+ (omit.list.inspect =~/"toc"/) \
260
+ ? :off
261
+ : :na
262
+ end
263
+ def manifest?
264
+ (omit.list.inspect =~/"manifest"/) \
265
+ ? :off
266
+ : :na
267
+ end
268
+ def links_to_manifest?
269
+ (omit.list.inspect =~/"manifest_links"|"links_to_manifest"/) \
270
+ ? :off
271
+ : :na
272
+ end
273
+ def metadata?
274
+ (omit.list.inspect =~/"metadata"/) \
275
+ ? :off
276
+ : :na
277
+ end
278
+ def minitoc?
279
+ (omit.list.inspect =~/"minitoc"/) \
280
+ ? :off
281
+ : :na
282
+ end
283
+ def html_minitoc?
284
+ (omit.list.inspect =~/"html_minitoc"/) \
285
+ ? :off
286
+ : :na
287
+ end
288
+ def html_top_band?
289
+ (omit.list.inspect =~/"html_top_band"/) \
290
+ ? :off
291
+ : :na
292
+ end
293
+ def html_navigation?
294
+ (omit.list.inspect =~/"html_navigation"/) \
295
+ ? :off
296
+ : :na
297
+ end
298
+ def html_navigation_bar?
299
+ (omit.list.inspect =~/"html_navigation_bar"/) \
300
+ ? :off
301
+ : :na
302
+ end
303
+ def segsubtoc?
304
+ (omit.list.inspect =~/"segsubtoc"/) \
305
+ ? :off
306
+ : :na
307
+ end
308
+ def search_form?
309
+ (omit.list.inspect =~/"search_form"/) \
310
+ ? :off
311
+ : :na
312
+ end
313
+ def html_search_form?
314
+ (omit.list.inspect =~/"html_search_form"/) \
315
+ ? :off
316
+ : :na
317
+ end
318
+ def html_right_pane?
319
+ (omit.list.inspect =~/"html_right_column"|"html_right_pane"/) \
320
+ ? :off
321
+ : :na
322
+ end
323
+ def manifest_minitoc?
324
+ (omit.list.inspect =~/"manifest_minitoc"/) \
325
+ ? :off
326
+ : :na
327
+ end
328
+ def cover_image?
329
+ (omit.list.inspect =~/"cover_image"/) \
330
+ ? :off
331
+ : :na
332
+ end
333
+ def home_button_image?
334
+ (omit.list.inspect =~/"home_button_image"/) \
335
+ ? :off
336
+ : :na
337
+ end
338
+ def texpdf_font
339
+ def main
340
+ @h['texpdf_font'] \
341
+ && (@h['texpdf_font']=~/\S{3,}/) \
342
+ ? @h['texpdf_font']
343
+ : @env.font.texpdf.main
344
+ end
345
+ def sans # not used
346
+ @h['texpdf_font_sans'] \
347
+ && (@h['texpdf_font_sans']=~/\S{3,}/) \
348
+ ? @h['texpdf_font_sans']
349
+ : @env.font.texpdf.sans
350
+ end
351
+ def serif # not used
352
+ @h['texpdf_font_serif'] \
353
+ && (@h['texpdf_font_serif']=~/\S{3,}/) \
354
+ ? @h['texpdf_font_serif']
355
+ : @env.font.texpdf.serif
356
+ end
357
+ def mono
358
+ @h['texpdf_font_mono'] \
359
+ && (@h['texpdf_font_mono']=~/\S{3,}/) \
360
+ ? @h['texpdf_font_mono']
361
+ : @env.font.texpdf.mono
362
+ end
363
+ def cjk
364
+ @h['texpdf_font_cjk'] \
365
+ && (@h['texpdf_font_cjk']=~/\S{3,}/) \
366
+ ? @h['texpdf_font_cjk']
367
+ : @env.font.texpdf.cjk
368
+ end
369
+ def cjk_zh
370
+ @h['texpdf_font_cjk_zh'] \
371
+ && (@h['texpdf_font_cjk_zh']=~/\S{3,}/) \
372
+ ? @h['texpdf_font_cjk_zh']
373
+ : @env.font.texpdf.cjk_zh
374
+ end
375
+ def cjk_ja
376
+ @h['texpdf_font_cjk_ja'] \
377
+ && (@h['texpdf_font_cjk_ja']=~/\S{3,}/) \
378
+ ? @h['texpdf_font_cjk_ja']
379
+ : @env.font.texpdf.cjk_ja
380
+ end
381
+ def cjk_ko
382
+ @h['texpdf_font_cjk_ko'] \
383
+ && (@h['texpdf_font_cjk_ko']=~/\S{3,}/) \
384
+ ? @h['texpdf_font_cjk_ko']
385
+ : @env.font.texpdf.cjk_ko
386
+ end
387
+ self
388
+ end
389
+ def promo
390
+ @h['promo']
391
+ end
392
+ def ad
393
+ @h['ad']
394
+ end
395
+ def manpage
396
+ manpage={}
397
+ if @h['manpage']
398
+ if @h['manpage'] =~/;/m
399
+ man=@h['manpage'].split(/;/m)
400
+ man.each do |x|
401
+ m=(x=~/=/m) ? x.split(/=/m) : nil
402
+ if m
403
+ manpage[m[0].strip] = m[1].split(/ \. /)
404
+ end
405
+ end
406
+ end
407
+ end
408
+ if manpage['name']
409
+ manpage['name']=manpage['name'].join("\n.br\n").
410
+ gsub(/(-)/m,"\\\\\\1").
411
+ gsub(/\A/,"\n.br\n.SH NAME\n.br\n")
412
+ else
413
+ manpage['name']='man page "name/whatis" information not provided, set in header @man: name=[whatis information]'
414
+ end
415
+ if manpage['synopsis']
416
+ manpage['synopsis']=manpage['synopsis'].join("\n\n.br\n").
417
+ gsub(/(-)/m,"\\\\\\1").
418
+ gsub(/\A/,"\n.br\n.SH SYNOPSIS\n.br\n")
419
+ else
420
+ manpage['synopsis']=''
421
+ end
422
+ unless manpage['section']
423
+ manpage['section']=1
424
+ end
425
+ manpage
426
+ end
427
+ def get_image_dimensions(img)
428
+ imgk=SiSU_Env::SystemCall.new.imagemagick
429
+ gmgk=SiSU_Env::SystemCall.new.graphicsmagick
430
+ img_pth={
431
+ sst: @env.path.image_source_include,
432
+ pod: File.expand_path("../../../sisupod/image" )
433
+ }
434
+ path_img=if FileTest.file?("#{img_pth[:pod]}/#{img}")
435
+ "#{img_pth[:pod]}/#{img}"
436
+ elsif FileTest.file?("#{img_pth[:sst]}/#{img}")
437
+ "#{img_pth[:sst]}/#{img}"
438
+ else nil
439
+ end
440
+ if path_img
441
+ if imgk or gmgk
442
+ if imgk
443
+ imgsys=`identify #{path_img}`.strip #system call
444
+ elsif gmgk
445
+ imgsys=`gm identify #{path_img}`.strip #system call
446
+ end
447
+ w,h=/(\d+)x(\d+)/m.match(imgsys)[1,2]
448
+ else
449
+ w,h='600','800'
450
+ end
451
+ else
452
+ w,h=nil,nil
453
+ end
454
+ {w: w, h: h}
455
+ end
456
+ def home_button_text
457
+ if @h['home_button_text']
458
+ @h['home_button_text'].split(/\s*;\s*/)
459
+ else nil
460
+ end
461
+ end
462
+ def home_button_image
463
+ s=nil
464
+ s=if @h['home_button_image']
465
+ s=@h['home_button_image'].split(/\s*;\s*/)
466
+ s0=s[0] #if
467
+ image={}
468
+ s=if s0 =~/{(\S+\.(?:jpg|png|gif))(?:\s+(\d+x\d+))?\s*}(?:(http:\/\/\S+)|image)/
469
+ image[:home_button]=$1
470
+ if $2
471
+ image[:dimensions]=$2
472
+ image[:w],image[:h]=/(\d+)x(\d+)/m.match(image[:dimensions])[1,2]
473
+ else
474
+ d=get_image_dimensions(image[:home_button])
475
+ image[:w],image[:h]=d[:w],d[:h]
476
+ image[:dimensions]="#{d[:w]}x#{d[:h]}"
477
+ end
478
+ image[:link]=$3
479
+ image
480
+ end
481
+ else nil
482
+ end
483
+ end
484
+ def cover_image
485
+ s=nil
486
+ if @h['cover_image']
487
+ s=@h['cover_image'].split(/\s*;\s*/)
488
+ s=s[0] #if
489
+ image={}
490
+ if s =~/{\s*(\S+\.(?:jpg|png|gif))(?:\s+(\d+x\d+))?(?:\s+"(.+?)")?\s*}image/
491
+ image[:cover]=$1
492
+ if $2
493
+ image[:dimensions]=$2
494
+ image[:w],image[:h]=/(\d+)x(\d+)/m.match(image[:dimensions])[1,2]
495
+ else
496
+ d=get_image_dimensions(image[:cover])
497
+ image[:w],image[:h]=d[:w],d[:h]
498
+ image[:dimensions]="#{d[:w]}x#{d[:h]}"
499
+ end
500
+ image[:note]=$3
501
+ elsif s =~/(\S+\.(?:jpg|png|gif))/
502
+ image[:cover]=$1
503
+ d=get_image_dimensions(image[:cover])
504
+ image[:w],image[:h]=d[:w],d[:h]
505
+ image[:dimensions]="#{d[:w]}x#{d[:h]}"
506
+ image[:note]=nil
507
+ end
508
+ image
509
+ else nil
510
+ end
511
+ end
512
+ def footer
513
+ if @h['footer']
514
+ @h['footer'].split(/\s*;\s*/)
515
+ else nil
516
+ end
517
+ end
518
+ self
519
+ end
520
+ def make_links
521
+ @doc_links=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m)
522
+ def links
523
+ lnks,a_idx=[],0
524
+ @doc_links.each do |doc_link|
525
+ if doc_link=~/\{.+?\}(?:(?:https?|file|ftp):\/|\.\.)\/\S+(?:\s|$)/
526
+ say,url=/\{\s*(.+?)\s*\}((?:(?:https?|file|ftp):\/|\.\.)\/\S+)/im.match(doc_link)[1,2]
527
+ lnks[a_idx]={ say: say, url: url }
528
+ a_idx +=1
529
+ end
530
+ end
531
+ lnks
532
+ end
533
+ def append?
534
+ (@doc_links[0]=='+') \
535
+ ? :yes
536
+ : :no
537
+ end
538
+ self
539
+ end
540
+ end
541
+ class MakeHead
542
+ attr_accessor :pagenew,:pagebreak,:pageline,:toc,:lv1,:lv2,:lv3,:lv4,:lv5,:lv6,:num_top,:i18n,:man_section,:substitution_match_list,:bold_match_list,:italics_match_list,:emphasis_set_to,:footer_links,:home_button_links,:home_button_image,:cover_image
543
+ def initialize(make)
544
+ @make=make
545
+ end
546
+ def clear
547
+ @pagenew=@pagebreak=@pageline=@toc=@lv1=@lv2=@lv3=@lv4=@lv5=@lv6=@num_top=@i18n=@man_section=@footer_links=@substitution_match_list=@bold_match_list=@italics_match_list=@emphasis_set_to=@home_button_links=@home_button_image=@cover_image=nil
548
+ end
549
+ def make_instruct
550
+ clear
551
+ if defined? @make.breaks \
552
+ and @make.breaks[:page_new] #clearpage
553
+ @pagenew=@make.breaks[:page_new]
554
+ end
555
+ if defined? @make.breaks \
556
+ and @make.breaks[:page_break] #newpage
557
+ @pagebreak=@make.breaks[:page_break]
558
+ end
559
+ if defined? @make.breaks \
560
+ and @make.breaks[:page_line] #page line across
561
+ @pagebreak=@make.breaks[:page_line]
562
+ end
563
+ if defined? @make.headings \
564
+ and @make.headings
565
+ @toc=@make.headings[0]
566
+ @lv1=@make.headings[1]
567
+ @lv2=@make.headings[2]
568
+ @lv3=@make.headings[3]
569
+ @lv4=@make.headings[4]
570
+ @lv5=@make.headings[5]
571
+ @lv6=@make.headings[6]
572
+ end
573
+ if defined? @make.num_top \
574
+ and @make.num_top
575
+ @num_top=@make.num_top # remove @num_top
576
+ end
577
+ if defined? @make.language \
578
+ and @make.language[0]
579
+ @i18n=@make.language
580
+ end
581
+ if defined? @make.manpage \
582
+ and @make.manpage
583
+ @man_section=(defined? @make.manpage.section) \
584
+ ? @make.manpage.section
585
+ : 1
586
+ end
587
+ if defined? @make.substitute \
588
+ and @make.substitute
589
+ @substitution_match_list=@make.substitute
590
+ end
591
+ if defined? @make.bold \
592
+ and @make.bold
593
+ @bold_match_list=@make.bold
594
+ end
595
+ if defined? @make.italics \
596
+ and @make.italics
597
+ @italics_match_list=@make.italics
598
+ end
599
+ if defined? @make.emphasis \
600
+ and @make.emphasis
601
+ @emphasis_set_to=@make.emphasis
602
+ end
603
+ if defined? @make.footer \
604
+ and @make.footer.is_a?(Array)
605
+ @footer_links= { left: { say: '', url: '' }, center: { say: '', url: '' } } #already set
606
+ @footer_links[:left]=if @make.footer[0]=~/\{.+?\}(?:(?:https?|file|ftp):\/|\.\.)\/\S+(?:\s|$)/
607
+ say,url=/\{\s*(.+?)\s*\}((?:(?:https?|file|ftp):\/|\.\.)\/\S+)/im.match(@make.footer[0])[1,2]
608
+ { say: say, url: url }
609
+ else
610
+ { say: '', url: '' }
611
+ end
612
+ @footer_links[:center]=if @make.footer[1]=~/\{.+?\}(?:(?:https?|file|ftp):\/|\.\.)\/\S+(?:\s|$)/
613
+ say,url=/\{\s*(.+?)\s*\}((?:(?:https?|file|ftp):\/|\.\.)\/\S+)/im.match(@make.footer[1])[1,2]
614
+ { say: say, url: url }
615
+ else
616
+ { say: '', url: '' }
617
+ end
618
+ @footer_links
619
+ else #already set
620
+ @footer_links= { left: { say: '', url: '' }, center: { say: '', url: '' } }
621
+ end
622
+ if defined? @make.home_button_text \
623
+ and @make.home_button_text.is_a?(Array)
624
+ a_idx=0
625
+ @home_button_links=[]
626
+ @make.home_button_text.each do |doc_link|
627
+ if doc_link=~/\{.+?\}(?:(?:https?|file|ftp):\/|\.\.)\/\S+(?:\s|$)/
628
+ say,url=/\{\s*(.+?)\s*\}((?:(?:https?|file|ftp):\/|\.\.)\/\S+)/im.match(doc_link)[1,2]
629
+ @home_button_links[a_idx]= { say: say, url: url }
630
+ a_idx +=1
631
+ end
632
+ end
633
+ @home_button_links
634
+ end
635
+ if defined? @make.home_button_image \
636
+ and @make.home_button_image.is_a?(Hash)
637
+ @home_button_image=@make.home_button_image
638
+ end
639
+ if defined? @make.cover_image \
640
+ and @make.cover_image.is_a?(Hash)
641
+ @cover_image=@make.cover_image
642
+ end
643
+ { pagenew: @pagenew,
644
+ pagebreak: @pagebreak,
645
+ pageline: @pageline,
646
+ toc: @toc,
647
+ lv1: @lv1,
648
+ lv2: @lv2,
649
+ lv3: @lv3,
650
+ lv4: @lv4,
651
+ lv5: @lv5,
652
+ lv6: @lv6,
653
+ num_top: @num_top,
654
+ i18n: @i18n,
655
+ emphasis_set_to: @emphasis_set_to,
656
+ bold_match_list: @bold_match_list,
657
+ italics_match_list: @italics_match_list,
658
+ substitution_match_list: @substitution_match_list,
659
+ man_section: @man_section,
660
+ footer_links: @footer_links,
661
+ home_button_links: @home_button_links,
662
+ home_button_image: @home_button_image,
663
+ cover_image: @cover_image,
664
+ }
665
+ end
666
+ end
667
+ end
668
+ __END__