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,1162 @@
1
+ # encoding: utf-8
2
+ =begin
3
+
4
+ * Name: SiSU
5
+
6
+ ** Description: documents, structuring, processing, publishing, search
7
+ *** LaTeX generation
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/texpdf.rb;hb=HEAD>
55
+
56
+ =end
57
+ module SiSU_TeX
58
+ begin
59
+ require 'pstore'
60
+ rescue LoadError
61
+ SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).
62
+ error('pstore NOT FOUND (LoadError)')
63
+ end
64
+ require_relative 'texpdf_parts' # texpdf_parts.rb
65
+ require_relative 'se_hub_particulars' # se_hub_particulars.rb
66
+ include SiSU_Particulars
67
+ require_relative 'texpdf_format' # texpdf_format.rb
68
+ include SiSU_TeX_Pdf
69
+ require_relative 'shared_metadata' # shared_metadata.rb
70
+ require_relative 'prog_text_translation' # prog_text_translation.rb
71
+ @tex_file=@@tex_footnote_array=@@tex_col_w=[]
72
+ @@tabular="{tabular}"
73
+ @@column_instruct=@@squigle_close=@@tex_line_mode=@@tex_word_mode=@@line_mode=''
74
+ @@tex_debug_counter=@@table_pagebreak_counter=@@tex_footnote_call_counter=@@tex_table_flag=@@tex_counter=@@tex_column=@@tex_columns=@@tex_columns=@@counting=0
75
+ @@tex_pattern_margin_number=/\\\\begin\\\{tiny\\\}\\\\hspace\\\{0mm\\\}\\\\end\\\{tiny\\\}\\\{\\\\marginpar.+?\s+/
76
+ @@n=@@tableheader=@@rights=nil
77
+ @@date ||=SiSU_Env::InfoDate.new
78
+ class Source
79
+ begin
80
+ require 'pstore'
81
+ rescue LoadError
82
+ SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).
83
+ error('pstore NOT FOUND (LoadError)')
84
+ end
85
+ require_relative 'se' # se.rb
86
+ include SiSU_Env
87
+ require_relative 'ao' # ao.rb
88
+ include SiSU_AO
89
+ include SiSU_TeX
90
+ def initialize(opt)
91
+ @opt=opt
92
+ @particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt)
93
+ @md=@particulars.md
94
+ @env=SiSU_Env::InfoEnv.new(@md.fns) #@env=@particulars.env
95
+ end
96
+ def directories
97
+ begin
98
+ case @opt.fns
99
+ when /\.(?:-|ssm\.)?sst$/
100
+ SiSU_Env::FileOp.new(@md).mkdir
101
+ Dir.mkdir(@env.processing_path.tex) unless FileTest.directory?(@env.processing_path.tex)
102
+ end
103
+ rescue
104
+ SiSU_Errors::Rescued.new($!,$@,@opt.selections.str,@opt.fns).location do
105
+ __LINE__.to_s + ':' + __FILE__
106
+ end
107
+ ensure
108
+ end
109
+ end
110
+ def read
111
+ begin
112
+ song
113
+ ensure
114
+ Dir.chdir(@opt.f_pth[:pth])
115
+ end
116
+ end
117
+ def song
118
+ begin
119
+ @md=@particulars.md
120
+ SiSU_Screen::Ansi.new(
121
+ @opt.act[:color_state][:set],
122
+ 'LaTeX/PDF',
123
+ "[#{@opt.f_pth[:lng_is]}] #{@opt.fno}"
124
+ ).green_title_hi unless @opt.act[:quiet][:set]==:on
125
+ if (@opt.act[:verbose][:set]==:on \
126
+ || @opt.act[:verbose_plus][:set]==:on \
127
+ || @opt.act[:maintenance][:set]==:on)
128
+ @env.url.output_tell
129
+ if @md.opt.act[:pdf_l][:set]==:on
130
+ SiSU_Screen::Ansi.new(
131
+ @opt.act[:color_state][:set],
132
+ @opt.fns,
133
+ "#{@env.program.pdf_viewer} #{@md.file.output_path.pdf.dir}/#{@md.file.base_filename.pdf_l}#{@md.papersize_array[0]}.pdf"
134
+ ).flow
135
+ end
136
+ if @md.opt.act[:pdf_p][:set]==:on
137
+ SiSU_Screen::Ansi.new(
138
+ @opt.act[:color_state][:set],
139
+ @opt.fns,
140
+ "#{@opt.fns} #{@env.program.pdf_viewer} #{@md.file.output_path.pdf.dir}/#{@md.file.base_filename.pdf_p}#{@md.papersize_array[0]}.pdf"
141
+ ).flow
142
+ end
143
+ end
144
+ @md=@particulars.md
145
+ $flag=@md.opt.selections.str #introduced to pass 0 for no object citation numbers... to texpdf_format
146
+ directories
147
+ #% needed needs to be reprogrammed !!!
148
+ ao_array=SiSU_AO::Source.new(@opt).get # ao file drawn here
149
+ SiSU_TeX::Source::LaTeXcreate.new(@particulars).songsheet
150
+ ao_array=''
151
+ pwd=Dir.pwd
152
+ SiSU_TeX::Source::LaTeXtoPdf.new(@md,@particulars.env).latexrun_selective
153
+ Dir.chdir(pwd)
154
+ rescue
155
+ SiSU_Errors::Rescued.new($!,$@,@opt.selections.str,@opt.fns).location do
156
+ __LINE__.to_s + ':' + __FILE__
157
+ end
158
+ ensure
159
+ unless (@opt.act[:verbose_plus][:set]==:on \
160
+ || @opt.act[:maintenance][:set]==:on)
161
+ texfiles=Dir["#{@env.processing_path.tex}/#{@opt.fns}*"]
162
+ texfiles.each do |f|
163
+ if FileTest.file?(f)
164
+ File.unlink(f)
165
+ end
166
+ end
167
+ end
168
+ @tex_file=@@tex_footnote_array=[]
169
+ @@column_instruct=''
170
+ @@squigle_close=@@tex_line_mode=@@tex_word_mode=@@line_mode=''
171
+ @@tex_debug_counter=@@table_pagebreak_counter=@@tex_footnote_call_counter=@@tex_table_flag=@@tex_counter=@@tex_column=@@tex_columns=@@tex_columns=@@counting=0
172
+ @@tex_col_w=[]
173
+ @@n=@@tableheader=@@rights=nil
174
+ @@date=SiSU_Env::InfoDate.new
175
+ @@flag={}
176
+ $flag=1 #remove at some stage
177
+ SiSU_Env::Clear.new(@opt.selections.str,@opt.fns).param_instantiate
178
+ end
179
+ end
180
+ private
181
+ class LaTeXtoPdf
182
+ @@n_lpdf||=0 #change
183
+ def initialize(md,env)
184
+ @md,@env=md,env
185
+ @f=SiSU_Env::FileOp.new(@md).base_filename
186
+ end
187
+ def latex_do(texfilename,papersize)
188
+ @texfilename=texfilename
189
+ @@n_lpdf=@@n_lpdf+1
190
+ tex_fn_base=@texfilename.gsub(/\.tex$/,'')
191
+ tell=SiSU_Screen::Ansi.new(@md.opt.selections.str)
192
+ if @md.opt.act[:pdf_p][:set]==:on
193
+ if (@md.opt.act[:verbose][:set]==:on \
194
+ || @md.opt.act[:verbose_plus][:set]==:on \
195
+ || @md.opt.act[:maintenance][:set]==:on)
196
+ SiSU_Screen::Ansi.new(
197
+ @md.opt.act[:color_state][:set],
198
+ "#{papersize} portrait ->"
199
+ ).dark_grey_title_hi
200
+ end
201
+ cmd=SiSU_Env::SystemCall.new("#{tex_fn_base}.tex",'',@md.opt.selections.str)
202
+ if @md.opt.act[:verbose][:set]==:on \
203
+ || @md.opt.act[:verbose_plus][:set]==:on \
204
+ || @md.opt.act[:maintenance][:set]==:on
205
+ tell.grey_open
206
+ end
207
+ if "#{tex_fn_base}" =~/\w+/ \
208
+ and "#{papersize}" =~/\w+/
209
+ 2.times { |i| cmd.latex2pdf(@md,papersize) } #comment out to skip processing of latex portrait
210
+ end
211
+ if @md.opt.act[:verbose][:set]==:on \
212
+ || @md.opt.act[:verbose_plus][:set]==:on \
213
+ || @md.opt.act[:maintenance][:set]==:on
214
+ tell.p_off
215
+ end
216
+ end
217
+ if @md.opt.act[:pdf_l][:set]==:on
218
+ if (@md.opt.act[:verbose][:set]==:on \
219
+ || @md.opt.act[:verbose_plus][:set]==:on \
220
+ || @md.opt.act[:maintenance][:set]==:on)
221
+ SiSU_Screen::Ansi.new(
222
+ @md.opt.act[:color_state][:set],
223
+ "#{papersize} landscape ->"
224
+ ).dark_grey_title_hi
225
+ end
226
+ cmd=SiSU_Env::SystemCall.new("#{tex_fn_base}.landscape.tex",'',@md.opt.selections.str)
227
+ if (@md.opt.act[:verbose][:set]==:on \
228
+ || @md.opt.act[:verbose_plus][:set]==:on \
229
+ || @md.opt.act[:maintenance][:set]==:on)
230
+ tell.grey_open
231
+ end
232
+ if "#{tex_fn_base}" =~/\w+/ \
233
+ and "#{papersize}" =~/\w+/
234
+ 2.times { |i| cmd.latex2pdf(@md,papersize) } #comment out to skip processing of latex landscape
235
+ end
236
+ if (@md.opt.act[:verbose][:set]==:on \
237
+ || @md.opt.act[:verbose_plus][:set]==:on \
238
+ || @md.opt.act[:maintenance][:set]==:on)
239
+ tell.p_off
240
+ end
241
+ end
242
+ pwd=Dir.pwd
243
+ if @md.opt.act[:pdf_p][:set]==:on
244
+ portrait_pdf="#{pwd}/#{tex_fn_base}.pdf"
245
+ end
246
+ if @md.opt.act[:pdf_l][:set]==:on
247
+ landscape_pdf="#{pwd}/#{tex_fn_base}.landscape.pdf"
248
+ end
249
+ case papersize
250
+ when /a4/ then pdf_p=@f.pdf_p_a4; pdf_l=@f.pdf_l_a4
251
+ when /a5/ then pdf_p=@f.pdf_p_a5; pdf_l=@f.pdf_l_a5
252
+ when /b5/ then pdf_p=@f.pdf_p_b5; pdf_l=@f.pdf_l_b5
253
+ when /letter/ then pdf_p=@f.pdf_p_letter; pdf_l=@f.pdf_l_letter
254
+ when /legal/ then pdf_p=@f.pdf_p_legal; pdf_l=@f.pdf_l_legal
255
+ else pdf_p=@f.pdf_p_a4; pdf_l=@f.pdf_l_a4
256
+ end
257
+ FileUtils::mkdir_p(@md.file.output_path.pdf.dir) unless FileTest.directory?(@md.file.output_path.pdf.dir)
258
+ cX=SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set]).cX
259
+ if @md.opt.act[:pdf_p][:set]==:on
260
+ if FileTest.file?(portrait_pdf)
261
+ FileUtils::cp(portrait_pdf,"#{@md.file.output_path.pdf.dir}/#{pdf_p}")
262
+ FileUtils::rm(portrait_pdf)
263
+ else
264
+ STDERR.puts "#{__FILE__}:#{__LINE__} NOT FOUND: #{portrait_pdf}" if @md.opt.act[:maintenance][:set]==:on
265
+ errmsg="pdf file not generated #{portrait_pdf.gsub(/.+?([^\/]+?\.pdf)$/,'\1')} (check texlive dependencies)"
266
+ if @md.opt.act[:no_stop][:set]==:on
267
+ SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).
268
+ error("#{errmsg}, proceeding without pdf output (as requested)")
269
+ else
270
+ SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).
271
+ error("#{errmsg}, STOPPING")
272
+ exit
273
+ end
274
+ end
275
+ end
276
+ if @md.opt.act[:pdf_l][:set]==:on
277
+ if FileTest.file?(landscape_pdf)
278
+ FileUtils::cp(landscape_pdf,"#{@md.file.output_path.pdf.dir}/#{pdf_l}")
279
+ FileUtils::rm(landscape_pdf)
280
+ else
281
+ STDERR.puts "#{__FILE__}:#{__LINE__} NOT FOUND: #{landscape_pdf}" if @md.opt.act[:maintenance][:set]==:on
282
+ errmsg="pdf file not generated #{landscape_pdf.gsub(/.+?([^\/]+?\.pdf)$/,'\1')} (check texlive dependencies)"
283
+ if @md.opt.act[:no_stop][:set]==:on
284
+ SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).
285
+ error("#{errmsg}, proceeding without pdf output (as requested)")
286
+ else
287
+ SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).
288
+ error("#{errmsg}, STOPPING")
289
+ exit
290
+ end
291
+ end
292
+ end
293
+ if (@md.opt.act[:verbose][:set]==:on \
294
+ || @md.opt.act[:verbose_plus][:set]==:on \
295
+ || @md.opt.act[:maintenance][:set]==:on)
296
+ SiSU_Screen::Ansi.new(
297
+ @md.opt.act[:color_state][:set],
298
+ @@n_lpdf,
299
+ 'processed (SiSU LaTeX to pdf - using pdfetex aka. pdftex or pdflatex)'
300
+ ).generic_number
301
+ end
302
+ end
303
+ def latexrun_selective
304
+ begin
305
+ pwd=Dir.pwd
306
+ Dir.chdir(pwd) #watch
307
+ @tex_f_no=0
308
+ if FileTest.file?(@env.source_file_with_path)
309
+ @md.papersize_array.each do |ps|
310
+ if @md.fns =~/\.(?:-|ssm\.)?sst$/
311
+ case @md.fns
312
+ when /\.(?:-|ssm\.)?sst$/
313
+ if FileTest.directory?(@env.processing_path.tex)==true
314
+ Dir.chdir(@env.processing_path.tex)
315
+ texfile=@md.fns.gsub(/$/,".#{ps}.tex").
316
+ gsub(/~/,'-')
317
+ if @md.opt.act[:pdf_p][:set]==:on \
318
+ or @md.opt.act[:pdf_l][:set]==:on
319
+ latex_do(texfile,ps)
320
+ if @md.opt.act[:pdf_p][:set]==:on
321
+ if File.exist?(texfile) \
322
+ and File.size(texfile) > 0
323
+ #@tex_f_no+=1
324
+ else
325
+ errmsg="zero file size #{@env.processing_path.tex}/#{texfile}"
326
+ if @md.opt.act[:no_stop][:set]==:on
327
+ SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).
328
+ error("#{errmsg}, proceeding without pdf output (as requested)")
329
+ else
330
+ SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).
331
+ error("#{errmsg}, STOPPING")
332
+ exit
333
+ end
334
+ end
335
+ end
336
+ end
337
+ end
338
+ end
339
+ end
340
+ end
341
+ case @md.papersize_array[0] #default pdf
342
+ when /a4/ then pdf_p=@f.pdf_p_a4; pdf_l=@f.pdf_l_a4
343
+ when /a5/ then pdf_p=@f.pdf_p_a5; pdf_l=@f.pdf_l_a5
344
+ when /b5/ then pdf_p=@f.pdf_p_b5; pdf_l=@f.pdf_l_b5
345
+ when /letter/ then pdf_p=@f.pdf_p_letter; pdf_l=@f.pdf_l_letter
346
+ when /legal/ then pdf_p=@f.pdf_p_legal; pdf_l=@f.pdf_l_legal
347
+ else pdf_p=@f.pdf_p_a4; pdf_l=@f.pdf_l_a4
348
+ end
349
+ if @md.opt.act[:pdf_p][:set]==:on
350
+ if FileTest.file?("#{@md.file.output_path.pdf.dir}/#{pdf_p}")
351
+ mklnk=((@md.file.output_dir_structure.by_language_code?) \
352
+ || (@md.file.output_dir_structure.by_filetype?)) \
353
+ ? "#{@md.fnb}.portrait.pdf"
354
+ : 'portrait.pdf'
355
+ if FileTest.directory?(@md.file.output_path.pdf.dir)
356
+ pwd=Dir.pwd
357
+ Dir.chdir(@md.file.output_path.pdf.dir)
358
+ FileUtils::rm_f(mklnk)
359
+ FileUtils::ln_s(pdf_p, mklnk)
360
+ Dir.chdir(pwd)
361
+ end
362
+ end
363
+ end
364
+ if @md.opt.act[:pdf_l][:set]==:on
365
+ if FileTest.file?("#{@md.file.output_path.pdf.dir}/#{pdf_l}")
366
+ mklnk=((@md.file.output_dir_structure.by_language_code?) \
367
+ || (@md.file.output_dir_structure.by_filetype?)) \
368
+ ? "#{@md.fnb}.landscape.pdf"
369
+ : 'landscape.pdf'
370
+ pwd_set=Dir.pwd
371
+ Dir.chdir(@md.file.output_path.pdf.dir)
372
+ FileUtils::rm_f(mklnk)
373
+ FileUtils::ln_s(pdf_l, mklnk)
374
+ Dir.chdir(pwd_set)
375
+ end
376
+ end
377
+ else
378
+ SiSU_Screen::Ansi.new(
379
+ @md.opt.act[:color_state][:set],
380
+ "*WARN* FILE NOT FOUND: << #{@md.fns} >> - requested latex system processing skipped"
381
+ ).warn
382
+ end
383
+ lst=Dir["*.{aux,log,out}"]
384
+ lst.each {|file| File.unlink(file)} if lst
385
+ rescue
386
+ SiSU_Errors::Rescued.new($!,$@,@md.opt.selections.str,@md.fns).location do
387
+ __LINE__.to_s + ':' + __FILE__
388
+ end
389
+ end
390
+ end
391
+ end
392
+ class LaTeXcreate
393
+ include SiSU_Parts_TeXpdf
394
+ @@tex_head={
395
+ 'a4'=> { p: nil, l: nil },
396
+ 'a5'=> { p: nil, l: nil },
397
+ 'b5'=> { p: nil, l: nil },
398
+ 'letter'=>{ p: nil, l: nil },
399
+ 'legal'=> { p: nil, l: nil },
400
+ 'book'=> { p: nil, l: nil }
401
+ }
402
+ @@prefix_b=nil
403
+ def initialize(particulars)
404
+ @particulars=particulars
405
+ @md=@particulars.md
406
+ @env=SiSU_Env::InfoEnv.new(@md.fns) #@env=@particulars.env
407
+ @data=@particulars.ao_array # ao file drawn here
408
+ @st={ tex: {} }
409
+ @tex_ml=SiSU_TeX_Pdf::UseTeX.new(@md)
410
+ @dp=@@dp ||=SiSU_Env::InfoEnv.new.digest.pattern
411
+ l=SiSU_Env::StandardiseLanguage.new(@md.opt.lng).language
412
+ @language=l[:n]
413
+ @translate=SiSU_Translate::Source.new(@md,@language)
414
+ @codeblock_box='listings' #alternative 'boites'
415
+ @make ||=SiSU_Env::ProcessingSettings.new(@md)
416
+ end
417
+ def songsheet
418
+ begin
419
+ data=@data
420
+ @@tex_footnote_array=[]
421
+ @@rights=nil
422
+ txt_gen=if @md.opt.act[:pdf_l][:set]==:on \
423
+ and @md.opt.act[:pdf_p][:set]==:on
424
+ 'pdfTex portrait & landscape'
425
+ elsif @md.opt.act[:pdf_l][:set]==:on
426
+ 'pdfTex landscape'
427
+ elsif @md.opt.act[:pdf_p][:set]==:on
428
+ 'pdfTex portrait'
429
+ else
430
+ SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('error: neither landscape nor portrait')
431
+ end
432
+ if (@md.opt.act[:verbose][:set]==:on \
433
+ || @md.opt.act[:verbose_plus][:set]==:on \
434
+ || @md.opt.act[:maintenance][:set]==:on)
435
+ SiSU_Screen::Ansi.new(
436
+ @md.opt.act[:color_state][:set],
437
+ txt_gen
438
+ ).txt_grey
439
+ end
440
+ if defined? @md.rights.all \
441
+ and not @md.rights.all.empty?
442
+ sp_char=SiSU_TeX_Pdf::SpecialCharacters.new(@md,@md.rights.copyright.copyright_and_license.dup)
443
+ copymark='Copyright {\begin{small}{\copyright\end{small}} '
444
+ #copymark='Copyright {\begin{small}^{\copyright\end{small}} '
445
+ copyright=sp_char.special_characters_safe.gsub(/\s*Copyright \(C\)/, copymark)
446
+ @@rights||="\n #{Tex[:backslash]*2}[3]\\ \\linebreak #{copyright}"
447
+ end
448
+ if defined? @md.notes.prefix_b \
449
+ and not @md.notes.prefix_b.empty?
450
+ sp_char=SiSU_TeX_Pdf::SpecialCharacters.new(@md,@md.notes.prefix_b)
451
+ prefix_b=sp_char.special_characters_safe
452
+ @@prefix_b="\n #{Tex[:backslash]*2}[3]\\ \\linebreak \\ #{prefix_b}\n" unless @@prefix_b
453
+ end
454
+ data=pre(data)
455
+ data=footnote(data)
456
+ if @md.flag_tables #WORK ON 2009
457
+ data=tables(data) #uncomment to start experimenting with tables
458
+ end
459
+ data=number_paras(data)
460
+ data=markup(data)
461
+ output(data)
462
+ rescue
463
+ SiSU_Errors::Rescued.new($!,$@,@md.opt.selections.str,@md.fns).location do
464
+ __LINE__.to_s + ':' + __FILE__
465
+ end
466
+ ensure
467
+ end
468
+ end
469
+ protected
470
+ def pre(data)
471
+ @tex_file=[]
472
+ data.each do |dob|
473
+ # DEBUG 2003w16 this is a kludge, because i could not get parameters
474
+ # from param, Sort out ... revert to more elegant solution
475
+ # even more of a kludge as had to insert newlines where code is used not satisfactory, think about
476
+ dob.tmp=dob.obj #.dup
477
+ if dob.is==:para \
478
+ || dob.is==:heading
479
+ dob.tmp=dob.tmp.gsub(/#{Mx[:mk_o]}:name#\S+?#{Mx[:mk_c]}/,'')
480
+ dob.tmp=SiSU_TeX_Pdf::SpecialCharacters.new(@md,dob.tmp).special_characters
481
+ if dob.tmp =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/
482
+ dob.tmp=SiSU_TeX_Pdf::FormatTextObject.new(@md,dob.tmp).url_str_internal(dob.tmp)
483
+ end
484
+ elsif dob.is ==:code
485
+ dob.tmp=if @codeblock_box=='listings'
486
+ dob.tmp
487
+ else
488
+ SiSU_TeX_Pdf::SpecialCharacters.new(@md,dob.tmp).special_characters_code
489
+ end
490
+ elsif dob.is ==:break
491
+ if dob.obj==Mx[:br_page]; dob.tmp='\newpage'
492
+ elsif dob.obj==Mx[:br_page_new]; dob.tmp='\clearpage'
493
+ elsif dob.obj==Mx[:br_page_line]; dob.tmp=' \\ \hline \\ '
494
+ elsif dob.obj==Mx[:br_obj]; dob.tmp='\parasep'
495
+ end
496
+ elsif dob.is==:comment \
497
+ || dob.is==:meta
498
+ dob.tmp='' #dob.tmp=nil
499
+ end
500
+ end
501
+ data
502
+ end
503
+ def footnote(data)
504
+ data.each do |dob|
505
+ # EMBEDDED FOOTNOTES / ENDNOTES should be straightforward but not quite a synch.
506
+ if dob.tmp =~/#{Mx[:en_a_o]}[\d*+]+\s|#{Mx[:en_b_o]}([*+]\d+)\s/
507
+ dob.tmp=dob.tmp.gsub(/#{Mx[:en_a_o]}(\d+)\s+(.+?)#{Mx[:en_a_c]}/m,"\\footnote[\\1]{%\n \\2} ").
508
+ gsub(/#{Mx[:en_b_o]}([*+]\d+)\s+(.+?)#{Mx[:en_b_c]}/m,"\\FootnoteA{\\1}{%\n \\2} ").
509
+ gsub(/#{Mx[:en_a_o]}([*+]+)\s+(.+?)#{Mx[:en_a_c]}/m,"\\FootnoteA{\\1}{%\n \\2} ")
510
+ end
511
+ end
512
+ data
513
+ end
514
+ def tables_hash(md,dob)
515
+ @block={}
516
+ @dob=dob
517
+ @md.papersize_array.each do |ps|
518
+ @@tableheader={ ps => { p: 0, l: 0 } }
519
+ dob.tmp={ tmp: dob.tmp, paper_size: ps }
520
+ format_l=SiSU_TeX_Pdf::FormatTextObject.new(md,dob)
521
+ dob.tmp={ tmp: dob.tmp, paper_size: ps }
522
+ format_p=SiSU_TeX_Pdf::FormatTextObject.new(md,dob)
523
+ @block[ps]={
524
+ l: format_l.longtable_landscape,
525
+ p: format_p.longtable_portrait
526
+ }
527
+ end
528
+ @dob.tmp=@block
529
+ @dob
530
+ end
531
+ def tables(data)
532
+ @tex_file=[]
533
+ data.each do |dob|
534
+ @tex_file << if dob.is_a?(String) \
535
+ or dob.is_a?(Hash)
536
+ dob
537
+ elsif dob.is==:table
538
+ tables_hash(@md,dob) #Hash result
539
+ else dob
540
+ end
541
+ end
542
+ @tex_file
543
+ end
544
+ def enclose(dob)
545
+ dob
546
+ end
547
+ def box_boites(dob,ocn)
548
+ sp_char=SiSU_TeX_Pdf::SpecialCharacters.new(@md,dob.tmp,dob.is)
549
+ dob.tmp=sp_char.special_characters_safe
550
+ dob.tmp=dob.tmp.gsub(/(#{Mx[:nbsp]})/m,'{\color{mywhite}\1}').
551
+ #dob.tmp.gsub(/#{Mx[:nbsp]}/m,'{~}') # dob.tmp.gsub(/#{Mx[:nbsp]}\s*/m,'{~}')
552
+ gsub(/#{Mx[:vline]}/m,'\vline').
553
+ gsub(/ \\( |#{Mx[:br_nl]})/,' {\textbackslash}\1').
554
+ gsub(/#{Mx[:br_nl]}\s*\Z/m,'').
555
+ gsub(/#{Mx[:br_nl]}{2}/,'\newline \\\\\\ ').
556
+ gsub(/#{Mx[:br_nl]}/,' \\\\\\ ').
557
+ gsub(/\n\n\n/m," \\newline\n\n")
558
+ ocn=SiSU_TeX_Pdf::FormatTextObject.new(@md).ocn_display(dob)
559
+ dob.tmp = ocn \
560
+ + @tex_ml.paraskip_small \
561
+ + '\begin{Codeblock}' \
562
+ + '\begin{codeblockboitebox} \hardspace \newline ' \
563
+ + dob.tmp \
564
+ + '\end{codeblockboitebox}' \
565
+ + '\end{Codeblock}' \
566
+ + "\n" \
567
+ + @tex_ml.paraskip_normal
568
+ dob
569
+ end
570
+ def box_listings(dob,ocn)
571
+ sp_char=SiSU_TeX_Pdf::SpecialCharacters.new(@md,dob.tmp,dob.is)
572
+ dob.tmp=sp_char.characters_code_listings
573
+ dob.tmp=dob.tmp.gsub(/^\s+/m,''). #bug, fix earlier, should be made unecessary
574
+ gsub(/#{Mx[:nbsp]}/m,' ').
575
+ gsub(/#{Mx[:vline]}/m,'|').
576
+ gsub(/#{Mx[:br_nl]}(?:\s?\n)?/m,"\n").
577
+ gsub(/\n\n\n/m," \n\n")
578
+ ocn=SiSU_TeX_Pdf::FormatTextObject.new(@md).ocn_display(dob)
579
+ dob.tmp = ocn \
580
+ + @tex_ml.paraskip_small \
581
+ + '\begin{Codeblock}' \
582
+ + "\n" \
583
+ + '\begin{lstlisting} ' \
584
+ + "\n" \
585
+ + dob.tmp \
586
+ + "\n" \
587
+ + '\end{lstlisting} ' \
588
+ + "\n" \
589
+ + '\end{Codeblock}' \
590
+ + "\n" \
591
+ + @tex_ml.paraskip_normal
592
+ dob
593
+ end
594
+ def markup_common(dob)
595
+ if dob.of==:block
596
+ @lineone=if dob.is==:block \
597
+ || dob.is==:group \
598
+ || dob.is==:alt \
599
+ || dob.is==:verse
600
+ dob.tmp=dob.tmp.gsub(/#{Mx[:nbsp]}/m,' \hardspace ').
601
+ gsub(/#{Mx[:gl_bullet]}/m,'\txtbullet \hardspace '). #Bullet environment not used for grouped text, no hanging indent here
602
+ gsub(/#{Mx[:br_nl]}+/m,"\n\n") #match not ideal, but currently not inserting extra newlines anyway
603
+ ocn=SiSU_TeX_Pdf::FormatTextObject.new(@md).ocn_display(dob)
604
+ dob.tmp=if dob.is==:group \
605
+ || dob.is==:block \
606
+ || dob.is==:alt
607
+ dob.tmp=SiSU_TeX_Pdf::SpecialCharacters.new(@md,dob.tmp).special_characters_safe
608
+ ocn \
609
+ + @tex_ml.paraskip_small \
610
+ + "\n" \
611
+ + ' \\begin{footnotesize}' \
612
+ + "\n\n" \
613
+ + dob.tmp \
614
+ + '\\end{footnotesize}' \
615
+ + "\n" \
616
+ + @tex_ml.paraskip_normal
617
+ elsif dob.is==:verse
618
+ dob.tmp=dob.tmp.gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/m,'\begin{bfseries}\1 \end{bfseries}').
619
+ gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/m,'\emph{\1}').
620
+ gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/m,'\uline{\1}')
621
+ ocn \
622
+ + @tex_ml.paraskip_tiny \
623
+ + "\n" \
624
+ + ' \\begin{footnotesize}' \
625
+ + "\n\n" \
626
+ + dob.tmp \
627
+ + '\\end{footnotesize}' \
628
+ + "\n" \
629
+ + @tex_ml.paraskip_normal \
630
+ + "\n\\linebreak\n"
631
+ end
632
+ dob
633
+ elsif dob.is ==:code
634
+ dob=if @codeblock_box == 'listings'
635
+ box_listings(dob,ocn)
636
+ elsif @codeblock_box == 'boites'
637
+ box_boites(dob,ocn)
638
+ else
639
+ box_boites(dob,ocn)
640
+ end
641
+ dob
642
+ else 'error' #should never occur
643
+ end
644
+ dob=enclose(dob) unless dob.tmp =~/^$/
645
+ dob
646
+ else
647
+ tst=SiSU_TeX_Pdf::FormatTextObject.new(@md,dob)
648
+ case dob.is
649
+ when :heading
650
+ case dob.ln
651
+ when 0
652
+ tst.title_level_A
653
+ when 1
654
+ tst.section_heading_level_B
655
+ when 2
656
+ tst.section_heading_level_C
657
+ when 3
658
+ tst.section_heading_level_D
659
+ when 4
660
+ tst.heading_level_1
661
+ when 5
662
+ tst.heading_level_2
663
+ when 6
664
+ tst.heading_level_3
665
+ when 7
666
+ tst.heading_level_4
667
+ else dob
668
+ end
669
+ when :heading_insert
670
+ br="\n\\\\\n"
671
+ if dob.name=='book_index'
672
+ h=tst.section_heading_level_B
673
+ heading="\\clearpage\n" + h.tmp
674
+ idx_arr=[]
675
+ idx=SiSU_Particulars::CombinedSingleton.instance.get_idx_raw(@md.opt).raw_idx
676
+ idx.each do |x|
677
+ x=if x.is_a?(String)
678
+ x=SiSU_TeX_Pdf::SpecialCharacters.new(@md,x).special_characters
679
+ x=SiSU_TeX_Pdf::FormatTextObject.new(@md,x).url_str_internal(x,true)
680
+ else x=nil
681
+ end
682
+ idx_arr << x.sub(/,$/,'') if x.is_a?(String)
683
+ end
684
+ idx_str=idx_arr.join(br)
685
+ l=heading + br + idx_str
686
+ p=heading + br +
687
+ '\begin{multicols}{2}' + br +
688
+ idx_str + br +
689
+ '\end{multicols}'
690
+ dob.tmp={ l: l, p: p }
691
+ elsif dob.ln==2 \
692
+ and dob.obj=~/Metadata\b/
693
+ tst.section_heading_level_B
694
+ elsif dob.ln==4 \
695
+ and dob.obj=~/Metadata\b/
696
+ h=tst.heading_level_1
697
+ metadata=SiSU_Metadata::TeX_Metadata.new(@md).metadata_tex
698
+ dob.tmp=h.tmp + ' ' + '\begin{scriptsize}' + metadata.join(br) + '\end{scriptsize}'
699
+ else dob.tmp='' # dob.tmp={ l: '', p: '' }
700
+ end
701
+ when :para
702
+ if dob.bullet_
703
+ dob.tmp=tst.bullet
704
+ elsif dob.indent \
705
+ and dob.hang \
706
+ and dob.indent =~/[1-9]/ \
707
+ and dob.indent == dob.hang
708
+ dob.tmp=tst.indent
709
+ elsif dob.hang \
710
+ and dob.hang =~/[0-9]/ \
711
+ and (dob.indent != dob.hang or dob.indent =~/[1-9]/)
712
+ dob.tmp=tst.hang
713
+ else
714
+ dob.tmp=dob.tmp.strip
715
+ dob=enclose(dob) unless dob.tmp =~/^$/
716
+ end
717
+ else
718
+ dob.tmp=dob.tmp.strip unless dob.is==:code
719
+ dob=enclose(dob) unless dob.tmp =~/^$/
720
+ end
721
+ if dob.is_a?(String)
722
+ dob.tmp=dob.tmp.gsub(/\s*(?:#{Mx[:br_line]}|#{Mx[:br_nl]})\s*/,' \newline '). #% tread with care
723
+ gsub(/(\.#{Tex[:tilde]}\S*\s*|<:\S+>|#{Mx[:fa_o]}.*?#{Mx[:fa_c]}|#{Mx[:gr_o]}.*?#{Mx[:gr_c]}|<!.*?!>|<!>)/,' ') #% tread with care
724
+ end
725
+ dob
726
+ end
727
+ if dob.tmp =~/(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image\b)/m \
728
+ && dob.is !=:code
729
+ dob=SiSU_TeX_Pdf::BareUrls.new(@md,dob).bare_urls
730
+ tst=SiSU_TeX_Pdf::FormatTextObject.new(@md,dob)
731
+ dob=tst.urls_txt_and_images
732
+ dob
733
+ elsif dob.tmp =~/https?:\/\/\S+\b/m \
734
+ && dob.is ==:code \
735
+ && @codeblock_box !='listings'
736
+ dob=SiSU_TeX_Pdf::BareUrls.new(@md,dob).bare_urls_in_code
737
+ dob
738
+ end
739
+ if dob.class !=Hash \
740
+ && dob.tmp =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}image\b/ \
741
+ && dob.is !=:code
742
+ tst=SiSU_TeX_Pdf::FormatTextObject.new(@md,dob)
743
+ end
744
+ dob
745
+ end
746
+ def tex_box_listings
747
+ <<-WOK
748
+ \\definecolor{listinggray}{gray}{0.9}
749
+ \\definecolor{lbcolor}{rgb}{0.9,0.9,0.9}
750
+ \\lstset{
751
+ backgroundcolor=\\color{lbcolor},
752
+ tabsize=4,
753
+ rulecolor=,
754
+ language=,
755
+ basicstyle=\\scriptsize,
756
+ upquote=true,
757
+ aboveskip={1.5\\baselineskip},
758
+ columns=fixed,
759
+ showstringspaces=false,
760
+ extendedchars=true,
761
+ breaklines=true,
762
+ prebreak = \\raisebox{0ex}[0ex][0ex]{\\ensuremath{\\hookleftarrow}},
763
+ frame=single,
764
+ showtabs=false,
765
+ showspaces=false,
766
+ showstringspaces=false,
767
+ identifierstyle=\\ttfamily,
768
+ keywordstyle=\\color[rgb]{0,0,1},
769
+ commentstyle=\\color[rgb]{0.133,0.545,0.133},
770
+ stringstyle=\\color[rgb]{0.627,0.126,0.941},
771
+ }
772
+ WOK
773
+ end
774
+ def tex_box_boites
775
+ <<-WOK
776
+ \\def\\codeblockboitebox{%
777
+ \\def\\bkvz@before@breakbox{\\ifhmode\\par\\fi\\vskip\\breakboxskip\\relax}%
778
+ \\def\\bkvz@set@linewidth{\\advance\\linewidth -2\\fboxrule
779
+ \\advance\\linewidth -2\\fboxsep} %
780
+ \\def\\bk@line{\\hbox to \\linewidth{%
781
+ \\ifbkcount\\smash{\\llap{\\the\\bk@lcnt\\ }}\\fi
782
+ \\psframebox*[framesep=0pt,linewidth=0pt]{%
783
+ \\vrule\\@width\\fboxrule \\hskip\\fboxsep
784
+ \\box\\bk@bxa
785
+ \\hskip\\fboxsep \\vrule\\@width\\fboxrule
786
+ }%
787
+ }}%
788
+ %\\def\\bkvz@top{\\hrule\\@height\\fboxrule}
789
+ \\def\\bkvz@top{\\hrule height .6pt}%
790
+ \\def\\bkvz@bottom{\\hrule\\@height\\fboxrule}%
791
+ \\breakbox}
792
+ \\def\\endcodeblockboitebox{\\endbreakbox}
793
+ WOK
794
+ end
795
+ def tex_codeblock
796
+ codeblock_box=if @codeblock_box=='listings'
797
+ tex_box_listings
798
+ elsif @codeblock_box=='boites'
799
+ tex_box_boites
800
+ else
801
+ tex_box_boites
802
+ end
803
+ codeblock_box
804
+ end
805
+ def markup(data)
806
+ @tex_file=[]
807
+ home=the_text.txt_home.gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}|#{Mx[:br_paragraph]}|\\\\/,' - ') #no line splitting in heading neither html nor latex
808
+ title=@md.title.full.gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}|#{Mx[:br_paragraph]}|\\\\/,' - ') #no line splitting in heading neither html nor latex
809
+ @md.papersize_array.each do |ps|
810
+ if @md.opt.act[:pdf_p][:set]==:on
811
+ txt_obj={ txt: "#{home}: - #{title}", paper_size: ps, orientation: :portrait }
812
+ orient_portrait=SiSU_TeX_Pdf::FormatHead.new(@md,txt_obj)
813
+ @@tex_head[ps][:p]=orient_portrait.document_head_with_orientation(@codeblock_box)
814
+ end
815
+ if @md.opt.act[:pdf_l][:set]==:on
816
+ txt_obj={ txt: "#{home}: - #{title}", paper_size: ps, orientation: :landscape }
817
+ orient_landscape=SiSU_TeX_Pdf::FormatHead.new(@md,txt_obj)
818
+ @@tex_head[ps][:l]=orient_landscape.document_head_with_orientation(@codeblock_box)
819
+ end
820
+ end
821
+ @tex_file << <<-WOK
822
+ #{@tex_ml.header}#{@tex_ml.footer}
823
+ \\tolerance=300
824
+ \\clubpenalty=300
825
+ \\widowpenalty=300
826
+ \\makeatother
827
+ \\makeatother
828
+ \\chardef\\txtbullet="2022
829
+ \\chardef\\tilde="7E
830
+ %\\chardef\\asterisk="2A
831
+ \\def\\asterisk{{\\rm \\char42} }
832
+ \\definecolor{Light}{gray}{.92}
833
+ \\newcommand{\\Codeblock}[1]{\\normaltext\\raggedright\\small\\ttfamily\\texbackslash#1}
834
+ \\newcommand{\\monosp}[1]{\\normaltext\\ttfamily\\texbackslash#1}
835
+ \\newcommand{\\parasep}{\\\\ \\begin{center}*\\hspace{2em}*\\hspace{2em}*\\end{center} \\\\}
836
+ \\newcommand{\\hardspace}{{~}}
837
+ %\\newcommand{\\hardspace}{\\hspace{.5em}}
838
+ \\newcommand{\\caret}{{\\^{~}}}
839
+ \\newcommand{\\pipe}{{\\textbar}}
840
+ \\newcommand{\\curlyopen}{\{}
841
+ \\newcommand{\\curlyclose}{\}}
842
+ \\newcommand{\\lt}{{\UseTextSymbol{OML}{<}}}
843
+ \\newcommand{\\gt}{{\UseTextSymbol{OML}{>}}}
844
+ \\newcommand{\\slash}{{/}}
845
+ \\newcommand{\\underscore}{\\_}
846
+ \\newcommand{\\exclaim}{\\Verbatim{!}}
847
+ #{tex_codeblock}
848
+ % (tilde hash amp affected by http)
849
+ % \\sloppy
850
+ \\begin{document}
851
+ WOK
852
+ @copymark='' #check and remove as now is superflous
853
+ x={}
854
+ txt_obj={ title: @md.title.full }
855
+ if @md.opt.act[:pdf_l][:set]==:on
856
+ x[:l]=SiSU_TeX_Pdf::FormatTextObject.new(@md,txt_obj).title_landscape
857
+ end
858
+ if @md.opt.act[:pdf_p][:set]==:on
859
+ x[:p]=SiSU_TeX_Pdf::FormatTextObject.new(@md,txt_obj).title_portrait
860
+ end
861
+ @tex_file << x
862
+ x=nil
863
+ if defined? @md.creator.author \
864
+ and @md.creator.author
865
+ sp_char=SiSU_TeX_Pdf::SpecialCharacters.new(@md,@md.creator.author)
866
+ author=sp_char.special_characters
867
+ @tex_file << if @md.author_home
868
+ <<-WOK
869
+
870
+ \\author{\\href{#{@md.author_home}}{#{@copymark} \\textnormal{#{author}}}}
871
+ WOK
872
+ else "\n\\author{#{@copymark} \\textnormal{#{author}}}"
873
+ end
874
+ end
875
+ if defined? @md.make.cover_image \
876
+ and not @md.make.cover_image.nil? \
877
+ and @md.make.cover_image[:cover] =~/\S+/
878
+ x={}
879
+ dir=SiSU_Env::InfoEnv.new(@md.fns)
880
+ x[:l] =<<-WOK
881
+ \\titlepic{\\includegraphics[width=0.3\\textwidth]{#{dir.path.image_source_include}/#{@md.make.cover_image[:cover]}}}
882
+ WOK
883
+ x[:p] =<<-WOK
884
+ \\titlepic{\\includegraphics[width=0.6\\textwidth]{#{dir.path.image_source_include}/#{@md.make.cover_image[:cover]}}}
885
+ WOK
886
+ @tex_file << x
887
+ x=nil
888
+ end
889
+ @tex_file << unless @md.fnb =~/^mail\s*$/ then @tex_ml.site
890
+ else '\date'
891
+ end
892
+ @tex_file << <<-WOK
893
+ \\pagenumbering{roman}\\maketitle
894
+ \\pagestyle{fancy}
895
+ WOK
896
+ if defined? @md.rights.all \
897
+ and @md.rights.all
898
+ @tex_file << "\\newpage\n"
899
+ @tex_file << @@rights
900
+ @tex_file << @@prefix_b if defined? @md.creator.prefix_b and @md.creator.prefix_b
901
+ end
902
+ x={}
903
+ if (@make.build.toc?)
904
+ toc=<<-WOK
905
+ \\renewcommand{\\contentsname}{#{@translate.contents}}
906
+ \\tableofcontents
907
+ WOK
908
+ toc_pb={ l: @tex_ml.newpage(:landscape), p: @tex_ml.newpage(:portrait) }
909
+ else
910
+ toc=''
911
+ toc_pb={ l: '', p: '' }
912
+ end
913
+ if @md.opt.act[:pdf_l][:set]==:on
914
+ x[:l] =<<-WOK
915
+ #{@tex_ml.newpage(:landscape)}
916
+ \\pagestyle{fancy}
917
+ #{toc}#{toc_pb[:l]}
918
+ \\pagenumbering{arabic}
919
+ #{@tex_ml.paraskip_normal}
920
+ #{@tex_ml.newpage(:landscape)}
921
+ WOK
922
+ end
923
+ if @md.opt.act[:pdf_p][:set]==:on
924
+ x[:p] =<<-WOK
925
+ #{@tex_ml.newpage(:portrait)}
926
+ \\pagestyle{fancy}
927
+ #{toc}#{toc_pb[:p]}
928
+ #{@tex_ml.newpage(:portrait)}
929
+ \\pagenumbering{arabic}
930
+ #{@tex_ml.paraskip_normal}
931
+ #{@tex_ml.newpage(:portrait)}
932
+ WOK
933
+ end
934
+ @tex_file << x
935
+ x=nil
936
+ data.each do |dob| #% case follows with levels 1-6 indents & graphics
937
+ if dob.is_a?(Hash)
938
+ elsif dob.of==:para \
939
+ || dob.of==:block #GATEWAY FIX FIX stuff
940
+ dob=markup_common(dob)
941
+ elsif dob.is==:table
942
+ if ( dob.tmp['a4'] \
943
+ or dob.tmp['a5'] \
944
+ or dob.tmp['b5'] \
945
+ or dob.tmp['letter'] \
946
+ or dob.tmp['legal'])
947
+ @md.papersize_array.each do |ps|
948
+ if dob.tmp[ps]
949
+ if (dob.tmp[ps][:p] and dob.tmp[ps][:l])
950
+ dob.tmp[ps]={
951
+ p: markup_common(dob.tmp[ps][:p]),
952
+ l: markup_common(dob.tmp[ps][:l])
953
+ }
954
+ else p "#{__FILE__}:#{__LINE__}" if @md.opt.act[:maintenance][:set]==:on
955
+ end
956
+ end
957
+ end
958
+ elsif dob.tmp.is_a?(Hash) \
959
+ and (dob.tmp[:p] and dob.tmp[:l])
960
+ dob = {
961
+ p: markup_common(dob.tmp[:p]),
962
+ l: markup_common(dob.tmp[:l])
963
+ }
964
+ else p "#{__FILE__}:#{__LINE__}" if @md.opt.act[:maintenance][:set]==:on
965
+ end
966
+ end
967
+ @tex_file << dob
968
+ end
969
+ @st[:tex][:stmp]||=@md.stmpd
970
+ stamp=@st[:tex][:stmp] if @st[:tex][:stmp]
971
+ if stamp
972
+ use=stamp.gsub(/\n/,"#{Tex[:backslash]*2}\n")
973
+ @tex_file << "\n\\newpage\n"
974
+ @tex_file << "\\section*" +
975
+ "{#{@tex_ml.owner_chapter}}\n" +
976
+ "\\addcontentsline{toc}" +
977
+ "{section}{#{@tex_ml.owner_chapter}}\n"
978
+ @tex_file << "#{use}\n"
979
+ @tex_file << @@rights if @@rights
980
+ end
981
+ @tex_file << "\n\\end{document}"
982
+ end
983
+ def number_paras_numbering(dob) # need tables and other types of object
984
+ if dob.of ==:para
985
+ paranum=dob.ocn ? dob.ocn : ''
986
+ paranum = '' if paranum.to_i==0
987
+ paranumber_display=if @make.build.ocn?
988
+ tags=''
989
+ #[keep] code that follows inserts "name tags" as hypertargets, currently using ocn (converting nametags to ocn) for internal linking, related code: |texpdf_format.rb|@|uses nametags directly|
990
+ #if dob.tags.length > 0 # insert tags "hypertargets"
991
+ # dob.tags.each do |t|
992
+ # tags=tags +"\\hspace{0mm}\\hypertarget{#{t}}{\\hspace{0mm}}"
993
+ # end
994
+ #end
995
+ "\\begin{tiny}\\hspace{0mm}\\end{tiny}{\\marginpar{\\begin{tiny}\\hspace{0mm}\\hypertarget{#{dob.ocn}}{#{dob.ocn}}#{tags}\\end{tiny}}}" #ocn object citation numbering
996
+ else ''
997
+ end
998
+ dob.tmp = paranumber_display + dob.tmp
999
+ end
1000
+ dob
1001
+ end
1002
+ def number_paras(data)
1003
+ data.each do |dob|
1004
+ dob=if dob.is_a?(Hash)
1005
+ if ( dob['a4'] \
1006
+ or dob['a5'] \
1007
+ or dob['b5'] \
1008
+ or dob['letter'] \
1009
+ or dob['legal'])
1010
+ para_hash={}
1011
+ @md.papersize_array.each do |ps|
1012
+ if defined? dob.tmp and dob.tmp[ps]
1013
+ if (dob.tmp[ps][:p] and dob.tmp[ps][:l])
1014
+ para_hash[ps]={
1015
+ p: number_paras_numbering(dob.tmp[ps][:p]),
1016
+ l: number_paras_numbering(dob.tmp[ps][:l])
1017
+ }
1018
+ dob.tmp=para_hash
1019
+ else p "#{__FILE__}:#{__LINE__}" if @md.opt.act[:maintenance][:set]==:on
1020
+ end
1021
+ end
1022
+ end
1023
+ elsif (dob.tmp[:p] and dob.tmp[:l])
1024
+ dob.tmp = {
1025
+ p: number_paras_numbering(dob.tmp[:p]),
1026
+ l: number_paras_numbering(dob.tmp[:l])
1027
+ }
1028
+ else p "#{__FILE__}:#{__LINE__}" if @md.opt.act[:maintenance][:set]==:on
1029
+ end
1030
+ else
1031
+ dob=if dob.of !=:comment \
1032
+ || dob.of !=:meta \
1033
+ || dob.of !=:layout
1034
+ number_paras_numbering(dob)
1035
+ else dob
1036
+ end
1037
+ end
1038
+ end
1039
+ data
1040
+ end
1041
+ def output_morph_hash(o)
1042
+ ps,h,fn=o[:ps],o[:h],o[:filename]
1043
+ if h[ps] \
1044
+ and (h[ps][:p] or h[ps][:l])
1045
+ if @md.opt.act[:pdf_p][:set]==:on
1046
+ if h[ps][:p]
1047
+ h[ps][:p]=h[ps][:p].gsub(/[ ]+$/m,'').
1048
+ gsub(/\n\n\n+/m,"\n\n")
1049
+ end
1050
+ if h[ps][:p] !~/\A\s*\Z/
1051
+ fn[:portrait].puts h[ps][:p],"\n"
1052
+ end
1053
+ end
1054
+ if @md.opt.act[:pdf_l][:set]==:on
1055
+ if h[ps][:l]
1056
+ h[ps][:l]=h[ps][:l].gsub(/[ ]+$/m,'').
1057
+ gsub(/\n\n\n+/m,"\n\n")
1058
+ end
1059
+ if h[ps][:l] !~/\A\s*\Z/
1060
+ fn[:landscape].puts h[ps][:l],"\n"
1061
+ end
1062
+ end
1063
+ elsif (h[:p] or h[:l])
1064
+ if @md.opt.act[:pdf_p][:set]==:on
1065
+ if h[:p]
1066
+ h[:p]=h[:p].gsub(/[ ]+$/m,'').
1067
+ gsub(/\n\n\n+/m,"\n\n")
1068
+ end
1069
+ if h[:p] !~/\A\s*\Z/
1070
+ fn[:portrait].puts h[:p],"\n"
1071
+ end
1072
+ end
1073
+ if @md.opt.act[:pdf_l][:set]==:on
1074
+ if h[:l]
1075
+ h[:l]=h[:l].gsub(/[ ]+$/m,'').
1076
+ gsub(/\n\n\n+/m,"\n\n")
1077
+ end
1078
+ if h[:l] !~/\A\s*\Z/
1079
+ fn[:landscape].puts h[:l],"\n"
1080
+ end
1081
+ end
1082
+ else p "#{__FILE__}:#{__LINE__}" if @md.opt.act[:maintenance][:set]==:on
1083
+ end
1084
+ end
1085
+ def output(array)
1086
+ @array=array=array.flatten.compact
1087
+ fns=@md.fns.gsub(/~/,'-') #this is a sorry fix, but necessary as it appears latex programs like not ~
1088
+ @md.papersize_array.each do |ps|
1089
+ texfile_landscape=(@md.opt.act[:pdf_l][:set]==:on) \
1090
+ ? (File.new("#{@env.processing_path.tex}/#{fns}.#{ps}.landscape.tex",'w+'))
1091
+ : nil
1092
+ texfile_portrait=(@md.opt.act[:pdf_p][:set]==:on) \
1093
+ ? (File.new("#{@env.processing_path.tex}/#{fns}.#{ps}.tex",'w+'))
1094
+ : nil
1095
+ file={
1096
+ landscape: texfile_landscape,
1097
+ portrait: texfile_portrait
1098
+ }
1099
+ if @md.opt.act[:pdf_p][:set]==:on
1100
+ file[:portrait] << @@tex_head[ps][:p]
1101
+ end
1102
+ if @md.opt.act[:pdf_l][:set]==:on
1103
+ file[:landscape] << @@tex_head[ps][:l]
1104
+ end
1105
+ array.each do |morph|
1106
+ if morph.is_a?(String)
1107
+ #morph.gsub!(/^\s+/,'')
1108
+ if morph !~/\A\s*\Z/
1109
+ if @md.opt.act[:pdf_p][:set]==:on
1110
+ file[:portrait].puts morph,"\n"
1111
+ end
1112
+ if @md.opt.act[:pdf_l][:set]==:on
1113
+ file[:landscape].puts morph,"\n"
1114
+ end
1115
+ end
1116
+ elsif morph.class.inspect =~ /SiSU_AO_DocumentStructure/ \
1117
+ and morph.tmp \
1118
+ and morph.tmp.is_a?(String)
1119
+ if morph.is !=:code \
1120
+ && morph.of !=:block
1121
+ morph.tmp=morph.tmp.gsub(/^\s+/,'')
1122
+ else morph.tmp
1123
+ end
1124
+ if (morph.tmp !~/\A\s*\Z/) \
1125
+ || morph.is==:code
1126
+ if @md.opt.act[:pdf_p][:set]==:on
1127
+ file[:portrait].puts morph.tmp,"\n"
1128
+ end
1129
+ if @md.opt.act[:pdf_l][:set]==:on
1130
+ file[:landscape].puts morph.tmp,"\n"
1131
+ end
1132
+ end
1133
+ elsif morph.is_a?(Hash) #inserted headers and the like, only
1134
+ h={ ps: ps, h: morph, filename: file }
1135
+ output_morph_hash(h)
1136
+ elsif morph.tmp.is_a?(Hash) #tables & images?
1137
+ h={ ps: ps, h: morph.tmp, filename: file }
1138
+ output_morph_hash(h)
1139
+ end
1140
+ end
1141
+ array=@array
1142
+ if @md.opt.act[:pdf_p][:set]==:on
1143
+ file[:portrait].close
1144
+ end
1145
+ if @md.opt.act[:pdf_l][:set]==:on
1146
+ file[:landscape].close
1147
+ end
1148
+ end
1149
+ @@tex_head={
1150
+ 'a4'=> { p: nil, l: nil },
1151
+ 'a5'=> { p: nil, l: nil },
1152
+ 'b5'=> { p: nil, l: nil },
1153
+ 'letter'=>{ p: nil, l: nil },
1154
+ 'legal'=> { p: nil, l: nil },
1155
+ 'book'=> { p: nil, l: nil }
1156
+ }
1157
+ array=[]
1158
+ end
1159
+ end
1160
+ end
1161
+ end
1162
+ __END__