| 1 |
<?php
|
| 2 |
// $Id$
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
* Provide the LaTeX-to-HTML transformation rules.
|
| 7 |
*/
|
| 8 |
|
| 9 |
/**
|
| 10 |
* Implementation of subhook_info().
|
| 11 |
*/
|
| 12 |
function drutex_latex_info($format = -1) {
|
| 13 |
return (object) array(
|
| 14 |
'title' => t('LaTeX to HTML'),
|
| 15 |
'description' => t('Converts many LaTeX commands and environments to plain HTML.'),
|
| 16 |
'toggle' => true,
|
| 17 |
'weight' => 4
|
| 18 |
);
|
| 19 |
}
|
| 20 |
|
| 21 |
/**
|
| 22 |
* Implementation of subhook_defaults().
|
| 23 |
*/
|
| 24 |
function drutex_latex_defaults() {
|
| 25 |
$D['drutex_latex_active'] = false;
|
| 26 |
return $D;
|
| 27 |
}
|
| 28 |
|
| 29 |
/**
|
| 30 |
* Implementation of subhook_node2html().
|
| 31 |
*/
|
| 32 |
function drutex_latex_node2html() {
|
| 33 |
$E = array();
|
| 34 |
|
| 35 |
$E[] = (object) array(
|
| 36 |
'type' => 'latex-command',
|
| 37 |
'pattern' => 'section',
|
| 38 |
'replacement' => '<h2 class="section">$1</h2>'
|
| 39 |
);
|
| 40 |
|
| 41 |
$E[] = (object) array(
|
| 42 |
'type' => 'latex-command',
|
| 43 |
'pattern' => 'subsection',
|
| 44 |
'replacement' => '<h3 class="subsection">$1</h3>'
|
| 45 |
);
|
| 46 |
|
| 47 |
$E[] = (object) array(
|
| 48 |
'type' => 'latex-command',
|
| 49 |
'pattern' => 'minisection',
|
| 50 |
'replacement' => '<h3 class="minisection">$1</h3>'
|
| 51 |
);
|
| 52 |
|
| 53 |
$E[] = (object) array(
|
| 54 |
'type' => 'latex-command',
|
| 55 |
'pattern' => 'paragraph',
|
| 56 |
'replacement' => '<h4 class="paragraph">$1</h4>'
|
| 57 |
);
|
| 58 |
|
| 59 |
$E[] = (object) array(
|
| 60 |
'type' => 'latex-command',
|
| 61 |
'pattern' => 'textbf',
|
| 62 |
'replacement' => '<b>$1</b>'
|
| 63 |
);
|
| 64 |
|
| 65 |
$E[] = (object) array(
|
| 66 |
'type' => 'latex-command',
|
| 67 |
'pattern' => 'textit',
|
| 68 |
'replacement' => '<i>$1</i>'
|
| 69 |
);
|
| 70 |
|
| 71 |
$E[] = (object) array(
|
| 72 |
'type' => 'latex-command',
|
| 73 |
'pattern' => 'emph',
|
| 74 |
'replacement' => '<em>$1</em>'
|
| 75 |
);
|
| 76 |
|
| 77 |
|
| 78 |
/*
|
| 79 |
regex hacks for:
|
| 80 |
enumeration aka ordered list
|
| 81 |
itemize aka unordered list
|
| 82 |
*/
|
| 83 |
|
| 84 |
$E[] = (object) array(
|
| 85 |
'pattern' => '@\\\\begin\{enumerate\}@s',
|
| 86 |
'replacement' => '<ol class="enumerate">',
|
| 87 |
'weight' => 100
|
| 88 |
);
|
| 89 |
|
| 90 |
$E[] = (object) array(
|
| 91 |
'pattern' => '@\\\\begin\{itemize\}@s',
|
| 92 |
'replacement' => '<ul class="itemize">',
|
| 93 |
'weight' => 100
|
| 94 |
);
|
| 95 |
|
| 96 |
$E[] = (object) array(
|
| 97 |
'pattern' => '@\\\\item(.*?)(?=\\\\item|\\\\end\{enumerate\}|\\\\end\{itemize\})@s',
|
| 98 |
'replacement' => "<li>$1</li>",
|
| 99 |
'weight' => 101
|
| 100 |
);
|
| 101 |
|
| 102 |
$E[] = (object) array(
|
| 103 |
'pattern' => '@\\\\end\{enumerate\}@s',
|
| 104 |
'replacement' => "</ol>",
|
| 105 |
'weight' => 102
|
| 106 |
);
|
| 107 |
|
| 108 |
$E[] = (object) array(
|
| 109 |
'pattern' => '@\\\\end\{itemize\}@s',
|
| 110 |
'replacement' => "</ul>",
|
| 111 |
'weight' => 102
|
| 112 |
);
|
| 113 |
|
| 114 |
return $E;
|
| 115 |
}
|