Skip to content

self-contained-math:true in reveal.js format still require internet access #9404

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
AndreiBiziuk opened this issue Apr 18, 2024 · 11 comments
Assignees
Labels
bug Something isn't working math any issue related to math support in specific formats revealjs Issues with the revealjs format
Milestone

Comments

@AndreiBiziuk
Copy link

Bug description

When creating presentations with formulas in the reveal.js format, the formulas do not render without Internet access, even if you specify self-contained-math: true.

The presentation file always requests the address https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS_HTML-full and without Internet access the formulas are not rendered.

Steps to reproduce

  1. Create new default project
  2. Modify _quarto.yml
project:
  title: "Test"

format:
  revealjs: 
    embed-resources: true
    self-contained-math: true 
  1. Create index.qmd
---
title: "Test"
---

## Math

$$x^2$$
  1. Render project quarto render
  2. Open index.html
  3. See request to Internet in developer console (F12)
  4. Or disconnect from Internet and see not rendered math on slide

Expected behavior

Math rendered offline

Actual behavior

Math do not render offline

Your environment

OS: Arch Linux
IDE: VsCode

Quarto check output

Quarto 1.5.29
[✓] Checking versions of quarto binary dependencies...
      Pandoc version 3.1.11: OK
      Dart Sass version 1.70.0: OK
      Deno version 1.41.0: OK
      Typst version 0.11.0: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
      Version: 1.5.29
      Path: /opt/quarto/bin

[✓] Checking tools....................OK
      Chromium: 869685
      TinyTeX: (not installed)

[✓] Checking LaTeX....................OK
      Using: Installation From Path
      Path: /usr/bin
      Version: undefined

[✓] Checking basic markdown render....OK

[✓] Checking Python 3 installation....OK
      Version: 3.11.8
      Path: /usr/bin/python3
      Jupyter: 5.7.2
      Kernels: haskell, python3

[✓] Checking Jupyter engine render....OK

[✓] Checking R installation...........OK
      Version: 4.3.3
      Path: /usr/lib64/R
      LibPaths:
        - /home/andrei/R/x86_64-pc-linux-gnu-library/4.3
        - /usr/lib/R/library
      knitr: 1.45
      rmarkdown: 2.25

[✓] Checking Knitr engine render......OK
@AndreiBiziuk AndreiBiziuk added the bug Something isn't working label Apr 18, 2024
@mcanouil
Copy link
Collaborator

Double dollars should be on their own line.
Use single dollar for inline Maths.

I cannot reproduce using a single document project or using _quarto.yml:

Quarto documentHTML
---
title: "Quarto Playground"
format:
  revealjs: 
    embed-resources: true
    self-contained-math: true 
---

## Math

This is inline math: $x^2$

This is display math:

$$
x^2
$$
image

@mcanouil mcanouil added the needs-repro Issues that are blocked until reporter provides an adequate reproduction label Apr 18, 2024
@AndreiBiziuk
Copy link
Author

---
title: "Quarto Playground"
format:
  revealjs: 
    embed-resources: true
    self-contained-math: true 
---

## Math

This is inline math: $x^2$

This is display math:

$$
x^2
$$

With internet:

image

Without internet:

image

@AndreiBiziuk
Copy link
Author

Link in the source code of page:

image

@mcanouil
Copy link
Collaborator

What I shared was rendered following the steps below:

  1. turning off network connection
  2. rendering with Quarto (in a clean workspace, without any previous rendering)

@AndreiBiziuk
Copy link
Author

I tried to build the project with the Internet turned off and in a clean directory, nothing changed.

When you opened a presentation offline, did you clear your browser cache?

@AndreiBiziuk
Copy link
Author

It looks like the MathJax plugin is embedded in the assembled presentation, but the plugin itself turns to the Internet for resources.

@mcanouil
Copy link
Collaborator

mcanouil commented Apr 18, 2024

Ok, I can reproduce.
Now, is it Quarto or Pandoc that is doing this wrong.

Edit: Quarto takes over that part which works correctly in the case of format: html but not for format: revealjs.
self-contained-math is only listed for html format and not for revealjs, which explains why it does nothing.
At the same time the codebase involves the two format:

  • if (isHtmlDocOutput(format.pandoc) || isRevealjsOutput(format.pandoc)) {
    if (
    ((flags && flags[kSelfContained]) || format.pandoc[kSelfContained] ||
    (flags && flags[kEmbedResources]) || format.pandoc[kEmbedResources]) &&
    !format.render[kSelfContainedMath]
    ) {
    const math = mathConfig(format, flags);

    (Cannot investigate this more right now)

@mcanouil mcanouil removed the needs-repro Issues that are blocked until reporter provides an adequate reproduction label Apr 18, 2024
@mcanouil mcanouil added the math any issue related to math support in specific formats label Jun 4, 2024
@cscheid cscheid added this to the Future milestone Jun 6, 2024
@blendersamsonov
Copy link

I'm experiencing the same bug. Would love some attention being drawn to the problem

@cderv cderv added the revealjs Issues with the revealjs format label Nov 12, 2024
@cderv cderv self-assigned this Nov 12, 2024
@cderv
Copy link
Collaborator

cderv commented Nov 12, 2024

It looks like the MathJax plugin is embedded in the assembled presentation, but the plugin itself turns to the Internet for resources.

This is what happens. Math in Revealjs is supported through the Math Plugins, which expect the mathjax configuration. The JS library is not loaded in a HTML script tag from the HTML itself, like with HTML format.

So the embed logic from Pandoc to make everything inlined is not working here.

As documented in the Revealjs doc (https://revealjs.com/math/), to make it work offline, it would require downloading Mathjax and configuring revealjs to use the local version - but this also means it won't be embed inside a single HTML.

I don't know if there is a good solution here 🤔 Maybe using KaTeX and server side rendering would be the easiest way to provide self contained math in Revealjs.

Pandoc itself is not embedding mathjax JS when doing pandoc --to revealjs -s --mathjax --embed-resources. This is a limitation of Mathjax and self contained feature.

@AndreiBiziuk
Copy link
Author

It is not necessary for the presentation to be a single file. The main thing is that it can be launched offline with the ability to draw formulas.

@cderv
Copy link
Collaborator

cderv commented Nov 22, 2024

I see. This is is not possible with Mathjax right now. I'll see if other math framework like KaTeX can allow this. Thanks for the feedback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working math any issue related to math support in specific formats revealjs Issues with the revealjs format
Projects
None yet
Development

No branches or pull requests

5 participants