From 78f1e1ca985657b75fe7fd12d8783d345ba601e7 Mon Sep 17 00:00:00 2001 From: Tim Allen Date: Thu, 15 Mar 2018 18:16:47 +1100 Subject: [PATCH 1/2] Highlight footnote-style hyperlinks. As well as the traditional `[text](url)` syntax, Markdown allows the text to be followed by a tag in square brackets. If the text is followed by nothing at all, then the tag for that link is the text itself. The actual URL is supplied later in the document, like a footnote at the bottom of the page: Some text with [a link][tag] and [another link]. [tag]: http://www.example.com/link1 [another link]: http://www.example.com/link2 This adds the "link" face to the URL in such footnote lines. --- rc/base/markdown.kak | 1 + 1 file changed, 1 insertion(+) diff --git a/rc/base/markdown.kak b/rc/base/markdown.kak index 94466a1ab..c232769fa 100644 --- a/rc/base/markdown.kak +++ b/rc/base/markdown.kak @@ -52,6 +52,7 @@ add-highlighter shared/markdown/content regex [^_](_([^\s_]|([^\s_][^_]*[^\s_])) add-highlighter shared/markdown/content regex [^*](\*\*([^\s*]|([^\s*][^*]*[^\s*]))\*\*)[^*] 1:bold add-highlighter shared/markdown/content regex [^_](__([^\s_]|([^\s_][^_]*[^\s_]))__)[^_] 1:bold add-highlighter shared/markdown/content regex <(([a-z]+://.*?)|((mailto:)?[\w+-]+@[a-z]+[.][a-z]+))> 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 From 0a4a9f1c3d07e75c72c5cbc4fb3d937c9c60d4ef Mon Sep 17 00:00:00 2001 From: Tim Allen Date: Thu, 15 Mar 2018 18:26:20 +1100 Subject: [PATCH 2/2] Markdown inline formatting should not span paragraphs. Previously, two underscore characters in a document would mark the entire space between them as italic, no matter how far apart. Now we only accept a single consecutive newline within an inline-formatted span, so hard-wrapped documents will still format nicely but stray characters won't mess up your entire document. Note that the highlighter for backtick-enclosed spans was modified, even though it's redundant with the code-block highlighting introduced in 5bc62c694. --- rc/base/markdown.kak | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/rc/base/markdown.kak b/rc/base/markdown.kak index c232769fa..c03b5a295 100644 --- a/rc/base/markdown.kak +++ b/rc/base/markdown.kak @@ -46,11 +46,11 @@ add-highlighter shared/markdown/content 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 [^`](``([^\s`]|([^\s`][^`]*[^\s`]))``)[^`] 1:mono -add-highlighter shared/markdown/content regex [^*](\*([^\s*]|([^\s*][^*]*[^\s*]))\*)[^*] 1:italic -add-highlighter shared/markdown/content regex [^_](_([^\s_]|([^\s_][^_]*[^\s_]))_)[^_] 1:italic -add-highlighter shared/markdown/content regex [^*](\*\*([^\s*]|([^\s*][^*]*[^\s*]))\*\*)[^*] 1:bold -add-highlighter shared/markdown/content regex [^_](__([^\s_]|([^\s_][^_]*[^\s_]))__)[^_] 1:bold +add-highlighter shared/markdown/content regex [^`](``([^\s`]|([^\s`](\n?[^\n`])*[^\s`]))``)[^`] 1:mono +add-highlighter shared/markdown/content regex [^*](\*([^\s*]|([^\s*](\n?[^\n*])*[^\s*]))\*)[^*] 1:italic +add-highlighter shared/markdown/content regex [^_](_([^\s_]|([^\s_](\n?[^\n_])*[^\s_]))_)[^_] 1:italic +add-highlighter shared/markdown/content regex [^*](\*\*([^\s*]|([^\s*](\n?[^\n*])*[^\s*]))\*\*)[^*] 1:bold +add-highlighter shared/markdown/content regex [^_](__([^\s_]|([^\s_](\n?[^\n_])*[^\s_]))__)[^_] 1:bold add-highlighter shared/markdown/content regex <(([a-z]+://.*?)|((mailto:)?[\w+-]+@[a-z]+[.][a-z]+))> 0:link add-highlighter shared/markdown/content regex ^\[[^\]\n]*\]:\h*([^\n]*) 1:link add-highlighter shared/markdown/content regex ^\h*(>\h*)+ 0:comment