refactor: prefer link-index get across examples and tests

Migrate remaining footnote-style collection access in examples,
public/structure, and ext/lib smokes to [key](base); teach link-index in
structure pages and use bracket calls in the cafe journal example.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
cflmyandCursor committed 2026-09-14 12:54:38 +08:00
1 parent 8d97adc1dc
commit abcb141737
75 files changed
+284 -281

No files matched your search

+3
View File
@@ -27,12 +27,14 @@
| **M2** | 其余 `lib/*` 叙述化;禁新脚注取元 | **done** |
| **M3–M4** | `ext/web`、`ext/ai`:脚注→链接取元;叙述;示例可逐步换括号调用 | **done**(取元迁移) |
| **M5** | quantum / linalg + full gold | **done** |
| **M6** | examples + public/structure + tests/ext·lib 链接取元;cafe 括号调用例 | **done** |
## 2. 验收(出门)
- 括号调用与 `[k](c)` 取元金样并存、不回归。
- 试点库可读:目的句 + 叙述形参 + 一例 + 短实现。
- `cargo test --test gold` 绿。
- 脚注取元金样(`tests/structure/footnote*`)仍保留作兼容门禁。
## 3. 修订历史
@@ -43,3 +45,4 @@
| 2026-09-14 | M2 其余 lib 叙述化标 done |
| 2026-09-14 | M3–M4 ext/web+ai 脚注→链接取元 |
| 2026-09-14 | M5 quantum/linalg 叙述 + public/features 取元 |
| 2026-09-14 | M6 examples/public/tests 批量链接取元 + cafe 括号调用 |
+12 -12
View File
@@ -12,12 +12,12 @@ import text:lib/text.mq.md
**段 = None**
- [帖](行)
**板 = 帖[^board]**
**题 = 帖[^title]**
**链 = 帖[^slug]**
**作 = 帖[^author]**
**评 = 帖[^comments_count]**
**时 = 帖[^created_at]**
**板 = [board](帖)**
**题 = [title](帖)**
**链 = [slug](帖)**
**作 = [author](帖)**
**评 = [comments_count](帖)**
**时 = [created_at](帖)**
1. not 作
**作 = "匿名"**
2. *
@@ -42,10 +42,10 @@ import text:lib/text.mq.md
**段 = None**
- [讯](行)
**题 = 讯[^title]**
**链 = 讯[^slug]**
**板 = 讯[^board]**
**时 = 讯[^created_at]**
**题 = [title](讯)**
**链 = [slug](讯)**
**板 = [board](讯)**
**时 = [created_at](讯)**
1. not 板
**板 = ""**
2. *
@@ -80,8 +80,8 @@ import text:lib/text.mq.md
**全项 = "<a href=\"" + 全链 + "\" class=\"" + 全部类 + " active\" " + 数据属 + "=\"0\">" + 全标签 + "</a>"**
**段 = > table.append list=段 item=全项**
- [板](板块)
**名 = 板[^name]**
**号 = 板[^id]**
**名 = [name](板)**
**号 = [id](板)**
**链 = 前缀 + "?" + 查询键 + "=" + 号**
**项 = "<a href=\"" + 链 + "\" class=\"" + 全部类 + "\" " + 数据属 + "=\"" + 号 + "\">" + 名 + "</a>"**
**段 = > table.append list=段 item=项**
@@ -20,8 +20,8 @@ import feed:feed.mq.md
**公告段 = None**
- [告](公告行)
**文 = 告[^content]**
**时 = 告[^created_at]**
**文 = [content](告)**
**时 = [created_at](告)**
**一项 = "<div class=\"notice-item\"><article class=\"notice-content\">" + 文 + "</article><p class=\"notice-create-time\">" + 时 + "</p></div>"**
**公告段 = > table.append list=公告段 item=一项**
1. 公告段
+6 -6
View File
@@ -141,9 +141,9 @@ import db:db/index.mq.md
**房间行 = > store.查询 表="chat_rooms" 上限=50**
**房间段 = None**
- [房](房间行)
**名 = 房[^name]**
**链 = 房[^slug]**
**摘 = 房[^summary]**
**名 = [name](房)**
**链 = [slug](房)**
**摘 = [summary](房)**
**项 = "<article class=\"chat-room-card\"><h3><a href=\"/chat/" + 链 + "\">" + 名 + "</a></h3><p>" + 摘 + "</p></article>"**
**房间段 = > table.append list=房间段 item=项**
**房间内 = > text.str_join xs=房间段 sep=""**
@@ -165,9 +165,9 @@ import db:db/index.mq.md
**专题行 = > store.查询 表="topics" 上限=50**
**专题段 = None**
- [题](专题行)
**题名 = 题[^title]**
**链 = 题[^slug]**
**摘 = 题[^summary]**
**题名 = [title](题)**
**链 = [slug](题)**
**摘 = [summary](题)**
**项 = "<article class=\"topic-card\"><h3>" + 题名 + "</h3><p>" + 摘 + "</p><p class=\"text-muted\">slug: " + 链 + "</p></article>"**
**专题段 = > table.append list=专题段 item=项**
**专题内 = > text.str_join xs=专题段 sep=""**
+4 -4
View File
@@ -44,7 +44,7 @@ import sys:lib/sys.mq.md
**应用 = > 应用.门禁 路径="/write" 角色="admin" 匹配="prefix" 拒绝="redirect"**
**应用 = > 应用.路由实时 路径="/chat/ws" 模式="broadcast"**
**gates = 应用[^gates]**
**gates = [gates](应用)**
**n = > len value=`gates`**
1. `n` >= 2
> print text=gates-ok
@@ -52,9 +52,9 @@ import sys:lib/sys.mq.md
> print text=gates-fail
> sys.exit code=1
**ws = 应用[^ws_routes]**
**room = ws[^/chat/ws]**
**mode = room[^mode]**
**ws = [ws_routes](应用)**
**room = [/chat/ws](ws)**
**mode = [mode](room)**
1. `mode` == "broadcast"
> print text=ws-ok
2. *
+2 -2
View File
@@ -56,12 +56,12 @@ description: >-
**名 = "拿铁"**
**价 = [`名`](菜单)**
**摘要 = 结账摘要 品名=`名` 价=`价` 杯数=2 会员=True**
**摘要 = [结账摘要] 品名=`名` 价=`价` 杯数=2 会员=True**
**打印 内容=`摘要`**
旁桌只要一杯普通美式,对照一下原价:
**对照 = 结账摘要 品名="美式" 价=[美式](菜单)**
**对照 = [结账摘要] 品名="美式" 价=[美式](菜单)**
**打印 内容=`对照`**
---
+2 -2
View File
@@ -27,8 +27,8 @@ $$
**`_` = > la.draw factor=`A` kind="heatmap" theme="light" path="ls-heatmap.svg"**
**`ls` = > la.lstsq a=`A` b=`b`**
**`x` = ls[^x]**
**`resid` = ls[^residual_fro]**
**`x` = [x](ls)**
**`resid` = [residual_fro](ls)**
> print text=`x`
> print text=`resid`
+1 -1
View File
@@ -17,7 +17,7 @@ $$
**`M` = > la.from_formula formula=`M`**
**`f` = > la.factorize matrix=`M` kind="svd"**
**`S` = f[^S]**
**`S` = [S](f)**
**`_` = > la.draw factor=`f` kind="svd" theme="light" path="svd-structure.svg"**
**`hm` = > la.draw factor=`M` kind="hinton" path="svd-hinton.svg"**
+2 -2
View File
@@ -18,8 +18,8 @@ Declare shapes in a table, form \(P = AB\), then check \((AB)^\top = B^\top A^\t
| 2 | B | 3 | 2 |
**`env` = > la.declare table=`shapes`**
**`A` = env[^A]**
**`B` = env[^B]**
**`A` = [A](env)**
**`B` = [B](env)**
**`P` = `A` * `B`**
**`t` = > `P`.T_ascii**
> print text=`t`
+1 -1
View File
@@ -30,7 +30,7 @@ Build |Φ⁺⟩ with H then CX. Full-state purity stays 1; tracing out one qubit
**ezz = > `qc`.expect obs=`zz`**
**sch = > `qc`.schmidt cut=1**
**ent = sch[^entropy]**
**ent = [entropy](sch)**
**_ = > `qc`.draw path="entangle-circuit.svg" theme="dark"**
**_ = > `qc`.draw kind="hinton" path="entangle-hinton.svg"**
+8 -8
View File
@@ -55,18 +55,18 @@ import db:db/index.mq.md
<!-- 工具页:用 lib/net 解析展示 -->
**解析请求 = > net.解析Cookie 内容="session=abc123; theme=dark"**
**请求块 = 解析请求[^1]**
**请求块 = [1](解析请求)**
**解析响应 = > net.解析Cookie 内容="id=42; Path=/; HttpOnly; SameSite=Lax" 是响应头=True**
**响应块 = 解析响应[^1]**
**响应块 = [1](解析响应)**
`边界` = ----b
`正文` = "--`边界`\nContent-Disposition: form-data; name=\"title\"\n\n你好\n--`边界`\nContent-Disposition: form-data; name=\"封面\"; filename=\"pic.png\"\nContent-Type: image/png\n\n<字节>\n--`边界`--\n"
**多部分 = > net.解析多部分 正文=`正文` 边界=`边界`**
**字段块 = 多部分[^1]**
**文件块 = 多部分[^2]**
**字段块 = [1](多部分)**
**文件块 = [2](多部分)**
`工具段` =
@@ -74,13 +74,13 @@ import db:db/index.mq.md
|----|
| <h1>网络工具</h1><p>由 lib/net 提供的解析演示:解析Cookie 与 解析多部分。</p><section class="content cards"> |
| <article><h2>Cookie 请求头</h2><p> |
| `请求块`[^name]=`请求块`[^value] |
| [name](`请求块`)=[value](`请求块`) |
| </p></article><article><h2>Set-Cookie 响应头</h2><p> |
| `响应块`[^name]=`响应块`[^value] · HttpOnly=`响应块`[^http_only] |
| [name](`响应块`)=[value](`响应块`) · HttpOnly=[http_only](`响应块`) |
| </p></article><article><h2>多部分字段</h2><p> |
| `字段块`[^name]=`字段块`[^value] |
| [name](`字段块`)=[value](`字段块`) |
| </p></article><article><h2>多部分文件</h2><p> |
| `文件块`[^name] · `文件块`[^filename] · `文件块`[^content_type] |
| [name](`文件块`) · [filename](`文件块`) · [content_type](`文件块`) |
| </p></article></section> |
**工具引言 = > text.str_join xs=`工具段` sep=""**
+8 -8
View File
@@ -46,12 +46,12 @@ About page: same shell.
Parse a `Cookie` request header with the standard library.
**parsed_req = > net.cookie_parse text="session=abc123; theme=dark"**
**req_cookie = parsed_req[^1]**
**req_cookie = [1](parsed_req)**
Parse a `Set-Cookie` response header.
**parsed_resp = > net.cookie_parse text="id=42; Path=/; HttpOnly; SameSite=Lax" is_response=True**
**resp_cookie = parsed_resp[^1]**
**resp_cookie = [1](parsed_resp)**
Parse a `multipart/form-data` body.
@@ -60,8 +60,8 @@ Parse a `multipart/form-data` body.
`_body` = "--`_b`\nContent-Disposition: form-data; name=\"title\"\n\nHello\n--`_b`\nContent-Disposition: form-data; name=\"cover\"; filename=\"pic.png\"\nContent-Type: image/png\n\n<bytes>\n--`_b`--\n"
**mp = > net.multipart_parse body=`_body` boundary=`_b`**
**mp_title = mp[^1]**
**mp_cover = mp[^2]**
**mp_title = [1](mp)**
**mp_cover = [2](mp)**
Build the tools page as one HTML intro (intro is served raw).
@@ -71,13 +71,13 @@ Build the tools page as one HTML intro (intro is served raw).
|----|
| <h1>Net tools</h1><p>Parsing demos powered by lib/net: cookie_parse and multipart_parse.</p><section class="content cards"> |
| <article><h2>Cookie request</h2><p> |
| `req_cookie`[^name]=`req_cookie`[^value] |
| [name](`req_cookie`)=[value](`req_cookie`) |
| </p></article><article><h2>Set-Cookie response</h2><p> |
| `resp_cookie`[^name]=`resp_cookie`[^value] · HttpOnly=`resp_cookie`[^http_only] |
| [name](`resp_cookie`)=[value](`resp_cookie`) · HttpOnly=[http_only](`resp_cookie`) |
| </p></article><article><h2>Multipart field</h2><p> |
| `mp_title`[^name]=`mp_title`[^value] |
| [name](`mp_title`)=[value](`mp_title`) |
| </p></article><article><h2>Multipart file</h2><p> |
| `mp_cover`[^name] · `mp_cover`[^filename] · `mp_cover`[^content_type] |
| [name](`mp_cover`) · [filename](`mp_cover`) · [content_type](`mp_cover`) |
| </p></article></section> |
**tools_intro = > text.str_join xs=`tools_parts` sep=""**
+1 -1
View File
@@ -5,7 +5,7 @@ description: One-column tables are lists
# main
A single-column Markdown table is a list; loop to read each item. Use `basket`[^1] for 1-based index.
A single-column Markdown table is a list; loop to read each item. Prefer link-index get `[1](basket)` (1-based).
`basket` =
+1 -1
View File
@@ -5,7 +5,7 @@ description: 单列竖表即列表
# main
单列 Markdown 表是列表;用循环读每一项。按下标用 `` `篮子`[^1] ``(1-based)。
单列 Markdown 表是列表;用循环读每一项。按下标优先用链接取元 `[1](篮子)`(1-based)。
`篮子` =
+4 -4
View File
@@ -1,11 +1,11 @@
---
title: Maps (horizontal tables)
description: Multi-column tables are maps; footnote gets
description: Multi-column tables are maps; link-index get
---
# main
A multi-column table with one data row is a map. Read values with footnote keys.
A multi-column table with one data row is a map. Read values with `[key](map)`.
`kinds` =
@@ -13,10 +13,10 @@ A multi-column table with one data row is a map. Read values with footnote keys.
|-------|----------|
| fruit | vegetable |
**`k` = `kinds`[^apple] **
**`k` = [apple](kinds)**
> print text=`k`
**`k` = `kinds`[^cucumber] **
**`k` = [cucumber](kinds)**
> print text=`k`
+4 -4
View File
@@ -1,11 +1,11 @@
---
title: 字典(横表)
description: 多列表是字典;脚注按键取元
description: 多列表是字典;链接取元
---
# main
多列且仅一行数据的表是字典。用脚注键取元。
多列且仅一行数据的表是字典。用 `[键](字典)` 取元。
`分类` =
@@ -13,10 +13,10 @@ description: 多列表是字典;脚注按键取元
|------|------|
| 水果 | 蔬菜 |
**`种` = `分类`[^苹果] **
**`种` = [苹果](分类)**
> 打印 内容=`种`
**`种` = `分类`[^黄瓜] **
**`种` = [黄瓜](分类)**
> 打印 内容=`种`
+3 -3
View File
@@ -5,7 +5,7 @@ description: First header @ / row makes a list of maps
# main
When the first header is `@` or `row`, each data row is a map (marker column is not a field).
When the first header is `@` or `row`, each data row is a map (marker column is not a field). Nested get: `[field]([1](orders))`.
`orders` =
@@ -14,10 +14,10 @@ When the first header is `@` or `row`, each data row is a map (marker column is
| 1 | apple | 2 |
| 2 | pear | 3 |
**`n` = `orders`[^1][^name] **
**`n` = [name]([1](orders))**
> print text=`n`
**`q` = `orders`[^2][^qty] **
**`q` = [qty]([2](orders))**
> print text=`q`
+3 -3
View File
@@ -5,7 +5,7 @@ description: 首列表头「行」→ 每行一个字典
# main
首列表头为 `行`(或 `@` / `row`)时,每行数据是一个字典;标记列不进入字段。
首列表头为 `行`(或 `@` / `row`)时,每行数据是一个字典;标记列不进入字段。嵌套取元:`[字段]([1](订单))`。
`订单` =
@@ -14,10 +14,10 @@ description: 首列表头「行」→ 每行一个字典
| 1 | 苹果 | 2 |
| 2 | 梨 | 3 |
**`名` = `订单`[^1][^品名] **
**`名` = [品名]([1](订单))**
> 打印 内容=`名`
**`量` = `订单`[^2][^数量] **
**`量` = [数量]([2](订单))**
> 打印 内容=`量`
Binary file not shown.
+3 -3
View File
@@ -17,15 +17,15 @@ import demo:agent-mcp-server-helpers.mq.md
**srv = > agent.mcp_server name="marqdo-test"**
**srv = > `srv`.tool name="ping" fn="demo.ping" description="ping tool"**
**tools = srv[^tools]**
**tools = [tools](srv)**
**n = > len value=`tools`**
1. `n` == 1
> print text=mcp-tool-ok
2. *
> print text=mcp-tool-fail
**t0 = tools[^1]**
**fn = t0[^fn]**
**t0 = [1](tools)**
**fn = [fn](t0)**
1. `fn` == "demo.ping"
> print text=mcp-fn-ok
2. *
+3 -3
View File
@@ -38,8 +38,8 @@ $$
> print text=trace-fail
**`sol` = > la.solve a=`A` b=`b`**
**`x` = sol[^x]**
**`data` = x[^data]**
**`x` = [x](sol)**
**`data` = [data](x)**
**`row0` = > at value=`data` index=0**
**`x0` = > at value=`row0` index=0**
**`e0` = > math.sub a=`x0` b=2**
@@ -52,7 +52,7 @@ $$
**`I` = > la.eye n=2**
**`P` = > la.mul a=`A` b=`I`**
**`E` = > la.explicit expr=`P`**
**`ed` = E[^data]**
**`ed` = [data](E)**
**`ed0` = > at value=`ed` index=0**
**`ed00` = > at value=`ed0` index=0**
**`ee` = > math.sub a=`ed00` b=2**
+1 -1
View File
@@ -42,7 +42,7 @@ import la:ext/linalg/linalg.mq.md
> print text=`ct`
**`ping` = > la.ping**
**`ok` = ping[^ok]**
**`ok` = [ok](ping)**
1. `ok`
> print text=ping-ok
2. *
+2 -2
View File
@@ -28,8 +28,8 @@ Narration: \((AB)^\top = B^\top A^\top\). The identity is checked by running thi
| 2 | Y | 2 | 2 |
**`env` = > la.declare table=`shapes`**
**`X` = env[^X]**
**`Y` = env[^Y]**
**`X` = [X](env)**
**`Y` = [Y](env)**
**`S` = `X` + `Y`**
**`st` = > la.ascii expr=`S`**
1. `st` == "X + Y"
+7 -7
View File
@@ -16,13 +16,13 @@ $$
**`eps` = > math.div a=1 b=1000**
**`f` = > la.factorize matrix=`M` kind="eig"**
**`kind` = f[^kind]**
**`kind` = [kind](f)**
1. `kind` == eig
> print text=eig-kind-ok
2. *
> print text=eig-kind-fail
**`evals` = f[^eigenvalues]**
**`evals` = [eigenvalues](f)**
**`ev0` = > at value=`evals` index=0**
**`e0` = > math.sub a=`ev0` b=3**
**`e0` = > math.abs value=`e0`**
@@ -32,13 +32,13 @@ $$
> print text=eig-val-fail
**`img` = > la.draw factor=`f` kind="eig" path="linalg-factor-eig.svg"**
**`ik` = img[^kind]**
**`ik` = [kind](img)**
1. `ik` == eig
> print text=draw-kind-ok
2. *
> print text=draw-kind-fail
**`svg` = img[^svg]**
**`svg` = [svg](img)**
**`parts` = > split value=`svg` sep="data-linalg=\"eig\""**
**`pn` = > len value=`parts`**
1. `pn` > 1
@@ -60,8 +60,8 @@ $$
**`b` = > la.from_formula formula=`b`**
**`lu` = > la.factorize matrix=`A` kind="lu"**
**`sol` = > la.solve factor=`lu` b=`b`**
**`x` = sol[^x]**
**`data` = x[^data]**
**`x` = [x](sol)**
**`data` = [data](x)**
**`row0` = > at value=`data` index=0**
**`x0` = > at value=`row0` index=0**
**`xe` = > math.sub a=`x0` b=2**
@@ -72,7 +72,7 @@ $$
> print text=lu-solve-fail
**`svd` = > la.factorize matrix=`M` kind="svd"**
**`sk` = svd[^ascii]**
**`sk` = [ascii](svd)**
1. `sk` == SVD
> print text=svd-ok
2. *
+1 -1
View File
@@ -15,7 +15,7 @@ import la:ext/linalg/linalg.mq.md
> print text=`txt`
**`ping` = > la.ping**
**`ok` = ping[^ok]**
**`ok` = [ok](ping)**
1. `ok`
> print text=ping-ok
2. *
+2 -2
View File
@@ -17,7 +17,7 @@ import la:ext/linalg/linalg.mq.md
**`st` = > `Pt`.ascii**
> print text=`st`
**`ty` = C[^_type]**
**`ty` = [_type](C)**
1. `ty` == matrix
> print text=type-ok
2. *
@@ -35,7 +35,7 @@ $$
**`S` = `M` + `N`**
**`Se` = > la.explicit expr=`S`**
**`d` = Se[^data]**
**`d` = [data](Se)**
**`r0` = > at value=`d` index=0**
**`x00` = > at value=`r0` index=0**
**`xs` = > str value=`x00`**
+6 -6
View File
@@ -23,8 +23,8 @@ $$
**`eps` = > math.div a=1 b=1000**
**`ls` = > la.lstsq a=`A` b=`b`**
**`x` = ls[^x]**
**`xd` = x[^data]**
**`x` = [x](ls)**
**`xd` = [data](x)**
**`r0` = > at value=`xd` index=0**
**`x0` = > at value=`r0` index=0**
**`e0` = > math.sub a=`x0` b=1.1666666667**
@@ -49,7 +49,7 @@ $$
**`D` = > la.from_formula formula=`D`**
**`c` = > la.cond expr=`D`**
**`cv` = c[^value]**
**`cv` = [value](c)**
**`ce` = > math.sub a=`cv` b=2**
**`ce` = > math.abs value=`ce`**
1. `ce` < `eps`
@@ -65,7 +65,7 @@ $$
**`raw` = > json.parse text="[[[0,1],[1,0]],[[1,0],[0,-1]]]"**
**`Z` = > la.from_list data=`raw`**
**`dt` = Z[^dtype]**
**`dt` = [dtype](Z)**
1. `dt` == complex
> print text=complex-dtype-ok
2. *
@@ -80,13 +80,13 @@ $$
> print text=complex-norm-fail
**`img` = > la.draw factor=`D` kind="heatmap" theme="dark" path="linalg-metrics-heat.svg"**
**`th` = img[^theme]**
**`th` = [theme](img)**
1. `th` == dark
> print text=theme-ok
2. *
> print text=theme-fail
**`svg` = img[^svg]**
**`svg` = [svg](img)**
**`parts` = > split value=`svg` sep="data-theme=\"dark\""**
**`pn` = > len value=`parts`**
1. `pn` > 1
+1 -1
View File
@@ -15,7 +15,7 @@ import la:ext/linalg/线性代数.mq.md
> 打印 内容=`txt`
**`ping` = > la.探测**
**`ok` = ping[^ok]**
**`ok` = [ok](ping)**
1. `ok`
> 打印 内容=探测-ok
2. *
+2 -2
View File
@@ -7,5 +7,5 @@ import llm:ext/ai/llm.mq.md
# main
**model = > llm.llm**
> print text=`model`[^model]
> print text=`model`[^suffix]
> print text=[model](`model`)
> print text=[suffix](`model`)
+1 -1
View File
@@ -10,7 +10,7 @@ import quantum:ext/quantum/quantum.mq.md
**qc = > `qc`.x qubit=0**
**qc = > `qc`.noise kind="amplitude_damping" p=1**
**r = > `qc`.run shots=32 seed=7**
**c0 = r[^counts][^0]**
**c0 = [0]([counts](r))**
1. `c0` == 32
> print text=amp-ok
+1 -1
View File
@@ -10,7 +10,7 @@ description: 泡利X 后 振幅阻尼 p=1 全部落回 |0⟩.
**qc = > `qc`.泡利X 比特=0**
**qc = > `qc`.噪声 种类="振幅阻尼" 概率=1**
**r = > `qc`.运行 次数=32 种子=7**
**c0 = r[^counts][^0]**
**c0 = [0]([counts](r))**
1. `c0` == 32
> print text=amp-ok
+3 -3
View File
@@ -13,14 +13,14 @@ import quantum:ext/quantum/quantum.mq.md
**qc = > `qc`.measure**
**st = > `qc`.state**
**dim = st[^dim]**
**dim = [dim](st)**
1. `dim` == 4
> print text=state-ok
2. *
> print text=state-fail
**img = > `qc`.draw path="quantum-author-draw.svg"**
**kind = img[^kind]**
**kind = [kind](img)**
1. `kind` == circuit
> print text=draw-ok
2. *
@@ -29,7 +29,7 @@ import quantum:ext/quantum/quantum.mq.md
**other = > quantum.circuit qubits=2**
**other = > `other`.x qubit=1**
**qc2 = > `qc`.append op=`other`**
**ops = qc2[^ops]**
**ops = [ops](qc2)**
**n = > len `ops`**
1. `n` == 5
> print text=append-ok
+3 -3
View File
@@ -13,14 +13,14 @@ description: 屏障 / 测量 / 追加 / 态 / 绘图.
**qc = > `qc`.测量**
**st = > `qc`.态**
**dim = st[^dim]**
**dim = [dim](st)**
1. `dim` == 4
> print text=state-ok
2. *
> print text=state-fail
**img = > `qc`.绘图 路径="quantum-author-zh-draw.svg"**
**kind = img[^kind]**
**kind = [kind](img)**
1. `kind` == circuit
> print text=draw-ok
2. *
@@ -29,7 +29,7 @@ description: 屏障 / 测量 / 追加 / 态 / 绘图.
**other = > 量子.电路 比特数=2**
**other = > `other`.泡利X 比特=1**
**qc2 = > `qc`.追加 操作=`other`**
**ops = qc2[^ops]**
**ops = [ops](qc2)**
**n = > len `ops`**
1. `n` == 5
> print text=append-ok
+3 -3
View File
@@ -12,8 +12,8 @@ import math:lib/math.mq.md
**qc = > `qc`.cx control=0 target=1**
**p = > `qc`.probabilities**
**p00 = p[^00]**
**p11 = p[^11]**
**p00 = [00](p)**
**p11 = [11](p)**
**lo = > math.div a=2 b=5**
**hi = > math.div a=3 b=5**
@@ -34,7 +34,7 @@ import math:lib/math.mq.md
> print text=p11-fail
**ping = > quantum_ping**
**ok = ping[^ok]**
**ok = [ok](ping)**
1. `ok`
> print text=ping-ok
2. *
+1 -1
View File
@@ -16,7 +16,7 @@ $$
**qc = > quantum.circuit qubits=1**
**qc = > `qc`.apply gate=`U` qubits=0**
**p = > `qc`.probabilities**
**p0 = p[^0]**
**p0 = [0](p)**
**lo = > math.div a=4 b=10**
**hi = > math.div a=6 b=10**
+1 -1
View File
@@ -16,7 +16,7 @@ $$
**qc = > 量子.电路 比特数=1**
**qc = > `qc`.施加 门=`U` 比特=0**
**p = > `qc`.概率**
**p0 = p[^0]**
**p0 = [0](p)**
**lo = > math.div a=4 b=10**
**hi = > math.div a=6 b=10**
+2 -2
View File
@@ -15,7 +15,7 @@ import quantum:ext/quantum/quantum.mq.md
**qc = > quantum.circuit qubits=2 steps=`steps`**
**img = > `qc`.draw kind="probs" path="quantum-draw-probs.svg"**
**kind = img[^kind]**
**kind = [kind](img)**
1. `kind` == probs
> print text=probs-ok
@@ -25,7 +25,7 @@ import quantum:ext/quantum/quantum.mq.md
**qc1 = > quantum.circuit qubits=1**
**qc1 = > `qc1`.h qubit=0**
**bloch = > `qc1`.draw kind="bloch" path="quantum-draw-bloch.svg"**
**bk = bloch[^kind]**
**bk = [kind](bloch)**
1. `bk` == bloch
> print text=bloch-ok
+1 -1
View File
@@ -8,7 +8,7 @@ import quantum:ext/quantum/quantum.mq.md
**H = > quantum.gate name="H"**
**img = > `H`.draw kind="matrix" path="quantum-gate-heatmap.svg"**
**kind = img[^kind]**
**kind = [kind](img)**
1. `kind` == matrix
> print text=heatmap-ok
+6 -6
View File
@@ -14,7 +14,7 @@ H-Z-H on |0⟩ → |1⟩.
**qc = > `qc`.z qubit=0**
**qc = > `qc`.h qubit=0**
**p = > `qc`.probabilities**
**p1 = p[^1]**
**p1 = [1](p)**
**lo = > math.div a=9 b=10**
1. `p1` > `lo`
@@ -28,7 +28,7 @@ Ry(π) on |0⟩ → |1⟩.
**ry = > quantum.circuit qubits=1**
**ry = > `ry`.ry qubit=0 theta=`pi`**
**rp = > `ry`.probabilities**
**rp1 = rp[^1]**
**rp1 = [1](rp)**
1. `rp1` > `lo`
> print text=ry-ok
@@ -41,10 +41,10 @@ Bell run with fixed seed: both 00 and 11 appear; shots sum.
**bell = > `bell`.h qubit=0**
**bell = > `bell`.cx control=0 target=1**
**res = > `bell`.run shots=200 seed=42**
**counts = res[^counts]**
**c00 = counts[^00]**
**c11 = counts[^11]**
**shots = res[^shots]**
**counts = [counts](res)**
**c00 = [00](counts)**
**c11 = [11](counts)**
**shots = [shots](res)**
1. `c00`
1. `c11`
+1 -1
View File
@@ -40,7 +40,7 @@ import math:lib/math.mq.md
> print text=expect-fail
**sch = > `qc`.schmidt cut=1**
**ent = sch[^entropy]**
**ent = [entropy](sch)**
**elo = > math.div a=1 b=2**
1. `ent` > `elo`
> print text=schmidt-ok
+1 -1
View File
@@ -10,7 +10,7 @@ import quantum:ext/quantum/quantum.mq.md
**qc = > `qc`.i qubit=0**
**qc = > `qc`.noise kind="bitflip" p=1**
**r = > `qc`.run shots=32 seed=3**
**c1 = r[^counts][^1]**
**c1 = [1]([counts](r))**
1. `c1` == 32
> print text=noise-ok
+1 -1
View File
@@ -10,7 +10,7 @@ description: 噪声 bitflip p=1 后 I 使全部射中 |1⟩.
**qc = > `qc`.单位 比特=0**
**qc = > `qc`.噪声 种类="bitflip" 概率=1**
**r = > `qc`.运行 次数=32 种子=3**
**c1 = r[^counts][^1]**
**c1 = [1]([counts](r))**
1. `c1` == 32
> print text=noise-ok
+2 -2
View File
@@ -16,7 +16,7 @@ import math:lib/math.mq.md
**qc = > quantum.circuit qubits=2 steps=`steps`**
**p = > `qc`.probabilities**
**p00 = p[^00]**
**p00 = [00](p)**
**lo = > math.div a=2 b=5**
**hi = > math.div a=3 b=5**
@@ -29,7 +29,7 @@ import math:lib/math.mq.md
> print text=steps-fail
**img = > `qc`.draw path="quantum-steps-draw.svg"**
**kind = img[^kind]**
**kind = [kind](img)**
1. `kind` == circuit
> print text=draw-ok
+1 -1
View File
@@ -12,7 +12,7 @@ import math:lib/math.mq.md
**电路 = > `电路`.泡利Z 比特=0**
**电路 = > `电路`.哈达玛 比特=0**
**概率 = > `电路`.概率**
**p1 = 概率[^1]**
**p1 = [1](概率)**
**lo = > math.div a=9 b=10**
1. `p1` > `lo`
+3 -3
View File
@@ -24,15 +24,15 @@ import sys:lib/sys.mq.md
**page = > web.page title="Home"**
**page = > page.meta meta=`meta`**
**mm = page[^meta]**
**m = mm[^title]**
**mm = [meta](page)**
**m = [title](mm)**
1. `m` == "My Site"
> print text=meta-ok
2. *
> print text=meta-fail
**page = > page.paginate offset=0 limit=5 path="/"**
**poff = page[^paginate][^offset]**
**poff = [offset]([paginate](page))**
1. `poff` == 0
> print text=paginate-ok
2. *
+4 -4
View File
@@ -49,8 +49,8 @@ import json:lib/json.mq.md
> print text=count-where-fail
**page1 = > `store`.paginate table="posts" limit=2 跳过=0**
**total1 = page1[^total]**
**p1r = page1[^rows]**
**total1 = [total](page1)**
**p1r = [rows](page1)**
**n1 = > len value=`p1r`**
1. `total1` == 4
1. `n1` == 2
@@ -59,7 +59,7 @@ import json:lib/json.mq.md
> print text=page-fail
**page2 = > `store`.paginate table="posts" limit=2 跳过=2**
**p2r = page2[^rows]**
**p2r = [rows](page2)**
**n2 = > len value=`p2r`**
1. `n2` == 2
> print text=page2-ok
@@ -107,7 +107,7 @@ import json:lib/json.mq.md
> print text=or-fail
**agg = > `store`.query sql="SELECT title, views FROM posts WHERE views >= 30 ORDER BY views DESC"**
**nagg = agg[^count]**
**nagg = [count](agg)**
1. `nagg` == 2
> print text=query-ok
2. *
+6 -6
View File
@@ -15,7 +15,7 @@ import web:ext/web/web.mq.md
| 2 | CREATE TABLE IF NOT EXISTS comments (id INTEGER PRIMARY KEY AUTOINCREMENT, post_id INTEGER NOT NULL, body TEXT NOT NULL, status TEXT NOT NULL DEFAULT 'pending') |
**m1 = > `store`.migrate steps=`steps`**
**a1 = m1[^applied]**
**a1 = [applied](m1)**
**n1 = > len value=`a1`**
1. `n1` == 2
> print text=migrate-ok
@@ -23,7 +23,7 @@ import web:ext/web/web.mq.md
> print text=migrate-fail
**m2 = > `store`.migrate steps=`steps`**
**a2 = m2[^applied]**
**a2 = [applied](m2)**
**n2 = > len value=`a2`**
1. `n2` == 0
> print text=migrate-idempotent-ok
@@ -68,15 +68,15 @@ import web:ext/web/web.mq.md
> `store`.fts table="posts" columns="title,body"
**hit = > `store`.search table="posts" q="hello" limit=10**
**hn = hit[^count]**
**hn = [count](hit)**
1. `hn` >= 1
> print text=fts-ok
2. *
> print text=fts-fail
**rows2 = hit[^rows]**
**first = rows2[^1]**
**ft = first[^title]**
**rows2 = [rows](hit)**
**first = [1](rows2)**
**ft = [title](first)**
1. `ft`
> print text=fts-row-ok
2. *
+6 -6
View File
@@ -19,7 +19,7 @@ import sys:lib/sys.mq.md
**c = > web.cache url="memory:drivers-smoke"**
> `c`.set key="k1" value="v1" ttl=60
**g = > `c`.get key="k1"**
**gv = g[^value]**
**gv = [value](g)**
1. `gv` == "v1"
> print text=cache-ok
2. *
@@ -27,7 +27,7 @@ import sys:lib/sys.mq.md
> `c`.del key="k1"
**ex = > `c`.exists key="k1"**
**eok = ex[^ok]**
**eok = [ok](ex)**
1. `eok`
> print text=cache-del-fail
2. *
@@ -38,14 +38,14 @@ import sys:lib/sys.mq.md
**blob = > web.storage url="file:tests/ext/web-fixtures/data/drivers-blobs"**
> `blob`.put key="notes/a.txt" body="hello" content_type="text/plain"
**got = > `blob`.get key="notes/a.txt"**
**body = got[^body]**
**body = [body](got)**
1. `body` == "hello"
> print text=storage-ok
2. *
> print text=storage-fail
**ls = > `blob`.list prefix="notes/"**
**n = ls[^count]**
**n = [count](ls)**
1. `n` == 1
> print text=storage-list-ok
2. *
@@ -56,7 +56,7 @@ import sys:lib/sys.mq.md
<!-- db: postgres URL is accepted as a handle (no live server required) -->
**pg = > web.db url="postgres://marqdo:marqdo@127.0.0.1:5432/marqdo"**
**purl = pg[^url]**
**purl = [url](pg)**
1. `purl` == "postgres://marqdo:marqdo@127.0.0.1:5432/marqdo"
> print text=postgres-url-ok
2. *
@@ -65,7 +65,7 @@ import sys:lib/sys.mq.md
<!-- s3 URL shape validates at open -->
**s3 = > web.storage url="s3://bucket?endpoint=http://127.0.0.1:9000"**
**sb = s3[^backend]**
**sb = [backend](s3)**
1. `sb` == "s3"
> print text=s3-open-ok
2. *
+2 -2
View File
@@ -18,13 +18,13 @@ import plugin:lib/plugin.mq.md
| 0ae9134cca7eff9d756fbf52402ee28ae0c2be22f01e53653e4fe86021479703 | read,api |
**ok = > web_api_key_check key="smoke-secret" authorization="" pepper=`pepper` keys=`keys`**
1. ok[^ok]
1. [ok](ok)
> print text=api-key-ok
2. *
> print text=api-key-fail
**bad = > web_api_key_check key="wrong" authorization="" pepper=`pepper` keys=`keys`**
1. bad[^ok]
1. [ok](bad)
> print text=api-key-bad-ok
2. *
> print text=api-key-bad-fail
+1 -1
View File
@@ -12,7 +12,7 @@ Nested plugin call (`web.page`) while `app.listen` is the outer plugin frame —
must not clear GLOBAL_HOST so a second HTTP invoke still works.
**pg = > web.page title=`msg`**
**title = pg[^title]**
**title = [title](pg)**
`out` =
+22 -22
View File
@@ -50,33 +50,33 @@ import sys:lib/sys.mq.md
**app = > web.app page=`pg`**
**app = > `app`.configure cors=`cors` security=`sec` compress=True body_limit=1048576 json=`api`**
**mw = app[^middleware]**
**mw = [middleware](app)**
<!-- cors -->
**cobj = mw[^cors]**
**origins = cobj[^allow_origins]**
**o0 = origins[^1]**
**cobj = [cors](mw)**
**origins = [allow_origins](cobj)**
**o0 = [1](origins)**
1. `o0` == "https://a.example"
> print text=cors-origin-ok
2. *
> print text=cors-origin-fail
**methods = cobj[^methods]**
**m1 = methods[^2]**
**methods = [methods](cobj)**
**m1 = [2](methods)**
1. `m1` == "POST"
> print text=cors-method-ok
2. *
> print text=cors-method-fail
**expose = cobj[^expose_headers]**
**e0 = expose[^1]**
**expose = [expose_headers](cobj)**
**e0 = [1](expose)**
1. `e0` == "X-Total"
> print text=cors-expose-ok
2. *
> print text=cors-expose-fail
**cred = cobj[^credentials]**
**cred = [credentials](cobj)**
1. `cred`
> print text=cors-cred-ok
2. *
@@ -84,14 +84,14 @@ import sys:lib/sys.mq.md
<!-- security -->
**secmap = mw[^security]**
**frame = secmap[^X-Frame-Options]**
**secmap = [security](mw)**
**frame = [X-Frame-Options](secmap)**
1. `frame` == "DENY"
> print text=security-frame-ok
2. *
> print text=security-frame-fail
**csp = secmap[^Content-Security-Policy]**
**csp = [Content-Security-Policy](secmap)**
1. `csp` == "default-src 'self'"
> print text=security-csp-ok
2. *
@@ -99,13 +99,13 @@ import sys:lib/sys.mq.md
<!-- compress / body_limit -->
**comp = mw[^compress]**
**comp = [compress](mw)**
1. `comp`
> print text=compress-ok
2. *
> print text=compress-fail
**bl = mw[^body_limit]**
**bl = [body_limit](mw)**
1. `bl` == 1048576
> print text=body-limit-ok
2. *
@@ -113,34 +113,34 @@ import sys:lib/sys.mq.md
<!-- json routes -->
**jmap = mw[^json_routes]**
**posts = jmap[^api/posts]**
**pok = posts[^method]**
**jmap = [json_routes](mw)**
**posts = [api/posts](jmap)**
**pok = [method](posts)**
1. `pok` == "GET"
> print text=json-get-ok
2. *
> print text=json-get-fail
**ptable = posts[^table]**
**ptable = [table](posts)**
1. `ptable` == "articles"
> print text=json-table-ok
2. *
> print text=json-table-fail
**porder = posts[^order]**
**porder = [order](posts)**
1. `porder` == "-created_at"
> print text=json-order-ok
2. *
> print text=json-order-fail
**plimit = posts[^limit]**
**plimit = [limit](posts)**
1. `plimit` == 20
> print text=json-limit-ok
2. *
> print text=json-limit-fail
**pub = jmap[^api/publish]**
**pmethod = pub[^method]**
**pub = [api/publish](jmap)**
**pmethod = [method](pub)**
1. `pmethod` == "POST"
> print text=json-post-ok
2. *
+20 -20
View File
@@ -28,35 +28,35 @@ import sys:lib/sys.mq.md
<!-- session CRUD -->
**sess = > web_session_new ttl_sec=120**
**sid = sess[^id]**
**sid = [id](sess)**
1. `sid` != ""
> print text=session-new-ok
2. *
> print text=session-new-fail
**set1 = > web_session_set id=`sid` key="theme" value="dark"**
**ok1 = set1[^ok]**
**ok1 = [ok](set1)**
1. `ok1`
> print text=session-set-ok
2. *
> print text=session-set-fail
**get1 = > web_session_get id=`sid` key="theme"**
**v1 = get1[^value]**
**v1 = [value](get1)**
1. `v1` == "dark"
> print text=session-get-ok
2. *
> print text=session-get-fail
**del1 = > web_session_del id=`sid` key="theme"**
**ok2 = del1[^ok]**
**ok2 = [ok](del1)**
1. `ok2`
> print text=session-del-ok
2. *
> print text=session-del-fail
**get2 = > web_session_get id=`sid` key="theme"**
**ok3 = get2[^ok]**
**ok3 = [ok](get2)**
1. `ok3`
> print text=session-del-confirm-fail
2. *
@@ -65,43 +65,43 @@ import sys:lib/sys.mq.md
<!-- auth login/check/logout -->
**login = > web_auth_login username="admin" password="secret" users=`users` session_ttl=120**
**lok = login[^ok]**
**lok = [ok](login)**
1. `lok`
> print text=auth-login-ok
2. *
> print text=auth-login-fail
**sid2 = login[^session_id]**
**sid2 = [session_id](login)**
**check = > web_auth_check session_id=`sid2`**
**cok = check[^ok]**
**cok = [ok](check)**
1. `cok`
> print text=auth-check-ok
2. *
> print text=auth-check-fail
**badlogin = > web_auth_login username="admin" password="wrong" users=`users` session_ttl=120**
**bok = badlogin[^ok]**
**bok = [ok](badlogin)**
1. `bok`
> print text=auth-bad-should-fail
2. *
> print text=auth-bad-ok
**zhlogin = > web_auth_login username="站长" password="pw123" users=`users` session_ttl=120**
**zhok = zhlogin[^ok]**
**zhok = [ok](zhlogin)**
1. `zhok`
> print text=auth-zh-ok
2. *
> print text=auth-zh-fail
**logout = > web_auth_logout session_id=`sid2`**
**dok = logout[^ok]**
**dok = [ok](logout)**
1. `dok`
> print text=auth-logout-ok
2. *
> print text=auth-logout-fail
**check2 = > web_auth_check session_id=`sid2`**
**cok2 = check2[^ok]**
**cok2 = [ok](check2)**
1. `cok2`
> print text=auth-logout-confirm-fail
2. *
@@ -112,18 +112,18 @@ import sys:lib/sys.mq.md
**pg = > web.page title="ws-test"**
**app = > web.app page=`pg` admin=True**
**app = > `app`.route_ws path="/live" echo=True**
**routes = app[^ws_routes]**
**has_live = routes[^/live]**
**routes = [ws_routes](app)**
**has_live = [/live](routes)**
1. `has_live`
> print text=ws-route-ok
2. *
> print text=ws-route-fail
**app = > `app`.auth users=`users` session_ttl=120**
**authobj = app[^auth]**
**ausers = authobj[^users]**
**au1 = ausers[^1][^用户]**
**ou1 = users[^1][^用户]**
**authobj = [auth](app)**
**ausers = [users](authobj)**
**au1 = [用户]([1](ausers))**
**ou1 = [用户]([1](users))**
1. `au1` == `ou1`
> print text=app-auth-ok
2. *
@@ -133,7 +133,7 @@ import sys:lib/sys.mq.md
**authz = > web.auth users=`users` session_ttl=120**
**login2 = > `authz`.login username="admin" password="secret"**
**lok2 = login2[^ok]**
**lok2 = [ok](login2)**
1. `lok2`
> print text=ext-auth-ok
2. *
@@ -141,7 +141,7 @@ import sys:lib/sys.mq.md
**ws = > web.ws timeout_sec=1**
**badurl = > `ws`.connect url="ws://127.0.0.1:1" message="hi"**
**bwok = badurl[^ok]**
**bwok = [ok](badurl)**
1. `bwok`
> print text=ws-connect-should-fail
2. *
+7 -7
View File
@@ -48,7 +48,7 @@ import json:lib/json.mq.md
> `store`.insert table="posts" rows=`rows`
**got = > `store`.get table="posts" id=1**
**ca = got[^created_at]**
**ca = [created_at](got)**
1. `ca`
> print text=audit-insert-ok
2. *
@@ -57,14 +57,14 @@ import json:lib/json.mq.md
**upd = > json.parse text={"title":"Hello P3b"}**
> `store`.update table="posts" id=1 row=`upd`
**got2 = > `store`.get table="posts" id=1**
**ua2 = got2[^updated_at]**
**ua2 = [updated_at](got2)**
1. `ua2`
> print text=audit-update-ok
2. *
> print text=audit-update-fail
**fk = > `store`.query sql="SELECT sql FROM sqlite_master WHERE type='table' AND name='comments'"**
**fkddl = fk[^rows][^1][^sql]**
**fkddl = [sql]([1]([rows](fk)))**
1. `fkddl`
> print text=fk-ok
2. *
@@ -78,7 +78,7 @@ import json:lib/json.mq.md
| alice | secret | author |
**login = > web_auth_login username="alice" password="secret" users=`users` session_ttl=120**
**role = login[^role]**
**role = [role](login)**
1. `role` == "author"
> print text=rbac-login-ok
2. *
@@ -88,7 +88,7 @@ import json:lib/json.mq.md
**app = > web.app page=`pg` port=18130**
**app = > `app`.auth users=`users`**
**app = > `app`.gate path="/write*" roles="admin,author"**
**gates = app[^gates]**
**gates = [gates](app)**
**ng = > len value=`gates`**
1. `ng` >= 2
> print text=rbac-gate-ok
@@ -98,8 +98,8 @@ import json:lib/json.mq.md
**blob = > web.storage url="file:web-fixtures/data/p3-gallery"**
> `blob`.put key="uploads/a.txt" body="hi" content_type="text/plain"
**app = > `app`.gallery path="/gallery" storage=`blob` prefix="uploads/" title="Media" download_base="/_media"**
**gal = app[^gallery_routes]**
**g = gal[^/gallery]**
**gal = [gallery_routes](app)**
**g = [/gallery](gal)**
1. `g`
> print text=gallery-ok
2. *
+12 -12
View File
@@ -32,43 +32,43 @@ import sys:lib/sys.mq.md
**app = > `app`.proxy path="/v1/stream" upstream="https://example.com/v1/chat" stream=True headers_from_env="TOKEN=X-Token"**
**app = > `app`.invoke path="/api/ping" fn="demo.ping" method="GET" body="query"**
**proutes = app[^proxy_routes]**
**chat = proutes[^proxy/chat]**
**up = chat[^upstream]**
**proutes = [proxy_routes](app)**
**chat = [proxy/chat](proutes)**
**up = [upstream](chat)**
1. `up` == "$OPENAI_BASE_URL"
> print text=proxy-table-ok
2. *
> print text=proxy-table-fail
**stream = chat[^stream]**
**stream = [stream](chat)**
1. `stream`
> print text=proxy-stream-ok
2. *
> print text=proxy-stream-fail
**hdr = chat[^headers_from_env]**
**hdr = [headers_from_env](chat)**
1. `hdr` == "OPENAI_API_KEY=Authorization"
> print text=proxy-env-ok
2. *
> print text=proxy-env-fail
**v1 = proutes[^v1/stream]**
**v1u = v1[^upstream]**
**v1 = [v1/stream](proutes)**
**v1u = [upstream](v1)**
1. `v1u` == "https://example.com/v1/chat"
> print text=proxy-method-ok
2. *
> print text=proxy-method-fail
**iroutes = app[^invoke_routes]**
**echo = iroutes[^api/echo]**
**efn = echo[^fn]**
**iroutes = [invoke_routes](app)**
**echo = [api/echo](iroutes)**
**efn = [fn](echo)**
1. `efn` == "demo.echo"
> print text=invoke-table-ok
2. *
> print text=invoke-table-fail
**ping = iroutes[^api/ping]**
**pm = ping[^method]**
**ping = [api/ping](iroutes)**
**pm = [method](ping)**
1. `pm` == "GET"
> print text=invoke-method-ok
2. *
+3 -3
View File
@@ -19,7 +19,7 @@ import sys:lib/sys.mq.md
<!-- argon2 hash must be non-empty PHC string -->
**hash = > web_password_hash password="secret"**
**h = hash[^hash]**
**h = [hash](hash)**
1. `h` != ""
> print text=hash-ok
2. *
@@ -34,14 +34,14 @@ import sys:lib/sys.mq.md
| 1 | admin | secret |
**login = > web_auth_login username="admin" password="secret" users=`users` session_ttl=120**
**lok = login[^ok]**
**lok = [ok](login)**
1. `lok`
> print text=auth-login-ok
2. *
> print text=auth-login-fail
**bad = > web_auth_login username="admin" password="wrong" users=`users` session_ttl=120**
**bok = bad[^ok]**
**bok = [ok](bad)**
1. `bok`
> print text=auth-bad-should-fail
2. *
+6 -6
View File
@@ -23,21 +23,21 @@ import sys:lib/sys.mq.md
**m = > web.media**
**ok = > `m`.validate filename="a.png" content_type="image/png" size=100 max_bytes=1000 types=`types`**
**ook = ok[^ok]**
**ook = [ok](ok)**
1. `ook`
> print text=validate-ok
2. *
> print text=validate-fail
**bad = > `m`.validate filename="a.exe" content_type="application/octet-stream" size=100 max_bytes=1000 types=`types`**
**bok = bad[^ok]**
**bok = [ok](bad)**
1. `bok`
> print text=reject-type-fail
2. *
> print text=reject-type-ok
**big = > `m`.validate filename="a.png" content_type="image/png" size=9000 max_bytes=1000 types=`types`**
**gok = big[^ok]**
**gok = [ok](big)**
1. `gok`
> print text=reject-size-fail
2. *
@@ -46,15 +46,15 @@ import sys:lib/sys.mq.md
**blob = > web.storage url="file:tests/ext/web-fixtures/data/upload-blobs"**
**m = > web.media storage=`blob`**
**saved = > `m`.save path="tests/ext/web-fixtures/upload/sample.txt" content_type="text/plain" prefix="smoke/"**
**sok = saved[^ok]**
**skey = saved[^key]**
**sok = [ok](saved)**
**skey = [key](saved)**
1. `sok`
> print text=save-ok
2. *
> print text=save-fail
**got = > `blob`.get key=`skey`**
**body = got[^body]**
**body = [body](got)**
1. `body` == "hello-upload"
> print text=save-roundtrip-ok
2. *
+8 -8
View File
@@ -27,7 +27,7 @@ import sys:lib/sys.mq.md
> `store`.init name=posts fields=`fields`
**idx = > `store`.query sql="SELECT name FROM sqlite_master WHERE type='index' AND tbl_name='posts'"**
**nidx = > len value=idx[^rows]**
**nidx = > len value=[rows](idx)**
1. `nidx` >= 1
> print text=unique-ok
2. *
@@ -41,7 +41,7 @@ import sys:lib/sys.mq.md
| /about | 2026-08-28 |
**sm = > web_sitemap_build base="https://example.com" items=`items`**
**xml = sm[^xml]**
**xml = [xml](sm)**
1. `xml`
> print text=sitemap-ok
2. *
@@ -55,27 +55,27 @@ import sys:lib/sys.mq.md
**app = > `app`.error_page status=404 page=`notfound`**
**app = > `app`.sitemap path="/sitemap.xml" base="https://example.com" items=`items`**
**app = > `app`.robots sitemap="https://example.com/sitemap.xml"**
**rd = app[^redirects]**
**has = rd[^/old]**
**rd = [redirects](app)**
**has = [/old](rd)**
1. `has`
> print text=redirect-ok
2. *
> print text=redirect-fail
**rb = app[^robots_body]**
**rb = [robots_body](app)**
1. `rb`
> print text=robots-ok
2. *
> print text=robots-fail
**mw = app[^middleware]**
**cc = mw[^cache_control]**
**mw = [middleware](app)**
**cc = [cache_control](mw)**
1. `cc` == "public, max-age=60"
> print text=cache-control-ok
2. *
> print text=cache-control-fail
**p404 = app[^page_404]**
**p404 = [page_404](app)**
1. `p404`
> print text=error-page-ok
2. *
+5 -5
View File
@@ -16,17 +16,17 @@ import sys:lib/sys.mq.md
**pg = > web.page title="w6b"**
**app = > web.app page=`pg` port=18111**
**app = > `app`.route_ws path="/room" mode="broadcast"**
**routes = app[^ws_routes]**
**room = routes[^/room]**
**mode = room[^mode]**
**routes = [ws_routes](app)**
**room = [/room](routes)**
**mode = [mode](room)**
1. `mode` == "broadcast"
> print text=ws-broadcast-route-ok
2. *
> print text=ws-broadcast-route-fail
**app = > `app`.configure access_log=True compress=False**
**mw = app[^middleware]**
**al = mw[^access_log]**
**mw = [middleware](app)**
**al = [access_log](mw)**
1. `al`
> print text=access-log-ok
2. *
+4 -4
View File
@@ -11,12 +11,12 @@ import cli:lib/cli.mq.md
**rows = > csv.parse text=`raw`**
**rows = > table.sort_by list=`rows` key="name"**
**r0 = > at value=`rows` index=0**
> print text=`r0`[^name]
> print text=[name](`r0`)
**args = > split value="--input,data.csv,rest,--verbose" sep=","**
**flags = > cli.parse args=`args`**
> print text=`flags`[^input]
> print text=`flags`[^verbose]
**pos = `flags`[^_]**
> print text=[input](`flags`)
> print text=[verbose](`flags`)
**pos = [_](`flags`)**
**p0 = > at value=`pos` index=0**
> print text=`p0`
+2 -2
View File
@@ -12,8 +12,8 @@ import csv:lib/csv.mq.md
> print text=`n`
**r0 = > at value=`rows` index=0**
> print text=`r0`[^name]
> print text=`r0`[^note]
> print text=[name](`r0`)
> print text=[note](`r0`)
**out = > csv.stringify rows=`rows`**
**rows2 = > csv.parse text=`out`**
+2 -2
View File
@@ -6,10 +6,10 @@ import dt:lib/datetime.mq.md
# main
**m = > dt.from_unix unix=0**
> print text=`m`[^iso]
> print text=[iso](`m`)
**sh = > dt.in_zone dt=`m` zone="Asia/Shanghai"**
> print text=`sh`[^iso]
> print text=[iso](`sh`)
**p = > dt.parse text="2020-01-02T03:04:05+08:00"**
**u = > dt.to_unix dt=`p`**
+3 -3
View File
@@ -12,9 +12,9 @@ import fs:lib/fs.mq.md
> fs.write_text path="m9-tree/nested/b.txt" text="B"
**st = > fs.stat path="m9-tree/a.txt"**
> print text=`st`[^size]
> print text=`st`[^is_file]
> print text=`st`[^is_dir]
> print text=[size](`st`)
> print text=[is_file](`st`)
> print text=[is_dir](`st`)
**w = > fs.walk path="m9-tree"**
**n = > len `w`**
+6 -6
View File
@@ -9,9 +9,9 @@ import net:lib/net.mq.md
**resp = > net.cookie_parse text="id=42; Path=/; HttpOnly; Secure; SameSite=Lax, theme=light; Max-Age=3600" is_response=True**
> print text=`req`[^1][^name]
> print text=`req`[^1][^value]
> print text=`resp`[^1][^http_only]
> print text=`resp`[^1][^secure]
> print text=`resp`[^1][^same_site]
> print text=`resp`[^2][^max_age]
> print text=[name]([1](`req`))
> print text=[value]([1](`req`))
> print text=[http_only]([1](`resp`))
> print text=[secure]([1](`resp`))
> print text=[same_site]([1](`resp`))
> print text=[max_age]([2](`resp`))
+6 -6
View File
@@ -11,9 +11,9 @@ import net:lib/net.mq.md
**parts = > net.multipart_parse body=`body` boundary=`boundary`**
> print text=`parts`[^1][^name]
> print text=`parts`[^1][^value]
> print text=`parts`[^2][^name]
> print text=`parts`[^2][^filename]
> print text=`parts`[^2][^content_type]
> print text=`parts`[^2][^value]
> print text=[name]([1](`parts`))
> print text=[value]([1](`parts`))
> print text=[name]([2](`parts`))
> print text=[filename]([2](`parts`))
> print text=[content_type]([2](`parts`))
> print text=[value]([2](`parts`))
+2 -2
View File
@@ -15,8 +15,8 @@ import json:lib/json.mq.md
**args = > json.parse text=["-c","printf hi-capture"]**
**out = > sys.exec cmd="sh" args=args capture=True**
**c = out[^code]**
**s = out[^stdout]**
**c = [code](out)**
**s = [stdout](out)**
1. `c` == 0
> print text=capture-code-ok
2. *
+5 -5
View File
@@ -7,7 +7,7 @@ import table:lib/table.mq.md
# main
**h = > table.put in=None at="Authorization" value="Bearer-x"**
> print text=`h`[^Authorization]
> print text=[Authorization](`h`)
`xs` =
@@ -17,8 +17,8 @@ import table:lib/table.mq.md
| b |
**xs = > table.put in=`xs` at=1 value="A"**
> print text=`xs`[^1]
> print text=`xs`[^2]
> print text=[1](`xs`)
> print text=[2](`xs`)
`req` =
@@ -31,8 +31,8 @@ import table:lib/table.mq.md
**messages = > table.append list=None item=`msg`**
**req = > table.put in=`req` at="messages" value=`messages`**
**req = > table.put in=`req` at="stream" value=True**
> print text=`req`[^messages][^1][^content]
> print text=`req`[^stream]
> print text=[content]([1]([messages](`req`)))
> print text=[stream](`req`)
**xs = > table.append list=`xs` item="c"**
**n = > table.len xs=`xs`**
+4 -4
View File
@@ -8,10 +8,10 @@ import enc:lib/encoding.mq.md
# main
**cfg = > toml.parse text="name = \"marqdo\"\ncount = 2\n[pkg]\nver = \"1\"\n"**
> print text=`cfg`[^name]
> print text=`cfg`[^count]
**pkg = `cfg`[^pkg]**
> print text=`pkg`[^ver]
> print text=[name](`cfg`)
> print text=[count](`cfg`)
**pkg = [pkg](`cfg`)**
> print text=[ver](`pkg`)
**e = > html.escape text="a<b>&\"c'"**
> print text=`e`
+8 -8
View File
@@ -6,16 +6,16 @@ import url:lib/url.mq.md
# main
**u = > url.parse text="https://example.com:8443/a/b?x=1&y=2#frag"**
> print text=`u`[^scheme]
> print text=`u`[^host]
> print text=`u`[^port]
> print text=`u`[^path]
> print text=`u`[^query]
> print text=`u`[^fragment]
> print text=[scheme](`u`)
> print text=[host](`u`)
> print text=[port](`u`)
> print text=[path](`u`)
> print text=[query](`u`)
> print text=[fragment](`u`)
**q = > url.query_parse text="a=1&b=hi%20x&a=2"**
> print text=`q`[^b]
**as = `q`[^a]**
> print text=[b](`q`)
**as = [a](`q`)**
**a0 = > at value=`as` index=0**
**a1 = > at value=`as` index=1**
> print text=`a0`
+4 -4
View File
@@ -6,7 +6,7 @@ title: lib/地址 烟测
# main
**u = > 址.解析 内容="https://example.com/a?x=1"**
> print text=`u`[^scheme]
> print text=`u`[^host]
> print text=`u`[^path]
> print text=`u`[^query]
> print text=[scheme](`u`)
> print text=[host](`u`)
> print text=[path](`u`)
> print text=[query](`u`)
+1 -1
View File
@@ -10,7 +10,7 @@ title: 文件 Mid2 M9 烟测
> 文件.写文本 路径="m9-zh/a.txt" 内容="A"
**st = > 文件.状态 路径="m9-zh/a.txt"**
> print text=`st`[^is_file]
> print text=[is_file](`st`)
**w = > 文件.遍历 路径="m9-zh"**
**n = > 长度 `w`**
+2 -2
View File
@@ -6,10 +6,10 @@ title: lib/日期时间 烟测
# main
**m = > 日时.自戳 秒=0**
> print text=`m`[^iso]
> print text=[iso](`m`)
**sh = > 日时.时区 时刻=`m` 区="Asia/Shanghai"**
> print text=`sh`[^iso]
> print text=[iso](`sh`)
**p = > 日时.解析 内容="2020-01-02T03:04:05+08:00"**
**u = > 日时.成戳 时刻=`p`**
+2 -2
View File
@@ -13,5 +13,5 @@ title: 表与命令行 烟测
**args = > split value="--x,1,--flag" sep=","**
**flags = > 命令行.解析 参数=`args`**
> 打印 内容=`flags`[^x]
> 打印 内容=`flags`[^flag]
> 打印 内容=[x](`flags`)
> 打印 内容=[flag](`flags`)
+2 -2
View File
@@ -7,7 +7,7 @@ description: 改 + 列表字典
# main
**h = > 表.改 入=None 于="Authorization" 值="Bearer-x"**
> 打印 内容=`h`[^Authorization]
> 打印 内容=[Authorization](`h`)
`xs` =
@@ -17,7 +17,7 @@ description: 改 + 列表字典
| b |
**xs = > 表.改 入=`xs` 于=1 值="A"**
> 打印 内容=`xs`[^1]
> 打印 内容=[1](`xs`)
**xs = > 表.追加 list=`xs` item="c"**
**n = > 表.长度 xs=`xs`**
+1 -1
View File
@@ -12,4 +12,4 @@ title: lib/逗号表 烟测
> 打印 内容=`n`
**r0 = > at value=`rows` index=0**
> 打印 内容=`r0`[^a]
> 打印 内容=[a](`r0`)
@@ -8,8 +8,8 @@ title: lib/配置表 超文本 编码 烟测
# main
**cfg = > 配置.解析 内容="name = \"中文\"\nok = true\n"**
> print text=`cfg`[^name]
> print text=`cfg`[^ok]
> print text=[name](`cfg`)
> print text=[ok](`cfg`)
**e = > 超.转义 内容="a<b>"**
> print text=`e`