@@ -61,7 +61,7 @@ def test_reference_implicit():
6161 run_references_test (
6262 url_map = {"Foo" : "foo.html#Foo" },
6363 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>' ,
6565 )
6666
6767
@@ -70,7 +70,7 @@ def test_reference_explicit_with_markdown_text():
7070 run_references_test (
7171 url_map = {"Foo" : "foo.html#Foo" },
7272 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>' ,
7474 )
7575
7676
@@ -79,7 +79,7 @@ def test_reference_implicit_with_code():
7979 run_references_test (
8080 url_map = {"Foo" : "foo.html#Foo" },
8181 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>' ,
8383 )
8484
8585
@@ -88,7 +88,7 @@ def test_reference_with_punctuation():
8888 run_references_test (
8989 url_map = {'Foo&"bar' : 'foo.html#Foo&"bar' },
9090 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>' ,
9292 )
9393
9494
@@ -98,7 +98,7 @@ def test_reference_to_relative_path():
9898 from_url = "sub/sub/page.html" ,
9999 url_map = {"zz" : "foo.html#zz" },
100100 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>' ,
102102 )
103103
104104
@@ -174,7 +174,7 @@ def test_custom_required_reference():
174174 url_map = {"ok" : "ok.html#ok" }
175175 source = "<span data-autorefs-identifier=bar>foo</span> <span data-autorefs-identifier=ok>ok</span>"
176176 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>'
178178 assert unmapped == ["bar" ]
179179
180180
@@ -183,7 +183,7 @@ def test_custom_optional_reference():
183183 url_map = {"ok" : "ok.html#ok" }
184184 source = '<span data-autorefs-optional="bar">foo</span> <span data-autorefs-optional=ok>ok</span>'
185185 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>'
187187 assert unmapped == [] # noqa: WPS520
188188
189189
@@ -192,5 +192,17 @@ def test_custom_optional_hover_reference():
192192 url_map = {"ok" : "ok.html#ok" }
193193 source = '<span data-autorefs-optional-hover="bar">foo</span> <span data-autorefs-optional-hover=ok>ok</span>'
194194 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>'
196208 assert unmapped == [] # noqa: WPS520
0 commit comments