Add bilingual public docs, keyword aliases, and frontmatter stdin for view.

English/Chinese user pages sit side by side; L0 builtins and lib/ text|表 dual APIs land with gold coverage. Capture/view input demos use stdin:/输入: so static export and first page load succeed.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
cflmyandCursor committed 2026-08-05 09:14:26 +08:00
1 parent fd36b92224
commit a5d30c00b3
68 files changed
+1812 -241

No files matched your search

+78
View File
@@ -30,3 +30,81 @@ pub fn builtin_int(v: &Value) -> Result<i64, String> {
_ => Err("int needs int, bool, or text".into()),
}
}
/// `type`: type tag as text (`none` / `bool` / `int` / `text` / `list`).
pub fn builtin_type(v: &Value) -> Value {
Value::Text(
match v {
Value::None => "none",
Value::Bool(_) => "bool",
Value::Int(_) => "int",
Value::Text(_) => "text",
Value::List(_) => "list",
}
.into(),
)
}
/// `trim`: strip leading/trailing Unicode whitespace from text.
pub fn builtin_trim(v: &Value) -> Result<Value, String> {
match v {
Value::Text(s) => Ok(Value::Text(s.trim().to_string())),
_ => Err("trim needs text".into()),
}
}
/// `split`: split text by separator → list of text parts.
pub fn builtin_split(value: &Value, sep: &Value) -> Result<Value, String> {
let text = match value {
Value::Text(s) => s.as_str(),
_ => return Err("split needs text value".into()),
};
let sep = match sep {
Value::Text(s) => s.as_str(),
_ => return Err("split needs text sep".into()),
};
if sep.is_empty() {
return Err("split sep must not be empty".into());
}
let parts: Vec<Value> = text
.split(sep)
.map(|p| Value::Text(p.to_string()))
.collect();
Ok(Value::List(parts))
}
/// `join`: join list elements with separator → text.
pub fn builtin_join(value: &Value, sep: &Value) -> Result<Value, String> {
let items = match value {
Value::List(xs) => xs,
_ => return Err("join needs list value".into()),
};
let sep = match sep {
Value::Text(s) => s.as_str(),
_ => return Err("join needs text sep".into()),
};
let mut out = String::new();
for (i, item) in items.iter().enumerate() {
if i > 0 {
out.push_str(sep);
}
out.push_str(&item.as_display());
}
Ok(Value::Text(out))
}
/// `at`: list element at index (0-based); out of range → None.
pub fn builtin_at(value: &Value, index: &Value) -> Result<Value, String> {
let xs = match value {
Value::List(xs) => xs,
_ => return Err("at needs list value".into()),
};
let i = match index {
Value::Int(n) => *n,
_ => return Err("at needs int index".into()),
};
if i < 0 || (i as usize) >= xs.len() {
return Ok(Value::None);
}
Ok(xs[i as usize].clone())
}