From f757c932d0983411567c90f29f57c6f771f030c2 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Sat, 21 Mar 2015 22:07:35 +0100 Subject: [PATCH] Clean up README. --- README.md | 105 +----------------------------------------------------- 1 file changed, 1 insertion(+), 104 deletions(-) diff --git a/README.md b/README.md index 54f77fe..93c4a82 100644 --- a/README.md +++ b/README.md @@ -10,13 +10,6 @@ An object oriented, fully extensible CommonMark parser for PHP 5.4 and above. [**CommonMark spec**][commonmark-spec] * Forked from [Ciconia](https://github.com/kzykhys/ciconia) by [Kazuyuki Hayashi](https://github.com/kzykhys) -* [Github Flavored Markdown](https://help.github.com/articles/github-flavored-markdown) support (disabled by default) - * Multiple underscores in words - * New lines - * Fenced code blocks - * Task lists - * Table - * URL Autolinking * Tested to comply with the [full CommonMark spec test suite][commonmark-spec] ## Requirements @@ -36,7 +29,7 @@ Next, use Composer to install the library and its dependencies: ## Usage -### Traditional Markdown +### Parsing ```php use FluxBB\CommonMark\Parser; @@ -47,107 +40,11 @@ $html = $parser->render('Markdown is **awesome**'); //

Markdown is awesome

``` -### Options - -Option | Type | Default | Description | --------------------|---------|---------|-------------------------------| -**strict** | boolean | false | Throws exception if markdown contains syntax error | - -``` php -use FluxBB\CommonMark\Parser; - -$parser = new Parser(); -$html = $parser->render( - 'Markdown is **awesome**', - ['strict' => true] -); -``` - Rendering --------- The parser renders XHTML by default. -## Extensions - -### How to Extend - -Creating extensions is easy, you only need to implement the `FluxBB\CommonMark\Extension\ExtensionInterface`. - -Your class must implement two methods. - -#### _void_ register(`FluxBB\CommonMark\Markdown` $markdown) - -Register any callbacks with the markdown event manager. -`FluxBB\CommonMark\Markdown` is an instance of the `FluxBB\CommonMark\Event\EmitterInterface` (similar to Node's EventEmitter) - -#### _string_ getName() - -Returns the name of your extension. -If your name is the same as one of the core extensions, the latter will be replaced by your extension. - -### Extension Example - -This sample extension turns any `@username` mentions into links. - -``` php -on('inline', [$this, 'processMentions']); - } - - /** - * @param Text $text - */ - public function processMentions(Text $text) - { - // Turn @username into [@username](http://example.com/user/username) - $text->replace('/(?:^|[^a-zA-Z0-9.])@([A-Za-z]+[A-Za-z0-9]+)/', function (Text $w, Text $username) { - return '[@' . $username . '](http://example.com/user/' . $username . ')'; - }); - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'mention'; - } -} -``` - -Register your extension. - -``` php -addExtension(new MentionExtension()); -echo $parser->render('@admin my email address is example@example.com!'); -``` - -Output - -``` html -

@admin my email address is example@example.com!

-``` - -Each extension handles string as a `Text` object. See [API section of kzykhys/Text][textapi]. - ## Command Line Interface ### Usage