hakimel / reveal.js

The HTML Presentation Framework
https://revealjs.com
MIT License
67.28k stars 16.62k forks source link

feat: How to add HTML attributes to `<code>` under `<pre>` within Markdown #3642

Open gabyx opened 3 weeks ago

gabyx commented 3 weeks ago

It would be extremely useful if we could add attributs to the <code> element under <pre> as like the following try:

\`\`\`cpp
int a = 3;
int a;
enum class C {A, B, C} b;
std::vector&lt;int&gt; c;

int const * & const d;

using FuncPointer  = int (*)(float); // Type: Pointer to function.
using FuncReferenz = int (&)(float); // Type: Reference to function.
using Func =             int(float); // Type: Function.
\`\`\`

<!-- .element: data-line-numbers="|3-4|8-10" data-fragment-index="1,2" -->

- This is important.
  <!-- .element: class="fragment" data-fragment-index="1" -->
- This is now important.
  <!-- .element: class="fragment" data-fragment-index="2" -->

That does not work since the data-line-numbers="|3-4|8-10" gets added to the <pre> element. Is there already a syntax to specify a child elements, e.g. .element.code or something. This would help in not needing to do full HTML with the code block.

horenmar commented 2 weeks ago

I am running into this often enough that I set up a small script that converts markdown code block into html.

There are similar issues with lists of non-plain elements (e.g. IIRC both Math and Code are a problem).