breeswish / php-marked
A PHP markdown parser, ported from marked. Built for speed.
Installs: 15 089
Dependents: 0
Suggesters: 0
Security: 0
Stars: 14
Watchers: 1
Forks: 0
Language:HTML
Requires
- php: >5.3.0
This package is not auto-updated.
Last update: 2024-12-17 09:07:41 UTC
README
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
Requirements
-
PHP 5.3+
-
Composer
Installation
composer require "breeswish/php-marked"
Usage
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__.');
Marked::render(markdownString [,options])
markdownString
Type: string
String of markdown source to be compiled.
options
Type: array
Hash of options. Can also be set using the Marked::setOptions
method as seen above.
Basic Options
gfm
Type: boolean
Default: true
Enable GitHub flavored markdown.
tables
Type: boolean
Default: true
Enable GFM tables.
This option requires the gfm
option to be true.
breaks
Type: boolean
Default: false
Enable GFM line breaks.
This option requires the gfm
option to be true.
pedantic
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.
sanitize
Type: boolean
Default: false
Sanitize the output. Ignore any HTML that has been input.
smartLists
Type: boolean
Default: true
Use smarter list behavior than the original markdown. May eventually be
default with the old behavior moved into pedantic
.
smartypants
Type: boolean
Default: false
Use "smart" typograhic punctuation for things like quotes and dashes.
langPrefix
Type: string
Default: "lang-"
The prefix to be append in the className of <code>
.
xhtml
Type: boolean
Default: false
Render XHTML.
headerPrefix
Type: string
Default: ""
The prefix to be append in the id
attribute of headers.
Testing
run phpunit
.
License
The MIT License.