Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getting access to the unrendered TeX #22

Closed
jeisner opened this issue Apr 11, 2021 · 14 comments
Closed

getting access to the unrendered TeX #22

jeisner opened this issue Apr 11, 2021 · 14 comments

Comments

@jeisner
Copy link

jeisner commented Apr 11, 2021

Thanks for this awesome solution!

One issue that sometimes comes up: sometimes another user posts a formula and I want to reply with a slightly modified version, or even just quote what they said, including the formula.

Unfortunately, I can't get access to the tex that is underneath their image (unless I turn off math-with-slack!).
If I was the one who posted the previous formula, then I can get at the tex by asking to edit my previous post and then canceling the edit -- but Slack won't let me ask to edit another user's post.

Any ideas about how to expose the underlying tex?

  • It would be ideal if selecting text with an inline math image and copying to the clipboard acted as if math-with-slack were turned off, i.e., the clipboard would contain something like the $f(\epsilon)^2$ subexpression.
  • If that's not possible, is there some way to allow a user to (temporarily) unrender a math image, perhaps by double-clicking or right-clicking it?
@thisiscam
Copy link
Owner

If you right click on the rendered equation there should be an option to let you copy to clip board?

I agree that perhaps a "select -> ctrl+c" solution would be even better.

@thisiscam
Copy link
Owner

@jeisner I'm closing this for now since it seems like "right click -> copy" would work.
Please feel free to reopen if you have any suggestions!

@jeisner
Copy link
Author

jeisner commented Jun 7, 2021 via email

@thisiscam
Copy link
Owner

@jeisner that is very curious.
Which operating system are you on?

@thisiscam thisiscam reopened this Jun 7, 2021
@thisiscam
Copy link
Owner

This is what I see on my Mac:

Screen Shot 2021-06-07 at 1 38 36 PM

@jeisner
Copy link
Author

jeisner commented Jun 7, 2021

Oh, I see -- you have to right-click on the formula itself (as you'd said in an earlier post) and then you get a MathJax menu.  I was clicking elsewhere on the post. (I'm on Linux, btw.)

That does work for me for getting the text for a single long formula.  On the other hand, it doesn't help for copying a paragraph that is mostly text but keeps mentioning $x$ and $y$ and $y^2$.

Perhaps you'd be willing to leave this open, tagged as a feature request for the "select -> Ctrl+C" solution, if you think that request might be technically feasible?

@thisiscam
Copy link
Owner

thisiscam commented Jun 8, 2021

@jeisner I understand your request now.

TBH, this seems more like something Slack should fix. Currently right click a message on slack does give one a "copy" option, but that option does nothing! This is bad UX IMO.

If Slack will ever fix this problem, the raw formulas would have been copied automatically with the message too!

@thisiscam
Copy link
Owner

On the other hand, it appears that selecting spans of text that contains an MathJax equation is currently not possible: mathjax/MathJax#2240

@thisiscam
Copy link
Owner

thisiscam commented Jun 8, 2021

@jeisner I pushed a small update according to suggestions by the MathJax developers: https://groups.google.com/g/mathjax-users/c/1BzTQFINbqY/m/xGYAlhDNAwAJ.

If you try this new update copying text should "sort of work". It's far from perfect but I'd still like to share my progress now since I'm not sure when this issue will be entirely resolved.

With this update, if you select a paragraph that contains MathJax formulas, and do a copy, it will copy the original un-rendered text to your clipboard.
Unfortunately there are a few caveats:

  • The rendered formula will not be highlighted. This appears to be technically very difficult to resolve if possible at. This seems to be tolerable, but see the second issue.
  • If the formula is at begin or end of a message, it won't be copied unless you copy a larger portion of the message, potentially including the Author name etc. This is due to the first point that the rendered formula cannot be selected, and we are relying on the selection of the surrounding text to select the math formula.
  • Copying escaped formulas like $ \$10 $ is not well supported at the moment
  • It appears that simply pasting the message into the Slack's input box doesn't work well, since Slack clipboard logic seems be doing some magic and causes the rendered formula to have duplicated HTML unicode output (you can try and see what I mean). The workaround for now is to copy the message into some text editor on your machine, and then copy that to paste into Slack's input box. I will look into how to remove this painful process. This is fixed now

@jeisner
Copy link
Author

jeisner commented Jun 9, 2021

Oh that's brilliant. Great find, and thanks so much for implementing it!

@jeisner
Copy link
Author

jeisner commented Jun 9, 2021

If the formula is at begin or end of a message, it won't be copied unless you copy a larger portion of the message

Hmm, since you (or MathJax) is doctoring the HTML anyway, could this perhaps be handled by inserting some unobtrusive character before/after a formula image that is initial/final in a message? Perhaps just U+200B Zero Width Space? This would provide surrounding text that can be selected.

@thisiscam
Copy link
Owner

thisiscam commented Jun 9, 2021

@jeisner

Perhaps just U+200B Zero Width Space? This would provide surrounding text that can be selected.

I just tried this but unfortunately it appears that zero width space is not selectable. My guess is that probably because it has zero width, it's impossible to click on the character to select it in the first place. However, the thin space character https://www.compart.com/en/unicode/U+2009 does work, though once copied out the spaces are preserved.

Unfortunately, I'm not a JS guru (perhaps not even close to a hobbyist), so I'm out of idea for this.

I do realize though, that on Mac I can triple click a message to select all of that message! So even for single formulas without context, this copies the TeX just fine.

@jeisner
Copy link
Author

jeisner commented Jun 9, 2021

probably because it has zero width, it's impossible to click on the character to select it in the first place

I was thinking that click-drag might be able to get past it.

the thin space character https://www.compart.com/en/unicode/U+2009 does work

Perhaps someone else will be able to figure this out then.

though once copied out the spaces are preserved.

Perhaps deletable via JS.

I do realize though, that on Mac I can triple click a message to select all of that message!

Good point! I tried this on Ubuntu and found that triple click selects a paragraph. To pick up adjacent paragraphs as well, I can triple click and drag, so I can indeed get the whole message. Not very discoverable but does work!

@thisiscam thisiscam mentioned this issue Jun 10, 2021
3 tasks
@thisiscam
Copy link
Owner

@jeisner I will close this issue in favor of #25, which summarizes the current TODOs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants