hacker-slides icon indicating copy to clipboard operation
hacker-slides copied to clipboard

Math in slides?

Open dextorious opened this issue 10 years ago • 4 comments

There doesn't seem to be any support for writing equations at the moment. The usual way of writing equations in RevealJS involves using a MathJax dependency, though I'm not sure what kind of syntax people are using when writing slides in MarkDown.

Regardless, this would probably be a fairly popular feature request, so here it is.

dextorious avatar Feb 19 '15 13:02 dextorious

Cool, thanks for bringing this up! As there is already support in Reveal it shouldn't be much work to add.

jacksingleton avatar Feb 19 '15 22:02 jacksingleton

I took a quick look at what might be involved – it's almost as simple as enabling the "math" plugin for Reveal.js.

With the "math" plugin enabled, you can write math using $y = f(x)$ in your Markdown, but it will only render as nice typeset math when the slide first comes into view. Any changes you type in will just appear as text.

  • The "math" plugin listens for a "slidechanged" event and tells MathJax to typeset the text.
  • Reveal.js only fires the "slidechanged" event when navigating from one slide to another – not when the text changes.

So the options are:

  • No special math handling (current state)
  • Math works for final presentation, but has no real-time preview (easy change)
  • Editing math works just like editing lists or links (more complicated change)

Full support is more complicated because it requires upstream changes (to Reveal.js) or hacky workarounds such as triggering MathJax typesetting directly.

rhunter avatar Sep 15 '15 00:09 rhunter

Hey thanks for looking into this.

I'm not entirely against hacky workarounds :)

First sorry for the state of the 'static' directory - a lot of it is plain old RevealJS, but some are files I've added/modified. If you look though on github you can see any file that doesn't have "initial commit" as the latest commit is one that I added or changed.

There is already a decent amount of hackyness to make live reload work as it does.

So a save gets kicked of after a debounced keyup event here: https://github.com/jacksingleton/hacker-slides/blob/master/static/index.html#L82

That kicks off the save function here: https://github.com/jacksingleton/hacker-slides/blob/master/static/js/save.js which executes an ajax call to the server but then also uses the postMessage api to send a message to RevealJS telling it to execute the reloadMarkdown function.

reloadMarkdown is defined and monkey patched onto RevealJS here: https://github.com/jacksingleton/hacker-slides/blob/master/static/slides.html#L118

highlightAnyCodeBlocks() exists for a similar reason you described here - we would lose highlighting whenever the content was edited.

What do you think about adding a triggerMathJaxTypesetting function?

jacksingleton avatar Sep 15 '15 01:09 jacksingleton

Just posting to say that I was just hunting for this feature and would love to see even a quick-hack edition added for now!

joshgiesbrecht avatar Feb 08 '17 19:02 joshgiesbrecht