Permalink
Browse files
BUG: Fix wrapping non-raw URLs (e.g. in HTML)
- Loading branch information...
Showing
with
5 additions
and
1 deletion.
-
+1
−1
pdoc/html_helpers.py
-
+4
−0
pdoc/test/__init__.py
|
|
@@ -279,7 +279,7 @@ def doctests(text, |
|
|
|
@staticmethod |
|
|
|
def raw_urls(text): |
|
|
|
"""Wrap URLs in Python-Markdown-compatible <angle brackets>.""" |
|
|
|
return re.sub(r'(?<!<)(\s*)((?:http|ftp)s?://[^>)\s]+)(\s*)(?!>)', r'\1<\2>\3', text) |
|
|
|
return re.sub(r'(?<![<"\'])(\s*)((?:http|ftp)s?://[^>)\s]+)(\s*)', r'\1<\2>\3', text) |
|
|
|
|
|
|
|
|
|
|
|
def to_html(text: str, docformat: str = 'numpy,google', *, |
|
|
|
|
|
@@ -960,6 +960,8 @@ def test_reST_include(self): |
|
|
|
def test_urls(self): |
|
|
|
text = """Beautiful Soup |
|
|
|
http://www.foo.bar |
|
|
|
http://www.foo.bar?q="foo" |
|
|
|
<a href="https://travis-ci.org/cs01/pygdbmi"><img src="https://foo" /></a> |
|
|
|
<https://foo.bar> |
|
|
|
|
|
|
|
Work [like this](http://foo/) and [like that]. |
|
|
@@ -969,6 +971,8 @@ def test_urls(self): |
|
|
|
data:text/plain;base64,SGVsbG8sIFdvcmxkIQ%3D%3D""" |
|
|
|
expected = """<p>Beautiful Soup |
|
|
|
<a href="http://www.foo.bar">http://www.foo.bar</a> |
|
|
|
<a href="http://www.foo.bar?q="foo"">http://www.foo.bar?q="foo"</a> |
|
|
|
<a href="https://travis-ci.org/cs01/pygdbmi"><img src="https://foo" /></a> |
|
|
|
<a href="https://foo.bar">https://foo.bar</a></p> |
|
|
|
<p>Work <a href="http://foo/">like this</a> and <a href="ftp://bar">like that</a>.</p> |
|
|
|
<p>data:text/plain;base64,SGVsbG8sIFdvcmxkIQ%3D%3D</p>""" |
|
|
|
0 comments on commit
ca359aa