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

image path is falsely patched with <> if URL includes (), breaks render #416

Open
Borda opened this issue Oct 13, 2023 · 5 comments
Open
Labels
bug Something isn't working

Comments

@Borda
Copy link

Borda commented Oct 13, 2023

Describe the bug

context
Formating status badges from Azure, just copy paste the provided code by Azure devops

expectation
keep it as it is:
[![Build Status](https://dev.azure.com/Lightning-AI/lightning/_apis/build/status%2Fpytorch-lightning%20(GPUs)?branchName=master)](https://dev.azure.com/Lightning-AI/lightning/_build/latest?definitionId=24&branchName=master)

bug
with added <> it is not rendered as image

[![Build Status](<https://dev.azure.com/Lightning-AI/lightning/_apis/build/status%2Fpytorch-lightning%20(GPUs)?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

@Borda Borda added the bug Something isn't working label Oct 13, 2023
@Borda
Copy link
Author

Borda commented Oct 13, 2023

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

@Borda Borda changed the title URL in image path is falsely patched with ,<> image path is falsely patched with <> if URL includes (), breaks render Oct 13, 2023
@hukkin
Copy link
Member

hukkin commented Feb 2, 2024

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.

@Borda
Copy link
Author

Borda commented Feb 2, 2024

This seems to me like a renderer issue. Which renderer do you use?

GitHub preview I guess and maybe PyPI...

@hukkin
Copy link
Member

hukkin commented Feb 2, 2024

Link with brackets:
render1

Rendered:
render2

Works fine on GitHub. If not on PyPI, then that should be a PyPI bug I think.

@kdeldycke
Copy link

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)

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