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

Conversion from Markdown to HTML+MathJax fails to add "http" in front of CND #1847

Closed
nbigaouette opened this Issue Dec 30, 2014 · 3 comments

Comments

Projects
None yet
3 participants
@nbigaouette

nbigaouette commented Dec 30, 2014

I'm playing around with equations in a markdown file for conversion to both LaTeX and HTML.

Unfortunately, there is a problem with the generated HTML file. The MathJax inclusing is missing the "http:" in front of the URL, breaking the rendering of equations.

Conversion to HTML is performed this way:

pandoc --toc --from=markdown --standalone --to=html5 --mathjax notes.md -o notes.html

The simple markdown file is the following:

# Section 1

Equation 1:

$$I = \int \rho R^{2} dV$$


Equation 2:

\begin{align}
I = \int \rho R^{2} dV
\end{align}


Equation 3:

$e^x = \sum_{n=0}^\infty \frac{x^n}{n!} = \lim_{n\rightarrow\infty} (1+x/n)^n$

Pandoc style equations/references:

(@foo)  $a^2 + b^2 = c^2$

As (@foo) says, ...

(@bar)  $e = x + y$

## Subsection 1.1

The resulting html is:

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="generator" content="pandoc">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
  <title></title>
  <style type="text/css">code{white-space: pre;}</style>
  <!--[if lt IE 9]>
    <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
  <![endif]-->
  <script src="//cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script>
</head>
<body>
<nav id="TOC">
<ul>
<li><a href="#section-1">Section 1</a><ul>
<li><a href="#subsection-1.1">Subsection 1.1</a></li>
</ul></li>
</ul>
</nav>
<h1 id="section-1">Section 1</h1>
<p>Equation 1:</p>
<p><span class="math">\[I = \int \rho R^{2} dV\]</span></p>
<p>Equation 2:</p>

<p>Equation 3:</p>
<p><span class="math">\(e^x = \sum_{n=0}^\infty \frac{x^n}{n!} = \lim_{n\rightarrow\infty} (1+x/n)^n\)</span></p>
<p>Pandoc style equations/references:</p>
<ol type="1">
<li><span class="math">\(a^2 + b^2 = c^2\)</span></li>
</ol>
<p>As (1) says, ...</p>
<ol start="2" type="1">
<li><span class="math">\(e = x + y\)</span></li>
</ol>
<h2 id="subsection-1.1">Subsection 1.1</h2>
</body>
</html>

Note the wrong:

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

instead of the expected

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

Passing the full MathJax url as in --mathjax="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" produce the proper javascript inclusion.

Using package named "pandoc-cabal", version 1.13.2-1, as compiled from https://aur.archlinux.org/packages/pandoc-cabal/ on ArchLinux x86_64.

@mpickering

This comment has been minimized.

Show comment
Hide comment
@mpickering

mpickering Dec 30, 2014

Collaborator

There has been quite a bit of discussion about what the mathjax url should be. It was previously hard coded as you suggest but this didn't work if people wanted to use https. Omitting the protocol, it is inferred from whatever the parent protocol is. (ie in your case it is probably file, when used on the web http or https).

Collaborator

mpickering commented Dec 30, 2014

There has been quite a bit of discussion about what the mathjax url should be. It was previously hard coded as you suggest but this didn't work if people wanted to use https. Omitting the protocol, it is inferred from whatever the parent protocol is. (ie in your case it is probably file, when used on the web http or https).

@nbigaouette

This comment has been minimized.

Show comment
Hide comment
@nbigaouette

nbigaouette Dec 30, 2014

I see. In that case, I'll explicitly leave the url option to --mathjax as to prevent any issue...

Thanks.

nbigaouette commented Dec 30, 2014

I see. In that case, I'll explicitly leave the url option to --mathjax as to prevent any issue...

Thanks.

@timtylin

This comment has been minimized.

Show comment
Hide comment
@timtylin

timtylin Dec 30, 2014

Contributor

@mpickering most browser protocol-relative URL implementations famously doesn't handle file correctly when opening as a standalone html file in your filesystem.

Contributor

timtylin commented Dec 30, 2014

@mpickering most browser protocol-relative URL implementations famously doesn't handle file correctly when opening as a standalone html file in your filesystem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment