Skip to content

Commit

Permalink
Make bold and italics work as overlays
Browse files Browse the repository at this point in the history
Closes #39
  • Loading branch information
jrblevin committed Dec 16, 2015
1 parent 9be1a27 commit dae7046
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 6 deletions.
12 changes: 6 additions & 6 deletions markdown-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -1770,12 +1770,12 @@ See `font-lock-syntactic-face-function' for details."
(4 markdown-markup-face) ; :
(5 markdown-url-face) ; url
(6 markdown-link-title-face))) ; "title" (optional)
(cons 'markdown-match-bold '((1 markdown-markup-face)
(2 markdown-bold-face)
(3 markdown-markup-face)))
(cons 'markdown-match-italic '((1 markdown-markup-face)
(2 markdown-italic-face)
(3 markdown-markup-face)))
(cons 'markdown-match-bold '((1 markdown-markup-face prepend)
(2 markdown-bold-face append)
(3 markdown-markup-face prepend)))
(cons 'markdown-match-italic '((1 markdown-markup-face prepend)
(2 markdown-italic-face append)
(3 markdown-markup-face prepend)))
(cons markdown-regex-uri 'markdown-link-face)
(cons markdown-regex-email 'markdown-link-face)
(cons markdown-regex-line-break '(1 markdown-line-break-face prepend))
Expand Down
64 changes: 64 additions & 0 deletions tests/markdown-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -1649,6 +1649,42 @@ the opening bracket of [^2], and then subsequent functions would kill [^2])."
(markdown-test-range-has-face 9 14 markdown-italic-face)
(markdown-test-range-has-face 15 15 markdown-markup-face)))

(ert-deftest test-markdown-font-lock/italics-in-heading ()
"Test italic overlay in a heading."
(markdown-test-string
"# *Italics* in a Heading"
(markdown-test-range-has-face 3 3 markdown-markup-face)
(markdown-test-range-has-face 4 10 markdown-italic-face)
(markdown-test-range-has-face 11 11 markdown-markup-face)))

(ert-deftest test-markdown-font-lock/italics-link ()
"Test italic overlay in an inline link."
(markdown-test-string
"*[italic link](http://www.link.com/)*"
(markdown-test-range-has-face 1 1 markdown-markup-face)
(markdown-test-range-has-face 2 36 markdown-italic-face)
(markdown-test-range-has-face 37 37 markdown-markup-face))
(markdown-test-string
"[*italic link*](http://www.link.com/)"
(markdown-test-range-has-face 2 2 markdown-markup-face)
(markdown-test-range-has-face 3 13 markdown-italic-face)
(markdown-test-range-has-face 14 14 markdown-markup-face)))

(ert-deftest test-markdown-font-lock/italics-in-blockquote ()
"Test italics overlay in a blockquote."
(markdown-test-string
"> *italics* inside a blockquote"
(markdown-test-range-has-face 3 3 markdown-markup-face)
(markdown-test-range-has-face 4 10 markdown-italic-face)
(markdown-test-range-has-face 11 11 markdown-markup-face)))

(ert-deftest test-markdown-font-lock/italics-in-pre ()
"Test italics overlay in a blockquote."
(markdown-test-string
" *italics* inside a pre block"
(markdown-test-range-has-face (point-min) (1- (point-max))
markdown-pre-face)))

(ert-deftest test-markdown-font-lock/bold-1 ()
"A simple bold test."
(markdown-test-file "inline.text"
Expand Down Expand Up @@ -1704,6 +1740,34 @@ the opening bracket of [^2], and then subsequent functions would kill [^2])."
(markdown-test-range-has-face 10 13 markdown-bold-face)
(markdown-test-range-has-face 14 15 markdown-markup-face)))

(ert-deftest test-markdown-font-lock/bold-link ()
"Test bold overlay in an inline link."
(markdown-test-string
"**[bold link](http://www.link.com/)**"
(markdown-test-range-has-face 1 2 markdown-markup-face)
(markdown-test-range-has-face 3 35 markdown-bold-face)
(markdown-test-range-has-face 36 37 markdown-markup-face))
(markdown-test-string
"[**bold link**](http://www.link.com/)"
(markdown-test-range-has-face 2 3 markdown-markup-face)
(markdown-test-range-has-face 4 12 markdown-bold-face)
(markdown-test-range-has-face 13 14 markdown-markup-face)))

(ert-deftest test-markdown-font-lock/bold-in-blockquote ()
"Test bold overlay in a blockquote."
(markdown-test-string
"> **bold** inside a blockquote"
(markdown-test-range-has-face 3 4 markdown-markup-face)
(markdown-test-range-has-face 5 8 markdown-bold-face)
(markdown-test-range-has-face 9 10 markdown-markup-face)))

(ert-deftest test-markdown-font-lock/bold-in-pre ()
"Test bold overlay in a blockquote."
(markdown-test-string
" **bold** inside a pre block"
(markdown-test-range-has-face (point-min) (1- (point-max))
markdown-pre-face)))

(ert-deftest test-markdown-font-lock/code-1 ()
"A simple inline code test."
(markdown-test-file "inline.text"
Expand Down

0 comments on commit dae7046

Please sign in to comment.