From cc40c6fcbf8113510691f8414a66dd0fb99785c3 Mon Sep 17 00:00:00 2001 From: Martijn Laarman Date: Mon, 17 Feb 2025 12:00:42 +0100 Subject: [PATCH 1/2] Empty url in markdown links should result in an error not warning (cherry picked from commit bea59d560911b1d63e69e047408547596ae1cabd) --- .../Myst/InlineParsers/DiagnosticLinkInlineParser.cs | 2 +- tests/authoring/Inline/InlineLinks.fs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Elastic.Markdown/Myst/InlineParsers/DiagnosticLinkInlineParser.cs b/src/Elastic.Markdown/Myst/InlineParsers/DiagnosticLinkInlineParser.cs index a350aa533..e8cdedbbd 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 cb599316c..07c907f0e 100644 --- a/tests/authoring/Inline/InlineLinks.fs +++ b/tests/authoring/Inline/InlineLinks.fs @@ -45,7 +45,7 @@ type ``inline link with mailto not allowed external host`` () = let ``has no errors`` () = markdown |> hasNoErrors [] - let ``has warning`` () = markdown |> hasWarning "mailto links should be to elastic.co domains." + let ``has error`` () = markdown |> hasWarning "External URI 'mailto:fake-email@somehost.co' is not allowed." type ``empty link should result in an error`` () = @@ -54,7 +54,7 @@ type ``empty link should result in an error`` () = """ [] - let ``should warn`` () = markdown |> hasWarning "Found empty url" + let ``has error`` () = markdown |> hasError "Found empty url" [] - let ``has no erros`` () = markdown |> hasNoErrors + let ``has no warnings`` () = markdown |> hasNoWarnings From 90e4ca726f7018f47715f16aaa2585c238527455 Mon Sep 17 00:00:00 2001 From: Martijn Laarman Date: Mon, 17 Feb 2025 17:22:31 +0100 Subject: [PATCH 2/2] fix cherry-pick update test failure --- tests/authoring/Inline/InlineLinks.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/authoring/Inline/InlineLinks.fs b/tests/authoring/Inline/InlineLinks.fs index 07c907f0e..479e222df 100644 --- a/tests/authoring/Inline/InlineLinks.fs +++ b/tests/authoring/Inline/InlineLinks.fs @@ -45,7 +45,7 @@ type ``inline link with mailto not allowed external host`` () = let ``has no errors`` () = markdown |> hasNoErrors [] - let ``has error`` () = markdown |> hasWarning "External URI 'mailto:fake-email@somehost.co' is not allowed." + let ``has error`` () = markdown |> hasWarning "mailto links should be to elastic.co domains." type ``empty link should result in an error`` () =