[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/markdown-mode ae19974705 1/3: Fix fontification of repeate
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/markdown-mode ae19974705 1/3: Fix fontification of repeated lists and tables |
Date: |
Tue, 18 Jan 2022 09:58:16 -0500 (EST) |
branch: elpa/markdown-mode
commit ae19974705c14616ee7c4aef6cbc025169310cfe
Author: Vitalie Spinu <spinuvit@gmail.com>
Commit: Vitalie Spinu <spinuvit@gmail.com>
Fix fontification of repeated lists and tables
---
markdown-mode.el | 52 ++++++++++++++++++++++----------------------
tests/markdown-test.el | 13 +++++++++++
tests/repeated-elements.text | 23 ++++++++++++++++++++
3 files changed, 62 insertions(+), 26 deletions(-)
diff --git a/markdown-mode.el b/markdown-mode.el
index dc2d319fc4..119aec3be9 100644
--- a/markdown-mode.el
+++ b/markdown-mode.el
@@ -3426,11 +3426,11 @@ SEQ may be an atom or a sequence."
t))
(defun markdown-fontify-tables (last)
- (when (and (re-search-forward "|" last t)
- (markdown-table-at-point-p))
- (font-lock-append-text-property
- (line-beginning-position) (min (1+ (line-end-position)) (point-max))
- 'face 'markdown-table-face)
+ (when (re-search-forward "|" last t)
+ (when (markdown-table-at-point-p)
+ (font-lock-append-text-property
+ (line-beginning-position) (min (1+ (line-end-position)) (point-max))
+ 'face 'markdown-table-face))
(forward-line 1)
t))
@@ -3450,27 +3450,27 @@ SEQ may be an atom or a sequence."
(defun markdown-fontify-list-items (last)
"Apply font-lock properties to list markers from point to LAST."
- (when (and (markdown-match-list-items last)
- (not (markdown-code-block-at-point-p (match-beginning 2))))
- (let* ((indent (length (match-string-no-properties 1)))
- (level (/ indent markdown-list-indent-width)) ;; level = 0, 1, 2,
...
- (bullet (nth (mod level (length markdown-list-item-bullets))
- markdown-list-item-bullets)))
- (add-text-properties
- (match-beginning 2) (match-end 2) '(face markdown-list-face))
- (when markdown-hide-markup
- (cond
- ;; Unordered lists
- ((string-match-p "[\\*\\+-]" (match-string 2))
- (add-text-properties
- (match-beginning 2) (match-end 2) `(display ,bullet)))
- ;; Definition lists
- ((string-equal ":" (match-string 2))
- (let ((display-string
- (char-to-string (markdown--first-displayable
- markdown-definition-display-char))))
- (add-text-properties (match-beginning 2) (match-end 2)
- `(display ,display-string)))))))
+ (when (markdown-match-list-items last)
+ (when (not (markdown-code-block-at-point-p (match-beginning 2)))
+ (let* ((indent (length (match-string-no-properties 1)))
+ (level (/ indent markdown-list-indent-width)) ;; level = 0, 1, 2,
...
+ (bullet (nth (mod level (length markdown-list-item-bullets))
+ markdown-list-item-bullets)))
+ (add-text-properties
+ (match-beginning 2) (match-end 2) '(face markdown-list-face))
+ (when markdown-hide-markup
+ (cond
+ ;; Unordered lists
+ ((string-match-p "[\\*\\+-]" (match-string 2))
+ (add-text-properties
+ (match-beginning 2) (match-end 2) `(display ,bullet)))
+ ;; Definition lists
+ ((string-equal ":" (match-string 2))
+ (let ((display-string
+ (char-to-string (markdown--first-displayable
+ markdown-definition-display-char))))
+ (add-text-properties (match-beginning 2) (match-end 2)
+ `(display ,display-string))))))))
t))
(defun markdown-fontify-hrs (last)
diff --git a/tests/markdown-test.el b/tests/markdown-test.el
index fcf7d53118..6042cea2e6 100644
--- a/tests/markdown-test.el
+++ b/tests/markdown-test.el
@@ -2795,6 +2795,19 @@ See https://github.com/jrblevin/markdown-mode/issues/631"
(should-not (markdown-range-property-any 9 9 'face '(markdown-list-face)))
(should-not (markdown-range-property-any 16 16 'face
'(markdown-list-face)))))
+
+(ert-deftest test-markdown-font-lock/repeated-lists ()
+ "A simple definition list marker font lock test."
+ (markdown-test-file "repeated-elements.text"
+ (markdown-test-range-has-face 163 164 'markdown-list-face)
+ (markdown-test-range-has-face 190 191 'markdown-list-face)))
+
+(ert-deftest test-markdown-font-lock/repeated-tables ()
+ "A simple definition list marker font lock test."
+ (markdown-test-file "repeated-elements.text"
+ (markdown-test-range-has-face 149 155 nil)
+ (markdown-test-range-has-face 218 336 'markdown-table-face)))
+
(ert-deftest test-markdown-font-lock/definition-list ()
"A simple definition list marker font lock test."
(markdown-test-file "definition-list.text"
diff --git a/tests/repeated-elements.text b/tests/repeated-elements.text
new file mode 100644
index 0000000000..01c157b9d1
--- /dev/null
+++ b/tests/repeated-elements.text
@@ -0,0 +1,23 @@
+Markdown Repeated Elements
+==========================
+
+```fortran
+*
+PROGRAM EUCLID
+```
+
+1. This is an ordered list
+2. With a second element.
+
+fake |table| sfds
+
+1. This is an ordered list
+2. With a second element.
+
+
+| Syntax | Description |
+| ----------- | ----------- |
+| Header | Title |
+| Paragraph | Text |
+
+