remark-bracketed-spans
Version:
Add an id, classes, and data attributes to `<span>` tags in markdown.
60 lines (40 loc) • 1.77 kB
Markdown
Add an id, classes, and data attributes to `<span>` tags in markdown.
[![npm][npm-image]][npm-url]
[![travis][travis-image]][travis-url]
[![standard][standard-image]][standard-url]
[![conduct][conduct]][conduct-url]
[]: https://img.shields.io/npm/v/remark-bracketed-spans.svg?style=flat-square
[]: https://www.npmjs.com/package/remark-bracketed-spans
[]: https://img.shields.io/travis/sethvincent/remark-bracketed-spans.svg?style=flat-square
[]: https://travis-ci.org/sethvincent/remark-bracketed-spans
[]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square
[]: http://npm.im/standard
[]: https://img.shields.io/badge/code%20of%20conduct-contributor%20covenant-green.svg?style=flat-square
[]: CONDUCT.md
A [remark](http://npmjs.com/remark) plugin for adding attributes to span tags in markdown that works even when the span is nested inside other markdown elements.
Usage looks like this:
```md
[]{.class .other-class key=val another=example}
```
And results in HTML like this:
```html
<p><span class="class other-class" data-key="val" data-another="example">text in the span</span></p>
```
```sh
npm install --save remark-bracketed-spans
```
This module is a [remark](http://npmjs.com/remark) plugin, and can be used like this:
```js
var remark = require('remark')
var toHTML = require('remark-html')
var bracketedSpans = require('remark-bracketed-spans')
var md = '[text in the span]{.class .other-class key=val another=example}'
var html = remark().use(bracketedSpans).use(toHTML).processSync(md).toString()
console.log(html)
```
[](LICENSE.md)