mdast-util-gfm-footnote
Advanced tools
Comparing version 1.0.0 to 1.0.1
65
index.js
@@ -16,7 +16,4 @@ /** | ||
import {safe} from 'mdast-util-to-markdown/lib/util/safe.js' | ||
import {visit, EXIT} from 'unist-util-visit' | ||
import {track} from 'mdast-util-to-markdown/lib/util/track.js' | ||
let warningColonInFootnote = false | ||
let warningListInFootnote = false | ||
/** | ||
@@ -115,12 +112,18 @@ * @returns {FromMarkdownExtension} | ||
*/ | ||
function footnoteReference(node, _, context) { | ||
function footnoteReference(node, _, context, safeOptions) { | ||
const tracker = track(safeOptions) | ||
let value = tracker.move('[^') | ||
const exit = context.enter('footnoteReference') | ||
const subexit = context.enter('reference') | ||
const reference = safe(context, association(node), { | ||
before: '^', | ||
after: ']' | ||
}) | ||
value += tracker.move( | ||
safe(context, association(node), { | ||
...tracker.current(), | ||
before: value, | ||
after: ']' | ||
}) | ||
) | ||
subexit() | ||
exit() | ||
return '[^' + reference + ']' | ||
value += tracker.move(']') | ||
return value | ||
} | ||
@@ -137,30 +140,24 @@ | ||
*/ | ||
function footnoteDefinition(node, _, context) { | ||
function footnoteDefinition(node, _, context, safeOptions) { | ||
const tracker = track(safeOptions) | ||
let value = tracker.move('[^') | ||
const exit = context.enter('footnoteDefinition') | ||
const subexit = context.enter('label') | ||
const id = safe(context, association(node), {before: '^', after: ']'}) | ||
const label = '[^' + id + ']:' | ||
value += tracker.move( | ||
safe(context, association(node), { | ||
...tracker.current(), | ||
before: value, | ||
after: ']' | ||
}) | ||
) | ||
subexit() | ||
const value = indentLines(containerFlow(node, context), map) | ||
value += tracker.move( | ||
']:' + (node.children && node.children.length > 0 ? ' ' : '') | ||
) | ||
tracker.shift(4) | ||
value += tracker.move( | ||
indentLines(containerFlow(node, context, tracker.current()), map) | ||
) | ||
exit() | ||
if (!warningColonInFootnote && id.includes(':')) { | ||
console.warn( | ||
'[mdast-util-gfm-footnote] Warning: Found a colon in footnote identifier `' + | ||
id + | ||
'`. GitHub currently crahes on colons in footnotes (see <https://github.com/github/cmark-gfm/issues/241> for more info)' | ||
) | ||
warningColonInFootnote = true | ||
} | ||
if (!warningListInFootnote) { | ||
visit(node, 'list', () => { | ||
console.warn( | ||
'[mdast-util-gfm-footnote] Warning: Found a list in a footnote definition. GitHub currently crahes on lists in footnotes (see <https://github.com/github/cmark-gfm/issues/241> for more info)' | ||
) | ||
warningListInFootnote = true | ||
return EXIT | ||
}) | ||
} | ||
return value | ||
@@ -174,5 +171,5 @@ | ||
return (blank ? label : label + ' ') + line | ||
return line | ||
} | ||
} | ||
} |
{ | ||
"name": "mdast-util-gfm-footnote", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "mdast extension to parse and serialize GFM footnotes", | ||
@@ -38,5 +38,4 @@ "license": "MIT", | ||
"@types/mdast": "^3.0.0", | ||
"mdast-util-to-markdown": "^1.0.0", | ||
"micromark-util-normalize-identifier": "^1.0.0", | ||
"unist-util-visit": "^4.0.0" | ||
"mdast-util-to-markdown": "^1.3.0", | ||
"micromark-util-normalize-identifier": "^1.0.0" | ||
}, | ||
@@ -55,3 +54,3 @@ "devDependencies": { | ||
"typescript": "^4.0.0", | ||
"xo": "^0.45.0" | ||
"xo": "^0.47.0" | ||
}, | ||
@@ -58,0 +57,0 @@ "scripts": { |
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
3
14278
- Removedunist-util-visit@^4.0.0