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

Markdown processed incorrectly inside Markdown fragments added with element attributes #2507

Open
mthmulders opened this issue Oct 12, 2019 · 19 comments

Comments

@mthmulders
Copy link

In my Reveal.js presentations I have some math equations. I prefer to have my slides in external Markdown files.

Now, in Reveal.js 3.6.0 this worked great, but in 3.8.0 it doesn't work anymore. The equations have a red backslash, some markup is not processed (showing _note_ instead of note) and the animations are out of order.

Initially, 3.6.0 renders as
reveal360-initial

But in 3.8.0, this becomes
reveal380-initial

In the end state, 3.6.0 renders as
reveal360-final

Whereas 3.8.0 renders as
reveal380-final

I've created a repo with both versions in it.

@mthmulders
Copy link
Author

Seems to have been introduced with 3.8.0, as 3.7.0 works just like 3.6.0.

@mthmulders
Copy link
Author

Adding the slidechanged or fragmentshown event handlers (as described in #226 resp #505) doesn't help.

@burgerga
Copy link

I don't know why it changed, but it is preprocessed by markdown. You might need an extra escape so \\* instead of \*. The other suggestions I came across is placing the equation in backticks but that might not work.

@burgerga
Copy link

burgerga commented May 18, 2020

I don't know why it changed, but it is preprocessed by markdown. You might need an extra escape so \\* instead of \*. The other suggestions I came across is placing the equation in backticks but that might not work.

Never mind, it's actually the other way around, you don't need the backslashes anymore (the reason it's red, is because mathjax flags it as an unknown command). Just a * should work, so for example:

1. $(d * 3) − 1  \mod (10 * 16) = 0$
1. <!-- .element: class="fragment" --> $(d * 3) − 1  \mod (10 * 16) = 0$

Don't know why it changed though, it's not something in the math plugin, I guess something in markdown.js. Very strange how in

1. $(d \* 3) − 1  \mod (10 \* 16) = 0$
1. <!-- .element: class="fragment" --> $(d \* 3) − 1  \mod (10 \* 16) = 0$

the top line works, but not the bottom.

@mthmulders
Copy link
Author

Thanks for your reply, @burgerga. Removing the backslash indeed fixes rendering of the formula.

The other issue still remains: markup that is part of a fragment is not applied. So where you would have

<!-- .element: class="fragment" -->This is an _example_ fragment.

You would expect the word "example" to emphasised, e.g.This is an <em>example</em> fragment. Instead, it becomes This is an _example_ fragment.

@mthmulders
Copy link
Author

I've added Reveal 3.9.2 to the repo.

@Brickaction
Copy link

7.3.11

@mthmulders
Copy link
Author

I'm not sure what that means, @Brickaction....

@burgerga
Copy link

Thanks for your reply, @burgerga. Removing the backslash indeed fixes rendering of the formula.

The other issue still remains: markup that is part of a fragment is not applied. So where you would have

<!-- .element: class="fragment" -->This is an _example_ fragment.

You would expect the word "example" to emphasised, e.g.This is an <em>example</em> fragment. Instead, it becomes This is an _example_ fragment.

Yes, I guess this is the real issue, so it's not MathJax related at all actually. The markdown is simply not processed anymore (if markdown would be processed, the backslash in \* would have been removed, which is why \* works outside of fragments).
Maybe you can change the title of your bug.

@hakimel do you have any idea what changed? (also happens in v4)

@mthmulders
Copy link
Author

I'm not sure I correctly understand... Something like "Markdown is not processed inside Reveal fragments" ?

@burgerga
Copy link

Yes almost, to be more specific "Markdown processed incorrectly inside Markdown fragments added with element attributes", because if you modify https://revealjs.com/markdown/#element-attributes to

- Item 1 <!-- .element: class="fragment"  -->
- Item 2 test <!-- .element: class="fragment"  -->
- Item 3 _test_ <!-- .element: class="fragment"  -->
- <!-- .element: class="fragment"  --> Item 4 _test_ 

this also gives very unexpected results.

@gitpitch
Copy link

I wonder if the issue was introduced when the revealjs dependency on marked was updated to v0.6.0. That update happened in reveal 3.8.0. Possibly as a result of this change to marked. It might be worth dropping in the older v0.5.2 library to see if the upgrade to v0.6.0 is indeed the culprit.

@mthmulders mthmulders changed the title External Markdown with math equations broken in 3.8.0 Markdown processed incorrectly inside Markdown fragments added with element attributes May 21, 2020
@mthmulders
Copy link
Author

Good catch, @gitpitch. I've changed my repo to use Reveal 3.8.0 with the Marked version that shipped with 3.7.0. Reverting the backslash-change makes the slide behave as before.

@burgerga
Copy link

burgerga commented May 21, 2020

Just the marked.js or also the markdown.js? Because when I try to use marked 0.5.2 in reveal 4.0.0 it still doesn't work for me 😕

EDIT:
does this also work correctly for you with marked 0.5.2?

- Item 1 <!-- .element: class="fragment"  -->
- Item 2 test <!-- .element: class="fragment"  -->
- Item 3 _test_ <!-- .element: class="fragment"  -->
- <!-- .element: class="fragment"  --> Item 4 _test_ 

@mthmulders
Copy link
Author

Just the marked.js or also the markdown.js? Because when I try to use marked 0.5.2 in reveal 4.0.0 it still doesn't work for me 😕

That was with marked.js and markdown.js from Reveal 3.7.0.

EDIT:
does this also work correctly for you with marked 0.5.2?

With Reveal 3.8.0 and both marked.js and markdown.js from Reveal 3.7.0, I see appearing (in order):

  • Item 3
  • Item 1
  • Item 2 test
  • test behind Item 3
  • Item 4 test

@Brickaction
Copy link

I'm not sure what that means, @Brickaction....

Neither do I but I feel like those numbers are important

@burgerga
Copy link

Reported as troll.

@burgerga
Copy link

burgerga commented May 22, 2020

That was with marked.js and markdown.js from Reveal 3.7.0.

Ah, so the issue is not marked.js but rather the markdown.js plugin which uses marked.js. I quickly had a look at it, but between 3.7.0 and 3.8.0 there was a substantial rewrite of the plugin (3.7.0...3.8.0, see Files changed), and I'm completely unfamiliar with that code, so I hope @hakimel will step in and have a look at it 😉

With Reveal 3.8.0 and both marked.js and markdown.js from Reveal 3.7.0, I see appearing (in order):

  • Item 3
  • Item 1
  • Item 2 test
  • test behind Item 3
  • Item 4 test

This is then the second issue 😞, which has probably never worked as intended
So the fragment element attribute should be added right after the */- to make it work properly with markdown in the items, so instead of

<section data-markdown>
  <script type="text/template">
    - Item 1 <!-- .element: class="fragment" data-fragment-index="2" -->
    - Item 2 <!-- .element: class="fragment" data-fragment-index="1" -->
  </script>
</section>

the documentation should probably read

<section data-markdown>
  <script type="text/template">
    - <!-- .element: class="fragment" data-fragment-index="2" --> Item 1
    - <!-- .element: class="fragment" data-fragment-index="1" --> Item 2
  </script>
</section>

to circumvent this.

@nkutsche
Copy link

nkutsche commented Dec 2, 2021

I'm not sure if it is clear, but a nasty workaround is to use HTML markup in Markdown:

- <!-- .element: class="fragment" data-fragment-index="1" --> <em>Item 1</em>
- <!-- .element: class="fragment" data-fragment-index="1" --> _Item 2_

The first item is rendered correctly, the second is not.

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

No branches or pull requests

5 participants