andrusha / mathml-chrome

Chrome extension which provides LaTeX & MathML rendering for any page you want via MathJax.
https://chrome.google.com/webstore/detail/gebhifiddmaaeecbaiemfpejghjdjmhc
MIT License
15 stars 6 forks source link

Enable for wikipedia #7

Open physikerwelt opened 8 years ago

physikerwelt commented 8 years ago

Can you add a custom css rule to enable this plugin in the new Math rendering for Wikipeda http://en.wikipedia.beta.wmflabs.org/wiki/Math ?

andrusha commented 8 years ago

@physikerwelt I don't quite get the request. Wikipedia has its own formula rendering engine and from what I see it's working well. Why would you need this plugin enabled also?

physikerwelt commented 8 years ago

@andrusha sorry for my short description. If you look at the current beta version you see SVG images. They look kind of good at a first glance.

However, with MathML the integration is slightly better, and some people prefer to use the MathJax menu for example to be able to zoom formulae. This could be realized with your plugin since the MathML is code is there, but it's hidden. screenshot-math - wikipedia the free encyclopedia - google chrome Everything that needs to be done is to change the css in the following way

Remove the svg fallback

    .mwe-math-mathml-inline + .mwe-math-fallback-image-inline,      
       .mwe-math-mathml-display + .mwe-math-fallback-image-display { display: none !important; }

And show the mathML

    .mwe-math-mathml-a11y {     
           clip: auto;      
           overflow: visible;       
           position: static;        
           width: auto;     
           height: auto;        
           opacity: 1;      
    }

Note, that this was just introduced today which means that it will be not available on wikipedia.org before April 28th.

That's how it looks with the current version of your plugin with a manual rewrite of the css 2016-04-25

andrusha commented 8 years ago

I see how this can be useful, but I'm a bit wary about overwriting default Wikipedia rendering, I would prefer to keep this plugin non-destructive, it was intended as a way to add formulae rendering to the pages which were lacking it.

In your case it would probably be better to use some other plugin to inject CSS styles like that one: https://chrome.google.com/webstore/detail/stylebot/oiaejidbmkiecgbjeifoejpgmdaleoha?hl=en

Or maybe you could fork and create new plugin strictly for Wikipedia.

physikerwelt commented 8 years ago

@andrusha I understand your argument. What is about making that an optional feature for your plugin? I get the impression that a forked version of your plugin might confuse users. @fred-wang What is your oppinion? I think it would be bad, if math power users need to install one plugin for each site.

fred-wang commented 8 years ago

I think all what is needed (besides that mathml-chrome plugin) is a way to define CSS rules in a custom user stylesheets. For Safari/Epiphany, there is some configuration menu for that and probably something similar exists in Chrome...

I have a greasemonkey script that I guess should work https://github.com/fred-wang/mathjax-native-mathml-greasemonkey. However, it must be adapted to remove the mathjax menu change and so avoid conflicts with this mathml-chrome plugin.

Maybe one of the people who were interested in having MathJax's HTML-CSS output instead of SVG should try it... Or maybe you (@physikerwelt) should try it, since the existence of that mathml-chrome plugin was one of the argument you gave to remove the client-side MathJax module.

fred-wang commented 8 years ago

@physikerwelt If found that there is a user stylesheet but no UI: https://bugs.chromium.org/p/chromium/issues/detail?id=2393#c45 (not sure it's that's really the latest update)

physikerwelt commented 8 years ago

I finally installed Chrome:-( so yes, I can try it. I'm currently testing chromevox. It works quite nice after I modified the css manually.

physikerwelt commented 8 years ago

voila http://stylebot.me/styles/13574

physikerwelt commented 8 years ago

while it works well on beta which uses http, there is an additional warning for prduction wikipedia which uses https Is there a way to load mathjax via https?

physikerwelt commented 8 years ago

That seems to be a general problem cf #2

physikerwelt commented 8 years ago

I guess one could get rid of http here https://github.com/andrusha/mathml-chrome/blob/master/inject.coffee#L14 ´//cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML´ should work Am I right @fred-wang ?

fred-wang commented 8 years ago

I'm not familiar with all of this to know whether that would work but note that anyway MathJax recommends to use https http://docs.mathjax.org/en/latest/start.html#using-the-mathjax-content-delivery-network-cdn by default

andrusha commented 8 years ago

@physikerwelt @fred-wang so... maybe you guys could give me a bit more context? What are you trying to achieve and how it relates to other projects you're working on?

fred-wang commented 8 years ago

@andrusha As said in https://github.com/andrusha/mathml-chrome/issues/7#issuecomment-214481518 Wikipedia will replace PNG images with the MathML + SVG fallback mode. The default CSS style hides MathML and displays the SVG fallback. SVG is better than PNG but still has some issues (rendering quality, inability to search the text, not accessible to screen readers etc). It's easy to write some add-on or custom user stylesheet to switch to MathML instead of SVG and mechanisms exist on all browsers.

Now Chrome users also complained about the SVG fallback but MathML rendering is not natively supported in this browser. Until that happens, we would like to recommend your MathJax extension, but it seems that is not usable on HTTPS pages such as wikipedia websites. That's probably a bug on its own and not specific to wikipedia.

andrusha commented 8 years ago

@fred-wang makes sense now. I can dig a bit deeper into HTTPS issue, from what I understand it's about security settings in the browser, so insecure scripts would not leech into secure sites. Maybe worth getting in touch with MathJax guys too.

fred-wang commented 8 years ago

@andrusha So do you have any reason to use http instead of https (as recommended by MathJax doc) here: https://github.com/andrusha/mathml-chrome/blob/master/inject.coffee#L14

andrusha commented 8 years ago

Good point, this is 4-years old code, I honestly have no idea why I did it that way. Could be that MathJax did not support https back then. Let's change it.

andrusha commented 8 years ago

@fred-wang @physikerwelt I finally had some time to play around with mathjax to resolve this issue. It now does pick up formulas in alt tags of images with a particular class. Maybe I should preserve the original tag too so the same styling will apply?

Before

screenshot 2016-08-13 19 49 29

After

screenshot 2016-08-13 19 49 06