Class: SiSU_TeX_Pdf::FormatTextObject
- Inherits:
-
Object
- Object
- SiSU_TeX_Pdf::FormatTextObject
- Includes:
- SiSU_Parts_TeXpdf
- Defined in:
- lib/sisu/texpdf_format.rb
Constant Summary collapse
- @@sys =
SiSU_Env::SystemCall.new
- @@tex_pattern_margin_number =
/\\begin\{tiny\}\\hspace\{0mm\}\\end\{tiny\}\{\\marginpar.+?\}\}\}/
- @@tableheader =
{ 'a4' => { p: 0, l: 0 }, 'a5' => { p: 0, l: 0 }, 'b5' => { p: 0, l: 0 }, 'letter' => { p: 0, l: 0 }, 'legal' => { p: 0, l: 0 } }
Instance Attribute Summary collapse
-
#dir ⇒ Object
Returns the value of attribute dir.
-
#orientation ⇒ Object
Returns the value of attribute orientation.
-
#string ⇒ Object
Returns the value of attribute string.
-
#string1 ⇒ Object
Returns the value of attribute string1.
-
#tex ⇒ Object
Returns the value of attribute tex.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #bullet ⇒ Object
- #hang ⇒ Object
- #heading_dev_null(dob) ⇒ Object
- #heading_level_1 ⇒ Object
- #heading_level_2 ⇒ Object
- #heading_level_3 ⇒ Object
- #heading_level_4 ⇒ Object
- #heading_sublevels(dob) ⇒ Object
- #indent ⇒ Object
-
#initialize(md, dob = nil) ⇒ FormatTextObject
constructor
A new instance of FormatTextObject.
- #longtable_landscape ⇒ Object
- #longtable_portrait ⇒ Object
- #ocn_display(dob) ⇒ Object
- #remove_footnotes(cont_ln) ⇒ Object
- #section_heading_level(dob) ⇒ Object
- #section_heading_level_B ⇒ Object
- #section_heading_level_C ⇒ Object
- #section_heading_level_D ⇒ Object
- #symbol_graphic ⇒ Object
- #table_special_characters(r) ⇒ Object
- #title ⇒ Object
- #title_landscape ⇒ Object
- #title_level_A ⇒ Object
- #title_portrait ⇒ Object
- #url_str(str) ⇒ Object
- #url_str_internal(str, idx = nil) ⇒ Object
- #url_with_txt(dob) ⇒ Object
- #urls_txt_and_images ⇒ Object
Methods included from SiSU_Parts_TeXpdf
#set_fonts, #tex_close, #tex_open, #the_font, #the_line_break, #txt_close, #txt_open, #url_decoration
Methods included from SiSU_Parts_Generic
#footer_signature, #home, #home_txt, #i_choice, #i_home_button, #i_ico, #i_new, #rl_root, #root_http, #sisu, #sisu_txt, #sisudoc, #site, #the_icon, #the_text, #the_url, #txt_home, #txt_hp, #txt_hp_alias, #txt_signature, #urify, #url_close, #url_open
Constructor Details
#initialize(md, dob = nil) ⇒ FormatTextObject
Returns a new instance of FormatTextObject.
91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/sisu/texpdf_format.rb', line 91 def initialize(md,dob=nil) @md,@dob=md,dob if defined? @md.image \ and @md.image =~/center/ @center_begin,@center_end='\begin{center}','\end{center}' else @center_begin,@center_end='','' end @start_table='' @tx=SiSU_Env::GetInit.new.tex @env ||=SiSU_Env::InfoEnv.new(@md.fns) @tex2pdf=@@tex3pdf ||=SiSU_Env::SystemCall.new.tex2pdf_engine @make ||=SiSU_Env::ProcessingSettings.new(@md) end |
Instance Attribute Details
#dir ⇒ Object
Returns the value of attribute dir.
80 81 82 |
# File 'lib/sisu/texpdf_format.rb', line 80 def dir @dir end |
#orientation ⇒ Object
Returns the value of attribute orientation.
80 81 82 |
# File 'lib/sisu/texpdf_format.rb', line 80 def orientation @orientation end |
#string ⇒ Object
Returns the value of attribute string.
80 81 82 |
# File 'lib/sisu/texpdf_format.rb', line 80 def string @string end |
#string1 ⇒ Object
Returns the value of attribute string1.
80 81 82 |
# File 'lib/sisu/texpdf_format.rb', line 80 def string1 @string1 end |
#tex ⇒ Object
Returns the value of attribute tex.
80 81 82 |
# File 'lib/sisu/texpdf_format.rb', line 80 def tex @tex end |
#url ⇒ Object
Returns the value of attribute url.
80 81 82 |
# File 'lib/sisu/texpdf_format.rb', line 80 def url @url end |
Instance Method Details
#bullet ⇒ Object
469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 |
# File 'lib/sisu/texpdf_format.rb', line 469 def bullet blt=if @dob.indent indent=case @dob.indent when /1/ then '0em' when /2/ then '1.0em' when /3/ then '2.0em' when /4/ then '3.0em' when /5/ then '4.0em' when /6/ then '5.0em' when /7/ then '6.0em' when /8/ then '7.0em' when /9/ then '8.0em' else '-1.0em' end "\\begin{Bullet}{#{indent}}$\\txtbullet$\\hspace{\\enspace}#{@dob.tmp}\\end{Bullet}" else "\\begin{Bullet}{-5mm}$\\txtbullet$\\hspace{\\enspace}#{@dob.tmp}\\end{Bullet}" end blt end |
#hang ⇒ Object
320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 |
# File 'lib/sisu/texpdf_format.rb', line 320 def hang case @dob.indent when /0/ case @dob.hang when /0/ then indent,hang='0mm', '0mm' when /1/ then indent,hang='0mm','10mm' when /2/ then indent,hang='0mm','20mm' when /3/ then indent,hang='0mm','30mm' when /4/ then indent,hang='0mm','40mm' when /5/ then indent,hang='0mm','50mm' when /6/ then indent,hang='0mm','60mm' when /7/ then indent,hang='0mm','70mm' when /8/ then indent,hang='0mm','80mm' when /9/ then indent,hang='0mm','90mm' end when /1/ case @dob.hang when /0/ then indent,hang='10mm','-10mm' when /1/ then indent,hang='10mm', '0mm' when /2/ then indent,hang='10mm', '10mm' when /3/ then indent,hang='10mm', '20mm' when /4/ then indent,hang='10mm', '30mm' when /5/ then indent,hang='10mm', '40mm' when /6/ then indent,hang='10mm', '50mm' when /7/ then indent,hang='10mm', '60mm' when /8/ then indent,hang='10mm', '70mm' when /9/ then indent,hang='10mm', '80mm' end when /2/ case @dob.hang when /0/ then indent,hang='20mm','-20mm' when /1/ then indent,hang='20mm','-10mm' when /2/ then indent,hang='20mm', '0mm' when /3/ then indent,hang='20mm', '10mm' when /4/ then indent,hang='20mm', '20mm' when /5/ then indent,hang='20mm', '30mm' when /6/ then indent,hang='20mm', '40mm' when /7/ then indent,hang='20mm', '50mm' when /8/ then indent,hang='20mm', '60mm' when /9/ then indent,hang='20mm', '70mm' end when /3/ case @dob.hang when /0/ then indent,hang='30mm','-30mm' when /1/ then indent,hang='30mm','-20mm' when /2/ then indent,hang='30mm','-10mm' when /3/ then indent,hang='30mm', '0mm' when /4/ then indent,hang='30mm', '10mm' when /5/ then indent,hang='30mm', '20mm' when /6/ then indent,hang='30mm', '30mm' when /7/ then indent,hang='30mm', '40mm' when /8/ then indent,hang='30mm', '50mm' when /9/ then indent,hang='30mm', '60mm' end when /4/ case @dob.hang when /0/ then indent,hang='40mm','-40mm' when /1/ then indent,hang='40mm','-30mm' when /2/ then indent,hang='40mm','-20mm' when /3/ then indent,hang='40mm','-10mm' when /4/ then indent,hang='40mm', '0mm' when /5/ then indent,hang='40mm', '10mm' when /6/ then indent,hang='40mm', '20mm' when /7/ then indent,hang='40mm', '30mm' when /8/ then indent,hang='40mm', '40mm' when /9/ then indent,hang='40mm', '50mm' end when /5/ case @dob.hang when /0/ then indent,hang='50mm','-50mm' when /1/ then indent,hang='50mm','-40mm' when /2/ then indent,hang='50mm','-30mm' when /3/ then indent,hang='50mm','-20mm' when /4/ then indent,hang='50mm','-10mm' when /5/ then indent,hang='50mm', '0mm' when /6/ then indent,hang='50mm', '10mm' when /7/ then indent,hang='50mm', '20mm' when /8/ then indent,hang='50mm', '30mm' when /9/ then indent,hang='50mm', '40mm' end when /6/ case @dob.hang when /0/ then indent,hang='60mm','-60mm' when /1/ then indent,hang='60mm','-50mm' when /2/ then indent,hang='60mm','-40mm' when /3/ then indent,hang='60mm','-30mm' when /4/ then indent,hang='60mm','-20mm' when /5/ then indent,hang='60mm','-10mm' when /6/ then indent,hang='60mm', '0mm' when /7/ then indent,hang='60mm', '10mm' when /8/ then indent,hang='60mm', '20mm' when /9/ then indent,hang='60mm', '30mm' end when /7/ case @dob.hang when /0/ then indent,hang='70mm','-70mm' when /1/ then indent,hang='70mm','-60mm' when /2/ then indent,hang='70mm','-50mm' when /3/ then indent,hang='70mm','-40mm' when /4/ then indent,hang='70mm','-30mm' when /5/ then indent,hang='70mm','-20mm' when /6/ then indent,hang='70mm','-10mm' when /7/ then indent,hang='70mm', '0mm' when /8/ then indent,hang='70mm', '10mm' when /9/ then indent,hang='70mm', '20mm' end when /8/ case @dob.hang when /0/ then indent,hang='80mm','-80mm' when /1/ then indent,hang='80mm','-70mm' when /2/ then indent,hang='80mm','-60mm' when /3/ then indent,hang='80mm','-50mm' when /4/ then indent,hang='80mm','-40mm' when /5/ then indent,hang='80mm','-30mm' when /6/ then indent,hang='80mm','-20mm' when /7/ then indent,hang='80mm','-10mm' when /8/ then indent,hang='80mm', '0mm' when /9/ then indent,hang='80mm', '10mm' end when /9/ case @dob.hang when /0/ then indent,hang='90mm','-90mm' when /1/ then indent,hang='90mm','-80mm' when /2/ then indent,hang='90mm','-70mm' when /3/ then indent,hang='90mm','-60mm' when /4/ then indent,hang='90mm','-50mm' when /5/ then indent,hang='90mm','-40mm' when /6/ then indent,hang='90mm','-30mm' when /7/ then indent,hang='90mm','-20mm' when /8/ then indent,hang='90mm','-10mm' when /9/ then indent,hang='90mm', '0mm' end end "\\begin{ParagraphHang}{#{indent}}{#{hang}}#{@dob.tmp} \\end{ParagraphHang}}" end |
#heading_dev_null(dob) ⇒ Object
252 253 254 255 |
# File 'lib/sisu/texpdf_format.rb', line 252 def heading_dev_null(dob) dob.tmp,dob.obj='','' dob end |
#heading_level_1 ⇒ Object
304 305 306 307 308 309 310 |
# File 'lib/sisu/texpdf_format.rb', line 304 def heading_level_1 if not @dob.use_ == :dummy heading_sublevels(@dob) else heading_dev_null(@dob) end end |
#heading_level_2 ⇒ Object
311 312 313 |
# File 'lib/sisu/texpdf_format.rb', line 311 def heading_level_2 heading_sublevels(@dob) end |
#heading_level_3 ⇒ Object
314 315 316 |
# File 'lib/sisu/texpdf_format.rb', line 314 def heading_level_3 heading_sublevels(@dob) end |
#heading_level_4 ⇒ Object
317 318 319 |
# File 'lib/sisu/texpdf_format.rb', line 317 def heading_level_4 heading_sublevels(@dob) end |
#heading_sublevels(dob) ⇒ Object
256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 |
# File 'lib/sisu/texpdf_format.rb', line 256 def heading_sublevels(dob) if dob.lv=='1' sect='section' tocadd=%{\\addcontentsline{toc}{section}} pre='' post='' headadd=%{\n\\markright{#{@md.title.full}}} elsif dob.lv=='2' sect='subsection' tocadd=%{\\addcontentsline{toc}{subsection}} pre='' post=" \\\\\n" headadd='' elsif dob.lv=='3' sect='subsubsection' tocadd=%{\\addcontentsline{toc}{subsubsection}} pre='' #pre='~~~~' post=" \\\\\n" headadd='' end dob.tmp=dob.tmp.strip if dob.tmp dob.tmp=dob.tmp.gsub(/\\begin\{(bfseries|itshape)\}(.+?)\\end\{\1\}/m,'\2'). gsub(/#{Mx[:url_o]}|#{Mx[:url_c]}/,'') cont_ln=dob.tmp.dup cont_ln=cont_ln.gsub(/\\begin\{(monosp)\}(.+?)\\end\{\1\}/m,'\2'). gsub(@@tex_pattern_margin_number,''). gsub(/#{Tex[:backslash]*2}/,"#{Tex[:backslash]*4}"). # added w42 gsub(/\\footnote\[\d+\]\{%.+?\\end\{scriptsize\}\s*\}/m,''). #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22 gsub(/\\Footnote[A]\{[*+]+\d*\}\{%.+?\\end\{scriptsize\}\s*\}/m,'') #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22 if dob.name =~/endnotes/ dob.tmp=dob.tmp.gsub(/.+/m,'') end cont_ln=remove_footnotes(cont_ln) cont_ln=cont_ln.gsub(/\{[\\]+(&)\}/,'\\1') dob.tmp=dob.tmp.gsub(/^(.*)?\n?$/m, "\\#{sect}*{\\1} #{tocadd}{#{pre}#{cont_ln}#{post}}#{headadd}") dob end |
#indent ⇒ Object
455 456 457 458 459 460 461 462 463 464 465 466 467 468 |
# File 'lib/sisu/texpdf_format.rb', line 455 def indent indent=case @dob.indent when /1/ then '0mm' when /2/ then '10mm' when /3/ then '20mm' when /4/ then '30mm' when /5/ then '40mm' when /6/ then '50mm' when /7/ then '60mm' when /8/ then '70mm' when /9/ then '80mm' end "\\begin{ParagraphIndent}{#{indent}}#{@dob.tmp} \\end{ParagraphIndent}}" end |
#longtable_landscape ⇒ Object
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/sisu/texpdf_format.rb', line 123 def longtable_landscape end_table='\end{longtable}' row_break='\\\\\\' if @dob.is==:table tw=case @dob.tmp[:paper_size] when /a4/i then @tx.a4.landscape.w #European default, SiSU default when /letter/i then @tx.letter.landscape.w #U.S. default when /legal/i then @tx.legal.landscape.w #U.S. alternative when /book|b5/i then @tx.b5.landscape.w #book default - larger when /a5/i then @tx.a5.landscape.w else @tx.a4.landscape.w #default currently A4 end textwidth=(tw.to_i/2) - 24 colW=[] colW << '{' @dob.widths.each do |x| x=(x.to_i * textwidth)/100 col_w=x.to_s # x.gsub(/.+/,'l\|') #unless x.nil? colW << "p{#{col_w}mm}" if col_w end colW << '}' colW=colW.join start_table="\n\\setlength{\\LTleft}{0pt}\n\\setlength{\\LTright}{\\fill}\n" + "\\begin{tiny}\n\\begin{longtable}#{colW}\n" rows=@dob.obj.split(/#{Mx[:br_nl]}/) if @dob.head_ #result imperfect, check on rows[0]=rows[0].gsub(/(^|.+?)(?:#{Mx[:tc_p]}|$)/u,'\bfseries \1&'). gsub(/&\s*$/," #{row_break} \\hline\\endhead #{row_break}") end rows_new=[] rows.each do |r| r=table_special_characters(r) r=r.gsub(/$/," #{row_break}\n") unless r =~/#{row_break*2}$/ if r=~/\<!f(.+?)!\>/ # not tested table footer if any tablefoot=$1 r=r.gsub(/\<!f(.+?)!\>/,'') r="#{r} \\multicolumn{#{@dob.cols}}{l}{\\tiny #{tablefoot}} \\\\ \\hline\n\\endfoot\n\\hline\n" end rows_new << r end table=rows_new.join #@dob[:ao].obj=rows.join ocn_display(@dob) + start_table + table + " #{end_table}\n\\end{tiny}" else '' end end |
#longtable_portrait ⇒ Object
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 |
# File 'lib/sisu/texpdf_format.rb', line 168 def longtable_portrait end_table='\end{longtable}' row_break='\\\\\\' if @dob.is==:table tw=case @dob.tmp[:paper_size] when /a4/i then @tx.a4.portrait.w #European default, SiSU default when /letter/i then @tx.letter.portrait.w #U.S. default when /legal/i then @tx.legal.portrait.w #U.S. alternative when /book|b5/i then @tx.b5.portrait.w #book default - larger when /a5/i then @tx.a5.portrait.w else @tx.a4.portrait.w #default currently A4 end textwidth=tw.to_i - 20 colW=[] colW << '{' @dob.widths.each do |x| x=(x.to_i * textwidth)/100 #x=(x.to_i/100.0 * 160) col_w=x.to_s # x.gsub(/.+/,'l\|') #unless x.nil? colW << "p{#{col_w}mm}" if col_w end colW << '}' colW=colW.join start_table="\n\\setlength{\\LTleft}{0pt}\n\\setlength{\\LTright}{\\fill}\n" + "\\begin{tiny}\n\\begin{longtable}#{colW}\n" rows=@dob.obj.split(/#{Mx[:br_nl]}/) if @dob.head_ rows[0]=rows[0].gsub(/(^|.+?)(?:#{Mx[:tc_p]}|$)/u,'\bfseries \1&'). gsub(/&\s*$/," #{row_break} \\hline\\endhead #{row_break}") end rows_new=[] rows.each do |r| r=table_special_characters(r) r=r.gsub(/$/," #{row_break}\n") unless r =~/#{row_break*2}$/ if r=~/\<!f(.+?)!\>/ # not tested table footer if any tablefoot=$1 r=r.gsub(/\<!f(.+?)!\>/,'') r="#{r} \\multicolumn{#{@dob.cols}}{l}{\\tiny #{tablefoot}} \\\\ \\hline\n\\endfoot\n\\hline\n" end rows_new << r end table=rows_new.join #@dob[:ao].obj=rows.join ocn_display(@dob) + start_table + table + " #{end_table}\n\\end{tiny}" else '' end end |
#ocn_display(dob) ⇒ Object
104 105 106 107 108 109 |
# File 'lib/sisu/texpdf_format.rb', line 104 def ocn_display(dob) show_ocn=(@make.build.ocn?) \ ? dob.ocn : '' "\\begin{tiny}\\hspace{0mm}\\end{tiny}{\\marginpar{\\begin{tiny}\\hspace{0mm}\\hypertarget{#{dob.ocn}}{#{show_ocn}}\\end{tiny}}}" #ocn object citation numbering end |
#remove_footnotes(cont_ln) ⇒ Object
213 214 215 216 217 218 219 |
# File 'lib/sisu/texpdf_format.rb', line 213 def remove_footnotes(cont_ln) cont_ln=if cont_ln =~/\\[Ff]ootnote/m cont_ln.gsub(/\s*\\[Ff]ootnote\[\d+\]\{%\s+.+?\}\s*/m,' '). gsub(/\s*\\[Ff]ootnote[A]\{[*+]+\d*\}\{%\S+.+?\}\s*/m,' ') else cont_ln end end |
#section_heading_level(dob) ⇒ Object
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 |
# File 'lib/sisu/texpdf_format.rb', line 236 def section_heading_level(dob) dob.tmp=dob.tmp.strip if dob.tmp dob.tmp=dob.tmp.gsub(/\\begin\{(bfseries|itshape)\}(.+?)\\end\{\1\}/m,'\2'). gsub(/#{Mx[:url_o]}|#{Mx[:url_c]}/,'') cont_ln=dob.tmp.dup cont_ln=cont_ln.gsub(/\\begin\{(monosp)\}(.+?)\\end\{\1\}/m,'\2'). gsub(@@tex_pattern_margin_number,'') cont_ln=remove_footnotes(cont_ln) cont_ln=cont_ln.gsub(/\{[\\]+(&)\}/,'\\1') dob.tmp=dob.tmp.gsub(/^(.*)\n?$/m, "\\clearpage \\part*{\\1} \\addcontentsline{toc}{part}{#{cont_ln}} \\markboth{#{@md.title.full}}\n") dob end |
#section_heading_level_B ⇒ Object
295 296 297 |
# File 'lib/sisu/texpdf_format.rb', line 295 def section_heading_level_B section_heading_level(@dob) end |
#section_heading_level_C ⇒ Object
298 299 300 |
# File 'lib/sisu/texpdf_format.rb', line 298 def section_heading_level_C section_heading_level(@dob) end |
#section_heading_level_D ⇒ Object
301 302 303 |
# File 'lib/sisu/texpdf_format.rb', line 301 def section_heading_level_D section_heading_level(@dob) end |
#symbol_graphic ⇒ Object
489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 |
# File 'lib/sisu/texpdf_format.rb', line 489 def symbol_graphic dir=SiSU_Env::InfoEnv.new(@md.fns) image='c_' + /<:=\s*(\S+?)\s*>/m.match(@txt).captures.join + '.png' #watch if FileTest.file?("#{dir.path.image_source_include}/#{image}") @txt.gsub!(/<:=\s*(\S+?)\s*>/, "\\includegraphics*[width=11pt]{#{dir.path.image_source_include}/c_\\1.png}") else SiSU_Screen::Ansi.new( @md.opt.act[:color_state][:set], "ERROR - image:", %{"#{image}" missing}, "search path: #{dir.path.image_source_include}" ).error2 unless @md.opt.act[:quiet][:set]==:on @txt.gsub!(/#{Mx[:lnk_o]}\S+\.(png|jpg|gif).+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/,'') # fragile match operator\\ fragile ! end end |
#table_special_characters(r) ⇒ Object
110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/sisu/texpdf_format.rb', line 110 def table_special_characters(r) r=r.gsub(/#{Mx[:tc_p]}/mu,'&'). gsub(/#{Mx[:tc_c]}/m,'\\\\\\'). gsub(/%/,'\%'). gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'\begin{bfseries}\1 \end{bfseries}'). gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'\emph{\1}'). gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'\uline{\1}'). # ulem gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,"``\\1''"). # quote #CHECK gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'\uline{\1}'). # ulem gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'\sout{\1}'). # ulem gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,"\$^{\\textrm{\\1}}\$"). gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,"\$_{\\textrm{\\1}}\$") end |
#title ⇒ Object
730 731 732 733 |
# File 'lib/sisu/texpdf_format.rb', line 730 def title title=SiSU_TeX_Pdf::SpecialCharacters.new(@md,@md.title.full).special_characters_safe "\n\\title{#{title}}" end |
#title_landscape ⇒ Object
734 735 736 |
# File 'lib/sisu/texpdf_format.rb', line 734 def title_landscape title end |
#title_level_A ⇒ Object
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
# File 'lib/sisu/texpdf_format.rb', line 220 def title_level_A dob=@dob dob.tmp=dob.tmp.strip if dob.tmp dob.tmp=dob.tmp.gsub(/\\begin\{(bfseries|itshape)\}(.+?)\\end\{\1\}/m,'\2'). gsub(/#{Mx[:url_o]}|#{Mx[:url_c]}/,'') cont_ln=dob.tmp.dup cont_ln=cont_ln.gsub(/\\begin\{(monosp)\}(.+?)\\end\{\1\}/m,'\2'). gsub(@@tex_pattern_margin_number,'') cont_ln=remove_footnotes(cont_ln) cont_ln=cont_ln.gsub(/\{[\\]+(&)\}/,'\\1') titleset='' dob.tmp=dob.tmp.gsub(/^(.*)\n?$/m, "#{titleset}\\part*{\\1} \\markboth{#{@md.title.full}}\n") dob end |
#title_portrait ⇒ Object
737 738 739 |
# File 'lib/sisu/texpdf_format.rb', line 737 def title_portrait title end |
#url_str(str) ⇒ Object
542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 |
# File 'lib/sisu/texpdf_format.rb', line 542 def url_str(str) rgx_url_generic=/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/m while str =~rgx_url_generic if str=~rgx_url_generic regx_url=%r/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/m z,url=regx_url.match(str).captures if str =~regx_url url=url.strip link=z.strip link.gsub!(/&/,"#{Xx[:protect]}&") str.sub!(rgx_url_generic,"#{url_decoration.tex_open}\\href{#{url}}{#{link}}#{url_decoration.tex_close}") str=str.gsub(/#{Xx[:protect]}/,'') str else str end str end str end |
#url_str_internal(str, idx = nil) ⇒ Object
505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 |
# File 'lib/sisu/texpdf_format.rb', line 505 def url_str_internal(str,idx=nil) =SiSU_Particulars::CombinedSingleton.instance.(@md). #p map_nametags rgx_url_internal=/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:rel_o]}#?\S+?#{Mx[:rel_c]}/m while str =~/#{Mx[:lnk_o]}([^#{Mx[:lnk_o]}#{Mx[:lnk_c]}]+)#{Mx[:lnk_c]}#{Mx[:rel_o]}:(\S+?)#{Mx[:rel_c]}/m link,url=$1,$2 link,url=link.strip,url.strip link.gsub!(/&/,"#{Xx[:protect]}&") url="#{@env.url.root}/" + url str.sub!(/#{Mx[:lnk_o]}[^#{Mx[:lnk_o]}#{Mx[:lnk_c]}]+#{Mx[:lnk_c]}#{Mx[:rel_o]}:\S+?#{Mx[:rel_c]}/m, "#{url_decoration.tex_open}\\href{#{url}}{#{link}}#{url_decoration.tex_close}") end while str =~/#{Mx[:lnk_o]}([^#{Mx[:lnk_o]}#{Mx[:lnk_c]}]+)#{Mx[:lnk_c]}#{Mx[:rel_o]}#?(\S+?)#{Mx[:rel_c]}/m link,url=$1,$2 link,url=link.strip,url.strip link.gsub!(/&/,"#{Xx[:protect]}&") url.gsub!(/\\_/,'_') ocn_lnk=if [url] \ and [url][:ocn] [url][:ocn] else nil end ocn_lnk=(url=~/^\d+$/ ? url : ocn_lnk) if ocn_lnk and not ocn_lnk.empty? idx \ ? (str.sub!(rgx_url_internal,"\\hyperlink{#{ocn_lnk}}{#{link}}")) : (str.sub!(rgx_url_internal,"#{url_decoration.tex_open}\\hyperlink{#{ocn_lnk}}{#{link}}#{url_decoration.tex_close}")) else puts %{name tag: "#{url}" not found} str.sub!(rgx_url_internal,"#{link}") end #[keep] code that follows uses nametags directly, currently nametags converted to their ocn, related code: |texpdf.rb|@|hypertargets| #idx \ #? (str.sub!(rgx_url_internal,"\\hyperlink{#{url}}{#{link}}")) \ #: (str.sub!(rgx_url_internal,"#{url_decoration.tex_open}\\hyperlink{#{url}}{#{link}}#{url_decoration.tex_close}")) end str=str.gsub(/#{Xx[:protect]}/,'') end |
#url_with_txt(dob) ⇒ Object
560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 |
# File 'lib/sisu/texpdf_format.rb', line 560 def url_with_txt(dob) rgx_url_generic=/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/m while dob.tmp =~rgx_url_generic if dob.tmp=~rgx_url_generic if dob.tmp =~/#{Mx[:lnk_o]}(?:.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/m regx_url=%r/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/m punctuate=/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/m.match(dob.tmp).captures.join else regx_url=%r/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/m punctuate='' end z,url=regx_url.match(dob.tmp).captures if dob.tmp =~regx_url url=url.strip link=z.strip link.gsub!(/&/,"#{Xx[:protect]}&") dob.tmp.sub!(rgx_url_generic,"#{url_decoration.tex_open}\\href{#{url}}{#{link}}#{url_decoration.tex_close}#{punctuate}") dob.tmp.gsub!(/#{Xx[:protect]}/,'') #dob.tmp=dob.tmp.sub(rgx_url_generic,"#{url_decoration.tex_open}\\href{#{url}}{#{link}}#{url_decoration.tex_close}#{punctuate}"). # gsub(/#{Xx[:protect]}/,'') dob else dob end dob end dob end |
#urls_txt_and_images ⇒ Object
586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 |
# File 'lib/sisu/texpdf_format.rb', line 586 def urls_txt_and_images dob=@dob dir=SiSU_Env::InfoEnv.new(@md.fns) @dm={ 'a4'=> @tx.a4.landscape.img_px, 'letter'=> @tx.letter.landscape.img_px, 'legal'=> @tx.legal.landscape.img_px, 'b5'=> @tx.b5.landscape.img_px, 'a5'=> @tx.a5.landscape.img_px } images_hash={ } generic_rgx=/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image\b)/m rgx_url_generic=/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/m #url_bare_rgx=/#{Mx[:url_o]}\S+?#{Mx[:url_c]}/m url_image_rgx=/#{Mx[:lnk_o]}[a-zA-Z0-9_\\-]+\.(?:png|jpg|gif).+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/m image_rgx=/#{Mx[:lnk_o]}[a-zA-Z0-9_\\-]+\.(?:png|jpg|gif).+?#{Mx[:lnk_c]}image/m @md.papersize_array.each do |ps| images_hash[ps] = dob.tmp while images_hash[ps] =~generic_rgx if dob.tmp =~rgx_url_generic \ and dob.tmp !~/\.(?:png|jpg|gif)|#{Mx[:lnk_c]}image\b/m dob=url_with_txt(dob) elsif images_hash[ps]=~generic_rgx if dob.tmp=~rgx_url_generic if images_hash[ps] =~/#{Mx[:lnk_o]}(?:.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/m regx_url=%r/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/m punctuate=/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/m.match(images_hash[ps]).captures.join else regx_url=%r/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/m punctuate='' end z,url=regx_url.match(images_hash[ps]).captures if images_hash[ps] =~regx_url url=url.strip else if images_hash[ps] =~/#{Mx[:lnk_o]}(?:.+?)#{Mx[:lnk_c]}image\.[^'"\s]+?(?:[;.,]?(?:\s|$)|(?:\s|$))/m regx_url=%r/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}image\.[^'"\s]+?(?:[;.,]?(?:\s|$)|(?:\s|$))/m punctuate=/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}image\.[^'"\s]+?([;.,]?(?:\s|$))/m.match(images_hash[ps]).captures.join else regx_url=%r/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}image/m punctuate='' end z=regx_url.match(images_hash[ps])[1] if images_hash[ps] =~regx_url url='' end if images_hash[ps] =~/#{Mx[:lnk_o]}\s*\S+\.?(?:png|jpg|gif)/m \ and images_hash[ps]=~/\s+\d+x\d+(\s+|\s*#{Mx[:lnk_c]})/m image=z.scan(/\S+/)[0] #image,x,y=z.scan(/\S+/) image.gsub!(/\\/,'') w=((z =~/\s(\d+)x\d*/) ? z[/\s(\d+)x\d*/,1] : 200) width={} width['a4'] = ((w.to_i > @dm['a4']) ? @dm['a4'] : w) width['letter'] = ((w.to_i > @dm['letter']) ? @dm['letter'] : w) width['legal'] = ((w.to_i > @dm['legal']) ? @dm['legal'] : w) width['a5'] = ((w.to_i > @dm['a5']) ? @dm['a5'] : w) width['b5'] = ((w.to_i > @dm['b5']) ? @dm['b5'] : w) c=z[/``(.+?)''/m,1] hsp="\n{\\color{mywhite} .}&~\n" # ~ character for hardspace =(c ? "{\\\\\ \n\\begin{scriptsize}#{hsp*3}#{c}\\end{scriptsize}&}" : '') elsif images_hash[ps] =~/#{Mx[:lnk_o]}\s*(\S+\.?\.(?:png|jpg|gif))/m SiSU_Screen::Ansi.new( @md.opt.act[:color_state][:set], %{document built without image: "#{$1}" as image dimensions not provided (either image not found or neither imagemagick nor graphicsmagick is installed)?\n} ).print_grey #unless @md.opt.act[:quiet][:set]==:on images_hash[ps].gsub!(/#{Mx[:lnk_o]}\s*(\S+\.?\.(?:png|jpg|gif))/,'[image]') end if image #most images fc etc. #% clean up ! if FileTest.file?("#{dir.path.image_source_include}/#{image}") case images_hash[ps] when url_image_rgx images_hash[ps].sub!(url_image_rgx, "#{@center_begin}\\\n\\href{#{url}}\n{\\includegraphics*[width=#{width[ps]}pt]{#{dir.path.image_source_include}/#{image}}}#{}#{@center_end}") when image_rgx images_hash[ps].sub!(image_rgx, "#{@center_begin}\\\n\\includegraphics*[width=#{width[ps]}pt]{#{dir.path.image_source_include}/#{image}}#{}#{@center_end}") end images_hash[ps] elsif @md.opt.f_pth[:pth] =~/\/\S+?\/sisupod\/\S+?\/sisupod\/doc/ pt=/(\/\S+?\/sisupod\/\S+?\/sisupod)\/doc/.match(@md.opt.f_pth[:pth])[1] img_src=pt + '/image' if FileTest.file?("#{img_src}/#{image}") case images_hash[ps] when url_image_rgx images_hash[ps].sub!(url_image_rgx, "#{@center_begin}\\\n\\href{#{url}}{\\includegraphics*[width=#{width[ps]}pt]{#{img_src}/#{image}}}#{} #{@center_end}") when image_rgx images_hash[ps].sub!(image_rgx, "#{@center_begin}\\\n\\includegraphics*[width=#{width[ps]}pt]{#{img_src}/#{image}}#{} #{@center_end}") end images_hash[ps] end elsif @md.fns =~/\.(?:ssm\.)?sst$/ \ and FileTest.file?("#{dir.path.image_source_include_local}/#{image}") case images_hash[ps] when url_image_rgx images_hash[ps].sub!(url_image_rgx, "#{@center_begin}\\\n\\href{#{url}}{\\includegraphics*[width=#{width[ps]}pt]{#{dir.path.image_source_include_local}/#{image}}}#{} #{@center_end}") when image_rgx images_hash[ps].sub!(image_rgx, "#{@center_begin}\\\n\\includegraphics*[width=#{width[ps]}pt]{#{dir.path.image_source_include_local}/#{image}}#{} #{@center_end}") end images_hash[ps] elsif @md.fns =~/\.-ss[tm]$/ \ and FileTest.file?("#{dir.path.image_source_include_remote}/#{image}") case images_hash[ps] when url_image_rgx images_hash[ps].sub!(url_image_rgx, "#{@center_begin}\\\n\\href{#{url}}{\\includegraphics*[width=#{width[ps]}pt]{#{dir.path.image_source_include_remote}/#{image}}}#{}#{@center_end}") when image_rgx images_hash[ps].sub!(image_rgx, "#{@center_begin}\\\n\\includegraphics*[width=#{width[ps]}pt]{#{dir.path.image_source_include_remote}/#{image}}#{}#{@center_end}") end images_hash[ps] else SiSU_Screen::Ansi.new( @md.opt.act[:color_state][:set], "ERROR - image:", %{"#{image}" missing}, "search locations: #{dir.path.image_source_include_local}, #{dir.path.image_source_include_remote} and #{dir.path.image_source_include}" ).error2 unless @md.opt.act[:quiet][:set]==:on if images_hash[ps] =~url_image_rgx \ or images_hash[ps] =~image_rgx images_hash[ps]='' end images_hash[ps] end else link=z.strip #[/(.+?)\\/m,1] images_hash[ps]="\\href{#{url}}{#{link}}#{punctuate}" if images_hash[ps] =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/ images_hash[ps] end else images_hash[ps] end images_hash[ps] #=ocn_display(dob) + images_hash[ps] end #while loop images_hash end use_images_hash={} images_hash.each do |k,t| use_images_hash[k]={ l: t, p: t} end dob.tmp=use_images_hash dob end |