Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Support for Pandoc Markdown's inline footnotes #81

Closed
zmwangx opened this issue Jan 19, 2016 · 6 comments
Closed

Feature request: Support for Pandoc Markdown's inline footnotes #81

zmwangx opened this issue Jan 19, 2016 · 6 comments

Comments

@zmwangx
Copy link

zmwangx commented Jan 19, 2016

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.

@jrblevin
Copy link
Owner

Thanks--I'll definitely consider it.

@zmwangx
Copy link
Author

zmwangx commented Jan 19, 2016

Hmm, just noticed that my regex didn't match linefeeds in footnote texts, so it didn't even pass the example above... The regex is now corrected in the original post.

@syohex
Copy link
Collaborator

syohex commented Jan 19, 2016

You can highlight by font-lock-add-keywords as bellow.

(font-lock-add-keywords
 'markdown-mode
 '(("\\(\\^\\[\\)\\([^]]+\\)\\(\\]\\)"
    (1 'markdown-markup-face)
    (2 'markdown-footnote-face)
    (3 'markdown-markup-face))))

pandoc

I'm not sure it is better to support such markdown dialect. Because there are many markdown dialects.

@zmwangx
Copy link
Author

zmwangx commented Jan 19, 2016

You can highlight by font-lock-add-keywords as bellow.

Why? My patch already does highlighting.

I'm not sure it is better to support such markdown dialect. Because there are many markdown dialects.

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. ^[text] is very uncommon in regular prose, so there's no surprise.

@syohex
Copy link
Collaborator

syohex commented Jan 19, 2016

Why? My patch already does highlighting.

As I said, I'm not sure to implement this feature into markdown-mode. My snippet is highlight pandoc inline footnote syntax without changing markdown-mode code(You can highlight by putting it your init.el).

@jrblevin
Copy link
Owner

Thanks for this suggestion. We now have support for inline footnotes (7499d28), with raised text and optionally hidden markup (669815e).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants