Add support for extension settings passed to markdown-it-pandoc#191
Add support for extension settings passed to markdown-it-pandoc#191jadeglaze wants to merge 2 commits intomb21:masterfrom
Conversation
| "markdown-it-highlightjs": "^4.2.0", | ||
| "markdown-it-implicit-figures": "^0.9.0", | ||
| "markdown-it-pandoc": "^2.1.0", | ||
| "markdown-it-mathjax3": "^4.3.2", |
There was a problem hiding this comment.
Oops. mathjax3 was added by accident. I'll remove it.
There was a problem hiding this comment.
Actually, I left it. It doesn't run properly without it so I figured it's silly to remove it and leave the repo broken.
| "start": "react-scripts --openssl-legacy-provider start", | ||
| "build": "INLINE_RUNTIME_CHUNK=false react-scripts --openssl-legacy-provider build", | ||
| "postinstall": "cp node_modules/pagedjs/dist/paged.polyfill.js public && cp -r node_modules/katex/dist/ public/katex && cp node_modules/markdown-it-texmath/css/texmath.css public/katex", | ||
| "postinstall": "cp node_modules/pagedjs/dist/paged.polyfill.js public && cp -r node_modules/katex/dist/ public/katex && cp node_modules/markdown-it-texmath/css/texmath.css public/katex && mkdir -p public/highlight.js && cp node_modules/highlight.js/styles/base16/default-light.min.css public/highlight.js/ && cp node_modules/highlight.js/styles/base16/default-dark.min.css public/highlight.js/", |
There was a problem hiding this comment.
Need a light and dark theme for syntax highlighting.
package.json
Outdated
| "markdown-it-implicit-figures": "^0.9.0", | ||
| "markdown-it-pandoc": "^2.1.0", | ||
| "markdown-it-mathjax3": "^4.3.2", | ||
| "markdown-it-pandoc": "file:../markdown-it-pandoc", |
There was a problem hiding this comment.
This will obviously change to ^2.3.0 after markdown-it-pandoc side is merged/released.
src/renderPreview/convertMd.ts
Outdated
| let mdItPandoc: any | ||
| let defaultImageRender: any | ||
| // let mdItPandoc = markdownItPandoc(md) | ||
| // let defaultImageRender = mdItPandoc.renderer.rules.image as Renderer.RenderRule |
There was a problem hiding this comment.
I was figuring out how to load the settings but not initialize twice. This is working. Will remove the commented code.
| darkLink.setAttribute('media', '(prefers-color-scheme: dark)') | ||
| contentWindow.document.head.appendChild(darkLink) | ||
| } | ||
|
|
There was a problem hiding this comment.
Similar to injectMathCss except for the syntax highlighting themes we also need to set them up to be selected based on the system light/dark mode.
|
|
||
| autoUpdateApp: true | ||
| autoUpdateApp: true # whether to automatically check for and install updates | ||
| extensions: # optional: configure markdown-it extensions |
There was a problem hiding this comment.
| extensions: # optional: configure markdown-it extensions | |
| extensions: # optional: configure markdown-it-pandoc extensions |
|
|
||
| export interface Settings { | ||
| autoUpdateApp: boolean; | ||
| extensions?: Record<string, boolean>; |
There was a problem hiding this comment.
Could we use the type we have from markdown-it-pandoc here instead of Record<string, boolean>?
Also, seems extensions can never be undefined, so we don't need the ?
There was a problem hiding this comment.
Ah. Of course. That's an excellent idea... However, it's not exported yet. So here's another PR over there: mb21/markdown-it-pandoc#15
READY TO MERGE
This is the update to panwriter that passes all of extension settings to markdown-it-pandoc.
My settings.yaml looks like:
(and of course I tried a few variations)
Note that I ended up leaving markdown-it-mathjax3 since it doesn't run properly without it.
Let me know if you'd like any changes!