@@ -61,7 +61,7 @@ def test_reference_implicit():
61
61
run_references_test (
62
62
url_map = {"Foo" : "foo.html#Foo" },
63
63
source = "This [Foo][]." ,
64
- output = '<p>This <a href="foo.html#Foo">Foo</a>.</p>' ,
64
+ output = '<p>This <a class="autorefs autorefs-internal" href="foo.html#Foo">Foo</a>.</p>' ,
65
65
)
66
66
67
67
@@ -70,7 +70,7 @@ def test_reference_explicit_with_markdown_text():
70
70
run_references_test (
71
71
url_map = {"Foo" : "foo.html#Foo" },
72
72
source = "This [**Foo**][Foo]." ,
73
- output = '<p>This <a href="foo.html#Foo"><strong>Foo</strong></a>.</p>' ,
73
+ output = '<p>This <a class="autorefs autorefs-internal" href="foo.html#Foo"><strong>Foo</strong></a>.</p>' ,
74
74
)
75
75
76
76
@@ -79,7 +79,7 @@ def test_reference_implicit_with_code():
79
79
run_references_test (
80
80
url_map = {"Foo" : "foo.html#Foo" },
81
81
source = "This [`Foo`][]." ,
82
- output = '<p>This <a href="foo.html#Foo"><code>Foo</code></a>.</p>' ,
82
+ output = '<p>This <a class="autorefs autorefs-internal" href="foo.html#Foo"><code>Foo</code></a>.</p>' ,
83
83
)
84
84
85
85
@@ -88,7 +88,7 @@ def test_reference_with_punctuation():
88
88
run_references_test (
89
89
url_map = {'Foo&"bar' : 'foo.html#Foo&"bar' },
90
90
source = 'This [Foo&"bar][].' ,
91
- output = '<p>This <a href="foo.html#Foo&"bar">Foo&"bar</a>.</p>' ,
91
+ output = '<p>This <a class="autorefs autorefs-internal" href="foo.html#Foo&"bar">Foo&"bar</a>.</p>' ,
92
92
)
93
93
94
94
@@ -98,7 +98,7 @@ def test_reference_to_relative_path():
98
98
from_url = "sub/sub/page.html" ,
99
99
url_map = {"zz" : "foo.html#zz" },
100
100
source = "This [zz][]." ,
101
- output = '<p>This <a href="../../foo.html#zz">zz</a>.</p>' ,
101
+ output = '<p>This <a class="autorefs autorefs-internal" href="../../foo.html#zz">zz</a>.</p>' ,
102
102
)
103
103
104
104
@@ -174,7 +174,7 @@ def test_custom_required_reference():
174
174
url_map = {"ok" : "ok.html#ok" }
175
175
source = "<span data-autorefs-identifier=bar>foo</span> <span data-autorefs-identifier=ok>ok</span>"
176
176
output , unmapped = fix_refs (source , url_map .__getitem__ ) # noqa: WPS609
177
- assert output == '[foo][bar] <a href="ok.html#ok">ok</a>'
177
+ assert output == '[foo][bar] <a class="autorefs autorefs-internal" href="ok.html#ok">ok</a>'
178
178
assert unmapped == ["bar" ]
179
179
180
180
@@ -183,7 +183,7 @@ def test_custom_optional_reference():
183
183
url_map = {"ok" : "ok.html#ok" }
184
184
source = '<span data-autorefs-optional="bar">foo</span> <span data-autorefs-optional=ok>ok</span>'
185
185
output , unmapped = fix_refs (source , url_map .__getitem__ ) # noqa: WPS609
186
- assert output == 'foo <a href="ok.html#ok">ok</a>'
186
+ assert output == 'foo <a class="autorefs autorefs-internal" href="ok.html#ok">ok</a>'
187
187
assert unmapped == [] # noqa: WPS520
188
188
189
189
@@ -192,5 +192,17 @@ def test_custom_optional_hover_reference():
192
192
url_map = {"ok" : "ok.html#ok" }
193
193
source = '<span data-autorefs-optional-hover="bar">foo</span> <span data-autorefs-optional-hover=ok>ok</span>'
194
194
output , unmapped = fix_refs (source , url_map .__getitem__ ) # noqa: WPS609
195
- assert output == '<span title="bar">foo</span> <a title="ok" href="ok.html#ok">ok</a>'
195
+ assert (
196
+ output
197
+ == '<span title="bar">foo</span> <a class="autorefs autorefs-internal" title="ok" href="ok.html#ok">ok</a>'
198
+ )
199
+ assert unmapped == [] # noqa: WPS520
200
+
201
+
202
+ def test_external_references ():
203
+ """Check that external references are marked as such."""
204
+ url_map = {"example" : "https://example.com" }
205
+ source = '<span data-autorefs-optional="example">example</span>'
206
+ output , unmapped = fix_refs (source , url_map .__getitem__ ) # noqa: WPS609
207
+ assert output == '<a class="autorefs autorefs-external" href="https://example.com">example</a>'
196
208
assert unmapped == [] # noqa: WPS520
0 commit comments