### Install remark-gfm with npm Source: https://github.com/remarkjs/remark-gfm/blob/main/readme.md Installs the remark-gfm package using npm. This package is ESM only and requires Node.js version 16 or later. ```sh npm install remark-gfm ``` -------------------------------- ### Example: stringLength Option Source: https://github.com/remarkjs/remark-gfm/blob/main/readme.md Illustrates how to improve table alignment for full-width characters and emoji by providing a custom `stringLength` function, such as `string-width`. ```APIDOC ## Example: `stringLength` ### Description It’s possible to align tables based on the visual width of cells. First, let’s show the problem. To improve the alignment of these full-width characters and emoji, pass a `stringLength` function that calculates the visual width of cells. One such algorithm is [`string-width`][string-width]. ### Method `unified().use() ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```javascript import {remark} from 'remark' import remarkGfm from 'remark-gfm' import stringWidth from 'string-width' const input = `| Alpha | Bravo | | - | - | | δΈ­ζ–‡ | Charlie | | πŸ‘©β€β€οΈβ€πŸ‘© | Delta |` const file = await remark() .use(remarkGfm, {stringLength: stringWidth}) .process(input) console.log(String(file)) ``` ### Response #### Success Response (200) - **Output** (`string`) - The processed markdown content as a string, with improved table alignment. #### Response Example ```markdown | Alpha | Bravo | | ----- | ------- | | δΈ­ζ–‡ | Charlie | | πŸ‘©β€β€οΈβ€πŸ‘© | Delta | ``` ``` -------------------------------- ### Example: singleTilde Option Source: https://github.com/remarkjs/remark-gfm/blob/main/readme.md Demonstrates how to disable the parsing of strikethrough text when using a single tilde (`~`) by setting the `singleTilde` option to `false`. ```APIDOC ## Example: `singleTilde` ### Description To turn off support for parsing strikethrough with single tildes, pass `singleTilde: false`. ### Method `unified().use() ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```javascript // ... const file = await unified() .use(remarkParse) .use(remarkGfm, {singleTilde: false}) .use(remarkRehype) .use(rehypeStringify) .process('~one~ and ~~two~~') console.log(String(file)) ``` ### Response #### Success Response (200) - **Output** (`string`) - The processed markdown content as an HTML string. #### Response Example ```html

~one~ and two

``` ``` -------------------------------- ### Markdown with GFM features Source: https://github.com/remarkjs/remark-gfm/blob/main/readme.md Example markdown content demonstrating various GitHub Flavored Markdown (GFM) features supported by remark-gfm, including autolink literals, footnotes, strikethrough, and tables. ```markdown # 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 | | - | :- | -: | :-: | ``` -------------------------------- ### Configure remark-gfm: Disable single tilde for strikethrough Source: https://github.com/remarkjs/remark-gfm/blob/main/readme.md This example shows how to disable the parsing of strikethrough syntax using a single tilde. By passing `{singleTilde: false}` to `remarkGfm`, only double tildes will be recognized for strikethrough. ```javascript import rehypeStringify from 'rehype-stringify' import remarkGfm from 'remark-gfm' import remarkParse from 'remark-parse' import remarkRehype from 'remark-rehype' import {unified} from 'unified' const file = await unified() .use(remarkParse) .use(remarkGfm, {singleTilde: false}) .use(remarkRehype) .use(rehypeStringify) .process('~one~ and ~~two~~') console.log(String(file)) ``` -------------------------------- ### Import remark-gfm in Deno Source: https://github.com/remarkjs/remark-gfm/blob/main/readme.md Imports the remark-gfm plugin for use in Deno environments using esm.sh. This import utilizes esm.sh for module resolution. ```js import remarkGfm from 'https://esm.sh/remark-gfm@4' ``` -------------------------------- ### remarkGfm Usage Source: https://github.com/remarkjs/remark-gfm/blob/main/readme.md This section details how to use the remarkGfm plugin within a remark processing pipeline and explains the available options for configuration. ```APIDOC ## `unified().use(remarkGfm[, options])` ### Description Add support GFM (autolink literals, footnotes, strikethrough, tables, tasklists). ### Method `unified().use() ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters #### Options (TypeScript type) - **firstLineBlank** (`boolean`, default: `false`) - serialize with a blank line for the first line of footnote definitions - **stringLength** (`((value: string) => number)`, default: `d => d.length`) - detect the size of table cells, used when aligning cells - **singleTilde** (`boolean`, default: `true`) - whether to support strikethrough with a single tilde; single tildes work on github.com, but are technically prohibited by GFM; you can always use 2 or more tildes for strikethrough - **tablePipeAlign** (`boolean`, default: `true`) - whether to align table pipes - **tableCellPadding** (`boolean`, default: `true`) - whether to add a space of padding between table pipes and cells ### Request Example ```javascript import rehypeStringify from 'rehype-stringify' import remarkGfm from 'remark-gfm' import remarkParse from 'remark-parse' import remarkRehype from 'remark-rehype' import {read} from 'to-vfile' import {unified} from 'unified' const file = await unified() .use(remarkParse) .use(remarkGfm) .use(remarkRehype) .use(rehypeStringify) .process(await read('example.md')) console.log(String(file)) ``` ### Response #### Success Response (200) - **Output** (`string`) - The processed markdown content as an HTML string. #### Response Example ```html

GFM

Autolink literals

www.example.com, https://example.com, and contact@example.com.

Footnote

A note1

Strikethrough

one or two tildes.

Table

a b c d

Tasklist

Footnotes

  1. Big note. ↩

``` ``` -------------------------------- ### remark-gfm Plugin API Source: https://github.com/remarkjs/remark-gfm/blob/main/readme.md This section details how to use the remark-gfm plugin within the unified ecosystem. It covers the primary function for using the plugin and its configuration options. ```APIDOC ## `unified().use(remarkGfm[, options])` ### Description Adds GitHub Flavored Markdown (GFM) support to remark. ### Method `use` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```javascript import { unified } from 'unified' import remarkGfm from 'remark-gfm' const processor = unified().use(remarkGfm) ``` ### Response #### Success Response (200) N/A (This is a function for configuring a processor) #### Response Example N/A ## Options ### Description Configuration options for the `remarkGfm` plugin. ### Method N/A (Configuration object passed to `use`) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **options** (object) - Optional configuration object. - **stringLength** (boolean, default: `false`) - Configure whether to use `string-length` or `mdast-util-gfm`'s implementation for string length. GFM treats strings with 16-bit characters as multiple characters. When `true`, this plugin uses `string-length` which does not. When `false`, it uses `mdast-util-gfm` which does. - **singleTilde** (boolean, default: `true`) - Configure whether to support ~~this~~ (single tildes) for strikethrough. ### Request Example ```javascript import { unified } from 'unified' import remarkGfm from 'remark-gfm' // Example with options const processor = unified() .use(remarkGfm, { stringLength: true, singleTilde: false }) ``` ### Response #### Success Response (200) N/A (This is a function for configuring a processor) #### Response Example N/A ``` -------------------------------- ### Import remark-gfm in Browser Source: https://github.com/remarkjs/remark-gfm/blob/main/readme.md Imports the remark-gfm plugin for use in web browsers via esm.sh, bundled for efficiency. This script tag should be placed within an HTML file. ```html ``` -------------------------------- ### Process Markdown with remark-gfm Source: https://github.com/remarkjs/remark-gfm/blob/main/readme.md This snippet demonstrates how to use remark-gfm to process a markdown file. It chains remark-parse, remark-gfm, remark-rehype, and rehype-stringify to convert markdown to HTML. The input markdown file is read using 'to-vfile'. ```javascript import rehypeStringify from 'rehype-stringify' import remarkGfm from 'remark-gfm' import remarkParse from 'remark-parse' import remarkRehype from 'remark-rehype' import {read} from 'to-vfile' import {unified} from 'unified' const file = await unified() .use(remarkParse) .use(remarkGfm) .use(remarkRehype) .use(rehypeStringify) .process(await read('example.md')) console.log(String(file)) ``` -------------------------------- ### Configure remark-gfm: Align tables with string-width Source: https://github.com/remarkjs/remark-gfm/blob/main/readme.md This snippet demonstrates how to use the `stringLength` option with `remark-gfm` to correctly align table columns, especially when dealing with full-width characters or emoji. It imports and uses the `string-width` package for accurate character width calculation. ```javascript import {remark} from 'remark' import remarkGfm from 'remark-gfm' import stringWidth from 'string-width' const input = `| Alpha | Bravo | | - | - | | δΈ­ζ–‡ | Charlie | | πŸ‘©β€β€οΈβ€πŸ‘© | Delta |` const file = await remark() .use(remarkGfm, {stringLength: stringWidth}) .process(input) console.log(String(file)) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.