Skip to content
Snippets Groups Projects
Commit ad656e38 authored by Chris Burschka's avatar Chris Burschka
Browse files

xbbcode_tex was long dead.

git-svn-id: http://svn.ermarian.net/drupal/modules/xbbcode/branches/DRUPAL-5@238 e07e5eb3-9d27-0410-88b2-edc8e7ca7259
parent 94121a7a
No related branches found
No related tags found
No related merge requests found
name = LaTeX conversion
description = Converts standard XBBCode tags to their LaTeX equivalent.
dependencies = xbbcode
package = Filters
<?php
function xbbcode_tex_xbbcode($op='list',$delta=NULL,$tag=NULL)
{
switch ($op)
{
case 'list':
case 'info':
return xbbcode_tex_info($delta);
case 'render':
return xbbcode_tex_process($delta,$tag);
}
}
function xbbcode_tex_info($tag='')
{
$tags['i']=array('replacewith'=>'\begin{itshape}{content}\end{itshape}');
$tags['b']=array('replacewith'=>'\begin{bfseries}{content}\end{bfseries}');
$tags['h1']=array('replacewith'=>'\section{{content}}');
$tags['h2']=array('replacewith'=>'\subsection{{content}}');
$tags['h3']=array('replacewith'=>'\subsubsection{{content}}');
$tags['list']=array('dynamic'=>true);
if ($tag) return $tags[$tag];
else return array_keys($tags);
}
function xbbcode_tex_process($delta,$tag)
{
$f="xbbcode_tex_render_$delta";
//var_dump($f);
return $f($tag->content,$tag->option,$tag);
}
function xbbcode_tex_render_list($text,$type) {
/* nested lists? */
//var_dump($text);
$text=preg_replace('/\[list[^\]]*?\].*?\[\/list[^\]]*?\]/ies','xbbcode_escape_list(\'$0\')',$text);
//var_dump($text);
$text=explode("[*]",$text);
unset($text[0]);
$text = '\item '.implode('\item ',$text);
$text = str_replace("[*-]","[*]",$text);
switch($type) {
case 'o':return '\begin{enumerate}'.$text.'\end{enumerate}';
case 'ul':
default: return '\begin{itemize}'.$text.'\end{itemize}';
}
}
function xbbcode_escape_list($text)
{
//var_dump($text);
return str_replace("[*]","[*-]",$text);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment