or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

index.md
tile.json

tessl/npm-remark-gfm

remark plugin to support GitHub Flavored Markdown (GFM) features including autolink literals, footnotes, strikethrough, tables, and task lists

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/remark-gfm@4.0.x

To install, run

npx @tessl/cli install tessl/npm-remark-gfm@4.0.0

index.mddocs/

remark-gfm

remark-gfm is a plugin for the remark markdown processor that adds support for GitHub Flavored Markdown (GFM) extensions. It enables parsing and serialization of autolink literals, footnotes, strikethrough, tables, and task lists in markdown documents.

Package Information

  • Package Name: remark-gfm
  • Package Type: npm
  • Language: JavaScript (with TypeScript definitions)
  • Installation: npm install remark-gfm

Core Imports

ESM (recommended):

import remarkGfm from 'remark-gfm';

For TypeScript users with type annotations:

import remarkGfm, {type Options} from 'remark-gfm';

CommonJS:

const remarkGfm = require('remark-gfm');

Basic Usage

import {unified} from 'unified';
import remarkParse from 'remark-parse';
import remarkRehype from 'remark-rehype';
import rehypeStringify from 'rehype-stringify';
import remarkGfm from 'remark-gfm';

const processor = unified()
  .use(remarkParse)
  .use(remarkGfm)
  .use(remarkRehype)
  .use(rehypeStringify);

const result = await processor.process('~~strikethrough~~ and www.example.com');

Capabilities

Plugin Function

The main function that adds GFM support to a remark processor.

/**
 * Add support for GFM (autolink literals, footnotes, strikethrough, tables, tasklists)
 * @param options - Configuration options (optional)
 * @returns Nothing (undefined)
 */
declare function remarkGfm(options?: Options | null | undefined): undefined;
export default remarkGfm;

Usage Examples:

import {unified} from 'unified';
import remarkParse from 'remark-parse';
import remarkGfm from 'remark-gfm';

// Basic usage without options
const processor = unified()
  .use(remarkParse)
  .use(remarkGfm);

// With options
const processor = unified()
  .use(remarkParse)
  .use(remarkGfm, {
    singleTilde: false,
    tablePipeAlign: true
  });

// TypeScript usage with explicit types
import type {Options} from 'remark-gfm';

const options: Options = {
  singleTilde: false,
  stringLength: (value: string) => value.length,
  tablePipeAlign: true,
  tableCellPadding: true
};

const processor = unified()
  .use(remarkParse)
  .use(remarkGfm, options);

Configuration Options

Options interface for customizing remark-gfm behavior.

export interface Options {
  /**
   * 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.
   * @default true
   */
  singleTilde?: boolean;

  /**
   * Whether to serialize with a blank line for the first line of footnote definitions.
   * @default false
   */
  firstLineBlank?: boolean;

  /**
   * Function to detect the size of table cells, used when aligning cells.
   * @default (value) => value.length
   */
  stringLength?: (value: string) => number;

  /**
   * Whether to align table pipes in serialized output.
   * @default true
   */
  tablePipeAlign?: boolean;

  /**
   * Whether to add a space of padding between table pipes and cells.
   * @default true
   */
  tableCellPadding?: boolean;
}

Usage Examples:

import remarkGfm from 'remark-gfm';
import stringWidth from 'string-width';

// Disable single tilde strikethrough
processor.use(remarkGfm, {
  singleTilde: false
});

// Custom string length for Unicode-aware table alignment
processor.use(remarkGfm, {
  stringLength: stringWidth
});

// Disable table formatting
processor.use(remarkGfm, {
  tablePipeAlign: false,
  tableCellPadding: false
});

GitHub Flavored Markdown Features

This plugin adds support for the following GFM extensions:

Autolink Literals

Automatically converts URLs and email addresses to links:

  • www.example.com<a href="http://www.example.com">www.example.com</a>
  • https://example.com<a href="https://example.com">https://example.com</a>
  • contact@example.com<a href="mailto:contact@example.com">contact@example.com</a>

Footnotes

Support for footnote syntax:

Here is a footnote reference[^1].

[^1]: Here is the footnote definition.

Strikethrough

Support for strikethrough text:

  • ~~two tildes~~ (standard GFM)
  • ~one tilde~ (GitHub extension, can be disabled with singleTilde: false)

Tables

Support for GitHub-style tables:

| Header 1 | Header 2 |
| -------- | -------- |
| Cell 1   | Cell 2   |

With alignment:

| Left | Center | Right |
| :--- | :----: | ----: |
| L    |   C    |     R |

Task Lists

Support for task list items:

- [ ] Incomplete task
- [x] Complete task

Integration Notes

  • Requires unified ecosystem with remark-parse for parsing
  • Use with remark-stringify for serialization back to markdown
  • Compatible with remark-rehype for HTML conversion
  • Works with Node.js 16+ and modern browsers (ESM)
  • Integrates with micromark extensions for low-level parsing
  • Uses mdast utilities for syntax tree manipulation