)([^<]*)(<\/pre>)/', array($this,'escape_verbatim'), $html);
//
$html = preg_replace_callback('/([^<]*)<\/code>/', array($this,'escape_verb'), $html);
//runbar
$html = preg_replace('/ /',
'\href{http://www.pradosoft.com/demos/quickstart/index.php?page=$1}{$1 Demo}', $html);
//DocLink
$html = preg_replace('/ /',
'\href{http://www.pradosoft.com/docs/manual/$1/$2.html}{$3}', $html);
$html = preg_replace('/ /',
'\href{http://www.pradosoft.com/docs/manual/$1/$2.html}{$1.$2 API Reference}', $html);
//text modifiers
$html = preg_replace('/<(b|strong)[^>]*>([^<]*)<\/(b|strong)>/', '\textbf{$2}', $html);
$html = preg_replace('/]*>([^<]*)+?<\/i>/', '\emph{$1}', $html);
$html = preg_replace_callback('/([^<]*)<\/tt>/', array($this,'texttt'), $html);
//links
$html = preg_replace_callback('/]+href="([^"]*)"[^>]*>([^<]*)<\/a>/',
array($this,'make_link'), $html);
//anchor
$html = preg_replace_callback('/]+name="([^"]*)"[^>]*><\/a>/', array($this,'anchor'), $html);
//description
$html = preg_replace('/- ([^<]*)<\/dt>/', '\item[$1]', $html);
$html = preg_replace('/<\/?dd>/', '', $html);
$html = preg_replace('/
/', '\begin{description}', $html);
$html = preg_replace('/<\/dl>/', '\end{description}', $html);
//item lists
$html = preg_replace('/]*>/', '\begin{itemize}', $html);
$html = preg_replace('/<\/ul>/', '\end{itemize}', $html);
$html = preg_replace('/]*>/', '\begin{enumerate}', $html);
$html = preg_replace('/<\/ol>/', '\end{enumerate}', $html);
$html = preg_replace('/- ]*>/', '\item ', $html);
$html = preg_replace('/<\/li>/', '', $html);
//headings
$html = preg_replace('/
([^<]+)<\/h1>/', '\section{$2}', $html);
$html = preg_replace('/([^<]+)<\/h2>/', '\subsection{$2}', $html);
$html = preg_replace('/([^<]+)<\/h3>/', '\subsubsection{$2}', $html);
//div box
$html = preg_replace_callback('/((.|\n)*?)<\/div>/',
array($this, 'mbox'), $html);
//tabular
$html = preg_replace_callback('/\s*]*>((.|\n)*?)<\/table>/',
array($this, 'tabular'), $html);
$html = preg_replace('//', '', $html);
$html = preg_replace('/((.|\n)*?)<\/div>/', '', $html);
//useless divs
$html = preg_replace('/]*">((.|\n)*?)<\/div>/', '$1', $html);
//since
$html = preg_replace('/]+>/', '', $html);
//requiresversion
$html = preg_replace('/]+>/', '', $html);
$html = html_entity_decode($html);
return $html;
}
function tabular($matches)
{
$options = array();
foreach(explode(',', $matches[1]) as $string)
{
$sub = explode('=', trim($string));
$options[trim($sub[0])] = trim($sub[1]);
}
$widths = explode(' ',preg_replace('/\(|\)/', '', $options['width']));
$this->_tabular_widths = $widths;
$this->_tabular_total = count($widths);
$this->_tabular_col = 0;
$begin = '\begin{table}[!hpt]\centering '."\n".' \begin{tabular}{'.$options['align'].'}\hline';
$end = '\end{tabular} '."\n".'\end{table}'."\n";
$table = preg_replace('/<\/tr>/', '\\\\\\\\ \hline', $matches[2]);
$table = preg_replace('//', '', $table);
$table = preg_replace('/([^<]+)<\/th>/', '\textbf{$1} &', $table);
$table = preg_replace_callback('/ ((.|\n)*?)<\/td>/', array($this, 'table_column'), $table);
$table = preg_replace('/
/', ' \\\\\\\\', $table);
$table = preg_replace('/&\s*\\\\\\\\/', '\\\\\\\\', $table);
return $begin.$table.$end;
}
function table_column($matches)
{
$width = $this->_tabular_widths[$this->_tabular_col];
if($this->_tabular_col >= $this->_tabular_total-1)
$this->_tabular_col = 0;
else
$this->_tabular_col++;
return '\begin{minipage}{'.$width.'\textwidth}\vspace{3mm}'.
$matches[1].'\vspace{3mm}\end{minipage} & ';
}
function mbox($matches)
{
return "\n\begin{mybox}\n".$matches[1]."\n".'\end{mybox}'."\n";
}
function get_chapter_label($chapter)
{
return '\hypertarget{'.str_replace(' ', '', $chapter).'}{}';
}
function get_section_label($section)
{
$section = str_replace('.page', '', $section);
return '\hypertarget{'.str_replace('/', '.', $section).'}{}';
}
function set_header_id($content, $j)
{
$this->page_count=$j;
$content = preg_replace_callback('//', array($this,"h1"), $content);
$content = preg_replace_callback('//', array($this,"h2"), $content);
$content = preg_replace_callback('//', array($this,"h3"), $content);
$content = $this->set_block_content_id($content);
return $content;
}
function h1($matches)
{
$page = $this->page_count*1000;
return "";
}
function h2($matches)
{
$page = $this->page_count*1000;
return "";
}
function h3($matches)
{
$page = $this->page_count*1000;
return "";
}
function set_block_content_id($content)
{
$content = preg_replace_callback('/
/', array($this, 'add_p'), $content);
$content = preg_replace_callback('/]+)>/', array($this, 'hil'), $content);
return $content;
}
function hil($matches)
{
$id = ($this->page_count*10000) + (++self::$hil_count);
if(preg_match('/id="code-\d+"/i', $matches[1]))
{
$code = preg_replace('/id="code-(\d+)"/', 'id="code_$1"', $matches[0]);
//var_dump($code);
return $code;
}
else if(preg_match('/id="[^"]+"/i', $matches[1]))
{
return $matches[0];
}
else
{
$changes = str_replace('"source"', '"source block-content" id="code-'.$id.'"', $matches[0]);
return $changes;
}
}
function add_p($matches)
{
$page = $this->page_count*10000;
return "";
}
}
?>