Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Feature request: Support for Pandoc Markdown's inline footnotes #81
The syntax of Pandoc Markdown's inline footnotes, per manual, is
Here is an inline note.^[Inlines notes are easier to write, since you don't have to pick an identifier and move down to type the note.]
Would you consider supporting this syntax? A quick patch to enable this would be
diff --git a/markdown-mode.el b/markdown-mode.el index 524b311..b760f58 100644 --- a/markdown-mode.el +++ b/markdown-mode.el @@ -1173,6 +1173,13 @@ Group 1 matches the opening square bracket and carat. Group 2 matches only the label, without the surrounding markup. Group 3 matches the closing square bracket.") +(defconst markdown-regex-inline-footnote + "\\(\\^\\[\\)\\([^]]+\\)\\(\\]\\)" + "Regular expression for an inline footnote ^[footnote text]. +Group 1 matches the opening caret and square bracket. +Group 2 matches the footnote text, without the surrounding markup. +Group 3 matches the closing square bracket.") + (defconst markdown-regex-header "^\\(?:\\(.+\\)\n\\(=+\\)\\|\\(.+\\)\n\\(-+\\)\\|\\(#+\\)\\s-*\\(.*?\\)\\s-*?\\(#*\\)\\)$" "Regexp identifying Markdown headings. @@ -1886,6 +1893,9 @@ See `font-lock-syntactic-face-function' for details." (cons markdown-regex-footnote '((1 markdown-markup-face) ; [^ (2 markdown-footnote-face) ; label (3 markdown-markup-face))) ; ] + (cons markdown-regex-inline-footnote '((1 markdown-markup-face) ; ^[ + (2 markdown-footnote-face) ; footnote text + (3 markdown-markup-face))) ; ] (cons markdown-regex-link-inline '((1 markdown-markup-face nil t) ; ! (optional) (2 markdown-markup-face) ; [ (3 markdown-link-face) ; text
I haven't considered if there would be any undesirable side effects.
You can highlight by
(font-lock-add-keywords 'markdown-mode '(("\\(\\^\\[\\)\\([^]]+\\)\\(\\]\\)" (1 'markdown-markup-face) (2 'markdown-footnote-face) (3 'markdown-markup-face))))
I'm not sure it is better to support such markdown dialect. Because there are many markdown dialects.
Why? My patch already does highlighting.
I'm not sure either, that's why I asked "would you consider supporting this syntax?". Bottom line: Pandoc is a popular dialect, and markdown-mode already supports some Pandoc-specific features (as well as features from other dialects, e.g., multimarkdown). Those are reasons why I'm even mentioning this.
Update. Actually there's another reason: it doesn't hurt.