emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/markdown-mode ece4f28a3d 1/2: Hide markup even if markdown


From: ELPA Syncer
Subject: [nongnu] elpa/markdown-mode ece4f28a3d 1/2: Hide markup even if markdown-fontify-whole-heading-line is enabled
Date: Sun, 23 Jul 2023 10:01:51 -0400 (EDT)

branch: elpa/markdown-mode
commit ece4f28a3de756e85240a53ccbbcffa7f49a06e2
Author: Tomohisa Kuranari <tomohisa.kuranari@gmail.com>
Commit: Tomohisa Kuranari <tomohisa.kuranari@gmail.com>

    Hide markup even if markdown-fontify-whole-heading-line is enabled
---
 CHANGES.md             |  4 ++--
 markdown-mode.el       | 29 +++++++++++++++++++++--------
 tests/markdown-test.el | 19 +++++++++++++++----
 3 files changed, 38 insertions(+), 14 deletions(-)

diff --git a/CHANGES.md b/CHANGES.md
index 5a69b6efda..3c45adf003 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -9,7 +9,7 @@
 
 *   New Features:
     - Introduce `markdown-fontify-whole-heading-line` variable for highlighting
-      whole header line. [GH-705][]
+      whole header line. [GH-705][] [GH-773][]
     - Backslashes in escape sequences are now treated as markup. [GH-377][]
 
 *   Improvements:
@@ -52,10 +52,10 @@
   [gh-766]: https://github.com/jrblevin/markdown-mode/issues/766
   [gh-768]: https://github.com/jrblevin/markdown-mode/pull/768
   [gh-771]: https://github.com/jrblevin/markdown-mode/issues/771
+  [gh-773]: https://github.com/jrblevin/markdown-mode/issues/773
   [gh-774]: https://github.com/jrblevin/markdown-mode/issues/774
   [gh-778]: https://github.com/jrblevin/markdown-mode/issues/778
 
-
 # Markdown Mode 2.5
 
 *   **Breaking changes:**
diff --git a/markdown-mode.el b/markdown-mode.el
index 9d260648ec..d3b1231a4f 100644
--- a/markdown-mode.el
+++ b/markdown-mode.el
@@ -3483,17 +3483,30 @@ SEQ may be an atom or a sequence."
                    (add-text-properties
                     (match-beginning 3) (match-end 3) rule-props)))
         ;; atx heading
-        (if markdown-fontify-whole-heading-line
-            (let ((header-end (min (point-max) (1+ (match-end 0)))))
-              (add-text-properties
-               (match-beginning 0) header-end heading-props))
+        (let ((header-end
+               (if markdown-fontify-whole-heading-line
+                   (min (point-max) (1+ (match-end 0)))
+                 (match-end 0))))
           (add-text-properties
            (match-beginning 4) (match-end 4) left-markup-props)
-          (add-text-properties
-           (match-beginning 5) (match-end 5) heading-props)
-          (when (match-end 6)
+
+          ;; If closing tag is present
+          (if (match-end 6)
+              (progn
+                (if markdown-hide-markup
+                    (progn
+                      (add-text-properties
+                       (match-beginning 5) header-end heading-props)
+                      (add-text-properties
+                       (match-beginning 6) (match-end 6) right-markup-props))
+                  (add-text-properties
+                   (match-beginning 5) (match-end 5) heading-props)
+                  (add-text-properties
+                   (match-beginning 6) header-end right-markup-props)))
+            ;; If closing tag is not present
             (add-text-properties
-             (match-beginning 6) (match-end 6) right-markup-props)))))
+             (match-beginning 5) header-end heading-props))
+          )))
     t))
 
 (defun markdown-fontify-tables (last)
diff --git a/tests/markdown-test.el b/tests/markdown-test.el
index 0793667ef7..43dad3b390 100644
--- a/tests/markdown-test.el
+++ b/tests/markdown-test.el
@@ -3038,10 +3038,21 @@ puts markdown.to_html
 (ert-deftest test-markdown-font-lock/atx-whole-line ()
   "Test font-lock for atx headers with whole line flag."
   (let ((markdown-fontify-whole-heading-line t))
-    (markdown-test-string "## abc  "
-      (markdown-test-range-has-face 1 8 'markdown-header-face-2))
-    (markdown-test-string "## abc ##"
-      (markdown-test-range-has-face 1 9 'markdown-header-face-2))))
+    (let ((markdown-hide-markup nil))
+      (markdown-test-string "## abc  \n"
+                            (markdown-test-range-has-face 4 9 
'markdown-header-face-2))
+      (markdown-test-string "## abc ##\n"
+                            (markdown-test-range-has-face 4 6 
'markdown-header-face-2)
+                            (markdown-test-range-has-face 7 10 
'markdown-header-delimiter-face)))
+
+    (let ((markdown-hide-markup t))
+      (markdown-test-string "## abc  \n"
+                            (markdown-test-range-has-face 4 9 
'markdown-header-face-2))
+      (markdown-test-string "## abc ##\n"
+                            (markdown-test-range-has-face 4 6 
'markdown-header-face-2)
+                            (markdown-test-range-has-face 7 9 
'markdown-header-delimiter-face)
+                            (markdown-test-range-has-face 10 10 
'markdown-header-face-2))
+      )))
 
 (ert-deftest test-markdown-font-lock/setext-1-letter ()
   "An edge case for level-one setext headers."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]