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

Including a README.md with links that contain &s, "translates them" to & #19

Open
stdedos opened this issue Sep 26, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@stdedos
Copy link

stdedos commented Sep 26, 2022

Description

With README.md of

# Title

[![CalVer v0.2.0+2022.09.1000][version_img]][version_url]

[version_img]: https://img.shields.io/static/v1.svg?label=CalVer&message=v0.2.0+2022.09.1000&color=blue
[version_url]: https://pypi.org/project/bumpver/

Url https://img.shields.io/static/v1.svg?label=CalVer&message=v0.2.0+2022.09.1000&color=blue is rendered as https://img.shields.io/static/v1.svg?label=CalVer&message=v0.2.0+2022.09.1000&color=blue, breaking linkage

Details

  • OS: debian/buster
  • Python version: 3.9
  • Project version: sphinx_mdinclude 0.5.2
  • Can you repro on main? N/A
  • Can you repro in a clean virtualenv? Yes (? - repro is done on CI)
@amyreese amyreese added the bug Something isn't working label Sep 27, 2022
@veenstrajelmer
Copy link

veenstrajelmer commented May 4, 2024

@amyreese I am running into the same issue. Would it be complex to fix? I looked into the code, but would not know how to solve it directly

@veenstrajelmer
Copy link

veenstrajelmer commented Jul 5, 2024

I did a lot of digging in the sphinx-mdinclude and mistune code and found that this is because of an issue in mistune: lepture/mistune#372

I am not sure if it will be resolved there, but if it will it will probably only be resolved in mistune>3.0. sphinx-mdinclude requires mistune 2 at the moment. A sort of decent alternative is to add some replacements to the RestRenderer class:

  • Restrenderer.link: link = link.replace("&","&")
  • Restrenderer.image: src = src.replace("&","&")
  • maybe also for other class functions

These replacements will result in the desired outputs for these two usecases:

from sphinx_mdinclude.render import convert
src = "[A link with ampersand](https://sonarcloud.io/api/project_badges/measure?project=Deltares_ddlpy&metric=alert_status)"
out = convert(src)
print(out)

src = "[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=Deltares_ddlpy&metric=alert_status)](https://sonarcloud.io/summary/overall?id=Deltares_ddlpy)"
out = convert(src)
print(out)

@veenstrajelmer
Copy link

Since sphinx-mdinclude now supports mistune>=3, I think the issue should be resolved in mistune. I will update my findings in lepture/mistune#372

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants