Skip to content

Commit

Permalink
Autolink .cheatmd files
Browse files Browse the repository at this point in the history
  • Loading branch information
sabiwara committed Feb 3, 2024
1 parent 3062cd9 commit c738188
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/ex_doc/autolink.ex
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ defmodule ExDoc.Autolink do

defp remove_and_warn_if_invalid(result, _, _), do: result

@builtin_ext [".livemd", ".md", ".txt", ""]
@builtin_ext [".livemd", ".cheatmd", ".md", ".txt", ""]

defp build_extra_link(link, config) do
with %{scheme: nil, host: nil, path: path} = uri <- URI.parse(link),
Expand Down
10 changes: 9 additions & 1 deletion test/ex_doc/language/elixir_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -250,12 +250,20 @@ defmodule ExDoc.Language.ElixirTest do
end

test "extras" do
opts = [extras: %{"Foo Bar.md" => "foo-bar", "Bar Baz.livemd" => "bar-baz"}]
opts = [
extras: %{
"Foo Bar.md" => "foo-bar",
"Bar Baz.livemd" => "bar-baz",
"Bar Baz.cheatmd" => "bar-baz"
}
]

assert autolink_doc("[Foo](Foo Bar.md)", opts) == ~s|<a href="foo-bar.html">Foo</a>|

assert autolink_doc("[Bar](Bar Baz.livemd)", opts) == ~s|<a href="bar-baz.html">Bar</a>|

assert autolink_doc("[Bar](Bar Baz.cheatmd)", opts) == ~s|<a href="bar-baz.html">Bar</a>|

assert autolink_doc("[Foo](Foo Bar.md)", [ext: ".xhtml"] ++ opts) ==
~s|<a href="foo-bar.xhtml">Foo</a>|

Expand Down

0 comments on commit c738188

Please sign in to comment.