diff --git a/CHANGES.md b/CHANGES.md index 8f28a896..58748f5a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -33,6 +33,7 @@ - Mark `markdown-css-paths` safe as file local variables [GH-834][] - Resolve style sheets in `markdown-css-paths` relative to the Markdown file (if the path starts with `./` or `../`) [GH-855][] [GH-870][] + - Don't insert list item in code block [GH-841][] [gh-780]: https://github.com/jrblevin/markdown-mode/issues/780 [gh-802]: https://github.com/jrblevin/markdown-mode/issues/802 @@ -43,6 +44,7 @@ [gh-834]: https://github.com/jrblevin/markdown-mode/issues/834 [gh-838]: https://github.com/jrblevin/markdown-mode/issues/838 [gh-839]: https://github.com/jrblevin/markdown-mode/issues/839 + [gh-841]: https://github.com/jrblevin/markdown-mode/issues/841 [gh-845]: https://github.com/jrblevin/markdown-mode/issues/845 [gh-848]: https://github.com/jrblevin/markdown-mode/issues/848 [gh-855]: https://github.com/jrblevin/markdown-mode/issues/855 diff --git a/markdown-mode.el b/markdown-mode.el index fc01170a..f99897db 100644 --- a/markdown-mode.el +++ b/markdown-mode.el @@ -5188,6 +5188,7 @@ list simply adds a blank line)." (markdown-indent-on-enter (let (bounds) (if (and (memq markdown-indent-on-enter '(indent-and-new-item)) + (not (markdown-code-block-at-point-p)) (setq bounds (markdown-cur-list-item-bounds))) (let ((beg (cl-first bounds)) (end (cl-second bounds)) diff --git a/tests/markdown-test.el b/tests/markdown-test.el index 66ecf298..83059bf7 100644 --- a/tests/markdown-test.el +++ b/tests/markdown-test.el @@ -2109,6 +2109,17 @@ See GH-245." (should (string-equal (buffer-string) " - [X] item\n\n")) (should (= (point) 18))))) +(ert-deftest test-markdown-indentation/not-insert-list-item-in-code-block () + "Don't insert new item if here is in code." + (let ((markdown-indent-on-enter 'indent-and-new-item)) + (markdown-test-string "``` + - foo +```" + (forward-line) + (end-of-line) + (call-interactively #'markdown-enter-key) + (should-not (looking-back "- "))))) + ;;; Markup hiding tests: (ert-deftest test-markdown-markup-hiding/italics-1 ()