From 15b41ba0c656ea831d09b219afc915702ea73e95 Mon Sep 17 00:00:00 2001 From: Jason Blevins Date: Mon, 8 Jul 2013 09:56:25 -0400 Subject: [PATCH] GFM code blocks without language keywords --- markdown-mode.el | 4 ++-- tests/markdown-test.el | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/markdown-mode.el b/markdown-mode.el index 4dd07abc..dbb71627 100644 --- a/markdown-mode.el +++ b/markdown-mode.el @@ -1870,7 +1870,7 @@ because `thing-at-point-looking-at' does not work reliably with "Match GFM quoted code blocks from point to LAST." (let (open lang body close all) (cond ((and (eq major-mode 'gfm-mode) - (search-forward-regexp "^\\(```\\)\\(\\w+\\)?$" last t)) + (search-forward-regexp "^\\(```\\)\\([^[:space:]]+[[:space:]]*\\)?$" last t)) (beginning-of-line) (setq open (list (match-beginning 1) (match-end 1)) lang (list (match-beginning 2) (match-end 2))) @@ -4653,7 +4653,7 @@ if ARG is omitted or nil." ;; GFM features to match first (list (cons 'markdown-match-gfm-code-blocks '((1 markdown-pre-face) - (2 markdown-language-keyword-face) + (2 markdown-language-keyword-face t t) (3 markdown-pre-face) (4 markdown-pre-face)))) ;; Basic Markdown features (excluding possibly overridden ones) diff --git a/tests/markdown-test.el b/tests/markdown-test.el index 8d9b73f4..f254d0e1 100644 --- a/tests/markdown-test.el +++ b/tests/markdown-test.el @@ -2334,6 +2334,13 @@ See `paragraph-separate'." (markdown-test-range-has-face 2647 2728 markdown-pre-face) ; code (markdown-test-range-has-face 2730 2732 markdown-pre-face))) ; ``` +(ert-deftest test-markdown-gfm/code-block-font-lock-2 () + "GFM code block font lock test without language identifier." + (markdown-test-string-gfm "Plain code block:\n\n```\nfoo\n```\n" + (markdown-test-range-has-face 20 22 markdown-pre-face) + (markdown-test-range-has-face 24 26 markdown-pre-face) + (markdown-test-range-has-face 28 30 markdown-pre-face))) + (provide 'markdown-test) ;;; markdown-test.el ends here