[ Index ] |
|
Code source de Serendipity 1.2 |
1 <?php 2 3 /** 4 * 5 * Formats parsed Text_Wiki for LaTeX rendering. 6 * 7 * $Id: Latex.php,v 1.2 2004/09/25 19:05:13 pmjones Exp $ 8 * 9 * @author Jeremy Cowgar <jeremy@cowgar.com> 10 * 11 * @package Text_Wiki 12 * 13 * @todo [http://google.com] becomes 1 with a LaTeX footnote in subscript. 14 * This should be a normal LaTeX footnote associated with the 15 * previous word? 16 * 17 * @todo parse "..." to be ``...'' 18 * 19 * @todo parse '...' to be `...' 20 * 21 * @todo move escape_latex to a static function, move escaping to the 22 * individual .php files they are associated with 23 * 24 * @todo allow the user to add conf items to do things like 25 * + A custom document header 26 * + Custom page headings 27 * + Include packages 28 * + Set Title, Author, Date 29 * + Include a title page 30 * + Not output Document Head/Foot (maybe combinding many pages?) 31 * 32 */ 33 34 class Text_Wiki_Render_Latex extends Text_Wiki_Render { 35 function escape_latex ($txt) { 36 $txt = str_replace("\\", "\\\\", $txt); 37 $txt = str_replace('#', '\#', $txt); 38 $txt = str_replace('$', '\$', $txt); 39 $txt = str_replace('%', '\%', $txt); 40 $txt = str_replace('^', '\^', $txt); 41 $txt = str_replace('&', '\&', $txt); 42 $txt = str_replace('_', '\_', $txt); 43 $txt = str_replace('{', '\{', $txt); 44 $txt = str_replace('}', '\}', $txt); 45 46 // Typeset things a bit prettier than normas 47 $txt = str_replace('~', '$\sim$', $txt); 48 $txt = str_replace('...', '\ldots', $txt); 49 50 return $txt; 51 } 52 53 function escape($tok, $ele) { 54 if (isset($tok[$ele])) { 55 $tok[$ele] = $this->escape_latex($tok[$ele]); 56 } 57 58 return $tok; 59 } 60 61 function pre() 62 { 63 foreach ($this->wiki->tokens as $k => $tok) { 64 if ($tok[0] == 'Code') { 65 continue; 66 } 67 68 $tok[1] = $this->escape($tok[1], 'text'); 69 $tok[1] = $this->escape($tok[1], 'page'); 70 $tok[1] = $this->escape($tok[1], 'href'); 71 72 $this->wiki->tokens[$k] = $tok; 73 } 74 75 $this->wiki->source = $this->escape_latex($this->wiki->source); 76 77 return 78 "\\documentclass{article}\n". 79 "\\usepackage{ulem}\n". 80 "\\pagestyle{headings}\n". 81 "\\begin{document}\n"; 82 } 83 84 function post() 85 { 86 return "\\end{document}\n"; 87 } 88 89 } 90 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sat Nov 24 09:00:37 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |