A full-featured PHP markdown parser.
-
Ported from chjj/marked, consistent with previewing by JavaScript
-
Support Github Flavoured Markdown
-
Multiple underscores in words
-
URL autolinking
-
Strikethrough
-
Fenced code blocks
-
Tables
-
-
High performance
-
PHP 5.3+
-
Composer
composer require "breeswish/php-marked"
Minimal usage:
echo \Breezewish\Marked\Marked::render('I am using __markdown__.');
// => <p>I am using <strong>markdown</strong>.</p>
Example setting options with default values:
\Breezewish\Marked\Marked::setOptions(array(
'gfm' => true,
'tables' => true,
'breaks' => false,
'pedantic' => false,
'sanitize' => false,
'smartLists' => false,
'smartypants' => false,
'langPrefix' => 'lang-',
'xhtml' => false,
'headerPrefix' => '',
'highlight' => null,
'renderer' => new \Breezewish\Marked\Renderer()
));
echo \Breezewish\Marked\Marked::render('I am using __markdown__.');
Type: string
String of markdown source to be compiled.
Type: array
Hash of options. Can also be set using the Marked::setOptions
method as seen above.
Type: boolean
Default: true
Enable GitHub flavored markdown.
Type: boolean
Default: true
Enable GFM tables.
This option requires the gfm
option to be true.
Type: boolean
Default: false
Enable GFM line breaks.
This option requires the gfm
option to be true.
Type: boolean
Default: false
Conform to obscure parts of markdown.pl
as much as possible. Don't fix any of
the original markdown bugs or poor behavior.
Type: boolean
Default: false
Sanitize the output. Ignore any HTML that has been input.
Type: boolean
Default: true
Use smarter list behavior than the original markdown. May eventually be
default with the old behavior moved into pedantic
.
Type: boolean
Default: false
Use "smart" typograhic punctuation for things like quotes and dashes.
Type: string
Default: "lang-"
The prefix to be append in the className of <code>
.
Type: boolean
Default: false
Render XHTML.
Type: string
Default: ""
The prefix to be append in the id
attribute of headers.
run phpunit
.
The MIT License.