Skip to content

Commit

Permalink
Respect blockquotes for filling and movement
Browse files Browse the repository at this point in the history
fill-paragraph now respects paragraph boundaries within
blockquotes.  Similarly, forward-paragraph now stops
at blank lines within blockquotes.
  • Loading branch information
jrblevin committed May 9, 2017
1 parent 438e7dd commit 858a9bd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions markdown-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -6615,6 +6615,7 @@ or \\[markdown-toggle-inline-images]."
'(
"\f" ; starts with a literal line-feed
"[ \t\f]*$" ; space-only line
"\\(?:[ \t]*>\\)+[ \t\f]*$"; empty line in blockquote
"[ \t]*[*+-][ \t]+" ; unordered list item
"[ \t]*\\(?:[0-9]+\\|#\\)\\.[ \t]+" ; ordered list item
"[ \t]*\\[\\S-*\\]:[ \t]+" ; link ref def
Expand All @@ -6627,6 +6628,7 @@ or \\[markdown-toggle-inline-images]."
(make-local-variable 'paragraph-separate)
(mapconcat #'identity
'("[ \t\f]*$" ; space-only line
"\\(?:[ \t]*>\\)+[ \t\f]*$"; empty line in blockquote
;; The following is not ideal, but the Fill customization
;; options really only handle paragraph-starting prefixes,
;; not paragraph-ending suffixes:
Expand Down
16 changes: 16 additions & 0 deletions tests/markdown-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -3301,6 +3301,15 @@ date = 2015-08-13 11:35:25 EST
(markdown-beginning-of-block)
(should (= (point) (point-min)))))

(ert-deftest test-markdown-movement/blockquote-paragraphs ()
"Test filling of blockquotes containing multiple paragraphs."
(markdown-test-string "> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\n>\n> Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.\n"
(forward-paragraph)
(should (looking-at "^>$"))
(should (= (point) 128))
(forward-paragraph)
(should (= (point) (point-max)))))

(ert-deftest test-markdown-movement/reference-definition ()
"Test jumping to reference definitions."
;; Jumping to explicit reference definition
Expand Down Expand Up @@ -3461,6 +3470,13 @@ See `adaptive-fill-first-line-regexp'."
(fill-paragraph)
(should (string-equal (buffer-string) "> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do\n> eiusmod tempor incididunt ut labore et dolore magna aliqua."))))

(ert-deftest test-markdown-filling/blockquote-paragraphs ()
"Test filling of blockquotes containing multiple paragraphs."
(markdown-test-string "> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\n>\n> Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.\n"
(forward-paragraph)
(fill-paragraph)
(should (string-equal (buffer-string) "> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\n>\n> Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris\n> nisi ut aliquip ex ea commodo consequat.\n"))))

(ert-deftest test-markdown-filling/space-after-list-marker ()
"`fill-paragraph' should preserve more than one space after a list marker,
since users may wish to indent their lists more than one space more than the
Expand Down

1 comment on commit 858a9bd

@meygerjos
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Please sign in to comment.