-
Notifications
You must be signed in to change notification settings - Fork 29
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
Use custom template with rehype-typst #618
Comments
Rendering fenced code really looks like a killer feature. But we can be more fit in typst-y style setup. If I want to extend _
.use(rehypeTypst, {
transformers: [
{
type: FencedCodeMatcher,
language: /^typst-cetz$/,
use: 'my-cetz-template.typ',
show: 'typst-cetz-main',
}
]
} And implement the show rule #let typst-cetz-main(content, caption: none, ..more-args) = {
import "@preview/cetz:0.3.1"
show raw.where(lang: "typst-cetz"): it => cetz.canvas({
import cetz.draw: *
let cetz-scope = (..);
figure(diagram(eval(it.text, cetz-scope)), caption: caption)
})
content
} It would capture the typst-cetz #import "my-cetz-template.typ": typst-cetz-main
#show: typst-cetz-main.with(..sys.inputs)
${content} |
Add some comment, It is fancy but in practical we cannot report the error with precise source location anymore. |
my two cents:
|
The title was unmatched. I edited the title to match their description. |
Is your feature request related to a problem? Please describe.
I want to use packages (e.g. physica) in my math, and I have patch the
inlineMathTemplate
anddisplayMathTemplate
with#import "@preview/physica:0.9.4": *
manually.Describe the solution you'd like
add options that can pass custom template to rehype-typst like this:
or just write extra lines to be added before the default templates.
And I think more than just rendering math is a good idea. Such as rendering some diagrams:
The text was updated successfully, but these errors were encountered: