micromark-extension-gfm-strikethrough
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -12,2 +12,5 @@ /** | ||
export type Event = import('micromark-util-types').Event | ||
/** | ||
* Configuration (optional). | ||
*/ | ||
export type Options = { | ||
@@ -14,0 +17,0 @@ /** |
@@ -12,2 +12,3 @@ /** | ||
* @typedef Options | ||
* Configuration (optional). | ||
* @property {boolean} [singleTilde=true] | ||
@@ -14,0 +15,0 @@ * Whether to support strikethrough with a single tilde (`boolean`, default: |
@@ -12,2 +12,5 @@ /** | ||
export type Event = import('micromark-util-types').Event | ||
/** | ||
* Configuration (optional). | ||
*/ | ||
export type Options = { | ||
@@ -14,0 +17,0 @@ /** |
@@ -12,2 +12,3 @@ /** | ||
* @typedef Options | ||
* Configuration (optional). | ||
* @property {boolean} [singleTilde=true] | ||
@@ -14,0 +15,0 @@ * Whether to support strikethrough with a single tilde (`boolean`, default: |
{ | ||
"name": "micromark-extension-gfm-strikethrough", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "micromark extension to support GFM strikethrough", | ||
@@ -54,2 +54,3 @@ "license": "MIT", | ||
"c8": "^7.0.0", | ||
"create-gfm-fixtures": "^1.0.0", | ||
"micromark": "^3.0.0", | ||
@@ -64,3 +65,3 @@ "micromark-build": "^1.0.0", | ||
"typescript": "^4.0.0", | ||
"xo": "^0.45.0" | ||
"xo": "^0.47.0" | ||
}, | ||
@@ -67,0 +68,0 @@ "scripts": { |
140
readme.md
@@ -12,19 +12,47 @@ # micromark-extension-gfm-strikethrough | ||
**[micromark][]** extension to support GitHub flavored markdown (GFM) | ||
[strikethrough][] (~~like this~~). | ||
This syntax extension matches either the GFM spec (only two tildes work) or | ||
github.com (both one or two tildes, when they match, work). | ||
[strikethrough][]. | ||
## Contents | ||
* [What is this?](#what-is-this) | ||
* [When to use this](#when-to-use-this) | ||
* [Install](#install) | ||
* [Use](#use) | ||
* [API](#api) | ||
* [`gfmStrikethrough(options?)`](#gfmstrikethroughoptions) | ||
* [`gfmStrikethroughHtml`](#gfmstrikethroughhtml) | ||
* [Types](#types) | ||
* [Compatibility](#compatibility) | ||
* [Security](#security) | ||
* [Related](#related) | ||
* [Contribute](#contribute) | ||
* [License](#license) | ||
## What is this? | ||
This package is a micromark extension to add support for GFM strikethrough. | ||
Strikethrough on `github.com`, which this extension matches, can use one | ||
(`~one~`) or two (`~~two~~`) tildes. | ||
You can also strictly match the GFM spec instead of their implementation by | ||
passing `singleTilde: false`. | ||
## When to use this | ||
You should probably use [`micromark-extension-gfm`][micromark-extension-gfm] | ||
instead, which combines this package with other GFM features. | ||
Alternatively, if you don’t want all of GFM, use this package. | ||
In many cases, when working with micromark, you’d want to use | ||
[`micromark-extension-gfm`][micromark-extension-gfm] instead, which combines | ||
this package with other GFM features. | ||
When working with syntax trees, you’d want to combine this package with | ||
[`mdast-util-gfm-strikethrough`][mdast-util-gfm-strikethrough] (or | ||
[`mdast-util-gfm`][mdast-util-gfm] when using `micromark-extension-gfm`). | ||
These tools are all rather low-level. | ||
In most cases, you’d instead want to use [`remark-gfm`][remark-gfm] with | ||
[remark][]. | ||
## Install | ||
This package is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c): | ||
Node 12+ is needed to use it and it must be `import`ed instead of `require`d. | ||
This package is [ESM only][esm]. | ||
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]: | ||
[npm][]: | ||
```sh | ||
@@ -34,2 +62,16 @@ npm install micromark-extension-gfm-strikethrough | ||
In Deno with [Skypack][]: | ||
```js | ||
import {gfmStrikethrough, gfmStrikethroughHtml} from 'https://cdn.skypack.dev/micromark-extension-gfm-strikethrough@1?dts' | ||
``` | ||
In browsers with [Skypack][]: | ||
```html | ||
<script type="module"> | ||
import {gfmStrikethrough, gfmStrikethroughHtml} from 'https://cdn.skypack.dev/micromark-extension-gfm-strikethrough@1?min' | ||
</script> | ||
``` | ||
## Use | ||
@@ -65,3 +107,3 @@ | ||
The export map supports the endorsed | ||
[`development` condition](https://nodejs.org/api/packages.html#packages\_resolving\_user\_conditions). | ||
[`development` condition](https://nodejs.org/api/packages.html#packages_resolving_user_conditions). | ||
Run `node --conditions development module.js` to get instrumented dev code. | ||
@@ -72,13 +114,9 @@ Without this condition, production code is loaded. | ||
### `gfmStrikethroughHtml` | ||
A function that can be called to get an extension for micromark to parse | ||
GFM strikethrough (can be passed in `extensions`). | ||
Support strikethrough (~~like this~~). | ||
`gfmStrikethrough` is a function that can be called with options and returns | ||
an extension for micromark to parse strikethrough (can be passed in | ||
`extensions`). | ||
`gfmStrikethroughHtml` is an extension for micromark to compile as `<del>` | ||
elements (can be passed in `htmlExtensions`). | ||
##### `options` | ||
Configuration (optional). | ||
###### `options.singleTilde` | ||
@@ -88,23 +126,31 @@ | ||
`true`). | ||
Single tildes work on github.com, but are technically prohibited by the GFM | ||
spec. | ||
Single tildes work on github.com, but are technically prohibited by GFM. | ||
### `gfmStrikethroughHtml` | ||
An extension to compile them to HTML (can be passed in `htmlExtensions`). | ||
## Types | ||
This package is fully typed with [TypeScript][]. | ||
It exports additional `Options` type that models its respective interface. | ||
## Compatibility | ||
This package is at least compatible with all maintained versions of Node.js. | ||
As of now, that is Node.js 12.20+, 14.14+, and 16.0+. | ||
It also works in Deno and modern browsers. | ||
## Security | ||
This package is safe. | ||
## Related | ||
* [`remarkjs/remark`][remark] | ||
— markdown processor powered by plugins | ||
* [`remarkjs/remark-gfm`](https://github.com/remarkjs/remark-gfm) | ||
— remark plugin using this and other GFM features | ||
* [`micromark/micromark`][micromark] | ||
— the smallest commonmark-compliant markdown parser that exists | ||
* [`micromark/micromark-extension-gfm`][micromark-extension-gfm] | ||
— micromark extension combining this with other GFM features | ||
* [`syntax-tree/mdast-util-gfm-strikethrough`][mdast-util-gfm-strikethrough] | ||
— mdast utility to support strikethrough | ||
* [`syntax-tree/mdast-util-gfm`](https://github.com/syntax-tree/mdast-util-gfm) | ||
— mdast utility to support GFM | ||
* [`syntax-tree/mdast-util-from-markdown`][from-markdown] | ||
— mdast parser using `micromark` to create mdast from markdown | ||
* [`syntax-tree/mdast-util-to-markdown`][to-markdown] | ||
— mdast serializer to create markdown from mdast | ||
— support GFM strikethrough in mdast | ||
* [`syntax-tree/mdast-util-gfm`][mdast-util-gfm] | ||
— support GFM in mdast | ||
* [`remarkjs/remark-gfm`][remark-gfm] | ||
— support GFM in remark | ||
@@ -155,2 +201,4 @@ ## Contribute | ||
[skypack]: https://www.skypack.dev | ||
[license]: license | ||
@@ -160,20 +208,24 @@ | ||
[contributing]: https://github.com/micromark/.github/blob/HEAD/contributing.md | ||
[contributing]: https://github.com/micromark/.github/blob/main/contributing.md | ||
[support]: https://github.com/micromark/.github/blob/HEAD/support.md | ||
[support]: https://github.com/micromark/.github/blob/main/support.md | ||
[coc]: https://github.com/micromark/.github/blob/HEAD/code-of-conduct.md | ||
[coc]: https://github.com/micromark/.github/blob/main/code-of-conduct.md | ||
[micromark]: https://github.com/micromark/micromark | ||
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c | ||
[from-markdown]: https://github.com/syntax-tree/mdast-util-from-markdown | ||
[typescript]: https://www.typescriptlang.org | ||
[to-markdown]: https://github.com/syntax-tree/mdast-util-to-markdown | ||
[micromark]: https://github.com/micromark/micromark | ||
[remark]: https://github.com/remarkjs/remark | ||
[micromark-extension-gfm]: https://github.com/micromark/micromark-extension-gfm | ||
[mdast-util-gfm-strikethrough]: https://github.com/syntax-tree/mdast-util-gfm-strikethrough | ||
[mdast-util-gfm]: https://github.com/syntax-tree/mdast-util-gfm | ||
[remark-gfm]: https://github.com/remarkjs/remark-gfm | ||
[strikethrough]: https://github.github.com/gfm/#strikethrough-extension- | ||
[micromark-extension-gfm]: https://github.com/micromark/micromark-extension-gfm |
23966
419
225
13