mirror of
https://github.com/Myriad-Dreamin/tinymist.git
synced 2025-07-19 18:55:01 +00:00

* feat: move featured components * feat: provide package view and local documentation * stage * fix: compile error by merged commits
24 lines
666 B
Rust
24 lines
666 B
Rust
use std::sync::Arc;
|
|
|
|
use ecow::eco_format;
|
|
use typlite::value::*;
|
|
|
|
pub(super) fn lib() -> Arc<typlite::scopes::Scopes<Value>> {
|
|
let mut scopes = typlite::library::library();
|
|
|
|
// todo: how to import this function correctly?
|
|
scopes.define("example", example as RawFunc);
|
|
|
|
Arc::new(scopes)
|
|
}
|
|
|
|
/// Evaluate a `example`.
|
|
pub fn example(mut args: Args) -> typlite::Result<Value> {
|
|
let body = get_pos_named!(args, body: Content).0;
|
|
let body = body.trim();
|
|
let ticks = body.chars().take_while(|t| *t == '`').collect::<String>();
|
|
let body = &body[ticks.len()..];
|
|
let body = eco_format!("{ticks}typ{body}");
|
|
|
|
Ok(Value::Content(body))
|
|
}
|