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

embed element not working in revealjs format #7830

Open
cderv opened this issue Jan 13, 2022 · 3 comments
Open

embed element not working in revealjs format #7830

cderv opened this issue Jan 13, 2022 · 3 comments
Labels

Comments

@cderv
Copy link
Contributor

cderv commented Jan 13, 2022

This is what we got if we tries to embed a PDF file in HTML file and HTML presentation

❯ echo "![](myplot.pdf)" | pandoc -t revealjs
<section class="slide level6">

<p><embed data-src="myplot.pdf" /></p>
</section>

❯ echo "![](myplot.pdf)" | pandoc -t html
<p><embed src="myplot.pdf" /></p>

There is a special treatment to use data-src for Lazy Loading feature in revealjs instead of src. I believe this is here
https://github.com/jgm/pandoc/blob/2e50c8d1378e911095918a42c04643d64946d554/src/Text/Pandoc/Writers/HTML.hs#L1520-L524
This is then applied for various element

(tag, specAttrs) = case mediaCategory normSrc of
Just "image" -> imageTag
Just "video" -> mediaTag H5.video "Video"
Just "audio" -> mediaTag H5.audio "Audio"
Just _ -> (H5.embed, [])
_ -> imageTag

However, revealjs does support only a few, and especially <embed> is not one of them - only img, video, audio and iframe are supported.

		// Media elements with data-src attributes
		queryAll( slide, 'img[data-src], video[data-src], audio[data-src], iframe[data-src]' ).forEach( element => {
			if( element.tagName !== 'IFRAME' || this.shouldPreload( element ) ) {
				element.setAttribute( 'src', element.getAttribute( 'data-src' ) );
				element.setAttribute( 'data-lazy-loaded', '' );
				element.removeAttribute( 'data-src' );
			}
		} );

Source: https://github.com/hakimel/reveal.js/blob/f7c59649fe9d72a148860220a66511cefd142907/js/controllers/slidecontent.js#L52-L59
Doc: https://revealjs.com/media/#lazy-loading

We could also ask upstream to support this, but currently I believe this is a bug as you can't insert such document using image syntax for revealjs format because Pandoc will write something not supported by revealjs.

@jgm
Copy link
Owner

jgm commented Jan 13, 2022

What do you think we should do instead?

@cderv
Copy link
Contributor Author

cderv commented Jan 13, 2022

Using src attributes as in html output works in revealjs.
I believe the data-src attributes for Lazy Loading should be used only for the elements that are supported in revealjs.

@cderv
Copy link
Contributor Author

cderv commented Jan 13, 2022

We could also ask upstream to support this, but currently I believe this is a bug as you can't insert such document using image syntax for revealjs format because Pandoc will write something not supported by revealjs.

But asking upstream is definitely a solution. Lazy Loading could also work with <embed> I believe. I'll open an issue there.

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

No branches or pull requests

2 participants