Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mdast-util-gfm-strikethrough

Package Overview
Dependencies
Maintainers
2
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mdast-util-gfm-strikethrough - npm Package Compare versions

Comparing version 1.0.3 to 2.0.0

1

index.d.ts

@@ -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 @@ /**

18

lib/index.d.ts
/**
* 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

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