Open kwinso opened 10 months ago
Also, what about some API to define these custom operators the way we do it in symbols.json
(with placeholders for value)?
asciimath-parser
uses replaceBeforeTokenizing
as one of its config params. It is a preprocess before the formula is passed into the parser. I can replace the matched token and replace it with common asciimath.
For example, the expression should be
[
[/mat\(([^,]+?),([^,]+?),([^\)]+?)\)/g,
(_, $1, $2, $3) => `limits(${$1})_(${$2} xx ${$3})`]
]
However, it's unsafe to execute user written code and inject it into the program. I haven't thought about how to implement this feature in Obsidian plugin safely.
Also, what about some API to define these custom operators the way we do it in
symbols.json
(with placeholders for value)?
asciimath-parser
is written in pure algorithm instead of grammar tools like antlr. So it may be hard to change the current grammar, or use it like C/C++ and define macros...
I've seen "limits" is defined with
mathop
I've been using
limits(A)_(m xx n)
to define matrix name with it's size. Not a convenient thing tbh.I wonder is it possible to add new
mat
ormatrix
operator defined withmathop
, which will do this. I image the API like this:mat(A, n)
->limits(A)_(n xx n)
mat(A, m, n)
->limits(A)_(m xx n)