remark-text-decoration

1.1.0 • Public • Published

remark-text-decoration

npm version

A remark plugin that adds support for adding arbitrary decoration round the text (i.e. things like underlining or highlighting)

Based on https://github.com/Darkhax/remark-underline

Installation

npm install remark-text-decoration

For best results you should use remark-html or similar.

Usage

We'll demonstrate the usage using underlining as example decoration. Import the plugin and then pass it into remark, or your unified processor chain.

import remark from 'remark';
import html from 'remark-html';
import decoration from 'remark-text-decoration';

remark.use(html).use(decoration("__", "ins")).process("__hello world__");

With the plugin the output will be

<p>
  <ins>hello world</ins>
</p>

Without the plugin the output will be

<p>
  <strong>hello world</strong>
</p>

Options

You may supply additional parameters to the function to configure the plugin. These are the options currently supported:

  • marker - Required. The token used to identify text to decorate.
  • tagType - Required. The name of the HTML tag to wrap the text in.
  • classNames - An array of class names to use for the HTML tag. Empty by default.
  • nodeType - The name of the node to create. By default, this is decoration.

Example

remark().use(html).use(decoration("__", "ins", ['class1', 'class2'], "superDecoration")).process("__I Am Underline__");

License

MIT
© Darkhax
© Valdyslav Sitalo

Package Sidebar

Install

npm i remark-text-decoration

Weekly Downloads

0

Version

1.1.0

License

MIT

Unpacked Size

25.8 kB

Total Files

14

Last publish

Collaborators

  • stvad