mathlive icon indicating copy to clipboard operation
mathlive copied to clipboard

[Feature]: custom styling command that does not group or affect positioning

Open orelbn opened this issue 1 year ago • 0 comments

Description

There are already styling commands, such as /class, but I would like to see a similar command that does not affect the positioning or cause grouping (similar to mathit but with the ability to apply custom styles). The grouping caused by commands such as /class and /operatorname makes it so there are different behaviours to doing things, such as pressing the backward key based on whether the the cursor is in or outside the group that might not be wanted in all cases.

My Specific use case:

In my application, I have some custom logic for wrapping variables/functions/units in styling when the user types (so that I can identify variables even if the user types non-continuously).

The steps are as follows:

  • Parse the input to identify variables/functions/units.
  • Wrap the identified symbols in the input using the appropriate styling.
  • Grab the mathfield current position. (currPosition = mf.position)
  • Set the value of the math-field (setValue())
  • Reset the positioning of the math-field (mf.position = currPosition)

Because the /class styling command affects the position, it's difficult for me to figure out the logic for setting the position after wrapping the variables in all circumstances.

My current workaround:

  • I wrap things with styling commands that do not affect the positioning, such as 'mathbf' (even though semantically it's not ideal), then overwrite the styles already applied to it.

All the best,

Orel

orelbn avatar Nov 26 '24 19:11 orelbn