Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Recognize links with multi-line text #32

Merged
merged 1 commit into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/mkdocs_autorefs/references.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
AUTO_REF_RE = re.compile(
r"<span data-(?P<kind>autorefs-identifier|autorefs-optional|autorefs-optional-hover)="
r'("?)(?P<identifier>[^"<>]*)\2>(?P<title>.*?)</span>',
flags=re.DOTALL,
)
"""A regular expression to match mkdocs-autorefs' special reference markers
in the [`on_post_page` hook][mkdocs_autorefs.plugin.AutorefsPlugin.on_post_page].
Expand Down
9 changes: 9 additions & 0 deletions tests/test_references.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,15 @@ def test_reference_to_relative_path() -> None:
)


def test_multiline_links() -> None:
"""Check that links with multiline text are recognized."""
run_references_test(
url_map={"foo-bar": "foo.html#bar"},
source="This [Foo\nbar][foo-bar].",
output='<p>This <a class="autorefs autorefs-internal" href="foo.html#bar">Foo\nbar</a>.</p>',
)


def test_no_reference_with_space() -> None:
"""Check that references with spaces are not fixed."""
run_references_test(
Expand Down
Loading