kaloa / renderer
A collection of HTML output renderers
v0.2.0
2022-06-17 11:29 UTC
Requires
- php: >=7.4
- league/commonmark: ^0.18.3
- michelf/php-markdown: ~1.6
Requires (Dev)
- phpmd/phpmd: ~2.0
- phpunit/phpunit: ~4.0
- squizlabs/php_codesniffer: ^2.8.1
README
Install
Via Composer:
$ composer require kaloa/renderer
Requirements
The following PHP versions are supported:
- PHP 7.4
Documentation
Usage
use Kaloa\Renderer\Factory; $cm = Factory::createRenderer('commonmark'); echo $cm->render('**Hello *[World](http://example.org)*!**'); // <p><strong>Hello <em><a href="http://example.org">World</a></em>!</strong></p> $md = Factory::createRenderer('markdown'); echo $md->render('**Hello *[World](http://example.org)*!**'); // <p><strong>Hello <em><a href="http://example.org">World</a></em>!</strong></p> $bb = Factory::createRenderer('inigo'); echo $bb->render('[i]Hello [s]Moon[/s] [b]Earth[/b]![/i]'); // <p><em>Hello <s>Moon</s> <strong>Earth</strong>!</em></p> // ...
Renderers
commonmark (third-party)
The league/commonmark parser for CommonMark.
inigo
This is basically a BBCode renderer. The parser tries to automatically add <p>
elements where appropriate. Therefore, all tags are classified as inline or outline.
Supported tags:
i
|em
,b
|strong
u
,s
|strike
icode
h1
-h6
dl
,dt
,dd
ul
,ol
,li
table
,tr
,th
,td
quote
(=@author
)off
|noparse
var
indent
,center
url
|link
(=@href
,@title
)img
(=@src
)abbr
(=@title
)html
code
(=@lang
)fn
,fnt
youtube
amazon
markdown (third-party)
The PHP Markdown parser (without extras).
xml
todo
xmllegacy
todo
Testing
$ ./vendor/bin/phpunit
Further quality assurance:
$ ./vendor/bin/phpcs --standard=PSR2 ./src $ ./vendor/bin/phpmd ./src text codesize,design,naming
Credits
License
The package is published under the MIT License. See LICENSE for full license info.