arnog / mathlive

A web component for easy math input
https://cortexjs.io/mathlive
MIT License
1.53k stars 270 forks source link

FEATURE: Editing macros with arguments #1565

Open corlick98 opened 2 years ago

corlick98 commented 2 years ago

Description

If I have a macro with args (Plus: {args: 2, def: '#1+#2', expand: false}) and I add it to a key of a custom keyboard with placeholders for the args ({latex: '+', insert: '\\Plus{\\placeholder{}}{\\placeholder{}}'}) then if I get the value of the math-field the placeholders are not substituted for the values that the user filled in unless I add expand: true to the macro definition and use mf.getValue('latex-expanded') instead of latex or math-ml. Is this the intended behavior?

With expand: false: WithoutExpand

With expand: true: WithExpand

JSFiddle: https://jsfiddle.net/1rx3huz6/4/ Relevant line is 129.

Actual Behavior

Placeholders are not substituted unless macro is defined with expand: true and one uses .getValue('latex-expanded')

Expected Behavior

Placeholders are substituted in at least some of the other scenarios.

Environment

MathLive version mathlive: 0.77.0

Operating System [macOS, Windows, iOS. Include the version] Ubuntu 20.04.4 LTS

Browser [Safari, Chrome, IE, Firefox, etc... Try several browsers and note if there are differences between browsers. Include the version number of the browsers.] Firefox 103.0 (64-bit)

Also tested in jsfiddle on Chrome 103.0.5060.134 (Official Build) (64-bit).

arnog commented 2 years ago

I had a look at this. This is going to require a non-trivial amount of changes, but I'm going to give it a try. This may take a little while.

corlick98 commented 2 years ago

Thank you for looking into it.