mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-20 21:31:32 +02:00
Handle KaTeX warnings (#13760)
Co-authored-by: Joe Mooring <joe.mooring@veriphor.com> Fixes #13735
This commit is contained in:
committed by
GitHub
parent
75259636c8
commit
6334948515
@@ -7,6 +7,16 @@ const render = function (input) {
|
||||
const expression = data.expression;
|
||||
const options = data.options;
|
||||
const header = input.header;
|
||||
header.warnings = [];
|
||||
|
||||
if (options.strict == 'warn') {
|
||||
// By default, KaTeX will write to console.warn, that's a little hard to handle.
|
||||
options.strict = (errorCode, errorMsg) => {
|
||||
header.warnings.push(
|
||||
`katex: LaTeX-incompatible input and strict mode is set to 'warn': ${errorMsg} [${errorCode}]`,
|
||||
);
|
||||
};
|
||||
}
|
||||
// Any error thrown here will be caught by the common.js readInput function.
|
||||
const output = katex.renderToString(expression, options);
|
||||
writeOutput({ header: header, data: { output: output } });
|
||||
|
Reference in New Issue
Block a user