remark-kbd-plus
This JS plugin for remark parses custom Markdown syntax to handle keyboard keys in the format ++Cmd+Alt+M++
similar to used in the Python Markdown extension pymdownx.
It adds a new node type to the mdast produced by remark: kbd
. While pymdownx.keys
itemizes the single keys and allows creation of nested objects, remark-kbd-plus
currently places the strings wrapped in ++
into one kbd
node. If you are using rehype, the stringified HTML result will be <kbd>
.
Syntax
Hit ++Enter++ twice to create a new paragraph.
mdast specification)
AST (seeKbd
(Parent
) represents a reference to a user.
interface Kbd <: Parent type: "kbd";
For example, the following markdown:
++Cmd+Alt+M++
Yields:
type: 'kbd' children: type: 'text' value: 'Cmd+Alt+M'
Rehype
This plugin is compatible with rehype. Kbd
mdast nodes will become <kbd>Cmd+Alt+M</kbd>
.
Installation
npm:
npm install remark-kbd-plus
Usage
Dependencies:
const unified = const remarkParse = const stringify = const remark2rehype = const remarkKbd =
Usage:
Changelog
- 2019-04-14
Copyright
remark-kbd-plus © 2019 Adam Twardoch Based on remark-kbd © Zeste de Savoir