Skip to content

Commit

Permalink
Fix issue with code after headings without whitespace
Browse files Browse the repository at this point in the history
Fixes "Invalid face reference: markdown-header-face-7" error.

Closes GH-234.
  • Loading branch information
jrblevin committed Aug 30, 2017
1 parent 7bf0736 commit 09b1074
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
4 changes: 3 additions & 1 deletion markdown-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -7170,7 +7170,9 @@ Calls `markdown-cycle' with argument t."
(defun markdown-outline-level ()
"Return the depth to which a statement is nested in the outline."
(cond
((markdown-code-block-at-point-p) 7) ;; Only 6 header levels are defined.
((and (match-beginning 0)
(markdown-code-block-at-pos (match-beginning 0)))
7) ;; Only 6 header levels are defined.
((match-end 2) 1)
((match-end 3) 2)
((match-end 4)
Expand Down
19 changes: 19 additions & 0 deletions tests/markdown-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -2940,6 +2940,25 @@ takes precedence)."
(should (markdown-on-heading-p))
(should-not (markdown-range-property-any 453 484 'face '(markdown-hr-face)))))

(ert-deftest test-markdown-font-lock/heading-code-block-no-whitespace ()
"Headings immediately before code blocks should be identified correctly.
See GH-234."
(markdown-test-string
"#### code snippet
```javascript
const styles = require('gadgets/dist/styles.css');
```"
(goto-char (point-min))
(forward-word)
(should (markdown-on-heading-p))
(should (markdown-match-propertized-text 'markdown-heading (point-at-eol)))
(goto-char (match-beginning 0))
(should (markdown-outline-level))
(should (= (markdown-outline-level) 4))
(markdown-test-range-has-face 6 17 'markdown-header-face-4)
(end-of-line)
(should-not (markdown-code-block-at-point-p))))

(ert-deftest test-markdown-font-lock/inline-attributes ()
"Test inline attributes before a fenced code block."
(markdown-test-file "Leanpub.md"
Expand Down

0 comments on commit 09b1074

Please sign in to comment.