Markdown
, (*1)
Abstraction layer for using several Markdown converters, mostly written in PHP., (*2)
Description
Use Cases
Allows to convert Markdown to other formats (HTML only at the moment).
Within this library this process will be done using a Renderer, since a Markdown code will be rendered into another format.
Since there are several Markdown flavors and implementations, this library is providing an abstraction layer to easily switch between flavors., (*3)
Allows to convert other formats (HTML only at the moment) to Markdown.
Within this library this process will be done using a Parser, since other formats will be parsed to be understood as Markdown., (*4)
Aim
This library aims to provide an abstraction layer for existing implementations for convert Markdown into and from other formats. This will be done by maintaining a list of Open Source packages and providing this collection easily using composer., (*5)
Installation
Using composer:, (*6)
composer require ceus-media/markdown
Usage
After loading the libraries or using autoloading, e.G. using composer, you can use this library the following ways., (*7)
Rendering
To render Markdown code into HTML, using the PHP implementation of Commonmark syntax:, (*8)
use \CeusMedia\Markdown\Renderer\Html;
$renderer = new Html();
//$renderer->setRenderer( Html::RENDERER_PARSEDOWN );
$html = $renderer->convert( "## Heading 2" );
You can change the used renderer, for example to support tables and fenced code by switching to Parsedown:, (*9)
$renderer->setRenderer( Html::RENDERER_PARSEDOWN );
Parsing
Trying to convert HTML to Markdown can be done like this:, (*10)
use \CeusMedia\Markdown\Parser\Html;
$parser = new Html();
$markdown = $parser->convert( "<h2>Heading</h2>" );
Outlook
The next versions will include other output formats (like PDF or Open Document) and input formats (like DokuWiki and other Wiki syntaxes)., (*11)
Todos
Add DokuWiki Parser
- use [titledk/dokuwiki-to-markdown-converter][91]
- call
convert on [DocuwikiToMarkdownExtra][92]