Skip to content

Commit c0cac44

Browse files
authored
epub: void elements, such wbr, must be terminated by the matching end-tag (#2198)
Otherwise, it will produce an error while parsing the XHTML in some EPUB readers.
1 parent 755668a commit c0cac44

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

lib/ex_doc/formatter/html/templates.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ defmodule ExDoc.Formatter.HTML.Templates do
1515
end
1616

1717
@doc """
18-
Returns the title with `<wbr>` after each fullstop, allowing word breaks in long module names.
18+
Returns the title with `<wbr />` after each fullstop, allowing word breaks in long module names.
1919
"""
2020
def breakable_module_title(title) when is_binary(title) do
21-
String.replace(title, ".", ".<wbr>")
21+
String.replace(title, ".", ".<wbr />")
2222
end
2323

2424
@doc """

test/ex_doc/formatter/epub/templates_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ defmodule ExDoc.Formatter.EPUB.TemplatesTest do
116116
content = Templates.module_template(formatter_config(), module_node)
117117

118118
assert content =~ ~r{<title>XPTO.NestedModule [^<]*</title>}
119-
assert content =~ ~r{<h1 id="content">\s*XPTO.<wbr>NestedModule\s*}
119+
assert content =~ ~r{<h1 id="content">\s*XPTO.<wbr />NestedModule\s*}
120120
end
121121

122122
test "outputs the functions and docstrings" do

test/ex_doc/formatter/html/templates_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ defmodule ExDoc.Formatter.HTML.TemplatesTest do
525525
test "add word breaks to title", context do
526526
content = get_module_template([CompiledWithDocs.Nested], context)
527527

528-
assert content =~ "CompiledWithDocs.<wbr>Nested"
528+
assert content =~ "CompiledWithDocs.<wbr />Nested"
529529
end
530530

531531
test "do not output overlapping functions, causing duplicate IDs", context do

test/ex_doc/formatter/html_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ defmodule ExDoc.Formatter.HTMLTest do
117117
assert content =~ ~r{<p>moduledoc</p>}
118118

119119
assert content =~
120-
~r{<a href="CompiledWithDocs.Nested.html" translate="no">CompiledWithDocs.<wbr>Nested</a>}
120+
~r{<a href="CompiledWithDocs.Nested.html" translate="no">CompiledWithDocs.<wbr />Nested</a>}
121121

122122
assert content =~
123123
~r{<a href="Mix.Tasks.TaskWithDocs.html" translate="no">mix task_with_docs</a>}

0 commit comments

Comments
 (0)