Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/breezewish/php-marked
Yet another PHP markdown parser.
https://github.com/breezewish/php-marked
gfm markdown php php-markdown-parser
Last synced: 9 days ago
JSON representation
Yet another PHP markdown parser.
- Host: GitHub
- URL: https://github.com/breezewish/php-marked
- Owner: breezewish
- License: mit
- Created: 2014-07-07T06:20:49.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-02-19T07:49:43.000Z (over 9 years ago)
- Last Synced: 2024-10-31T12:46:13.468Z (16 days ago)
- Topics: gfm, markdown, php, php-markdown-parser
- Language: HTML
- Homepage:
- Size: 207 KB
- Stars: 14
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
php-marked - Yet Another PHP Markdown Parser
============================================A full-featured PHP markdown parser.
- Ported from [chjj/marked][marked], consistent with previewing by JavaScript
- Support [Github Flavoured Markdown][gfm]
- Multiple underscores in words
- URL autolinking
- Strikethrough
- Fenced code blocks
- Tables
- High performance
## Requirements
- PHP 5.3+
- Composer
## Installation
```bash
composer require "breeswish/php-marked"```
## Usage
Minimal usage:
```php
echo \Breezewish\Marked\Marked::render('I am using __markdown__.');
// =>I am using markdown.
```Example setting options with default values:
```php
\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][gfm].
### tables
Type: `boolean`
Default: `true`Enable GFM [tables][tables].
This option requires the `gfm` option to be true.### breaks
Type: `boolean`
Default: `false`Enable GFM [line breaks][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 `
`.
### 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.
[marked]: https://github.com/chjj/marked
[gfm]: https://help.github.com/articles/github-flavored-markdown
[tables]: https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#wiki-tables
[breaks]: https://help.github.com/articles/github-flavored-markdown#newlines