Module remark-kbd-nested - v0.6.1

remark plugin to support keyboard and variable sequences. See micromark-extension-kbd-nested for syntax and options.

Use

import { unified } from "unified";
import remarkParse from "remark-parse";
import { remarkKbdNested } from "remark-kbd-nested";
import remarkRehype from "remark-rehype";
import rehypeStringify from "rehype-stringify";

main();

async function main() {
const file = await unified()
.use(remarkParse)
.use(remarkKbdNested)
.use(remarkRehype)
.use(rehypeStringify)
.process("Press ||| ||Ctrl|| + ||//key//|| ||| to trigger the action.");

console.log(String(file));
}

Yields:

<p>Press <kbd><kbd>Ctrl</kbd></kbd> + <kbd><var>key</var></kbd></kbd> to trigger the action.</p>

remark-kbd-nested

Build Downloads Size

remark extension to support kbd element syntax with configurable delimiters, escaping, var sequences, and arbitrary nesting (e.g. Ctrl + key).

Docs at shivjm.github.io/remark-extensions.

Install

This package is ESM only: Node 18+ is needed to use it and it must be imported instead of required.

npm:

npm install micromark-extension-kbd-nested

Use

import { remark } from "remark";
import { remarkKbdNested } from "remark-kbd-nested";
import remarkRehype from "remark-rehype";
import rehypeStringify from "rehype-stringify";

const output = remark()
.use(remarkKbdNested)
.use(remarkRehype)
.use(rehypeStringify)
.processSync("Press ||| ||Ctrl|| + || \| || |||, then || //key// ||.");

console.log(String(output));

Yields:

<p>Press <kbd><kbd>Ctrl</kbd> + <kbd>|</kbd></kbd>, then <kbd><var>key</var></kbd>.</p>

Syntax

See micromark-extension-kbd-nested.

API

remarkKbdNested(options?)

Returns a remark plugin to parse keyboard sequences optionally containing variable sequences (can be passed to use). The options are passed directly to micromark-extension-kbd-nested.

License

ISC © Shiv Jha Mathur

Index

Interfaces

Functions