]*>/', '', $html); $html = preg_replace('/<\/?p>/m', '', $html); //escape { and } $html = preg_replace('/([^\s]+){([^}]*)}([^\s]+)/', '$1\\\{$2\\\}$3', $html); //codes $html = str_replace('$', '\$', $html); $html = preg_replace('/]*>/', '`1`', $html); $html = preg_replace('/<\/com:TTextHighlighter>/', '`2`', $html); $html = preg_replace_callback('/(`1`)([^`]*)(`2`)/m', 'escape_verbatim', $html); $html = preg_replace_callback('/(
)([^<]*)(<\/div>)/', 'escape_verbatim', $html); $html = preg_replace_callback('/(
)([^<]*)(<\/pre>)/', 'escape_verbatim', $html);

	//
	$html = preg_replace_callback('/([^<]*)<\/code>/', 'escape_verb', $html);

	$html = preg_replace_callback('/"?[^\\/]*\/>/', 'include_image', $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}{$1.$2 API Reference}', $html);

	//text modifiers
	$html = preg_replace('/([^<]*)<\/b>/', '\textbf{$1}', $html);
	$html = preg_replace('/([^<]*)<\/i>/', '\emph{$1}', $html);
	$html = preg_replace_callback('/([^<]*)<\/tt>/', 'texttt', $html);

	//links
	$html = preg_replace_callback('/]+href="([^"]*)"[^>]*>([^<]*)<\/a>/',
							'make_link', $html);
	//anchor
	$html = preg_replace_callback('/]+name="([^"]*)"[^>]*><\/a>/', '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('/
    1. /', '\item ', $html); $html = preg_replace('/<\/li>/', '', $html); //headings $html = preg_replace('/([^<]+)<\/h1>/', '\section{$1}', $html); $html = preg_replace('/([^<]+)<\/h2>/', '\subsection{$1}', $html); $html = preg_replace('/([^<]+)<\/h3>/', '\subsubsection{$1}', $html); $html = html_entity_decode($html); return $html; } 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, $count) { global $header_count; $header_count = $count*100; $content = preg_replace_callback('/

      /', "h1", $content); $content = preg_replace_callback('/

      /', "h2", $content); $content = preg_replace_callback('/

      /', "h3", $content); return $content; } function h1($matches) { global $header_count; return "

      "; } function h2($matches) { global $header_count; return "

      "; } function h3($matches) { global $header_count; return "

      "; } $header_count = 0; //--------------- BEGIN PROCESSING ------------------- //--------------- Indexer ------------------- //require_once('create_index.php'); //$indexer = new quickstart_index($index_dir); // ---------------- Create the Tex files --------- $count = 1; $j = 1; $current_path = ''; echo "Compiling .page files to Latex files\n\n"; foreach($pages as $chapter => $sections) { $content = '\chapter{'.$chapter.'}'.get_chapter_label($chapter); echo "Creating ch{$count}.txt => Chapter {$count}: {$chapter}\n"; echo str_repeat('-',60)."\n"; foreach($sections as $section) { echo " Adding $section\n"; $page = $base.'/'.$section; $current_path = $page; //add id to

      ,

      , <3> $tmp_content = set_header_id(file_get_contents($page),$j++); file_put_contents($page, $tmp_content); $content .= get_section_label($section); $file_content = file_get_contents($page); $tex = $content .= parse_html($page,$file_content); } //var_dump($content); file_put_contents("ch{$count}.tex", $content); $count++; echo "\n"; } //$indexer->commit(); if($argc <= 1 && $count > 1) { echo "** Use pdflatex to compile quickstart.tex to obtain PDF version of quickstart tutorial. **\n"; exit; } if($argv[1] == 'pdf') { if(is_file($pdflatexExec)) { //build pdfTex $command=sprintf($pdfTex,$mainTexFile); system($command); system($command); //run it twice echo "\n\n** PDF file quickstart.pdf created **\n\n"; } else { echo " Unable to find pdfLatex executable $pdflatexExec"; } } ?>