From 55b2b8c88dd3dcc8c9ed851b7d634da7e8cc86b8 Mon Sep 17 00:00:00 2001 From: Lennard Hofmann Date: Thu, 23 Sep 2021 14:42:53 +0000 Subject: [PATCH] rc markdown: Fix fenced code blocks The closing ``` in the following example was not detected because the indented code block highlighter was higher up in the hierarchy than the fenced code block highlighter: ``` indented ``` The codeblock highlighter used to be inline so that it has an effect inside listblocks. This commits adds a listblock/codeblock highlighter as a replacement. Fixes #4351 --- rc/filetype/markdown.kak | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/rc/filetype/markdown.kak b/rc/filetype/markdown.kak index cdb17a71..e253ffbb 100644 --- a/rc/filetype/markdown.kak +++ b/rc/filetype/markdown.kak @@ -55,17 +55,21 @@ evaluate-commands %sh{ done } -add-highlighter shared/markdown/inline/codeblock region -match-capture \ - ^(\h*)```\h* \ - ^(\h*)```\h*$ \ - fill meta -add-highlighter shared/markdown/codeblock region "^( {4}|\t)" "$" fill meta - 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*$ \ + fill meta +add-highlighter shared/markdown/listblock/codeblock region -match-capture \ + ^(\h*)```\h* \ + ^(\h*)```\h*$ \ + fill meta +add-highlighter shared/markdown/codeline region "^( {4}|\t)" "$" fill meta + # https://spec.commonmark.org/0.29/#link-destination add-highlighter shared/markdown/angle_bracket_url region (?<=<)([a-z]+://|(mailto|magnet|xmpp):) (?!\\).(?=>)|\n fill link add-highlighter shared/markdown/inline/url region -recurse \( ([a-z]+://|(mailto|magnet|xmpp):) (?!\\).(?=\))|\s fill link