befocken / revealjs-embed-code

Embed external code files into your revealjs presentation
GNU General Public License v3.0
3 stars 1 forks source link

Feature or tip request: Use from Markdown #2

Open peter-lyons-kehl opened 2 years ago

peter-lyons-kehl commented 2 years ago

Hi Bent,

Any idea how I could use revealjs-embed-code from Markdown (rather than from HTML)?

I load/render my https://github.com/peter-kehl/embedded_low_level_rust/blob/main/README.md at https://github.com/peter-kehl/embedded_low_level_rust/blob/main/index.html#L26. But I don't see a way to load a file inside markdown: https://github.com/peter-kehl/embedded_low_level_rust/blob/ca0b67ddc4616dc34d758177d278e1bdcb7e12af/README.md?plain=1#L450-L458 --> https://peter-kehl.github.io/embedded_low_level_rust/#/10.

I can have <code...> code here... </code> within the markdown, and it does show up (though not highlighted and not preserving line breaks - any tips? I'll investigate). And if I have three backticks code here.... three backticks, that does show up and highlighted, too.

But I've tried several ways of <code and three backticks, or one backtick...one backtick - but no file loaded. I tried to follow https://revealjs.com/markdown/#element-attributes:

<!-- .element: attributes-here.... -->

but it doesn't seem to apply/work with revealjs-embed-code.

According to https://revealjs.com/code, Reveal.js uses https://marked.js.org. Then https://marked.js.org/#specifications > "Supported Markdown specifications" says it supports CommonMark and GitHub Flavored Markdown. Both seem to have identical (or very similar) handling of HTML elements in markdown (https://github.github.com/gfm/#html-blocks and https://spec.commonmark.org/0.30/#html-blocks). According to https://marked.js.org/using_advanced Marked.js uses GitHub Flavored Markdown (gfm) by default.

Any tips, workarounds, or any way to support this goal somehow in revealjs-embed-code, please?

peter-lyons-kehl commented 2 years ago

Update: The fix is to initiate the built-in RevealMarkdown plugin before EmbeddedCode:

                plugins: [
                    RevealMarkdown,
                    EmbedCode,

I'll provide a PR.

befocken commented 2 years ago

Hi Peter, I'm sorry that I didn't mention this in the README, I think I actually stumbled across the same error once and just fixed it in my presentation without giving it much of a second thought. As you might've noticed, I actually already mention that the order of the plugins can be of relevance in the README - however, I did not mention this cae.

Did you already prepare a PR? Otherwise I'll add that soon on my own.

peter-lyons-kehl commented 2 years ago

Thank you for following up Bent. No, I didn't get to make a PR. I'll leave this with you.

Thx in advance.