Myriad-Dreamin / tinymist

Tinymist [ˈtaɪni mɪst] is an integrated language service for Typst [taɪpst].
https://myriad-dreamin.github.io/tinymist
Apache License 2.0
272 stars 11 forks source link

Annotate code example as Typst code #284

Open Iorvethe opened 1 month ago

Iorvethe commented 1 month ago

Motivation

Annotating code snippets as Typst code in Markdown docs would make them correctly highlighted by Treesitter’s injection queries.

Description

I use Helix and currently when requesting docs for an item, code snippets inside aren’t highlighted as Typst code. I do not know whether the issue is with annotating the code or something else, but I suppose it is something in that vein. When writing Markdown and including a Typst snippet, it is correctly highlighted for example.

Examples/Questions

Hover Docs Markdown
image image
Myriad-Dreamin commented 1 month ago

I noticed that. The embedded document marks these code as example language, so we need a preprocessor to mark them all as typst language. This needs some effort.

https://github.com/typst/typst/blob/2d32ac73b63c81ea2754916feb7758c042f4ed3d/crates/typst/src/math/equation.rs#L31-L42

/// ```example
/// #set text(font: "New Computer Modern")
///
/// Let $a$, $b$, and $c$ be the side
/// lengths of right-angled triangle.
/// Then, we know that:
/// $ a^2 + b^2 = c^2 $
///
/// Prove by induction:
/// $ sum_(k=1)^n k = (n(n+1)) / 2 $
/// ```