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

--mathjax inserts broken URL to CDN #2200

Closed
KurtPfeifle opened this issue Jun 1, 2015 · 7 comments
Closed

--mathjax inserts broken URL to CDN #2200

KurtPfeifle opened this issue Jun 1, 2015 · 7 comments

Comments

@KurtPfeifle
Copy link

I've tried to insert a math formula into a RevealJS slide show. The inserted URL is incorrect. It is missing the http: (or should it be https:) part:

src="//cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" 

Short test case:

kp@> pandoc -t revealjs --standalone --mathjax | grep TeX
# Testslide

$$\frac{n!}{k!(n-k)!} = \binom{n}{k}$$
^D

  <script src="//cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script>

Tested with version 1.14.0.2 (cabal-installed).

@jgm
Copy link
Owner

jgm commented Jun 1, 2015

That's intentional, though we might want to revisit it.

This form of URL will adapt either http: or https:, depending on the
page it occurs on.

So, using this, you get an HTML page that will look for mathjax on
https, if the page is served https, or on http, if it is served http.

See
https://github.com/jgm/pandoc-templates/issues/67
for the original motivation, and for some problems similar to
yours:
https://gist.github.com/dunn/44370cb79d9d29abf805#file-04-cabal
#1920
https://groups.google.com/d/msg/pandoc-discuss/ytS8qcdy38c/-Uk6y_lDHn0J

The workaround is simple, you can provide your own URL with --mathjax.
However, I'm tempted to change back to defaulting to an http URL.
This should be brought up on pandoc-discuss, which could just link
to this issue.

+++ Kurt Pfeifle [Jun 01 15 00:37 ]:

I've tried to insert a math formula into a RevealJS slide show. The inserted URL is incorrect. It is missing the http: (or should it be https:) part:

src="//cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"

Short test case:

kp@> pandoc -t revealjs --standalone --mathjax | grep TeX
# Testslide

$$\frac{n!}{k!(n-k)!} = \binom{n}{k}$$
^D

 <script src="//cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script>

Reply to this email directly or view it on GitHub:
#2200

@petrelharp
Copy link

For others arriving here, a fix is to pass the mathjax URL explicitly, via

--mathjax="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" 

@KurtPfeifle
Copy link
Author

On Mon, Jun 1, 2015 at 10:35 AM, John MacFarlane notifications@github.com wrote:

That's intentional, though we might want to revisit it.

Yes, please! :-)

This form of URL will adapt either http: or https:, depending on the page it occurs on.

My use case when preparing HTML slides is usually (99% of all, I guess) to
play them from my notebook without any web server involved. In this case
the protocol-relative URL to the MathJax CDN will not work.

So, using this, you get an HTML page that will look for mathjax on
https, if the page is served https, or on http, if it is served http.

See

for the original motivation, and for some problems similar to yours:

The workaround is simple, you can provide your own URL with --mathjax.
However, I'm tempted to change back to defaulting to an http URL.
This should be brought up on pandoc-discuss, which could just link
to this issue.

Sure. But just using --mathjax on the commandline without a need to look up
a valid CDN URL first is so much more user-friendly and more comfortable
than adding it as --mathjax= http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML

@KurtPfeifle
Copy link
Author

Why is it that the --mathjax parameter does not work in conjunction with the --self-contained parameter? (This is documented in the Pandoc README.)

Is it due to a current Pandoc bug or limitation? Or is it a bug or "feature" of MathJax?

The MathJax website claims:

"A JavaScript display engine for mathematics that works in all browsers. No more setup for readers. It just works."

If I cannot use MathJax with --standalone, a HTML presentation using math formulas will only work if there is a working internet connection during the talk. This is not always guaranteed.

For the presentation to work with -standalone, but without an internet connection, it requires a local MathJax installation on the computer used to (dis)play the presentation. This should be documented!

@jgm
Copy link
Owner

jgm commented Jun 26, 2015

+++ Kurt Pfeifle [Jun 21 15 17:51 ]:

Why is it that the --mathjax parameter does not work in conjunction with the --self-contained parameter? (This is documented in the Pandoc README.)

Is it due to a current Pandoc bug or limitation? Or is it a bug or "feature" of MathJax?

It's because MathJax loads some javascript stuff dynamically (calling
JavaScript functions), so in order to know what to include, pandoc
would have to have to interpret the JavaScript. Currently it just looks
at links in the HTML and CSS.

If I cannot use MathJax with --standalone, a HTML presentation using math formulas will only work if there is a working internet connection during the talk. This is not always guaranteed.

It's a simple matter to clone the mathjax repository in a local
directory, and point your presentation there. I do this all the time
for presentations.

For the presentation to work with -standalone, but without an internet connection, it requires a local MathJax installation on the computer used to (dis)play the presentation. This should be documented!

It should be documented that --self-contained does not work with
MathJax.

@KurtPfeifle
Copy link
Author

On Sat, Jun 27, 2015 at 1:07 AM, John MacFarlane notifications@github.com
wrote:

+++ Kurt Pfeifle [Jun 21 15 17:51 ]:

Why is it that the --mathjax parameter does not work in conjunction
with the --self-contained parameter? (This is documented in the Pandoc
README.)

Is it due to a current Pandoc bug or limitation? Or is it a bug or
"feature" of MathJax?

It's because MathJax loads some javascript stuff dynamically (calling
JavaScript functions), so in order to know what to include, pandoc
would have to have to interpret the JavaScript. Currently it just looks
at links in the HTML and CSS.

If I cannot use MathJax with --standalone, a HTML presentation using
math formulas will only work if there is a working internet connection
during the talk. This is not always guaranteed.

It's a simple matter to clone the mathjax repository in a local
directory, and point your presentation there. I do this all the time
for presentations.

Yes, I do that too.

But you are not always allowed to use your own notebook for a presentation
(think lightning talks). Some organizers expect a file to be handed over or
submitted (sometimes even shortly before the talk), and they do not like to
do a custom installation on the presentation notebook.

For the presentation to work with -standalone, but without an internet
connection, it requires a local MathJax installation on the computer used
to (dis)play the presentation. This should be documented!

It should be documented that --self-contained does not work with
MathJax.

This IS documented (in recent versions), but I was asking for an
explanation. Which you gave… thanks for it!

@jgm
Copy link
Owner

jgm commented Jun 28, 2015

This should be fixed now.

@jgm jgm closed this as completed Jun 28, 2015
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

3 participants