Socket
Socket
Sign inDemoInstall

micromark-extension-gfm-task-list-item

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

micromark-extension-gfm-task-list-item

micromark extension to support GFM task list items


Version published
Weekly downloads
3.3M
increased by6.92%
Maintainers
1
Weekly downloads
 
Created

Package description

What is micromark-extension-gfm-task-list-item?

The micromark-extension-gfm-task-list-item package is an extension for micromark that adds support for GitHub Flavored Markdown (GFM) task list items. This allows you to parse and render task lists in markdown documents.

What are micromark-extension-gfm-task-list-item's main functionalities?

Parse GFM Task List Items

This feature allows you to parse GFM task list items from markdown input. The code sample demonstrates how to use the micromark-extension-gfm-task-list-item extension to parse a markdown string containing task list items.

const micromark = require('micromark');
const gfmTaskListItem = require('micromark-extension-gfm-task-list-item');

const input = '- [ ] Task 1\n- [x] Task 2';
const output = micromark(input, { extensions: [gfmTaskListItem()] });
console.log(output);

Render GFM Task List Items

This feature allows you to render GFM task list items to HTML. The code sample demonstrates how to use the micromark-extension-gfm-task-list-item extension along with its HTML renderer to convert a markdown string containing task list items into HTML.

const micromark = require('micromark');
const gfmTaskListItem = require('micromark-extension-gfm-task-list-item');
const html = require('micromark-extension-gfm-task-list-item/html');

const input = '- [ ] Task 1\n- [x] Task 2';
const output = micromark(input, { extensions: [gfmTaskListItem()], htmlExtensions: [html()] });
console.log(output);

Other packages similar to micromark-extension-gfm-task-list-item

Readme

Source

micromark-extension-gfm-task-list-item

Build Coverage Downloads Size Sponsors Backers Chat

micromark extensions to support GFM task list items.

Contents

What is this?

This package contains extensions that add support for task lists as enabled by GFM to micromark. It matches how task list items work on github.com.

When to use this

This project is useful when you want to support task lists in markdown.

You can use these extensions when you are working with micromark. To support all GFM features, use micromark-extension-gfm.

When you need a syntax tree, you can combine this package with mdast-util-gfm-task-list-item.

All these packages are used remark-gfm, which focusses on making it easier to transform content by abstracting these internals away.

Install

This package is ESM only. In Node.js (version 14.14+), install with npm:

npm install micromark-extension-gfm-task-list-item

In Deno with esm.sh:

import {gfmTaskListItem, gfmTaskListItemHtml} from 'https://esm.sh/micromark-extension-gfm-task-list-item@1'

In browsers with esm.sh:

<script type="module">
  import {gfmTaskListItem, gfmTaskListItemHtml} from 'https://esm.sh/micromark-extension-gfm-task-list-item@1?bundle'
</script>

Use

import {micromark} from 'micromark'
import {
  gfmTaskListItem,
  gfmTaskListItemHtml
} from 'micromark-extension-gfm-task-list-item'

const output = micromark('* [x] a\n* [ ] b', {
  extensions: [gfmTaskListItem],
  htmlExtensions: [gfmTaskListItemHtml]
})

console.log(output)

Yields:

<ul>
<li><input checked="" disabled="" type="checkbox"> a</li>
<li><input disabled="" type="checkbox"> b</li>
</ul>

API

This package exports the identifiers gfmTaskListItem and gfmTaskListItemHtml. There is no default export.

The export map supports the development condition. Run node --conditions development module.js to get instrumented dev code. Without this condition, production code is loaded.

gfmTaskListItem

Extension for micromark that can be passed in extensions, to enable GFM task list items syntax (Extension).

gfmTaskListItemHtml

Extension for micromark that can be passed in htmlExtensions to support GFM task list items when serializing to HTML (HtmlExtension).

Authoring

It is recommended to use lowercase x (instead of uppercase X), because in markdown, it is more common to use lowercase in places where casing does not matter. It is also recommended to use a space (instead of a tab), as there is no benefit of using tabs in this case.

HTML

Checks relate to the <input> element, in the checkbox state (type=checkbox), in HTML. See § 4.10.5.1.15 Checkbox state (type=checkbox) in the HTML spec for more info.

<!--…-->
<li><input type="checkbox" disabled="" /> foo</li>
<li><input type="checkbox" disabled="" checked="" /> bar</li>
<!--…-->

CSS

GitHub itself uses slightly different markup for task list items than they define in their spec. When following the spec, as this extension does, only inputs are added. They can be styled with the following CSS:

input[type="checkbox"] {
  margin: 0 .2em .25em -1.6em;
  vertical-align: middle;
}

input[type="checkbox"]:dir(rtl) {
  margin: 0 -1.6em .25em .2em;
}

For the complete actual CSS see sindresorhus/github-markdown-css.

Syntax

Checks form with the following BNF:

gfm_task_list_item_check ::= '[' (0x09 | ' ' | 'X' | 'x') ']'

The check is only allowed at the start of the first paragraph, optionally following zero or more definitions or a blank line, in a list item. The check must be followed by whitespace ([\t\n\r ]*), which is in turn followed by non-whitespace.

Types

This package is fully typed with TypeScript. It exports no additional types.

Compatibility

Projects maintained by the unified collective are compatible with all maintained versions of Node.js. As of now, that is Node.js 14.14+. Our projects sometimes work with older versions, but this is not guaranteed.

These extensions work with micromark version 3+.

Security

This package is safe.

Contribute

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.

License

MIT © Titus Wormer

Keywords

FAQs

Package last updated on 30 May 2023

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc