joeyuping / quick_latex_obsidian

MIT License
326 stars 21 forks source link

Fraction rule being overzealous #59

Closed Ellpeck closed 2 years ago

Ellpeck commented 2 years ago

Hi, first of all: I love this plugin, and I especially love the ease of use of rules, especially the fraction one.

However, sometimes it seems like the fraction rule is being a little overzealous in turning stuff into fractions. For example, a definition that involves replacing variables would look something like this:

E(F) = \{F^*[y_1 / t_1][y_2 / t_2]\dots[y_n / t_n] | t_1, \dots, t_n \in D(F)\}

However, even though I put a bunch of spaces between the slashes, adding additional spaces at the end still turns all of the parts into fractions. I would expect that, if I already went far beyond a part with a possible rule in it and then pressed space, previous rule matches would be ignored.

If I press space after a structure like y / t, it even turns it into a fraction with an empty part (\frac{}{ t}), when I would really expect it to ignore the rule entirely.

It would also be nice to possibly have a way to undo a rule replacement without having to undo the characters you input to trigger the rule replacement. For example, in MS Word, you can press the Undo button right after an automatic replacement to go back to the way it would have been without the replacement, without any of your other inputs being undone or replaced. This allows you to still type text that matches rules without having to actually use those rules in specific cases.

joeyuping commented 2 years ago

Thank you!!

I tried to resolve this by adding another conditional, which stops the autofraction from firing if the divide symbol "/" has spaces before and after it, or if space is pressed right after the divide symbol. This should allow the function you mentioned above to be typed more smoothly~ Please try updating to v2.3.4 and see if its ok.