From bea59d560911b1d63e69e047408547596ae1cabd Mon Sep 17 00:00:00 2001 From: Martijn Laarman Date: Mon, 17 Feb 2025 12:00:42 +0100 Subject: [PATCH] Empty url in markdown links should result in an error not warning --- .../Myst/InlineParsers/DiagnosticLinkInlineParser.cs | 2 +- tests/authoring/Inline/InlineLinks.fs | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Elastic.Markdown/Myst/InlineParsers/DiagnosticLinkInlineParser.cs b/src/Elastic.Markdown/Myst/InlineParsers/DiagnosticLinkInlineParser.cs index b75885d89..15ff98b50 100644 --- a/src/Elastic.Markdown/Myst/InlineParsers/DiagnosticLinkInlineParser.cs +++ b/src/Elastic.Markdown/Myst/InlineParsers/DiagnosticLinkInlineParser.cs @@ -119,7 +119,7 @@ private bool ValidateBasicUrl(LinkInline link, InlineProcessor processor, string { if (string.IsNullOrEmpty(url)) { - processor.EmitWarning(link, "Found empty url"); + processor.EmitError(link, "Found empty url"); return false; } diff --git a/tests/authoring/Inline/InlineLinks.fs b/tests/authoring/Inline/InlineLinks.fs index 10a9d6285..4792dcbd5 100644 --- a/tests/authoring/Inline/InlineLinks.fs +++ b/tests/authoring/Inline/InlineLinks.fs @@ -46,3 +46,15 @@ type ``inline link with mailto not allowed external host`` () = [] let ``has warning`` () = markdown |> hasWarning "External URI 'mailto:fake-email@somehost.co' is not allowed." + +type ``empty link should result in an error`` () = + + static let markdown = Setup.Markdown """ +[email me]() +""" + + [] + let ``has no errors`` () = markdown |> hasError "Found empty url" + + [] + let ``has warning`` () = markdown |> hasNoWarnings