Skip to content

Commit

Permalink
Do not trigger "unknown extra" warning on a reference
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtekmach committed Jul 20, 2020
1 parent 0f5cc7b commit 759512b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/ex_doc/autolink.ex
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,11 @@ defmodule ExDoc.Autolink do
{tag, attrs, walk(ast, config)}
end

@ref_regex ~r/^`(.+)`$/

defp custom_link(attrs, config) do
with {:ok, href} <- Keyword.fetch(attrs, :href),
[[_, text]] <- Regex.scan(~r/^`(.+)`$/, href) do
[[_, text]] <- Regex.scan(@ref_regex, href) do
url(text, :custom_link, config)
else
_ -> nil
Expand All @@ -105,6 +107,7 @@ defmodule ExDoc.Autolink do
uri <- URI.parse(href),
nil <- uri.host,
true <- is_binary(uri.path),
false <- uri.path =~ @ref_regex,
extension when extension in [".md", ".txt", ""] <- Path.extname(uri.path) do
file = Path.basename(uri.path)

Expand Down

0 comments on commit 759512b

Please sign in to comment.