npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

remark-gfm-configurable

v1.0.0

Published

remark plugin to support GFM (autolink literals, footnotes, strikethrough, tables, tasklists) with configurable plugin options

Downloads

76

Readme

remark-gfm-configurable

npm version Build Status

A fork of remark-gfm with configurable plugin options to enable or disable specific GitHub Flavored Markdown (GFM) features.

By default, remark-gfm enables all underlying features: autolink literals, footnotes, strikethrough, tables, and task list items.

This fork lets you configure which features are enabled by specifying them through a unified options object, offering more granular control over GitHub Flavored Markdown (GFM) features and their behavior.

Table of Contents

Introduction

remark-gfm-configurable is a remark plugin that adds support for GitHub Flavored Markdown (GFM) with the ability to configure which features are enabled. The options are unified into a single object, making it easy to swap this module with the original remark-gfm without changing your code structure.

Features

  • Unified Options Object: Combine plugin and extension options into a single object for simplicity.
  • Configurable Plugins: Enable or disable specific GFM features as needed.
  • Extension Options: Pass options directly to individual GFM extensions for fine-grained control.
  • Compatibility: By default, all GFM features are enabled, maintaining compatibility with remark-gfm.

Installation

Install via npm:

npm install remark-gfm-configurable

Or with Yarn:

yarn add remark-gfm-configurable

Usage

Basic Usage

import { remark } from 'remark';
import remarkGfm from 'remark-gfm-configurable';

const markdown = `
This is a ~~strikethrough~~ text with a task list:

- [x] Task 1
- [ ] Task 2
`;

remark()
  .use(remarkGfm)
  .process(markdown)
  .then((file) => {
    console.log(String(file));
  });

Configuring Options

You can customize both plugin features and extension options by passing an options object to remarkGfm. The options object can include plugin enable/disable settings under the plugins property and extension-specific options at the top level.

import { remark } from 'remark';
import remarkGfm from 'remark-gfm-configurable';

const options = {
  plugins: {
    table: false,        // Disable tables
    footnote: false,     // Disable footnotes
  },
  singleTilde: true,     // Extension option for strikethrough
  tableCellPadding: false, // Extension option for tables (ignored since tables are disabled)
};

remark()
  .use(remarkGfm, options)
  .process(markdown)
  .then((file) => {
    console.log(String(file));
  });

In this example:

  • Plugin Options: We disable table and footnote features by setting them to false under the plugins property.
  • Extension Options: We set singleTilde: true to allow single tilde strikethrough.

Options

The options object passed to remarkGfm can contain both plugin options (to enable or disable specific GFM features) and extension options (for fine-grained control over individual extensions).

interface Options extends MicromarkStrikethroughOptions, MdastTableOptions {
  plugins?: PluginOptions;
}

Plugin Options

Plugin options are provided under the plugins property within the options object. All features are enabled by default.

interface PluginOptions {
  autolinkLiteral?: boolean; // Default: true
  footnote?: boolean;        // Default: true
  strikethrough?: boolean;   // Default: true
  table?: boolean;           // Default: true
  tasklist?: boolean;        // Default: true
}

Available Plugin Options

Extension Options

Extension options are provided at the top level of the options object. These options are directly passed to the corresponding GFM extensions.

Strikethrough Extension Options

interface MicromarkStrikethroughOptions {
  singleTilde?: boolean; // Default: false
}
  • singleTilde: When set to true, allows single tilde (~like this~) to be used for strikethrough, in addition to double tildes (~~like this~~).

Table Extension Options

interface MdastTableOptions {
  tableCellPadding?: boolean; // Default: true
  tablePipeAlign?: boolean;   // Default: false
}
  • tableCellPadding: When set to false, disables padding in table cells when generating Markdown.
  • tablePipeAlign: When set to true, alignment markers (:) are placed next to the pipes in tables.

Note: Even if you provide extension options for a feature, they will be ignored if the corresponding plugin is disabled.

Complete Options Example

const options = {
  plugins: {
    autolinkLiteral: true,
    footnote: false,       // Disable footnotes
    strikethrough: true,
    table: true,
    tasklist: true,
  },
  // Extension options
  singleTilde: true,       // Strikethrough option
  tableCellPadding: false, // Table option
  tablePipeAlign: true,    // Table option
};

Differences from remark-gfm

  • Unified Options Object: Unlike remark-gfm, this package uses a unified options object that includes both plugin and extension options, simplifying configuration.
  • Configurable Features: Allows you to enable or disable specific GFM features under the plugins property.
  • Extension Options: Provides the ability to pass options directly to GFM extensions at the top level of the options object.
  • Module Swapping Compatibility: Designed to allow seamless swapping with remark-gfm without significant code changes.

Contributing

Contributions are welcome! If you have suggestions or find a bug, please open an issue or submit a pull request on GitHub.

Development

To set up the development environment:

  1. Clone the repository:

    git clone https://github.com/escherlies/remark-gfm-configurable.git
  2. Install dependencies:

    cd remark-gfm-configurable
    npm install
  3. Run tests:

    npm test

License

MIT

Acknowledgments