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

&name=large.png added to markdown image urls #11247

Closed
richardsprague opened this issue Oct 30, 2024 · 10 comments
Closed

&name=large.png added to markdown image urls #11247

richardsprague opened this issue Oct 30, 2024 · 10 comments
Labels
support a request for support

Comments

@richardsprague
Copy link

Bug description

how come this markdown image

![](https://pbs.twimg.com/media/Ga-G5MtWIAAjpC6?format=jpg&name=large)

gets turned into this html:

<p><img src="https://pbs.twimg.com/media/Ga-G5MtWIAAjpC6?format=jpg&amp;name=large.png" class="img-fluid" data-format="image/jpeg"></p>

Note the &amp;name=large.png appended to the end of the src url.

Steps to reproduce

make a qmd file with this line

![](https://pbs.twimg.com/media/Ga-G5MtWIAAjpC6?format=jpg&name=large)

quarto render

Expected behavior

No response

Actual behavior

No response

Your environment

No response

Quarto check output

Quarto 1.5.45
[✓] Checking versions of quarto binary dependencies...
Pandoc version 3.2.0: OK
Dart Sass version 1.70.0: OK
Deno version 1.41.0: OK
Typst version 0.11.0: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
Version: 1.5.45
Path: /Applications/quarto/bin

@richardsprague richardsprague added the bug Something isn't working label Oct 30, 2024
@cscheid
Copy link
Collaborator

cscheid commented Oct 30, 2024

This behavior comes from Pandoc, but in HTML, &amp; is a way to escape &. This should all work. See the request you get from your browser tools:

Image

I don't think there's a bug here.

@cscheid cscheid closed this as not planned Won't fix, can't repro, duplicate, stale Oct 30, 2024
@cscheid cscheid added support a request for support and removed bug Something isn't working labels Oct 30, 2024
@richardsprague
Copy link
Author

You sure?

Two identical files, one is pngappend.md and the other is pngappend.qmd

![](https://pbs.twimg.com/media/Ga-G5MtWIAAjpC6?format=jpg&name=large)

pandoc -f markdown -t html -o pngappend.html pngappend.md

correctly renders pngappend.html

<p><img

src="https://pbs.twimg.com/media/Ga-G5MtWIAAjpC6?format=jpg&amp;name=large" /></p>

but

quarto render pngappend.qmd

generates a bunch of stuff including this line

<p><img src="https://pbs.twimg.com/media/Ga-G5MtWIAAjpC6?format=jpg&amp;name=large.png" class="img-fluid"></p>

@mcanouil
Copy link
Collaborator

mcanouil commented Oct 30, 2024

The "src" attribute is exactly the same in both of the outputs you shared which is basically what Carlos already established.

edit: is the .png at the end that bothers you?

@cscheid
Copy link
Collaborator

cscheid commented Oct 30, 2024

Quoting from your answer:

pandoc -f markdown -t html -o pngappend.html pngappend.md

correctly renders pngappend.html

<p><img

src="https://pbs.twimg.com/media/Ga-G5MtWIAAjpC6?format=jpg&amp;name=large" /></p>

See the &amp; string there?

@richardsprague
Copy link
Author

richardsprague commented Oct 30, 2024

The &amp; string is fine, and it's found it both the Quarto and Pandoc output. But Quarto additionally appends an extra .png to the src, and that breaks the image rendering. If I manually remove the Quarto final .png it works fine.

I can also do this (Markdown) workaround to force the correct src, which renders properly in both Quarto and Pandoc:

<img src="https://pbs.twimg.com/media/Ga-G5MtWIAAjpC6?format=jpg&name=large" alt="">

why does Quarto append that extra .png ?

(Might be unrelated, but back in #7102 I thought it was reasonable that Quarto decided to not guess the image type, so I wonder if this is a change?)

@cderv
Copy link
Collaborator

cderv commented Oct 30, 2024

why does Quarto append that extra .png ?

This is added because of default-image-extension is PNG by default in Quarto. See for more context

If you do default-image-extension: "" in the YAML confirm for the document, there should not be any extension added.

@cscheid
Copy link
Collaborator

cscheid commented Oct 30, 2024

If you do default-image-extension: "" in the YAML confirm for the document, there should not be any extension added.

Thanks for the added context. @tarleb what do you think about a change to the default-image-extension behavior where Pandoc would try to append the extension before the URL params, if it finds them?

@tarleb
Copy link
Collaborator

tarleb commented Oct 30, 2024

This seems related to jgm/pandoc#9118. It could be argued that the fix for that issue was incomplete, and that URLs should never be altered. Are there situations in which the default-image-extension should be added to URLs?

Having that feature limited to local images would seem reasonable to me.

@cderv
Copy link
Collaborator

cderv commented Oct 31, 2024

Are there situations in which the default-image-extension should be added to URLs?
Having that feature limited to local images would seem reasonable to me.

I think most common use case if local image, but you could imagine users (of Quarto or Pandoc) that would have there image online with a .png and .pdf version available and they would like html format to use .png and pdf format to use pdf format.

Doing this with default-image-extension sets to png for html, and to pdf for pdf output would make this markdown syntax work.

[Caption](https://mysite.co/my-img)

Not that common but could happen. So it would be a breaking change for such users. A choice to make.

For the story we do set default-image-extension: "png" for format: html and default-image-extension=pdf for format: pdf so that you can use one link for multiformat output

---
format:
  pdf: default
  html: default
---

[Caption](images/my-awesome-img)

try to append the extension before the URL params, if it finds them

Doing this would insure nothing is broken IMO. And this would indeed complete jgm/pandoc#9118.

@tarleb
Copy link
Collaborator

tarleb commented Nov 4, 2024

I've opened jgm/pandoc#10355 to keep track of this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
support a request for support
Projects
None yet
Development

No branches or pull requests

5 participants