-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrender.php
54 lines (44 loc) · 1.32 KB
/
render.php
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
<?php
$pwd = dirname(__file__);
$parser_source = $pwd . '/FlourishWikiParser.plex';
$parser_file = $pwd . '/FlourishWikiParser.php';
if (!file_exists($parser_file) || filemtime($parser_source) > filemtime($parser_file)) {
set_include_path(get_include_path() . PATH_SEPARATOR . $pwd . '/pear');
include 'PHP/LexerGenerator.php';
new PHP_LexerGenerator($parser_source, $parser_file);
}
include $pwd . '/WikiParser.php';
include $pwd . '/WikiPlugin.php';
include $pwd . '/ParserIterator.php';
include $pwd . '/FlourishWikiParser.php';
include $pwd . '/PluginCss.php';
include $pwd . '/PluginToc.php';
include $pwd . '/PluginInclude.php';
function stderr($string)
{
static $fh = NULL;
if ($fh === NULL) {
$fh = fopen('php://stderr', 'w');
}
if (substr($string, -1) != "\n") {
$string .= "\n";
}
fwrite($fh, $string);
}
if (count($argv) < 2) {
stderr('No file name provided');
exit(1);
}
$file = $argv[1];
if (!file_exists($file)) {
stderr("File $file does not exist");
exit(2);
}
$cache_data = array();
if (preg_match('#(^|/)(f[a-zA-Z0-9]+)\.wiki$#', $file)) {
$page_name = preg_replace('#\.wiki$#', '', $file);
$cache_data['flourish_class'] = basename($page_name);
}
$cache_data['__dir__'] = dirname(realpath($file)) . '/';
$markup = file_get_contents($file);
echo WikiParser::execute('Flourish', $markup, $cache_data);