项目作者: johnmcdowall

项目描述 :
A remark plugin to handle inserted markdown and create mark HTML elements
高级语言: JavaScript
项目地址: git://github.com/johnmcdowall/remark-inserted.git
创建时间: 2019-02-16T06:44:20Z
项目社区:https://github.com/johnmcdowall/remark-inserted

开源协议:MIT License

下载


remark-inserted

This plugin parses custom Markdown syntax to handle text insertions like ++cats are awesome++. It adds a new node type to the mdast produced by remark: Mark

If you are using rehype, the stringified HTML result will be <mark>.

Syntax

  1. It's cool how ++cats++ are super awesome.

AST (see mdast specification)

Mark (Parent) represents a reference to a user.

  1. interface Mark <: Parent {
  2. type: "Mark";
  3. }

For example, the following markdown:

++cats++

Yields:

  1. {
  2. type: 'mark',
  3. children: [{
  4. type: 'text',
  5. value: 'cats'
  6. }]
  7. }

Rehype

This plugin is compatible with rehype. Mark mdast nodes will become <mark>contents</mark>.

Installation

npm:

  1. npm install remark-inserted

Usage

Dependencies:

  1. const unified = require("unified");
  2. const remarkParse = require("remark-parse");
  3. const stringify = require("rehype-stringify");
  4. const remark2rehype = require("remark-rehype");
  5. const remarkInserted = require("remark-inserted");

Usage:

  1. unified()
  2. .use(remarkParse)
  3. .use(remarkInserted)
  4. .use(remark2rehype)
  5. .use(stringify);

License

MIT © John McDowall