Skip to content

Commit 30137f3

Browse files
committed
Don't insert list item if here is in code block
1 parent 9fd2661 commit 30137f3

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

CHANGES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
- Mark `markdown-css-paths` safe as file local variables [GH-834][]
3434
- Resolve style sheets in `markdown-css-paths` relative to the Markdown file
3535
(if the path starts with `./` or `../`) [GH-855][] [GH-870][]
36+
- Don't insert list item in code block [GH-841][]
3637

3738
[gh-780]: https://github.com/jrblevin/markdown-mode/issues/780
3839
[gh-802]: https://github.com/jrblevin/markdown-mode/issues/802
@@ -43,6 +44,7 @@
4344
[gh-834]: https://github.com/jrblevin/markdown-mode/issues/834
4445
[gh-838]: https://github.com/jrblevin/markdown-mode/issues/838
4546
[gh-839]: https://github.com/jrblevin/markdown-mode/issues/839
47+
[gh-841]: https://github.com/jrblevin/markdown-mode/issues/841
4648
[gh-845]: https://github.com/jrblevin/markdown-mode/issues/845
4749
[gh-848]: https://github.com/jrblevin/markdown-mode/issues/848
4850
[gh-855]: https://github.com/jrblevin/markdown-mode/issues/855

markdown-mode.el

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5188,6 +5188,7 @@ list simply adds a blank line)."
51885188
(markdown-indent-on-enter
51895189
(let (bounds)
51905190
(if (and (memq markdown-indent-on-enter '(indent-and-new-item))
5191+
(not (markdown-code-block-at-point-p))
51915192
(setq bounds (markdown-cur-list-item-bounds)))
51925193
(let ((beg (cl-first bounds))
51935194
(end (cl-second bounds))

tests/markdown-test.el

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2109,6 +2109,17 @@ See GH-245."
21092109
(should (string-equal (buffer-string) " - [X] item\n\n"))
21102110
(should (= (point) 18)))))
21112111

2112+
(ert-deftest test-markdown-indentation/not-insert-list-item-in-code-block ()
2113+
"Don't insert new item if here is in code."
2114+
(let ((markdown-indent-on-enter 'indent-and-new-item))
2115+
(markdown-test-string "```
2116+
- foo
2117+
```"
2118+
(forward-line)
2119+
(end-of-line)
2120+
(call-interactively #'markdown-enter-key)
2121+
(should-not (looking-back "- ")))))
2122+
21122123
;;; Markup hiding tests:
21132124

21142125
(ert-deftest test-markdown-markup-hiding/italics-1 ()

0 commit comments

Comments
 (0)