![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
micromark-extension-gfm
Advanced tools
micromark extension to support GFM (GitHub Flavored Markdown)
The micromark-extension-gfm npm package is an extension for the micromark Markdown parser that adds support for GitHub Flavored Markdown (GFM). This extension enables users to parse and render Markdown text according to the specifications of GFM, which includes several GitHub-specific features such as tables, task lists, and strikethrough.
Tables
This feature allows the parsing of tables in Markdown formatted text. The code sample demonstrates how to convert a simple Markdown table into HTML using the micromark parser with the gfmTable extension.
import {micromark} from 'micromark';
import {gfmTable} from 'micromark-extension-gfm-table';
const markdown = '| Header 1 | Header 2 |\n| -------- | -------- |\n| Cell 1 | Cell 2 |';
const html = micromark(markdown, {extensions: [gfmTable()]});
console.log(html);
Task Lists
This feature supports the rendering of task lists, where tasks can be marked as completed or incomplete. The code sample shows how to convert Markdown task list items into HTML.
import {micromark} from 'micromark';
import {gfmTaskListItem} from 'micromark-extension-gfm-task-list-item';
const markdown = '- [x] Completed task\n- [ ] Incomplete task';
const html = micromark(markdown, {extensions: [gfmTaskListItem()]});
console.log(html);
Strikethrough
This feature enables the use of strikethrough text formatting in Markdown. The code sample illustrates how to parse and convert strikethrough text from Markdown to HTML.
import {micromark} from 'micromark';
import {gfmStrikethrough} from 'micromark-extension-gfm-strikethrough';
const markdown = 'This is ~~strikethrough~~ text.';
const html = micromark(markdown, {extensions: [gfmStrikethrough()]});
console.log(html);
remark-gfm is another npm package that provides support for GitHub Flavored Markdown. It is built on top of the remark Markdown processor and is similar to micromark-extension-gfm in functionality but uses a different underlying Markdown parsing library.
markdown-it is a Markdown parser that can be extended with plugins, including those for GFM features. It is similar to micromark-extension-gfm but offers a different API and plugin ecosystem, potentially providing more customization options for users.
micromark extensions to support GitHub flavored markdown (GFM).
This package contains extensions that add support for all features enabled by
GFM to micromark
.
It supports autolink literals, footnotes, strikethrough, tables, tagfilter, and
tasklists.
This project is useful when you want to support GFM in markdown.
You can use these extensions when you are working with micromark
.
Alternatively, you can also use the underlying features separately:
micromark-extension-gfm-autolink-literal
— support GFM autolink literalsmicromark-extension-gfm-footnote
— support GFM footnotesmicromark-extension-gfm-strikethrough
— support GFM strikethroughmicromark-extension-gfm-table
— support GFM tablesmicromark-extension-gfm-tagfilter
— support GFM tagfiltermicromark-extension-gfm-task-list-item
— support GFM tasklistsWhen you need a syntax tree, combine this package with
mdast-util-gfm
.
All these packages are used in remark-gfm
, which focusses on
making it easier to transform content by abstracting these internals away.
This package is ESM only. In Node.js (version 16+), install with npm:
npm install micromark-extension-gfm
In Deno with esm.sh
:
import {gfm, gfmHtml} from 'https://esm.sh/micromark-extension-gfm@3'
In browsers with esm.sh
:
<script type="module">
import {gfm, gfmHtml} from 'https://esm.sh/micromark-extension-gfm@3?bundle'
</script>
Say our document example.md
contains:
# GFM
## Autolink literals
www.example.com, https://example.com, and contact@example.com.
## Footnote
A note[^1]
[^1]: Big note.
## Strikethrough
~one~ or ~~two~~ tildes.
## Table
| a | b | c | d |
| - | :- | -: | :-: |
## Tag filter
<plaintext>
## Tasklist
* [ ] to do
* [x] done
…and our module example.js
looks as follows:
import fs from 'node:fs/promises'
import {micromark} from 'micromark'
import {gfm, gfmHtml} from 'micromark-extension-gfm'
const output = micromark(await fs.readFile('example.md'), {
allowDangerousHtml: true,
extensions: [gfm()],
htmlExtensions: [gfmHtml()]
})
console.log(output)
…now running node example.js
yields:
<h1>GFM</h1>
<h2>Autolink literals</h2>
<p><a href="http://www.example.com">www.example.com</a>, <a href="https://example.com">https://example.com</a>, and <a href="mailto:contact@example.com">contact@example.com</a>.</p>
<h2>Footnote</h2>
<p>A note<sup><a href="#user-content-fn-1" id="user-content-fnref-1" data-footnote-ref="" aria-describedby="footnote-label">1</a></sup></p>
<h2>Strikethrough</h2>
<p><del>one</del> or <del>two</del> tildes.</p>
<h2>Table</h2>
<table>
<thead>
<tr>
<th>a</th>
<th align="left">b</th>
<th align="right">c</th>
<th align="center">d</th>
</tr>
</thead>
</table>
<h2>Tag filter</h2>
<plaintext>
<h2>Tasklist</h2>
<ul>
<li><input type="checkbox" disabled="" /> to do</li>
<li><input type="checkbox" disabled="" checked="" /> done</li>
</ul>
<section data-footnotes="" class="footnotes"><h2 id="footnote-label" class="sr-only">Footnotes</h2>
<ol>
<li id="user-content-fn-1">
<p>Big note. <a href="#user-content-fnref-1" data-footnote-backref="" class="data-footnote-backref" aria-label="Back to content">↩</a></p>
</li>
</ol>
</section>
This package exports the identifiers gfm
and
gfmHtml
.
There is no default export.
The separate extensions support the development
condition.
Run node --conditions development module.js
to get instrumented dev code.
Without this condition, production code is loaded.
gfm(options?)
Create an extension for micromark
to enable GFM syntax.
options
(Options
, optional)
— configuration; passed to
micromark-extens-gfm-strikethrough
Extension for micromark
that can be passed in extensions
to enable GFM
syntax (Extension
).
gfmHtml(options?)
Create an extension for micromark
to support GFM when serializing to HTML.
options
(HtmlOptions
, optional)
— configuration; passed to
micromark-extens-gfm-footnote
Extension for micromark
that can be passed in htmlExtensions
to support GFM
when serializing to HTML (HtmlExtension
).
Options
Configuration for syntax (TypeScript type).
export type {Options} from 'micromark-extension-gfm-strikethrough'
HtmlOptions
Configuration for HTML (TypeScript type).
export type {HtmlOptions} from 'micromark-extension-gfm-footnote'
For bugs present in GFM but not here, or other peculiarities that are supported, see each corresponding readme:
For recommendations on how to author GFM, see each corresponding readme:
For info on what HTML features GFM relates to, see each corresponding readme:
For info on how GitHub styles these features, see each corresponding readme:
For info on the syntax of these features, see each corresponding readme:
This package is fully typed with TypeScript.
It exports the additional types HtmlOptions
and
Options
.
Projects maintained by the unified collective are compatible with maintained versions of Node.js.
When we cut a new major release, we drop support for unmaintained versions of
Node.
This means we try to keep the current release line,
micromark-extension-gfm@^3
, compatible with Node.js 16.
This package works with micromark
version 3
and later.
This package is safe.
Setting clobberPrefix = ''
is dangerous, it opens you up to DOM clobbering.
The labelTagName
and labelAttributes
options are unsafe when used with user
content, they allow defining arbitrary HTML.
See contributing.md
in micromark/.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
micromark extension to support GFM (GitHub Flavored Markdown)
The npm package micromark-extension-gfm receives a total of 1,571,691 weekly downloads. As such, micromark-extension-gfm popularity was classified as popular.
We found that micromark-extension-gfm demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.