-
-
Notifications
You must be signed in to change notification settings - Fork 55
Add support for extension settings passed to markdown-it-pandoc #191
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
base: master
Are you sure you want to change the base?
Conversation
"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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops. mathjax3 was added by accident. I'll remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
@@ -8,7 +8,7 @@ | |||
"scripts": { | |||
"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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extensions: # optional: configure markdown-it extensions | |
extensions: # optional: configure markdown-it-pandoc extensions |
@@ -38,8 +38,10 @@ export type ViewSplit = typeof viewSplits[number] | |||
|
|||
export interface Settings { | |||
autoUpdateApp: boolean; | |||
extensions?: Record<string, boolean>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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!