Skip to content

Commit 46df46e

Browse files
committed
Automatically convert .livemd links
1 parent 363edfa commit 46df46e

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

lib/ex_doc/formatter/html.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ defmodule ExDoc.Formatter.HTML do
366366

367367
_ ->
368368
raise ArgumentError,
369-
"file extension not recognized, allowed extension is either .md, .txt or no extension"
369+
"file extension not recognized, allowed extension is either .livemd, .md, .txt or no extension"
370370
end
371371

372372
{title_ast, ast} =

lib/ex_doc/language/elixir.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ defmodule ExDoc.Language.Elixir do
439439
defp build_extra_link(link, config) do
440440
with %{scheme: nil, host: nil, path: path} = uri <- URI.parse(link),
441441
true <- is_binary(path) and path != "" and not (path =~ @ref_regex),
442-
extension when extension in [".md", ".txt", ""] <- Path.extname(path) do
442+
true <- Path.extname(path) in [".livemd", ".md", ".txt", ""] do
443443
if file = config.extras[Path.basename(path)] do
444444
fragment = (uri.fragment && "#" <> uri.fragment) || ""
445445
file <> config.ext <> fragment

test/ex_doc/language/elixir_test.exs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,10 +218,12 @@ defmodule ExDoc.Language.ElixirTest do
218218
end
219219

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

223223
assert autolink_doc(~m"[Foo](Foo Bar.md)", opts) == ~m"[Foo](foo-bar.html)"
224224

225+
assert autolink_doc(~m"[Bar](Bar Baz.livemd)", opts) == ~m"[Bar](bar-baz.html)"
226+
225227
assert autolink_doc(~m"[Foo](Foo Bar.md)", [ext: ".xhtml"] ++ opts) ==
226228
~m"[Foo](foo-bar.xhtml)"
227229

0 commit comments

Comments
 (0)