https://github.com/webuni/commonmark-attributes-extension
The Attributes extension adds a syntax to define attributes on the various HTML elements in markdown’s output.
https://github.com/webuni/commonmark-attributes-extension
attributes commonmark
Last synced: 3 months ago
JSON representation
The Attributes extension adds a syntax to define attributes on the various HTML elements in markdown’s output.
- Host: GitHub
- URL: https://github.com/webuni/commonmark-attributes-extension
- Owner: webuni
- License: mit
- Archived: true
- Created: 2015-07-10T14:29:57.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2020-06-23T18:51:35.000Z (over 5 years ago)
- Last Synced: 2024-08-09T17:51:40.262Z (about 1 year ago)
- Topics: attributes, commonmark
- Language: PHP
- Size: 43 KB
- Stars: 31
- Watchers: 4
- Forks: 14
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
CommonMark Attributes Extension
===============================[](https://packagist.org/packages/webuni/commonmark-attributes-extension)
[](https://travis-ci.org/webuni/commonmark-attributes-extension)
[](https://scrutinizer-ci.com/g/webuni/commonmark-attributes-extension/?branch=master)
[](https://scrutinizer-ci.com/g/webuni/commonmark-attributes-extension/?branch=master)The Attributes extension adds a syntax to define attributes on the various HTML elements in markdown’s output.
## DEPRECATED
**This extension has been deprecated**. All of its functionality now exists in [`league/commonmark`](https://github.com/thephpleague/commonmark) 1.5+ under the `League\CommonMark\Extension\Attributes` 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 webuni/commonmark-attributes-extension
Usage
-----```php
use League\CommonMark\Converter;
use League\CommonMark\DocParser;
use League\CommonMark\Environment;
use League\CommonMark\HtmlRenderer;
use Webuni\CommonMark\AttributesExtension\AttributesExtension;$environment = Environment::createCommonMarkEnvironment();
$environment->addExtension(new AttributesExtension());$converter = new Converter(new DocParser($environment), new HtmlRenderer($environment));
echo $converter->convertToHtml('# Hello World!');
```Syntax
------The basic syntax was inspired by [Kramdown](http://kramdown.gettalong.org/syntax.html#attribute-list-definitions)‘s Attribute Lists feature.
You can assign any attribute to a block-level element. Just directly prepend or follow the block with a block inline attribute list.
That consists of a left curly brace, optionally followed by a colon, the attribute definitions and a right curly brace:```markdown
> A nice blockquote
{: title="Blockquote title"}{#id .class}
## Header
```As with a block-level element you can assign any attribute to a span-level elements using a span inline attribute list,
that has the same syntax and must immediately follow the span-level element:```markdown
This is *red*{style="color: red"}.
```