mirror of
https://github.com/erusev/parsedown.git
synced 2024-09-20 03:51:29 +02:00
Add the option to use parsedown from the CLI
Sample: php Parsedown.php sample.md
This commit is contained in:
parent
72f4a375ef
commit
ed28cea31d
@ -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
|
||||
{
|
||||
# Multiton
|
||||
@ -48,6 +56,16 @@ class Parsedown
|
||||
|
||||
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
|
||||
#
|
||||
|
Loading…
Reference in New Issue
Block a user