haskell-language-server icon indicating copy to clipboard operation
haskell-language-server copied to clipboard

Documentation popup: \mathcal not resolved/formatted?

Open mouse07410 opened this issue 4 years ago • 15 comments

VS Code with the current haskell-language-server master, GHC-8.10.1.

For some reason, when the Documentation popup is displayed - \mathcal{} content is not formatted. Here's what the popup shows: Screen Shot 2020-07-14 at 11 29 56

Here's what I see after clicking on "Documentation": Screen Shot 2020-07-14 at 10 59 32

Is it normal, or is there a way to make it formatted properly? How can I change my setup/configuration to enable that? Do I need to install some extra package...?

mouse07410 avatar Jul 14 '20 15:07 mouse07410

The source text actually says mathcal, but then Javascript goes in and replaces it. In general, Javascript won't run on docs being served up from local disk (as its a security risk), which I suspect is what happens. I personally think that relying on Javascript to format a slightly slopey O instead of just doing italics is a dumb case of making everything worse so pedants can have a fractionally more correct O. In Hoogle I just drop the entire mathcal bit, since I'm splicing in snippets of HTML, and don't want some Javascript going on too, which trashes page reflow time etc. See https://github.com/ndmitchell/hoogle/issues/353

ndmitchell avatar Jul 15 '20 18:07 ndmitchell

Javascript won't run on docs being served up from local disk (as its a security risk), which I suspect is what happens

As far as I'm concerned, the real security risk is a ton of crappy JavaScript pulled from all over the world that a lot of web sites link to.

I'd much prefer to have a configuration option to allow JavaScript run on docs served from the local disk, as it's an acceptable security risk (after all, I'm running this Cabal executable that came from the 'Net, ain't I? ;).

However, if it's possible to avoid JavaScript altogether - I'd love to embrace that solution. Is it feasible here?

mouse07410 avatar Jul 15 '20 21:07 mouse07410

It would be feasible for upstream not to use Javascript, if they wanted faster pages and an irrelevantly less precise font. But upstream seems to have introduced it deliberately and foolishly...

ndmitchell avatar Jul 16 '20 09:07 ndmitchell

But since upstream is what it is - regardless whether their decision was smart or not, how can we fix it here downstream?

For example, I'd be perfectly happy with simply enabling Javascript to execute files stored on my local disk (I consider that risk far more acceptable than what web browsers do on almost each and every site nowadays).

mouse07410 avatar Jul 16 '20 14:07 mouse07410

Ping?

mouse07410 avatar Jul 20 '20 14:07 mouse07410

Ping?

mouse07410 avatar Jul 21 '20 02:07 mouse07410

Given this issue is fairly minor (visual glitch), and a consequence of upstream making poor decisions, I suspect it's going to be a while before anyone gets around to it. If you're particularly interested, feel free to investigate. For example, is it possible to enable JS in this context? Is JS enabled but the support .js file not found? Would it be feasible/desirable to rewrite mathcal before rendering it?

ndmitchell avatar Jul 21 '20 11:07 ndmitchell

I believe this is a similar issue, but it would be nice to have image/gif support on hover as well as math support. image On the haddocks: image

Even if displaying math or gifs would be difficult to support, it would be good to at least display the raw text (instead of cannot render inline math formula) or the image path location (instead of the little image icon), like what is shown with :doc:

image

OwenGraves avatar Mar 18 '21 05:03 OwenGraves

Same error shows up in the Vim popup.

bitwombat avatar Apr 18 '22 07:04 bitwombat

I still have this problem as of August 2022. I would highly appreciate a fix!

l8l avatar Aug 21 '22 05:08 l8l

I still have this problem as of August 2022. I would highly appreciate a fix!

+1

refaelsh avatar Oct 11 '22 11:10 refaelsh

I want to re-emphasize that I don't see serious security implications of allowing LaTeX or JavaScript run on local files.

After all, that's what Cabal and Stack do.

mouse07410 avatar Oct 11 '22 12:10 mouse07410

I am still seeing this issue as well

rockboynton avatar Aug 10 '23 05:08 rockboynton

I don't think this is something we can solve very easily. We'd have to return raw HTML for the documentation instead of markdown, I think, after generating images for the latex blocks locally. Perhaps not impossible, but tricky.

michaelpj avatar Jan 11 '24 09:01 michaelpj

What about something like https://github.com/fKunstner/latex-to-utf8?

emlautarom1 avatar Apr 09 '24 17:04 emlautarom1