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

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

[nongnu] externals/markdown-mode 39cc717 2/2: Merge pull request #570 fr


From: Stefan Monnier
Subject: [nongnu] externals/markdown-mode 39cc717 2/2: Merge pull request #570 from jrblevin/syohex/569
Date: Fri, 11 Dec 2020 16:04:25 -0500 (EST)

branch: externals/markdown-mode
commit 39cc7176d3ba33d88e02cdd0707d4dac23836977
Merge: dcad557 16f65a0
Author: Shohei YOSHIDA <syohex@gmail.com>
Commit: GitHub <noreply@github.com>

    Merge pull request #570 from jrblevin/syohex/569
    
    Treat too indented line as list if previous line is list
---
 markdown-mode.el       |  8 ++++++--
 tests/markdown-test.el | 25 +++++++++++++++----------
 2 files changed, 21 insertions(+), 12 deletions(-)

diff --git a/markdown-mode.el b/markdown-mode.el
index 3cf0ec7..2e47247 100644
--- a/markdown-mode.el
+++ b/markdown-mode.el
@@ -1154,7 +1154,8 @@ this property is a list with elements of the form (begin 
. end)
 giving the bounds of the current and parent list items."
   (save-excursion
     (goto-char start)
-    (let (bounds level pre-regexp)
+    (let ((prev-list-line -100)
+          bounds level pre-regexp)
       ;; Find a baseline point with zero list indentation
       (markdown-search-backward-baseline)
       ;; Search for all list items between baseline and END
@@ -1171,7 +1172,9 @@ giving the bounds of the current and parent list items."
          ((markdown-new-baseline)
           (setq bounds nil))
          ;; Make sure this is not a line from a pre block
-         ((looking-at-p pre-regexp))
+         ((and (looking-at-p pre-regexp)
+               ;; too indented line is also treated as list if previous line 
is list
+               (>= (- (line-number-at-pos) prev-list-line) 2)))
          ;; If not, then update levels and propertize list item when in range.
          (t
           (let* ((indent (current-indentation))
@@ -1182,6 +1185,7 @@ giving the bounds of the current and parent list items."
             (setq bounds (markdown--append-list-item-bounds
                           marker indent cur-bounds bounds))
           (when (and (<= start (point)) (<= (point) end))
+            (setq prev-list-line (line-number-at-pos first))
             (put-text-property first last 'markdown-list-item bounds)))))
         (end-of-line)))))
 
diff --git a/tests/markdown-test.el b/tests/markdown-test.el
index 0983a4b..16e8ebb 100644
--- a/tests/markdown-test.el
+++ b/tests/markdown-test.el
@@ -2650,16 +2650,21 @@ See 
https://github.com/jrblevin/markdown-mode/issues/405 ."
     * level 3
       * level 4
         * level 5"
-      (markdown-test-range-has-face 62 62 'markdown-list-face)))
-
-  (let ((markdown-list-indent-width 4))
-    (markdown-test-string "
-* level 1
-  * level 2
-    * level 3
-      * level 4
-        * level 5"
-      (markdown-test-range-has-face 62 62 nil))))
+      (markdown-test-range-has-face 62 62 'markdown-list-face))))
+
+(ert-deftest test-markdown-font-lock/lists-3 ()
+  "Test markdown-list-face for too intended line.
+Too indented line is also treated as list rf previous line is line
+in Common mark.
+See https://github.com/jrblevin/markdown-mode/issues/569";
+  (markdown-test-string "* [ ] One
+  * [ ] Two
+    * [ ] Three
+      * [ ] Four
+        * [ ] Five
+          * [ ] Six"
+    (markdown-test-range-has-face 64 64 'markdown-list-face)
+    (markdown-test-range-has-face 85 85 'markdown-list-face)))
 
 (ert-deftest test-markdown-font-lock/definition-list ()
   "A simple definition list marker font lock test."



reply via email to

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