mdast-util-gfm-footnote
Advanced tools
Comparing version 1.0.2 to 2.0.0
export {gfmFootnoteFromMarkdown, gfmFootnoteToMarkdown} from './lib/index.js' | ||
declare module 'mdast-util-to-markdown' { | ||
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions | ||
interface ConstructNameMap { | ||
@@ -6,0 +5,0 @@ /** |
@@ -17,9 +17,9 @@ /** | ||
export function gfmFootnoteToMarkdown(): ToMarkdownExtension | ||
export type FootnoteDefinition = import('mdast').FootnoteDefinition | ||
export type FootnoteReference = import('mdast').FootnoteReference | ||
export type FootnoteDefinition = import('mdast').FootnoteDefinition | ||
export type CompileContext = import('mdast-util-from-markdown').CompileContext | ||
export type FromMarkdownExtension = import('mdast-util-from-markdown').Extension | ||
export type FromMarkdownHandle = import('mdast-util-from-markdown').Handle | ||
export type ToMarkdownExtension = import('mdast-util-to-markdown').Options | ||
export type ToMarkdownHandle = import('mdast-util-to-markdown').Handle | ||
export type Map = import('mdast-util-to-markdown').Map | ||
export type ToMarkdownExtension = import('mdast-util-to-markdown').Options |
/** | ||
* @typedef {import('mdast').FootnoteDefinition} FootnoteDefinition | ||
* @typedef {import('mdast').FootnoteReference} FootnoteReference | ||
* @typedef {import('mdast').FootnoteDefinition} FootnoteDefinition | ||
* @typedef {import('mdast-util-from-markdown').CompileContext} CompileContext | ||
* @typedef {import('mdast-util-from-markdown').Extension} FromMarkdownExtension | ||
* @typedef {import('mdast-util-from-markdown').Handle} FromMarkdownHandle | ||
* @typedef {import('mdast-util-to-markdown').Options} ToMarkdownExtension | ||
* @typedef {import('mdast-util-to-markdown').Handle} ToMarkdownHandle | ||
* @typedef {import('mdast-util-to-markdown').Map} Map | ||
* @typedef {import('mdast-util-to-markdown').Options} ToMarkdownExtension | ||
*/ | ||
import {ok as assert} from 'devlop' | ||
import {normalizeIdentifier} from 'micromark-util-normalize-identifier' | ||
import {association} from 'mdast-util-to-markdown/lib/util/association.js' | ||
import {containerFlow} from 'mdast-util-to-markdown/lib/util/container-flow.js' | ||
import {indentLines} from 'mdast-util-to-markdown/lib/util/indent-lines.js' | ||
import {safe} from 'mdast-util-to-markdown/lib/util/safe.js' | ||
import {track} from 'mdast-util-to-markdown/lib/util/track.js' | ||
footnoteReference.peek = footnoteReferencePeek | ||
// To do: next major: rename `context` -> `state`, `safeOptions` to `info`, use | ||
// utilities on `state`. | ||
/** | ||
@@ -88,5 +81,4 @@ * Create an extension for `mdast-util-from-markdown` to enable GFM footnotes | ||
const label = this.resume() | ||
const node = /** @type {FootnoteDefinition} */ ( | ||
this.stack[this.stack.length - 1] | ||
) | ||
const node = this.stack[this.stack.length - 1] | ||
assert(node.type === 'footnoteDefinition') | ||
node.label = label | ||
@@ -128,5 +120,4 @@ node.identifier = normalizeIdentifier( | ||
const label = this.resume() | ||
const node = /** @type {FootnoteDefinition} */ ( | ||
this.stack[this.stack.length - 1] | ||
) | ||
const node = this.stack[this.stack.length - 1] | ||
assert(node.type === 'footnoteReference') | ||
node.label = label | ||
@@ -150,9 +141,9 @@ node.identifier = normalizeIdentifier( | ||
*/ | ||
function footnoteReference(node, _, context, safeOptions) { | ||
const tracker = track(safeOptions) | ||
function footnoteReference(node, _, state, info) { | ||
const tracker = state.createTracker(info) | ||
let value = tracker.move('[^') | ||
const exit = context.enter('footnoteReference') | ||
const subexit = context.enter('reference') | ||
const exit = state.enter('footnoteReference') | ||
const subexit = state.enter('reference') | ||
value += tracker.move( | ||
safe(context, association(node), { | ||
state.safe(state.associationId(node), { | ||
...tracker.current(), | ||
@@ -178,9 +169,9 @@ before: value, | ||
*/ | ||
function footnoteDefinition(node, _, context, safeOptions) { | ||
const tracker = track(safeOptions) | ||
function footnoteDefinition(node, _, state, info) { | ||
const tracker = state.createTracker(info) | ||
let value = tracker.move('[^') | ||
const exit = context.enter('footnoteDefinition') | ||
const subexit = context.enter('label') | ||
const exit = state.enter('footnoteDefinition') | ||
const subexit = state.enter('label') | ||
value += tracker.move( | ||
safe(context, association(node), { | ||
state.safe(state.associationId(node), { | ||
...tracker.current(), | ||
@@ -197,3 +188,3 @@ before: value, | ||
value += tracker.move( | ||
indentLines(containerFlow(node, context, tracker.current()), map) | ||
state.indentLines(state.containerFlow(node, tracker.current()), map) | ||
) | ||
@@ -200,0 +191,0 @@ exit() |
{ | ||
"name": "mdast-util-gfm-footnote", | ||
"version": "1.0.2", | ||
"version": "2.0.0", | ||
"description": "mdast extension to parse and serialize GFM footnotes", | ||
@@ -30,4 +30,3 @@ "license": "MIT", | ||
"type": "module", | ||
"main": "index.js", | ||
"types": "index.d.ts", | ||
"exports": "./index.js", | ||
"files": [ | ||
@@ -39,11 +38,12 @@ "lib/", | ||
"dependencies": { | ||
"@types/mdast": "^3.0.0", | ||
"mdast-util-to-markdown": "^1.3.0", | ||
"micromark-util-normalize-identifier": "^1.0.0" | ||
"@types/mdast": "^4.0.0", | ||
"devlop": "^1.1.0", | ||
"mdast-util-from-markdown": "^2.0.0", | ||
"mdast-util-to-markdown": "^2.0.0", | ||
"micromark-util-normalize-identifier": "^2.0.0" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^18.0.0", | ||
"c8": "^7.0.0", | ||
"mdast-util-from-markdown": "^1.0.0", | ||
"micromark-extension-gfm-footnote": "^1.0.0", | ||
"@types/node": "^20.0.0", | ||
"c8": "^8.0.0", | ||
"micromark-extension-gfm-footnote": "^2.0.0", | ||
"prettier": "^2.0.0", | ||
@@ -53,4 +53,4 @@ "remark-cli": "^11.0.0", | ||
"type-coverage": "^2.0.0", | ||
"typescript": "^4.0.0", | ||
"xo": "^0.53.0" | ||
"typescript": "^5.0.0", | ||
"xo": "^0.54.0" | ||
}, | ||
@@ -61,20 +61,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-dev": "node --conditions development test.js", | ||
"test-api-prod": "node --conditions production 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" | ||
] | ||
@@ -85,5 +84,18 @@ }, | ||
"detail": true, | ||
"strict": true, | ||
"ignoreCatch": true | ||
"ignoreCatch": true, | ||
"strict": true | ||
}, | ||
"xo": { | ||
"overrides": [ | ||
{ | ||
"files": [ | ||
"**/*.ts" | ||
], | ||
"rules": { | ||
"@typescript-eslint/consistent-type-definitions": "off" | ||
} | ||
} | ||
], | ||
"prettier": true | ||
} | ||
} |
@@ -72,3 +72,3 @@ # mdast-util-gfm-footnote | ||
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][]: | ||
@@ -82,3 +82,3 @@ ```sh | ||
```js | ||
import {gfmFootnoteFromMarkdown, gfmFootnoteToMarkdown} from 'https://esm.sh/mdast-util-gfm-footnote@1' | ||
import {gfmFootnoteFromMarkdown, gfmFootnoteToMarkdown} from 'https://esm.sh/mdast-util-gfm-footnote@2' | ||
``` | ||
@@ -90,3 +90,3 @@ | ||
<script type="module"> | ||
import {gfmFootnoteFromMarkdown, gfmFootnoteToMarkdown} from 'https://esm.sh/mdast-util-gfm-footnote@1?bundle' | ||
import {gfmFootnoteFromMarkdown, gfmFootnoteToMarkdown} from 'https://esm.sh/mdast-util-gfm-footnote@2?bundle' | ||
</script> | ||
@@ -196,3 +196,3 @@ ``` | ||
See [Syntax in `micromark-extension-frontmatter`][syntax]. | ||
See [Syntax in `micromark-extension-gfm-footnote`][syntax]. | ||
@@ -263,3 +263,3 @@ ## Syntax tree | ||
**FootnoteReference** can be used where | ||
**[static phrasing][dfn-static-phrasing-content]** content is expected. | ||
**[phrasing][dfn-phrasing-content]** content is expected. | ||
It has no content model. | ||
@@ -296,6 +296,6 @@ | ||
#### `StaticPhrasingContent` (GFM footnotes) | ||
#### `PhrasingContent` (GFM footnotes) | ||
```idl | ||
type StaticPhrasingContentGfm = FootnoteReference | StaticPhrasingContent | ||
type PhrasingContentGfm = FootnoteReference | PhrasingContent | ||
``` | ||
@@ -313,9 +313,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-footnote@^2`, compatible with Node.js 16. | ||
@@ -360,5 +360,5 @@ ## Related | ||
[size-badge]: https://img.shields.io/bundlephobia/minzip/mdast-util-gfm-footnote.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-footnote | ||
[size]: https://bundlephobia.com/result?p=mdast-util-gfm-footnote | ||
[size]: https://bundlejs.com/?q=mdast-util-gfm-footnote | ||
@@ -431,3 +431,3 @@ [sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg | ||
[dfn-static-phrasing-content]: #staticphrasingcontent-gfm-footnotes | ||
[dfn-phrasing-content]: #phrasingcontent-gfm-footnotes | ||
@@ -434,0 +434,0 @@ [dfn-footnote-reference]: #footnotereference |
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
9
0
21387
5
229
+ Addeddevlop@^1.1.0
+ 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.1(transitive)
+ Addedmdast-util-phrasing@4.1.0(transitive)
+ Addedmdast-util-to-markdown@2.1.0(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-normalize-identifier@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