Skip to content

Commit

Permalink
Prohibit setext headers from starting with spaces
Browse files Browse the repository at this point in the history
Avoids ambiguity between setext headings and in-progress lists (e.g.,
when the point is at X below):

- foo
    - bar
-X

Closes GH-143.
  • Loading branch information
jrblevin committed Jun 11, 2016
1 parent 437713d commit 0b907b9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions markdown-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -1277,7 +1277,7 @@ Group 2 matches only the label, without the surrounding markup.
Group 3 matches the closing square bracket.")

(defconst markdown-regex-header
"^\\(?:\\([^\r\n-].*\\)\n\\(?:\\(=+\\)\\|\\(-+\\)\\)\\|\\(#+\\)[ \t]+\\(.*?\\)[ \t]*\\(#*\\)\\)$"
"^\\(?:\\([^\r\n- ].*\\)\n\\(?:\\(=+\\)\\|\\(-+\\)\\)\\|\\(#+\\)[ \t]+\\(.*?\\)[ \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.
Expand All @@ -1287,7 +1287,7 @@ Group 5 matches the text, without surrounding whitespace, of an atx heading.
Group 6 matches the closing hash marks of an atx heading.")

(defconst markdown-regex-header-setext
"^\\([^\r\n-].*\\)\n\\(=+\\|-+\\)$"
"^\\([^\r\n- ].*\\)\n\\(=+\\|-+\\)$"
"Regular expression for generic setext-style (underline) headers.")

(defconst markdown-regex-header-atx
Expand Down
2 changes: 1 addition & 1 deletion tests/markdown-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -1455,7 +1455,7 @@ the opening bracket of [^2], and then subsequent functions would kill [^2])."

(ert-deftest test-markdown-complete/setext-header ()
"Test `markdown-complete' for setext headers."
(markdown-test-string " test \n=="
(markdown-test-string "test \n=="
(call-interactively 'markdown-complete)
(should (string-equal (buffer-string) "test\n===="))))

Expand Down

0 comments on commit 0b907b9

Please sign in to comment.