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

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

[nongnu] elpa/markdown-mode 35e22965b1 2/3: Merge pull request #779 from


From: ELPA Syncer
Subject: [nongnu] elpa/markdown-mode 35e22965b1 2/3: Merge pull request #779 from kuranari/modify-markdown-regex-header
Date: Thu, 20 Jul 2023 22:01:11 -0400 (EDT)

branch: elpa/markdown-mode
commit 35e22965b12cf42e6c260f35dd2cbd14bf70df59
Merge: 0a7404a1c7 eba1baf31e
Author: Shohei YOSHIDA <syohex@gmail.com>
Commit: GitHub <noreply@github.com>

    Merge pull request #779 from kuranari/modify-markdown-regex-header
    
    Require a space before the closing sequence of an atx heade
---
 CHANGES.md             |  1 +
 markdown-mode.el       |  2 +-
 tests/markdown-test.el | 15 ++++++++++++++-
 3 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/CHANGES.md b/CHANGES.md
index 99cddab083..f2bd099bee 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -5,6 +5,7 @@
 *   **Breaking changes:**
     - GNU Emacs 26.1 or later is required.
     - Don't allow space between label and text in reference link same as 
CommonMark [GH-774][]
+    - Whitespace is required before the closing sequence of an atx header. 
[GH-778][]
 
 *   New Features:
     - Introduce `markdown-fontify-whole-heading-line` variable for highlighting
diff --git a/markdown-mode.el b/markdown-mode.el
index 521e191aba..9d260648ec 100644
--- a/markdown-mode.el
+++ b/markdown-mode.el
@@ -732,7 +732,7 @@ Group 2 matches only the label, without the surrounding 
markup.
 Group 3 matches the closing square bracket.")
 
 (defconst markdown-regex-header
-  "^\\(?:\\(?1:[^\r\n\t -].*\\)\n\\(?:\\(?2:=+\\)\\|\\(?3:-+\\)\\)\\|\\(?4:#+[ 
\t]+\\)\\(?5:.*?\\)\\(?6:[ \t]*#*\\)\\)$"
+  "^\\(?:\\(?1:[^\r\n\t -].*\\)\n\\(?:\\(?2:=+\\)\\|\\(?3:-+\\)\\)\\|\\(?4:#+[ 
\t]+\\)\\(?5:.*?\\)\\(?6:[ \t]+#+\\)?\\)$"
   "Regexp identifying Markdown headings.
 Group 1 matches the text of a setext heading.
 Group 2 matches the underline of a level-1 setext heading.
diff --git a/tests/markdown-test.el b/tests/markdown-test.el
index b5c26a7eb2..0793667ef7 100644
--- a/tests/markdown-test.el
+++ b/tests/markdown-test.el
@@ -3013,6 +3013,16 @@ puts markdown.to_html
       (markdown-test-range-has-face 70 72 'font-lock-builtin-face) ; puts
       (markdown-test-range-has-face 92 94 'markdown-markup-face)))) ; ```
 
+(ert-deftest test-markdown-font-lock/atx-headers ()
+  "Test font-lock for atx headers"
+  (markdown-test-string "## abc  "
+    (markdown-test-range-has-face 1 3 'markdown-header-delimiter-face)
+    (markdown-test-range-has-face 4 8 'markdown-header-face-2))
+  (markdown-test-string "## abc ##"
+    (markdown-test-range-has-face 1 3 'markdown-header-delimiter-face)
+    (markdown-test-range-has-face 4 6 'markdown-header-face-2)
+    (markdown-test-range-has-face 7 9 'markdown-header-delimiter-face)))
+
 (ert-deftest test-markdown-font-lock/atx-no-spaces ()
   "Test font-lock for atx headers with no spaces."
   (markdown-test-string "##abc##"
@@ -3020,7 +3030,10 @@ puts markdown.to_html
   (markdown-test-string "##"
     (markdown-test-range-has-face 1 2 nil))
   (markdown-test-string "###"
-    (markdown-test-range-has-face 1 3 nil)))
+    (markdown-test-range-has-face 1 3 nil))
+  (markdown-test-string "## abc##"
+    (markdown-test-range-has-face 1 3 'markdown-header-delimiter-face)
+    (markdown-test-range-has-face 4 8 'markdown-header-face-2)))
 
 (ert-deftest test-markdown-font-lock/atx-whole-line ()
   "Test font-lock for atx headers with whole line flag."



reply via email to

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