mdformat
mdformat copied to clipboard
image path is falsely patched with `<>` if URL includes `()`, breaks render
Describe the bug
context Formating status badges from Azure, just copy paste the provided code by Azure devops
expectation
keep it as it is:
[?branchName=master)](https://dev.azure.com/Lightning-AI/lightning/_build/latest?definitionId=24&branchName=master)
bug with added <> it is not rendered as image
[?branchName=master>)](https://dev.azure.com/Lightning-AI/lightning/_build/latest?definitionId=24&branchName=master)
Reproduce the bug
using pre-commit hook:
- repo: https://github.com/executablebooks/mdformat
rev: 0.7.17
hooks:
- id: mdformat
List your environment
No response
seems the problem is ()
in url which is a valid character, based on https://www.w3schools.com/tags/ref_urlencode.ASP but also could be replaced with %28
and %29
and properly recognised for rendering
Thanks for the issue!
with added <> it is not rendered as image
This seems to me like a renderer issue. Which renderer do you use? If I copy the link (with angle brackets) to e.g. GitHub's or Gitlab's comment field and press the "Preview" button, both correctly render the image.
The angle brackets should be allowed here.
This seems to me like a renderer issue. Which renderer do you use?
GitHub preview I guess and maybe PyPI...
Link with brackets:
Rendered:
Works fine on GitHub. If not on PyPI, then that should be a PyPI bug I think.
I can confirm the issue with the latest version:
$ mdformat --version
mdformat 0.7.17 (mdformat_web: 0.1.0)
$ cat ./edge-case.md
# Edge case
[Split screen](https://en.wikipedia.org/wiki/Split_screen_(video_production))
$ mdformat ./edge-case.md
$ cat ./edge-case.md
# Edge case
[Split screen](<https://en.wikipedia.org/wiki/Split_screen_(video_production)>)
Instead, I would expect mdformat
to let the link as-is, or URL-encode the parenthesis as @Borda suggested:
# Edge case
[Split screen](https://en.wikipedia.org/wiki/Split_screen_%28video_production%29)