I think .strip() is wrong in default_slugify():
|
def default_slugify(title: str) -> str: |
|
"""Default slugify function. |
|
|
|
This aims to mimic the GitHub Markdown format, see: |
|
|
|
- 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(" ", "-")) |
Have a look at this gist testing github slugs, you can hover the links at the left-hand side to check the correct slugs.
If there is a leading/trailing object such as an image, the stripping happens before removing the image (as in myst-parser currently). When slugifying, the image is removed, but no subsequent .strip() happens, which means slugs have a leading/trailing -.
Just removing .strip() should fix the behaviour (but maybe you want to add tests somewhere?)
I think
.strip()is wrong indefault_slugify():MyST-Parser/myst_parser/mdit_to_docutils/base.py
Lines 1969 to 1977 in a784880
Have a look at this gist testing github slugs, you can hover the links at the left-hand side to check the correct slugs.
If there is a leading/trailing object such as an image, the stripping happens before removing the image (as in myst-parser currently). When slugifying, the image is removed, but no subsequent
.strip()happens, which means slugs have a leading/trailing-.Just removing
.strip()should fix the behaviour (but maybe you want to add tests somewhere?)