remark-kbd
v1.1.1
Published
This plugin parses custom Markdown syntax to handle keyboard keys. It adds a new node type to the [mdast][mdast] produced by [remark][remark]: `kbd`
Downloads
529
Readme
remark-kbd
This plugin parses custom Markdown syntax to handle keyboard keys.
It adds a new node type to the mdast produced by remark: kbd
If you are using rehype, the stringified HTML result will be <kbd>
.
Syntax
Hit ||enter|| twice to create a new paragraph.
AST (see mdast specification)
Kbd
(Parent
) represents a reference to a user.
interface Kbd <: Parent {
type: "kbd";
}
For example, the following markdown:
||enter||
Yields:
{
type: 'kbd',
children: [{
type: 'text',
value: 'enter'
}]
}
Rehype
This plugin is compatible with rehype. Kbd
mdast nodes will become <kbd>contents</kbd>
.
Installation
npm:
npm install remark-kbd
Usage
Dependencies:
const unified = require('unified')
const remarkParse = require('remark-parse')
const stringify = require('rehype-stringify')
const remark2rehype = require('remark-rehype')
const remarkKbd = require('remark-kbd')
Usage:
unified()
.use(remarkParse)
.use(remarkKbd)
.use(remark2rehype)
.use(stringify)