rc markdown: use language highlighting also for indented code blocks inside lists

This commit is contained in:
Johannes Altmanninger 2022-08-16 19:44:08 +02:00
parent 615ec3ef7e
commit feb912fb9f

View File

@ -41,6 +41,11 @@ add-highlighter shared/markdown regions
add-highlighter shared/markdown/inline default-region regions add-highlighter shared/markdown/inline default-region regions
add-highlighter shared/markdown/inline/text default-region group 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{ evaluate-commands %sh{
languages=" languages="
awk c cabal clojure coffee cpp crystal css cucumber d diff dockerfile elixir erlang fish 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 ruby rust sass scala scss sh swift toml tupfile typescript yaml sql
" "
for lang in ${languages}; do 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 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}" 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/%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 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 \ add-highlighter shared/markdown/codeblock region -match-capture \
^(\h*)```\h* \ ^(\h*)```\h* \
^(\h*)```\h*$ \ ^(\h*)```\h*$ \