mathlive icon indicating copy to clipboard operation
mathlive copied to clipboard

Feature: Auto-scaling brackets without smartfences

Open Khazuar opened this issue 5 years ago • 2 comments

Problem

There's multiple issues we have with the current smartfences-feature:

  • users don't understand the "ghost brackets"; they think it's an actual bracket and wonder why the system still wants them to input one.
  • When inserting a bracket somewhere, the cursor jumps to the ghost brackets location
  • When a user wants to turn the term (a+b+c+d) into (a+b)+(c+d), they often try to insert a ) after the b and a ( just before the c. The closing bracket will not get a \left in that case and the opening one will create it's own closing ghost bracket just before the existing closing bracket.

Not using the smartfence-feature means that we're stuck with "normal" brackets though that don't scale with their contents. We tried just adding an inline shortcut that would replace all ( with \left( and all ) with \right), but every \left( will automatically spawn a \right..

Solution

I don't expect all the issues with smartfences to be solved (I doubt there's a good solution for them tbh), but I'd be great if it were possible to have the \left and \right brackets as a separate feature. \right. should only be inserted at the very end of the line (main-line or subscript/superscript-line) when there's too many opening brackets (to keep the latex valid), and they should be removed when closing brackets are added. Likewise \left. might be inserted in the beginning if there's too many closing brackets.

Example

User input Latex markup returned from mf.$latex()
( \left(\right.
(, a \left(a\right.
(, a, ) \left(a\right)
(, a, ^ MOVE RIGHT ) \left(a^{}\right)
(, a, ^ b + ( c MOVE RIGHT ) \left(a^{b+\left(c\right.}\right)

Khazuar avatar Jan 15 '20 10:01 Khazuar

When a user wants to turn the term (a+b+c+d) into (a+b)+(c+d), they often try to insert a ) after the b and a ( just before the c. Just to be clear: this is the behavior you are observing with smartfence off?

Are you looking for smartfence (i.e. insertion of \left, \right) but without the ghosting brackets? If that's the case, I think I could add an option for that, but FYI, it's already possible to prevent the ghosted brackets from displaying by overriding the "ML__smart-fence__open" and "ML__smart-fence__close" CSS rules.

arnog avatar Jan 15 '20 20:01 arnog

Just to be clear: this is the behavior you are observing with smartfence off?

With the smartfence-feature on. Hiding the ghost fences would be a start, I don't mind if there's \right? at the end (as it is right now) instead of the \right. I proposed. But the caret is still automatically jumping to the ghost brackets position.

Khazuar avatar Jan 15 '20 20:01 Khazuar