Skip to content

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jadeglaze
Copy link

@jadeglaze jadeglaze commented Mar 15, 2025

READY TO MERGE

This is the update to panwriter that passes all of extension settings to markdown-it-pandoc.

My settings.yaml looks like:

autoUpdateApp: true

extensions:
  tex_math_single_backslash: true
  highlight: true
  highlight_inline: true

(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!

"markdown-it-implicit-figures": "^0.9.0",
"markdown-it-pandoc": "^2.1.0",
"markdown-it-mathjax3": "^4.3.2",
Copy link
Author

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.

Copy link
Author

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/",
Copy link
Author

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",
Copy link
Author

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.

let mdItPandoc: any
let defaultImageRender: any
// let mdItPandoc = markdownItPandoc(md)
// let defaultImageRender = mdItPandoc.renderer.rules.image as Renderer.RenderRule
Copy link
Author

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)
}

Copy link
Author

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.

@jadeglaze jadeglaze changed the title WIP: add support for extension settings passed to markdown-it-pandoc Add support for extension settings passed to markdown-it-pandoc Mar 23, 2025

autoUpdateApp: true
autoUpdateApp: true # whether to automatically check for and install updates
extensions: # optional: configure markdown-it extensions
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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>;
Copy link
Owner

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 ?

Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants