aboutsummaryrefslogtreecommitdiffstats
path: root/include/markdownify/markdownify_cli.php
diff options
context:
space:
mode:
authorMichael Vogel <icarus@dabo.de>2012-06-17 19:49:05 +0200
committerMichael Vogel <icarus@dabo.de>2012-06-17 19:49:05 +0200
commit3968e77f9e15c149d8cafa1dac37411777bd58bd (patch)
tree860447e502067a1204d87be4955b63f2eac69e39 /include/markdownify/markdownify_cli.php
parent7c2d27e2750dc0b6cc7448f8e85b25a3c9b09687 (diff)
downloadvolse-hubzilla-3968e77f9e15c149d8cafa1dac37411777bd58bd.tar.gz
volse-hubzilla-3968e77f9e15c149d8cafa1dac37411777bd58bd.tar.bz2
volse-hubzilla-3968e77f9e15c149d8cafa1dac37411777bd58bd.zip
New function to convert bbcode to markdown.
Diffstat (limited to 'include/markdownify/markdownify_cli.php')
-rwxr-xr-xinclude/markdownify/markdownify_cli.php33
1 files changed, 33 insertions, 0 deletions
diff --git a/include/markdownify/markdownify_cli.php b/include/markdownify/markdownify_cli.php
new file mode 100755
index 000000000..b3fffbd5c
--- /dev/null
+++ b/include/markdownify/markdownify_cli.php
@@ -0,0 +1,33 @@
+#!/usr/bin/php
+<?php
+require dirname(__FILE__) .'/markdownify_extra.php';
+
+function param($name, $default = false) {
+ if (!in_array('--'.$name, $_SERVER['argv']))
+ return $default;
+ reset($_SERVER['argv']);
+ while (each($_SERVER['argv'])) {
+ if (current($_SERVER['argv']) == '--'.$name)
+ break;
+ }
+ $value = next($_SERVER['argv']);
+ if ($value === false || substr($value, 0, 2) == '--')
+ return true;
+ else
+ return $value;
+}
+
+
+$input = stream_get_contents(STDIN);
+
+$linksAfterEachParagraph = param('links');
+$bodyWidth = param('width');
+$keepHTML = param('html', true);
+
+if (param('no_extra')) {
+ $parser = new Markdownify($linksAfterEachParagraph, $bodyWidth, $keepHTML);
+} else {
+ $parser = new Markdownify_Extra($linksAfterEachParagraph, $bodyWidth, $keepHTML);
+}
+
+echo $parser->parseString($input) ."\n"; \ No newline at end of file