From fef005c4b7fcff0f9ae761408c9d8a8dccb9ac83 Mon Sep 17 00:00:00 2001 From: Shang-En Huang Date: Sun, 5 Jan 2020 16:43:37 +0800 Subject: [PATCH] Support global katex macros from book.json Grab the config and put them into the katex renderer. --- index.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index e9840bb..769b0a0 100644 --- a/index.js +++ b/index.js @@ -22,10 +22,13 @@ module.exports = { end: '$$' }, process(block) { + let config = this.book.config.get('pluginsConfig.katex-plus', {}) + let macros = config['macros'] || {} let output = '' try { output = katex.renderToString(block.body, { - displayMode: true + displayMode: true, + macros: macros }) } catch (e) { console.error(e) @@ -41,10 +44,13 @@ module.exports = { end: '$' }, process(block) { + let config = this.book.config.get('pluginsConfig.katex-plus', {}) + let macros = config['macros'] || {} let output = '' try { output = katex.renderToString(block.body, { - displayMode: false + displayMode: false, + macros: macros }) } catch (e) { console.error(e)