From 12c12897ac435ac18d1f055614ab68ab52d73fac Mon Sep 17 00:00:00 2001 From: Jason Blevins Date: Tue, 9 May 2017 10:54:05 -0400 Subject: [PATCH] Basic font lock and filling for definition lists As a side effect, list item navigation and movement should also work. --- markdown-mode.el | 4 ++-- tests/markdown-test.el | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/markdown-mode.el b/markdown-mode.el index 94ea9c1..f0edc75 100644 --- a/markdown-mode.el +++ b/markdown-mode.el @@ -1219,7 +1219,7 @@ Group 1 matches the closing three backticks.") "Regular expression for matching preformatted text sections.") (defconst markdown-regex-list - "^\\([ \t]*\\)\\([0-9#]+\\.\\|[\\*\\+-]\\)\\([ \t]+\\)" + "^\\([ \t]*\\)\\([0-9#]+\\.\\|[\\*\\+:-]\\)\\([ \t]+\\)" "Regular expression for matching list items.") (defconst markdown-regex-bold @@ -6323,7 +6323,7 @@ This is an exact copy of `line-number-at-pos' for use in emacs21." "Return prefix for filling paragraph or nil if not determined." (cond ;; List item inside blockquote - ((looking-at "^[ \t]*>[ \t]*\\(\\(?:[0-9]+\\|#\\)\\.\\|[*+-]\\)[ \t]+") + ((looking-at "^[ \t]*>[ \t]*\\(\\(?:[0-9]+\\|#\\)\\.\\|[*+:-]\\)[ \t]+") (markdown-replace-regexp-in-string "[0-9\\.*+-]" " " (match-string-no-properties 0))) ;; Blockquote diff --git a/tests/markdown-test.el b/tests/markdown-test.el index 01f4cb5..349eb9c 100644 --- a/tests/markdown-test.el +++ b/tests/markdown-test.el @@ -2140,6 +2140,13 @@ Test currently fails because this case isn't handled properly." (should (looking-at "[*+-]")) (markdown-test-range-has-face loc loc markdown-list-face)))) +(ert-deftest test-markdown-font-lock/definition-list () + "A simple definition list marker font lock test." + (markdown-test-file "definition-list.text" + (markdown-test-range-has-face 7 7 'markdown-list-face) + (markdown-test-range-has-face 29 52 'markdown-pre-face) + (markdown-test-range-has-face 55 55 'markdown-list-face))) + (ert-deftest test-markdown-font-lock/pre-1 () "Nested list and pre block font lock test." (markdown-test-file "nested-list.text" @@ -3498,6 +3505,24 @@ spaces after the list marker for a total indentation of four." (fill-paragraph) (should (string-equal (buffer-string) str)))))) +(ert-deftest test-markdown-filling/definition-list-add-leading-spaces () + "`fill-paragraph' should adapt to spaces after list marker." + (markdown-test-string + ": This list item is continued on the next line" + (let ((fill-column 35)) + (fill-paragraph) + (should (string-equal + (buffer-string) + ": This list item is continued on\n the next line"))))) + +(ert-deftest test-markdown-filling/definition-list-preserve-leading-spaces () + "`fill-paragraph' should preserve spaces after list marker." + (let ((str ": This list item is continued on\n the next line") + (fill-column 35)) + (markdown-test-string + str (fill-paragraph) + (should (string-equal (buffer-string) str))))) + (ert-deftest test-markdown-filling/list-item-plus () "Test filling of list items with plus sign markers. See `adaptive-fill-regexp'." -- 2.11.4.GIT