Changeset 8098 for trunk/gsdl/perllib/plugins
- Timestamp:
- 2004-09-03T16:36:33+12:00 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/perllib/plugins/LaTeXPlug.pm
r8097 r8098 22 22 ########################################################################### 23 23 24 # todo: 25 # \includegraphics 26 # parse/remove tex \if ... macros 24 27 25 28 package LaTeXPlug; … … 119 122 $$textref =~ m@\\title\s*{(.*?)}@s; 120 123 my $title = $1; 124 if (!$title) { 125 # no title tag. look for a chapter/section heading 126 $$textref =~ m@\\(?:chapter|section)\s*{(.*?)}@s; # will get 1st match 127 $title = $1; 128 } 129 if (!$title) { 130 # no chapter/section heading tags either... use filename 131 $title = $file; 132 $title =~ s/\.tex$//i; 133 $title =~ s/[-_.]/ /g; # turn punctuation into spaces 134 } 121 135 if ($title) { 122 136 $title =~ s@\\\\@ @g; # embedded newlines … … 379 393 $text =~ s~\\(?:texttt|tt|ttseries)\s*{(.*?)}~<tt>$1</tt>~g; 380 394 $text =~ s~\\emph{(.*?)}~<em>$1</em>~g; 381 $text =~ s~{\\ em\s*(.*?)}~<em>$1</em>~g;395 $text =~ s~{\\(?:em|it)\s*(.*?)}~<em>$1</em>~g; 382 396 $text =~ s~{\\(?:bf|bfseries)\s*(.*?)}~<strong>$1</strong>~g; 383 397 $text =~ s~\\(?:textbf|bf|bfseries)\s*{(.*?)}~<strong>$1</strong>~g; … … 445 459 return $verbatim; 446 460 } 447 461 # only used by process_latex_math 462 # returns a unicode char if applicable, otherwise ascii 463 sub math_fraction { 464 my $num=$1; 465 my $denom=$2; 466 467 if ($num==1 && $denom==2) {return chr(0xc2).chr(0xbd)} 468 if ($num==1 && $denom==4) {return chr(0xc2).chr(0xbc)} 469 if ($num==3 && $denom==4) {return chr(0xc2).chr(0xbe)} 470 return "$num/$denom"; 471 } 448 472 449 473 sub process_latex_math { … … 458 482 # $text =~ s~\\cup\b~\xe2\xc8\xaa~g; # union operator - unicode 0x222a 459 483 $text =~ s~\\cup\b~ U ~g; 484 485 $text =~ s~\\frac\s*{(.+?)}{(.+?)}~math_fraction($1,$2)~ge; 460 486 461 487 if ($html_markup) {
Note:
See TracChangeset
for help on using the changeset viewer.