5

GitHub - stefanzweifel/commonmark-markdown-renderer: Render a league/commonmark...

 3 years ago
source link: https://github.com/stefanzweifel/commonmark-markdown-renderer
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Render Markdown AST back to Markdown.

Render a league/commonmark AST back to Markdown.

Note: Markdown knows alternate syntaxes for the same elements (heading, emphasis, unordered lists, horizontal rules). Therefore input and output Markdown may differ.

Installation

You can install the package via composer:

composer require wnx/commonmark-markdown-renderer

Usage

use League\CommonMark\Environment\Environment;
use League\CommonMark\Parser\MarkdownParser;
use Wnx\CommonmarkMarkdownRenderer\MarkdownRendererExtension;
use Wnx\CommonmarkMarkdownRenderer\Renderer\MarkdownRenderer;

$environment = new Environment($config);
$environment->addExtension(new MarkdownRendererExtension());

$markdownParser = new MarkdownParser($environment);
$markdownRenderer = new MarkdownRenderer($environment);

$markdown = "**Hello World!**";

$documentAST = $markdownParser->parse($markdown);

// Manipulate AST in your script (append, prepend or replace nodes)

$markdown = $markdownRenderer->renderDocument($documentAST);

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.


Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK