diff --git a/docs/docset.yml b/docs/docset.yml index b7bb07219..e89280629 100644 --- a/docs/docset.yml +++ b/docs/docset.yml @@ -1,32 +1,6 @@ project: 'doc-builder' cross_links: - docs-content -# docs-builder will warn for links to external hosts not declared here -external_hosts: - - slack.com - - mystmd.org - - microsoft.com - - azure.com - - mistral.ai - - amazon.com - - python.org - - cohere.com - - docker.com - - langchain.com - - nodejs.org - - yarnpkg.com - - react.dev - - palletsprojects.com - - google.com - - checkvist.com - - commonmark.org - - github.io - - github.com - - pandoc.org - - atlassian.net - - elastic.dev - - visualstudio.com - - wikipedia.org exclude: - '_*.md' subs: diff --git a/src/Elastic.Markdown/IO/Configuration/ConfigurationFile.cs b/src/Elastic.Markdown/IO/Configuration/ConfigurationFile.cs index 6e8f24186..e6352591b 100644 --- a/src/Elastic.Markdown/IO/Configuration/ConfigurationFile.cs +++ b/src/Elastic.Markdown/IO/Configuration/ConfigurationFile.cs @@ -26,7 +26,6 @@ public record ConfigurationFile : DocumentationFile public HashSet Files { get; } = new(StringComparer.OrdinalIgnoreCase); public HashSet ImplicitFolders { get; } = new(StringComparer.OrdinalIgnoreCase); public Glob[] Globs { get; } = []; - public HashSet ExternalLinkHosts { get; } = new(StringComparer.OrdinalIgnoreCase) { "elastic.co", "github.com", "localhost", }; private readonly Dictionary _substitutions = new(StringComparer.OrdinalIgnoreCase); public IReadOnlyDictionary Substitutions => _substitutions; @@ -80,12 +79,6 @@ public ConfigurationFile(IFileInfo sourceFile, IDirectoryInfo rootPath, BuildCon case "subs": _substitutions = ReadDictionary(entry); break; - case "external_hosts": - var hosts = ReadStringArray(entry) - .ToArray(); - foreach (var host in hosts) - ExternalLinkHosts.Add(host); - break; case "toc": if (depth > 1) { @@ -97,6 +90,9 @@ public ConfigurationFile(IFileInfo sourceFile, IDirectoryInfo rootPath, BuildCon TableOfContents = entries; break; + case "external_hosts": + EmitWarning($"{key} has been deprecated and will be removed", entry.Key); + break; default: EmitWarning($"{key} is not a known configuration", entry.Key); break; diff --git a/src/Elastic.Markdown/Myst/InlineParsers/DiagnosticLinkInlineParser.cs b/src/Elastic.Markdown/Myst/InlineParsers/DiagnosticLinkInlineParser.cs index 15ff98b50..e8cdedbbd 100644 --- a/src/Elastic.Markdown/Myst/InlineParsers/DiagnosticLinkInlineParser.cs +++ b/src/Elastic.Markdown/Myst/InlineParsers/DiagnosticLinkInlineParser.cs @@ -143,13 +143,11 @@ private bool ValidateExternalUri(LinkInline link, InlineProcessor processor, Par return false; var baseDomain = uri.Host == "localhost" ? "localhost" : string.Join('.', uri.Host.Split('.')[^2..]); - if (!context.Configuration.ExternalLinkHosts.Contains(baseDomain)) + if (uri.Scheme == "mailto" && baseDomain != "elastic.co") { processor.EmitWarning( link, - $"External URI '{uri}' is not allowed. Add '{baseDomain}' to the " + - $"'external_hosts' list in the configuration file '{context.Configuration.SourceFile}' " + - "to allow links to this domain." + $"mailto links should be to elastic.co domains. Found {uri.Host} in {link.Url}. " ); } diff --git a/tests/authoring/Inline/InlineLinks.fs b/tests/authoring/Inline/InlineLinks.fs index 4792dcbd5..3e917f04f 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 "External URI 'mailto:fake-email@somehost.co' is not allowed." + let ``has warning`` () = markdown |> hasWarning "mailto links should be to elastic.co domains." type ``empty link should result in an error`` () =