-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat: add Typst support as alternative formula renderer #2183
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: main
Are you sure you want to change the base?
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. |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
__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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you revert this change?
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) |
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.
Why do we change this?
@@ -0,0 +1,16 @@ | |||
.slidev-typst-wrapper .typst-line.highlighted { | |||
} | |||
.slidev-typst-wrapper .typst-line.dishonored { |
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.
Is this file duplicated?
This PR adds support for Typst as an alternative to KaTeX for formula rendering in Slidev.
Features
formulaRenderer
option in frontmatter to choose between 'katex' (default) and 'typst'Usage
To use Typst as the formula renderer, add this to your frontmatter: