Esempio n. 1
0
$current_path = '';
echo "Compiling .page files to Latex files\n\n";
$parser = new Page2Tex($base, dirname(__FILE__));
foreach ($pages as $chapter => $sections) {
    $content = '\\chapter{' . $chapter . '}' . $parser->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;
        $parser->setCurrentPage($current_path);
        //add id to <h1>, <h2>, <3>
        $tmp_content = $parser->set_header_id(file_get_contents($page), $j++);
        //		file_put_contents($page, $tmp_content);
        $content .= $parser->get_section_label($section);
        $file_content = file_get_contents($page);
        $tex = $content .= $parser->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)) {