Security News
JavaScript Leaders Demand Oracle Release the JavaScript Trademark
In an open letter, JavaScript community leaders urge Oracle to give up the JavaScript trademark, arguing that it has been effectively abandoned through nonuse.
mdast-util-gfm-strikethrough
Advanced tools
The `mdast-util-gfm-strikethrough` package is a utility for working with strikethrough text in Markdown Abstract Syntax Trees (MDAST). It provides functionality to parse and serialize strikethrough text according to the GitHub Flavored Markdown (GFM) specification.
Parse Strikethrough
This feature allows you to parse Markdown text containing strikethrough syntax into an MDAST. The code sample demonstrates how to convert a Markdown string with strikethrough text into an MDAST tree.
const { fromMarkdown } = require('mdast-util-from-markdown');
const { gfmStrikethrough } = require('mdast-util-gfm-strikethrough');
const markdown = 'This is ~~strikethrough~~ text.';
const tree = fromMarkdown(markdown, { extensions: [gfmStrikethrough()] });
console.log(JSON.stringify(tree, null, 2));
Serialize Strikethrough
This feature allows you to serialize an MDAST containing strikethrough nodes back into Markdown text. The code sample demonstrates how to convert an MDAST tree with strikethrough nodes into a Markdown string.
const { toMarkdown } = require('mdast-util-to-markdown');
const { gfmStrikethrough } = require('mdast-util-gfm-strikethrough');
const tree = {
type: 'root',
children: [
{
type: 'paragraph',
children: [
{ type: 'text', value: 'This is ' },
{ type: 'delete', children: [{ type: 'text', value: 'strikethrough' }] },
{ type: 'text', value: ' text.' }
]
}
]
};
const markdown = toMarkdown(tree, { extensions: [gfmStrikethrough()] });
console.log(markdown);
The `remark-gfm` package is a plugin for the `remark` ecosystem that adds support for GitHub Flavored Markdown (GFM) syntax, including strikethrough. It provides a more comprehensive set of GFM features compared to `mdast-util-gfm-strikethrough`, which focuses specifically on strikethrough.
The `markdown-it` package is a Markdown parser that supports a wide range of Markdown features, including GFM strikethrough. It is a more general-purpose parser compared to `mdast-util-gfm-strikethrough`, which is specifically designed for working with MDAST.
The `turndown` package is a HTML to Markdown converter that supports various Markdown features, including GFM strikethrough. It is useful for converting HTML content to Markdown, whereas `mdast-util-gfm-strikethrough` is focused on parsing and serializing strikethrough in MDAST.
Extension for mdast-util-from-markdown
and/or
mdast-util-to-markdown
to support GitHub flavored markdown
strikethrough (like this) in mdast.
When parsing (from-markdown
), must be combined with
micromark-extension-gfm-strikethrough
.
You probably shouldn’t use this package directly, but instead use
remark-gfm
with remark.
npm:
npm install mdast-util-gfm-strikethrough
Say our script, example.js
, looks as follows:
var fromMarkdown = require('mdast-util-from-markdown')
var toMarkdown = require('mdast-util-to-markdown')
var syntax = require('micromark-extension-gfm-strikethrough')
var strikethrough = require('mdast-util-gfm-strikethrough')
var doc = '*Emphasis*, **importance**, and ~~strikethrough~~.'
var tree = fromMarkdown(doc, {
extensions: [syntax()],
mdastExtensions: [strikethrough.fromMarkdown]
})
console.log(tree)
var out = toMarkdown(tree, {extensions: [strikethrough.toMarkdown]})
console.log(out)
Now, running node example
yields:
{
type: 'root',
children: [
{
type: 'paragraph',
children: [
{type: 'emphasis', children: [{type: 'text', value: 'Emphasis'}]},
{type: 'text', value: ', '},
{type: 'strong', children: [{type: 'text', value: 'importance'}]},
{type: 'text', value: ', and '},
{type: 'delete', children: [{type: 'text', value: 'strikethrough'}]},
{type: 'text', value: '.'}
]
}
]
}
*Emphasis*, **importance**, and ~~strikethrough~~.
strikethrough.fromMarkdown
strikethrough.toMarkdown
Note: the separate extensions are also available at
mdast-util-gfm-strikethrough/from-markdown
andmdast-util-gfm-strikethrough/to-markdown
.
Support strikethrough.
The exports are extensions, respectively
for mdast-util-from-markdown
and
mdast-util-to-markdown
.
remarkjs/remark
— markdown processor powered by pluginsremarkjs/remark-gfm
— remark plugin to support GFMmicromark/micromark
— the smallest commonmark-compliant markdown parser that existsmicromark/micromark-extension-gfm-strikethrough
— micromark extension to parse GFM strikethroughsyntax-tree/mdast-util-from-markdown
— mdast parser using micromark
to create mdast from markdownsyntax-tree/mdast-util-to-markdown
— mdast serializer to create markdown from mdastSee contributing.md
in syntax-tree/.github
for ways to get
started.
See support.md
for ways to get help.
This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.
FAQs
mdast extension to parse and serialize GFM strikethrough
The npm package mdast-util-gfm-strikethrough receives a total of 2,939,219 weekly downloads. As such, mdast-util-gfm-strikethrough popularity was classified as popular.
We found that mdast-util-gfm-strikethrough demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
In an open letter, JavaScript community leaders urge Oracle to give up the JavaScript trademark, arguing that it has been effectively abandoned through nonuse.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.