Skip to content

Commit

Permalink
Escape &%/2 special form (#1562)
Browse files Browse the repository at this point in the history
  • Loading branch information
sabiwara committed Apr 26, 2022
1 parent f8aad1f commit 2b2bcbe
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/ex_doc/language/elixir.ex
Expand Up @@ -627,9 +627,10 @@ defmodule ExDoc.Language.Elixir do
end
end

# There are two special forms that are forbidden by the tokenizer
# There are special forms that are forbidden by the tokenizer
defp parse_function("__aliases__"), do: {:function, :__aliases__}
defp parse_function("__block__"), do: {:function, :__block__}
defp parse_function("%"), do: {:function, :%}

defp parse_function(string) do
case Code.string_to_quoted("& #{string}/0") do
Expand Down
3 changes: 3 additions & 0 deletions test/ex_doc/language/elixir_test.exs
Expand Up @@ -160,6 +160,9 @@ defmodule ExDoc.Language.ElixirTest do
assert autolink_doc("Kernel.SpecialForms.%{}/1") ==
~m"[`Kernel.SpecialForms.%{}/1`](https://hexdocs.pm/elixir/Kernel.SpecialForms.html#%25%7B%7D/1)"

assert autolink_doc("Kernel.SpecialForms.%/2") ==
~m"[`Kernel.SpecialForms.%/2`](https://hexdocs.pm/elixir/Kernel.SpecialForms.html#%25/2)"

assert autolink_doc("Kernel.SpecialForms.{}/1") ==
~m"[`Kernel.SpecialForms.{}/1`](https://hexdocs.pm/elixir/Kernel.SpecialForms.html#%7B%7D/1)"

Expand Down

0 comments on commit 2b2bcbe

Please sign in to comment.