diff --git a/myst_parser/mdit_to_docutils/base.py b/myst_parser/mdit_to_docutils/base.py index c70ae8fb..b70db12e 100644 --- a/myst_parser/mdit_to_docutils/base.py +++ b/myst_parser/mdit_to_docutils/base.py @@ -1974,7 +1974,7 @@ def default_slugify(title: str) -> str: - https://github.com/jch/html-pipeline/blob/master/lib/html/pipeline/toc_filter.rb - https://gist.github.com/asabaylus/3071099 """ - return _SLUGIFY_CLEAN_REGEX.sub("", title.strip().lower().replace(" ", "-")) + return _SLUGIFY_CLEAN_REGEX.sub("", title.lower().replace(" ", "-")) def compute_unique_slug( diff --git a/tests/test_sphinx/sourcedirs/references/index.md b/tests/test_sphinx/sourcedirs/references/index.md index 74d0fd6a..5255b475 100644 --- a/tests/test_sphinx/sourcedirs/references/index.md +++ b/tests/test_sphinx/sourcedirs/references/index.md @@ -67,3 +67,7 @@ Known explicit [**hallo**](#paragraph-target) Known with title [](#title-target) Ambiguous [](#duplicate) + +# Image in title ![badge](https://shields.io/or/something.svg) + +[link up](#image-in-title-) diff --git a/tests/test_sphinx/test_sphinx_builds/test_references.html b/tests/test_sphinx/test_sphinx_builds/test_references.html index 55b13a77..35d1aed7 100644 --- a/tests/test_sphinx/test_sphinx_builds/test_references.html +++ b/tests/test_sphinx/test_sphinx_builds/test_references.html @@ -263,6 +263,20 @@

+
+

+ Image in title + badge + + ΒΆ + +

+

+ + link up + +

+
diff --git a/tests/test_sphinx/test_sphinx_builds/test_references.resolved.xml b/tests/test_sphinx/test_sphinx_builds/test_references.resolved.xml index 58d73540..f832d049 100644 --- a/tests/test_sphinx/test_sphinx_builds/test_references.resolved.xml +++ b/tests/test_sphinx/test_sphinx_builds/test_references.resolved.xml @@ -1,6 +1,6 @@ -
+
Title with <strong> @@ -150,3 +150,10 @@ <reference internal="False" reftitle="Example 0.0.1" refuri="https://example.com/index.html#module-duplicate"> <literal classes="iref myst"> duplicate + <section classes="tex2jax_ignore mathjax_ignore" ids="image-in-title" names="image\ in\ title" slug="image-in-title-"> + <title> + Image in title + <image alt="badge" candidates="{'?': 'https://shields.io/or/something.svg'}" uri="https://shields.io/or/something.svg"> + <paragraph> + <reference id_link="True" refid="image-in-title"> + link up diff --git a/tests/test_sphinx/test_sphinx_builds/test_references.xml b/tests/test_sphinx/test_sphinx_builds/test_references.xml index 5069acec..4968ca2f 100644 --- a/tests/test_sphinx/test_sphinx_builds/test_references.xml +++ b/tests/test_sphinx/test_sphinx_builds/test_references.xml @@ -1,6 +1,6 @@ <document source="index.md"> <target refid="title"> - <section classes="tex2jax_ignore mathjax_ignore" ids="title-with-nested-a-1 title" names="title\ with\ nested\ a=1 title" slug="title-with-nested"> + <section classes="tex2jax_ignore mathjax_ignore" ids="title-with-nested-a-1 title" names="title\ with\ nested\ a=1 title" slug="title-with-nested-"> <title> Title with <strong> @@ -128,3 +128,10 @@ Ambiguous <pending_xref refdoc="index" refdomain="True" refexplicit="False" reftarget="duplicate" reftype="myst"> <inline classes="xref myst"> + <section classes="tex2jax_ignore mathjax_ignore" ids="image-in-title" names="image\ in\ title" slug="image-in-title-"> + <title> + Image in title + <image alt="badge" candidates="{'?': 'https://shields.io/or/something.svg'}" uri="https://shields.io/or/something.svg"> + <paragraph> + <reference id_link="True" refid="image-in-title"> + link up