From feb912fb9f2e706b88c8b93bc2d9229a768d249d Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Tue, 16 Aug 2022 19:44:08 +0200 Subject: [PATCH] rc markdown: use language highlighting also for indented code blocks inside lists --- rc/filetype/markdown.kak | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/rc/filetype/markdown.kak b/rc/filetype/markdown.kak index 3db7ca1d6..599dfd5db 100644 --- a/rc/filetype/markdown.kak +++ b/rc/filetype/markdown.kak @@ -41,6 +41,11 @@ add-highlighter shared/markdown regions add-highlighter shared/markdown/inline default-region regions add-highlighter shared/markdown/inline/text default-region group +add-highlighter shared/markdown/listblock region ^\h*[-*]\s ^(?=\S) regions +add-highlighter shared/markdown/listblock/g default-region group +add-highlighter shared/markdown/listblock/g/ ref markdown/inline +add-highlighter shared/markdown/listblock/g/marker regex ^\h*([-*])\s 1:bullet + evaluate-commands %sh{ languages=" awk c cabal clojure coffee cpp crystal css cucumber d diff dockerfile elixir erlang fish @@ -49,18 +54,16 @@ evaluate-commands %sh{ ruby rust sass scala scss sh swift toml tupfile typescript yaml sql " for lang in ${languages}; do + [ "${lang}" = kak ] && ref=kakrc || ref="${lang}" printf 'add-highlighter shared/markdown/%s region -match-capture ^(\h*)```\h*(%s\\b|\\{[.=]?%s\\}) ^(\h*)``` regions\n' "${lang}" "${lang}" "${lang}" printf 'add-highlighter shared/markdown/%s/ default-region fill meta\n' "${lang}" - [ "${lang}" = kak ] && ref=kakrc || ref="${lang}" printf 'add-highlighter shared/markdown/%s/inner region \A\h*```[^\\n]*\K (?=```) ref %s\n' "${lang}" "${ref}" + printf 'add-highlighter shared/markdown/listblock/%s region -match-capture ^(\h*)```\h*(%s\\b|\\{[.=]?%s\\}) ^(\h*)``` regions\n' "${lang}" "${lang}" "${lang}" + printf 'add-highlighter shared/markdown/listblock/%s/ default-region fill meta\n' "${lang}" + printf 'add-highlighter shared/markdown/listblock/%s/inner region \A\h*```[^\\n]*\K (?=```) ref %s\n' "${lang}" "${ref}" done } -add-highlighter shared/markdown/listblock region ^\h*[-*]\s ^(?=\S) regions -add-highlighter shared/markdown/listblock/g default-region group -add-highlighter shared/markdown/listblock/g/ ref markdown/inline -add-highlighter shared/markdown/listblock/g/marker regex ^\h*([-*])\s 1:bullet - add-highlighter shared/markdown/codeblock region -match-capture \ ^(\h*)```\h* \ ^(\h*)```\h*$ \