1
0
mirror of synced 2025-01-07 17:47:10 +03:00
doctrine2/manual/lib/Text/Wiki/Render/Latex/Code.php

45 lines
1.0 KiB
PHP
Raw Normal View History

2007-09-01 03:38:43 +04:00
<?php
class Text_Wiki_Render_Latex_Code extends Text_Wiki_Render {
2008-01-23 19:37:39 +03:00
2007-09-01 03:38:43 +04:00
/**
2008-01-23 19:37:39 +03:00
*
2007-09-01 03:38:43 +04:00
* Renders a token into text matching the requested format.
2008-01-23 19:37:39 +03:00
*
2007-09-01 03:38:43 +04:00
* @access public
2008-01-23 19:37:39 +03:00
*
2007-09-01 03:38:43 +04:00
* @param array $options The "options" portion of the token (second
* element).
2008-01-23 19:37:39 +03:00
*
2007-09-01 03:38:43 +04:00
* @return string The text rendered from the token options.
2008-01-23 19:37:39 +03:00
*
2007-09-01 03:38:43 +04:00
*/
2008-01-23 19:37:39 +03:00
2007-09-01 03:38:43 +04:00
function token($options)
{
$text = $options['text'];
$attr = $options['attr'];
$type = strtolower($attr['type']);
2008-01-23 19:37:39 +03:00
2007-09-01 03:38:43 +04:00
if ($type == 'php') {
if (substr($options['text'], 0, 5) != '<?php') {
// PHP code example:
// add the PHP tags
$text = "<?php\n\n" . $options['text'] . "\n\n?>"; // <?php
}
}
2008-01-23 19:37:39 +03:00
$text = "\\begin{lstlisting}[caption={} {}]\n$text\n\\end{lstlisting}\n\n";
2007-09-01 03:38:43 +04:00
if ($type != '') {
$text = "\\lstset{language=$type}\n" . $text;
} else {
$text = "\\lstset{language={}}\n" . $text;
}
return $text;
}
}
?>