Skip to content

Commit

Permalink
feat: set macros for MathLive
Browse files Browse the repository at this point in the history
Closes #33
  • Loading branch information
AllanChain committed Dec 1, 2024
1 parent dbfd63c commit b7d75f4
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/ml-tweak.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,9 @@ export function configureMF(mfe: MathfieldElement) {
} catch (err) {
logseq.UI.showMsg(`Fail to configure MathLive inline shortcuts: ${err}`, 'error')
}
try {
mfe.macros = { ...mfe.macros, ...logseq.settings?.macros }
} catch (err) {
logseq.UI.showMsg(`Fail to configure MathLive macros: ${err}`, 'error')
}
}
19 changes: 19 additions & 0 deletions src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,25 @@ export const settingsConfig: SettingSchemaDesc[] = [
align: '\\begin{align*}\n#? &= #? \\\\\n #? &= #?\\end{align*}',
},
},
{
title: 'Macros',
description:
'Configure [MathLive macros](https://cortexjs.io/mathlive/guides/macros/).' +
'\n\nOne trick is to copy over default macros with `expand: false` to avoid automatic macro expansion.\n\n' +
'**Note**: MathLive have [bugs](https://github.com/arnog/mathlive/issues/1565) with `expand: false`, ' +
'Use it with caution.\n\nYou can also check [this discussion]' +
'(https://github.com/AllanChain/logseq-live-math/discussions/14) for more examples.',
key: 'macros',
type: 'object',
default: {
phase: {
def: '\\enclose{phasorangle}{#1}',
args: 1,
captureSelection: false,
expand: false,
},
},
},
{
title: 'Disable default shortcuts',
description: 'Disable default inline shortcuts defined by MathLive.',
Expand Down

0 comments on commit b7d75f4

Please sign in to comment.