Skip to content

Commit

Permalink
links: Support null "title" attribute with --reference-links.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexmv committed Jan 16, 2024
1 parent 32f1c60 commit 66dd5ba
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
3 changes: 1 addition & 2 deletions html2text/__init__.py
Expand Up @@ -823,8 +823,7 @@ def o(
+ "]: "
+ urlparse.urljoin(self.baseurl, link.attrs["href"])
)
if "title" in link.attrs:
assert link.attrs["title"] is not None
if "title" in link.attrs and link.attrs["title"] is not None:
self.out(" (" + link.attrs["title"] + ")")
self.out("\n")
else:
Expand Down
1 change: 1 addition & 0 deletions test/no_inline_links_example.html
Expand Up @@ -7,3 +7,4 @@
<a href="http://example.com" title="abc">
link text
</a></a></a>
<a href='http://example.com' title>Empty link title</a>
4 changes: 3 additions & 1 deletion test/no_inline_links_example.md
@@ -1,8 +1,10 @@
[Googler][1] No href No href but title available [ Example][2] [ [ [ link text
][3]][3]][3]
][3]][3]][3] [Empty link title][4]

[1]: http://google.com

[2]: http://example.com (Example title)

[3]: http://example.com (abc)

[4]: http://example.com

0 comments on commit 66dd5ba

Please sign in to comment.