Skip to content

Math in slides? #14

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

Open
dextorious opened this issue Feb 19, 2015 · 4 comments
Open

Math in slides? #14

dextorious opened this issue Feb 19, 2015 · 4 comments

Comments

@dextorious
Copy link

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.

@jacksingleton
Copy link
Owner

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

@rhunter
Copy link

rhunter commented Sep 15, 2015

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.

@jacksingleton
Copy link
Owner

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?

@joshgiesbrecht
Copy link

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!

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

4 participants