vermiculus / sx.el

Stack Exchange for Emacs
http://stackapps.com/q/3950
709 stars 40 forks source link

show math formule #331

Closed beyondpie closed 6 years ago

beyondpie commented 7 years ago

Hi, when I enter the math topic, latex format is the original one. How can I make it possible to see the real formula? Thanks Songpeng

vermiculus commented 7 years ago

Similar to AUCTeX's preview-latex? I'm afraid that's not yet possible. Pull requests are welcome, though 😉

TobiasZawada commented 6 years ago

That works out of the box with https://github.com/TobiasZawada/TeXfrag/. It would be nice if sx-question-mode--print-question would run a hook after printing is finished. Therewith I wouldn't need to advice sx-question-mode--print-question.

texfrag-sx

Pityingly, if someone inserts some displayed formula in the middle of the text as, e.g., $$z=\sqrt{x^2 + y^2}$$ that formula is embedded within the text and therefore displaced. I think that will not change in the near future. I delegate the main work to the preview package and steal the image overlays from there. Correcting the error of others, i.e., the formatting of displayed formulas, would force quite some work on me.

TobiasZawada commented 6 years ago

@vermiculus May I insert additional newlines into the print buffer after sx-question-mode--print-question has finished?

vermiculus commented 6 years ago

I agree that trying to correct bad formatting on account of display-math being inline in a paragraph is out-of-scope for this; I don't think MathJax knows how to 'continue' a paragraph as TeX does after $$ or \[ anyway.

A hook seems like a fantastic idea; would you mind opening a PR? 😄

TobiasZawada commented 6 years ago

The last version of TeXfrag fixes the display-math problem. It inserts missing newlines around display-math environments.

vermiculus commented 6 years ago

Thanks again for the PR 😄 should we consider this issue resolved, or is there more we can do to advertise the capability of this combo?

TobiasZawada commented 6 years ago

You wrote:

Thanks again for the PR :smile: should we consider this issue resolved, or is there more we can do to advertise the capability of this combo?

I regard this issue as resolved if https://travis-ci.org/vermiculus/sx.el/builds/321518650?utm_source=github_status&utm_medium=notification is nothing serious. Could you tell me what the failing of that test means and how serious it is?

Note: I wrote TeXfrag for other use-cases (e.g., showing math in doxygen comments and showing math of html pages with embedded MathJax in eww). When I saw sx I noted that TeXfrag can also be helpful there. I think if you use it for sx it should become part of elpa?

vermiculus commented 6 years ago

The tests are failing because we've neglected to update them after some fairly core markdown-mode changes our entire testing framework is temporarily broken, probably related to cask-path issues. They're nothing to worry about. The big thing we care about is whether it compiles without errors – ideally without warnings.

If you submit it to the ELPA, that would likely be a boon for the entire Emacs community – but you will need to provide copyright assignment to the FSF. Submitting to MELPA will achieve almost the same effect (and it's worthwhile to note that sx.el itself is also excluded from the ELPA).

TobiasZawada commented 6 years ago

Of course, melpa it is. Somebody already has put ~msearch.el~ html-check-frag into melpa. I never did something like that myself before. Okay time to learn something new...

beyondpie commented 6 years ago

@vermiculus @TobiasZawada hi, guys, thanks a lot for your efforts, and I test it in math stack exchange. It works well! I love it. Just one small question, is it possible to set texfrag always show the preview under the math stack exchange? Songpeng

beyondpie commented 6 years ago

wait, I just set the texfrag global mode. and it works automatically to detect the latex fragment. Thanks!