mirror of
https://github.com/friendica/friendica
synced 2025-04-26 05:10:11 +00:00
New function to convert bbcode to markdown.
This commit is contained in:
parent
7c2d27e275
commit
3968e77f9e
10 changed files with 2939 additions and 19 deletions
33
include/markdownify/markdownify_cli.php
Executable file
33
include/markdownify/markdownify_cli.php
Executable file
|
@ -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";
|
Loading…
Add table
Add a link
Reference in a new issue