Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed May 27, 2020
1 parent df30225 commit 0d2b86d
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
11 changes: 11 additions & 0 deletions app/Common/CliMarkdown.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,17 @@ protected function renderList($block): string
return $output . self::NL2;
}

/**
* @param $block
*
* @return mixed|string
*/
protected function renderLink($block)
{
// \var_dump($block);
return ColorTag::add($block['orig'], 'info');
}

/**
* @param array $block
*
Expand Down
46 changes: 46 additions & 0 deletions app/Console/Command/MarkdownCommand.php
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);
}
}

0 comments on commit 0d2b86d

Please sign in to comment.