From 150e14c5a48b8e38dc73130d4cb01ddf0a1afb5e Mon Sep 17 00:00:00 2001 From: Jim Porter Date: Fri, 8 Mar 2024 19:05:08 -0800 Subject: [PATCH] Hide trailing whitespace when hiding markup See . --- CHANGES.md | 1 + markdown-mode.el | 6 +++++- tests/markdown-test.el | 12 ++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 1e4608d..f9e694e 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -11,6 +11,7 @@ - Add functions to move to the beginning and end of lines (`markdown-beginning-of-line` and `markdown-end-of-line`), and the variable `markdown-special-ctrl-a/e`, like Org mode. + - Trailing whitespace for line breaks are hidden when using `markdown-hide-markup` * Bug fixes: - Don't highlight superscript/subscript in math inline/block [GH-802][] diff --git a/markdown-mode.el b/markdown-mode.el index 8094e02..1514edb 100644 --- a/markdown-mode.el +++ b/markdown-mode.el @@ -1855,6 +1855,10 @@ START and END delimit region to propertize." '(face markdown-markup-face invisible markdown-markup) "List of properties and values to apply to markup.") +(defconst markdown-line-break-properties + '(face markdown-line-break-face invisible markdown-markup) + "List of properties and values to apply to line break markup.") + (defconst markdown-language-keyword-properties '(face markdown-language-keyword-face invisible markdown-markup) "List of properties and values to apply to code block language names.") @@ -2298,7 +2302,7 @@ Depending on your font, some reasonable choices are: (markdown--match-highlighting . ((3 markdown-markup-properties) (4 'markdown-highlighting-face) (5 markdown-markup-properties))) - (,markdown-regex-line-break . (1 'markdown-line-break-face prepend)) + (,markdown-regex-line-break . (1 markdown-line-break-properties prepend)) (markdown-match-escape . ((1 markdown-markup-properties prepend))) (markdown-fontify-sub-superscripts) (markdown-match-inline-attributes . ((0 markdown-markup-properties prepend))) diff --git a/tests/markdown-test.el b/tests/markdown-test.el index ae8820b..21c7a03 100644 --- a/tests/markdown-test.el +++ b/tests/markdown-test.el @@ -2257,6 +2257,18 @@ See GH-245." (should (invisible-p (point))) (should-not (invisible-p (1+ (point)))))) +(ert-deftest test-markdown-markup-hiding/line-break () + "Test hiding markup for line break markup." + (markdown-test-string "hello \nworld" + (markdown-test-range-has-property (+ 5 (point)) (+ 6 (point)) 'invisible 'markdown-markup) + (should-not (invisible-p (point))) ;; part of "hello" + (should-not (invisible-p (+ 5 (point)))) ;; part of line break + (should-not (invisible-p (+ 7 (point)))) ;; part of "world" + (markdown-toggle-markup-hiding t) + (should-not (invisible-p (point))) ;; part of "hello" + (should (invisible-p (+ 5 (point)))) ;; part of line break + (should-not (invisible-p (+ 7 (point)))))) ;; inside "world" + ;;; Markup hiding url tests: (ert-deftest test-markdown-url-hiding/eldoc () -- 2.25.1