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

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

[nongnu] elpa/markdown-mode b1db3c4c83 2/2: Merge pull request #717 from


From: ELPA Syncer
Subject: [nongnu] elpa/markdown-mode b1db3c4c83 2/2: Merge pull request #717 from jrblevin/issue-716
Date: Fri, 1 Jul 2022 12:58:38 -0400 (EDT)

branch: elpa/markdown-mode
commit b1db3c4c838a47f21d2c4a210b9840f61e757604
Merge: 45aed2caf0 c4f0889171
Author: Shohei YOSHIDA <syohex@gmail.com>
Commit: GitHub <noreply@github.com>

    Merge pull request #717 from jrblevin/issue-716
    
    Don't override table faces by link faces
---
 CHANGES.md             |  4 ++++
 markdown-mode.el       | 31 +++++++++++++++++--------------
 tests/markdown-test.el | 25 +++++++++++++++++++++++++
 3 files changed, 46 insertions(+), 14 deletions(-)

diff --git a/CHANGES.md b/CHANGES.md
index 383b394365..c208739c6b 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -16,8 +16,12 @@
     - Support newer version Eldoc ships with Emacs 28.
     - Don't spell-check against pandoc references. [GH-572][]
 
+*   Bug fixes:
+    - Don't override table faces by link faces [GH-716][]
+
   [gh-572]: https://github.com/jrblevin/markdown-mode/issues/572
   [gh-705]: https://github.com/jrblevin/markdown-mode/issues/705
+  [gh-716]: https://github.com/jrblevin/markdown-mode/issues/716
 
 
 # Markdown Mode 2.5
diff --git a/markdown-mode.el b/markdown-mode.el
index 7b84a85453..4e4bedc0c7 100644
--- a/markdown-mode.el
+++ b/markdown-mode.el
@@ -7858,15 +7858,13 @@ Translate filenames using 
`markdown-filename-translate-function'."
                      'help-echo (if title (concat title "\n" url) url)))
            ;; URL part
            (up (list 'keymap markdown-mode-mouse-map
-                     'face 'markdown-url-face
                      'invisible 'markdown-markup
                      'mouse-face 'markdown-highlight-face
                      'font-lock-multiline t))
            ;; URL composition character
            (url-char (markdown--first-displayable markdown-url-compose-char))
            ;; Title part
-           (tp (list 'face 'markdown-link-title-face
-                     'invisible 'markdown-markup
+           (tp (list 'invisible 'markdown-markup
                      'font-lock-multiline t)))
       (dolist (g '(1 2 4 5 8))
         (when (match-end g)
@@ -7874,10 +7872,13 @@ Translate filenames using 
`markdown-filename-translate-function'."
       ;; Preserve existing faces applied to link part (e.g., inline code)
       (when link-start
         (add-text-properties link-start link-end lp)
-        (add-face-text-property link-start link-end
-                                'markdown-link-face 'append))
-      (when url-start (add-text-properties url-start url-end up))
-      (when title-start (add-text-properties url-end title-end tp))
+        (add-face-text-property link-start link-end 'markdown-link-face))
+      (when url-start
+        (add-text-properties url-start url-end up)
+        (add-face-text-property url-start url-end 'markdown-url-face))
+      (when title-start
+        (add-text-properties url-end title-end tp)
+        (add-face-text-property url-end title-end 'markdown-link-title-face))
       (when (and markdown-hide-urls url-start)
         (compose-region url-start (or title-end url-end) url-char))
       t)))
@@ -7896,7 +7897,6 @@ Translate filenames using 
`markdown-filename-translate-function'."
                      'font-lock-multiline t))
            ;; Link part
            (lp (list 'keymap markdown-mode-mouse-map
-                     'face 'markdown-link-face
                      'mouse-face 'markdown-highlight-face
                      'font-lock-multiline t
                      'help-echo (lambda (_ __ pos)
@@ -7908,16 +7908,19 @@ Translate filenames using 
`markdown-filename-translate-function'."
            ;; URL composition character
            (url-char (markdown--first-displayable markdown-url-compose-char))
            ;; Reference part
-           (rp (list 'face 'markdown-reference-face
-                     'invisible 'markdown-markup
+           (rp (list 'invisible 'markdown-markup
                      'font-lock-multiline t)))
       (dolist (g '(1 2 4 5 8))
         (when (match-end g)
           (add-text-properties (match-beginning g) (match-end g) mp)))
-      (when link-start (add-text-properties link-start link-end lp))
-      (when ref-start (add-text-properties ref-start ref-end rp)
-            (when (and markdown-hide-urls (> (- ref-end ref-start) 2))
-              (compose-region ref-start ref-end url-char)))
+      (when link-start
+        (add-text-properties link-start link-end lp)
+        (add-face-text-property link-start link-end 'markdown-link-face))
+      (when ref-start
+        (add-text-properties ref-start ref-end rp)
+        (add-face-text-property ref-start ref-end 'markdown-reference-face)
+        (when (and markdown-hide-urls (> (- ref-end ref-start) 2))
+          (compose-region ref-start ref-end url-char)))
       t)))
 
 (defun markdown-fontify-angle-uris (last)
diff --git a/tests/markdown-test.el b/tests/markdown-test.el
index a21f17be86..468b066724 100644
--- a/tests/markdown-test.el
+++ b/tests/markdown-test.el
@@ -3018,6 +3018,31 @@ Detail: 
https://github.com/jrblevin/markdown-mode/issues/409";
                  (1+ (point-min)) (- (point-max) 2) 'face
                  '(markdown-markup-face markdown-link-face 
markdown-url-face)))))
 
+(ert-deftest test-markdown-font-lock/do-not-overwrite-by-link-face ()
+  "Test links inside of table.
+Don't override table faces by link faces.
+Detail: https://github.com/jrblevin/markdown-mode/issues/716";
+  (markdown-test-string "| Links                        |
+|------------------------------|
+| [Link 1](https://github.com) |
+| [Link 2][link-reference]     |
+"
+    (search-forward "Link 1")
+    (markdown-test-range-has-face (match-beginning 0) (1- (match-end 0)) 
'markdown-link-face)
+    (markdown-test-range-has-face (match-beginning 0) (1- (match-end 0)) 
'markdown-table-face)
+
+    (search-forward "https://github.com";)
+    (markdown-test-range-has-face (match-beginning 0) (1- (match-end 0)) 
'markdown-url-face)
+    (markdown-test-range-has-face (match-beginning 0) (1- (match-end 0)) 
'markdown-table-face)
+
+    (search-forward "Link 2")
+    (markdown-test-range-has-face (match-beginning 0) (1- (match-end 0)) 
'markdown-link-face)
+    (markdown-test-range-has-face (match-beginning 0) (1- (match-end 0)) 
'markdown-table-face)
+
+    (search-forward "link-reference")
+    (markdown-test-range-has-face (match-beginning 0) (1- (match-end 0)) 
'markdown-reference-face)
+    (markdown-test-range-has-face (match-beginning 0) (1- (match-end 0)) 
'markdown-table-face)))
+
 (ert-deftest test-markdown-font-lock/comment-hanging-indent ()
   "Test comments with hanging indentation."
   (markdown-test-string "<!-- This comment has\n    hanging indentation -->"



reply via email to

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