haskell / haskell-language-server

Official haskell ide support via language server (LSP). Successor of ghcide & haskell-ide-engine.
Apache License 2.0
2.71k stars 368 forks source link

Documentation popup: \mathcal not resolved/formatted? #201

Open mouse07410 opened 4 years ago

mouse07410 commented 4 years ago

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...?

ndmitchell commented 4 years ago

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

mouse07410 commented 4 years ago

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?

ndmitchell commented 4 years ago

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...

mouse07410 commented 4 years ago

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 commented 4 years ago

Ping?

mouse07410 commented 4 years ago

Ping?

ndmitchell commented 4 years ago

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?

OwenGraves commented 3 years ago

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

bitwombat commented 2 years ago

Same error shows up in the Vim popup.

l8l commented 2 years ago

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

refaelsh commented 2 years ago

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

+1

mouse07410 commented 2 years ago

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.

rockboynton commented 1 year ago

I am still seeing this issue as well

michaelpj commented 10 months ago

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.

emlautarom1 commented 7 months ago

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