Skip to content

Commit

Permalink
GFM code blocks without language keywords
Browse files Browse the repository at this point in the history
  • Loading branch information
jrblevin committed Jul 8, 2013
1 parent b664a7b commit 15b41ba
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions markdown-mode.el
Expand Up @@ -1870,7 +1870,7 @@ because `thing-at-point-looking-at' does not work reliably with
"Match GFM quoted code blocks from point to LAST." "Match GFM quoted code blocks from point to LAST."
(let (open lang body close all) (let (open lang body close all)
(cond ((and (eq major-mode 'gfm-mode) (cond ((and (eq major-mode 'gfm-mode)
(search-forward-regexp "^\\(```\\)\\(\\w+\\)?$" last t)) (search-forward-regexp "^\\(```\\)\\([^[:space:]]+[[:space:]]*\\)?$" last t))
(beginning-of-line) (beginning-of-line)
(setq open (list (match-beginning 1) (match-end 1)) (setq open (list (match-beginning 1) (match-end 1))
lang (list (match-beginning 2) (match-end 2))) lang (list (match-beginning 2) (match-end 2)))
Expand Down Expand Up @@ -4653,7 +4653,7 @@ if ARG is omitted or nil."
;; GFM features to match first ;; GFM features to match first
(list (list
(cons 'markdown-match-gfm-code-blocks '((1 markdown-pre-face) (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) (3 markdown-pre-face)
(4 markdown-pre-face)))) (4 markdown-pre-face))))
;; Basic Markdown features (excluding possibly overridden ones) ;; Basic Markdown features (excluding possibly overridden ones)
Expand Down
7 changes: 7 additions & 0 deletions tests/markdown-test.el
Expand Up @@ -2334,6 +2334,13 @@ See `paragraph-separate'."
(markdown-test-range-has-face 2647 2728 markdown-pre-face) ; code (markdown-test-range-has-face 2647 2728 markdown-pre-face) ; code
(markdown-test-range-has-face 2730 2732 markdown-pre-face))) ; ``` (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) (provide 'markdown-test)


;;; markdown-test.el ends here ;;; markdown-test.el ends here

0 comments on commit 15b41ba

Please sign in to comment.