-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from sdruskat/main
Fix #11: Adapt link regex to exclude anchor links
- Loading branch information
Showing
5 changed files
with
63 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
Jinja2==3.1.2 | ||
requests==2.31.0 | ||
pytest[test]==7.4.3 | ||
mkdocs[test]==1.5.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import pytest | ||
|
||
from external_markdown.plugin import EmbedExternalMarkdown | ||
|
||
BASE_URL = "https://BASEURL/" | ||
BASE_FILE = "https://BASEURL/FILE.md" | ||
TEST_DATA = [ | ||
( | ||
"external link", | ||
"https://github.com", | ||
"https://github.com"), | ||
( | ||
"external link with anchor", | ||
"https://ansible-docs.readthedocs.io/zh/stable-2.0/rst/playbooks_variables.html#using-variables-about-jinja2", | ||
"https://ansible-docs.readthedocs.io/zh/stable-2.0/rst/playbooks_variables.html#using-variables-about-jinja2", | ||
), | ||
( | ||
"anchor", | ||
"#links", | ||
"#links"), | ||
( | ||
"local link", | ||
"page.md", | ||
f"{BASE_URL}page.md"), | ||
( | ||
"local link with anchor", | ||
"page.md#test-subsection", | ||
f"{BASE_URL}page.md#test-subsection", | ||
), | ||
] | ||
|
||
|
||
class TestEmbedExternalMarkdown: | ||
@pytest.mark.parametrize("label,link_url,expected_url", TEST_DATA) | ||
def test_update_relative_links_external(self, label, link_url, expected_url): | ||
# Regression tests for #11 | ||
link = f"[{label}]({link_url})" | ||
expected = f"[{label}]({expected_url})" | ||
assert EmbedExternalMarkdown().update_relative_links(link, BASE_FILE) == expected |