summaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorJakob Peters <jakobj.peters@gmail.com>2024-08-11 13:15:30 -0700
committerGitHub <noreply@github.com>2024-08-11 20:15:30 +0000
commitd06f3f180cd06d11f45c439180027f57287f4f84 (patch)
treec28f2a500020ea58db5a9b456d33beebb40a77d2 /crates
parent831062a5880b42d20a5f819175c3d2d2e8b2e724 (diff)
Implement math mode language for `raw` (#4687)
Diffstat (limited to 'crates')
-rw-r--r--crates/typst/src/text/raw.rs16
1 files changed, 11 insertions, 5 deletions
diff --git a/crates/typst/src/text/raw.rs b/crates/typst/src/text/raw.rs
index e8cb3b99..fcf59c25 100644
--- a/crates/typst/src/text/raw.rs
+++ b/crates/typst/src/text/raw.rs
@@ -145,9 +145,10 @@ pub struct RawElem {
/// The language to syntax-highlight in.
///
/// Apart from typical language tags known from Markdown, this supports the
- /// `{"typ"}` and `{"typc"}` tags for
- /// [Typst markup]($reference/syntax/#markup) and
- /// [Typst code]($reference/syntax/#code), respectively.
+ /// `{"typ"}`, `{"typc"}`, and `{"typm"}` tags for
+ /// [Typst markup]($reference/syntax/#markup),
+ /// [Typst code]($reference/syntax/#code), and
+ /// [Typst math]($reference/syntax/#math), respectively.
///
/// ````example
/// ```typ
@@ -288,7 +289,11 @@ impl RawElem {
syntax.file_extensions.iter().map(|s| s.as_str()).collect(),
)
})
- .chain([("Typst", vec!["typ"]), ("Typst (code)", vec!["typc"])])
+ .chain([
+ ("Typst", vec!["typ"]),
+ ("Typst (code)", vec!["typc"]),
+ ("Typst (math)", vec!["typm"]),
+ ])
.collect()
}
}
@@ -344,11 +349,12 @@ impl Packed<RawElem> {
let foreground = theme.settings.foreground.unwrap_or(synt::Color::BLACK);
let mut seq = vec![];
- if matches!(lang.as_deref(), Some("typ" | "typst" | "typc")) {
+ if matches!(lang.as_deref(), Some("typ" | "typst" | "typc" | "typm")) {
let text =
lines.iter().map(|(s, _)| s.clone()).collect::<Vec<_>>().join("\n");
let root = match lang.as_deref() {
Some("typc") => syntax::parse_code(&text),
+ Some("typm") => syntax::parse_math(&text),
_ => syntax::parse(&text),
};