From 9053a1cdc1db04bf3fe85646058b4f1a6bf43066 Mon Sep 17 00:00:00 2001 From: lePerdu Date: Thu, 8 Nov 2018 12:44:03 -0500 Subject: [PATCH] Make list items match as regions --- rc/base/markdown.kak | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/rc/base/markdown.kak b/rc/base/markdown.kak index d7dc65e2..e8f30028 100644 --- a/rc/base/markdown.kak +++ b/rc/base/markdown.kak @@ -12,7 +12,8 @@ hook global BufCreate .*[.](markdown|md|mkd) %{ # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/markdown regions -add-highlighter shared/markdown/content default-region group +add-highlighter shared/markdown/inline default-region regions +add-highlighter shared/markdown/inline/text default-region group evaluate-commands %sh{ languages=" @@ -33,25 +34,31 @@ add-highlighter shared/markdown/codeblock region -match-capture \ ^(\h*)```\h* \ ^(\h*)```\h*$ \ fill meta -add-highlighter shared/markdown/codespan region -match-capture (`+) (`+) fill mono + +add-highlighter shared/markdown/listblock region -match-capture ^\h*[-*]\s ^\h*(?=[-*\n]) ref markdown/inline + +add-highlighter shared/markdown/inline/code region -match-capture (`+) (`+) fill mono # Setext-style header -add-highlighter shared/markdown/content/ regex (\A|\n\n)[^\n]+\n={2,}\h*\n\h*$ 0:title -add-highlighter shared/markdown/content/ regex (\A|\n\n)[^\n]+\n-{2,}\h*\n\h*$ 0:header +add-highlighter shared/markdown/inline/text/ regex (\A|\n\n)[^\n]+\n={2,}\h*\n\h*$ 0:title +add-highlighter shared/markdown/inline/text/ regex (\A|\n\n)[^\n]+\n-{2,}\h*\n\h*$ 0:header # Atx-style header -add-highlighter shared/markdown/content/ regex ^(#+)(\h+)([^\n]+) 1:header +add-highlighter shared/markdown/inline/text/ regex ^(#+)(\h+)([^\n]+) 1:header -add-highlighter shared/markdown/content/ regex ^\h?((?:[\s\t]+)?[-\*])\h+[^\n]*(\n\h+[^-\*]\S+[^\n]*\n)*$ 0:list 1:bullet -add-highlighter shared/markdown/content/ regex \B\+[^\n]+?\+\B 0:mono -add-highlighter shared/markdown/content/ regex (? 0:link -add-highlighter shared/markdown/content/ regex ^\[[^\]\n]*\]:\h*([^\n]*) 1:link -add-highlighter shared/markdown/content/ regex ^\h*(>\h*)+ 0:comment -add-highlighter shared/markdown/content/ regex \H\K\h\h$ 0:PrimarySelection +# This is kind of redundant since there is already a listblock highlighter but +# that can't just highlight the list marker +add-highlighter shared/markdown/inline/text/ regex ^\h*[-*]\s 0:bullet + +add-highlighter shared/markdown/inline/text/ regex \B\+[^\n]+?\+\B 0:mono +add-highlighter shared/markdown/inline/text/ regex (? 0:link +add-highlighter shared/markdown/inline/text/ regex ^\[[^\]\n]*\]:\h*([^\n]*) 1:link +add-highlighter shared/markdown/inline/text/ regex ^\h*(>\h*)+ 0:comment +add-highlighter shared/markdown/inline/text/ regex \H\K\h\h$ 0:PrimarySelection # Commands # ‾‾‾‾‾‾‾‾