feat: embed Markdown codes (#1296)

* feat: directly output raw language 'typlite'

* docs: raw output
This commit is contained in:
Hong Jiarong 2025-02-18 10:14:17 +08:00 committed by GitHub
parent b24a7fd497
commit 33df227b17
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 16 additions and 0 deletions

View file

@ -10,3 +10,7 @@ typlite main.typ
# specify output
typlite main.typ output.md
```
## Feature
- **Raw Output**: Raw codes with `typlite` language will be directly output into the Markdown result.

View file

@ -582,6 +582,18 @@ impl TypliteWorker {
fn raw(node: &SyntaxNode) -> Result<Value> {
let mut s = EcoString::new();
let raw = node.cast::<ast::Raw>().unwrap();
// Raw codes with typlite language will not be treated as a code block but directly output into the Markdown result.
if let Some(lang) = raw.lang() {
if &EcoString::from("typlite") == lang.get() {
for line in raw.lines() {
s.push_str(&Self::value(Self::str(line.to_untyped())?));
s.push('\n');
}
return Ok(Value::Content(s));
}
}
if raw.block() {
s.push_str(&Self::value(Self::str(node)?));
return Ok(Value::Content(s));