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,1689 @@
1
+ # encoding: utf-8
2
+ =begin
3
+
4
+ * Name: SiSU
5
+
6
+ ** Description: documents, structuring, processing, publishing, search
7
+ *** LaTeX formatting template, unicode utf-8 version, used for pdf
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_format.rb;hb=HEAD>
55
+
56
+ =end
57
+ module SiSU_TeX_Pdf
58
+ require_relative 'texpdf_parts' # texpdf_parts.rb
59
+ @@table_pg_break_counter=1
60
+ class BareUrls
61
+ include SiSU_Parts_TeXpdf
62
+ def initialize(md,dob=nil)
63
+ @md,@dob=md,dob
64
+ end
65
+ def bare_urls
66
+ @dob.obj=@dob.obj.gsub(/#{Mx[:url_o]}([a-zA-Z0-9._-]+\@[a-zA-Z0-9_-]+?\.[a-zA-Z0-9._-]+)#{Mx[:url_c]}/,
67
+ "#{url_decoration.tex_open}\\begin{scriptsize}\\email{\\1}#{url_decoration.tex_close}")
68
+ @dob.tmp=@dob.tmp.gsub(/(^|[^\\])_/m,'\1\_'). #watch may not work
69
+ gsub(/(^|[^#{Mx[:lnk_c]}])#{Mx[:url_o]}_?(?:\\?_)?(\S+?)#{Mx[:url_c]}/m,
70
+ "\\1#{url_decoration.tex_open}\\begin{scriptsize}\\url{\\2}\\end{scriptsize}#{url_decoration.tex_close}")
71
+ @dob
72
+ end
73
+ def bare_urls_in_code
74
+ @dob.tmp=@dob.tmp.gsub(/(^|[^\\])_/m,'\1\_'). #watch may not work
75
+ gsub(/(https?:\/\/\S+?)([{]|[.,;)\]]?(?: |$))/m,
76
+ '\begin{scriptsize}\url{\1}\end{scriptsize}\2')
77
+ @dob
78
+ end
79
+ end
80
+ class FormatTextObject
81
+ include SiSU_Parts_TeXpdf
82
+ attr_accessor :string,:string1,:orientation,:url,:dir,:tex
83
+ @@sys=SiSU_Env::SystemCall.new
84
+ @@tex_pattern_margin_number=/\\begin\{tiny\}\\hspace\{0mm\}\\end\{tiny\}\{\\marginpar.+?\}\}\}/
85
+ @@tableheader={
86
+ 'a4' => { p: 0, l: 0 },
87
+ 'a5' => { p: 0, l: 0 },
88
+ 'b5' => { p: 0, l: 0 },
89
+ 'letter' => { p: 0, l: 0 },
90
+ 'legal' => { p: 0, l: 0 }
91
+ }
92
+ @@sys=SiSU_Env::SystemCall.new
93
+ def initialize(md,dob=nil)
94
+ @md,@dob=md,dob
95
+ if defined? @md.image \
96
+ and @md.image =~/center/
97
+ @center_begin,@center_end='\begin{center}','\end{center}'
98
+ else @center_begin,@center_end='',''
99
+ end
100
+ @start_table=''
101
+ @tx=SiSU_Env::GetInit.new.tex
102
+ @env ||=SiSU_Env::InfoEnv.new(@md.fns)
103
+ @tex2pdf=@@tex3pdf ||=SiSU_Env::SystemCall.new.tex2pdf_engine
104
+ @make ||=SiSU_Env::ProcessingSettings.new(@md)
105
+ end
106
+ def ocn_display(dob)
107
+ show_ocn=(@make.build.ocn?) \
108
+ ? dob.ocn
109
+ : ''
110
+ "\\begin{tiny}\\hspace{0mm}\\end{tiny}{\\marginpar{\\begin{tiny}\\hspace{0mm}\\hypertarget{#{dob.ocn}}{#{show_ocn}}\\end{tiny}}}" #ocn object citation numbering
111
+ end
112
+ def table_special_characters(r)
113
+ r=r.gsub(/#{Mx[:tc_p]}/mu,'&').
114
+ gsub(/#{Mx[:tc_c]}/m,'\\\\\\').
115
+ gsub(/%/,'\%').
116
+ gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'\begin{bfseries}\1 \end{bfseries}').
117
+ gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'\emph{\1}').
118
+ gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'\uline{\1}'). # ulem
119
+ gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,"``\\1''"). # quote #CHECK
120
+ gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'\uline{\1}'). # ulem
121
+ gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'\sout{\1}'). # ulem
122
+ gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,"\$^{\\textrm{\\1}}\$").
123
+ gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,"\$_{\\textrm{\\1}}\$")
124
+ end
125
+ def longtable_landscape
126
+ end_table='\end{longtable}'
127
+ row_break='\\\\\\'
128
+ if @dob.is==:table
129
+ tw=case @dob.tmp[:paper_size]
130
+ when /a4/i then @tx.a4.landscape.w #European default, SiSU default
131
+ when /letter/i then @tx.letter.landscape.w #U.S. default
132
+ when /legal/i then @tx.legal.landscape.w #U.S. alternative
133
+ when /book|b5/i then @tx.b5.landscape.w #book default - larger
134
+ when /a5/i then @tx.a5.landscape.w
135
+ else @tx.a4.landscape.w #default currently A4
136
+ end
137
+ textwidth=(tw.to_i/2) - 24
138
+ colW=[]
139
+ colW << '{'
140
+ @dob.widths.each do |x|
141
+ x=(x.to_i * textwidth)/100
142
+ col_w=x.to_s # x.gsub(/.+/,'l\|') #unless x.nil?
143
+ colW << "p{#{col_w}mm}" if col_w
144
+ end
145
+ colW << '}'
146
+ colW=colW.join
147
+ start_table="\n\\setlength{\\LTleft}{0pt}\n\\setlength{\\LTright}{\\fill}\n" +
148
+ "\\begin{tiny}\n\\begin{longtable}#{colW}\n"
149
+ rows=@dob.obj.split(/#{Mx[:br_nl]}/)
150
+ if @dob.head_ #result imperfect, check on
151
+ rows[0]=rows[0].gsub(/(^|.+?)(?:#{Mx[:tc_p]}|$)/u,'\bfseries \1&').
152
+ gsub(/&\s*$/," #{row_break} \\hline\\endhead #{row_break}")
153
+ end
154
+ rows_new=[]
155
+ rows.each do |r|
156
+ r=table_special_characters(r)
157
+ r=r.gsub(/$/," #{row_break}\n") unless r =~/#{row_break*2}$/
158
+ if r=~/\<!f(.+?)!\>/ # not tested table footer if any
159
+ tablefoot=$1
160
+ r=r.gsub(/\<!f(.+?)!\>/,'')
161
+ r="#{r} \\multicolumn{#{@dob.cols}}{l}{\\tiny #{tablefoot}} \\\\ \\hline\n\\endfoot\n\\hline\n"
162
+ end
163
+ rows_new << r
164
+ end
165
+ table=rows_new.join #@dob[:ao].obj=rows.join
166
+ ocn_display(@dob) + start_table + table + " #{end_table}\n\\end{tiny}"
167
+ else ''
168
+ end
169
+ end
170
+ def longtable_portrait
171
+ end_table='\end{longtable}'
172
+ row_break='\\\\\\'
173
+ if @dob.is==:table
174
+ tw=case @dob.tmp[:paper_size]
175
+ when /a4/i then @tx.a4.portrait.w #European default, SiSU default
176
+ when /letter/i then @tx.letter.portrait.w #U.S. default
177
+ when /legal/i then @tx.legal.portrait.w #U.S. alternative
178
+ when /book|b5/i then @tx.b5.portrait.w #book default - larger
179
+ when /a5/i then @tx.a5.portrait.w
180
+ else @tx.a4.portrait.w #default currently A4
181
+ end
182
+ textwidth=tw.to_i - 20
183
+ colW=[]
184
+ colW << '{'
185
+ @dob.widths.each do |x|
186
+ x=(x.to_i * textwidth)/100 #x=(x.to_i/100.0 * 160)
187
+ col_w=x.to_s # x.gsub(/.+/,'l\|') #unless x.nil?
188
+ colW << "p{#{col_w}mm}" if col_w
189
+ end
190
+ colW << '}'
191
+ colW=colW.join
192
+ start_table="\n\\setlength{\\LTleft}{0pt}\n\\setlength{\\LTright}{\\fill}\n" +
193
+ "\\begin{tiny}\n\\begin{longtable}#{colW}\n"
194
+ rows=@dob.obj.split(/#{Mx[:br_nl]}/)
195
+ if @dob.head_
196
+ rows[0]=rows[0].gsub(/(^|.+?)(?:#{Mx[:tc_p]}|$)/u,'\bfseries \1&').
197
+ gsub(/&\s*$/," #{row_break} \\hline\\endhead #{row_break}")
198
+ end
199
+ rows_new=[]
200
+ rows.each do |r|
201
+ r=table_special_characters(r)
202
+ r=r.gsub(/$/," #{row_break}\n") unless r =~/#{row_break*2}$/
203
+ if r=~/\<!f(.+?)!\>/ # not tested table footer if any
204
+ tablefoot=$1
205
+ r=r.gsub(/\<!f(.+?)!\>/,'')
206
+ r="#{r} \\multicolumn{#{@dob.cols}}{l}{\\tiny #{tablefoot}} \\\\ \\hline\n\\endfoot\n\\hline\n"
207
+ end
208
+ rows_new << r
209
+ end
210
+ table=rows_new.join #@dob[:ao].obj=rows.join
211
+ ocn_display(@dob) + start_table + table + " #{end_table}\n\\end{tiny}"
212
+ else ''
213
+ end
214
+ end
215
+ def remove_footnotes(cont_ln)
216
+ cont_ln=if cont_ln =~/\\[Ff]ootnote/m
217
+ cont_ln.gsub(/\s*\\[Ff]ootnote\[\d+\]\{%\s+.+?\}\s*/m,' ').
218
+ gsub(/\s*\\[Ff]ootnote[A]\{[*+]+\d*\}\{%\S+.+?\}\s*/m,' ')
219
+ else cont_ln
220
+ end
221
+ end
222
+ def title_level_A
223
+ dob=@dob
224
+ dob.tmp=dob.tmp.strip if dob.tmp
225
+ dob.tmp=dob.tmp.gsub(/\\begin\{(bfseries|itshape)\}(.+?)\\end\{\1\}/m,'\2').
226
+ gsub(/#{Mx[:url_o]}|#{Mx[:url_c]}/,'')
227
+ cont_ln=dob.tmp.dup
228
+ cont_ln=cont_ln.gsub(/\\begin\{(monosp)\}(.+?)\\end\{\1\}/m,'\2').
229
+ gsub(@@tex_pattern_margin_number,'')
230
+ cont_ln=remove_footnotes(cont_ln)
231
+ cont_ln=cont_ln.gsub(/\{[\\]+(&)\}/,'\\1')
232
+ titleset=''
233
+ dob.tmp=dob.tmp.gsub(/^(.*)\n?$/m,
234
+ "#{titleset}\\part*{\\1}
235
+ \\markboth{#{@md.title.full}}\n")
236
+ dob
237
+ end
238
+ def section_heading_level(dob)
239
+ dob.tmp=dob.tmp.strip if dob.tmp
240
+ dob.tmp=dob.tmp.gsub(/\\begin\{(bfseries|itshape)\}(.+?)\\end\{\1\}/m,'\2').
241
+ gsub(/#{Mx[:url_o]}|#{Mx[:url_c]}/,'')
242
+ cont_ln=dob.tmp.dup
243
+ cont_ln=cont_ln.gsub(/\\begin\{(monosp)\}(.+?)\\end\{\1\}/m,'\2').
244
+ gsub(@@tex_pattern_margin_number,'')
245
+ cont_ln=remove_footnotes(cont_ln)
246
+ cont_ln=cont_ln.gsub(/\{[\\]+(&)\}/,'\\1')
247
+ dob.tmp=dob.tmp.gsub(/^(.*)\n?$/m,
248
+ "\\clearpage
249
+ \\part*{\\1}
250
+ \\addcontentsline{toc}{part}{#{cont_ln}}
251
+ \\markboth{#{@md.title.full}}\n")
252
+ dob
253
+ end
254
+ def heading_dev_null(dob)
255
+ dob.tmp,dob.obj='',''
256
+ dob
257
+ end
258
+ def heading_sublevels(dob)
259
+ if dob.lv=='1'
260
+ sect='section'
261
+ tocadd=%{\\addcontentsline{toc}{section}}
262
+ pre=''
263
+ post=''
264
+ headadd=%{\n\\markright{#{@md.title.full}}}
265
+ elsif dob.lv=='2'
266
+ sect='subsection'
267
+ tocadd=%{\\addcontentsline{toc}{subsection}}
268
+ pre=''
269
+ post=" \\\\\n"
270
+ headadd=''
271
+ elsif dob.lv=='3'
272
+ sect='subsubsection'
273
+ tocadd=%{\\addcontentsline{toc}{subsubsection}}
274
+ pre='' #pre='~~~~'
275
+ post=" \\\\\n"
276
+ headadd=''
277
+ end
278
+ dob.tmp=dob.tmp.strip if dob.tmp
279
+ dob.tmp=dob.tmp.gsub(/\\begin\{(bfseries|itshape)\}(.+?)\\end\{\1\}/m,'\2').
280
+ gsub(/#{Mx[:url_o]}|#{Mx[:url_c]}/,'')
281
+ cont_ln=dob.tmp.dup
282
+ cont_ln=cont_ln.gsub(/\\begin\{(monosp)\}(.+?)\\end\{\1\}/m,'\2').
283
+ gsub(@@tex_pattern_margin_number,'').
284
+ gsub(/#{Tex[:backslash]*2}/,"#{Tex[:backslash]*4}"). # added w42
285
+ gsub(/\\footnote\[\d+\]\{%.+?\\end\{scriptsize\}\s*\}/m,''). #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22
286
+ gsub(/\\Footnote[A]\{[*+]+\d*\}\{%.+?\\end\{scriptsize\}\s*\}/m,'') #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22
287
+ if dob.name =~/endnotes/
288
+ dob.tmp=dob.tmp.gsub(/.+/m,'')
289
+ end
290
+ cont_ln=remove_footnotes(cont_ln)
291
+ cont_ln=cont_ln.gsub(/\{[\\]+(&)\}/,'\\1')
292
+ dob.tmp=dob.tmp.gsub(/^(.*)?\n?$/m,
293
+ "\\#{sect}*{\\1}
294
+ #{tocadd}{#{pre}#{cont_ln}#{post}}#{headadd}")
295
+ dob
296
+ end
297
+ def section_heading_level_B
298
+ section_heading_level(@dob)
299
+ end
300
+ def section_heading_level_C
301
+ section_heading_level(@dob)
302
+ end
303
+ def section_heading_level_D
304
+ section_heading_level(@dob)
305
+ end
306
+ def heading_level_1
307
+ if not @dob.use_ == :dummy
308
+ heading_sublevels(@dob)
309
+ else
310
+ heading_dev_null(@dob)
311
+ end
312
+ end
313
+ def heading_level_2
314
+ heading_sublevels(@dob)
315
+ end
316
+ def heading_level_3
317
+ heading_sublevels(@dob)
318
+ end
319
+ def heading_level_4
320
+ heading_sublevels(@dob)
321
+ end
322
+ def hang
323
+ case @dob.indent
324
+ when /0/
325
+ case @dob.hang
326
+ when /0/ then indent,hang='0mm', '0mm'
327
+ when /1/ then indent,hang='0mm','10mm'
328
+ when /2/ then indent,hang='0mm','20mm'
329
+ when /3/ then indent,hang='0mm','30mm'
330
+ when /4/ then indent,hang='0mm','40mm'
331
+ when /5/ then indent,hang='0mm','50mm'
332
+ when /6/ then indent,hang='0mm','60mm'
333
+ when /7/ then indent,hang='0mm','70mm'
334
+ when /8/ then indent,hang='0mm','80mm'
335
+ when /9/ then indent,hang='0mm','90mm'
336
+ end
337
+ when /1/
338
+ case @dob.hang
339
+ when /0/ then indent,hang='10mm','-10mm'
340
+ when /1/ then indent,hang='10mm', '0mm'
341
+ when /2/ then indent,hang='10mm', '10mm'
342
+ when /3/ then indent,hang='10mm', '20mm'
343
+ when /4/ then indent,hang='10mm', '30mm'
344
+ when /5/ then indent,hang='10mm', '40mm'
345
+ when /6/ then indent,hang='10mm', '50mm'
346
+ when /7/ then indent,hang='10mm', '60mm'
347
+ when /8/ then indent,hang='10mm', '70mm'
348
+ when /9/ then indent,hang='10mm', '80mm'
349
+ end
350
+ when /2/
351
+ case @dob.hang
352
+ when /0/ then indent,hang='20mm','-20mm'
353
+ when /1/ then indent,hang='20mm','-10mm'
354
+ when /2/ then indent,hang='20mm', '0mm'
355
+ when /3/ then indent,hang='20mm', '10mm'
356
+ when /4/ then indent,hang='20mm', '20mm'
357
+ when /5/ then indent,hang='20mm', '30mm'
358
+ when /6/ then indent,hang='20mm', '40mm'
359
+ when /7/ then indent,hang='20mm', '50mm'
360
+ when /8/ then indent,hang='20mm', '60mm'
361
+ when /9/ then indent,hang='20mm', '70mm'
362
+ end
363
+ when /3/
364
+ case @dob.hang
365
+ when /0/ then indent,hang='30mm','-30mm'
366
+ when /1/ then indent,hang='30mm','-20mm'
367
+ when /2/ then indent,hang='30mm','-10mm'
368
+ when /3/ then indent,hang='30mm', '0mm'
369
+ when /4/ then indent,hang='30mm', '10mm'
370
+ when /5/ then indent,hang='30mm', '20mm'
371
+ when /6/ then indent,hang='30mm', '30mm'
372
+ when /7/ then indent,hang='30mm', '40mm'
373
+ when /8/ then indent,hang='30mm', '50mm'
374
+ when /9/ then indent,hang='30mm', '60mm'
375
+ end
376
+ when /4/
377
+ case @dob.hang
378
+ when /0/ then indent,hang='40mm','-40mm'
379
+ when /1/ then indent,hang='40mm','-30mm'
380
+ when /2/ then indent,hang='40mm','-20mm'
381
+ when /3/ then indent,hang='40mm','-10mm'
382
+ when /4/ then indent,hang='40mm', '0mm'
383
+ when /5/ then indent,hang='40mm', '10mm'
384
+ when /6/ then indent,hang='40mm', '20mm'
385
+ when /7/ then indent,hang='40mm', '30mm'
386
+ when /8/ then indent,hang='40mm', '40mm'
387
+ when /9/ then indent,hang='40mm', '50mm'
388
+ end
389
+ when /5/
390
+ case @dob.hang
391
+ when /0/ then indent,hang='50mm','-50mm'
392
+ when /1/ then indent,hang='50mm','-40mm'
393
+ when /2/ then indent,hang='50mm','-30mm'
394
+ when /3/ then indent,hang='50mm','-20mm'
395
+ when /4/ then indent,hang='50mm','-10mm'
396
+ when /5/ then indent,hang='50mm', '0mm'
397
+ when /6/ then indent,hang='50mm', '10mm'
398
+ when /7/ then indent,hang='50mm', '20mm'
399
+ when /8/ then indent,hang='50mm', '30mm'
400
+ when /9/ then indent,hang='50mm', '40mm'
401
+ end
402
+ when /6/
403
+ case @dob.hang
404
+ when /0/ then indent,hang='60mm','-60mm'
405
+ when /1/ then indent,hang='60mm','-50mm'
406
+ when /2/ then indent,hang='60mm','-40mm'
407
+ when /3/ then indent,hang='60mm','-30mm'
408
+ when /4/ then indent,hang='60mm','-20mm'
409
+ when /5/ then indent,hang='60mm','-10mm'
410
+ when /6/ then indent,hang='60mm', '0mm'
411
+ when /7/ then indent,hang='60mm', '10mm'
412
+ when /8/ then indent,hang='60mm', '20mm'
413
+ when /9/ then indent,hang='60mm', '30mm'
414
+ end
415
+ when /7/
416
+ case @dob.hang
417
+ when /0/ then indent,hang='70mm','-70mm'
418
+ when /1/ then indent,hang='70mm','-60mm'
419
+ when /2/ then indent,hang='70mm','-50mm'
420
+ when /3/ then indent,hang='70mm','-40mm'
421
+ when /4/ then indent,hang='70mm','-30mm'
422
+ when /5/ then indent,hang='70mm','-20mm'
423
+ when /6/ then indent,hang='70mm','-10mm'
424
+ when /7/ then indent,hang='70mm', '0mm'
425
+ when /8/ then indent,hang='70mm', '10mm'
426
+ when /9/ then indent,hang='70mm', '20mm'
427
+ end
428
+ when /8/
429
+ case @dob.hang
430
+ when /0/ then indent,hang='80mm','-80mm'
431
+ when /1/ then indent,hang='80mm','-70mm'
432
+ when /2/ then indent,hang='80mm','-60mm'
433
+ when /3/ then indent,hang='80mm','-50mm'
434
+ when /4/ then indent,hang='80mm','-40mm'
435
+ when /5/ then indent,hang='80mm','-30mm'
436
+ when /6/ then indent,hang='80mm','-20mm'
437
+ when /7/ then indent,hang='80mm','-10mm'
438
+ when /8/ then indent,hang='80mm', '0mm'
439
+ when /9/ then indent,hang='80mm', '10mm'
440
+ end
441
+ when /9/
442
+ case @dob.hang
443
+ when /0/ then indent,hang='90mm','-90mm'
444
+ when /1/ then indent,hang='90mm','-80mm'
445
+ when /2/ then indent,hang='90mm','-70mm'
446
+ when /3/ then indent,hang='90mm','-60mm'
447
+ when /4/ then indent,hang='90mm','-50mm'
448
+ when /5/ then indent,hang='90mm','-40mm'
449
+ when /6/ then indent,hang='90mm','-30mm'
450
+ when /7/ then indent,hang='90mm','-20mm'
451
+ when /8/ then indent,hang='90mm','-10mm'
452
+ when /9/ then indent,hang='90mm', '0mm'
453
+ end
454
+ end
455
+ "\\begin{ParagraphHang}{#{indent}}{#{hang}}#{@dob.tmp} \\end{ParagraphHang}}"
456
+ end
457
+ def indent
458
+ indent=case @dob.indent
459
+ when /1/ then '0mm'
460
+ when /2/ then '10mm'
461
+ when /3/ then '20mm'
462
+ when /4/ then '30mm'
463
+ when /5/ then '40mm'
464
+ when /6/ then '50mm'
465
+ when /7/ then '60mm'
466
+ when /8/ then '70mm'
467
+ when /9/ then '80mm'
468
+ end
469
+ "\\begin{ParagraphIndent}{#{indent}}#{@dob.tmp} \\end{ParagraphIndent}}"
470
+ end
471
+ def bullet
472
+ blt=if @dob.indent
473
+ indent=case @dob.indent
474
+ when /1/ then '0em'
475
+ when /2/ then '1.0em'
476
+ when /3/ then '2.0em'
477
+ when /4/ then '3.0em'
478
+ when /5/ then '4.0em'
479
+ when /6/ then '5.0em'
480
+ when /7/ then '6.0em'
481
+ when /8/ then '7.0em'
482
+ when /9/ then '8.0em'
483
+ else '-1.0em'
484
+ end
485
+ "\\begin{Bullet}{#{indent}}$\\txtbullet$\\hspace{\\enspace}#{@dob.tmp}\\end{Bullet}"
486
+ else
487
+ "\\begin{Bullet}{-5mm}$\\txtbullet$\\hspace{\\enspace}#{@dob.tmp}\\end{Bullet}"
488
+ end
489
+ blt
490
+ end
491
+ def symbol_graphic
492
+ dir=SiSU_Env::InfoEnv.new(@md.fns)
493
+ image='c_' + /<:=\s*(\S+?)\s*>/m.match(@txt).captures.join + '.png' #watch
494
+ if FileTest.file?("#{dir.path.image_source_include}/#{image}")
495
+ @txt.gsub!(/<:=\s*(\S+?)\s*>/,
496
+ "\\includegraphics*[width=11pt]{#{dir.path.image_source_include}/c_\\1.png}")
497
+ else
498
+ SiSU_Screen::Ansi.new(
499
+ @md.opt.act[:color_state][:set],
500
+ "ERROR - image:",
501
+ %{"#{image}" missing},
502
+ "search path: #{dir.path.image_source_include}"
503
+ ).error2 unless @md.opt.act[:quiet][:set]==:on
504
+ @txt.gsub!(/#{Mx[:lnk_o]}\S+\.(png|jpg|gif).+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/,'') # fragile match operator\\ fragile !
505
+ end
506
+ end
507
+ def url_str_internal(str,idx=nil)
508
+ map_nametags=SiSU_Particulars::CombinedSingleton.instance.get_map_nametags(@md).nametags_map #p map_nametags
509
+ rgx_url_internal=/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:rel_o]}#?\S+?#{Mx[:rel_c]}/m
510
+ while str =~/#{Mx[:lnk_o]}([^#{Mx[:lnk_o]}#{Mx[:lnk_c]}]+)#{Mx[:lnk_c]}#{Mx[:rel_o]}:(\S+?)#{Mx[:rel_c]}/m
511
+ link,url=$1,$2
512
+ link,url=link.strip,url.strip
513
+ link.gsub!(/&/,"#{Xx[:protect]}&")
514
+ url="#{@env.url.root}/" + url
515
+ str.sub!(/#{Mx[:lnk_o]}[^#{Mx[:lnk_o]}#{Mx[:lnk_c]}]+#{Mx[:lnk_c]}#{Mx[:rel_o]}:\S+?#{Mx[:rel_c]}/m,
516
+ "#{url_decoration.tex_open}\\href{#{url}}{#{link}}#{url_decoration.tex_close}")
517
+ end
518
+ while str =~/#{Mx[:lnk_o]}([^#{Mx[:lnk_o]}#{Mx[:lnk_c]}]+)#{Mx[:lnk_c]}#{Mx[:rel_o]}#?(\S+?)#{Mx[:rel_c]}/m
519
+ link,url=$1,$2
520
+ link,url=link.strip,url.strip
521
+ link.gsub!(/&/,"#{Xx[:protect]}&")
522
+ url.gsub!(/\\_/,'_')
523
+ ocn_lnk=if map_nametags[url] \
524
+ and map_nametags[url][:ocn]
525
+ map_nametags[url][:ocn]
526
+ else nil
527
+ end
528
+ ocn_lnk=(url=~/^\d+$/ ? url : ocn_lnk)
529
+ if ocn_lnk and not ocn_lnk.empty?
530
+ idx \
531
+ ? (str.sub!(rgx_url_internal,"\\hyperlink{#{ocn_lnk}}{#{link}}"))
532
+ : (str.sub!(rgx_url_internal,"#{url_decoration.tex_open}\\hyperlink{#{ocn_lnk}}{#{link}}#{url_decoration.tex_close}"))
533
+ else
534
+ puts %{name tag: "#{url}" not found}
535
+ str.sub!(rgx_url_internal,"#{link}")
536
+ end
537
+ #[keep] code that follows uses nametags directly, currently nametags converted to their ocn, related code: |texpdf.rb|@|hypertargets|
538
+ #idx \
539
+ #? (str.sub!(rgx_url_internal,"\\hyperlink{#{url}}{#{link}}")) \
540
+ #: (str.sub!(rgx_url_internal,"#{url_decoration.tex_open}\\hyperlink{#{url}}{#{link}}#{url_decoration.tex_close}"))
541
+ end
542
+ str=str.gsub(/#{Xx[:protect]}/,'')
543
+ end
544
+ def url_str(str)
545
+ rgx_url_generic=/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/m
546
+ while str =~rgx_url_generic
547
+ if str=~rgx_url_generic
548
+ regx_url=%r/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/m
549
+ z,url=regx_url.match(str).captures if str =~regx_url
550
+ url=url.strip
551
+ link=z.strip
552
+ link.gsub!(/&/,"#{Xx[:protect]}&")
553
+ str.sub!(rgx_url_generic,"#{url_decoration.tex_open}\\href{#{url}}{#{link}}#{url_decoration.tex_close}")
554
+ str=str.gsub(/#{Xx[:protect]}/,'')
555
+ str
556
+ else str
557
+ end
558
+ str
559
+ end
560
+ str
561
+ end
562
+ def url_with_txt(dob)
563
+ rgx_url_generic=/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/m
564
+ while dob.tmp =~rgx_url_generic
565
+ if dob.tmp=~rgx_url_generic
566
+ if dob.tmp =~/#{Mx[:lnk_o]}(?:.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/m
567
+ regx_url=%r/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/m
568
+ punctuate=/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/m.match(dob.tmp).captures.join
569
+ else
570
+ regx_url=%r/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/m
571
+ punctuate=''
572
+ end
573
+ z,url=regx_url.match(dob.tmp).captures if dob.tmp =~regx_url
574
+ url=url.strip
575
+ link=z.strip
576
+ link.gsub!(/&/,"#{Xx[:protect]}&")
577
+ dob.tmp.sub!(rgx_url_generic,"#{url_decoration.tex_open}\\href{#{url}}{#{link}}#{url_decoration.tex_close}#{punctuate}")
578
+ dob.tmp.gsub!(/#{Xx[:protect]}/,'')
579
+ #dob.tmp=dob.tmp.sub(rgx_url_generic,"#{url_decoration.tex_open}\\href{#{url}}{#{link}}#{url_decoration.tex_close}#{punctuate}").
580
+ # gsub(/#{Xx[:protect]}/,'')
581
+ dob
582
+ else dob
583
+ end
584
+ dob
585
+ end
586
+ dob
587
+ end
588
+ def urls_txt_and_images
589
+ dob=@dob
590
+ dir=SiSU_Env::InfoEnv.new(@md.fns)
591
+ @dm={
592
+ 'a4'=> @tx.a4.landscape.img_px,
593
+ 'letter'=> @tx.letter.landscape.img_px,
594
+ 'legal'=> @tx.legal.landscape.img_px,
595
+ 'b5'=> @tx.b5.landscape.img_px,
596
+ 'a5'=> @tx.a5.landscape.img_px
597
+ }
598
+ images_hash={ }
599
+ generic_rgx=/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image\b)/m
600
+ rgx_url_generic=/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/m
601
+ #url_bare_rgx=/#{Mx[:url_o]}\S+?#{Mx[:url_c]}/m
602
+ url_image_rgx=/#{Mx[:lnk_o]}[a-zA-Z0-9_\\-]+\.(?:png|jpg|gif).+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/m
603
+ image_rgx=/#{Mx[:lnk_o]}[a-zA-Z0-9_\\-]+\.(?:png|jpg|gif).+?#{Mx[:lnk_c]}image/m
604
+ @md.papersize_array.each do |ps|
605
+ images_hash[ps] = dob.tmp
606
+ while images_hash[ps] =~generic_rgx
607
+ if dob.tmp =~rgx_url_generic \
608
+ and dob.tmp !~/\.(?:png|jpg|gif)|#{Mx[:lnk_c]}image\b/m
609
+ dob=url_with_txt(dob)
610
+ elsif images_hash[ps]=~generic_rgx
611
+ if dob.tmp=~rgx_url_generic
612
+ if images_hash[ps] =~/#{Mx[:lnk_o]}(?:.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/m
613
+ regx_url=%r/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/m
614
+ punctuate=/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/m.match(images_hash[ps]).captures.join
615
+ else
616
+ regx_url=%r/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/m
617
+ punctuate=''
618
+ end
619
+ z,url=regx_url.match(images_hash[ps]).captures if images_hash[ps] =~regx_url
620
+ url=url.strip
621
+ else
622
+ if images_hash[ps] =~/#{Mx[:lnk_o]}(?:.+?)#{Mx[:lnk_c]}image\.[^'"\s]+?(?:[;.,]?(?:\s|$)|(?:\s|$))/m
623
+ regx_url=%r/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}image\.[^'"\s]+?(?:[;.,]?(?:\s|$)|(?:\s|$))/m
624
+ punctuate=/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}image\.[^'"\s]+?([;.,]?(?:\s|$))/m.match(images_hash[ps]).captures.join
625
+ else
626
+ regx_url=%r/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}image/m
627
+ punctuate=''
628
+ end
629
+ z=regx_url.match(images_hash[ps])[1] if images_hash[ps] =~regx_url
630
+ url=''
631
+ end
632
+ if images_hash[ps] =~/#{Mx[:lnk_o]}\s*\S+\.?(?:png|jpg|gif)/m \
633
+ and images_hash[ps]=~/\s+\d+x\d+(\s+|\s*#{Mx[:lnk_c]})/m
634
+ image=z.scan(/\S+/)[0] #image,x,y=z.scan(/\S+/)
635
+ image.gsub!(/\\/,'')
636
+ w=((z =~/\s(\d+)x\d*/) ? z[/\s(\d+)x\d*/,1] : 200)
637
+ width={}
638
+ width['a4'] = ((w.to_i > @dm['a4']) ? @dm['a4'] : w)
639
+ width['letter'] = ((w.to_i > @dm['letter']) ? @dm['letter'] : w)
640
+ width['legal'] = ((w.to_i > @dm['legal']) ? @dm['legal'] : w)
641
+ width['a5'] = ((w.to_i > @dm['a5']) ? @dm['a5'] : w)
642
+ width['b5'] = ((w.to_i > @dm['b5']) ? @dm['b5'] : w)
643
+ c=z[/``(.+?)''/m,1]
644
+ hsp="\n{\\color{mywhite} .}&~\n" # ~ character for hardspace
645
+ caption=(c ? "{\\\\\ \n\\begin{scriptsize}#{hsp*3}#{c}\\end{scriptsize}&}" : '')
646
+ elsif images_hash[ps] =~/#{Mx[:lnk_o]}\s*(\S+\.?\.(?:png|jpg|gif))/m
647
+ SiSU_Screen::Ansi.new(
648
+ @md.opt.act[:color_state][:set],
649
+ %{document built without image: "#{$1}" as image dimensions not provided (either image not found or neither imagemagick nor graphicsmagick is installed)?\n}
650
+ ).print_grey #unless @md.opt.act[:quiet][:set]==:on
651
+ images_hash[ps].gsub!(/#{Mx[:lnk_o]}\s*(\S+\.?\.(?:png|jpg|gif))/,'[image]')
652
+ end
653
+ if image #most images fc etc. #% clean up !
654
+ if FileTest.file?("#{dir.path.image_source_include}/#{image}")
655
+ case images_hash[ps]
656
+ when url_image_rgx
657
+ images_hash[ps].sub!(url_image_rgx,
658
+ "#{@center_begin}\\\n\\href{#{url}}\n{\\includegraphics*[width=#{width[ps]}pt]{#{dir.path.image_source_include}/#{image}}}#{caption}#{@center_end}")
659
+ when image_rgx
660
+ images_hash[ps].sub!(image_rgx,
661
+ "#{@center_begin}\\\n\\includegraphics*[width=#{width[ps]}pt]{#{dir.path.image_source_include}/#{image}}#{caption}#{@center_end}")
662
+ end
663
+ images_hash[ps]
664
+ elsif @md.opt.f_pth[:pth] =~/\/\S+?\/sisupod\/\S+?\/sisupod\/doc/
665
+ pt=/(\/\S+?\/sisupod\/\S+?\/sisupod)\/doc/.match(@md.opt.f_pth[:pth])[1]
666
+ img_src=pt + '/image'
667
+ if FileTest.file?("#{img_src}/#{image}")
668
+ case images_hash[ps]
669
+ when url_image_rgx
670
+ images_hash[ps].sub!(url_image_rgx,
671
+ "#{@center_begin}\\\n\\href{#{url}}{\\includegraphics*[width=#{width[ps]}pt]{#{img_src}/#{image}}}#{caption} #{@center_end}")
672
+ when image_rgx
673
+ images_hash[ps].sub!(image_rgx,
674
+ "#{@center_begin}\\\n\\includegraphics*[width=#{width[ps]}pt]{#{img_src}/#{image}}#{caption} #{@center_end}")
675
+ end
676
+ images_hash[ps]
677
+ end
678
+
679
+ elsif @md.fns =~/\.(?:ssm\.)?sst$/ \
680
+ and FileTest.file?("#{dir.path.image_source_include_local}/#{image}")
681
+ case images_hash[ps]
682
+ when url_image_rgx
683
+ images_hash[ps].sub!(url_image_rgx,
684
+ "#{@center_begin}\\\n\\href{#{url}}{\\includegraphics*[width=#{width[ps]}pt]{#{dir.path.image_source_include_local}/#{image}}}#{caption} #{@center_end}")
685
+ when image_rgx
686
+ images_hash[ps].sub!(image_rgx,
687
+ "#{@center_begin}\\\n\\includegraphics*[width=#{width[ps]}pt]{#{dir.path.image_source_include_local}/#{image}}#{caption} #{@center_end}")
688
+ end
689
+ images_hash[ps]
690
+ elsif @md.fns =~/\.-ss[tm]$/ \
691
+ and FileTest.file?("#{dir.path.image_source_include_remote}/#{image}")
692
+ case images_hash[ps]
693
+ when url_image_rgx
694
+ images_hash[ps].sub!(url_image_rgx,
695
+ "#{@center_begin}\\\n\\href{#{url}}{\\includegraphics*[width=#{width[ps]}pt]{#{dir.path.image_source_include_remote}/#{image}}}#{caption}#{@center_end}")
696
+ when image_rgx
697
+ images_hash[ps].sub!(image_rgx,
698
+ "#{@center_begin}\\\n\\includegraphics*[width=#{width[ps]}pt]{#{dir.path.image_source_include_remote}/#{image}}#{caption}#{@center_end}")
699
+ end
700
+ images_hash[ps]
701
+ else
702
+ SiSU_Screen::Ansi.new(
703
+ @md.opt.act[:color_state][:set],
704
+ "ERROR - image:",
705
+ %{"#{image}" missing},
706
+ "search locations: #{dir.path.image_source_include_local}, #{dir.path.image_source_include_remote} and #{dir.path.image_source_include}"
707
+ ).error2 unless @md.opt.act[:quiet][:set]==:on
708
+ if images_hash[ps] =~url_image_rgx \
709
+ or images_hash[ps] =~image_rgx
710
+ images_hash[ps]=''
711
+ end
712
+ images_hash[ps]
713
+ end
714
+ else
715
+ link=z.strip #[/(.+?)\\/m,1]
716
+ images_hash[ps]="\\href{#{url}}{#{link}}#{punctuate}" if images_hash[ps] =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/
717
+ images_hash[ps]
718
+ end
719
+ else images_hash[ps]
720
+ end
721
+ images_hash[ps] #=ocn_display(dob) + images_hash[ps]
722
+ end #while loop
723
+ images_hash
724
+ end
725
+ use_images_hash={}
726
+ images_hash.each do |k,t|
727
+ use_images_hash[k]={ l: t, p: t}
728
+ end
729
+ dob.tmp=use_images_hash
730
+ dob
731
+ end
732
+ def title
733
+ title=SiSU_TeX_Pdf::SpecialCharacters.new(@md,@md.title.full).special_characters_safe
734
+ "\n\\title{#{title}}"
735
+ end
736
+ def title_landscape
737
+ title
738
+ end
739
+ def title_portrait
740
+ title
741
+ end
742
+ end
743
+ class FormatHead
744
+ require_relative 'prog_text_translation' # prog_text_translation.rb
745
+ def initialize(md,t_o)
746
+ @md,@t_o=md,t_o
747
+ @env=SiSU_Env::InfoEnv.new(@md.fns)
748
+ if t_o.is_a?(Hash)
749
+ @txt =t_o[:txt] || nil
750
+ @subtitle=t_o[:subtitle] || nil
751
+ @ps=t_o[:paper_size] || nil
752
+ @ocn=t_o[:ocn] || nil
753
+ @layout=t_o[:orientation] || nil
754
+ else
755
+ p t_o.class
756
+ p caller
757
+ end
758
+ @tx=SiSU_Env::GetInit.new.tex
759
+ @tex2pdf=@@tex3pdf ||=SiSU_Env::SystemCall.new.tex2pdf_engine
760
+ @ps=@txt if @txt=~/(?:a4|letter|legal|book|a5|b5)/i
761
+ @lang ||=SiSU_i18n::Languages.new #.list[@md.opt.lng][:xlp]
762
+ @author=if defined? @md.creator.author \
763
+ and @md.creator.author=~/\S+/
764
+ SiSU_TeX_Pdf::SpecialCharacters.new(@md,@md.creator.author).special_characters_safe
765
+ else ''
766
+ end
767
+ @subject=if defined? @md.classify.subject \
768
+ and @md.classify.subject=~/\S+/
769
+ SiSU_TeX_Pdf::SpecialCharacters.new(@md,@md.classify.subject).special_characters_safe
770
+ else ''
771
+ end
772
+ @keywords=if defined? @md.classify.keywords \
773
+ and @md.classify.keywords=~/\S+/
774
+ SiSU_TeX_Pdf::SpecialCharacters.new(@md,@md.classify.keywords).special_characters_safe
775
+ else ''
776
+ end
777
+ end
778
+ def tex_head_lang #babel 18n
779
+ lang_char_arr=@md.i18n
780
+ mainlang_char=if @md.i18n == Array \
781
+ and @md.i18n.length > 0
782
+ lang_char_arr.slice(0)
783
+ else @md.opt.lng
784
+ end
785
+ mainlang=@lang.list[mainlang_char][:xlp]
786
+ otherlang=if mainlang != 'english'
787
+ [ @lang.list['en'][:xlp] ]
788
+ else []
789
+ end
790
+ if lang_char_arr.length > 0
791
+ lang_char_arr.slice(1..9).each { |ch| otherlang << @lang.list[ch][:xlp] }
792
+ otherlang=otherlang.uniq
793
+ end
794
+ otherlang=otherlang.join(',')
795
+ { mainlang: mainlang, otherlang: otherlang }
796
+ end
797
+ def tex_head_encode
798
+ texpdf_fontface=if defined? @md.make.texpdf_fontface.main \
799
+ and not @md.make.texpdf_fontface.main.nil? \
800
+ and @md.make.texpdf_fontface.main=~/\S{3,}/
801
+ @md.make.texpdf_fontface.main
802
+ else @env.font.texpdf.main
803
+ end
804
+ texpdf_fontface_sans=if defined? @md.make.texpdf_fontface.sans \
805
+ and not @md.make.texpdf_fontface.sans.nil? \
806
+ and @md.make.texpdf_fontface.sans=~/\S{3,}/ # not used
807
+ @md.make.texpdf_fontface.sans
808
+ else @env.font.texpdf.sans
809
+ end
810
+ texpdf_fontface_serif=if defined? @md.make.texpdf_fontface.serif \
811
+ and not @md.make.texpdf_fontface.serif.nil? \
812
+ and @md.make.texpdf_fontface.serif=~/\S{3,}/ # not used
813
+ @md.make.texpdf_fontface.serif
814
+ else @env.font.texpdf.serif
815
+ end
816
+ texpdf_fontface_mono=if defined? @md.make.texpdf_fontface.mono \
817
+ and not @md.make.texpdf_fontface.mono.nil? \
818
+ and @md.make.texpdf_fontface.mono=~/\S{3,}/
819
+ @md.make.texpdf_fontface.mono
820
+ else @env.font.texpdf.mono
821
+ end
822
+ texpdf_fontface_cjk=if @md.opt.lng =~/zh/ \
823
+ and defined? @md.make.texpdf_fontface.cjk_zh \
824
+ and not @md.make.texpdf_fontface.cjk_zh.nil? \
825
+ and @md.make.texpdf_fontface.cjk_zh=~/\S{3,}/
826
+ @md.make.texpdf_fontface.cjk_zh
827
+ elsif @md.opt.lng =~/ja/ \
828
+ and defined? @md.make.texpdf_fontface.cjk_ja \
829
+ and not @md.make.texpdf_fontface.cjk_ja.nil? \
830
+ and @md.make.texpdf_fontface.cjk_ja=~/\S{3,}/
831
+ @md.make.texpdf_fontface.cjk_ja
832
+ elsif @md.opt.lng =~/ko/ \
833
+ and defined? @md.make.texpdf_fontface.cjk_ko \
834
+ and not @md.make.texpdf_fontface.cjk_ko.nil? \
835
+ and @md.make.texpdf_fontface.cjk_ko=~/\S{3,}/
836
+ @md.make.texpdf_fontface.cjk_ko
837
+ elsif @md.opt.lng =~/(?:zh|ja|ko)/ \
838
+ and defined? @md.make.texpdf_fontface.cjk \
839
+ and not @md.make.texpdf_fontface.cjk.nil? \
840
+ and @md.make.texpdf_fontface.cjk=~/\S{3,}/
841
+ @md.make.texpdf_fontface.cjk
842
+ else
843
+ case @md.opt.lng
844
+ when /zh/ then @env.font.texpdf.cjk_zh
845
+ when /ja/ then @env.font.texpdf.cjk_ja
846
+ when /ko/ then @env.font.texpdf.cjk_ko
847
+ else @env.font.texpdf.cjk
848
+ end
849
+ end
850
+ # you may wish to check selected font against available fonts:
851
+ # fc-list :outline -f "%{family}\n"
852
+ # fc-list :lang=ja
853
+ case @tex2pdf
854
+ when /xe/
855
+ if @md.opt.lng =~/(?:zh|ja|ko)/
856
+ <<-WOK
857
+ \\usepackage{ucs, fontspec, xltxtra, xunicode, xeCJK}
858
+ \\setmainCJKlanguage{#{tex_head_lang[:mainlang]}}
859
+ \\setCJKmainfont{#{texpdf_fontface_cjk}}
860
+ \\XeTeXlinebreaklocale "#{tex_head_lang[:mainlang]}"
861
+ \\XeTeXlinebreakskip = 0pt plus 1pt
862
+ \\setotherlanguage{#{tex_head_lang[:otherlang]}}
863
+ \\setmainfont{#{texpdf_fontface}}
864
+ \\setmonofont[Scale=0.85]{#{texpdf_fontface_mono}}
865
+ WOK
866
+ else
867
+ <<-WOK
868
+ \\usepackage{polyglossia, ucs, fontspec, xltxtra, xunicode}
869
+ \\setmainlanguage{#{tex_head_lang[:mainlang]}}
870
+ \\setotherlanguage{#{tex_head_lang[:otherlang]}}
871
+ \\setmainfont{#{texpdf_fontface}}
872
+ \\setmonofont[Scale=0.85]{#{texpdf_fontface_mono}}
873
+ % \\setsansfont{#{texpdf_fontface_sans}}
874
+ % \\setromanfont{#{texpdf_fontface_serif}}
875
+ WOK
876
+ end
877
+ when /pdf/
878
+ if @md.file_encoding =~ /iso-?8859/i #% iso8859
879
+ <<-WOK
880
+ % \\usepackage[latin1]{inputenc}
881
+ \\usepackage{fontspec}
882
+ WOK
883
+ else #% utf-8 assumed
884
+ <<-WOK
885
+ \\usepackage{babel}
886
+ \\usepackage{ucs}
887
+ \\usepackage[utf8x]{inputenc}
888
+ WOK
889
+ end
890
+ end
891
+ end
892
+ def tex_head_info
893
+ generator="Generated by: #{@md.project_details.project} #{@md.project_details.version} of #{@md.project_details.date_stamp} (#{@md.project_details.date})" if @md.project_details.version
894
+ lastdone="Last Generated on: #{Time.now}"
895
+ rubyv="Ruby version: #{@md.ruby_version}"
896
+ <<-WOK
897
+ %% SiSU (Linux & Ruby - \"better ways\") LaTeX output
898
+ %% #{generator}
899
+ %% #{rubyv}
900
+ %% LaTeX output
901
+ %% #{lastdone}
902
+ %% SiSU http://www.jus.uio.no/sisu
903
+ WOK
904
+ end
905
+ def tex_head_paper_portrait(d)
906
+ multicol=(@md.book_idx ? '\usepackage{multicol}' : '')
907
+ <<-WOK
908
+ #{tex_head_info}
909
+ \\documentclass[#{d[:fontsize]},#{d[:papertype]},titlepage]{scrartcl} %with titlepage
910
+ \\setlength{\\textheight}{#{d[:textheight]}mm} \\setlength{\\textwidth}{#{d[:textwidth]}mm}
911
+ \\setlength{\\oddsidemargin}{#{d[:oddsidemargin]}} \\setlength{\\evensidemargin}{#{d[:evensidemargin]}}
912
+ \\setlength{\\topmargin}{#{d[:topmargin]}} \\setlength{\\headheight}{#{d[:headheight]}}
913
+ \\setlength{\\headsep}{#{d[:headsep]}}
914
+ \\setlength{\\marginparsep}{#{d[:marginparsep]}}
915
+ \\setlength{\\marginparwidth}{#{d[:marginparwidth]}}
916
+ #{multicol}
917
+ WOK
918
+ end
919
+ def tex_head_paper_landscape(d)
920
+ <<-WOK
921
+ #{tex_head_info}
922
+ \\documentclass[#{d[:fontsize]},#{d[:papertype]},landscape,titlepage,twocolumn]{scrartcl} %with titlepage
923
+ \\setlength{\\textheight}{#{d[:textheight]}mm} \\setlength{\\textwidth}{#{d[:textwidth]}mm}
924
+ \\setlength{\\oddsidemargin}{#{d[:oddsidemargin]}} \\setlength{\\evensidemargin}{#{d[:evensidemargin]}}
925
+ \\setlength{\\topmargin}{#{d[:topmargin]}} \\setlength{\\headheight}{#{d[:headheight]}}
926
+ \\setlength{\\headsep}{#{d[:headsep]}}
927
+ \\setlength{\\columnsep}{#{d[:columnsep]}}
928
+ \\setlength{\\marginparsep}{#{d[:marginparsep]}}
929
+ \\setlength{\\marginparwidth}{#{d[:marginparwidth]}}
930
+ WOK
931
+ end
932
+ def tex_head_paper_portrait_dvi(d)
933
+ <<-WOK
934
+ #{tex_head_info}
935
+ \\documentclass[#{d[:fontsize]},#{d[:papertype]},titlepage]{scrartcl} %with titlepage
936
+ \\setlength{\\textheight}{#{d[:textheight]}mm} \\setlength{\\textwidth}{#{d[:textwidth]}mm}
937
+ \\setlength{\\oddsidemargin}{#{d[:oddsidemargin]}} \\setlength{\\evensidemargin}{#{d[:evensidemargin]}}
938
+ \\setlength{\\topmargin}{#{d[:topmargin]}} \\setlength{\\headheight}{#{d[:headheight]}}
939
+ \\setlength{\\headsep}{#{d[:headsep]}}
940
+ \\setlength{\\marginparsep}{#{d[:marginparsep]}}
941
+ \\setlength{\\marginparwidth}{#{d[:marginparwidth]}}
942
+ WOK
943
+ end
944
+ def tex_head_paper_dimensions
945
+ d={}
946
+ fontsize_set=if defined? @env.font.texpdf.size(@md.opt.act[:pdf_font_size]) \
947
+ and not @env.font.texpdf.size(@md.opt.act[:pdf_font_size]).nil?
948
+ @env.font.texpdf.size(@md.opt.act[:pdf_font_size])
949
+ else :na
950
+ end
951
+ case @layout
952
+ when :portrait
953
+ fontsize=(fontsize_set==:na) ? '11pt' : (fontsize_set + 'pt')
954
+ d[:papertype],d[:fontsize]='a4paper',fontsize
955
+ d[:oddsidemargin],d[:evensidemargin],d[:topmargin]='0mm','0mm','-12pt'
956
+ d[:headheight],d[:headsep],d[:columnsep]='12pt','35pt',''
957
+ d[:marginparsep],d[:marginparwidth]='4mm','8mm'
958
+ case @ps #@md.papersize
959
+ when /a4/i #European default, SiSU default
960
+ fontsize=(fontsize_set==:na) ? '12pt' : (fontsize_set + 'pt')
961
+ d[:papertype],d[:fontsize]='a4paper',fontsize
962
+ d[:textheight],d[:textwidth]=@tx.a4.portrait.h,@tx.a4.portrait.w
963
+ when /letter/i #U.S. default
964
+ fontsize=(fontsize_set==:na) ? '12pt' : (fontsize_set + 'pt')
965
+ d[:papertype],d[:fontsize]='letterpaper',fontsize
966
+ d[:textheight],d[:textwidth]=@tx.letter.portrait.h,@tx.letter.portrait.w
967
+ when /legal/i #U.S. alternative
968
+ fontsize=(fontsize_set==:na) ? '12pt' : (fontsize_set + 'pt')
969
+ d[:papertype],d[:fontsize]='legalpaper',fontsize
970
+ d[:textheight],d[:textwidth]=@tx.legal.portrait.h,@tx.legal.portrait.w
971
+ when /book|b5/i #book default - larger
972
+ fontsize=(fontsize_set==:na) ? '11pt' : (fontsize_set + 'pt')
973
+ d[:papertype],d[:fontsize]='b5paper',fontsize
974
+ d[:oddsidemargin],d[:evensidemargin],d[:topmargin]='-4mm','-4mm','-36pt'
975
+ d[:headheight],d[:headsep],d[:columnsep]='12pt','20pt',''
976
+ d[:textheight],d[:textwidth]=@tx.b5.portrait.h,@tx.b5.portrait.w
977
+ when /a5/i
978
+ fontsize=(fontsize_set==:na) ? '11pt' : (fontsize_set + 'pt')
979
+ d[:papertype],d[:fontsize]='a5paper',fontsize
980
+ d[:oddsidemargin],d[:evensidemargin],d[:topmargin]='-4mm','-4mm','-36pt'
981
+ d[:headheight],d[:headsep],d[:columnsep]='11pt','12pt',''
982
+ d[:marginparsep],d[:marginparwidth]='4mm','6mm'
983
+ d[:textheight],d[:textwidth]=@tx.a5.portrait.h,@tx.a5.portrait.w
984
+ else #default currently A4
985
+ fontsize=(fontsize_set==:na) ? '12pt' : (fontsize_set + 'pt')
986
+ d[:papertype],d[:fontsize]='a4paper',fontsize
987
+ d[:textheight],d[:textwidth]=@tx.a4.portrait.h,@tx.a4.portrait.w
988
+ end
989
+ when :landscape
990
+ fontsize=(fontsize_set==:na) ? '11pt' : (fontsize_set + 'pt')
991
+ d[:papertype],d[:fontsize]='a4paper',fontsize
992
+ d[:oddsidemargin],d[:evensidemargin],d[:topmargin]='6mm','6mm','-12mm'
993
+ d[:headheight],d[:headsep],d[:columnsep]='12pt','20pt','40pt'
994
+ d[:marginparsep],d[:marginparwidth]='4mm','8mm'
995
+ case @ps #@md.papersize
996
+ when /a4/i #European default, SiSU default
997
+ fontsize=(fontsize_set==:na) ? '11pt' : (fontsize_set + 'pt')
998
+ d[:papertype],d[:fontsize]='a4paper',fontsize
999
+ d[:textheight],d[:textwidth]=@tx.a4.landscape.h,@tx.a4.landscape.w
1000
+ when /letter/i #U.S. default
1001
+ fontsize=(fontsize_set==:na) ? '11pt' : (fontsize_set + 'pt')
1002
+ d[:papertype],d[:fontsize]='letterpaper',fontsize
1003
+ d[:textheight],d[:textwidth]=@tx.letter.landscape.h,@tx.letter.landscape.w
1004
+ when /legal/i #U.S. alternative
1005
+ fontsize=(fontsize_set==:na) ? '11pt' : (fontsize_set + 'pt')
1006
+ d[:papertype],d[:fontsize],d[:columnsep]='legalpaper',fontsize,'48pt'
1007
+ d[:textheight],d[:textwidth]=@tx.legal.landscape.h,@tx.legal.landscape.w
1008
+ when /book|b5/i #book default - larger
1009
+ fontsize=(fontsize_set==:na) ? '11pt' : (fontsize_set + 'pt')
1010
+ d[:papertype],d[:fontsize],d[:columnsep]='b5paper',fontsize,'35pt'
1011
+ d[:textheight],d[:textwidth]=@tx.b5.landscape.h,@tx.b5.landscape.w
1012
+ when /a5/i
1013
+ fontsize=(fontsize_set==:na) ? '10pt' : (fontsize_set + 'pt')
1014
+ d[:papertype],d[:fontsize],d[:columnsep]='a5paper',fontsize,'32pt'
1015
+ d[:textheight],d[:textwidth]=@tx.a5.landscape.h,@tx.a5.landscape.w
1016
+ else #default currently A4
1017
+ fontsize=(fontsize_set==:na) ? '12pt' : (fontsize_set + 'pt')
1018
+ d[:papertype],d[:fontsize]='a4paper',fontsize
1019
+ d[:textheight],d[:textwidth]=@tx.a4.landscape.h,@tx.a4.landscape.w
1020
+ end
1021
+ end
1022
+ d
1023
+ end
1024
+ def tex_head_paper
1025
+ case @layout
1026
+ when :portrait
1027
+ tex_head_paper_portrait(tex_head_paper_dimensions)
1028
+ when :landscape
1029
+ tex_head_paper_landscape(tex_head_paper_dimensions)
1030
+ end
1031
+ end
1032
+ def hyperlinks_monochrome
1033
+ <<-WOK
1034
+ colorlinks=true,
1035
+ urlcolor=myblack,
1036
+ filecolor=myblack,
1037
+ linkcolor=myblack,
1038
+ WOK
1039
+ end
1040
+ def hyperlinks_colored
1041
+ <<-WOK
1042
+ colorlinks=true,
1043
+ urlcolor=myblue, % \\href{...}{...} external url
1044
+ filecolor=mygreen, % \\href{...} local file
1045
+ linkcolor=myred, % \\href{...} and \\pageref{...}
1046
+ WOK
1047
+ end
1048
+ def hyperlinks_color?
1049
+ case @layout
1050
+ when :portrait then hyperlinks_monochrome
1051
+ if @env.texpdf_hyperlinks(@md.opt.act[:pdf_hyperlink_colors]).portrait != :na
1052
+ case @env.texpdf_hyperlinks(@md.opt.act[:pdf_hyperlink_colors]).portrait
1053
+ when :color then hyperlinks_colored
1054
+ when :mono then hyperlinks_monochrome
1055
+ else p __LINE__.to_s + ':error'
1056
+ end
1057
+ else hyperlinks_monochrome
1058
+ end
1059
+ when :landscape
1060
+ if @env.texpdf_hyperlinks(@md.opt.act[:pdf_hyperlink_colors]).landscape != :na
1061
+ case @env.texpdf_hyperlinks(@md.opt.act[:pdf_hyperlink_colors]).landscape
1062
+ when :color then hyperlinks_colored
1063
+ when :mono then hyperlinks_monochrome
1064
+ else p __LINE__.to_s + ':error'
1065
+ end
1066
+ else hyperlinks_colored
1067
+ end
1068
+ end
1069
+ end
1070
+ def tex_head_pdftex
1071
+ author=if defined? @md.creator.author \
1072
+ and @md.creator.author=~/\S+/
1073
+ SiSU_TeX_Pdf::SpecialCharacters.new(@md,@md.creator.author).special_characters_safe_no_urls
1074
+ else ''
1075
+ end
1076
+ <<-WOK
1077
+ \\usepackage{alltt}
1078
+ \\usepackage{thumbpdf}
1079
+ \\usepackage[#{@tex2pdf},
1080
+ #{hyperlinks_color?.strip}
1081
+ pdftitle={#{@txt}},
1082
+ pdfauthor={#{author}},
1083
+ pdfsubject={#{@subject}},
1084
+ pdfkeywords={#{@keywords}},
1085
+ pageanchor=true,
1086
+ plainpages=true,
1087
+ pdfpagelabels=true,
1088
+ pagebackref,
1089
+ bookmarks=true,
1090
+ bookmarksopen=true,
1091
+ pdfmenubar=true,
1092
+ pdfpagemode=UseOutline,
1093
+ pdffitwindow=true,
1094
+ pdfwindowui=true,
1095
+ plainpages=false,
1096
+ % pdfusetitle=true,
1097
+ % pdfpagelayout=SinglePage,
1098
+ % pdfpagelayout=TwoColumnRight,
1099
+ % pdfpagelayout=TwoColumnLeft,
1100
+ % pdfstartpage=3,
1101
+ pdfstartview=FitH
1102
+ ]
1103
+ {hyperref}
1104
+ %% trace lost characters
1105
+ % \\tracinglostchars = 1
1106
+ % \\tracingonline = 1
1107
+ \\usepackage[usenames]{color}
1108
+ \\definecolor{myblack}{rgb}{0,0,0}
1109
+ \\definecolor{myred}{rgb}{0.75,0,0}
1110
+ \\definecolor{mygreen}{rgb}{0,0.5,0}
1111
+ \\definecolor{myblue}{rgb}{0,0,0.5}
1112
+ \\definecolor{mywhite}{rgb}{1,1,1}
1113
+ \\usepackage{url}
1114
+ \\urlstyle{sf}
1115
+ %\\usepackage{breakurl}
1116
+ WOK
1117
+ end
1118
+ def tex_head_codeblock(codeblock_box_type)
1119
+ codeblock_box=if codeblock_box_type=='listings'
1120
+ <<-WOK
1121
+ \\usepackage{listings}
1122
+ \\usepackage{color}
1123
+ \\usepackage{textcomp}
1124
+ WOK
1125
+ elsif codeblock_box_type=='boites'
1126
+ "\\usepackage{boites}"
1127
+ else
1128
+ "\\usepackage{boites}"
1129
+ end
1130
+ codeblock_box
1131
+ end
1132
+ def tex_head_misc
1133
+ <<-WOK
1134
+ \\usepackage{textcomp}
1135
+ \\usepackage[parfill]{parskip}
1136
+ \\usepackage[normalem]{ulem}
1137
+ \\usepackage{soul}
1138
+ \\usepackage{longtable}
1139
+ \\usepackage[tc]{titlepic}
1140
+ \\usepackage{graphicx}
1141
+ \\makeatletter
1142
+ \\parindent0pt
1143
+ %\\usepackage{mathptmx}
1144
+ \\usepackage{amssymb}
1145
+ % amssymb used for backslash
1146
+ WOK
1147
+ end
1148
+ def document_head_with_orientation(codeblock_box_type)
1149
+ endnotes=("\\usepackage{endnotes}" if @txt =~/endnotes?/) || '' #not implemented see also def endnotes
1150
+ @lang.list[@md.i18n[0]][:xlp]
1151
+ <<-WOK
1152
+ #{tex_head_paper}
1153
+ #{tex_head_encode}
1154
+ #{tex_head_pdftex}
1155
+ #{tex_head_misc}
1156
+ #{tex_head_codeblock(codeblock_box_type)}
1157
+ \\setcounter{secnumdepth}{2}
1158
+ \\setcounter{tocdepth}{4}
1159
+ \\makeatletter
1160
+ #{endnotes}
1161
+ \\usepackage[multiple,ragged]{footmisc}
1162
+ \\setlength\\footnotemargin{12pt}
1163
+ \\usepackage[para]{manyfoot}
1164
+ \\DeclareNewFootnote{A}
1165
+ %\\DeclareNewFootnote[para]{A}
1166
+ \\newenvironment{ParagraphIndent}[1]%
1167
+ {
1168
+ \\begin{list}{}{%
1169
+ \\setlength\\topsep{0pt}%
1170
+ \\addtolength{\\leftmargin}{#1}
1171
+ \\setlength\\parsep{0pt plus 1pt}%
1172
+ }
1173
+ \\item[]
1174
+ }
1175
+ {\\end{list}}
1176
+
1177
+ \\newenvironment{ParagraphHang}[2]%
1178
+ {
1179
+ \\begin{list}{}{%
1180
+ \\setlength\\topsep{0pt}%
1181
+ \\addtolength{\\leftmargin}{#1}
1182
+ \\itemindent=#2
1183
+ \\setlength\\parsep{0pt plus 1pt}%
1184
+ }
1185
+ \\item[]
1186
+ }
1187
+ {\\end{list}}
1188
+
1189
+ \\newenvironment{Bullet}[1]%
1190
+ {
1191
+ \\begin{list}{}{%
1192
+ \\setlength\\topsep{0pt}%
1193
+ \\addtolength{\\leftmargin}{#1}
1194
+ \\itemindent=-1em
1195
+ \\setlength\\parsep{0pt plus 1pt}%
1196
+ }
1197
+ \\item[]
1198
+ }
1199
+ {\\end{list}}
1200
+ \\usepackage{fancyhdr}
1201
+ \\lhead{}
1202
+ \\renewcommand{\\part}{\\\@startsection
1203
+ {part}{1}{-2mm}%
1204
+ {-\\baselineskip}{0.5\\baselineskip}%
1205
+ {\\bfseries\\large\\upshape\\raggedright}}
1206
+ \\renewcommand{\\section}{\\\@startsection
1207
+ {section}{2}{-2mm}%
1208
+ {-\\baselineskip}{0.5\\baselineskip}%
1209
+ {\\bfseries\\large\\upshape\\raggedright}}
1210
+ \\renewcommand{\\subsection}{\\\@startsection
1211
+ {subsection}{3}{-2mm}%
1212
+ {-\\baselineskip}{0.5\\baselineskip}%
1213
+ {\\bfseries\\large\\upshape\\raggedright}}
1214
+ \\renewcommand{\\subsubsection}{\\\@startsection
1215
+ {subsubsection}{4}{-2mm}%
1216
+ {-\\baselineskip}{0.5\\baselineskip}%
1217
+ {\\normalfont\\normalsize\\bfseries\\raggedright}}
1218
+ \\renewcommand{\\paragraph}{\\\@startsection
1219
+ {paragraph}{5}{-2mm}%
1220
+ {-\\baselineskip}{0.5\\baselineskip}%
1221
+ {\\normalfont\\normalsize\\itshape\\raggedright}}
1222
+ \\renewcommand{\\subparagraph}{\\\@startsection
1223
+ {subparagraph}%{6}%{-2mm}%
1224
+ {-\\baselineskip}{0.5\\baselineskip}%
1225
+ {\\normalfont\\normalsize\\itshape\\raggedright}}
1226
+ % \\makeatother
1227
+ \\selectlanguage{#{@lang.list[@md.i18n[0]][:xlp]}}
1228
+ WOK
1229
+ end
1230
+ def a4generic
1231
+ end
1232
+ end
1233
+ class SpecialCharacters
1234
+ include SiSU_Parts_TeXpdf
1235
+ def initialize(md,str,is=:default)
1236
+ @md,@txt,@is=md,str,is
1237
+ @tex2pdf=@@tex3pdf ||=SiSU_Env::SystemCall.new.tex2pdf_engine
1238
+ end
1239
+ def xetex_code_listings(str,is=:default) # ~ ^ $ & % _ { } #LaTeX special characters - KEEP list
1240
+ word=str.scan(/\S+|\n/) #unless line =~/^(?:@\S|%+\s)/
1241
+ para_array=[]
1242
+ str=if word
1243
+ word.each do |w| # _ - / # | : ! ^ ~
1244
+ w=w.gsub(/#{Mx[:gl_o]}#lt#{Mx[:gl_c]}/,'<').gsub(/#{Mx[:gl_o]}#gt#{Mx[:gl_c]}/,'>').
1245
+ gsub(/[\\]?~/,'~').
1246
+ gsub(/[#{Mx[:br_line]}#{Mx[:br_paragraph]}]/,"\n"). #watch
1247
+ gsub(/#{Mx[:gl_o]}#(?:126|152)#{Mx[:gl_c]}/,'~'). #126 usual
1248
+ gsub(/\\?\||#{Mx[:gl_o]}#124#{Mx[:gl_c]}/,'|') #unless is=='code' #unless w=~/<~\d+;(?:[ohmu]|[0-6]:)\d+;\w\d+>/ # | SiSU not really special sisu character but done, also LaTeX
1249
+ para_array << w
1250
+ end
1251
+ str=para_array.join(' ')
1252
+ str=str.strip unless is==:code
1253
+ str
1254
+ else ''
1255
+ end
1256
+ str=str.gsub(/\s*#{Mx[:mk_o]}:name#\S+?#{Mx[:mk_c]}\s*/,' ').
1257
+ gsub(/.+?<-#>/,'').
1258
+ gsub(/#{Mx[:br_eof]}/,'').
1259
+ gsub(/#{Mx[:br_endnotes]}/,'').
1260
+ #problem sequence ->
1261
+ gsub(/&(?:lt|#060);/,'<'). # < SiSU special character also LaTeX
1262
+ gsub(/#{Mx[:gl_o]}#(?:gt|062)#{Mx[:gl_c]}/,'>'). # > SiSU special character also LaTeX
1263
+ gsub(/#{Mx[:gl_o]}#123#{Mx[:gl_c]}/,'{'). # { SiSU special character also LaTeX
1264
+ gsub(/#{Mx[:gl_o]}#125#{Mx[:gl_c]}/,'}'). # } SiSU special character also LaTeX
1265
+ gsub(/#{Mx[:gl_o]}#(?:126|152)#{Mx[:gl_c]}/,'~'). # ~ SiSU special character also LaTeX
1266
+ gsub(/#{Mx[:gl_o]}#035#{Mx[:gl_c]}/,'#'). # SiSU special character also LaTeX
1267
+ gsub(/#{Mx[:gl_o]}#033#{Mx[:gl_c]}/,'!'). # ! SiSU not really special sisu character but done, also LaTeX
1268
+ #gsub(/(^|\s)\*\s/,'\1\asterisk '). # * should you wish to escape astrisk e.g. describing \*{bold}*
1269
+ gsub(/#{Mx[:gl_o]}#042#{Mx[:gl_c]}/,'*'). # * should you wish to escape astrisk e.g. describing \*{bold}*
1270
+ gsub(/#{Mx[:gl_o]}#045#{Mx[:gl_c]}/,'-'). # - SiSU special character also LaTeX
1271
+ gsub(/#{Mx[:gl_o]}#043#{Mx[:gl_c]}/,'+'). # + SiSU special character also LaTeX
1272
+ gsub(/#{Mx[:gl_o]}#044#{Mx[:gl_c]}/,','). # + SiSU special character also LaTeX
1273
+ gsub(/#{Mx[:gl_o]}#038#{Mx[:gl_c]}/,'&'). #unless @txt=~/<:code>/ # / SiSU special character also LaTeX
1274
+ gsub(/#{Mx[:gl_o]}#047#{Mx[:gl_c]}/,'/'). # / SiSU special character also LaTeX
1275
+ gsub(/#{Mx[:gl_o]}#092#{Mx[:gl_c]}/,'\\'). # \ SiSU special character also LaTeX
1276
+ gsub(/#{Mx[:gl_o]}#095#{Mx[:gl_c]}/,'_'). # _ SiSU special character also LaTeX
1277
+ gsub(/#{Mx[:gl_o]}#124#{Mx[:gl_c]}/,'|'). # | SiSU not really special sisu character but done, also LaTeX
1278
+ gsub(/#{Mx[:gl_o]}#058#{Mx[:gl_c]}/,':'). # : SiSU not really special sisu character but done, also LaTeX
1279
+ gsub(/#{Mx[:gl_o]}#094#{Mx[:gl_c]}|\^/,'^'). # ^ SiSU not really special sisu character but done, also LaTeX
1280
+ ##watch placement, problem sequence ^
1281
+ gsub(/<sup><font face=symbol>&atild;<\/font><\/sup>/,' ').
1282
+ gsub(/\\copy(right|mark)?/,'<=copymark>') # ok problem with superscript
1283
+ end
1284
+ def xetex_special_characters_1(str,is=:default) # ~ ^ $ & % _ { } #LaTeX special characters - KEEP list
1285
+ word=str.scan(/\S+|\n/) #unless line =~/^(?:@\S|%+\s)/
1286
+ para_array=[]
1287
+ str=if word
1288
+ word.each do |w| # _ - / # | : ! ^ ~
1289
+ if w !~/https?:/ \
1290
+ and w=~/\/\S+?\// \
1291
+ and w.length > 6
1292
+ w=w.gsub(/([_.\/])/,'\1\-')
1293
+ end
1294
+ w=w.gsub(/#{Mx[:gl_o]}#lt#{Mx[:gl_c]}/,'<').gsub(/#{Mx[:gl_o]}#gt#{Mx[:gl_c]}/,'>').
1295
+ gsub(/[\\]?~/,'<=tilde>').
1296
+ gsub(/[#{Mx[:br_line]}#{Mx[:br_paragraph]}]/,' \newline '). #watch
1297
+ gsub(/#{Mx[:gl_o]}#(?:126|152)#{Mx[:gl_c]}/,'<=tilde>'). #126 usual
1298
+ gsub(/\\?\||#{Mx[:gl_o]}#124#{Mx[:gl_c]}/,'\pipe') #unless is=='code' #unless w=~/<~\d+;(?:[ohmu]|[0-6]:)\d+;\w\d+>/ # | SiSU not really special sisu character but done, also LaTeX
1299
+ if w !~/#{Mx[:rel_o]}/ \
1300
+ and w !~/#{Mx[:gl_o]}#/
1301
+ w=w.gsub(/\#/,'<=hash>')
1302
+ end
1303
+ para_array << w
1304
+ end
1305
+ str=para_array.join(' ')
1306
+ str=str.strip unless is==:code
1307
+ str
1308
+ else ''
1309
+ end
1310
+ str=str.gsub(/\s*#{Mx[:mk_o]}:name#\S+?#{Mx[:mk_c]}\s*/,' ').
1311
+ gsub(/.+?<-#>/,'').
1312
+ gsub(/#{Mx[:br_eof]}/,'').
1313
+ gsub(/#{Mx[:br_endnotes]}/,'')
1314
+ #problem sequence ->
1315
+ str=str.gsub(/&(?:nbsp);|#{Mx[:nbsp]}/,'\hardspace') unless is==:code # < SiSU special character also LaTeX
1316
+ str=str.gsub(/&(?:lt|#060);/,'\lt'). # < SiSU special character also LaTeX
1317
+ gsub(/#{Mx[:gl_o]}#(?:gt|062)#{Mx[:gl_c]}/,'\gt'). # > SiSU special character also LaTeX
1318
+ gsub(/#{Mx[:gl_o]}#123#{Mx[:gl_c]}/,'\curlyopen'). # { SiSU special character also LaTeX
1319
+ gsub(/#{Mx[:gl_o]}#125#{Mx[:gl_c]}/,'\curlyclose'). # } SiSU special character also LaTeX
1320
+ gsub(/#{Mx[:gl_o]}#(?:126|152)#{Mx[:gl_c]}/,'<=tilde>'). # ~ SiSU special character also LaTeX
1321
+ gsub(/#{Mx[:gl_o]}#035#{Mx[:gl_c]}/,'\#'). # # SiSU special character also LaTeX
1322
+ gsub(/#{Mx[:gl_o]}#033#{Mx[:gl_c]}/,'!'). # ! SiSU not really special sisu character but done, also LaTeX
1323
+ gsub(/(^|\s)\*\s/,'\1\asterisk '). # * should you wish to escape astrisk e.g. describing \*{bold}*
1324
+ gsub(/#{Mx[:gl_o]}#042#{Mx[:gl_c]}/,'\*'). # * should you wish to escape astrisk e.g. describing \*{bold}*
1325
+ gsub(/#{Mx[:gl_o]}#045#{Mx[:gl_c]}/,'-'). # - SiSU special character also LaTeX
1326
+ gsub(/#{Mx[:gl_o]}#043#{Mx[:gl_c]}/,'+'). # + SiSU special character also LaTeX
1327
+ gsub(/#{Mx[:gl_o]}#044#{Mx[:gl_c]}/,','). # + SiSU special character also LaTeX
1328
+ gsub(/#{Mx[:gl_o]}#038#{Mx[:gl_c]}/,'<=amp>'). #unless @txt=~/<:code>/ # / SiSU special character also LaTeX
1329
+ gsub(/#{Mx[:gl_o]}#047#{Mx[:gl_c]}/,'\slash'). # / SiSU special character also LaTeX
1330
+ gsub(/#{Mx[:gl_o]}#092#{Mx[:gl_c]}/,'\textbackslash'). # \ SiSU special character also LaTeX
1331
+ gsub(/#{Mx[:gl_o]}#095#{Mx[:gl_c]}/,'<=underscore>'). # _ SiSU special character also LaTeX
1332
+ gsub(/#{Mx[:gl_o]}#124#{Mx[:gl_c]}/,'|'). # | SiSU not really special sisu character but done, also LaTeX
1333
+ gsub(/#{Mx[:gl_o]}#058#{Mx[:gl_c]}/,':'). # : SiSU not really special sisu character but done, also LaTeX
1334
+ gsub(/#{Mx[:gl_o]}#094#{Mx[:gl_c]}|\^/,'\caret'). # ^ SiSU not really special sisu character but done, also LaTeX
1335
+ ##watch placement, problem sequence ^
1336
+ gsub(/<sup><font face=symbol>&atild;<\/font><\/sup>/,' ').
1337
+ gsub(/\\copy(right|mark)?/,'<=copymark>') # ok problem with superscript
1338
+ end
1339
+ def xetex_special_characters_2(str,is=:default)
1340
+ str=str.gsub(/#{Mx[:gl_o]}#156#{Mx[:gl_c]}/,'\oe ').
1341
+ gsub(/\$/,'\$').
1342
+ gsub(/\#/,'\#').
1343
+ gsub(/\%/,'\%').
1344
+ gsub(/\~/,'\~') #revist, should not be necessary to mark remaining tildes
1345
+ if str !~/^\s*#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}image\s/
1346
+ str=str.gsub(/_/,'\_')
1347
+ end
1348
+ str=str.gsub(/\{/,'\{').
1349
+ gsub(/\}/,'\}')
1350
+ str=if is==:code
1351
+ str.gsub(/&/,'{\\\&}').
1352
+ gsub(/\\~(\\\{)/,'{$\tilde$}\1').
1353
+ gsub(/(\\\})\\~/,'\1{$\tilde$}').
1354
+ gsub(/\\~(\[)/,'{$\tilde$}\1').
1355
+ gsub(/(\])\\~/,'\1{$\tilde$}').
1356
+ gsub(/<=tilde>/,'{$\tilde$}').
1357
+ gsub(/<=hash>/,'{\#}')
1358
+ else
1359
+ str.gsub(/&nbsp;|#{Mx[:nbsp]}/,'~'). # ~ character for hardspace
1360
+ gsub(/&/,'<=amp>')
1361
+ end
1362
+ str=str.gsub(/&\S+?;/,' ').
1363
+ gsub(/§/u,'\S'). #latex: space between next character not preserved? #str.gsub(/§ /,'\S ')
1364
+ gsub(/£/u,'\pounds').
1365
+ gsub(/<a href=".+?">/,' ').
1366
+ gsub(/<\/a>/,' ')
1367
+ unless is==:no_urls
1368
+ str=str.gsub(/((?:^|\s)#{Mx[:lnk_c]})#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,
1369
+ '\1\begin{scriptsize}\url{\2}\end{scriptsize}\3'). #special case \{ e.g. \}http://url
1370
+ gsub(/#{Mx[:url_o]}\\_(\S+?)#{Mx[:url_c]}/,
1371
+ '\begin{scriptsize}\url{\1}\end{scriptsize}'). #special case \{ e.g. \}http://url
1372
+ gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,
1373
+ '\begin{scriptsize}\\url{\1}\end{scriptsize}') #specially escaped url no decoration
1374
+ end
1375
+ if is !=:code \
1376
+ and is !=:no_urls
1377
+ str=str.gsub(/(^|#{Mx[:gl_c]}|\s)((?:https?|file|ftp):\/\/\S+?\.[^'"\s]+?)([;.,]?(?=\s|$))/,
1378
+ "\\1#{url_decoration.tex_open}\\begin{scriptsize}\\url{\\2}\\end{scriptsize}#{url_decoration.tex_close}\\3") #url matching with decoration <url> positive lookahead, sequence issue with { linked }http://url cannot use \b at start
1379
+ end
1380
+ str=str.gsub(/<:ee>/,'').
1381
+ gsub(/<!>/,' '). #proposed change, insert, but may be redundant
1382
+ gsub(/<(br|p)>|<\/\s*(br|p)>|<(br|p)\s*\/>/," #{Tex[:backslash]*2} "). # Work Area
1383
+ gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'\begin{bfseries}\1 \end{bfseries}').
1384
+ gsub(/<h\d+>(.+?)<\/h\d+>/,'\begin{bfseries}\1 \end{bfseries}').
1385
+ gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'\emph{\1}').
1386
+ gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'\uline{\1}'). # ulem
1387
+ gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,"``\\1''"). # quote #CHECK
1388
+ gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'\uline{\1}'). # ulem
1389
+ gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'\sout{\1}'). # ulem
1390
+ gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,"\$^{\\textrm{\\1}}\$").
1391
+ gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,"\$_{\\textrm{\\1}}\$").
1392
+ gsub(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/,'\begin{monosp}\1\end{monosp}')
1393
+ unless is==:code
1394
+ str=str.gsub(/"(.+?)"/,'“\1”'). # quote marks / quotations open & close " need condition exclude for code
1395
+ gsub(/\s+"/,' “'). # open "
1396
+ gsub(/^(#{Mx[:lv_o]}[1-6-]:\S*?#{Mx[:lv_c]}|<.+?>)?\s*"/,'\1“'). #fix Mx[:lv_o] # open "
1397
+ gsub(/"(\s|\.|,|:|;)/,'”\1'). # close "
1398
+ gsub(/"(#{Mx[:lv_o]}[1-6-]:\S*?#{Mx[:lv_c]}|<.+?>)?\s*$/,'”\1'). #fix Mx[:lv_o] # close "
1399
+ gsub(/"(\.|,)/,'”'). # close "
1400
+ gsub(/\s+'/,' `'). # open '
1401
+ gsub(/^(#{Mx[:lv_o]}[1-6-]:\S*?#{Mx[:lv_c]}|<.+?>)?\s*'/,'\1`') #fix Mx[:lv_o] # open '
1402
+ end
1403
+ str=str.gsub(/(<font.*?>|<\/font>)/,'').
1404
+ gsub(/\s*#{Mx[:fa_superscript_o]}(\S+?)#{Mx[:fa_superscript_c]}/,'^\1')
1405
+ str
1406
+ end
1407
+ def xetex_special_characters_3(str)
1408
+ str=str.gsub(/<br(\s*[^\/][^>])/,'\1'). # clean up, incredibly messy :-( footnote indents, problems if match exists in ordinary paragraphs? check! Work Area 200501 a bit tricky as must be able to match multiple times, and to clean remainder
1409
+ gsub(/([^<][^b][^r]\s+)\/>/,'\1') # clean up, incredibly messy :-( footnote indents, problems if match exists in ordinary paragraphs? check! Work Area 200501 a bit tricky as must be able to match multiple times, and to clean remainder
1410
+ while str =~/(https?:\/\/\S+?)(?:<=tilde>\S+)+/ #tilde in urls \href treated differently from text #FIX
1411
+ str=str.gsub(/(https?:\/\/\S+?)(?:<=tilde>(\S+))+/,'\1~\2')
1412
+ end
1413
+ str=str.gsub(/<=tilde>/,'{$\tilde$}').
1414
+ gsub(/(https?:\/\/\S+?)(?:(?:<=hash>)(\S+))+/,'\1#\2'). #hash in urls \href treated differently from text #FIX
1415
+ gsub(/<=hash>/,'{\#}')
1416
+ while str =~/(https?:\/\/\S+?)(?:<=amp>\S+)+/ #amp in urls \href treated differently from text #FIX
1417
+ str=str.gsub(/(https?:\/\/\S+?)(?:<=amp>(\S+))+/,'\1&\2')
1418
+ end
1419
+ str=str.gsub(/<=amp>/,'{\\\&}'). #changed ... 2005
1420
+ gsub(/<=copymark>\s*(.+)/,
1421
+ '^\copyright \textnormal{\1} \2') # watch likely to be problematic
1422
+ str
1423
+ end
1424
+ def special_characters_safe_close(str)
1425
+ str=str.gsub(/<=tilde>/,'{$\tilde$}').
1426
+ gsub(/<=hash>/,'{\#}').
1427
+ gsub(/<=amp>/,'{\\\&}'). #changed ... 2005
1428
+ gsub(/<=copymark>\s*(.+)/,
1429
+ '^\copyright \textnormal{\1} \2') # watch likely to be problematic
1430
+ end
1431
+ def special_characters_code_fix(str)
1432
+ str=str.gsub(/<=tilde>/,'{$\tilde$}')
1433
+ str
1434
+ end
1435
+ def special_characters_unsafe_1(str) #depreciated, make obsolete
1436
+ # some substitutions are sequence sensitive, rearrange with care.
1437
+ str=str.gsub(/\\textbackslash (copyright|clearpage|newpage)/,"\\\\\\1") #kludge bad solution, find out where tail is sent through specChar !
1438
+ str
1439
+ end
1440
+ def special_characters # special characters - some substitutions are sequence sensitive, rearrange with care
1441
+ str,is=@txt,@is
1442
+ str=xetex_special_characters_1(str,is) unless str.nil?
1443
+ str=special_characters_unsafe_1(str) unless str.nil? #xetex_special_characters_unsafe_1(@txt)
1444
+ str=xetex_special_characters_2(str,is) unless str.nil? #issues with xetex
1445
+ str=xetex_special_characters_3(str) unless str.nil?
1446
+ @txt=str
1447
+ end
1448
+ def special_word_break_points
1449
+ str=@txt
1450
+ str=str.gsub(/([_,.;:\/|=])/,'\1\-').
1451
+ gsub(/(--)(\S{4,})/,'\1\-\2')
1452
+ @txt=str
1453
+ end
1454
+ def special_number_break_points
1455
+ str=@txt
1456
+ str=str.gsub(/([0-9a-f]{8})/i,'\1\-')
1457
+ @txt=str
1458
+ end
1459
+ def special_characters_safe # special characters - some substitutions are sequence sensitive, rearrange with care
1460
+ str,is=@txt,@is
1461
+ str=xetex_special_characters_1(str,is) unless str.nil?
1462
+ str=xetex_special_characters_2(str,is) unless str.nil? # remove this to start with, causes issues
1463
+ str=special_characters_safe_close(str) unless str.nil?
1464
+ @txt=str
1465
+ end
1466
+ def special_characters_safe_no_urls
1467
+ str,is=@txt,:no_urls
1468
+ str=xetex_special_characters_1(str,is) unless str.nil?
1469
+ str=xetex_special_characters_2(str,is) unless str.nil? # remove this to start with, causes issues
1470
+ str=special_characters_safe_close(str) unless str.nil?
1471
+ @txt=str
1472
+ end
1473
+ def characters_code_listings # special characters - some substitutions are sequence sensitive, rearrange with care
1474
+ str,is=@txt,@is
1475
+ str=xetex_code_listings(str,is) unless str.nil?
1476
+ @txt=str
1477
+ end
1478
+ def special_characters_code
1479
+ str=@txt
1480
+ str=str.gsub(/ \\\\([ #{Mx[:br_nl]}]+|$)/,' \textbackslash\textbackslash\hardspace\1')
1481
+ str
1482
+ end
1483
+ end
1484
+ class UseTeX
1485
+ include SiSU_Parts_TeXpdf
1486
+ attr_accessor :url,:txt,:date
1487
+ def initialize(md)
1488
+ @md=md
1489
+ @date=SiSU_Env::InfoDate.new # #{@date.year}
1490
+ @copymark='{\\begin{footnotesize}\\raisebox{1ex}{\\copyright}\\end{footnotesize}}'
1491
+ end
1492
+ def skip
1493
+ "\n\\vspace*{\\smallskipamount} \n"
1494
+ end
1495
+ def paraskip_normal
1496
+ '\setlength{\parskip}{1ex plus0.5ex minus0.2ex}'
1497
+ end
1498
+ def paraskip_small
1499
+ '\setlength{\parskip}{0.5ex plus0.2ex minus0.1ex}'
1500
+ end
1501
+ def paraskip_tiny
1502
+ '\setlength{\parskip}{0.1ex plus0.1ex minus0.1ex}'
1503
+ end
1504
+ def skip_small
1505
+ "\\smallskip{}"
1506
+ end
1507
+ def skip_small_vspace
1508
+ "\n\\vspace*{\\smallskipamount} \n"
1509
+ end
1510
+ def skip_small_footnote
1511
+ end
1512
+ def skip_medium
1513
+ "\n\\medskip{}\n\n"
1514
+ end
1515
+ def skip_dummy
1516
+ "\n"
1517
+ end
1518
+ def header
1519
+ "\\lhead[ ]{ }\n" +
1520
+ "\\chead[ \\fancyplain{} \\bfseries \\footnotesize \\leftmark ]{ \\fancyplain{} \\bfseries \\footnotesize \\rightmark }\n" +
1521
+ "\\rhead[ ]{ }\n"
1522
+ end
1523
+ def footer
1524
+ "\\lfoot[\\textrm{\\thepage}]{\\tiny \\href{#{@md.footer_links[:left][:url]}}{#{@md.footer_links[:left][:say]}}}\n" +
1525
+ "\\cfoot{\\href{#{@md.footer_links[:center][:url]}}{#{@md.footer_links[:center][:say]}}}\n" +
1526
+ "\\rfoot[\\tiny \\href{}{}]{\\textrm{\\thepage}}\n"
1527
+ end
1528
+ def site
1529
+ if not the_url.home.empty? \
1530
+ and not the_url.home_txt.empty?
1531
+ "\n\\date{\\begin{tiny} \\end{tiny}}"
1532
+ else ''
1533
+ end
1534
+ end
1535
+ def owner_chapter
1536
+ "Contact Details for Original Promulgating Authority"
1537
+ end
1538
+ #BOOK standard dimensions - 229x156
1539
+ def newpage(orientation)
1540
+ case orientation
1541
+ when :landscape # using longtable latex package
1542
+ <<-WOK
1543
+ \\clearpage
1544
+ WOK
1545
+ when :portrait
1546
+ <<-WOK
1547
+ \\newpage
1548
+ WOK
1549
+ end
1550
+ end
1551
+ def sisu_rights
1552
+ v=SiSU_Env::InfoVersion.instance.get_version
1553
+ base_prog_txt=if @md.base_program
1554
+ case @md.base_program
1555
+ when /kdissert/i then "\n\\\\ This document prepared using \\href{http://freehackers.org/~tnagy/kdissert/}{Kdissert \\ http://freehackers.org/~tnagy/kdissert/ } \\\\ Kdissert is Document Mapping software by Thomas Nagy"
1556
+ else ''
1557
+ end
1558
+ else ''
1559
+ end
1560
+ <<-WOK
1561
+ \\\\ ~
1562
+ {\\begin{footnotesize}#{base_prog_txt}
1563
+ \\\\ Generated by \\href{http://www.jus.uio.no/sisu}{SiSU} \\begin{tiny}[ #{v.project} #{v.version} of #{v.date_stamp} ]\\end{tiny} \\href{http://www.jus.uio.no/sisu}{www.jus.uio.no/sisu}
1564
+ \\\\ Copyright #{@copymark} 1997, current #{@date.year_static} Ralph Amissah, All Rights Reserved.
1565
+ \\\\ SiSU is software for document structuring, publishing and search (with object citation numbering), \\href{http://www.sisudoc.org}{www.sisudoc.org}
1566
+ \\\\ SiSU is released under \\href{http://www.fsf.org/licenses/gpl.html}{GPL 3 } or later, #{url_brace.tex_open}\\href{http://www.fsf.org/licenses/gpl.html}{http://www.fsf.org/licenses/gpl.html}#{url_brace.tex_close}.
1567
+ {\\end{footnotesize}
1568
+ \\\\
1569
+ WOK
1570
+ end
1571
+ def doc_sc_info_footnote_full
1572
+ <<-WOK
1573
+ \\footnote{%\nGenerated by \\href{http://www.jus.uio.no/sisu}{SiSU \\ www.jus.uio.no/sisu }\\ \\newline \\scriptsize{Document version information: \\emph{sourcefile} \\uline{#{@md.fnstex}}; \\emph{version} \\uline{#{@md.sc_number}}; \\emph{date} \\uline{#{@md.sc_date}}; \\emph{time} \\uline{#{@md.sc_time}}}}
1574
+ WOK
1575
+ end
1576
+ def doc_sc_info_footnote_brief
1577
+ " \\footnote{%\nGenerated by \\href{http://www.jus.uio.no/sisu}{SiSU} \\ \\href{http://www.jus.uio.no/sisu}{www.jus.uio.no/sisu} \\newline \\href{http://www.sisudoc.org}{www.sisudoc.org} \\\n}"
1578
+ end
1579
+ def doc_sc_info
1580
+ v=SiSU_Env::InfoVersion.instance.get_version
1581
+ <<-WOK
1582
+ \\\\
1583
+ {\\begin{footnotesize}
1584
+ Document version information: \\\\
1585
+ \\emph{sourcefile} \\uline{#{@md.fnstex}}; \\emph{version} \\uline{#{@md.sc_number}}; \\emph{date} \\uline{#{@md.sc_date}}; \\emph{time} \\uline{#{@md.sc_time}} \\\\
1586
+ Generated by \\href{http://www.jus.uio.no/sisu}{SiSU www.jus.uio.no/sisu }\\- version information: \\\\
1587
+ \\uline{ #{v.project} #{v.version} of #{v.date_stamp}}
1588
+ \\end{footnotesize}}&
1589
+ WOK
1590
+ end
1591
+ def doc_no_sc_info
1592
+ v=SiSU_Env::InfoVersion.instance.get_version
1593
+ <<-WOK
1594
+ \\\\
1595
+ {\\begin{small}
1596
+ Document information: \\\\
1597
+ \\emph{sourcefile} \\uline{#{@md.fnstex}} \\\\
1598
+ Generated by \\href{http://www.jus.uio.no/sisu}{SiSU www.jus.uio.no/sisu } \\\\ version information: \\
1599
+ \\uline{ #{v.project} #{v.version} of #{v.date_stamp}}
1600
+
1601
+ \\end{small}}&
1602
+ WOK
1603
+ end
1604
+ def endnotes #not used should be inserted before MetaData section which preceeds doc_tail, but is "part of document"
1605
+ <<-WOK
1606
+ \\subsection*{Endnotes}
1607
+ \\addcontentsline{toc}{section}{Endnotes}
1608
+ \\
1609
+ \\listofendnotes
1610
+ WOK
1611
+ end
1612
+ end
1613
+ end
1614
+ __END__
1615
+ #ack usepackage texpdf*
1616
+ #ack usepackage texpdf* |ack '\{.+?\}'
1617
+ #see sisu_texpdf_usepackage.rb
1618
+ alltt.sty
1619
+ amssymb.sty
1620
+ babel.sty
1621
+ boites.sty
1622
+ color.sty
1623
+ endnotes.sty
1624
+ fancyhdr.sty
1625
+ fontspec.sty
1626
+ footmisc.sty
1627
+ graphicx.sty
1628
+ inputenc.sty
1629
+ listings.sty
1630
+ longtable.sty
1631
+ manyfoot.sty
1632
+ multicol.sty
1633
+ parskip.sty
1634
+ polyglossia.sty
1635
+ soul.sty
1636
+ textcomp.sty
1637
+ thumbpdf.sty
1638
+ titlepic.sty
1639
+ ucs.sty
1640
+ ulem.sty
1641
+ url.sty
1642
+ xetex.sty
1643
+ xltxtra.sty
1644
+ xunicode.sty
1645
+ ---
1646
+ texlive-latex-base
1647
+ texlive-base
1648
+ texlive-latex-extra
1649
+ texlive-latex-recommended
1650
+ texlive-xetex
1651
+ texlive-generic-recommended
1652
+ ---
1653
+ texlive-latex-base:
1654
+ /usr/share/texlive/texmf-dist/tex/generic/babel/babel.sty
1655
+ /usr/share/texlive/texmf-dist/tex/latex/base/alltt.sty
1656
+ /usr/share/texlive/texmf-dist/tex/latex/base/inputenc.sty
1657
+ /usr/share/texlive/texmf-dist/tex/latex/base/textcomp.sty
1658
+ /usr/share/texlive/texmf-dist/tex/latex/fancyhdr/fancyhdr.sty
1659
+ /usr/share/texlive/texmf-dist/tex/latex/graphics/color.sty
1660
+ /usr/share/texlive/texmf-dist/tex/latex/graphics/graphicx.sty
1661
+ /usr/share/texlive/texmf-dist/tex/latex/tools/longtable.sty
1662
+ /usr/share/texlive/texmf-dist/tex/latex/tools/multicol.sty
1663
+ ---
1664
+ texlive-base:
1665
+ /usr/share/texlive/texmf-dist/tex/latex/amsfonts/amssymb.sty
1666
+ ---
1667
+ texlive-latex-extra:
1668
+ /usr/share/texlive/texmf-dist/tex/latex/boites/boites.sty
1669
+ /usr/share/texlive/texmf-dist/tex/latex/endnotes/endnotes.sty
1670
+ /usr/share/texlive/texmf-dist/tex/latex/footmisc/footmisc.sty
1671
+ /usr/share/texlive/texmf-dist/tex/latex/ncctools/manyfoot.sty
1672
+ /usr/share/texlive/texmf-dist/tex/latex/soul/soul.sty
1673
+ /usr/share/texlive/texmf-dist/tex/latex/titlepic/titlepic.sty
1674
+ /usr/share/texlive/texmf-dist/tex/latex/ucs/ucs.sty
1675
+ ---
1676
+ texlive-latex-recommended:
1677
+ /usr/share/texlive/texmf-dist/tex/generic/thumbpdf/thumbpdf.sty
1678
+ /usr/share/texlive/texmf-dist/tex/latex/fontspec/fontspec.sty
1679
+ /usr/share/texlive/texmf-dist/tex/latex/listings/listings.sty
1680
+ /usr/share/texlive/texmf-dist/tex/latex/parskip/parskip.sty
1681
+ /usr/share/texlive/texmf-dist/tex/latex/url/url.sty
1682
+ ---
1683
+ texlive-xetex:
1684
+ /usr/share/texlive/texmf-dist/tex/latex/xltxtra/xltxtra.sty
1685
+ /usr/share/texlive/texmf-dist/tex/xelatex/polyglossia/polyglossia.sty
1686
+ /usr/share/texlive/texmf-dist/tex/xelatex/xunicode/xunicode.sty
1687
+ ---
1688
+ texlive-generic-recommended:
1689
+ /usr/share/texlive/texmf-dist/tex/generic/ulem/ulem.sty