Skip to content

Commit b7d75f4

Browse files
committed
feat: set macros for MathLive
Closes #33
1 parent dbfd63c commit b7d75f4

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/ml-tweak.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,9 @@ export function configureMF(mfe: MathfieldElement) {
3232
} catch (err) {
3333
logseq.UI.showMsg(`Fail to configure MathLive inline shortcuts: ${err}`, 'error')
3434
}
35+
try {
36+
mfe.macros = { ...mfe.macros, ...logseq.settings?.macros }
37+
} catch (err) {
38+
logseq.UI.showMsg(`Fail to configure MathLive macros: ${err}`, 'error')
39+
}
3540
}

src/settings.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,25 @@ export const settingsConfig: SettingSchemaDesc[] = [
111111
align: '\\begin{align*}\n#? &= #? \\\\\n #? &= #?\\end{align*}',
112112
},
113113
},
114+
{
115+
title: 'Macros',
116+
description:
117+
'Configure [MathLive macros](https://cortexjs.io/mathlive/guides/macros/).' +
118+
'\n\nOne trick is to copy over default macros with `expand: false` to avoid automatic macro expansion.\n\n' +
119+
'**Note**: MathLive have [bugs](https://github.com/arnog/mathlive/issues/1565) with `expand: false`, ' +
120+
'Use it with caution.\n\nYou can also check [this discussion]' +
121+
'(https://github.com/AllanChain/logseq-live-math/discussions/14) for more examples.',
122+
key: 'macros',
123+
type: 'object',
124+
default: {
125+
phase: {
126+
def: '\\enclose{phasorangle}{#1}',
127+
args: 1,
128+
captureSelection: false,
129+
expand: false,
130+
},
131+
},
132+
},
114133
{
115134
title: 'Disable default shortcuts',
116135
description: 'Disable default inline shortcuts defined by MathLive.',

0 commit comments

Comments
 (0)