Skip to content

Commit

Permalink
fill-paragraph considers GFM alert syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
syohex committed Nov 7, 2024
1 parent 9f75eda commit 4a4ed7e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
variable `markdown-special-ctrl-a/e`, like Org mode.
- Trailing whitespace characters for line breaks are hidden when using
`markdown-hide-markup`
- `fill-paragraph` considers GFM alert syntax [GH-838][]

* Bug fixes:
- Don't highlight superscript/subscript in math inline/block [GH-802][]
Expand All @@ -35,6 +36,7 @@
[gh-817]: https://github.com/jrblevin/markdown-mode/issues/817
[gh-827]: https://github.com/jrblevin/markdown-mode/issues/827
[gh-834]: https://github.com/jrblevin/markdown-mode/issues/834
[gh-838]: https://github.com/jrblevin/markdown-mode/issues/838
[gh-845]: https://github.com/jrblevin/markdown-mode/issues/845
[gh-848]: https://github.com/jrblevin/markdown-mode/issues/848

Expand Down
5 changes: 5 additions & 0 deletions markdown-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -10305,6 +10305,11 @@ rows and columns and the column alignment."
(setq markdown-link-space-sub-char "-")
(setq markdown-wiki-link-search-subdirectories t)
(setq-local markdown-table-at-point-p-function #'gfm--table-at-point-p)
(setq-local paragraph-separate
(concat paragraph-separate
"\\|"
;; GFM alert syntax
"^>\s-*\\[!\\(?:NOTE\\|TIP\\|IMPORTANT\\|WARNING\\|CAUTION\\)\\]"))
(add-hook 'post-self-insert-hook #'gfm--electric-pair-fence-code-block 'append t)
(markdown-gfm-parse-buffer-for-languages))

Expand Down
10 changes: 10 additions & 0 deletions tests/markdown-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -6107,6 +6107,16 @@ bar baz"
(markdown-fill-paragraph)
(should (string= (buffer-string) "- foo bar baz"))))

(ert-deftest test-markdown-filling/gfm-alert ()
"Fill paragraph at GFM alert."
(let ((levels '("NOTE" "TIP" "IMPORTANT" "WARNING" "CAUTION"))
(template "> [!%s]\foo bar baz"))
(dolist (level levels)
(let ((input (format template level)))
(markdown-test-string-mode 'gfm-mode input
(markdown-fill-paragraph)
(should (string= (buffer-string) input)))))))

;;; Export tests:

(ert-deftest test-markdown-hook/xhtml-standalone ()
Expand Down

0 comments on commit 4a4ed7e

Please sign in to comment.