Skip to content

Commit

Permalink
fix: Recognize links with multi-line text
Browse files Browse the repository at this point in the history
Issue #31: #31
PR #32: #32
  • Loading branch information
oprypin committed Feb 15, 2024
1 parent a6e373b commit 225a6f2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
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

0 comments on commit 225a6f2

Please sign in to comment.