-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Check if Katex macro persistence can work #1105
Comments
I think the problem is that some object needs to be passed to
So I think these changes are needed to make class MdToHtml_Katex {
constructor() {
this.cache_ = {};
this.assetsLoaded_ = false;
// initial empty macro object
this.macros = {};
}
// ...
processContent(renderedTokens, content, tagType) {
try {
const cacheKey = tagType + '_' + content;
let renderered = null;
if (this.cache_[cacheKey]) {
renderered = this.cache_[cacheKey];
} else {
renderered = katex.renderToString(content, {
displayMode: tagType === 'block',
// here we put the (mutatable) macro object
macros: this.macros
});
this.cache_[cacheKey] = renderered;
}
if (tagType === 'block') renderered = '<p>' + renderered + '</p>';
renderedTokens.push(renderered);
} catch (error) {
renderedTokens.push('Cannot render Katex content: ' + error.message);
}
return renderedTokens;
}
// ...
} |
I've tried the two examples on the forum but for both the app says that it's invalid Katex code.
Any chance you could post examples that work and expected result? |
Yes sorry I didn't use code blocks so a backslash got eaten. The below should display a matrix but doesn't. It has a "global macro" defined in the first pair of
The below does display a matrix, but because the usage of the defined macro is in the same
|
The solution you posted above worked. |
https://discourse.joplin.cozic.net/t/is-there-a-way-to-get-katex-global-macros-working/1316
The text was updated successfully, but these errors were encountered: