hackmd-io-issues icon indicating copy to clipboard operation
hackmd-io-issues copied to clipboard

LaTeX not rendering when downloading note as html

Open ddejohn opened this issue 5 years ago • 6 comments

Is this a hackmd.io issue?

Yes, the bug happens on https://hackmd.io

What's the problem

LaTeX is not rendering when downloading as html

Current behaviour

I've tried in Firefox, Chrome, and Edge (both downloading from and viewing in). Here is a screenshot of one of my notes:

Steps to reproduce:

Write some LaTeX, try to download your note as html.

ddejohn avatar Sep 11 '19 03:09 ddejohn

Was there any progress here? It's still occurring in my environment too.

  • On hackmd スクリーンショット 2020-11-12 17 52 47

  • via downloading html file スクリーンショット 2020-11-12 17 52 31

  • the code

$$
    C_{i}=\frac{L_i}{{}_{k_i}\mathrm{C}_2}=\frac{2L_{i}}{k_{i}\left(k_{i}-1\right)}
$$

Xilorole avatar Nov 12 '20 08:11 Xilorole

Was there any progress here?

PRamoneda avatar Jan 12 '21 16:01 PRamoneda

Hi guys, thanks for keeping this issue in track. There is no near plan to fix this, we are working on other tasks. We will list this as known issue.

jackycute avatar Jan 21 '21 05:01 jackycute

As a workaround,

  1. download the HTML file
  2. add the following, right after <head>
    • <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
  3. delete the code between <span class="MathJax_Preview" style="color: inherit;"> and <script type="math/tex; mode=display" id="MathJax-Element-1">(1 would be a specific number)
    • I've provided an example: https://gist.github.com/Xilorole/f9d4d167c3583923a0bef795690d32ea/revisions?diff=unified

worked for me. What you need was this;

 <div id="doc" class="markdown-body container-fluid comment-inner comment-enabled" data-hard-breaks="true"><p><span class="mathjax"><script type="math/tex; mode=display" id="MathJax-Element-1">
    C_{i}=\frac{L_i}{{}_{k_i}\mathrm{C}_2}=\frac{2L_{i}}{k_{i}\left(k_{i}-1\right)}
</script></span></p></div>

I hope this helps.

Xilorole avatar Jan 21 '21 06:01 Xilorole

A simpler (but uglier) workaround is to change the math renderer. image

Result of the first formula: image

andreamatt avatar Jan 21 '21 10:01 andreamatt

A workaround building upon @Xilorole's comment:

  1. download the HTML file
  2. add the following, right after <head>
    • <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>

...and then add span.MathJax_CHTML {display: none} in the <style> of the document.
This avoids having to manually delete all the badly rendered characters.

I hope this will get fixed, though! :)

rturquier avatar Nov 07 '22 10:11 rturquier