From 0cfeae1dcd0d0bef743e64805df2fe741d00bb08 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Sun, 4 Oct 2020 10:22:24 +0200 Subject: [PATCH] Update for `micromark` in `remark@13` * Update to a micromark parser, defer work to , * Change footnote reference to match link references: footnote references are only parsed when defined * Change footnote definitions to match lists: footnote definitions can now interrupt block quotes, lists, and paragraphs --- index.js | 522 ++---------------- package.json | 10 +- readme.md | 28 +- test/fixtures/continuation.json | 118 +--- test/fixtures/footnote-calls.json | 96 +--- test/fixtures/footnote-definitions.json | 236 +++----- test/fixtures/footnotes-pandoc.json | 78 +-- test/fixtures/inline-notes-pandoc.json | 21 +- test/fixtures/inline-notes.json | 326 +++-------- test/fixtures/interrupt.json | 143 ++--- test/fixtures/many-blank-lines-no-indent.json | 97 +--- test/fixtures/many-blank-lines.json | 104 +--- test/fixtures/nest.json | 57 +- .../normal-blank-lines-no-indent.json | 95 +--- test/fixtures/normal-blank-lines.json | 98 +--- test/index.js | 173 +++--- 16 files changed, 524 insertions(+), 1678 deletions(-) diff --git a/index.js b/index.js index 8b0621f..04c0ffd 100644 --- a/index.js +++ b/index.js @@ -1,498 +1,38 @@ 'use strict' -module.exports = footnotes - -var tab = 9 // '\t' -var lineFeed = 10 // '\n' -var space = 32 -var exclamationMark = 33 // '!' -var colon = 58 // ':' -var leftSquareBracket = 91 // '[' -var backslash = 92 // '\' -var rightSquareBracket = 93 // ']' -var caret = 94 // '^' -var graveAccent = 96 // '`' +var syntax = require('micromark-extension-footnote') +var fromMarkdown = require('mdast-util-footnote/from-markdown') +var toMarkdown = require('mdast-util-footnote/to-markdown') +var warningIssued -var tabSize = 4 -var maxSlice = 1024 +module.exports = footnotes function footnotes(options) { - var parser = this.Parser - var compiler = this.Compiler - - if (isRemarkParser(parser)) { - attachParser(parser, options) - } - - if (isRemarkCompiler(compiler)) { - attachCompiler(compiler) - } -} - -function isRemarkParser(parser) { - return Boolean(parser && parser.prototype && parser.prototype.blockTokenizers) -} - -function isRemarkCompiler(compiler) { - return Boolean(compiler && compiler.prototype && compiler.prototype.visitors) -} - -function attachParser(parser, options) { - var settings = options || {} - var proto = parser.prototype - var blocks = proto.blockTokenizers - var spans = proto.inlineTokenizers - var blockMethods = proto.blockMethods - var inlineMethods = proto.inlineMethods - var originalDefinition = blocks.definition - var originalReference = spans.reference - var interruptors = [] - var index = -1 - var length = blockMethods.length - var method - - // Interrupt by anything except for indented code or paragraphs. - while (++index < length) { - method = blockMethods[index] - - if ( - method === 'newline' || - method === 'indentedCode' || - method === 'paragraph' || - method === 'footnoteDefinition' - ) { - continue - } - - interruptors.push([method]) - } - - interruptors.push(['footnoteDefinition']) - - // Insert tokenizers. - if (settings.inlineNotes) { - before(inlineMethods, 'reference', 'inlineNote') - spans.inlineNote = footnote - } - - before(blockMethods, 'definition', 'footnoteDefinition') - before(inlineMethods, 'reference', 'footnoteCall') - - blocks.definition = definition - blocks.footnoteDefinition = footnoteDefinition - spans.footnoteCall = footnoteCall - spans.reference = reference - - proto.interruptFootnoteDefinition = interruptors - reference.locator = originalReference.locator - footnoteCall.locator = locateFootnoteCall - footnote.locator = locateFootnote - - function footnoteDefinition(eat, value, silent) { - var self = this - var interruptors = self.interruptFootnoteDefinition - var offsets = self.offset - var length = value.length + 1 - var index = 0 - var content = [] - var label - var labelStart - var labelEnd - var code - var now - var add - var exit - var children - var start - var indent - var contentStart - var lines - var line - - // Skip initial whitespace. - while (index < length) { - code = value.charCodeAt(index) - if (code !== tab && code !== space) break - index++ - } - - // Parse `[^`. - if (value.charCodeAt(index++) !== leftSquareBracket) return - if (value.charCodeAt(index++) !== caret) return - - // Parse label. - labelStart = index - - while (index < length) { - code = value.charCodeAt(index) - - // Exit on white space. - if ( - code !== code || - code === lineFeed || - code === tab || - code === space - ) { - return - } - - if (code === rightSquareBracket) { - labelEnd = index - index++ - break - } - - index++ - } - - // Exit if we didn’t find an end, no label, or there’s no colon. - if ( - labelEnd === undefined || - labelStart === labelEnd || - value.charCodeAt(index++) !== colon - ) { - return - } - - // Found it! - /* istanbul ignore if - never used (yet) */ - if (silent) { - return true - } - - label = value.slice(labelStart, labelEnd) - - // Now, to get all lines. - now = eat.now() - start = 0 - indent = 0 - contentStart = index - lines = [] - - while (index < length) { - code = value.charCodeAt(index) - - if (code !== code || code === lineFeed) { - line = { - start: start, - contentStart: contentStart || index, - contentEnd: index, - end: index - } - - lines.push(line) - - // Prepare a new line. - if (code === lineFeed) { - start = index + 1 - indent = 0 - contentStart = undefined - - line.end = start - } - } else if (indent !== undefined) { - if (code === space || code === tab) { - indent += code === space ? 1 : tabSize - (indent % tabSize) - - if (indent > tabSize) { - indent = undefined - contentStart = index - } - } else { - // If this line is not indented and it’s either preceded by a blank - // line or starts a new block, exit. - if ( - indent < tabSize && - line && - (line.contentStart === line.contentEnd || - interrupt(interruptors, blocks, self, [ - eat, - value.slice(index, maxSlice), - true - ])) - ) { - break - } - - indent = undefined - contentStart = index - } - } - - index++ - } - - // Remove trailing lines without content. - index = -1 - length = lines.length - - while (length > 0) { - line = lines[length - 1] - - if (line.contentStart !== line.contentEnd) { - break - } - - length-- - } - - // Add all, but ignore the final line feed. - add = eat(value.slice(0, line.contentEnd)) - - // Add indent offsets and get content w/o indents. - while (++index < length) { - line = lines[index] - - offsets[now.line + index] = - (offsets[now.line + index] || 0) + (line.contentStart - line.start) - - content.push(value.slice(line.contentStart, line.end)) - } - - // Parse content. - exit = self.enterBlock() - children = self.tokenizeBlock(content.join(''), now) - exit() - - return add({ - type: 'footnoteDefinition', - identifier: label.toLowerCase(), - label: label, - children: children - }) - } - - // Parse a footnote call / footnote reference, such as `[^label]` - function footnoteCall(eat, value, silent) { - var length = value.length + 1 - var index = 0 - var label - var labelStart - var labelEnd - var code - - if (value.charCodeAt(index++) !== leftSquareBracket) return - if (value.charCodeAt(index++) !== caret) return - - labelStart = index - - while (index < length) { - code = value.charCodeAt(index) - - if ( - code !== code || - code === lineFeed || - code === tab || - code === space - ) { - return - } - - if (code === rightSquareBracket) { - labelEnd = index - index++ - break - } - - index++ - } - - if (labelEnd === undefined || labelStart === labelEnd) { - return - } - - /* istanbul ignore if - never used (yet) */ - if (silent) { - return true - } - - label = value.slice(labelStart, labelEnd) - - return eat(value.slice(0, index))({ - type: 'footnoteReference', - identifier: label.toLowerCase(), - label: label - }) - } - - // Parse an inline note / footnote, such as `^[text]` - function footnote(eat, value, silent) { - var self = this - var length = value.length + 1 - var index = 0 - var balance = 0 - var now - var code - var contentStart - var contentEnd - var fenceStart - var fenceOpenSize - var fenceCloseSize - - if (value.charCodeAt(index++) !== caret) return - if (value.charCodeAt(index++) !== leftSquareBracket) return - - contentStart = index - - while (index < length) { - code = value.charCodeAt(index) - - // EOF: - if (code !== code) { - return - } - - // If we’re not in code: - if (fenceOpenSize === undefined) { - if (code === backslash) { - index += 2 - } else if (code === leftSquareBracket) { - balance++ - index++ - } else if (code === rightSquareBracket) { - if (balance === 0) { - contentEnd = index - index++ - break - } else { - balance-- - index++ - } - } else if (code === graveAccent) { - fenceStart = index - fenceOpenSize = 1 - - while (value.charCodeAt(fenceStart + fenceOpenSize) === graveAccent) { - fenceOpenSize++ - } - - index += fenceOpenSize - } else { - index++ - } - } - // We’re in code: - else { - if (code === graveAccent) { - fenceStart = index - fenceCloseSize = 1 - - while ( - value.charCodeAt(fenceStart + fenceCloseSize) === graveAccent - ) { - fenceCloseSize++ - } - - index += fenceCloseSize - - // Found it, we’re no longer in code! - if (fenceOpenSize === fenceCloseSize) { - fenceOpenSize = undefined - } - - fenceCloseSize = undefined - } else { - index++ - } - } - } - - if (contentEnd === undefined) { - return - } - - /* istanbul ignore if - never used (yet) */ - if (silent) { - return true - } - - now = eat.now() - now.column += 2 - now.offset += 2 - - return eat(value.slice(0, index))({ - type: 'footnote', - children: self.tokenizeInline(value.slice(contentStart, contentEnd), now) - }) - } - - // Do not allow `![^` or `[^` as a normal reference, do pass all other values - // through. - function reference(eat, value, silent) { - var index = 0 - if (value.charCodeAt(index) === exclamationMark) index++ - if (value.charCodeAt(index) !== leftSquareBracket) return - if (value.charCodeAt(index + 1) === caret) return - return originalReference.call(this, eat, value, silent) - } - - // Do not allow `[^` as a normal definition, do pass all other values through. - function definition(eat, value, silent) { - var index = 0 - var code = value.charCodeAt(index) - while (code === space || code === tab) code = value.charCodeAt(++index) - if (code !== leftSquareBracket) return - if (value.charCodeAt(index + 1) === caret) return - return originalDefinition.call(this, eat, value, silent) - } - - function locateFootnoteCall(value, from) { - return value.indexOf('[', from) - } - - function locateFootnote(value, from) { - return value.indexOf('^[', from) - } -} - -function attachCompiler(compiler) { - var serializers = compiler.prototype.visitors - var indent = ' ' - - serializers.footnote = footnote - serializers.footnoteReference = footnoteReference - serializers.footnoteDefinition = footnoteDefinition - - function footnote(node) { - return '^[' + this.all(node).join('') + ']' + var data = this.data() + + /* istanbul ignore next - old remark. */ + if ( + !warningIssued && + ((this.Parser && + this.Parser.prototype && + this.Parser.prototype.blockTokenizers) || + (this.Compiler && + this.Compiler.prototype && + this.Compiler.prototype.visitors)) + ) { + warningIssued = true + console.warn( + '[remark-footnotes] Warning: please upgrade to remark 13 to use this plugin' + ) + } + + add('micromarkExtensions', syntax(options)) + add('fromMarkdownExtensions', fromMarkdown) + add('toMarkdownExtensions', toMarkdown) + + function add(field, value) { + /* istanbul ignore if - other extensions. */ + if (data[field]) data[field].push(value) + else data[field] = [value] } - - function footnoteReference(node) { - return '[^' + (node.label || node.identifier) + ']' - } - - function footnoteDefinition(node) { - var lines = this.all(node).join('\n\n').split('\n') - var index = 0 - var length = lines.length - var line - - // Indent each line, except the first, that is not empty. - while (++index < length) { - line = lines[index] - if (line === '') continue - lines[index] = indent + line - } - - return '[^' + (node.label || node.identifier) + ']: ' + lines.join('\n') - } -} - -function before(list, before, value) { - list.splice(list.indexOf(before), 0, value) -} - -// Mimics , -// but simplified for our needs. -function interrupt(list, tokenizers, ctx, parameters) { - var length = list.length - var index = -1 - - while (++index < length) { - if (tokenizers[list[index][0]].apply(ctx, parameters)) { - return true - } - } - - return false } diff --git a/package.json b/package.json index 5efc4f4..3edba59 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,10 @@ "types/index.d.ts", "index.js" ], - "dependencies": {}, + "dependencies": { + "mdast-util-footnote": "^0.1.0", + "micromark-extension-footnote": "^0.3.0" + }, "devDependencies": { "dtslint": "^4.0.0", "nyc": "^15.0.0", @@ -38,14 +41,15 @@ "rehype-format": "^3.0.0", "rehype-stringify": "^8.0.0", "remark-cli": "^8.0.0", - "remark-parse": "^8.0.0", + "remark-parse": "^9.0.0-alpha.1", "remark-preset-wooorm": "^7.0.0", "remark-rehype": "^8.0.0", - "remark-stringify": "^8.0.0", + "remark-stringify": "^9.0.0-alpha.1", "tape": "^5.0.0", "to-vfile": "^6.0.0", "unified": "^9.0.0", "unist-builder": "^2.0.0", + "unist-util-remove-position": "^3.0.0", "xo": "^0.33.0" }, "scripts": { diff --git a/readme.md b/readme.md index f4689c0..28b099f 100644 --- a/readme.md +++ b/readme.md @@ -10,6 +10,14 @@ [**remark**][remark] plugin to add support for footnotes. +## Important! + +This plugin is affected by the new parser in remark +([`micromark`](https://github.com/micromark/micromark), +see [`remarkjs/remark#536`](https://github.com/remarkjs/remark/pull/536)). +Use version 2 while you’re still on remark 12. +Use version 3 for remark 13+. + ## Install [npm][]: @@ -121,13 +129,15 @@ Plugin to add support for footnotes. ###### `options.inlineNotes` Whether to support `^[inline notes]` (`boolean`, default: `false`). +Passed to [`micromark-extension-footnote`][mm-footnote]. ###### Notes * Labels, such as `[^this]` (in a footnote reference) or `[^this]:` (in a - footnote definition) cannot contain whitespace + footnote definition) work like link references +* Footnote definitions work like lists * Image and link references cannot start with carets, so `![^this doesn’t - work][]`, and `[^neither does this][]` + work][]` ## Security @@ -137,14 +147,14 @@ scripting (XSS)][xss] attacks. ## Related -* [`remark-breaks`](https://github.com/remarkjs/remark-breaks) - — More breaks +* [`remark-gfm`](https://github.com/remarkjs/remark-gfm) + — GitHub Flavored Markdown * [`remark-frontmatter`](https://github.com/remarkjs/remark-frontmatter) - — Frontmatter (yaml, toml, and more) support + — Frontmatter (YAML, TOML, and more) +* [`remark-math`](https://github.com/remarkjs/remark-math) + — Math * [`remark-github`](https://github.com/remarkjs/remark-github) - — References to issues, PRs, comments, users, etc -* [`remark-math`](https://github.com/rokt33r/remark-math) - — Inline and block math + — Auto-link references like in GitHub issues, PRs, and comments ## Contribute @@ -209,3 +219,5 @@ abide by its terms. [rehype]: https://github.com/rehypejs/rehype [hast]: https://github.com/syntax-tree/hast + +[mm-footnote]: https://github.com/micromark/micromark-extension-footnote#optionsinlinenotes diff --git a/test/fixtures/continuation.json b/test/fixtures/continuation.json index b64a991..d22c609 100644 --- a/test/fixtures/continuation.json +++ b/test/fixtures/continuation.json @@ -18,8 +18,7 @@ "line": 1, "column": 5, "offset": 4 - }, - "indent": [] + } } }, { @@ -36,8 +35,7 @@ "line": 1, "column": 9, "offset": 8 - }, - "indent": [] + } } }, { @@ -54,8 +52,7 @@ "line": 1, "column": 13, "offset": 12 - }, - "indent": [] + } } }, { @@ -72,8 +69,7 @@ "line": 1, "column": 17, "offset": 16 - }, - "indent": [] + } } } ], @@ -87,8 +83,7 @@ "line": 1, "column": 17, "offset": 16 - }, - "indent": [] + } } }, { @@ -112,10 +107,7 @@ "line": 4, "column": 14, "offset": 47 - }, - "indent": [ - 1 - ] + } } } ], @@ -129,10 +121,7 @@ "line": 4, "column": 14, "offset": 47 - }, - "indent": [ - 1 - ] + } } } ], @@ -146,10 +135,7 @@ "line": 4, "column": 14, "offset": 47 - }, - "indent": [ - 1 - ] + } } }, { @@ -169,8 +155,7 @@ "line": 6, "column": 10, "offset": 58 - }, - "indent": [] + } } } ], @@ -184,8 +169,7 @@ "line": 6, "column": 10, "offset": 58 - }, - "indent": [] + } } }, { @@ -209,10 +193,7 @@ "line": 9, "column": 14, "offset": 89 - }, - "indent": [ - 1 - ] + } } } ], @@ -226,10 +207,7 @@ "line": 9, "column": 14, "offset": 89 - }, - "indent": [ - 1 - ] + } } }, { @@ -248,8 +226,7 @@ "line": 11, "column": 33, "offset": 123 - }, - "indent": [] + } } } ], @@ -263,8 +240,7 @@ "line": 11, "column": 33, "offset": 123 - }, - "indent": [] + } } }, { @@ -283,8 +259,7 @@ "line": 13, "column": 28, "offset": 152 - }, - "indent": [] + } } } ], @@ -298,8 +273,7 @@ "line": 13, "column": 28, "offset": 152 - }, - "indent": [] + } } } ], @@ -313,14 +287,7 @@ "line": 13, "column": 28, "offset": 152 - }, - "indent": [ - 1, - 1, - 1, - 1, - 1 - ] + } } }, { @@ -344,10 +311,7 @@ "line": 16, "column": 14, "offset": 183 - }, - "indent": [ - 1 - ] + } } } ], @@ -361,10 +325,7 @@ "line": 16, "column": 14, "offset": 183 - }, - "indent": [ - 1 - ] + } } } ], @@ -378,10 +339,7 @@ "line": 16, "column": 14, "offset": 183 - }, - "indent": [ - 1 - ] + } } }, { @@ -403,8 +361,7 @@ "line": 18, "column": 14, "offset": 198 - }, - "indent": [] + } } } ], @@ -418,8 +375,7 @@ "line": 18, "column": 14, "offset": 198 - }, - "indent": [] + } } } ], @@ -433,8 +389,7 @@ "line": 18, "column": 14, "offset": 198 - }, - "indent": [] + } } }, { @@ -458,10 +413,7 @@ "line": 21, "column": 14, "offset": 229 - }, - "indent": [ - 1 - ] + } } } ], @@ -475,10 +427,7 @@ "line": 21, "column": 14, "offset": 229 - }, - "indent": [ - 1 - ] + } } } ], @@ -492,10 +441,7 @@ "line": 21, "column": 14, "offset": 229 - }, - "indent": [ - 1 - ] + } } }, { @@ -525,8 +471,7 @@ "line": 23, "column": 7, "offset": 237 - }, - "indent": [] + } } } ], @@ -540,8 +485,7 @@ "line": 23, "column": 7, "offset": 237 - }, - "indent": [] + } } } ], @@ -555,8 +499,7 @@ "line": 23, "column": 7, "offset": 237 - }, - "indent": [] + } } } ], @@ -570,8 +513,7 @@ "line": 23, "column": 7, "offset": 237 - }, - "indent": [] + } } } ], diff --git a/test/fixtures/footnote-calls.json b/test/fixtures/footnote-calls.json index f8100f8..40e32f3 100644 --- a/test/fixtures/footnote-calls.json +++ b/test/fixtures/footnote-calls.json @@ -17,8 +17,7 @@ "line": 1, "column": 29, "offset": 28 - }, - "indent": [] + } } } ], @@ -32,8 +31,7 @@ "line": 1, "column": 29, "offset": 28 - }, - "indent": [] + } } }, { @@ -52,8 +50,7 @@ "line": 3, "column": 44, "offset": 73 - }, - "indent": [] + } } } ], @@ -67,8 +64,7 @@ "line": 3, "column": 44, "offset": 73 - }, - "indent": [] + } } }, { @@ -87,10 +83,7 @@ "line": 6, "column": 3, "offset": 132 - }, - "indent": [ - 1 - ] + } } } ], @@ -104,10 +97,7 @@ "line": 6, "column": 3, "offset": 132 - }, - "indent": [ - 1 - ] + } } }, { @@ -126,8 +116,7 @@ "line": 8, "column": 53, "offset": 186 - }, - "indent": [] + } } }, { @@ -144,8 +133,7 @@ "line": 8, "column": 66, "offset": 199 - }, - "indent": [] + } } }, { @@ -161,8 +149,7 @@ "line": 8, "column": 71, "offset": 204 - }, - "indent": [] + } } }, { @@ -179,8 +166,7 @@ "line": 8, "column": 75, "offset": 208 - }, - "indent": [] + } } }, { @@ -196,10 +182,7 @@ "line": 9, "column": 20, "offset": 228 - }, - "indent": [ - 1 - ] + } } } ], @@ -213,10 +196,7 @@ "line": 9, "column": 20, "offset": 228 - }, - "indent": [ - 1 - ] + } } }, { @@ -235,8 +215,7 @@ "line": 11, "column": 11, "offset": 240 - }, - "indent": [] + } } } ], @@ -250,8 +229,7 @@ "line": 11, "column": 11, "offset": 240 - }, - "indent": [] + } } }, { @@ -270,8 +248,7 @@ "line": 13, "column": 12, "offset": 253 - }, - "indent": [] + } } } ], @@ -285,8 +262,7 @@ "line": 13, "column": 12, "offset": 253 - }, - "indent": [] + } } }, { @@ -305,8 +281,7 @@ "line": 15, "column": 10, "offset": 264 - }, - "indent": [] + } } } ], @@ -320,8 +295,7 @@ "line": 15, "column": 10, "offset": 264 - }, - "indent": [] + } } }, { @@ -340,8 +314,7 @@ "line": 17, "column": 3, "offset": 268 - }, - "indent": [] + } } } ], @@ -355,8 +328,7 @@ "line": 17, "column": 3, "offset": 268 - }, - "indent": [] + } } }, { @@ -375,8 +347,7 @@ "line": 19, "column": 13, "offset": 282 - }, - "indent": [] + } } } ], @@ -390,14 +361,13 @@ "line": 19, "column": 13, "offset": 282 - }, - "indent": [] + } } }, { "type": "footnoteDefinition", - "label": "1234567890", "identifier": "1234567890", + "label": "1234567890", "children": [ { "type": "paragraph", @@ -415,8 +385,7 @@ "line": 21, "column": 23, "offset": 306 - }, - "indent": [] + } } } ], @@ -430,8 +399,7 @@ "line": 21, "column": 23, "offset": 306 - }, - "indent": [] + } } } ], @@ -445,14 +413,13 @@ "line": 21, "column": 23, "offset": 306 - }, - "indent": [] + } } }, { "type": "footnoteDefinition", - "label": "^", "identifier": "^", + "label": "^", "children": [ { "type": "paragraph", @@ -470,8 +437,7 @@ "line": 23, "column": 12, "offset": 319 - }, - "indent": [] + } } } ], @@ -485,8 +451,7 @@ "line": 23, "column": 12, "offset": 319 - }, - "indent": [] + } } } ], @@ -500,8 +465,7 @@ "line": 23, "column": 12, "offset": 319 - }, - "indent": [] + } } } ], diff --git a/test/fixtures/footnote-definitions.json b/test/fixtures/footnote-definitions.json index 6d514a4..5dad51d 100644 --- a/test/fixtures/footnote-definitions.json +++ b/test/fixtures/footnote-definitions.json @@ -17,8 +17,7 @@ "line": 1, "column": 6, "offset": 5 - }, - "indent": [] + } } }, { @@ -35,8 +34,7 @@ "line": 1, "column": 10, "offset": 9 - }, - "indent": [] + } } }, { @@ -53,8 +51,7 @@ "line": 1, "column": 14, "offset": 13 - }, - "indent": [] + } } }, { @@ -71,8 +68,7 @@ "line": 1, "column": 18, "offset": 17 - }, - "indent": [] + } } }, { @@ -89,8 +85,7 @@ "line": 1, "column": 22, "offset": 21 - }, - "indent": [] + } } }, { @@ -107,8 +102,7 @@ "line": 1, "column": 26, "offset": 25 - }, - "indent": [] + } } }, { @@ -125,8 +119,7 @@ "line": 1, "column": 30, "offset": 29 - }, - "indent": [] + } } }, { @@ -143,8 +136,7 @@ "line": 1, "column": 34, "offset": 33 - }, - "indent": [] + } } }, { @@ -161,8 +153,7 @@ "line": 1, "column": 38, "offset": 37 - }, - "indent": [] + } } }, { @@ -179,8 +170,7 @@ "line": 1, "column": 42, "offset": 41 - }, - "indent": [] + } } }, { @@ -197,8 +187,7 @@ "line": 1, "column": 46, "offset": 45 - }, - "indent": [] + } } }, { @@ -215,8 +204,7 @@ "line": 1, "column": 51, "offset": 50 - }, - "indent": [] + } } } ], @@ -230,8 +218,7 @@ "line": 1, "column": 51, "offset": 50 - }, - "indent": [] + } } }, { @@ -255,8 +242,7 @@ "line": 3, "column": 10, "offset": 61 - }, - "indent": [] + } } } ], @@ -270,8 +256,7 @@ "line": 3, "column": 10, "offset": 61 - }, - "indent": [] + } } } ], @@ -285,8 +270,7 @@ "line": 3, "column": 10, "offset": 61 - }, - "indent": [] + } } }, { @@ -310,8 +294,7 @@ "line": 5, "column": 16, "offset": 78 - }, - "indent": [] + } } } ], @@ -325,8 +308,7 @@ "line": 5, "column": 16, "offset": 78 - }, - "indent": [] + } } } ], @@ -340,8 +322,7 @@ "line": 5, "column": 16, "offset": 78 - }, - "indent": [] + } } }, { @@ -365,10 +346,7 @@ "line": 8, "column": 18, "offset": 108 - }, - "indent": [ - 5 - ] + } } } ], @@ -382,10 +360,7 @@ "line": 8, "column": 18, "offset": 108 - }, - "indent": [ - 5 - ] + } } } ], @@ -399,10 +374,7 @@ "line": 8, "column": 18, "offset": 108 - }, - "indent": [ - 1 - ] + } } }, { @@ -411,38 +383,21 @@ "label": "3", "children": [ { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": " not code", - "position": { - "start": { - "line": 10, - "column": 10, - "offset": 119 - }, - "end": { - "line": 10, - "column": 21, - "offset": 130 - }, - "indent": [] - } - } - ], + "type": "code", + "lang": null, + "meta": null, + "value": " not code", "position": { "start": { "line": 10, - "column": 10, - "offset": 119 + "column": 7, + "offset": 116 }, "end": { "line": 10, "column": 21, "offset": 130 - }, - "indent": [] + } } } ], @@ -456,8 +411,7 @@ "line": 10, "column": 21, "offset": 130 - }, - "indent": [] + } } }, { @@ -469,19 +423,18 @@ "type": "code", "lang": null, "meta": null, - "value": "code", + "value": " code", "position": { "start": { "line": 12, - "column": 10, - "offset": 141 + "column": 7, + "offset": 138 }, "end": { "line": 12, "column": 18, "offset": 149 - }, - "indent": [] + } } } ], @@ -495,8 +448,7 @@ "line": 12, "column": 18, "offset": 149 - }, - "indent": [] + } } }, { @@ -523,8 +475,7 @@ "line": 14, "column": 19, "offset": 169 - }, - "indent": [] + } } } ], @@ -538,8 +489,7 @@ "line": 14, "column": 19, "offset": 169 - }, - "indent": [] + } } } ], @@ -553,8 +503,7 @@ "line": 14, "column": 19, "offset": 169 - }, - "indent": [] + } } } ], @@ -568,8 +517,7 @@ "line": 14, "column": 19, "offset": 169 - }, - "indent": [] + } } }, { @@ -578,56 +526,21 @@ "label": "6", "children": [ { - "type": "blockquote", - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "block quote", - "position": { - "start": { - "line": 16, - "column": 15, - "offset": 185 - }, - "end": { - "line": 16, - "column": 26, - "offset": 196 - }, - "indent": [] - } - } - ], - "position": { - "start": { - "line": 16, - "column": 15, - "offset": 185 - }, - "end": { - "line": 16, - "column": 26, - "offset": 196 - }, - "indent": [] - } - } - ], + "type": "code", + "lang": null, + "meta": null, + "value": " > block quote", "position": { "start": { "line": 16, - "column": 10, - "offset": 180 + "column": 7, + "offset": 177 }, "end": { "line": 16, "column": 26, "offset": 196 - }, - "indent": [] + } } } ], @@ -641,8 +554,7 @@ "line": 16, "column": 26, "offset": 196 - }, - "indent": [] + } } }, { @@ -654,19 +566,18 @@ "type": "code", "lang": null, "meta": null, - "value": "> code", + "value": " > code", "position": { "start": { "line": 18, - "column": 10, - "offset": 207 + "column": 7, + "offset": 204 }, "end": { "line": 18, "column": 20, "offset": 217 - }, - "indent": [] + } } } ], @@ -680,8 +591,7 @@ "line": 18, "column": 20, "offset": 217 - }, - "indent": [] + } } }, { @@ -706,8 +616,7 @@ "line": 20, "column": 89, "offset": 307 - }, - "indent": [] + } } } ], @@ -721,8 +630,7 @@ "line": 20, "column": 89, "offset": 307 - }, - "indent": [] + } } } ], @@ -736,8 +644,7 @@ "line": 20, "column": 89, "offset": 307 - }, - "indent": [] + } } }, { @@ -757,8 +664,7 @@ "line": 22, "column": 9, "offset": 317 - }, - "indent": [] + } } } ], @@ -772,8 +678,7 @@ "line": 22, "column": 9, "offset": 317 - }, - "indent": [] + } } }, { @@ -830,8 +735,7 @@ "line": 24, "column": 19, "offset": 337 - }, - "indent": [] + } } } ], @@ -845,8 +749,7 @@ "line": 24, "column": 19, "offset": 337 - }, - "indent": [] + } } } ], @@ -860,8 +763,7 @@ "line": 24, "column": 19, "offset": 337 - }, - "indent": [] + } } } ], @@ -875,8 +777,7 @@ "line": 24, "column": 19, "offset": 337 - }, - "indent": [] + } } } ], @@ -890,8 +791,7 @@ "line": 24, "column": 19, "offset": 337 - }, - "indent": [] + } } } ], @@ -905,8 +805,7 @@ "line": 24, "column": 19, "offset": 337 - }, - "indent": [] + } } } ], @@ -920,8 +819,7 @@ "line": 24, "column": 19, "offset": 337 - }, - "indent": [] + } } } ], @@ -935,8 +833,7 @@ "line": 24, "column": 19, "offset": 337 - }, - "indent": [] + } } } ], @@ -950,8 +847,7 @@ "line": 24, "column": 19, "offset": 337 - }, - "indent": [] + } } } ], diff --git a/test/fixtures/footnotes-pandoc.json b/test/fixtures/footnotes-pandoc.json index 6c71373..49ebd04 100644 --- a/test/fixtures/footnotes-pandoc.json +++ b/test/fixtures/footnotes-pandoc.json @@ -17,8 +17,7 @@ "line": 1, "column": 30, "offset": 29 - }, - "indent": [] + } } }, { @@ -35,8 +34,7 @@ "line": 1, "column": 34, "offset": 33 - }, - "indent": [] + } } }, { @@ -52,8 +50,7 @@ "line": 1, "column": 47, "offset": 46 - }, - "indent": [] + } } }, { @@ -70,8 +67,7 @@ "line": 1, "column": 58, "offset": 57 - }, - "indent": [] + } } } ], @@ -85,8 +81,7 @@ "line": 1, "column": 58, "offset": 57 - }, - "indent": [] + } } }, { @@ -110,8 +105,7 @@ "line": 3, "column": 28, "offset": 86 - }, - "indent": [] + } } } ], @@ -125,8 +119,7 @@ "line": 3, "column": 28, "offset": 86 - }, - "indent": [] + } } } ], @@ -140,8 +133,7 @@ "line": 3, "column": 28, "offset": 86 - }, - "indent": [] + } } }, { @@ -165,8 +157,7 @@ "line": 5, "column": 46, "offset": 133 - }, - "indent": [] + } } } ], @@ -180,8 +171,7 @@ "line": 5, "column": 46, "offset": 133 - }, - "indent": [] + } } }, { @@ -200,10 +190,7 @@ "line": 8, "column": 33, "offset": 224 - }, - "indent": [ - 1 - ] + } } } ], @@ -217,10 +204,7 @@ "line": 8, "column": 33, "offset": 224 - }, - "indent": [ - 1 - ] + } } }, { @@ -238,8 +222,7 @@ "line": 10, "column": 22, "offset": 247 - }, - "indent": [] + } } }, { @@ -258,11 +241,7 @@ "line": 14, "column": 32, "offset": 399 - }, - "indent": [ - 5, - 5 - ] + } } } ], @@ -276,11 +255,7 @@ "line": 14, "column": 32, "offset": 399 - }, - "indent": [ - 5, - 5 - ] + } } } ], @@ -294,18 +269,7 @@ "line": 14, "column": 32, "offset": 399 - }, - "indent": [ - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1 - ] + } } }, { @@ -324,10 +288,7 @@ "line": 17, "column": 16, "offset": 469 - }, - "indent": [ - 1 - ] + } } } ], @@ -341,10 +302,7 @@ "line": 17, "column": 16, "offset": 469 - }, - "indent": [ - 1 - ] + } } } ], diff --git a/test/fixtures/inline-notes-pandoc.json b/test/fixtures/inline-notes-pandoc.json index 7cf55f6..aca24c3 100644 --- a/test/fixtures/inline-notes-pandoc.json +++ b/test/fixtures/inline-notes-pandoc.json @@ -17,8 +17,7 @@ "line": 1, "column": 24, "offset": 23 - }, - "indent": [] + } } }, { @@ -37,11 +36,7 @@ "line": 3, "column": 6, "offset": 134 - }, - "indent": [ - 1, - 1 - ] + } } } ], @@ -55,11 +50,7 @@ "line": 3, "column": 7, "offset": 135 - }, - "indent": [ - 1, - 1 - ] + } } } ], @@ -73,11 +64,7 @@ "line": 3, "column": 7, "offset": 135 - }, - "indent": [ - 1, - 1 - ] + } } } ], diff --git a/test/fixtures/inline-notes.json b/test/fixtures/inline-notes.json index c00e315..57bfa26 100644 --- a/test/fixtures/inline-notes.json +++ b/test/fixtures/inline-notes.json @@ -17,8 +17,7 @@ "line": 1, "column": 24, "offset": 23 - }, - "indent": [] + } } }, { @@ -37,11 +36,7 @@ "line": 3, "column": 6, "offset": 134 - }, - "indent": [ - 1, - 1 - ] + } } } ], @@ -55,11 +50,7 @@ "line": 3, "column": 7, "offset": 135 - }, - "indent": [ - 1, - 1 - ] + } } } ], @@ -73,11 +64,7 @@ "line": 3, "column": 7, "offset": 135 - }, - "indent": [ - 1, - 1 - ] + } } }, { @@ -96,8 +83,7 @@ "line": 5, "column": 7, "offset": 143 - }, - "indent": [] + } } }, { @@ -105,7 +91,7 @@ "children": [ { "type": "text", - "value": "one ", + "value": "one [balanced", "position": { "start": { "line": 5, @@ -114,65 +100,9 @@ }, "end": { "line": 5, - "column": 13, - "offset": 149 - }, - "indent": [] - } - }, - { - "type": "linkReference", - "identifier": "balanced", - "label": "balanced", - "referenceType": "shortcut", - "children": [ - { - "type": "text", - "value": "balanced", - "position": { - "start": { - "line": 5, - "column": 14, - "offset": 150 - }, - "end": { - "line": 5, - "column": 22, - "offset": 158 - }, - "indent": [] - } + "column": 22, + "offset": 158 } - ], - "position": { - "start": { - "line": 5, - "column": 13, - "offset": 149 - }, - "end": { - "line": 5, - "column": 23, - "offset": 159 - }, - "indent": [] - } - }, - { - "type": "text", - "value": " three", - "position": { - "start": { - "line": 5, - "column": 23, - "offset": 159 - }, - "end": { - "line": 5, - "column": 29, - "offset": 165 - }, - "indent": [] } } ], @@ -184,27 +114,25 @@ }, "end": { "line": 5, - "column": 30, - "offset": 166 - }, - "indent": [] + "column": 23, + "offset": 159 + } } }, { "type": "text", - "value": " bravo.", + "value": " three] bravo.", "position": { "start": { "line": 5, - "column": 30, - "offset": 166 + "column": 23, + "offset": 159 }, "end": { "line": 5, "column": 37, "offset": 173 - }, - "indent": [] + } } } ], @@ -218,8 +146,7 @@ "line": 5, "column": 37, "offset": 173 - }, - "indent": [] + } } }, { @@ -227,7 +154,7 @@ "children": [ { "type": "text", - "value": "alpha ^[four ", + "value": "alpha ", "position": { "start": { "line": 7, @@ -236,48 +163,42 @@ }, "end": { "line": 7, - "column": 14, - "offset": 188 - }, - "indent": [] + "column": 7, + "offset": 181 + } } }, { - "type": "linkReference", - "identifier": "unbalanced five", - "label": "unbalanced five", - "referenceType": "shortcut", + "type": "footnote", "children": [ { "type": "text", - "value": "unbalanced five", + "value": "four [unbalanced five", "position": { "start": { "line": 7, - "column": 15, - "offset": 189 + "column": 9, + "offset": 183 }, "end": { "line": 7, "column": 30, "offset": 204 - }, - "indent": [] + } } } ], "position": { "start": { "line": 7, - "column": 14, - "offset": 188 + "column": 7, + "offset": 181 }, "end": { "line": 7, "column": 31, "offset": 205 - }, - "indent": [] + } } }, { @@ -293,8 +214,7 @@ "line": 7, "column": 38, "offset": 212 - }, - "indent": [] + } } } ], @@ -308,8 +228,7 @@ "line": 7, "column": 38, "offset": 212 - }, - "indent": [] + } } }, { @@ -328,8 +247,7 @@ "line": 9, "column": 7, "offset": 220 - }, - "indent": [] + } } }, { @@ -348,8 +266,7 @@ "line": 9, "column": 23, "offset": 236 - }, - "indent": [] + } } } ], @@ -363,8 +280,7 @@ "line": 9, "column": 24, "offset": 237 - }, - "indent": [] + } } }, { @@ -380,8 +296,7 @@ "line": 9, "column": 38, "offset": 251 - }, - "indent": [] + } } } ], @@ -395,8 +310,7 @@ "line": 9, "column": 38, "offset": 251 - }, - "indent": [] + } } }, { @@ -415,8 +329,7 @@ "line": 11, "column": 7, "offset": 259 - }, - "indent": [] + } } }, { @@ -424,53 +337,18 @@ "children": [ { "type": "text", - "value": "eight escaped", + "value": "eight escaped] nine", "position": { "start": { "line": 11, "column": 9, "offset": 261 }, - "end": { - "line": 11, - "column": 22, - "offset": 274 - }, - "indent": [] - } - }, - { - "type": "text", - "value": "]", - "position": { - "start": { - "line": 11, - "column": 22, - "offset": 274 - }, - "end": { - "line": 11, - "column": 24, - "offset": 276 - }, - "indent": [] - } - }, - { - "type": "text", - "value": " nine", - "position": { - "start": { - "line": 11, - "column": 24, - "offset": 276 - }, "end": { "line": 11, "column": 29, "offset": 281 - }, - "indent": [] + } } } ], @@ -484,8 +362,7 @@ "line": 11, "column": 30, "offset": 282 - }, - "indent": [] + } } }, { @@ -501,8 +378,7 @@ "line": 11, "column": 37, "offset": 289 - }, - "indent": [] + } } } ], @@ -516,8 +392,7 @@ "line": 11, "column": 37, "offset": 289 - }, - "indent": [] + } } }, { @@ -536,8 +411,7 @@ "line": 13, "column": 7, "offset": 297 - }, - "indent": [] + } } }, { @@ -553,8 +427,7 @@ "line": 13, "column": 10, "offset": 300 - }, - "indent": [] + } } }, { @@ -570,8 +443,7 @@ "line": 13, "column": 17, "offset": 307 - }, - "indent": [] + } } } ], @@ -585,8 +457,7 @@ "line": 13, "column": 17, "offset": 307 - }, - "indent": [] + } } }, { @@ -605,8 +476,7 @@ "line": 15, "column": 31, "offset": 339 - }, - "indent": [] + } } } ], @@ -620,8 +490,7 @@ "line": 15, "column": 31, "offset": 339 - }, - "indent": [] + } } }, { @@ -640,8 +509,7 @@ "line": 17, "column": 18, "offset": 358 - }, - "indent": [] + } } }, { @@ -660,8 +528,7 @@ "line": 17, "column": 24, "offset": 364 - }, - "indent": [] + } } }, { @@ -677,8 +544,7 @@ "line": 17, "column": 48, "offset": 388 - }, - "indent": [] + } } }, { @@ -694,8 +560,7 @@ "line": 17, "column": 54, "offset": 394 - }, - "indent": [] + } } } ], @@ -709,8 +574,7 @@ "line": 17, "column": 55, "offset": 395 - }, - "indent": [] + } } }, { @@ -726,8 +590,7 @@ "line": 17, "column": 62, "offset": 402 - }, - "indent": [] + } } } ], @@ -741,8 +604,7 @@ "line": 17, "column": 62, "offset": 402 - }, - "indent": [] + } } }, { @@ -761,8 +623,7 @@ "line": 19, "column": 18, "offset": 421 - }, - "indent": [] + } } }, { @@ -781,8 +642,7 @@ "line": 19, "column": 24, "offset": 427 - }, - "indent": [] + } } }, { @@ -798,8 +658,7 @@ "line": 19, "column": 41, "offset": 444 - }, - "indent": [] + } } }, { @@ -815,8 +674,7 @@ "line": 19, "column": 47, "offset": 450 - }, - "indent": [] + } } } ], @@ -830,8 +688,7 @@ "line": 19, "column": 48, "offset": 451 - }, - "indent": [] + } } }, { @@ -847,8 +704,7 @@ "line": 19, "column": 55, "offset": 458 - }, - "indent": [] + } } } ], @@ -862,8 +718,7 @@ "line": 19, "column": 55, "offset": 458 - }, - "indent": [] + } } }, { @@ -871,7 +726,7 @@ "children": [ { "type": "text", - "value": "mixed ^", + "value": "mixed ^[ with ", "position": { "start": { "line": 21, @@ -880,65 +735,25 @@ }, "end": { "line": 21, - "column": 8, - "offset": 467 - }, - "indent": [] - } - }, - { - "type": "linkReference", - "identifier": " with `code", - "label": " with `code", - "referenceType": "shortcut", - "children": [ - { - "type": "text", - "value": " with `code", - "position": { - "start": { - "line": 21, - "column": 9, - "offset": 468 - }, - "end": { - "line": 21, - "column": 20, - "offset": 479 - }, - "indent": [] - } + "column": 15, + "offset": 474 } - ], - "position": { - "start": { - "line": 21, - "column": 8, - "offset": 467 - }, - "end": { - "line": 21, - "column": 21, - "offset": 480 - }, - "indent": [] } }, { - "type": "text", - "value": "`", + "type": "inlineCode", + "value": "code]", "position": { "start": { "line": 21, - "column": 21, - "offset": 480 + "column": 15, + "offset": 474 }, "end": { "line": 21, "column": 22, "offset": 481 - }, - "indent": [] + } } } ], @@ -952,8 +767,7 @@ "line": 21, "column": 22, "offset": 481 - }, - "indent": [] + } } } ], diff --git a/test/fixtures/interrupt.json b/test/fixtures/interrupt.json index 5799603..bcc317e 100644 --- a/test/fixtures/interrupt.json +++ b/test/fixtures/interrupt.json @@ -18,8 +18,7 @@ "line": 1, "column": 5, "offset": 4 - }, - "indent": [] + } } }, { @@ -36,8 +35,7 @@ "line": 1, "column": 9, "offset": 8 - }, - "indent": [] + } } }, { @@ -54,8 +52,7 @@ "line": 1, "column": 13, "offset": 12 - }, - "indent": [] + } } }, { @@ -72,8 +69,7 @@ "line": 1, "column": 17, "offset": 16 - }, - "indent": [] + } } }, { @@ -90,8 +86,7 @@ "line": 1, "column": 21, "offset": 20 - }, - "indent": [] + } } }, { @@ -108,8 +103,7 @@ "line": 1, "column": 25, "offset": 24 - }, - "indent": [] + } } } ], @@ -123,8 +117,7 @@ "line": 1, "column": 25, "offset": 24 - }, - "indent": [] + } } }, { @@ -148,10 +141,7 @@ "line": 4, "column": 14, "offset": 55 - }, - "indent": [ - 1 - ] + } } } ], @@ -165,10 +155,7 @@ "line": 4, "column": 14, "offset": 55 - }, - "indent": [ - 1 - ] + } } } ], @@ -182,10 +169,7 @@ "line": 4, "column": 14, "offset": 55 - }, - "indent": [ - 1 - ] + } } }, { @@ -209,8 +193,7 @@ "line": 5, "column": 14, "offset": 69 - }, - "indent": [] + } } } ], @@ -224,8 +207,7 @@ "line": 5, "column": 14, "offset": 69 - }, - "indent": [] + } } } ], @@ -239,8 +221,7 @@ "line": 5, "column": 14, "offset": 69 - }, - "indent": [] + } } }, { @@ -264,10 +245,7 @@ "line": 8, "column": 14, "offset": 100 - }, - "indent": [ - 1 - ] + } } } ], @@ -281,10 +259,7 @@ "line": 8, "column": 14, "offset": 100 - }, - "indent": [ - 1 - ] + } } } ], @@ -298,10 +273,7 @@ "line": 8, "column": 14, "offset": 100 - }, - "indent": [ - 1 - ] + } } }, { @@ -321,8 +293,7 @@ "line": 9, "column": 10, "offset": 110 - }, - "indent": [] + } } } ], @@ -336,8 +307,7 @@ "line": 9, "column": 10, "offset": 110 - }, - "indent": [] + } } }, { @@ -361,11 +331,7 @@ "line": 13, "column": 33, "offset": 174 - }, - "indent": [ - 1, - 5 - ] + } } } ], @@ -379,11 +345,7 @@ "line": 13, "column": 33, "offset": 174 - }, - "indent": [ - 1, - 5 - ] + } } }, { @@ -402,8 +364,7 @@ "line": 15, "column": 28, "offset": 203 - }, - "indent": [] + } } } ], @@ -417,8 +378,7 @@ "line": 15, "column": 28, "offset": 203 - }, - "indent": [] + } } } ], @@ -432,13 +392,7 @@ "line": 15, "column": 28, "offset": 203 - }, - "indent": [ - 1, - 1, - 1, - 1 - ] + } } }, { @@ -462,10 +416,7 @@ "line": 18, "column": 14, "offset": 234 - }, - "indent": [ - 1 - ] + } } } ], @@ -479,10 +430,7 @@ "line": 18, "column": 14, "offset": 234 - }, - "indent": [ - 1 - ] + } } } ], @@ -496,10 +444,7 @@ "line": 18, "column": 14, "offset": 234 - }, - "indent": [ - 1 - ] + } } }, { @@ -521,8 +466,7 @@ "line": 19, "column": 14, "offset": 248 - }, - "indent": [] + } } } ], @@ -536,8 +480,7 @@ "line": 19, "column": 14, "offset": 248 - }, - "indent": [] + } } } ], @@ -551,8 +494,7 @@ "line": 19, "column": 14, "offset": 248 - }, - "indent": [] + } } }, { @@ -576,10 +518,7 @@ "line": 22, "column": 14, "offset": 279 - }, - "indent": [ - 1 - ] + } } } ], @@ -593,10 +532,7 @@ "line": 22, "column": 14, "offset": 279 - }, - "indent": [ - 1 - ] + } } } ], @@ -610,10 +546,7 @@ "line": 22, "column": 14, "offset": 279 - }, - "indent": [ - 1 - ] + } } }, { @@ -643,8 +576,7 @@ "line": 23, "column": 7, "offset": 286 - }, - "indent": [] + } } } ], @@ -658,8 +590,7 @@ "line": 23, "column": 7, "offset": 286 - }, - "indent": [] + } } } ], @@ -673,8 +604,7 @@ "line": 23, "column": 7, "offset": 286 - }, - "indent": [] + } } } ], @@ -688,8 +618,7 @@ "line": 23, "column": 7, "offset": 286 - }, - "indent": [] + } } } ], diff --git a/test/fixtures/many-blank-lines-no-indent.json b/test/fixtures/many-blank-lines-no-indent.json index ba8fd6a..af5be44 100644 --- a/test/fixtures/many-blank-lines-no-indent.json +++ b/test/fixtures/many-blank-lines-no-indent.json @@ -18,8 +18,7 @@ "line": 1, "column": 5, "offset": 4 - }, - "indent": [] + } } }, { @@ -36,8 +35,7 @@ "line": 1, "column": 9, "offset": 8 - }, - "indent": [] + } } }, { @@ -54,8 +52,7 @@ "line": 1, "column": 13, "offset": 12 - }, - "indent": [] + } } }, { @@ -72,8 +69,7 @@ "line": 1, "column": 17, "offset": 16 - }, - "indent": [] + } } } ], @@ -87,8 +83,7 @@ "line": 1, "column": 17, "offset": 16 - }, - "indent": [] + } } }, { @@ -112,8 +107,7 @@ "line": 3, "column": 16, "offset": 33 - }, - "indent": [] + } } } ], @@ -127,8 +121,7 @@ "line": 3, "column": 16, "offset": 33 - }, - "indent": [] + } } } ], @@ -142,8 +135,7 @@ "line": 3, "column": 16, "offset": 33 - }, - "indent": [] + } } }, { @@ -163,8 +155,7 @@ "line": 6, "column": 10, "offset": 45 - }, - "indent": [] + } } } ], @@ -178,8 +169,7 @@ "line": 6, "column": 10, "offset": 45 - }, - "indent": [] + } } }, { @@ -203,8 +193,7 @@ "line": 9, "column": 16, "offset": 63 - }, - "indent": [] + } } } ], @@ -218,8 +207,7 @@ "line": 9, "column": 16, "offset": 63 - }, - "indent": [] + } } }, { @@ -238,8 +226,7 @@ "line": 12, "column": 33, "offset": 98 - }, - "indent": [] + } } } ], @@ -253,8 +240,7 @@ "line": 12, "column": 33, "offset": 98 - }, - "indent": [] + } } }, { @@ -273,8 +259,7 @@ "line": 15, "column": 28, "offset": 128 - }, - "indent": [] + } } } ], @@ -288,8 +273,7 @@ "line": 15, "column": 28, "offset": 128 - }, - "indent": [] + } } } ], @@ -303,15 +287,7 @@ "line": 15, "column": 28, "offset": 128 - }, - "indent": [ - 1, - 1, - 1, - 1, - 1, - 1 - ] + } } }, { @@ -335,8 +311,7 @@ "line": 18, "column": 16, "offset": 146 - }, - "indent": [] + } } } ], @@ -350,8 +325,7 @@ "line": 18, "column": 16, "offset": 146 - }, - "indent": [] + } } } ], @@ -365,8 +339,7 @@ "line": 18, "column": 16, "offset": 146 - }, - "indent": [] + } } }, { @@ -388,8 +361,7 @@ "line": 21, "column": 14, "offset": 162 - }, - "indent": [] + } } } ], @@ -403,8 +375,7 @@ "line": 21, "column": 14, "offset": 162 - }, - "indent": [] + } } } ], @@ -418,8 +389,7 @@ "line": 21, "column": 14, "offset": 162 - }, - "indent": [] + } } }, { @@ -443,8 +413,7 @@ "line": 24, "column": 16, "offset": 180 - }, - "indent": [] + } } } ], @@ -458,8 +427,7 @@ "line": 24, "column": 16, "offset": 180 - }, - "indent": [] + } } } ], @@ -473,8 +441,7 @@ "line": 24, "column": 16, "offset": 180 - }, - "indent": [] + } } }, { @@ -504,8 +471,7 @@ "line": 27, "column": 7, "offset": 189 - }, - "indent": [] + } } } ], @@ -519,8 +485,7 @@ "line": 27, "column": 7, "offset": 189 - }, - "indent": [] + } } } ], @@ -534,8 +499,7 @@ "line": 27, "column": 7, "offset": 189 - }, - "indent": [] + } } } ], @@ -549,8 +513,7 @@ "line": 27, "column": 7, "offset": 189 - }, - "indent": [] + } } } ], diff --git a/test/fixtures/many-blank-lines.json b/test/fixtures/many-blank-lines.json index eb794f2..0e9d676 100644 --- a/test/fixtures/many-blank-lines.json +++ b/test/fixtures/many-blank-lines.json @@ -18,8 +18,7 @@ "line": 1, "column": 5, "offset": 4 - }, - "indent": [] + } } }, { @@ -36,8 +35,7 @@ "line": 1, "column": 9, "offset": 8 - }, - "indent": [] + } } }, { @@ -54,8 +52,7 @@ "line": 1, "column": 13, "offset": 12 - }, - "indent": [] + } } }, { @@ -72,8 +69,7 @@ "line": 1, "column": 17, "offset": 16 - }, - "indent": [] + } } } ], @@ -87,8 +83,7 @@ "line": 1, "column": 17, "offset": 16 - }, - "indent": [] + } } }, { @@ -112,8 +107,7 @@ "line": 3, "column": 16, "offset": 33 - }, - "indent": [] + } } } ], @@ -127,8 +121,7 @@ "line": 3, "column": 16, "offset": 33 - }, - "indent": [] + } } }, { @@ -148,8 +141,7 @@ "line": 6, "column": 14, "offset": 49 - }, - "indent": [] + } } } ], @@ -163,8 +155,7 @@ "line": 6, "column": 14, "offset": 49 - }, - "indent": [] + } } } ], @@ -178,12 +169,7 @@ "line": 6, "column": 14, "offset": 49 - }, - "indent": [ - 1, - 1, - 1 - ] + } } }, { @@ -207,8 +193,7 @@ "line": 9, "column": 16, "offset": 67 - }, - "indent": [] + } } } ], @@ -222,8 +207,7 @@ "line": 9, "column": 16, "offset": 67 - }, - "indent": [] + } } }, { @@ -241,12 +225,7 @@ "line": 15, "column": 18, "offset": 102 - }, - "indent": [ - 1, - 1, - 5 - ] + } } } ], @@ -260,15 +239,7 @@ "line": 15, "column": 18, "offset": 102 - }, - "indent": [ - 1, - 1, - 1, - 1, - 1, - 1 - ] + } } }, { @@ -292,8 +263,7 @@ "line": 18, "column": 16, "offset": 120 - }, - "indent": [] + } } } ], @@ -307,8 +277,7 @@ "line": 18, "column": 16, "offset": 120 - }, - "indent": [] + } } }, { @@ -330,8 +299,7 @@ "line": 21, "column": 18, "offset": 140 - }, - "indent": [] + } } } ], @@ -345,8 +313,7 @@ "line": 21, "column": 18, "offset": 140 - }, - "indent": [] + } } } ], @@ -360,8 +327,7 @@ "line": 21, "column": 18, "offset": 140 - }, - "indent": [] + } } } ], @@ -375,12 +341,7 @@ "line": 21, "column": 18, "offset": 140 - }, - "indent": [ - 1, - 1, - 1 - ] + } } }, { @@ -404,8 +365,7 @@ "line": 24, "column": 16, "offset": 158 - }, - "indent": [] + } } } ], @@ -419,8 +379,7 @@ "line": 24, "column": 16, "offset": 158 - }, - "indent": [] + } } }, { @@ -450,8 +409,7 @@ "line": 27, "column": 11, "offset": 171 - }, - "indent": [] + } } } ], @@ -465,8 +423,7 @@ "line": 27, "column": 11, "offset": 171 - }, - "indent": [] + } } } ], @@ -480,8 +437,7 @@ "line": 27, "column": 11, "offset": 171 - }, - "indent": [] + } } } ], @@ -495,8 +451,7 @@ "line": 27, "column": 11, "offset": 171 - }, - "indent": [] + } } } ], @@ -510,12 +465,7 @@ "line": 27, "column": 11, "offset": 171 - }, - "indent": [ - 1, - 1, - 1 - ] + } } } ], diff --git a/test/fixtures/nest.json b/test/fixtures/nest.json index 86585d1..c4751ae 100644 --- a/test/fixtures/nest.json +++ b/test/fixtures/nest.json @@ -17,8 +17,7 @@ "line": 1, "column": 6, "offset": 5 - }, - "indent": [] + } } }, { @@ -35,8 +34,7 @@ "line": 1, "column": 10, "offset": 9 - }, - "indent": [] + } } }, { @@ -53,8 +51,7 @@ "line": 1, "column": 14, "offset": 13 - }, - "indent": [] + } } }, { @@ -71,8 +68,7 @@ "line": 1, "column": 18, "offset": 17 - }, - "indent": [] + } } }, { @@ -89,8 +85,7 @@ "line": 1, "column": 22, "offset": 21 - }, - "indent": [] + } } } ], @@ -104,8 +99,7 @@ "line": 1, "column": 22, "offset": 21 - }, - "indent": [] + } } }, { @@ -140,8 +134,7 @@ "line": 3, "column": 18, "offset": 40 - }, - "indent": [] + } } } ], @@ -155,8 +148,7 @@ "line": 3, "column": 18, "offset": 40 - }, - "indent": [] + } } } ], @@ -170,8 +162,7 @@ "line": 3, "column": 18, "offset": 40 - }, - "indent": [] + } } } ], @@ -185,8 +176,7 @@ "line": 3, "column": 18, "offset": 40 - }, - "indent": [] + } } } ], @@ -200,8 +190,7 @@ "line": 3, "column": 18, "offset": 40 - }, - "indent": [] + } } }, { @@ -228,8 +217,7 @@ "line": 5, "column": 18, "offset": 59 - }, - "indent": [] + } } } ], @@ -243,8 +231,7 @@ "line": 5, "column": 18, "offset": 59 - }, - "indent": [] + } } } ], @@ -258,8 +245,7 @@ "line": 5, "column": 18, "offset": 59 - }, - "indent": [] + } } } ], @@ -273,8 +259,7 @@ "line": 5, "column": 18, "offset": 59 - }, - "indent": [] + } } }, { @@ -303,8 +288,7 @@ "line": 7, "column": 22, "offset": 82 - }, - "indent": [] + } } } ], @@ -318,8 +302,7 @@ "line": 7, "column": 22, "offset": 82 - }, - "indent": [] + } } } ], @@ -333,8 +316,7 @@ "line": 7, "column": 22, "offset": 82 - }, - "indent": [] + } } } ], @@ -348,8 +330,7 @@ "line": 7, "column": 22, "offset": 82 - }, - "indent": [] + } } } ], diff --git a/test/fixtures/normal-blank-lines-no-indent.json b/test/fixtures/normal-blank-lines-no-indent.json index 2fcff29..23beff8 100644 --- a/test/fixtures/normal-blank-lines-no-indent.json +++ b/test/fixtures/normal-blank-lines-no-indent.json @@ -18,8 +18,7 @@ "line": 1, "column": 5, "offset": 4 - }, - "indent": [] + } } }, { @@ -36,8 +35,7 @@ "line": 1, "column": 9, "offset": 8 - }, - "indent": [] + } } }, { @@ -54,8 +52,7 @@ "line": 1, "column": 13, "offset": 12 - }, - "indent": [] + } } }, { @@ -72,8 +69,7 @@ "line": 1, "column": 17, "offset": 16 - }, - "indent": [] + } } } ], @@ -87,8 +83,7 @@ "line": 1, "column": 17, "offset": 16 - }, - "indent": [] + } } }, { @@ -112,8 +107,7 @@ "line": 3, "column": 16, "offset": 33 - }, - "indent": [] + } } } ], @@ -127,8 +121,7 @@ "line": 3, "column": 16, "offset": 33 - }, - "indent": [] + } } } ], @@ -142,8 +135,7 @@ "line": 3, "column": 16, "offset": 33 - }, - "indent": [] + } } }, { @@ -163,8 +155,7 @@ "line": 5, "column": 10, "offset": 44 - }, - "indent": [] + } } } ], @@ -178,8 +169,7 @@ "line": 5, "column": 10, "offset": 44 - }, - "indent": [] + } } }, { @@ -203,8 +193,7 @@ "line": 7, "column": 16, "offset": 61 - }, - "indent": [] + } } } ], @@ -218,8 +207,7 @@ "line": 7, "column": 16, "offset": 61 - }, - "indent": [] + } } }, { @@ -238,8 +226,7 @@ "line": 9, "column": 33, "offset": 95 - }, - "indent": [] + } } } ], @@ -253,8 +240,7 @@ "line": 9, "column": 33, "offset": 95 - }, - "indent": [] + } } }, { @@ -273,8 +259,7 @@ "line": 11, "column": 28, "offset": 124 - }, - "indent": [] + } } } ], @@ -288,8 +273,7 @@ "line": 11, "column": 28, "offset": 124 - }, - "indent": [] + } } } ], @@ -303,13 +287,7 @@ "line": 11, "column": 28, "offset": 124 - }, - "indent": [ - 1, - 1, - 1, - 1 - ] + } } }, { @@ -333,8 +311,7 @@ "line": 13, "column": 16, "offset": 141 - }, - "indent": [] + } } } ], @@ -348,8 +325,7 @@ "line": 13, "column": 16, "offset": 141 - }, - "indent": [] + } } } ], @@ -363,8 +339,7 @@ "line": 13, "column": 16, "offset": 141 - }, - "indent": [] + } } }, { @@ -386,8 +361,7 @@ "line": 15, "column": 14, "offset": 156 - }, - "indent": [] + } } } ], @@ -401,8 +375,7 @@ "line": 15, "column": 14, "offset": 156 - }, - "indent": [] + } } } ], @@ -416,8 +389,7 @@ "line": 15, "column": 14, "offset": 156 - }, - "indent": [] + } } }, { @@ -441,8 +413,7 @@ "line": 17, "column": 16, "offset": 173 - }, - "indent": [] + } } } ], @@ -456,8 +427,7 @@ "line": 17, "column": 16, "offset": 173 - }, - "indent": [] + } } } ], @@ -471,8 +441,7 @@ "line": 17, "column": 16, "offset": 173 - }, - "indent": [] + } } }, { @@ -502,8 +471,7 @@ "line": 19, "column": 7, "offset": 181 - }, - "indent": [] + } } } ], @@ -517,8 +485,7 @@ "line": 19, "column": 7, "offset": 181 - }, - "indent": [] + } } } ], @@ -532,8 +499,7 @@ "line": 19, "column": 7, "offset": 181 - }, - "indent": [] + } } } ], @@ -547,8 +513,7 @@ "line": 19, "column": 7, "offset": 181 - }, - "indent": [] + } } } ], diff --git a/test/fixtures/normal-blank-lines.json b/test/fixtures/normal-blank-lines.json index 3144df7..b5a82de 100644 --- a/test/fixtures/normal-blank-lines.json +++ b/test/fixtures/normal-blank-lines.json @@ -18,8 +18,7 @@ "line": 1, "column": 5, "offset": 4 - }, - "indent": [] + } } }, { @@ -36,8 +35,7 @@ "line": 1, "column": 9, "offset": 8 - }, - "indent": [] + } } }, { @@ -54,8 +52,7 @@ "line": 1, "column": 13, "offset": 12 - }, - "indent": [] + } } }, { @@ -72,8 +69,7 @@ "line": 1, "column": 17, "offset": 16 - }, - "indent": [] + } } } ], @@ -87,8 +83,7 @@ "line": 1, "column": 17, "offset": 16 - }, - "indent": [] + } } }, { @@ -112,8 +107,7 @@ "line": 3, "column": 16, "offset": 33 - }, - "indent": [] + } } } ], @@ -127,8 +121,7 @@ "line": 3, "column": 16, "offset": 33 - }, - "indent": [] + } } }, { @@ -148,8 +141,7 @@ "line": 5, "column": 14, "offset": 48 - }, - "indent": [] + } } } ], @@ -163,8 +155,7 @@ "line": 5, "column": 14, "offset": 48 - }, - "indent": [] + } } } ], @@ -178,11 +169,7 @@ "line": 5, "column": 14, "offset": 48 - }, - "indent": [ - 1, - 1 - ] + } } }, { @@ -206,8 +193,7 @@ "line": 7, "column": 16, "offset": 65 - }, - "indent": [] + } } } ], @@ -221,8 +207,7 @@ "line": 7, "column": 16, "offset": 65 - }, - "indent": [] + } } }, { @@ -240,11 +225,7 @@ "line": 11, "column": 18, "offset": 98 - }, - "indent": [ - 1, - 5 - ] + } } } ], @@ -258,13 +239,7 @@ "line": 11, "column": 18, "offset": 98 - }, - "indent": [ - 1, - 1, - 1, - 1 - ] + } } }, { @@ -288,8 +263,7 @@ "line": 13, "column": 16, "offset": 115 - }, - "indent": [] + } } } ], @@ -303,8 +277,7 @@ "line": 13, "column": 16, "offset": 115 - }, - "indent": [] + } } }, { @@ -326,8 +299,7 @@ "line": 15, "column": 18, "offset": 134 - }, - "indent": [] + } } } ], @@ -341,8 +313,7 @@ "line": 15, "column": 18, "offset": 134 - }, - "indent": [] + } } } ], @@ -356,8 +327,7 @@ "line": 15, "column": 18, "offset": 134 - }, - "indent": [] + } } } ], @@ -371,11 +341,7 @@ "line": 15, "column": 18, "offset": 134 - }, - "indent": [ - 1, - 1 - ] + } } }, { @@ -399,8 +365,7 @@ "line": 17, "column": 16, "offset": 151 - }, - "indent": [] + } } } ], @@ -414,8 +379,7 @@ "line": 17, "column": 16, "offset": 151 - }, - "indent": [] + } } }, { @@ -445,8 +409,7 @@ "line": 19, "column": 11, "offset": 163 - }, - "indent": [] + } } } ], @@ -460,8 +423,7 @@ "line": 19, "column": 11, "offset": 163 - }, - "indent": [] + } } } ], @@ -475,8 +437,7 @@ "line": 19, "column": 11, "offset": 163 - }, - "indent": [] + } } } ], @@ -490,8 +451,7 @@ "line": 19, "column": 11, "offset": 163 - }, - "indent": [] + } } } ], @@ -505,11 +465,7 @@ "line": 19, "column": 11, "offset": 163 - }, - "indent": [ - 1, - 1 - ] + } } } ], diff --git a/test/index.js b/test/index.js index 141da09..77a9e26 100644 --- a/test/index.js +++ b/test/index.js @@ -4,6 +4,7 @@ var fs = require('fs') var path = require('path') var test = require('tape') var u = require('unist-builder') +var clean = require('unist-util-remove-position') var vfile = require('to-vfile') var unified = require('unified') var parse = require('remark-parse') @@ -15,58 +16,42 @@ var footnotes = require('..') var base = path.join('test', 'fixtures') test('parse', function (t) { - var basic = unified().use(parse, {position: false}).use(footnotes) - var all = basic().use(footnotes, {inlineNotes: true}) + var basic = unified().use(parse).use(footnotes) + var all = unified().use(parse).use(footnotes, {inlineNotes: true}) t.deepEqual( - basic.parse('^[inline]'), - u('root', [ - u('paragraph', [ - u('text', '^'), - u( - 'linkReference', - {identifier: 'inline', label: 'inline', referenceType: 'shortcut'}, - [u('text', 'inline')] - ) - ]) - ]), + clean(basic.parse('^[inline]'), true), + u('root', [u('paragraph', [u('text', '^[inline]')])]), 'should not parse inline footnotes by default' ) t.deepEqual( - all.parse('^[inline]'), + clean(all.parse('^[inline]'), true), u('root', [u('paragraph', [u('footnote', [u('text', 'inline')])])]), 'should parse inline footnotes in `inlineNotes` mode' ) t.deepEqual( - basic() - .use(parse, {gfm: false}) - .parse('[^def inition]: https://example.com'), - u('root', [ - u('paragraph', [u('text', '[^def inition]: https://example.com')]) - ]), + clean(basic().parse('[^]: https://example.com'), true), + u('root', [u('paragraph', [u('text', '[^]: https://example.com')])]), 'should no longer allow normal definitions that start w/ caret' ) t.deepEqual( - basic.parse('Such as [^like so], [^or so][], or [^like this][this].'), + clean( + basic.parse('Such as [^like so], [^or so][], or [^like this][this].'), + true + ), u('root', [ u('paragraph', [ - u('text', 'Such as [^like so], [^or so][], or [^like this]'), - u( - 'linkReference', - {identifier: 'this', label: 'this', referenceType: 'shortcut'}, - [u('text', 'this')] - ), - u('text', '.') + u('text', 'Such as [^like so], [^or so][], or [^like this][this].') ]) ]), 'should no longer allow normal references that start w/ caret' ) t.deepEqual( - basic.parse('[definition]: https://example.com'), + clean(basic.parse('[definition]: https://example.com'), true), u('root', [ u('definition', { identifier: 'definition', @@ -79,124 +64,129 @@ test('parse', function (t) { ) t.deepEqual( - basic.parse('Such as [like so], [or so][], or [like this][this].'), + clean( + basic.parse('Such as [x], [x][], or [like this][x].\n\n[x]: y'), + true + ), u('root', [ u('paragraph', [ u('text', 'Such as '), u( 'linkReference', - {identifier: 'like so', label: 'like so', referenceType: 'shortcut'}, - [u('text', 'like so')] + {identifier: 'x', label: 'x', referenceType: 'shortcut'}, + [u('text', 'x')] ), u('text', ', '), u( 'linkReference', - {identifier: 'or so', label: 'or so', referenceType: 'collapsed'}, - [u('text', 'or so')] + {identifier: 'x', label: 'x', referenceType: 'collapsed'}, + [u('text', 'x')] ), u('text', ', or '), u( 'linkReference', - {identifier: 'this', label: 'this', referenceType: 'full'}, + {identifier: 'x', label: 'x', referenceType: 'full'}, [u('text', 'like this')] ), u('text', '.') - ]) + ]), + u('definition', {identifier: 'x', label: 'x', url: 'y', title: null}) ]), 'should still allow proper normal references' ) t.deepEqual( - basic.parse('['), + clean(basic.parse('['), true), u('root', [u('paragraph', [u('text', '[')])]), 'should not crash on `[`' ) t.deepEqual( - basic.parse('[]'), + clean(basic.parse('[]'), true), u('root', [u('paragraph', [u('text', '[]')])]), 'should not crash on `[]`' ) t.deepEqual( - basic.parse('[^'), + clean(basic.parse('[^'), true), u('root', [u('paragraph', [u('text', '[^')])]), 'should not crash on `[^`' ) t.deepEqual( - basic.parse('[^]'), + clean(basic.parse('[^]'), true), u('root', [u('paragraph', [u('text', '[^]')])]), 'should not crash on `[^]`' ) t.deepEqual( - basic.parse('[^ '), - u('root', [u('paragraph', [u('text', '[^ ')])]), + clean(basic.parse('[^ '), true), + u('root', [u('paragraph', [u('text', '[^')])]), 'should not crash on `[^ `' ) t.deepEqual( - basic.parse('[^a]'), + clean(basic.parse('[^a]\n\n[^a]:'), true), u('root', [ - u('paragraph', [u('footnoteReference', {label: 'a', identifier: 'a'})]) + u('paragraph', [u('footnoteReference', {label: 'a', identifier: 'a'})]), + u('footnoteDefinition', {identifier: 'a', label: 'a'}, []) ]), 'should not crash on `[^a]` (conforming)' ) t.deepEqual( - all.parse('^'), + clean(all.parse('^'), true), u('root', [u('paragraph', [u('text', '^')])]), 'should not crash on `^`' ) t.deepEqual( - all.parse('^['), + clean(all.parse('^['), true), u('root', [u('paragraph', [u('text', '^[')])]), 'should not crash on `^[`' ) t.deepEqual( - all.parse('^[]'), + clean(all.parse('^[]'), true), u('root', [u('paragraph', [u('footnote', [])])]), 'should not crash on `^[]` (conforming)' ) t.deepEqual( - all.parse('^[\\'), + clean(all.parse('^[\\'), true), u('root', [u('paragraph', [u('text', '^[\\')])]), 'should not crash on `^[\\`' ) t.deepEqual( - all.parse('^[asd\\'), + clean(all.parse('^[asd\\'), true), u('root', [u('paragraph', [u('text', '^[asd\\')])]), 'should not crash on `^[asd\\`' ) t.deepEqual( - all.parse('^[asd\\]'), - u('root', [u('paragraph', [u('text', '^[asd'), u('text', ']')])]), + clean(all.parse('^[asd\\]'), true), + u('root', [u('paragraph', [u('text', '^[asd]')])]), 'should not crash on `^[asd\\]`' ) t.deepEqual( - all.parse('^[\\\\]'), + clean(all.parse('^[\\\\]'), true), u('root', [u('paragraph', [u('footnote', [u('text', '\\')])])]), 'should not crash on `^[\\\\]` (conforming)' ) t.deepEqual( - all.parse('^[\\]]'), + clean(all.parse('^[\\]]'), true), u('root', [u('paragraph', [u('footnote', [u('text', ']')])])]), 'should not crash on `^[\\]]` (conforming)' ) t.deepEqual( - basic.parse('[^a]:'), + clean(basic.parse('[^a]:'), true), u('root', [u('footnoteDefinition', {identifier: 'a', label: 'a'}, [])]), 'should not crash on `[^a]:` (conforming)' ) t.deepEqual( - basic.parse('[^a]: '), + clean(basic.parse('[^a]: '), true), u('root', [u('footnoteDefinition', {identifier: 'a', label: 'a'}, [])]), 'should not crash on `[^a]: ` (3 spaces, conforming)' ) t.deepEqual( - basic.parse('[^a]: '), + clean(basic.parse('[^a]: '), true), u('root', [u('footnoteDefinition', {identifier: 'a', label: 'a'}, [])]), 'should not crash on `[^a]: ` (8 spaces, conforming)' ) t.deepEqual( - basic.parse('[^a]:b'), + clean(basic.parse('[^a]:b'), true), u('root', [ u('footnoteDefinition', {identifier: 'a', label: 'a'}, [ u('paragraph', [u('text', 'b')]) @@ -206,21 +196,18 @@ test('parse', function (t) { ) t.deepEqual( - basic.parse('> block quote\n[^1]: 1'), + clean(basic.parse('> block quote\n[^1]: 1'), true), u('root', [ - u('blockquote', [ - u('paragraph', [ - u('text', 'block quote\n'), - u('footnoteReference', {identifier: '1', label: '1'}), - u('text', ': 1') - ]) + u('blockquote', [u('paragraph', [u('text', 'block quote')])]), + u('footnoteDefinition', {identifier: '1', label: '1'}, [ + u('paragraph', [u('text', '1')]) ]) ]), - 'should not interrupt a block quote' + 'should interrupt a block quote' ) t.deepEqual( - basic.parse('---\n[^1]: 1'), + clean(basic.parse('---\n[^1]: 1'), true), u('root', [ u('thematicBreak'), u('footnoteDefinition', {identifier: '1', label: '1'}, [ @@ -231,7 +218,7 @@ test('parse', function (t) { ) t.deepEqual( - basic.parse('# Heading\n[^1]: 1'), + clean(basic.parse('# Heading\n[^1]: 1'), true), u('root', [ u('heading', {depth: 1}, [u('text', 'Heading')]), u('footnoteDefinition', {identifier: '1', label: '1'}, [ @@ -242,7 +229,7 @@ test('parse', function (t) { ) t.deepEqual( - basic.parse('```fenced\n```\n[^1]: 1'), + clean(basic.parse('```fenced\n```\n[^1]: 1'), true), u('root', [ u('code', {lang: 'fenced', meta: null}, ''), u('footnoteDefinition', {identifier: '1', label: '1'}, [ @@ -253,7 +240,7 @@ test('parse', function (t) { ) t.deepEqual( - basic.parse(' indented\n[^1]: 1'), + clean(basic.parse(' indented\n[^1]: 1'), true), u('root', [ u('code', {lang: null, meta: null}, 'indented'), u('footnoteDefinition', {identifier: '1', label: '1'}, [ @@ -264,41 +251,39 @@ test('parse', function (t) { ) t.deepEqual( - basic.parse('\n[^1]: 1'), + clean(basic.parse('\n[^1]: 1'), true), u('root', [u('html', '\n[^1]: 1')]), 'should not interrupt HTML' ) t.deepEqual( - basic.parse('- list\n[^1]: 1'), + clean(basic.parse('- list\n[^1]: 1'), true), u('root', [ u('list', {ordered: false, start: null, spread: false}, [ u('listItem', {spread: false, checked: null}, [ - u('paragraph', [ - u('text', 'list\n'), - u('footnoteReference', {identifier: '1', label: '1'}), - u('text', ': 1') - ]) + u('paragraph', [u('text', 'list')]) ]) + ]), + u('footnoteDefinition', {identifier: '1', label: '1'}, [ + u('paragraph', [u('text', '1')]) ]) ]), - 'should not interrupt a list' + 'should interrupt a list' ) t.deepEqual( - basic.parse('paragraph\n[^1]: 1'), + clean(basic.parse('paragraph\n[^1]: 1'), true), u('root', [ - u('paragraph', [ - u('text', 'paragraph\n'), - u('footnoteReference', {identifier: '1', label: '1'}), - u('text', ': 1') + u('paragraph', [u('text', 'paragraph')]), + u('footnoteDefinition', {identifier: '1', label: '1'}, [ + u('paragraph', [u('text', '1')]) ]) ]), - 'should not interrupt a paragraph' + 'should interrupt a paragraph' ) t.deepEqual( - basic.parse('[^1]\n\n[^1]: 1\nParagraph'), + clean(basic.parse('[^1]\n\n[^1]: 1\nParagraph'), true), u('root', [ u('paragraph', [u('footnoteReference', {identifier: '1', label: '1'})]), u('footnoteDefinition', {identifier: '1', label: '1'}, [ @@ -309,7 +294,7 @@ test('parse', function (t) { ) t.deepEqual( - basic.parse('[^1]\n\n[^1]: 1\n\tParagraph'), + clean(basic.parse('[^1]\n\n[^1]: 1\n\tParagraph'), true), u('root', [ u('paragraph', [u('footnoteReference', {identifier: '1', label: '1'})]), u('footnoteDefinition', {identifier: '1', label: '1'}, [ @@ -319,7 +304,7 @@ test('parse', function (t) { 'should indent with tabs' ) t.deepEqual( - basic.parse('[^1]\n\n[^1]: 1\n \tParagraph'), + clean(basic.parse('[^1]\n\n[^1]: 1\n \tParagraph'), true), u('root', [ u('paragraph', [u('footnoteReference', {identifier: '1', label: '1'})]), u('footnoteDefinition', {identifier: '1', label: '1'}, [ @@ -330,11 +315,11 @@ test('parse', function (t) { ) t.deepEqual( - basic.parse('[^1]\n\n[^1]: 1\n \tParagraph'), + clean(basic.parse('[^1]\n\n[^1]: 1\n \tParagraph'), true), u('root', [ u('paragraph', [u('footnoteReference', {identifier: '1', label: '1'})]), u('footnoteDefinition', {identifier: '1', label: '1'}, [ - u('paragraph', [u('text', '1\n\tParagraph')]) + u('paragraph', [u('text', '1\nParagraph')]) ]) ]), 'should indent with four spaces, and a next tab is part of the content' @@ -354,19 +339,19 @@ test('serialize', function (t) { u('text', '.') ]) ), - '^[Text with _markup_.]', + '^[Text with *markup*.]\n', 'should serialize a footnote' ) t.equal( p.stringify(u('footnoteReference', {identifier: 'a', label: 'A'})), - '[^A]', + '[^A]\n', 'should serialize a footnote reference' ) t.equal( p.stringify(u('footnoteReference', {identifier: 'a'})), - '[^a]', + '[^a]\n', 'should serialize a footnote reference w/o label' ) @@ -380,7 +365,7 @@ test('serialize', function (t) { ]) ]) ), - '[^A]: Text with _markup_.', + '[^A]: Text with *markup*.\n', 'should serialize a footnote definition' ) @@ -394,7 +379,7 @@ test('serialize', function (t) { ]) ]) ), - '[^a]: Text with _markup_.', + '[^a]: Text with *markup*.\n', 'should serialize a footnote definition w/o label' ) @@ -406,7 +391,7 @@ test('serialize', function (t) { u('code', 'console.log(1)\n\nconsole.log(2)') ]) ), - '[^a]: # Heading\n\n > Block quote.\n\n console.log(1)\n\n console.log(2)', + '[^a]: # Heading\n\n > Block quote.\n\n console.log(1)\n\n console.log(2)\n', 'should serialize a footnote definition w/o label' )