rezozero / commonmark-ext-footnotes
A footnote extension for CommonMark PHP implementation
Installs: 2 688
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 4
Forks: 3
Open Issues: 0
Type:commonmark-extension
Requires
- php: >=7.1
- league/commonmark: ^1.3
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.13
- phpstan/phpstan: ^0.11.19
- phpunit/phpunit: ^7.0|^8.0
- satooshi/php-coveralls: ^2.0
- squizlabs/php_codesniffer: ^3.3
README
The Footnotes extension adds the ability to create footnotes in CommonMark documents.
DEPRECATED
This extension has been deprecated. All of its functionality now exists in league/commonmark
1.5+ under the League\CommonMark\Extension\Footnote
namespace, so you should upgrade to that version and use that bundled extension instead of this one.
Installation
This project can be installed via Composer:
composer require rezozero/commonmark-ext-footnotes
Usage
Configure your Environment
as usual and simply add the FootnoteExtension
provided by this package:
use League\CommonMark\Converter; use League\CommonMark\DocParser; use League\CommonMark\Environment; use League\CommonMark\HtmlRenderer; use RZ\CommonMark\Ext\Footnote\FootnoteExtension; // Obtain a pre-configured Environment with all the standard CommonMark parsers/renderers ready-to-go $environment = Environment::createCommonMarkEnvironment(); // Add this extension $environment->addExtension(new FootnoteExtension()); // Instantiate the converter engine and start converting some Markdown! $converter = new Converter(new DocParser($environment), new HtmlRenderer($environment)); echo $converter->convertToHtml('# Hello World!');
Syntax
Code:
Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi[^note1] leo risus, porta ac consectetur ac.
[^note1]: Elit Malesuada Ridiculus
Result:
<p> Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi<sup id="fnref:note1"><a class="footnote-ref" href="#fn:note1" role="doc-noteref">1</a></sup> leo risus, porta ac consectetur ac. </p> <div class="footnotes"> <hr /> <ol> <li class="footnote" id="fn:note1"> <p> Elit Malesuada Ridiculus <a class="footnote-backref" rev="footnote" href="#fnref:note1">↩</a> </p> </li> </ol> </div>