critic-markup
v1.1.2
Published
CriticMarkup in JavaScript
Downloads
14
Readme
CriticMarkup
This package is an implementation of CriticMarkup in JavaScript as a Node.js package/module. It provides functions to parse CriticMarkup syntax or render it into HTML.
Installation
Install via npm
:
npm install critic-markup
Usage
The critic-markup
package exposes two functions, parse()
and render()
. The parse()
function returns an array of all the CriticMarkup tag occurrences in a string with their most important metadata. The render()
function replaces all CriticMarkup tags with their HTML equivalent in the input.
import { parse, render } from 'critic-markup';
parse(`Lorem{++ ipsum++} dolor sit amet.`);
// [{
// type: "addition",
// inputText: "Lorem{++ ipsum++} dolor sit amet.",
// matchedText: "{++ ipsum++},
// start: 5,
// end: 17,
// length: 12,
// content: { addition: " ipsum" }
// }]
render(`Lorem{++ ipsum++} dolor sit amet.`);
// Lorem<ins> ipsum</ins> dolor sit amet.
Contributing
All ideas, recommendations, bug reports, pull requests are welcome. 🙂