-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php declare(strict_types=1); | ||
/** | ||
* This file is part of PTool. | ||
* | ||
* @link https://github.com/inhere | ||
* @author https://github.com/inhere | ||
* @license MIT | ||
*/ | ||
|
||
namespace Inhere\PTool\Console\Command; | ||
|
||
use Inhere\Console\Command; | ||
use Inhere\Console\IO\Input; | ||
use Inhere\Console\IO\Output; | ||
use Inhere\PTool\Common\CliMarkdown; | ||
use Toolkit\Cli\Color; | ||
|
||
/** | ||
* Class MarkdownCommand | ||
*/ | ||
class MarkdownCommand extends Command | ||
{ | ||
protected static $name = 'md:render'; | ||
|
||
protected static $description = 'render markdown file on terminal'; | ||
|
||
/** | ||
* do execute | ||
* @param Input $input | ||
* @param Output $output | ||
*/ | ||
protected function execute($input, $output) | ||
{ | ||
$filename = $input->getFirstArg(); | ||
|
||
$text = \file_get_contents($filename); | ||
|
||
// parse content | ||
$md = new CliMarkdown(); | ||
$doc = $md->parse($text); | ||
$doc = Color::parseTag(rtrim($doc)); | ||
|
||
// $output->colored("Document for the #$nameString"); | ||
$output->writeRaw($doc); | ||
} | ||
} |