Skip to content

Commit 225a6f2

Browse files
authored
fix: Recognize links with multi-line text
Issue #31: #31 PR #32: #32
1 parent a6e373b commit 225a6f2

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

src/mkdocs_autorefs/references.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
AUTO_REF_RE = re.compile(
1919
r"<span data-(?P<kind>autorefs-identifier|autorefs-optional|autorefs-optional-hover)="
2020
r'("?)(?P<identifier>[^"<>]*)\2>(?P<title>.*?)</span>',
21+
flags=re.DOTALL,
2122
)
2223
"""A regular expression to match mkdocs-autorefs' special reference markers
2324
in the [`on_post_page` hook][mkdocs_autorefs.plugin.AutorefsPlugin.on_post_page].

tests/test_references.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,15 @@ def test_reference_to_relative_path() -> None:
111111
)
112112

113113

114+
def test_multiline_links() -> None:
115+
"""Check that links with multiline text are recognized."""
116+
run_references_test(
117+
url_map={"foo-bar": "foo.html#bar"},
118+
source="This [Foo\nbar][foo-bar].",
119+
output='<p>This <a class="autorefs autorefs-internal" href="foo.html#bar">Foo\nbar</a>.</p>',
120+
)
121+
122+
114123
def test_no_reference_with_space() -> None:
115124
"""Check that references with spaces are not fixed."""
116125
run_references_test(

0 commit comments

Comments
 (0)