feat: add Typst support as alternative formula renderer#2183
feat: add Typst support as alternative formula renderer#2183KHemanthRaju wants to merge 1 commit intoslidevjs:mainfrom
Conversation
❌ Deploy Preview for slidev failed.
|
|
There is already a community addons for that #2179, have you tried it? If it works well I don't think we need to have it builtin |
Well, to be clear these are different features. Consider this slide, which uses both typst and katex: ---
addons:
- slidev-addon-typst
---
Given pair of graphs $(H, G)$, determine *if there exists* an injective map $f: V_H \to V_G$ satisfying:
'''typst
$ (v,v') in E_H <==> (f(v), f(v')) in E_G $
'''vs this slide, which would use typst exclusively via the proposed change: ---
formulaRenderer: typst
---
Given pair of graphs $(H, G)$, determine *if there exists* an injective map $f: V_H to V_G$ satisfying:
$ (v,v') in E_H <==> (f(v), f(v')) in E_G $ Neither the typst plugin nor MDC apparently supports inline syntax, I don't see how to avoid using katex for inline changes, but this is unfavorable. |
antfu
left a comment
There was a problem hiding this comment.
Ok, I am fine having it, but there are a few things need to be addressed before moving forward
| __SLIDEV_FEATURE_BROWSER_EXPORTER__: matchMode(options.data.config.browserExporter), | ||
| __SLIDEV_FEATURE_WAKE_LOCK__: matchMode(options.data.config.wakeLock), | ||
| __SLIDEV_HAS_SERVER__: options.mode !== 'build', | ||
| __SLIDEV_FEATURE_TYPST__: options.data.headmatter.formulaRenderer === 'typst', |
There was a problem hiding this comment.
| __SLIDEV_FEATURE_TYPST__: options.data.headmatter.formulaRenderer === 'typst', | |
| __SLIDEV_FEATURE_FORMULA_RENDERER__: options.data.headmatter.formulaRenderer, |
Should it be something like this?
| "@vueuse/motion": "^2.0.0", | ||
| "codemirror": "^5.65.16", | ||
| "defu": "^6.1.4", | ||
| "drauu": "^0.3.2", |
There was a problem hiding this comment.
Also, since typst is a Rust-based tool which could be rather heavy, I think we should make it an optional peer dep and ask users to install it manually when they opt-in to this feature.
| let can_open = true | ||
| let can_close = true | ||
|
|
||
| const prevChar = pos > 0 ? state.src.charCodeAt(pos - 1) : -1 |
There was a problem hiding this comment.
Do we have a markdown-it-typst plugin? I don't want to host this complexity here which would be hard for us to maintain
| } | ||
| export function transformMarkdown(ctx: MarkdownTransformContext) { | ||
| transformCodeWrapper(ctx) | ||
| transformInPageCSS(ctx) |
| @@ -0,0 +1,16 @@ | |||
| .slidev-typst-wrapper .typst-line.highlighted { | |||
| } | |||
| .slidev-typst-wrapper .typst-line.dishonored { | |||
|
Am I understanding correctly that even with this PR, inline math formulas are still currently limited to KaTeX? If so then I think it's not worth supporting Typst until we have that, because that's just adding complexity to the Typst code base while not being better than To properly support Typst on Slidev with inline math formula support, someone needs to implement a version of markdown-it-typst that is optimized for browser usage. |
This PR adds support for Typst as an alternative to KaTeX for formula rendering in Slidev.
Features
formulaRendereroption in frontmatter to choose between 'katex' (default) and 'typst'Usage
To use Typst as the formula renderer, add this to your frontmatter: