### Install mdast-util-gfm with npm Source: https://github.com/syntax-tree/mdast-util-gfm/blob/main/readme.md Install the mdast-util-gfm package using npm for Node.js environments. This command fetches and installs the package and its dependencies. ```sh npm install mdast-util-gfm ``` -------------------------------- ### GFM Autolink Literals, Footnotes, Strikethrough, Tables, Tasklists (Markdown) Source: https://github.com/syntax-tree/mdast-util-gfm/blob/main/readme.md This is a sample Markdown document showcasing various GitHub Flavored Markdown (GFM) features that can be processed by `mdast-util-gfm`. It includes autolink literals, footnotes, strikethrough text, tables, and tasklists. ```markdown # GFM ## Autolink literals [www.example.com](http://www.example.com), , and . ## Footnote A note[^1] [^1]: Big note. ## Strikethrough ~~one~~ or ~~two~~ tildes. ## Table | a | b | c | d | | - | :- | -: | :-: | ## Tasklist * [ ] to do * [x] done ``` -------------------------------- ### Import mdast-util-gfm in Deno Source: https://github.com/syntax-tree/mdast-util-gfm/blob/main/readme.md Import the gfmFromMarkdown and gfmToMarkdown functions from mdast-util-gfm in Deno using esm.sh. This allows direct use in Deno projects. ```javascript import {gfmFromMarkdown, gfmToMarkdown} from 'https://esm.sh/mdast-util-gfm@3' ``` -------------------------------- ### Import mdast-util-gfm in Browser Source: https://github.com/syntax-tree/mdast-util-gfm/blob/main/readme.md Import the gfmFromMarkdown and gfmToMarkdown functions from mdast-util-gfm in the browser using esm.sh with bundling enabled. This provides the functions as a module for browser-based JavaScript. ```html ``` -------------------------------- ### Parse Markdown with GFM extensions (JavaScript) Source: https://github.com/syntax-tree/mdast-util-gfm/blob/main/readme.md This snippet demonstrates how to use `mdast-util-gfm` to parse a Markdown string into an mdast tree, enabling GFM features. It utilizes `fs` for file reading, `fromMarkdown` from `mdast-util-from-markdown`, and GFM extensions. The resulting AST is logged to the console. ```javascript import fs from 'node:fs/promises' import {fromMarkdown} from 'mdast-util-from-markdown' import {gfmFromMarkdown, gfmToMarkdown} from 'mdast-util-gfm' import {toMarkdown} from 'mdast-util-to-markdown' import {gfm} from 'micromark-extension-gfm' const value = await fs.readFile('example.md', 'utf8') const tree = fromMarkdown(value, { extensions: [gfm()], mdastExtensions: [gfmFromMarkdown()] }) console.log(tree) const result = toMarkdown(tree, {extensions: [gfmToMarkdown()]}) console.log(result) ``` -------------------------------- ### GFM Parsing and Serialization API Source: https://github.com/syntax-tree/mdast-util-gfm/blob/main/readme.md This section details the functions for enabling GitHub Flavored Markdown (GFM) parsing and serialization with mdast. ```APIDOC ## API This package exports the identifiers [`gfmFromMarkdown`][api-gfm-from-markdown] and [`gfmToMarkdown`][api-gfm-to-markdown]. There is no default export. ### `gfmFromMarkdown()` Create an extension for [`mdast-util-from-markdown`][mdast-util-from-markdown] to enable GFM (autolink literals, footnotes, strikethrough, tables, tasklists). ###### Returns Extension for `mdast-util-from-markdown` to enable GFM ([`Array`][from-markdown-extension]). ### `gfmToMarkdown(options?)` Create an extension for [`mdast-util-to-markdown`][mdast-util-to-markdown] to enable GFM (autolink literals, footnotes, strikethrough, tables, tasklists). ###### Parameters * `options` ([`Options`][api-options]) — configuration ###### Returns Extension for `mdast-util-to-markdown` to enable GFM ([`Array`][to-markdown-extension]). ### `Options` Configuration (TypeScript type). ``` -------------------------------- ### Configure GFM table cell padding and alignment Source: https://github.com/syntax-tree/mdast-util-gfm/blob/main/readme.md This utility provides options to control how table delimiters are handled. `tableCellPadding` adds spaces around cell content, and `tablePipeAlign` ensures consistent alignment of pipe characters in table syntax. These options affect the parsing and potentially the representation of table nodes in the AST. ```javascript import {mdastUtilGfm} from 'mdast-util-gfm'; // Example usage with options: const processor = unified() .use(markdown) .use(mdastUtilGfm, { tableCellPadding: true, tablePipeAlign: false, }); ``` -------------------------------- ### Configure GFM first line blank footnote definitions Source: https://github.com/syntax-tree/mdast-util-gfm/blob/main/readme.md The `firstLineBlank` option in `mdast-util-gfm` determines whether a blank line is required before the first line of a footnote definition. This setting influences how footnote definitions are parsed and recognized within the markdown AST, impacting the interpretation of footnote content. ```javascript import {mdastUtilGfm} from 'mdast-util-gfm'; // Example usage with firstLineBlank option: const processor = unified() .use(markdown) .use(mdastUtilGfm, { firstLineBlank: true, }); ``` -------------------------------- ### Configure GFM table cell content length detection Source: https://github.com/syntax-tree/mdast-util-gfm/blob/main/readme.md The `stringLength` option allows customization of how the length of table cell content is detected. This function is crucial for aligning delimiters between table cells, ensuring consistent formatting. Providing a custom function can be useful for handling complex cell content or specific display requirements. ```javascript import {mdastUtilGfm} from 'mdast-util-gfm'; // Example usage with custom stringLength function: const processor = unified() .use(markdown) .use(mdastUtilGfm, { stringLength: (value) => value.split('').filter(char => char !== ' ').length, // Example: count non-space characters }); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.