mdast-util-gfm-task-list-item

WebJar for mdast-util-gfm-task-list-item

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

mdast-util-gfm-task-list-item
Last Version

Last Version

0.1.6
Release Date

Release Date

Type

Type

jar
Description

Description

mdast-util-gfm-task-list-item
WebJar for mdast-util-gfm-task-list-item
Project URL

Project URL

https://www.webjars.org
Source Code Management

Source Code Management

https://github.com/syntax-tree/mdast-util-gfm-task-list-item

Download mdast-util-gfm-task-list-item

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/mdast-util-gfm-task-list-item/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>mdast-util-gfm-task-list-item</artifactId>
    <version>0.1.6</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/mdast-util-gfm-task-list-item/
implementation 'org.webjars.npm:mdast-util-gfm-task-list-item:0.1.6'
// https://jarcasting.com/artifacts/org.webjars.npm/mdast-util-gfm-task-list-item/
implementation ("org.webjars.npm:mdast-util-gfm-task-list-item:0.1.6")
'org.webjars.npm:mdast-util-gfm-task-list-item:jar:0.1.6'
<dependency org="org.webjars.npm" name="mdast-util-gfm-task-list-item" rev="0.1.6">
  <artifact name="mdast-util-gfm-task-list-item" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='mdast-util-gfm-task-list-item', version='0.1.6')
)
libraryDependencies += "org.webjars.npm" % "mdast-util-gfm-task-list-item" % "0.1.6"
[org.webjars.npm/mdast-util-gfm-task-list-item "0.1.6"]

Dependencies

compile (1)

Group / Artifact Type Version
org.webjars.npm » mdast-util-to-markdown jar [0.6.0,0.7)

Project Modules

There are no modules declared in this project.

mdast-util-gfm-task-list-item

Build Coverage Downloads Size Sponsors Backers Chat

Extension for mdast-util-from-markdown and/or mdast-util-to-markdown to support GitHub flavored markdown task list items in mdast. When parsing (from-markdown), must be combined with micromark-extension-gfm-task-list-item.

You probably shouldn’t use this package directly, but instead use remark-gfm with remark.

Install

npm:

npm install mdast-util-gfm-task-list-item

Use

Say we have the following file, example.md:

* [ ] To do
* [x] Done

1. Mixed…
2. [x] …messages

And our script, example.js, looks as follows:

var fs = require('fs')
var fromMarkdown = require('mdast-util-from-markdown')
var toMarkdown = require('mdast-util-to-markdown')
var syntax = require('micromark-extension-gfm-task-list-item')
var taskListItem = require('mdast-util-gfm-task-list-item')

var doc = fs.readFileSync('example.md')

var tree = fromMarkdown(doc, {
  extensions: [syntax],
  mdastExtensions: [taskListItem.fromMarkdown]
})

console.log(tree)

var out = toMarkdown(tree, {extensions: [taskListItem.toMarkdown]})

console.log(out)

Now, running node example yields (positional info removed for the sake of brevity):

{
 type: 'root',
 children: [
   {
     type: 'list',
     ordered: false,
     start: null,
     spread: false,
     children: [
       {
         type: 'listItem',
         spread: false,
         checked: false,
         children: [
           {type: 'paragraph', children: [{type: 'text', value: 'To do'}]}
         ]
       },
       {
         type: 'listItem',
         spread: false,
         checked: true,
         children: [
           {type: 'paragraph', children: [{type: 'text', value: 'Done'}]}
         ]
       }
     ]
   },
   {
     type: 'list',
     ordered: true,
     start: 1,
     spread: false,
     children: [
       {
         type: 'listItem',
         spread: false,
         checked: null,
         children: [
           {type: 'paragraph', children: [{type: 'text', value: 'Mixed…'}]}
         ]
       },
       {
         type: 'listItem',
         spread: false,
         checked: true,
         children: [
           {type: 'paragraph', children: [{type: 'text', value: '…messages'}]}
         ]
       }
     ]
   }
 ]
}
*   [ ] To do
*   [x] Done

1.  Mixed…
2.  [x] …messages

API

taskListItem.fromMarkdown

taskListItem.toMarkdown

Note: the separate extensions are also available at mdast-util-gfm-task-list-item/from-markdown and mdast-util-gfm-task-list-item/to-markdown.

Support task list items. The exports are extensions, respectively for mdast-util-from-markdown and mdast-util-to-markdown.

Related

Contribute

See contributing.md in syntax-tree/.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

org.webjars.npm
🌲🌲🌲🌳🌲🌳🌲🌲🌲🌳🌳🌲🌲🌳🌲🌲🎄🌲🌳🌲🌲🌳🐻🌳🌳🌳🌲🌲🌳🌲🎄🌲🌳🌲🌲🌳🌳🌳

Versions

Version
0.1.6