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

+41
View File
@@ -627,6 +627,47 @@ fn lib_math_plot() {
let _ = std::fs::remove_file("tests/lib/math-plot-plot-1.svg");
}
fn python_available() -> bool {
for cmd in ["python", "python3"] {
if let Ok(out) = Command::new(cmd)
.args(["-c", "print(1)"])
.output()
{
if out.status.success() {
return true;
}
}
}
false
}
#[test]
fn lib_foreign_python() {
if !python_available() {
eprintln!("skip lib_foreign_python: no python on PATH");
return;
}
assert_out("tests/lib/foreign-python.mq.md", "hello-from-python");
}
#[test]
fn lib_foreign_run_lang() {
if !python_available() {
eprintln!("skip lib_foreign_run_lang: no python on PATH");
return;
}
assert_out("tests/lib/foreign-run-lang.mq.md", "4");
}
#[test]
fn lib_foreign_zh() {
if !python_available() {
eprintln!("skip lib_foreign_zh: no python on PATH");
return;
}
assert_out("tests/lib/外联-python.mq.md", "中文外联");
}
#[test]
fn bytecode_lib_math_formula() {
assert_out_backend(
+15
View File
@@ -0,0 +1,15 @@
---
title: foreign python hello
> lib/foreign.mq.md
---
# main
`hi` =
```python
print("hello-from-python")
```
*`out` = > run code=`hi` *
> print text=`out`
+10
View File
@@ -0,0 +1,10 @@
---
title: foreign run_lang
> lib/foreign.mq.md
---
# main
*`out` = > run_lang lang=python source=print(2+2) *
> print text=`out`
+15
View File
@@ -0,0 +1,15 @@
---
title: foreign zh
> lib/外联.mq.md
---
# main
`hi` =
```python
print("中文外联")
```
*`out` = > 运行 代码=`hi` *
> print text=`out`