Consecutive markdown list bullets are not a valid list prefix.
Previously, if you opened a new line after an underlined heading (what the CommonMark spec calls a "Setext heading") or inserted a newline into a line that started with `**strong emphasis**` the Markdown autoindent hook would assume the leading symbols were list bullets and paste them at the beginning of the new line. However, the CommonMark specification says that list bullets must be followed by at least one horizontal whitespace character, so Setext heading underlines and strong emphasis are not valid list bullets and should not be matched by the autoindent pattern. This commit changes the regex that selects the pastable prefix of the previous line so that it must match either: - One or more `>` characters with optional whitespace between them (a blockquote prefix), optionally followed by a list bullet; or - An optional blockquote prefix and a list bullet Since we don't strictly need either the blockquote prefix nor the list bullet, we could concievably just make both optional... but for lines without either, the regex would find a zero-length match, and for the purposes of copy/paste Kakoune treats that as a one-character match. Therefore, the regex is written to fail if neither pattern is found.
This commit is contained in:
parent
8a6df93dc6
commit
e640e6d859
|
@ -127,7 +127,7 @@ add-highlighter -group /markdown/content regex \H\K\h\h$ 0:PrimarySelection
|
||||||
def -hidden markdown-indent-on-new-line %{
|
def -hidden markdown-indent-on-new-line %{
|
||||||
eval -draft -itersel %{
|
eval -draft -itersel %{
|
||||||
# copy block quote(s), list item prefix and following white spaces
|
# copy block quote(s), list item prefix and following white spaces
|
||||||
try %{ exec -draft k <a-x> s ^\h*\K((>\h*)|[*+-])+\h* <ret> y gh j P }
|
try %{ exec -draft k <a-x> s ^\h*\K((>\h*)+([*+-]\h)?|(>\h*)*[*+-]\h)\h* <ret> y gh j P }
|
||||||
# preserve previous line indent
|
# preserve previous line indent
|
||||||
try %{ exec -draft \; K <a-&> }
|
try %{ exec -draft \; K <a-&> }
|
||||||
# remove trailing white spaces
|
# remove trailing white spaces
|
||||||
|
|
1
test/indent/markdown/inside-strong-emphasis/cmd
Normal file
1
test/indent/markdown/inside-strong-emphasis/cmd
Normal file
|
@ -0,0 +1 @@
|
||||||
|
i<ret><esc>
|
1
test/indent/markdown/inside-strong-emphasis/in
Normal file
1
test/indent/markdown/inside-strong-emphasis/in
Normal file
|
@ -0,0 +1 @@
|
||||||
|
**strong %(e)mphasis**
|
2
test/indent/markdown/inside-strong-emphasis/out
Normal file
2
test/indent/markdown/inside-strong-emphasis/out
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
**strong
|
||||||
|
emphasis**
|
3
test/indent/markdown/inside-strong-emphasis/rc
Normal file
3
test/indent/markdown/inside-strong-emphasis/rc
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
source "%val{runtime}/colors/default.kak"
|
||||||
|
source "%val{runtime}/rc/base/markdown.kak"
|
||||||
|
set buffer filetype markdown
|
1
test/indent/markdown/open-after-setext-heading-2/cmd
Normal file
1
test/indent/markdown/open-after-setext-heading-2/cmd
Normal file
|
@ -0,0 +1 @@
|
||||||
|
o
|
2
test/indent/markdown/open-after-setext-heading-2/in
Normal file
2
test/indent/markdown/open-after-setext-heading-2/in
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
Some Heading
|
||||||
|
%(-)-----------
|
3
test/indent/markdown/open-after-setext-heading-2/out
Normal file
3
test/indent/markdown/open-after-setext-heading-2/out
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
Some Heading
|
||||||
|
------------
|
||||||
|
|
3
test/indent/markdown/open-after-setext-heading-2/rc
Normal file
3
test/indent/markdown/open-after-setext-heading-2/rc
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
source "%val{runtime}/colors/default.kak"
|
||||||
|
source "%val{runtime}/rc/base/markdown.kak"
|
||||||
|
set buffer filetype markdown
|
Loading…
Reference in New Issue
Block a user