From 83639b8ef8790fcf00ae87f5b7b46df59a67bc52 Mon Sep 17 00:00:00 2001 From: David Anson Date: Fri, 24 Jun 2016 23:13:00 -0700 Subject: [PATCH] Add support to MD011 for Markdown Extra-style footnotes (fixes #18). --- doc/Rules.md | 4 ++++ lib/rules.js | 2 +- test/markdown-extra-footnote.md | 12 ++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 test/markdown-extra-footnote.md diff --git a/doc/Rules.md b/doc/Rules.md index 48e24e73..b2896a4b 100644 --- a/doc/Rules.md +++ b/doc/Rules.md @@ -260,6 +260,10 @@ To fix this, swap the `[]` and `()` around: [Correct link syntax](http://www.example.com/) +Note: [Markdown Extra](https://en.wikipedia.org/wiki/Markdown_Extra)-style footnotes do not trigger this rule: + + For (example)[^1] + ## MD012 - Multiple consecutive blank lines Tags: whitespace, blank_lines diff --git a/lib/rules.js b/lib/rules.js index 986df2b8..36e52118 100644 --- a/lib/rules.js +++ b/lib/rules.js @@ -327,7 +327,7 @@ module.exports = [ "aliases": [ "no-reversed-links" ], "func": function MD011(params, errors) { forEachInlineChild(params, "text", function forToken(token) { - if (/\([^)]+\)\[[^\]]+\]/.test(token.content)) { + if (/\([^)]+\)\[[^\]^][^\]]*\]/.test(token.content)) { errors.push(token.lineNumber); } }); diff --git a/test/markdown-extra-footnote.md b/test/markdown-extra-footnote.md new file mode 100644 index 00000000..2c7aafe7 --- /dev/null +++ b/test/markdown-extra-footnote.md @@ -0,0 +1,12 @@ +# Header + +Text with Markdown Extra footnote[^1] + +Text with (parenthesized footnote)[^2] + +This is not a (parenthesized footnote)[x^y] {MD011} + +Nor (is this)[z] {MD011} + +[^1]: Footnote +[^2]: Another footnote