Merge pull request #18 from pineconellc/fix_title_tag_finder
Scope the title tag selector to the head element
This commit is contained in:
commit
203efa28d4
|
@ -33,7 +33,7 @@ defmodule Readability.TitleFinder do
|
|||
@spec tag_title(html_tree) :: binary
|
||||
def tag_title(html_tree) do
|
||||
html_tree
|
||||
|> Floki.find("title")
|
||||
|> Floki.find("head title")
|
||||
|> clean_title()
|
||||
|> String.split(@title_suffix)
|
||||
|> hd()
|
||||
|
|
|
@ -71,6 +71,19 @@ defmodule Readability.TitleFinderTest do
|
|||
"""
|
||||
title = Readability.TitleFinder.tag_title(html)
|
||||
assert title == "Tag title-tag-title"
|
||||
|
||||
html = """
|
||||
<html>
|
||||
<head>
|
||||
<title>Tag title</title>
|
||||
</head>
|
||||
<body>
|
||||
<svg><title>SVG title</title></svg>
|
||||
</body>
|
||||
</html>
|
||||
"""
|
||||
title = Readability.TitleFinder.tag_title(html)
|
||||
assert title == "Tag title"
|
||||
end
|
||||
|
||||
test "extract h1 tag title" do
|
||||
|
|
Loading…
Reference in New Issue