fsprojects/IfSharp

MathJax not displayed on Print Preview and Download as HTML when used with XPlot.Plotly

cannorin opened this issue · 13 comments

Description

LaTeX equations $..$ inside Markdown blocks are rendered in the notebook with MathJax, but not in the print preview and the downloaded HTML.

When used with XPlot.Plotly.fsx, LaTeX equations $..$ inside Markdown blocks are rendered in the notebook with MathJax, but not in the print preview and the downloaded HTML.

Repro steps

  1. Change the cell to Markdown

  2. Enter any LaTeX equation such as $1+2$

3. Execute File>Print Preview

  1. Use #load "XPlot.Plotly.fsx

  2. Execute File>Print Preview

Expected behavior

The equation will get rendered.

Actual behavior

$1+2$ is shown as-is.

Known workarounds

Not known.

Print the notebook directly to a PDF with the browser.

Related information

  • Operating system: Debian GNU/Linux buster/sid
  • Branch: Release 3.0.0
  • .NET Runtime, CoreCLR or Mono Version:
$ mono --version
Mono JIT compiler version 5.18.0.225 (tarball Wed Jan  2 21:21:16 UTC 2019)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
        TLS:           __thread
        SIGSEGV:       altstack
        Notifications: epoll
        Architecture:  amd64
        Disabled:      none
        Misc:          softdebug 
        Interpreter:   yes
        LLVM:          yes(600)
        Suspend:       preemptive
        GC:            sgen (concurrent by default)
$ dotnet --version
2.2.102

I've tried this in a couple of places and print preview seems to be working for me:

image

It's behaving right on Edge / Windows 10 and Safari / macOS.

Does LaTeX work correctly for you in a Python notebook when you download the html?

@cgravill It seems not to be the simplest repro.
screenshot from 2019-01-18 19-58-26
screenshot from 2019-01-18 20-00-52

It turned out that the XPlot.Plotly.fsx is actually causing the problem:
screenshot from 2019-01-18 20-09-28

Sorry for confusing you.

I've updated the issue accordingly.

Ah it's probably this then:
plotly/plotly.py#515

Ahh so is it not related to IFSharp? Sorry if so...

It's in-between. The way we, and others, load XPlot/Plotly looks like it's causing the issue. It looks like they have a new flag that might help us. Needs investigating.

I found a potential workaround for this of hiding MathJax (used for LaTeX) from Plotly so it won't mangle it. It follows on from what I did with @npmurphy who originally integrated XPlot into IFSharp. It works in the notebook and on print preview for me:

image

@cannorin if you get a chance could you confirm if works for you? It's on pull request #196

I also updated XPlot.Plotly and Plotly JavaScript to their latest stable version so will need to do a bit more testing elsewhere too.

@cgravill Thanks! I'll try later today.

@cgravill It worked very nicely! 👍

btw I noticed F# highlighting is not working on the print preview. Am I missing something?

@cgravill It worked very nicely! +1

It also worked on my real notebooks which heavily use LaTeX and Plotly.

Great, thanks for testing. It looked good on my other tests too so I'll go ahead and merge.

On the F# highlighting, I don't think F# highlighting on print preview has ever worked. It's probably falling back on styling it as Python. Last time I looked into this sort of thing on #105 while I easily adjusted export the templates needed configuring inside the Python distribution. That seemed messy so it's been on hold until changes are made upstream or someone comes up with a good approach.

Thank you! Now I'll close this issue as solved.

Hmm... It looks really complicated. I think I might be able to override it with something like highlight.js. It's just an idea and will be a dirty workaround, though. Anyway, thanks for fixing this!