aboutsummaryrefslogtreecommitdiffstats
path: root/library/markdownify/markdownify_cli.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2012-10-22 19:46:18 -0700
committerfriendica <info@friendica.com>2012-10-22 19:46:18 -0700
commita7abe24382bac00243fd19ebc2cdde87569eab79 (patch)
tree2e802f3357af5e13407241e1c94a17f5e7962517 /library/markdownify/markdownify_cli.php
parent896ca97330f86afe3ab9c7a07ae6d1676c1a546a (diff)
downloadvolse-hubzilla-a7abe24382bac00243fd19ebc2cdde87569eab79.tar.gz
volse-hubzilla-a7abe24382bac00243fd19ebc2cdde87569eab79.tar.bz2
volse-hubzilla-a7abe24382bac00243fd19ebc2cdde87569eab79.zip
more file cleanup
Diffstat (limited to 'library/markdownify/markdownify_cli.php')
-rwxr-xr-xlibrary/markdownify/markdownify_cli.php33
1 files changed, 33 insertions, 0 deletions
diff --git a/library/markdownify/markdownify_cli.php b/library/markdownify/markdownify_cli.php
new file mode 100755
index 000000000..b3fffbd5c
--- /dev/null
+++ b/library/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