Socket
Socket
Sign inDemoInstall

mdast-util-gfm-task-list-item

Package Overview
Dependencies
Maintainers
2
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mdast-util-gfm-task-list-item - npm Package Compare versions

Comparing version 1.0.2 to 2.0.0

20

lib/index.d.ts
/**
* Extension for `mdast-util-from-markdown` to enable GFM task list items.
* Create an extension for `mdast-util-from-markdown` to enable GFM task
* list items in markdown.
*
* @type {FromMarkdownExtension}
* @returns {FromMarkdownExtension}
* Extension for `mdast-util-from-markdown` to enable GFM task list items.
*/
export const gfmTaskListItemFromMarkdown: FromMarkdownExtension
export function gfmTaskListItemFromMarkdown(): FromMarkdownExtension
/**
* Extension for `mdast-util-to-markdown` to enable GFM task list items.
* Create an extension for `mdast-util-to-markdown` to enable GFM task list
* items in markdown.
*
* @type {ToMarkdownExtension}
* @returns {ToMarkdownExtension}
* Extension for `mdast-util-to-markdown` to enable GFM task list items.
*/
export const gfmTaskListItemToMarkdown: ToMarkdownExtension
export type Content = import('mdast').Content
export function gfmTaskListItemToMarkdown(): ToMarkdownExtension
export type ListItem = import('mdast').ListItem
export type Paragraph = import('mdast').Paragraph
export type Parent = import('mdast').Parent
export type Root = import('mdast').Root
export type CompileContext = import('mdast-util-from-markdown').CompileContext

@@ -23,2 +24,1 @@ export type FromMarkdownExtension = import('mdast-util-from-markdown').Extension

export type ToMarkdownHandle = import('mdast-util-to-markdown').Handle
export type Parents = Extract<Root | Content, Parent>
/**
* @typedef {import('mdast').Content} Content
* @typedef {import('mdast').ListItem} ListItem
* @typedef {import('mdast').Paragraph} Paragraph
* @typedef {import('mdast').Parent} Parent
* @typedef {import('mdast').Root} Root
* @typedef {import('mdast-util-from-markdown').CompileContext} CompileContext

@@ -14,24 +11,19 @@ * @typedef {import('mdast-util-from-markdown').Extension} FromMarkdownExtension

/**
* @typedef {Extract<Root | Content, Parent>} Parents
*/
import {ok as assert} from 'devlop'
import {defaultHandlers} from 'mdast-util-to-markdown'
import {listItem} from 'mdast-util-to-markdown/lib/handle/list-item.js'
import {track} from 'mdast-util-to-markdown/lib/util/track.js'
// To do: next major: rename `context` -> `state`, `safeOptions` -> `info`, use
// `track` from `state`.
// To do: next major: replace exports with functions.
// To do: next major: use `defaulthandlers.listItem`.
/**
* Extension for `mdast-util-from-markdown` to enable GFM task list items.
* Create an extension for `mdast-util-from-markdown` to enable GFM task
* list items in markdown.
*
* @type {FromMarkdownExtension}
* @returns {FromMarkdownExtension}
* Extension for `mdast-util-from-markdown` to enable GFM task list items.
*/
export const gfmTaskListItemFromMarkdown = {
exit: {
taskListCheckValueChecked: exitCheck,
taskListCheckValueUnchecked: exitCheck,
paragraph: exitParagraphWithTaskListItem
export function gfmTaskListItemFromMarkdown() {
return {
exit: {
taskListCheckValueChecked: exitCheck,
taskListCheckValueUnchecked: exitCheck,
paragraph: exitParagraphWithTaskListItem
}
}

@@ -41,9 +33,13 @@ }

/**
* Extension for `mdast-util-to-markdown` to enable GFM task list items.
* Create an extension for `mdast-util-to-markdown` to enable GFM task list
* items in markdown.
*
* @type {ToMarkdownExtension}
* @returns {ToMarkdownExtension}
* Extension for `mdast-util-to-markdown` to enable GFM task list items.
*/
export const gfmTaskListItemToMarkdown = {
unsafe: [{atBreak: true, character: '-', after: '[:|-]'}],
handlers: {listItem: listItemWithTaskListItem}
export function gfmTaskListItemToMarkdown() {
return {
unsafe: [{atBreak: true, character: '-', after: '[:|-]'}],
handlers: {listItem: listItemWithTaskListItem}
}
}

@@ -56,4 +52,5 @@

function exitCheck(token) {
const node = /** @type {ListItem} */ (this.stack[this.stack.length - 2])
// We’re always in a paragraph, in a list item.
const node = this.stack[this.stack.length - 2]
assert(node.type === 'listItem')
node.checked = token.type === 'taskListCheckValueChecked'

@@ -67,3 +64,3 @@ }

function exitParagraphWithTaskListItem(token) {
const parent = /** @type {Parents} */ (this.stack[this.stack.length - 2])
const parent = this.stack[this.stack.length - 2]

@@ -75,3 +72,4 @@ if (

) {
const node = /** @type {Paragraph} */ (this.stack[this.stack.length - 1])
const node = this.stack[this.stack.length - 1]
assert(node.type === 'paragraph')
const head = node.children[0]

@@ -119,3 +117,3 @@

*/
function listItemWithTaskListItem(node, parent, context, safeOptions) {
function listItemWithTaskListItem(node, parent, state, info) {
const head = node.children[0]

@@ -125,3 +123,3 @@ const checkable =

const checkbox = '[' + (node.checked ? 'x' : ' ') + '] '
const tracker = track(safeOptions)
const tracker = state.createTracker(info)

@@ -132,4 +130,4 @@ if (checkable) {

let value = listItem(node, parent, context, {
...safeOptions,
let value = defaultHandlers.listItem(node, parent, state, {
...info,
...tracker.current()

@@ -136,0 +134,0 @@ })

{
"name": "mdast-util-gfm-task-list-item",
"version": "1.0.2",
"version": "2.0.0",
"description": "mdast extension to parse and serialize GFM task list items",

@@ -34,4 +34,3 @@ "license": "MIT",

"type": "module",
"main": "index.js",
"types": "index.d.ts",
"exports": "./index.js",
"files": [

@@ -43,10 +42,11 @@ "lib/",

"dependencies": {
"@types/mdast": "^3.0.0",
"mdast-util-to-markdown": "^1.3.0"
"@types/mdast": "^4.0.0",
"devlop": "^1.0.0",
"mdast-util-from-markdown": "^2.0.0",
"mdast-util-to-markdown": "^2.0.0"
},
"devDependencies": {
"@types/node": "^18.0.0",
"c8": "^7.0.0",
"mdast-util-from-markdown": "^1.0.0",
"micromark-extension-gfm-task-list-item": "^1.0.0",
"@types/node": "^20.0.0",
"c8": "^8.0.0",
"micromark-extension-gfm-task-list-item": "^2.0.0",
"prettier": "^2.0.0",

@@ -56,5 +56,5 @@ "remark-cli": "^11.0.0",

"type-coverage": "^2.0.0",
"typescript": "^4.0.0",
"unist-util-remove-position": "^4.0.0",
"xo": "^0.53.0"
"typescript": "^5.0.0",
"unist-util-remove-position": "^5.0.0",
"xo": "^0.54.0"
},

@@ -65,20 +65,19 @@ "scripts": {

"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix",
"test-api": "node --conditions development test.js",
"test-coverage": "c8 --check-coverage --100 --reporter lcov npm run test-api",
"test-api-prod": "node --conditions production test.js",
"test-api-dev": "node --conditions development test.js",
"test-api": "npm run test-api-dev && npm run test-api-prod",
"test-coverage": "c8 --100 --reporter lcov npm run test-api",
"test": "npm run build && npm run format && npm run test-coverage"
},
"prettier": {
"tabWidth": 2,
"useTabs": false,
"singleQuote": true,
"bracketSpacing": false,
"semi": false,
"trailingComma": "none"
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "none",
"useTabs": false
},
"xo": {
"prettier": true
},
"remarkConfig": {
"plugins": [
"preset-wooorm"
"remark-preset-wooorm"
]

@@ -89,5 +88,8 @@ },

"detail": true,
"strict": true,
"ignoreCatch": true
"ignoreCatch": true,
"strict": true
},
"xo": {
"prettier": true
}
}

@@ -20,4 +20,4 @@ # mdast-util-gfm-task-list-item

* [API](#api)
* [`gfmTaskListItemFromMarkdown`](#gfmtasklistitemfrommarkdown)
* [`gfmTaskListItemToMarkdown`](#gfmtasklistitemtomarkdown)
* [`gfmTaskListItemFromMarkdown()`](#gfmtasklistitemfrommarkdown)
* [`gfmTaskListItemToMarkdown()`](#gfmtasklistitemtomarkdown)
* [HTML](#html)

@@ -69,3 +69,3 @@ * [Syntax](#syntax)

This package is [ESM only][esm].
In Node.js (version 14.14+ and 16.0+), install with [npm][]:
In Node.js (version 16+), install with [npm][]:

@@ -79,3 +79,3 @@ ```sh

```js
import {gfmTaskListItemFromMarkdown, gfmTaskListItemToMarkdown} from 'https://esm.sh/mdast-util-gfm-task-list-item@1'
import {gfmTaskListItemFromMarkdown, gfmTaskListItemToMarkdown} from 'https://esm.sh/mdast-util-gfm-task-list-item@2'
```

@@ -87,3 +87,3 @@

<script type="module">
import {gfmTaskListItemFromMarkdown, gfmTaskListItemToMarkdown} from 'https://esm.sh/mdast-util-gfm-task-list-item@1?bundle'
import {gfmTaskListItemFromMarkdown, gfmTaskListItemToMarkdown} from 'https://esm.sh/mdast-util-gfm-task-list-item@2?bundle'
</script>

@@ -108,6 +108,6 @@ ```

import fs from 'node:fs/promises'
import {gfmTaskListItem} from 'micromark-extension-gfm-task-list-item'
import {fromMarkdown} from 'mdast-util-from-markdown'
import {gfmTaskListItemFromMarkdown, gfmTaskListItemToMarkdown} from 'mdast-util-gfm-task-list-item'
import {toMarkdown} from 'mdast-util-to-markdown'
import {gfmTaskListItem} from 'micromark-extension-gfm-task-list-item'
import {gfmTaskListItemFromMarkdown, gfmTaskListItemToMarkdown} from 'mdast-util-gfm-task-list-item'

@@ -197,16 +197,26 @@ const doc = await fs.readFile('example.md')

This package exports the identifiers
[`gfmTaskListItemFromMarkdown`][api-gfmtasklistitemfrommarkdown] and
[`gfmTaskListItemToMarkdown`][api-gfmtasklistitemtomarkdown].
[`gfmTaskListItemFromMarkdown`][api-gfm-task-list-item-from-markdown] and
[`gfmTaskListItemToMarkdown`][api-gfm-task-list-item-to-markdown].
There is no default export.
### `gfmTaskListItemFromMarkdown`
### `gfmTaskListItemFromMarkdown()`
Extension for [`mdast-util-from-markdown`][mdast-util-from-markdown]
to enable GFM task lists ([`FromMarkdownExtension`][frommarkdownextension]).
Create an extension for [`mdast-util-from-markdown`][mdast-util-from-markdown]
to enable GFM task list items in markdown.
### `gfmTaskListItemToMarkdown`
###### Returns
Extension for [`mdast-util-to-markdown`][mdast-util-to-markdown]
to enable GFM task lists ([`ToMarkdownExtension`][tomarkdownextension]).
Extension for `mdast-util-from-markdown` to enable GFM task list items
([`FromMarkdownExtension`][frommarkdownextension]).
### `gfmTaskListItemToMarkdown()`
Create an extension for [`mdast-util-to-markdown`][mdast-util-to-markdown] to
enable GFM task list items in markdown.
###### Returns
Extension for `mdast-util-to-markdown` to enable GFM task list items
([`ToMarkdownExtension`][tomarkdownextension]).
## HTML

@@ -256,9 +266,9 @@

Projects maintained by the unified collective are compatible with all maintained
Projects maintained by the unified collective are compatible with maintained
versions of Node.js.
As of now, that is Node.js 14.14+ and 16.0+.
Our projects sometimes work with older versions, but this is not guaranteed.
This plugin works with `mdast-util-from-markdown` version 1+ and
`mdast-util-to-markdown` version 1+.
When we cut a new major release, we drop support for unmaintained versions of
Node.
This means we try to keep the current release line,
`mdast-util-gfm-task-list-item@^2`, compatible with Node.js 16.

@@ -303,5 +313,5 @@ ## Related

[size-badge]: https://img.shields.io/bundlephobia/minzip/mdast-util-gfm-task-list-item.svg
[size-badge]: https://img.shields.io/badge/dynamic/json?label=minzipped%20size&query=$.size.compressedSize&url=https://deno.bundlejs.com/?q=mdast-util-gfm-task-list-item
[size]: https://bundlephobia.com/result?p=mdast-util-gfm-task-list-item
[size]: https://bundlejs.com/?q=mdast-util-gfm-task-list-item

@@ -362,4 +372,4 @@ [sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg

[api-gfmtasklistitemfrommarkdown]: #gfmtasklistitemfrommarkdown
[api-gfm-task-list-item-from-markdown]: #gfmtasklistitemfrommarkdown
[api-gfmtasklistitemtomarkdown]: #gfmtasklistitemtomarkdown
[api-gfm-task-list-item-to-markdown]: #gfmtasklistitemtomarkdown
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc