From f65d5210f892220f637e1c32db53bc35d2501df5 Mon Sep 17 00:00:00 2001 From: Lennard Hofmann Date: Tue, 5 Jan 2021 18:51:37 +0100 Subject: [PATCH 1/2] rc markdown: Prevent underscores in URLs cause italic highlighting Create regions to achieve that. Add support for inline links. --- rc/filetype/markdown.kak | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/rc/filetype/markdown.kak b/rc/filetype/markdown.kak index be7678c97..5a65a5d7c 100644 --- a/rc/filetype/markdown.kak +++ b/rc/filetype/markdown.kak @@ -59,9 +59,17 @@ add-highlighter shared/markdown/codeblock region -match-capture \ ^(\h*)```\h*$ \ fill meta -add-highlighter shared/markdown/listblock region ^\h*[-*]\s ^\h*((?=[-*])|$) group -add-highlighter shared/markdown/listblock/ ref markdown/inline -add-highlighter shared/markdown/listblock/marker regex ^\h*([-*])\s 1:bullet +add-highlighter shared/markdown/listblock region ^\h*[-*]\s ^\h*((?=[-*])|$) 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 + +# https://spec.commonmark.org/0.29/#link-destination +# This repetition is not pretty but shell escaping is worse +add-highlighter shared/markdown/angle_bracket_url region (?<=<)([a-z]+://|(mailto|magnet|xmpp):) (?!\\).(?=>)|\n fill link +add-highlighter shared/markdown/url region -recurse \( ([a-z]+://|(mailto|magnet|xmpp):) (?!\\).(?=\))|\s fill link +add-highlighter shared/markdown/listblock/angle_bracket_url region (?<=<)([a-z]+://|(mailto|magnet|xmpp):) (?!\\).(?=>)|\n fill link +add-highlighter shared/markdown/listblock/url region -recurse \( ([a-z]+://|(mailto|magnet|xmpp):) (?!\\).(?=\))|\s fill link add-highlighter shared/markdown/inline/code region -match-capture (`+) (`+) fill mono @@ -76,8 +84,6 @@ 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( {2,})$" 1:+r@meta From 61fabee03f5b175f85608d3035e84a8ff309cb99 Mon Sep 17 00:00:00 2001 From: Lennard Hofmann Date: Tue, 5 Jan 2021 19:09:33 +0100 Subject: [PATCH 2/2] rc markdown: Highlight HTML tags --- rc/filetype/markdown.kak | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rc/filetype/markdown.kak b/rc/filetype/markdown.kak index 5a65a5d7c..78d93c985 100644 --- a/rc/filetype/markdown.kak +++ b/rc/filetype/markdown.kak @@ -71,6 +71,11 @@ add-highlighter shared/markdown/url region -recurse \( ([a-z]+://|(mailto|magnet add-highlighter shared/markdown/listblock/angle_bracket_url region (?<=<)([a-z]+://|(mailto|magnet|xmpp):) (?!\\).(?=>)|\n fill link add-highlighter shared/markdown/listblock/url region -recurse \( ([a-z]+://|(mailto|magnet|xmpp):) (?!\\).(?=\))|\s fill link +try %{ + require-module html + add-highlighter shared/markdown/tag region (?i))) > ref html/tag +} + add-highlighter shared/markdown/inline/code region -match-capture (`+) (`+) fill mono # Setext-style header