You can use a simple plugin for this. Save the following code as /plugins/serendipity_event_latex/serendipity_event_latex.php.
I needed to modify the code a bit. You need to use $$LATEX
CODE$$ and it will transfer that. The double $$ was used so that you will still be able to use the $ sign in entries.
You may need to edit the string "/cgi-bin/latex.cgi" in the code to point to the right .cgi file!
Code: Select all
<?php # $Id: serendipity_event_latex.php,v 1.13 2005/01/04 10:06:34 garvinhicking Exp $
switch ($serendipity['lang']) {
case 'en':
default:
@define('PLUGIN_EVENT_LATEX_NAME', 'Markup: Latex-Code');
@define('PLUGIN_EVENT_LATEX_DESC', 'Markup text using LATEX and cgi transcoding');
break;
}
class serendipity_event_latex extends serendipity_event
{
var $title = PLUGIN_EVENT_LATEX_NAME;
function introspect(&$propbag)
{
global $serendipity;
$propbag->add('name', PLUGIN_EVENT_LATEX_NAME);
$propbag->add('description', PLUGIN_EVENT_LATEX_DESC);
$propbag->add('stackable', false);
$propbag->add('author', 'Garvin Hicking');
$propbag->add('version', '1.0');
$propbag->add('cachable_events', array('frontend_display' => true));
$propbag->add('event_hooks', array('frontend_display' => true));
$this->markup_elements = array(
array(
'name' => ENTRY_BODY,
'element' => 'body',
),
array(
'name' => EXTENDED_BODY,
'element' => 'extended',
),
array(
'name' => COMMENT,
'element' => 'comment',
),
array(
'name' => HTML_NUGGET,
'element' => 'html_nugget',
)
);
$conf_array = array();
foreach($this->markup_elements as $element) {
$conf_array[] = $element['name'];
}
$propbag->add('configuration', $conf_array);
}
function generate_content(&$title) {
$title = $this->title;
}
function introspect_config_item($name, &$propbag)
{
switch($name) {
default:
$propbag->add('type', 'boolean');
$propbag->add('name', $name);
$propbag->add('description', sprintf(APPLY_MARKUP_TO, $name));
$propbag->add('default', 'true');
break;
}
return true;
}
function install() {
serendipity_plugin_api::hook_event('backend_cache_entries', $this->title);
}
function uninstall() {
serendipity_plugin_api::hook_event('backend_cache_purge', $this->title);
serendipity_plugin_api::hook_event('backend_cache_entries', $this->title);
}
function event_hook($event, &$bag, &$eventData) {
global $serendipity;
$hooks = &$bag->get('event_hooks');
if (isset($hooks[$event])) {
switch($event) {
case 'frontend_display':
foreach ($this->markup_elements as $temp) {
if (serendipity_db_bool($this->get_config($temp['name'], true)) && isset($eventData[$temp['element']])) {
$element = $temp['element'];
$eventData[$element] = preg_replace('@\$\$(.*)\$\$@', '<img src="/cgi-bin/latex.cgi?\1" alt="\1" />', $eventData[$element]);
}
}
return true;
break;
default:
return false;
}
} else {
return false;
}
}
}
/* vim: set sts=4 ts=4 expandtab : */
?>