diff --git a/rc/filetype/markdown.kak b/rc/filetype/markdown.kak index 3aaf1c45..599dfd5d 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```[^\\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 } -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*$ \ @@ -124,7 +127,7 @@ define-command -hidden markdown-indent-on-new-line %{ define-command -hidden markdown-load-languages %{ evaluate-commands -draft %{ try %{ execute-keys 'gtGbGls```\h*\{?[.=]?\K[^}\s]+' - evaluate-commands -itersel %{ require-module %val{selection} } + evaluate-commands -itersel %{ try %{ require-module %val{selection} } } }} } diff --git a/rc/filetype/restructuredtext.kak b/rc/filetype/restructuredtext.kak index 434525a5..b1a69806 100644 --- a/rc/filetype/restructuredtext.kak +++ b/rc/filetype/restructuredtext.kak @@ -33,7 +33,7 @@ evaluate-commands %sh{ perl pug python ragel ruby rust sass scala scss sh swift \ tupfile yaml; do if [ "$ft" = kak ]; then ref="kakrc"; else ref="$ft"; fi - printf 'add-highlighter shared/restructuredtext/%s region %s %s ref %s\n' "$ft" '\.\.\h*'$ft'::\h*c\h*\n' '^(?=\S)' "$ref" + printf 'add-highlighter shared/restructuredtext/%s region %s %s ref %s\n' "$ft" "\.\.\h*code-block::\h*$ft\h*\n" '^(?=\S)' "$ref" done }