Add foreign stdlib with code values and ship v0.0.4.

Bind `lang fences like formulas, run them via local interpreters, polish live-view code cards, and refresh bilingual welcome docs.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
cflmyandCursor committed 2026-08-05 12:50:01 +08:00
1 parent dcd0cdb8f7
commit b5e9d15391
33 files changed
+1044 -199

No files matched your search

+11
View File
@@ -4,6 +4,13 @@ use std::fmt;
use crate::formula::Expr as FormulaExpr;
/// Bound Markdown code fence (`type` → `code`).
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct CodeBlock {
pub lang: String,
pub source: String,
}
#[derive(Debug, Clone, PartialEq)]
pub enum Value {
None,
@@ -18,6 +25,8 @@ pub enum Value {
Map(Vec<(String, Value)>),
/// Parsed symbolic expression (`type` → `formula`).
Formula(FormulaExpr),
/// External language source from ```lang fence (`type` → `code`).
Code(CodeBlock),
}
impl Value {
@@ -31,6 +40,7 @@ impl Value {
Value::List(xs) => !xs.is_empty(),
Value::Map(xs) => !xs.is_empty(),
Value::Formula(_) => true,
Value::Code(c) => !c.source.is_empty(),
}
}
@@ -48,6 +58,7 @@ impl Value {
}
Value::Map(_) => "<map>".into(),
Value::Formula(e) => e.as_display(),
Value::Code(c) => format!("```{}\n{}\n```", c.lang, c.source),
}
}
}