quarto-dev / quarto-cli

Open-source scientific and technical publishing system built on Pandoc.
https://quarto.org
Other
4k stars 329 forks source link

[HTML] add media embeding example as natively supported by Pandoc #10313

Open cderv opened 4 months ago

cderv commented 4 months ago

What would you like to do?

Give feedback or suggest an improvement

Description

Pandoc supports for Image syntax ![](media), a mimetype guesser which will in HTML use audio, video or embed tag. https://github.com/jgm/pandoc/blob/8613aa39e8b5b8282f30b9fd48b04ec2595ec8eb/src/Text/Pandoc/Writers/HTML.hs#L1589-L1594

We could document this syntax better as it is hard to find and know. We could also link from there to video shortcode (https://quarto.org/docs/authoring/videos.html) as a better solution.

Some extensions exists for this already:

We don't have great PDF embedding built-in yet too, and we can maybe provide something better than default one. 🤔 I'll open an issue maybe keep track of the idea and get votes.

mcanouil commented 4 months ago

The syntax also supports PDF and will display viewer when available in the browser.

For instance you can even do advanced thing for the PDF viewer:

![](slides-lec2.pdf#zoom=90&&navpanes=0&statusbar=0&messages=0&pagemode=none){width=100% height=475px}

Source: https://github.com/quarto-dev/quarto-cli/discussions/5863#discussioncomment-8946109

I'm not sure @coatless and @jmgirard knew about this native Pandoc feature/syntax for embedding PDF.

jmgirard commented 4 months ago

The fact that we didn't know about this is probably evidence that the enhanced Quarto documentation is needed. I think this feature largely obviates the need for my extension. One thing my extension does add, however, that I'm not sure pandoc supports is the ability to provide a "fallback" image and download link in case the PDF rendering fails. Something like this built into Quarto/pandoc would be helpful.

mcanouil commented 4 months ago

I think the syntax supports the preview image attribute. (I don't have an example right now though)

cderv commented 4 months ago

The syntax also supports PDF and will display viewer when available in the browser.

Yes it is using embed html5 tag

> quarto pandoc --to html
![](index.pdf)
^Z
<p><embed src="index.pdf" /></p>

It is a generic tag https://developer.mozilla.org/en-US/docs/Web/HTML/Element/embed

I think this feature largely obviates the need for my extension.

Your extension is using a Javascript library right ? The built in pandoc feature is nice, but it probably as way less feature that you can do in an extension targetting a specific JS pdf viewer.

If we build the feature inside quarto, this would be to provide

One thing my extension does add, however, that I'm not sure pandoc supports is the ability to provide a "fallback" image and download link in case the PDF rendering fails.

Pandoc only does something with it for HTML output format. For other format, I guess it will just try to use the file as an image of format pdf.

This issue is about documenting the existing syntax specific to HTML. For a built-in feature, it needs to be discussed in another issue. Thanks

jmgirard commented 4 months ago

I'll just note that the pandoc approach is really nice in that it makes it very easy to embed the PDF file into a standalone HTML file (if desired). This is more difficult in the extension approach. So the quarto version should (obviously) keep this functionality and the documentation should probably mention this.

coatless commented 4 months ago

I'm all for building/documenting more of these features. Going through an extension system to access it, requires knowing that the extension exists; which is a fun discoverability problem.

It would be nice for Quarto to have a similar repo and rendered website that mirrored Yihui's knitr-examples.

mcanouil commented 4 months ago

You mean: https://github.com/quarto-dev/quarto-examples

coatless commented 4 months ago

@mcanouil discoverability 😉 (ducks)

cderv commented 4 months ago

It would be nice for Quarto to have a similar repo and rendered website that mirrored Yihui's

The discussion have drift way from original issue - it would have been best to open a new discussion for this idea. 😉 Let me take the opportunity to add some notes on that, as the previous answer is a bit short.

knitr-examples is a repo for testing features. It serve as example, but main purpose is testing feature by adding small example document that we don't want to break. This repo would not contain example of external feature to knitr. I am taking the parallel as I am not sure we would document Pandoc's own behavior in such repo.

Equivalent of knitr-examples for Quarto is more the current test suites, and the new feature format matrix we are currently building. Like knitr-example, everything is in github repo form right now

Hope this answer can serve to clarify the current situation - TBH we are focusing on first one (good tests), and second one (ff-matrix), and currently don't spend much time on quarto-examples. This hopefully will change in the future.

Regarding discoverability, I hope @mcanouil work on https://github.com/mcanouil/awesome-quarto (and maybe its associated website 😉 ) are helpful ! In general, discoverability of everything existing thing in an ecosystem is a hard part of any project !