-
Notifications
You must be signed in to change notification settings - Fork 163
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
Line with a colon is highlighted as footnote #437
Comments
It seems meta-data highlighting does not works well. It is necessary to check the line which has contains colon is meta-data block or not more strictly. I suppose following patch fixes your issue and does not break tests(all tests are passed) diff --git a/markdown-mode.el b/markdown-mode.el
index 7df1e0a..3d9223c 100644
--- a/markdown-mode.el
+++ b/markdown-mode.el
@@ -3261,6 +3261,17 @@ Made into a variable to allow for dynamic let-binding.")
(setq ret (funcall condition)))
ret))
+(defun markdown-metadata-line-p (pos regexp)
+ (save-excursion
+ (or (= (line-number-at-pos pos) 1)
+ (progn
+ (forward-line -1)
+ ;; skip multi-line metadata
+ (while (and (looking-at-p "^\\s-+[[:alpha:]]")
+ (> (line-number-at-pos (point)) 1))
+ (forward-line -1))
+ (looking-at-p regexp)))))
+
(defun markdown-match-generic-metadata (regexp last)
"Match metadata declarations specified by REGEXP from point to LAST.
These declarations must appear inside a metadata block that begins at
@@ -3281,7 +3292,8 @@ the buffer)."
;; before the beginning of the block, start there. Otherwise,
;; move back to FIRST.
(goto-char (if (< first block-begin) block-begin first))
- (if (re-search-forward regexp (min last block-end) t)
+ (if (and (re-search-forward regexp (min last block-end) t)
+ (markdown-metadata-line-p (point) regexp))
;; If a metadata declaration is found, set match-data and return t.
(let ((key-beginning (match-beginning 1))
(key-end (match-end 1)) |
@syohex thanks a lot for this |
6 tasks
@kartikynwa I have merged #438. Please check latest version. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When a line contains a colon, it is highlighted the same way as a footnote.
For example, here is a screenshot of an entirety of a file.
This can be worked around by adding a space before the line or escaping the colon but I felt it was worth reporting anyway.
Edit: I realised that this doesn't happen all the time so I am attaching the file for reference:
example.zip
Expected Behavior
Line shouldn't be highlighted.
Actual Behavior
Line is highlighted as a footnote.
Software Versions
The text was updated successfully, but these errors were encountered: