Add the option to use parsedown from the CLI

Sample: php Parsedown.php sample.md
This commit is contained in:
Scott Baker 2014-01-29 22:25:26 -08:00
parent 72f4a375ef
commit ed28cea31d

View File

@ -13,6 +13,14 @@
# #
# #
if (Parsedown::is_cli() && is_readable($argv[1])) {
$str = file_get_contents($argv[1]);
print Parsedown::instance()->parse($str);
exit();
}
class Parsedown class Parsedown
{ {
# Multiton # Multiton
@ -48,6 +56,16 @@ class Parsedown
private $breaks_enabled = false; private $breaks_enabled = false;
# Detect if we're running in CLI mode
public static function is_cli() {
if (php_sapi_name() == 'cli') {
return true;
}
return false;
}
# #
# Synopsis # Synopsis
# #