fix: handle catex error
This commit is contained in:
@@ -6,19 +6,26 @@ const router = express.Router();
|
|||||||
|
|
||||||
// localhost:3002/katex
|
// localhost:3002/katex
|
||||||
router.get('/', async (req, res) => {
|
router.get('/', async (req, res) => {
|
||||||
const original = req._parsedUrl.search;
|
try {
|
||||||
|
const original = req._parsedUrl.search;
|
||||||
|
|
||||||
const latexString = original.replace('?', '').replaceAll('+', '+').replaceAll('&space;', '');
|
const latexString = original
|
||||||
console.log({ latexString });
|
.replace('?', '')
|
||||||
|
.replaceAll('+', '+')
|
||||||
|
.replaceAll('&space;', '');
|
||||||
|
console.log({ latexString });
|
||||||
|
|
||||||
const html = katex.renderToString(latexString, {
|
const html = katex.renderToString(latexString, {
|
||||||
throwOnError: false,
|
throwOnError: false,
|
||||||
output: 'mathml'
|
output: 'mathml'
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log({ html });
|
console.log({ html });
|
||||||
|
|
||||||
res.send(html);
|
res.send(html);
|
||||||
|
} catch (error) {
|
||||||
|
res.send('failed');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|||||||
Reference in New Issue
Block a user