feat(markup): adopt v0.3 as sole mapping (** code, * return)

Make prose-unified Markup the only runtime: bold segments are executable,
italic is return, params can be inferred from body/prose, with no v0.2 dual
mode. Migrate lib and structure/keywords golds; gate on tests/markup-v03.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
cflmyandCursor committed 2026-09-13 20:38:53 +08:00
1 parent 00a77181ef
commit bfb10d172b
114 files changed
+2271 -732

No files matched your search

+1
View File
@@ -6,6 +6,7 @@
|------|------|
| [`structure/`](structure/) | 函数、调用、分支、循环、表、导入、位置实参 |
| [`keywords/`](keywords/) | `print`、布尔与 `and`/`or`/`not` |
| [`markup-v03/`](markup-v03/) | **Markup v0.3 草案金样例**(`#[ignore]` 至旗标落地;见目录 README) |
| [`errors/`](errors/) | 期望失败(诊断文案) |
| [`gold.rs`](gold.rs) | 集成测试:跑上述夹具并比对 stdout / stderr |
+66
View File
@@ -3708,3 +3708,69 @@ fn tempfile_dir(prefix: &str) -> std::path::PathBuf {
std::fs::create_dir_all(&dir).unwrap();
dir
}
// ---------------------------------------------------------------------------
// Markup mapping v0.3 — fixtures under tests/markup-v03/
// ---------------------------------------------------------------------------
fn assert_out_v03(path: &str, expect: &str) {
assert_out(path, expect);
}
#[test]
fn markup_v03_inc_prose() {
assert_out_v03("tests/markup-v03/inc-prose.mq.md", "38");
}
#[test]
fn markup_v03_bold_call() {
assert_out_v03("tests/markup-v03/bold-call.mq.md", "38");
}
#[test]
fn markup_v03_dual_call() {
assert_out_v03("tests/markup-v03/dual-call.mq.md", "38\n38");
}
#[test]
fn markup_v03_greet_default() {
assert_out_v03(
"tests/markup-v03/greet-default.mq.md",
"您好,\nMarqdo\n嗨,\nWorld",
);
}
#[test]
fn markup_v03_dead_bind() {
assert_out_v03("tests/markup-v03/dead-bind.mq.md", "你好");
}
#[test]
fn markup_v03_empty_return_hr() {
assert_out_v03("tests/markup-v03/empty-return-hr.mq.md", "hi\ndone");
}
#[test]
fn markup_v03_empty_return_none() {
assert_out_v03("tests/markup-v03/empty-return-none.mq.md", "hi\ndone");
}
#[test]
fn markup_v03_empty_return_stars() {
assert_out_v03("tests/markup-v03/empty-return-stars.mq.md", "hi\ndone");
}
#[test]
fn markup_v03_empty_return_compat() {
assert_out_v03("tests/markup-v03/empty-return-compat.mq.md", "hi\ndone");
}
#[test]
fn markup_v03_multi_bold() {
assert_out_v03("tests/markup-v03/multi-bold.mq.md", "a\nb");
}
#[test]
fn markup_v03_print_bold() {
assert_out_v03("tests/markup-v03/print-bold.mq.md", "Hello");
}
+3 -3
View File
@@ -4,15 +4,15 @@ title: 布尔与逻辑关键字
# main
*a = True*
*b = False*
**a = True**
**b = False**
1. `a` and not `b`
> print text=ok
2. *
> print text=fail
*probe = 1*
**probe = 1**
1. None
> print text=none-truthy
+1 -1
View File
@@ -5,6 +5,6 @@ stdin: Ada
# main
*name = > input prompt="Name:\n"*
**name = > input prompt="Name:\n"**
> print text=Hello `name`!
+1 -1
View File
@@ -5,6 +5,6 @@ description: Read one stdin line (optional prompt)
# main
*name = > input prompt="Name:"*
**name = > input prompt="Name:"**
> print text=Hello `name`!
+5 -5
View File
@@ -4,17 +4,17 @@ title: quoted string literal
# main
*s = "a\nb"*
**s = "a\nb"**
> print text=`s`
*s2 = "hex \x22 quote\x27 single"*
**s2 = "hex \x22 quote\x27 single"**
> print text=`s2`
*s3 = "\u{4e2d}\u{6587}"*
**s3 = "\u{4e2d}\u{6587}"**
> print text=`s3`
*s4 = "keep \q verbatim"*
**s4 = "keep \q verbatim"**
> print text=`s4`
*s5 = "\x41\x42\x43"*
**s5 = "\x41\x42\x43"**
> print text=`s5`
+7 -7
View File
@@ -5,26 +5,26 @@ description: trim split join at type + lib imports
# main
*raw = " hi "*
**raw = " hi "**
*t = > trim `raw`*
**t = > trim `raw`**
> print text=`t`
*parts = > split value=a,b,c sep=,*
**parts = > split value=a,b,c sep=,**
*n = > len `parts`*
**n = > len `parts`**
> print text=`n`
*mid = > at value=`parts` index=1*
**mid = > at value=`parts` index=1**
> print text=`mid`
*joined = > join value=`parts` sep=-*
**joined = > join value=`parts` sep=-**
> print text=`joined`
*ty = > type `parts`*
**ty = > type `parts`**
> print text=`ty`
+6 -6
View File
@@ -5,9 +5,9 @@ description: Built-in conversions and length
# main
*s = "hello"*
**s = "hello"**
*n = > len `s`*
**n = > len `s`**
> print text=`n`
@@ -19,18 +19,18 @@ description: Built-in conversions and length
| b |
| c |
*m = > len `xs`*
**m = > len `xs`**
> print text=`m`
*t = > str 42*
**t = > str 42**
> print text=`t`
*i = > int `t`*
**i = > int `t`**
> print text=`i`
*j = > int True*
**j = > int True**
> print text=`j`
+3 -3
View File
@@ -4,15 +4,15 @@ title: 中文布尔与逻辑
# main
*a = 真*
*b = 假*
**a = 真**
**b = 假**
1. `a` 且 非 `b`
> 打印 内容=ok
2. *
> 打印 内容=fail
*probe = 1*
**probe = 1**
1. 空
> 打印 内容=none-truthy
+4 -4
View File
@@ -5,14 +5,14 @@ description: 打印 / 长度 / 文本 / 整数(与英文别名等价)
# main
*s = "hello"*
**s = "hello"**
*n = > 长度 值=`s`*
**n = > 长度 值=`s`**
> 打印 内容=`n`
*t = > 文本 值=7*
**t = > 文本 值=7**
*i = > 整数 值=`t`*
**i = > 整数 值=`t`**
> 打印 内容=`i`
+21
View File
@@ -0,0 +1,21 @@
# Markup v0.3 金样例
| | |
|---|---|
| 设计 | [markdown-mapping-v0.3.md](../../doc/design/markdown-mapping-v0.3.md) |
| 路线 | [markup-v0.3.md](../../doc/roadmap/markup-v0.3.md) |
| 状态 | **现行运行时(无 `--markup` 旗标 · 无 v0.2 兼容)** |
## 约定
- 文件使用 **v0.3 表面语法**(粗体代码、斜体返回、叙述 `` `名` `` 声明、形参体推断)。
- `tests/gold.rs` 中 `markup_v03_*` 为门禁。
## 清单
见各 `.mq.md` frontmatter;汇总期望以 `gold.rs` 为准。
```bash
cargo test --test gold markup_v03
marqdo run tests/markup-v03/inc-prose.mq.md
```
+16
View File
@@ -0,0 +1,16 @@
---
title: v0.3 粗体内调用(无 `>`)
description: `**结果 = 加一函数 37**` 粗体调用(callee 无 `>`)
markup: v0.3
---
## 加一函数
输入`n`。**n=n+1**返回*n*。
# main
或者可以直接用粗体调用(不必写 `>`):
**结果 = 加一函数 37**
**print text=结果**
+16
View File
@@ -0,0 +1,16 @@
---
title: v0.3 死绑定不升参
description: 叙述提到`Markdown`/`GFM`但不读写;仅`题干`为形参
markup: v0.3
---
## 回声
本文顺便提到`Markdown`与`GFM`,但真正的输入只有`题干`。
**print text=题干**
---
# main
> 回声 你好
+16
View File
@@ -0,0 +1,16 @@
---
title: v0.3 双调用面
description: 同函数一次 `>`、一次粗体调用
markup: v0.3
---
## 加一函数
输入`n`。**n=n+1**返回*n*。
# main
**a = > 加一函数 37**
**print text=a**
**b = 加一函数 37**
**print text=b**
@@ -0,0 +1,15 @@
---
title: v0.3 空返回(`****` 兼容)
description: v0.2 空粗体在 v0.3 仍识别为空返回
markup: v0.3
---
## 只打印
**print text="hi"**
****
# main
> 只打印
> print text=done
+15
View File
@@ -0,0 +1,15 @@
---
title: v0.3 空返回(`---`)
description: 副作用后分割线收束
markup: v0.3
---
## 只打印
**print text="hi"**
---
# main
> 只打印
> print text=done
+15
View File
@@ -0,0 +1,15 @@
---
title: v0.3 空返回(`*None*`)
description: 显式空值,对齐 Python return None
markup: v0.3
---
## 只打印
**print text="hi"**
*None*
# main
> 只打印
> print text=done
+15
View File
@@ -0,0 +1,15 @@
---
title: v0.3 空返回(整行 `**`)
description: 空斜体标记;词法须与粗体区分
markup: v0.3
---
## 只打印
**print text="hi"**
**
# main
> 只打印
> print text=done
+23
View File
@@ -0,0 +1,23 @@
---
title: v0.3 默认形参(叙述 `` `名`=值 ``)
description: 必选`谁` + 可选`礼貌`=False;分支打印
markup: v0.3
---
## 问候
向`谁`问好;默认`礼貌`=False。
1. `礼貌`
**print text="您好,"**
**print text=谁**
2. *
**print text="嗨,"**
**print text=谁**
---
# main
**问候 谁="Marqdo" 礼貌=True**
> 问候 World
+16
View File
@@ -0,0 +1,16 @@
---
title: v0.3 加一(叙述统一动机例)
description: 叙述声明 `n`;粗体赋值;斜体返回;`>` 调用后打印返回值
markup: v0.3
---
## 加一函数
对于输入变量`n`,我们执行操作**n=n+1**接着返回*n*。
# main
我要调用加一函数可以采用这样的办法:
**结果 = > 加一函数 37**
**print text=结果**
+9
View File
@@ -0,0 +1,9 @@
---
title: v0.3 一行多粗体
description: 同一叙述行内多个 `**…**` 按出现序执行
markup: v0.3
---
# main
先写**print text="a"**再写**print text="b"**。
+9
View File
@@ -0,0 +1,9 @@
---
title: v0.3 粗体内 print
description: 输出是调用不是返回;粗体包裹 print
markup: v0.3
---
# main
**print text="Hello"**
+11 -11
View File
@@ -1,37 +1,37 @@
---
title: bare id in italic and bold
description: Inside *…* / **…**, bare ids are variables; strings need quotes.
description: Inside **…** / *…*, bare ids are variables; strings need quotes.
---
# main
*answer = 1*
*n = answer + 1*
*ticked = 2*
*s = 'quoted'*
**answer = 1**
**n = answer + 1**
**ticked = 2**
**s = 'quoted'**
> print text=`n`
> print text=`ticked`
> print text=`s`
*a = > ret_var x=7*
**a = > ret_var x=7**
> print text=`a`
*b = > ret_str*
**b = > ret_str**
> print text=`b`
*c = > ret_single*
**c = > ret_single**
> print text=`c`
## ret_var
+ `x`
**x**
*x*
## ret_str
**"ok"**
*"ok"*
## ret_single
**'hi'**
*'hi'*
+2 -2
View File
@@ -5,8 +5,8 @@ description: Same-indent `1.` after a completed list is a new Branch, not more a
# main
*a = True*
*b = True*
**a = True**
**b = True**
1. `a`
> print text=A
+1 -1
View File
@@ -4,7 +4,7 @@ title: 分支示例
# main
*x = 0*
**x = 0**
1. `x` > 0
> print text=正数
+2 -2
View File
@@ -5,8 +5,8 @@ description: Data cells evaluate like call-arg values (`var`, paths, hyphen pros
# main
*secret = "sk-live"*
*name = "gpt-4o-mini"*
**secret = "sk-live"**
**name = "gpt-4o-mini"**
`cfg` =
+3 -3
View File
@@ -11,14 +11,14 @@ title: 横表多行 → 字典套列表
| 红富士 | 青瓜 |
| 嘎啦 | 黄瓜条 |
*第一种苹果 = 货架[^苹果][^1]*
**第一种苹果 = 货架[^苹果][^1]**
> print text=`第一种苹果`
*列 = 货架[^苹果]*
**列 = 货架[^苹果]**
> print text=`列`
*第二种黄瓜 = 货架[^黄瓜][^2]*
**第二种黄瓜 = 货架[^黄瓜][^2]**
> print text=`第二种黄瓜`
+3 -3
View File
@@ -10,15 +10,15 @@ title: 横表单行 → 字典
|------|------|------|
| 水果 | 蔬菜 | 数码用品 |
*种 = 分类[^苹果]*
**种 = 分类[^苹果]**
> print text=`种`
*种 = 分类[^黄瓜]*
**种 = 分类[^黄瓜]**
> print text=`种`
*种 = 分类[^鼠标]*
**种 = 分类[^鼠标]**
> print text=`种`
+2 -2
View File
@@ -11,10 +11,10 @@ title: row records with @ marker
| 1 | apple | 2 |
| 2 | pear | 3 |
*n = orders[^1][^name]*
**n = orders[^1][^name]**
> print text=`n`
*q = orders[^2][^qty]*
**q = orders[^2][^qty]**
> print text=`q`
+3 -3
View File
@@ -11,15 +11,15 @@ title: 行向记录表(首列 行 / @)
| 1 | 苹果 | 2 |
| 2 | 梨 | 3 |
*第一 = 订单[^1]*
**第一 = 订单[^1]**
> print text=`第一`
*名 = 订单[^1][^品名]*
**名 = 订单[^1][^品名]**
> print text=`名`
*量 = 订单[^2][^数量]*
**量 = 订单[^2][^数量]**
> print text=`量`
+3 -3
View File
@@ -12,14 +12,14 @@ title: 脚注取元(列表下标)
| 梨 |
| 桃 |
*第一 = 篮子[^1]*
**第一 = 篮子[^1]**
> print text=`第一`
*第二 = 篮子[^2]*
**第二 = 篮子[^2]**
> print text=`第二`
*第三 = 篮子[^3]*
**第三 = 篮子[^3]**
> print text=`第三`
+2 -2
View File
@@ -11,8 +11,8 @@ description: Pure-digit labels are map keys (text), not list indices. Bare base
|----|----|
| half | other |
*a = p[^00]*
*b = p[^11]*
**a = p[^00]**
**b = p[^11]**
> print text=`a`
> print text=`b`
+13 -13
View File
@@ -6,9 +6,9 @@ import json:lib/json.mq.md
# main
*a = > case_backtick*
*b = > case_json_array*
*c = > case_recover*
**a = > case_backtick**
**b = > case_json_array**
**c = > case_recover**
> print text=`a`
> print text=`b`
> print text=`c`
@@ -21,20 +21,20 @@ import json:lib/json.mq.md
|---|
| ok |
*code = > len value=`args`*
*y = 1*
**y**
**code = > len value=`args`**
**y = 1**
*y*
## case_json_array
*xs = > json.parse text=["scripts/legacy/web_search.py"]*
*n = > len value=`xs`*
**n**
**xs = > json.parse text=["scripts/legacy/web_search.py"]**
**n = > len value=`xs`**
*n*
## case_recover
故意少写闭合星号,后续语句仍须可执行:
故意少写闭合粗体,后续语句仍须可执行:
*c = > json.parse text=[]`
*z = 7*
**z**
**c = > json.parse text=[]
**z = 7**
*z*
+1 -1
View File
@@ -1,5 +1,5 @@
# Hello World
本程序调用内置函数 `print` 打印问候。注释里的 **粗体** 与 *斜体* 都不执行。
本程序调用内置函数 print 打印问候。叙述中不要用星号当强调(粗体/斜体已是可执行标记)。
> print text=Hello World!
+3 -3
View File
@@ -6,7 +6,7 @@ title: import official lib (Chinese)
# main
*t = > 文本.去空白 s=" x"*
**t = > 文本.去空白 s=" x"**
> 打印 内容=`t`
@@ -17,10 +17,10 @@ title: import official lib (Chinese)
| a |
| b |
*n = > 表.行数 xs=`xs`*
**n = > 表.行数 xs=`xs`**
> 打印 内容=`n`
*row = > 表.取行 xs=`xs` i=0*
**row = > 表.取行 xs=`xs` i=0**
> 打印 内容=`row`
+1 -1
View File
@@ -7,7 +7,7 @@ import utils:utils.mq.md
导入 `utils.mq.md` 后:用返回值绑定,再输出;并直接调用问候。
*y = > utils.加一 n=41*
**y = > utils.加一 n=41**
> print text=`y`
+1 -1
View File
@@ -6,7 +6,7 @@ description: 供 frontmatter > 导入;返回用粗体;副作用用输出函
## 加一
+ `n`
**n + 1**
*n + 1*
## 问候
+ `谁`
+10 -10
View File
@@ -6,23 +6,23 @@ import json:lib/json.mq.md
# Parent
+ `name`
*out = > json.parse text={"role":"parent"}*
*out = > json.set map=`out` key="name" value=`name`*
**out**
**out = > json.parse text={"role":"parent"}**
**out = > json.set map=`out` key="name" value=`name`**
*out*
# Child = > Parent
+ `name`
*self = > Parent name=`name`*
*self = > json.set map=`self` key="role" value="child"*
**self**
**self = > Parent name=`name`**
**self = > json.set map=`self` key="role" value="child"**
*self*
# main
*c = > Child name="Ada"*
*ty = > json.get value=`c` key="_type"*
*role = > json.get value=`c` key="role"*
*name = > json.get value=`c` key="name"*
**c = > Child name="Ada"**
**ty = > json.get value=`c` key="_type"**
**role = > json.get value=`c` key="role"**
**name = > json.get value=`c` key="name"**
> print text=`ty`
> print text=`role`
> print text=`name`
+8 -8
View File
@@ -7,22 +7,22 @@ title: inherit method override
## hello
+ `who`
*msg = "Hello, `who`!"*
**msg**
**msg = "Hello, `who`!"**
*msg*
# Loud = > Greeter
## hello
+ `who`
*msg = "HELLO, `who`!"*
**msg**
**msg = "HELLO, `who`!"**
*msg*
# main
*g = > Greeter*
*m = > `g`.hello who="world"*
**g = > Greeter**
**m = > `g`.hello who="world"**
> print text=`m`
*l = > Loud*
*m2 = > `l`.hello who="world"*
**l = > Loud**
**m2 = > `l`.hello who="world"**
> print text=`m2`
+5 -5
View File
@@ -8,15 +8,15 @@ import json:lib/json.mq.md
## hello
+ `who`
*msg = "Hello, `who`!"*
**msg**
**msg = "Hello, `who`!"**
*msg*
# Loud = > Greeter
# main
*l = > Loud*
*ty = > json.get value=`l` key="_type"*
**l = > Loud**
**ty = > json.get value=`l` key="_type"**
> print text=`ty`
*m = > `l`.hello who="world"*
**m = > `l`.hello who="world"**
> print text=`m`
+2 -2
View File
@@ -6,11 +6,11 @@ title: 循环示例
倒数:
*n = 3*
**n = 3**
- `n` > 0
> print text=`n`
*n = n - 1*
**n = n - 1**
遍历篮子:
+3 -5
View File
@@ -1,12 +1,10 @@
---
title: narrative bold in comment paragraph
description: **强调** mid-line must stay comment, not return syntax
title: narrative without star emphasis
description: v0.3 — do not use * /** for Markdown emphasis; plain prose stays non-executable
---
# main
说明如下
**强调信息**是什么什么
说明如下:强调信息是什么什么(叙述勿写星号强调)。
> print text=ok
+2 -2
View File
@@ -1,11 +1,11 @@
---
title: Hello World
description: Recommended entry — nested fn; print builtin; bold return
description: Nested fn; print builtin; v0.3 italic = return (unused here)
---
# main
打印一句问候。`print` 是函数,不是语法架构;粗体只用于返回值。
打印一句问候。print 是函数,不是语法架构。
> 问候 谁=World
+2 -2
View File
@@ -9,11 +9,11 @@ Nested free function (not an object method) for `helpers.pack.label`.
### label
+ `s`
**s**
*s*
# Box
## tag
+ `s`
**s**
*s*
+2 -2
View File
@@ -5,10 +5,10 @@ import helpers:helpers.mq.md
# main
*v = > helpers.pack.label s="ok"*
**v = > helpers.pack.label s="ok"**
> print text=`v`
*b = > helpers.Box*
**b = > helpers.Box**
> print text=constructed
+1 -1
View File
@@ -6,6 +6,6 @@ import trim_text:text.str_trim
# main
*t = > trim_text s=" hi"*
**t = > trim_text s=" hi"**
> print text=`t`
+20 -20
View File
@@ -6,32 +6,32 @@ import json:lib/json.mq.md
# counter
+ `n`
*t = > json.parse text={"p":"{\"n\":","s":"}"}*
*qn = > str `n`*
*p = > json.get value=`t` key="p"*
*s = > json.get value=`t` key="s"*
*raw = p + qn + s*
**> json.parse text=`raw`**
**t = > json.parse text={"p":"{\"n\":","s":"}"}**
**qn = > str `n`**
**p = > json.get value=`t` key="p"**
**s = > json.get value=`t` key="s"**
**raw = p + qn + s**
*> json.parse text=`raw`*
## bump
*n = > json.get value=`self` key="n"*
*n2 = n + 1*
*t = > json.parse text={"p":"{\"n\":","s":"}"}*
*qn = > str `n2`*
*p = > json.get value=`t` key="p"*
*s = > json.get value=`t` key="s"*
*raw = p + qn + s*
*m = > json.parse text=`raw`*
**m**
**n = > json.get value=`self` key="n"**
**n2 = n + 1**
**t = > json.parse text={"p":"{\"n\":","s":"}"}**
**qn = > str `n2`**
**p = > json.get value=`t` key="p"**
**s = > json.get value=`t` key="s"**
**raw = p + qn + s**
**m = > json.parse text=`raw`**
*m*
# main
*c = > counter n=3*
*ty = > json.get value=`c` key="_type"*
**c = > counter n=3**
**ty = > json.get value=`c` key="_type"**
> print text=`ty`
*n = > json.get value=`c` key="n"*
**n = > json.get value=`c` key="n"**
> print text=`n`
*c2 = > `c`.bump*
*n2 = > json.get value=`c2` key="n"*
**c2 = > `c`.bump**
**n2 = > json.get value=`c2` key="n"**
> print text=`n2`