blob: a42d6be3f29a49e8773d4760c4817e35f131bbdf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
<?php
// TBD: subsections in Control Reference
$pdflatexExec = "C:/Wei/miktex/texmf/MiKTeX/bin/pdflatex.exe";
$pdfTex = "$pdflatexExec -interaction=nonstopmode -max-print-line=120 %s";
$mainTexFile = dirname(__FILE__).'/quickstart.tex';
//page root location
$base = realpath(dirname(__FILE__).'/../../../demos/quickstart/protected/pages/');
$pages = include('pages.php');
//-------------- END CONFIG ------------------
include(dirname(__FILE__).'.../../../texbuilder/Page2Tex.php');
// ---------------- Create the Tex files ---------
$count = 1;
$j = 1;
$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>, <h3> and <p>
$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))
{
//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";
}
}
?>
|