mdast-util-gfm-strikethrough
Advanced tools
Comparing version 1.0.3 to 2.0.0
@@ -8,3 +8,2 @@ export { | ||
declare module 'mdast-util-to-markdown' { | ||
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions | ||
interface ConstructNameMap { | ||
@@ -11,0 +10,0 @@ /** |
/** | ||
* Extension for `mdast-util-from-markdown` to enable GFM strikethrough. | ||
* Create an extension for `mdast-util-from-markdown` to enable GFM | ||
* strikethrough in markdown. | ||
* | ||
* @type {FromMarkdownExtension} | ||
* @returns {FromMarkdownExtension} | ||
* Extension for `mdast-util-from-markdown` to enable GFM strikethrough. | ||
*/ | ||
export const gfmStrikethroughFromMarkdown: FromMarkdownExtension | ||
export function gfmStrikethroughFromMarkdown(): FromMarkdownExtension | ||
/** | ||
* Extension for `mdast-util-to-markdown` to enable GFM strikethrough. | ||
* Create an extension for `mdast-util-to-markdown` to enable GFM | ||
* strikethrough in markdown. | ||
* | ||
* @type {ToMarkdownExtension} | ||
* @returns {ToMarkdownExtension} | ||
* Extension for `mdast-util-to-markdown` to enable GFM strikethrough. | ||
*/ | ||
export const gfmStrikethroughToMarkdown: ToMarkdownExtension | ||
export function gfmStrikethroughToMarkdown(): ToMarkdownExtension | ||
export type Delete = import('mdast').Delete | ||
@@ -18,3 +22,3 @@ export type CompileContext = import('mdast-util-from-markdown').CompileContext | ||
export type ConstructName = import('mdast-util-to-markdown').ConstructName | ||
export type ToMarkdownHandle = import('mdast-util-to-markdown').Handle | ||
export type ToMarkdownExtension = import('mdast-util-to-markdown').Options | ||
export type ToMarkdownHandle = import('mdast-util-to-markdown').Handle |
@@ -9,12 +9,6 @@ /** | ||
* @typedef {import('mdast-util-to-markdown').ConstructName} ConstructName | ||
* @typedef {import('mdast-util-to-markdown').Handle} ToMarkdownHandle | ||
* @typedef {import('mdast-util-to-markdown').Options} ToMarkdownExtension | ||
* @typedef {import('mdast-util-to-markdown').Handle} ToMarkdownHandle | ||
*/ | ||
import {containerPhrasing} from 'mdast-util-to-markdown/lib/util/container-phrasing.js' | ||
import {track} from 'mdast-util-to-markdown/lib/util/track.js' | ||
// To do: next major: expose functions. | ||
// To do: next major: use `state`, state utilities. | ||
/** | ||
@@ -42,26 +36,34 @@ * List of constructs that occur in phrasing (paragraphs, headings), but cannot | ||
/** | ||
* Extension for `mdast-util-from-markdown` to enable GFM strikethrough. | ||
* Create an extension for `mdast-util-from-markdown` to enable GFM | ||
* strikethrough in markdown. | ||
* | ||
* @type {FromMarkdownExtension} | ||
* @returns {FromMarkdownExtension} | ||
* Extension for `mdast-util-from-markdown` to enable GFM strikethrough. | ||
*/ | ||
export const gfmStrikethroughFromMarkdown = { | ||
canContainEols: ['delete'], | ||
enter: {strikethrough: enterStrikethrough}, | ||
exit: {strikethrough: exitStrikethrough} | ||
export function gfmStrikethroughFromMarkdown() { | ||
return { | ||
canContainEols: ['delete'], | ||
enter: {strikethrough: enterStrikethrough}, | ||
exit: {strikethrough: exitStrikethrough} | ||
} | ||
} | ||
/** | ||
* Extension for `mdast-util-to-markdown` to enable GFM strikethrough. | ||
* Create an extension for `mdast-util-to-markdown` to enable GFM | ||
* strikethrough in markdown. | ||
* | ||
* @type {ToMarkdownExtension} | ||
* @returns {ToMarkdownExtension} | ||
* Extension for `mdast-util-to-markdown` to enable GFM strikethrough. | ||
*/ | ||
export const gfmStrikethroughToMarkdown = { | ||
unsafe: [ | ||
{ | ||
character: '~', | ||
inConstruct: 'phrasing', | ||
notInConstruct: constructsWithoutStrikethrough | ||
} | ||
], | ||
handlers: {delete: handleDelete} | ||
export function gfmStrikethroughToMarkdown() { | ||
return { | ||
unsafe: [ | ||
{ | ||
character: '~', | ||
inConstruct: 'phrasing', | ||
notInConstruct: constructsWithoutStrikethrough | ||
} | ||
], | ||
handlers: {delete: handleDelete} | ||
} | ||
} | ||
@@ -89,7 +91,7 @@ | ||
*/ | ||
function handleDelete(node, _, context, safeOptions) { | ||
const tracker = track(safeOptions) | ||
const exit = context.enter('strikethrough') | ||
function handleDelete(node, _, state, info) { | ||
const tracker = state.createTracker(info) | ||
const exit = state.enter('strikethrough') | ||
let value = tracker.move('~~') | ||
value += containerPhrasing(node, context, { | ||
value += state.containerPhrasing(node, { | ||
...tracker.current(), | ||
@@ -96,0 +98,0 @@ before: value, |
{ | ||
"name": "mdast-util-gfm-strikethrough", | ||
"version": "1.0.3", | ||
"version": "2.0.0", | ||
"description": "mdast extension to parse and serialize GFM strikethrough", | ||
@@ -34,4 +34,3 @@ "license": "MIT", | ||
"type": "module", | ||
"main": "index.js", | ||
"types": "index.d.ts", | ||
"exports": "./index.js", | ||
"files": [ | ||
@@ -43,10 +42,10 @@ "lib/", | ||
"dependencies": { | ||
"@types/mdast": "^3.0.0", | ||
"mdast-util-to-markdown": "^1.3.0" | ||
"@types/mdast": "^4.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-strikethrough": "^1.0.0", | ||
"@types/node": "^20.0.0", | ||
"c8": "^8.0.0", | ||
"micromark-extension-gfm-strikethrough": "^2.0.0", | ||
"prettier": "^2.0.0", | ||
@@ -56,5 +55,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 +64,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 +87,18 @@ }, | ||
"detail": true, | ||
"strict": true, | ||
"ignoreCatch": true | ||
"ignoreCatch": true, | ||
"strict": true | ||
}, | ||
"xo": { | ||
"overrides": [ | ||
{ | ||
"files": [ | ||
"**/*.ts" | ||
], | ||
"rules": { | ||
"@typescript-eslint/consistent-type-definitions": "off" | ||
} | ||
} | ||
], | ||
"prettier": true | ||
} | ||
} |
@@ -20,4 +20,4 @@ # mdast-util-gfm-strikethrough | ||
* [API](#api) | ||
* [`gfmStrikethroughFromMarkdown`](#gfmstrikethroughfrommarkdown) | ||
* [`gfmStrikethroughToMarkdown`](#gfmstrikethroughtomarkdown) | ||
* [`gfmStrikethroughFromMarkdown()`](#gfmstrikethroughfrommarkdown) | ||
* [`gfmStrikethroughToMarkdown()`](#gfmstrikethroughtomarkdown) | ||
* [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 {gfmStrikethroughFromMarkdown, gfmStrikethroughToMarkdown} from 'https://esm.sh/mdast-util-gfm-strikethrough@1' | ||
import {gfmStrikethroughFromMarkdown, gfmStrikethroughToMarkdown} from 'https://esm.sh/mdast-util-gfm-strikethrough@2' | ||
``` | ||
@@ -87,3 +87,3 @@ | ||
<script type="module"> | ||
import {gfmStrikethroughFromMarkdown, gfmStrikethroughToMarkdown} from 'https://esm.sh/mdast-util-gfm-strikethrough@1?bundle' | ||
import {gfmStrikethroughFromMarkdown, gfmStrikethroughToMarkdown} from 'https://esm.sh/mdast-util-gfm-strikethrough@2?bundle' | ||
</script> | ||
@@ -104,6 +104,6 @@ ``` | ||
import fs from 'node:fs/promises' | ||
import {gfmStrikethrough} from 'micromark-extension-gfm-strikethrough' | ||
import {fromMarkdown} from 'mdast-util-from-markdown' | ||
import {gfmStrikethroughFromMarkdown, gfmStrikethroughToMarkdown} from 'mdast-util-gfm-strikethrough' | ||
import {toMarkdown} from 'mdast-util-to-markdown' | ||
import {gfmStrikethrough} from 'micromark-extension-gfm-strikethrough' | ||
import {gfmStrikethroughFromMarkdown, gfmStrikethroughToMarkdown} from 'mdast-util-gfm-strikethrough' | ||
@@ -114,3 +114,3 @@ const doc = await fs.readFile('example.md') | ||
extensions: [gfmStrikethrough()], | ||
mdastExtensions: [gfmStrikethroughFromMarkdown] | ||
mdastExtensions: [gfmStrikethroughFromMarkdown()] | ||
}) | ||
@@ -120,3 +120,3 @@ | ||
const out = toMarkdown(tree, {extensions: [gfmStrikethroughToMarkdown]}) | ||
const out = toMarkdown(tree, {extensions: [gfmStrikethroughToMarkdown()]}) | ||
@@ -158,12 +158,22 @@ console.log(out) | ||
### `gfmStrikethroughFromMarkdown` | ||
### `gfmStrikethroughFromMarkdown()` | ||
Extension for [`mdast-util-from-markdown`][mdast-util-from-markdown] to enable | ||
GFM strikethrough ([`FromMarkdownExtension`][from-markdown-extension]). | ||
Create an extension for [`mdast-util-from-markdown`][mdast-util-from-markdown] | ||
to enable GFM strikethrough in markdown. | ||
### `gfmStrikethroughToMarkdown` | ||
###### Returns | ||
Extension for [`mdast-util-to-markdown`][mdast-util-to-markdown] to enable | ||
GFM strikethrough ([`ToMarkdownExtension`][to-markdown-extension]). | ||
Extension for `mdast-util-from-markdown` to enable GFM strikethrough | ||
([`FromMarkdownExtension`][from-markdown-extension]). | ||
### `gfmStrikethroughToMarkdown()` | ||
Create an extension for [`mdast-util-to-markdown`][mdast-util-to-markdown] to | ||
enable GFM strikethrough in markdown. | ||
###### Returns | ||
Extension for `mdast-util-to-markdown` to enable GFM strikethrough | ||
([`ToMarkdownExtension`][to-markdown-extension]). | ||
## HTML | ||
@@ -197,3 +207,3 @@ | ||
**Delete** can be used where **[static phrasing][dfn-static-phrasing-content]** | ||
**Delete** can be used where **[phrasing][dfn-phrasing-content]** | ||
content is expected. | ||
@@ -219,6 +229,6 @@ Its content model is **[transparent][dfn-transparent-content]** content. | ||
#### `StaticPhrasingContent` (GFM strikethrough) | ||
#### `PhrasingContent` (GFM strikethrough) | ||
```idl | ||
type StaticPhrasingContentGfm = Delete | StaticPhrasingContent | ||
type PhrasingContentGfm = Delete | PhrasingContent | ||
``` | ||
@@ -235,10 +245,13 @@ | ||
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-strikethrough@^2`, compatible with Node.js 16. | ||
This utility works with `mdast-util-from-markdown` version 2+ and | ||
`mdast-util-to-markdown` version 2+. | ||
## Related | ||
@@ -282,5 +295,5 @@ | ||
[size-badge]: https://img.shields.io/bundlephobia/minzip/mdast-util-gfm-strikethrough.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-strikethrough | ||
[size]: https://bundlephobia.com/result?p=mdast-util-gfm-strikethrough | ||
[size]: https://bundlejs.com/?q=mdast-util-gfm-strikethrough | ||
@@ -345,3 +358,3 @@ [sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg | ||
[dfn-static-phrasing-content]: #staticphrasingcontent-gfm-strikethrough | ||
[dfn-phrasing-content]: #phrasingcontent-gfm-strikethrough | ||
@@ -348,0 +361,0 @@ [api-gfm-strikethrough-from-markdown]: #gfmstrikethroughfrommarkdown |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
17828
10
144
351
0
3
+ Added@types/debug@4.1.12(transitive)
+ Added@types/mdast@4.0.4(transitive)
+ Added@types/ms@0.7.34(transitive)
+ Added@types/unist@3.0.3(transitive)
+ Addeddebug@4.3.7(transitive)
+ Addeddequal@2.0.3(transitive)
+ Addeddevlop@1.1.0(transitive)
+ Addedmdast-util-from-markdown@2.0.2(transitive)
+ Addedmdast-util-phrasing@4.1.0(transitive)
+ Addedmdast-util-to-markdown@2.1.1(transitive)
+ Addedmdast-util-to-string@4.0.0(transitive)
+ Addedmicromark@4.0.0(transitive)
+ Addedmicromark-core-commonmark@2.0.1(transitive)
+ Addedmicromark-factory-destination@2.0.0(transitive)
+ Addedmicromark-factory-label@2.0.0(transitive)
+ Addedmicromark-factory-space@2.0.0(transitive)
+ Addedmicromark-factory-title@2.0.0(transitive)
+ Addedmicromark-factory-whitespace@2.0.0(transitive)
+ Addedmicromark-util-character@2.1.0(transitive)
+ Addedmicromark-util-chunked@2.0.0(transitive)
+ Addedmicromark-util-classify-character@2.0.0(transitive)
+ Addedmicromark-util-combine-extensions@2.0.0(transitive)
+ Addedmicromark-util-decode-numeric-character-reference@2.0.1(transitive)
+ Addedmicromark-util-decode-string@2.0.0(transitive)
+ Addedmicromark-util-encode@2.0.0(transitive)
+ Addedmicromark-util-html-tag-name@2.0.0(transitive)
+ Addedmicromark-util-normalize-identifier@2.0.0(transitive)
+ Addedmicromark-util-resolve-all@2.0.0(transitive)
+ Addedmicromark-util-sanitize-uri@2.0.0(transitive)
+ Addedmicromark-util-subtokenize@2.0.1(transitive)
+ Addedmicromark-util-symbol@2.0.0(transitive)
+ Addedmicromark-util-types@2.0.0(transitive)
+ Addedms@2.1.3(transitive)
+ Addedunist-util-is@6.0.0(transitive)
+ Addedunist-util-stringify-position@4.0.0(transitive)
+ Addedunist-util-visit@5.0.0(transitive)
+ Addedunist-util-visit-parents@6.0.1(transitive)
- Removed@types/mdast@3.0.15(transitive)
- Removed@types/unist@2.0.11(transitive)
- Removedmdast-util-phrasing@3.0.1(transitive)
- Removedmdast-util-to-markdown@1.5.0(transitive)
- Removedmdast-util-to-string@3.2.0(transitive)
- Removedmicromark-util-character@1.2.0(transitive)
- Removedmicromark-util-decode-numeric-character-reference@1.1.0(transitive)
- Removedmicromark-util-decode-string@1.1.0(transitive)
- Removedmicromark-util-symbol@1.1.0(transitive)
- Removedmicromark-util-types@1.1.0(transitive)
- Removedunist-util-is@5.2.1(transitive)
- Removedunist-util-visit@4.1.2(transitive)
- Removedunist-util-visit-parents@5.1.3(transitive)
Updated@types/mdast@^4.0.0