blob: d30ef295874d833d8e3de5124af1b9a58a971614 (
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
|
#!/usr/bin/php
<?php
/**
* A simple commandline tool to render some DokuWiki syntax with a given
* renderer.
*
* This may not work for plugins that expect a certain environment to be
* set up before rendering, but should work for most or even all standard
* DokuWiki markup
*
* @license GPL2
* @author Andreas Gohr <andi@splitbrain.org>
*/
if ('cli' != php_sapi_name()) die();
ini_set('memory_limit','128M');
if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../').'/');
define('NOSESSION',1);
require_once(DOKU_INC.'inc/init.php');
require_once(DOKU_INC.'inc/common.php');
require_once(DOKU_INC.'inc/parserutils.php');
require_once(DOKU_INC.'inc/cliopts.php');
// handle options
$short_opts = 'hr:';
$long_opts = array('help','renderer:');
$OPTS = Doku_Cli_Opts::getOptions(__FILE__,$short_opts,$long_opts);
if ( $OPTS->isError() ) {
fwrite( STDERR, $OPTS->getMessage() . "\n");
_usage();
exit(1);
}
$RENDERER = 'xhtml';
foreach ($OPTS->options as $key => $val) {
switch ($key) {
case 'h':
case 'help':
_usage();
exit;
case 'r':
case 'renderer':
$RENDERER = $val;
}
}
// do the action
$source = stream_get_contents(STDIN);
$info = array();
$result = p_render($RENDERER,p_get_instructions($source),$info);
if(is_null($result)) die("No such renderer $RENDERER\n");
echo $result;
/**
* Print usage info
*/
function _usage(){
print "Usage: render.php <options>
Reads DokuWiki syntax from STDIN and renders it with the given renderer
to STDOUT
OPTIONS
-h, --help show this help and exit
-r, --renderer <renderer> the render mode (default: xhtml)
";
}
|