feat(markup): code-as-docs narration surface (G1–G4) and drop --- body end
Treat --- as Markdown HR everywhere, end side-effect helpers with empty returns, and accept soft emphasis, float literals, and dynamic footnote keys so LLM-friendly .mq.md stays runnable. Ship the weekend coffee example plus gold fixtures. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
b5c07385e9
commit
5e74ff39f2
28 files changed
+799
-99
No files matched your search
@@ -3824,3 +3824,23 @@ fn markup_v03_multi_bold() {
|
||||
fn markup_v03_print_bold() {
|
||||
assert_out_v03("tests/markup-v03/print-bold.mq.md", "Hello");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn markup_v03_module_hr() {
|
||||
assert_out_v03("tests/markup-v03/module-hr.mq.md", "ok");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn markup_v03_soft_emphasis() {
|
||||
assert_out_v03("tests/markup-v03/soft-emphasis.mq.md", "2");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn markup_v03_float_discount() {
|
||||
assert_out_v03("tests/markup-v03/float-discount.mq.md", "23.8");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn markup_v03_dynamic_footnote() {
|
||||
assert_out_v03("tests/markup-v03/dynamic-footnote.mq.md", "28");
|
||||
}
|
||||
@@ -15,6 +15,8 @@
|
||||
|
||||
见各 `.mq.md` frontmatter;汇总期望以 `gold.rs` 为准。
|
||||
|
||||
代码即文档叙述面(G1–G4):`module-hr` / `soft-emphasis` / `float-discount` / `dynamic-footnote` —— 设计见 [code-as-docs-gaps.md](../../doc/design/code-as-docs-gaps.md)。
|
||||
|
||||
```bash
|
||||
cargo test --test gold markup_v03
|
||||
marqdo run tests/markup-v03/inc-prose.mq.md
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
---
|
||||
title: G4 动态脚注键
|
||||
description: 菜单[^`名`] 用变量值取 map 键
|
||||
markup: v0.3
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
`菜单` =
|
||||
|
||||
| 美式 | 拿铁 |
|
||||
|------|------|
|
||||
| 18 | 28 |
|
||||
|
||||
**名 = "拿铁"**
|
||||
**价 = 菜单[^`名`]**
|
||||
> print text=`价`
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: v0.3 空返回(`---`)
|
||||
description: 副作用后分割线收束
|
||||
title: v0.3 副作用函数 + 体内 ---
|
||||
description: 分割线为叙述;函数在下一标题处结束(空返回见 empty-return-none)
|
||||
markup: v0.3
|
||||
---
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
---
|
||||
title: G3 浮点面量与折扣
|
||||
description: 0.85 可解析;Int * Num 得 Num
|
||||
markup: v0.3
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
**应付 = 28 * 0.85**
|
||||
> print text=`应付`
|
||||
@@ -0,0 +1,17 @@
|
||||
---
|
||||
title: G1 模块级 --- 为叙述分隔线
|
||||
description: 顶层与函数体内 --- 均为叙述分隔(不再收束)
|
||||
markup: v0.3
|
||||
---
|
||||
|
||||
本段在 frontmatter 之后、入口之前。
|
||||
|
||||
---
|
||||
|
||||
中间再来一条分隔线也不应报错。
|
||||
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
> print text=ok
|
||||
@@ -0,0 +1,13 @@
|
||||
---
|
||||
title: G2 叙述强调不执行
|
||||
description: 句中 **说明** / *only* 为装饰;像代码的粗体与整行斜体仍执行
|
||||
markup: v0.3
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
本段既是**说明**也是**程序**;英文里也有 *only* 这类强调词。
|
||||
|
||||
**n = 1**
|
||||
**n = n + 1**
|
||||
> print text=`n`
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: 函数结束 — 分割线
|
||||
description: --- 结束嵌套函数体,后续调用属于外层
|
||||
title: 函数体内 --- 为叙述分隔
|
||||
description: 分割线不再收束函数;嵌套 ## 在下一标题或空返回处结束
|
||||
---
|
||||
|
||||
# main
|
||||
@@ -13,3 +13,5 @@ description: --- 结束嵌套函数体,后续调用属于外层
|
||||
> print text=Hello `谁`!
|
||||
|
||||
---
|
||||
|
||||
叙述分隔线可写在函数体里,不结束函数;本例下一行已是文件尾,问候在 EOF 结束。
|
||||
Reference in new issue
Block a user