Compare commits

...
34 Commits
Author SHA1 Message Date
cflmyandCursor 3287799959 docs(skill): note table-bound page.compose_intro for v1.0.2
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-16 21:06:30 +08:00
cflmyandCursor f95e5d3339 release: v1.0.2 — table-bound page intro (compose_intro)
Ship web_compose_intro / 引言装配 and web-site demo polish; bump Cargo and docs.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-16 21:05:49 +08:00
cflmyandCursor 52b4bae423 feat(web-site): harden sample desk, auth login, and form layout
Align nav/side/foot slots and shell CSS with table-driven admin desk;
add session login/logout mount and widen form fields for usable create UX.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-16 19:44:12 +08:00
cflmyandCursor 037592087c feat(web): table-bound intro and demo-grade web-site sample
Add compose_intro (属性/值/样式) so page heroes are not HTML strings, and polish examples/web-site for WWW Demo: literary shell, card→detail routes, richer seeds, particle atmosphere without author JS.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-16 17:34:49 +08:00
cflmyandCursor 3eb8e732ea release: v1.0.1 — fix Go libweb dynamic-route query, Markdown, CSS false positives
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-15 14:48:47 +08:00
cflmyandCursor 761b92afce docs(public): keep narrative emphasis from executing as v0.3 code
Unbold code-shaped prose and give log.fields a map so pages and
`view output` stay green under markup v0.3.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-14 16:15:47 +08:00
cflmyandCursor b5f43ee993 release: v1.0.0 — markup v0.3 as the 1.0 language surface
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-14 16:05:29 +08:00
cflmyandCursor 76da97f090 ci(release): require Linux native+CLI zips; document proxy.cflmy.top
Pages was failing on leading-backtick narrative (already fixed on main).
Linux job now waits for the Windows release, then uploads .so plugins and a
Linux CLI bundle. Release skill treats those assets as mandatory.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-14 16:03:02 +08:00
cflmyandCursor 7554e45f60 feat(debug): dump v0.3 prose bits, inferred params, and dead binds
--dump-lines tags [decl]/[bold]/[italic]; --dump-ast prints `inferred` params
and `dead=[…]`. Migrate leftover italic-assign unit fixtures to bold/return.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-14 15:33:45 +08:00
cflmyandCursor 6994acb91d fix(prose): mid-line italic emphasis is not a return
Skip *very important* / *foo.bar* / *code-as-docs* so narrative emphasis cannot end a function; keep whole-line *n* and 返回*n*.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-14 15:25:26 +08:00
cflmyandCursor bccfec86ba feat(parse): bold infix expressions are ExprStmt, not calls
`` **n + 1** `` evaluates and discards (design §6.2); keep assign-first and
bare-call fallback. Explicit `` **> …** `` uses standalone bare=text rules.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-14 15:12:00 +08:00
cflmyandCursor 114fd53cd1 fix(prose): Decl names are identifiers; skip non-decl tick spans
Reject `` `n+1` `` as Decl, and when skipping non-decl `` `…` `` advance past the closing tick so inner `*` cannot open italic (fixes `` `OPENAI_*` `` in ext/ai/llm).

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-14 14:50:01 +08:00
cflmyandCursor c8f41164c5 fix(parse): keep GAP recovery for unclosed bold
Hard-erroring code-shaped `` **… `` broke tests/structure/gap-star-json-body.mq.md; unclosed bold stays Comment so later statements still run.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-14 14:41:51 +08:00
cflmyandCursor 6f303ff957 fix(parse): diagnose unclosed code-shaped bold
Treat `` **x = 1 `` as Code and error with a clear unclosed-`**` diagnostic instead of silently skipping it as a comment.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-14 14:39:58 +08:00
cflmyandCursor 95a49697f7 fix(lex): glued ` name=default …prose ` is Decl, not assign
Trailing text after a glued default (same terminators as prose Decl) keeps the line narrative so `` `礼貌`=False 时… `` no longer binds a mangled text value.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-14 14:31:12 +08:00
cflmyandCursor 8846f5f070 fix(lex): treat leading backtick decl lines as narrative
Only `` `name` = … `` binds stay Code; lines like `` `捕获=True` 时… `` are Comment Decl prose so they no longer raise unrecognized statement.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-14 14:22:19 +08:00
cflmyandCursor 4f09e515ee feat(view): mark prose-inferred params in Structure
Show inferred function parameters with a dashed chip and outline annotation so view surfaces v0.3 param elevation without changing the redundant call surfaces.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-14 14:04:45 +08:00
cflmyandCursor 551f4ff322 feat(view): preserve bracket-marked calls without modifiers
Track CallExpr.bracket_marked from `[callee]` parse so Structure display keeps `[fn] …` instead of falling back to `> fn …` when there are no pre-modifiers.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-14 13:39:12 +08:00
cflmyandCursor d5a9301c7f docs(public): finish stdlib bracket-call demos and fix import returns
Prefer [lib.fn] in remaining public/stdlib samples, correct italic returns in structure import modules, and keep lib/系统 narration from starting with backticks.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-14 13:32:17 +08:00
cflmyandCursor 34915e3b16 docs: align remaining tutorial chapters with markup v0.3
Teach bold-as-code, italic-as-return, link-index, and bracket-marked calls across chapters 1–8/10–14 and Skill reference so teaching matches the runtime.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-14 13:18:28 +08:00
cflmyandCursor c55aad775e docs: teach link-index and v0.3 markers in tutorial and Skill
Rewrite chapter 9 and Skill examples around [key](coll), bracket-marked
calls, and ** code / * return; keep footnote get as a transitional note.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-14 13:08:53 +08:00
cflmyandCursor ac3f0633cd refactor(tests): prefer link-index in structure collection golds
Move collection-* structure fixtures to [key](base), and modernize
public/stdlib table/fs/time demos with bracket-marked library calls.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-14 13:03:03 +08:00
cflmyandCursor d55567a634 chore: stop tracking ephemeral tests/ext/:memory:
Remove the accidental sqlite artifact from the tree and ignore it.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-14 12:54:51 +08:00
cflmyandCursor abcb141737 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>
2026-09-14 12:54:38 +08:00
cflmyandCursor 8d97adc1dc docs(ext): narrate quantum/linalg and link-index public features
Add module intros and missing purpose lines for EN/ZH quantum and linalg
extensions; migrate remaining public/features footnote gets to [key](base).

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-14 12:45:57 +08:00
cflmyandCursor 5c37d54070 refactor(ext): prefer link-index get in web and ai modules
Migrate footnote-style collection access to [key](base) (including nested
chains) in ext/web and ext/ai EN/ZH sources.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-14 11:55:09 +08:00
cflmyandCursor fecaacd5be docs(lib): narrate remaining stdlib modules (M2)
Add module intros and per-function purpose lines across EN/ZH libs, with
callable examples on the smaller modules; keep + params and host bodies intact.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-14 11:47:35 +08:00
cflmyandCursor 53bc3538da docs(lib): narrate table/text/json as code-as-docs pilot
Add purpose lines and bracket-call examples in EN/ZH libs and public/stdlib
demos; keep explicit + params so function-body prose cannot be mistaken for
link-index or bold code.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-14 11:38:24 +08:00
cflmyandCursor 0e0655b316 feat(markup): bracket-marked calls with pre_modifiers
Stabilize `mod… [callee] args` (modifiers → name=True) alongside link-index
disambiguation; expand in interp/bytecode, show in view, and document lib/view
code-as-docs waves before stdlib rewrite.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-14 11:33:11 +08:00
cflmyandCursor 5058f5ddcf docs(examples): make code-as-docs read as a cafe journal
Drop syntax-teaching asides, rename the tip helper to 印章加一, and keep
return phrasing that the italic heuristic recognizes.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-14 10:52:30 +08:00
cflmyandCursor 4a1c9c48a2 feat(markup): prefer [key](collection) for map and list access
Add GFM link-shaped index as the primary get surface, keep footnote
index as transitional compatibility, and align the coffee example.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-14 10:44:18 +08:00
cflmyandCursor 5e74ff39f2 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>
2026-09-14 10:16:48 +08:00
cflmyandCursor b5c07385e9 feat(markup): finish v0.3 stock migration and green gold
Migrate remaining .mq.md (tests/ext/public/examples), stop elevating local assigns to params, inject form_target in Go libweb, and skip live LLM gold without a real key.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-13 23:43:44 +08:00
cflmyandCursor bfb10d172b 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>
2026-09-13 20:38:53 +08:00
521 changed files with 13513 additions and 5931 deletions

No files matched your search

+15 -7
View File
@@ -63,22 +63,22 @@ Cells are expressions (`doc/design/table-cell-expressions.md`): bare words = tex
**Single dynamic key** — one `table.put` (or a helper), not a json chain: **Single dynamic key** — one `table.put` (or a helper), not a json chain:
```markdown ```markdown
*`set_text` = > table.put in=None at="#log" value=msg* **`set_text` = table.put in=None at="#log" value=msg**
**> table.put in=None at="set_text" value=set_text** **table.put in=None at="set_text" value=set_text**
``` ```
Better still — call a named helper: Better still — call a named helper:
```markdown ```markdown
**> browser.set_text sel="#log" text=msg** **browser.set_text sel="#log" text=msg**
``` ```
### 3. Bad pattern (do not write) ### 3. Bad pattern (do not write)
```markdown ```markdown
*`ret` = > json.set map=None key="set_text" value=…* **`ret` = json.set map=None key="set_text" value=…**
*`ret` = > json.set map=ret key="canvas" value=…* **`ret` = json.set map=ret key="canvas" value=…**
*`cmds` = > json.append list=cmds item=c0* **`cmds` = json.append list=cmds item=c0**
``` ```
## Writing application `.mq.md` ## Writing application `.mq.md`
@@ -88,23 +88,31 @@ Better still — call a named helper:
3. `##` handlers: short prose OK; data as tables; return via `browser.*` / `web.*` / one `table.put`. 3. `##` handlers: short prose OK; data as tables; return via `browser.*` / `web.*` / one `table.put`.
4. Blank line between comment paragraphs and code. 4. Blank line between comment paragraphs and code.
5. Run `marqdo run path.mq.md` from repo root. 5. Run `marqdo run path.mq.md` from repo root.
6. **Calls in narrative:** prefer `**结果 = 某函数 名=`x`**` (no `>` on the RHS). Bracket form `礼貌 [问候] "x"` / `**出 = [put] …**` is fine when modifiers help. Use `> …` for standalone step lists. See `examples/code-as-docs/`.
7. **Do not use `##` inside `# main` for document sectioning** — those become nested functions. Use paragraphs / `---` breaks instead.
8. **Index:** prefer `[键](集合)` / `` [`名`](集合) `` over footnote `` m[^k] ``.
Browser client programs: prefer `import browser:lib/browser.mq.md` (no native plugin). Server sites: `ext/web` + GFM page/style tables. Browser client programs: prefer `import browser:lib/browser.mq.md` (no native plugin). Server sites: `ext/web` + GFM page/style tables.
## Developing libraries (`lib/*`, `ext/*`) ## Developing libraries (`lib/*`, `ext/*`)
Canonical thin-template + waves: [lib-code-as-docs.md](../../doc/design/lib-code-as-docs.md) · [roadmap/lib-ext-code-as-docs.md](../../doc/roadmap/lib-ext-code-as-docs.md).
### Goals ### Goals
- **Authors** see tables and short calls; **library** may hide `table.put` / host calls. - **Authors** see tables and short calls; **library** may hide `table.put` / host calls.
- One concern per helper; name the effect (`set_text`, `canvas`, …), do not expose bag surgery. - One concern per helper; name the effect (`set_text`, `canvas`, …), do not expose bag surgery.
- EN + ZH pair when shipping user-facing libs (`lib/browser.mq.md` ↔ `lib/浏览器.mq.md`, `ext/web` ↔ `ext/web/网页.mq.md`). - EN + ZH pair when shipping user-facing libs (`lib/browser.mq.md` ↔ `lib/浏览器.mq.md`, `ext/web` ↔ `ext/web/网页.mq.md`).
- `ext/**` never calls `host_*` — use plugins / public lib only (`doc/design/ext-agent.md`). - `ext/**` never calls `host_*` — use plugins / public lib only (`doc/design/ext-agent.md`).
- Collection get: **`[key](coll)`** (no new footnote indexes). Calls in examples may use `修饰 [fn] …` or classic `>` / bold.
### Library checklist ### Library checklist
- [ ] Purpose sentence + prose params + one example + short body
- [ ] Public examples use **tables + helpers**, not json glue - [ ] Public examples use **tables + helpers**, not json glue
- [ ] Index with `[k](c)`; foreach `- [item](coll)`
- [ ] Helpers documented with a one-line purpose above `##` - [ ] Helpers documented with a one-line purpose above `##`
- [ ] Defaults on `+` params; omit `None` fields in merged maps - [ ] Defaults on params; omit `None` fields in merged maps
- [ ] No `json.set` chains in new code — use `table.put` / `table.merge` / GFM - [ ] No `json.set` chains in new code — use `table.put` / `table.merge` / GFM
- [ ] `marqdo run` on a tiny demo under `examples/` or inline smoke - [ ] `marqdo run` on a tiny demo under `examples/` or inline smoke
+30 -14
View File
@@ -4,11 +4,13 @@ description: >-
Run a full Marqdo product release: detect latest version and ask the user for Run a full Marqdo product release: detect latest version and ask the user for
the next tag, update CHANGELOG/README/skills/public docs, bump Cargo versions, the next tag, update CHANGELOG/README/skills/public docs, bump Cargo versions,
sync VS Code extension on branch vscode-extension when needed, build or sync VS Code extension on branch vscode-extension when needed, build or
trigger install assets (CLI, stdlib, ext, public zip, VSIX, wasm notes), push trigger install assets (Windows CLI + **required Linux native/CLI zips**,
tag, publish GitHub Release with detailed notes, and recover from network stdlib, ext, public zip, VSIX), push via origin or
failures via proxy or HK SSH jump (scripts/push-via-hk-jump.py). Use when the https://proxy.cflmy.top/github.com/cflmy/marqdo.git, publish GitHub Release
user asks to release, cut a version, publish vX.Y.Z, ship a GitHub release, with detailed notes, and recover from network failures via that proxy or HK
发版, 发布新版本, or tag marqdo. SSH jump (scripts/push-via-hk-jump.py). Use when the user asks to release,
cut a version, publish vX.Y.Z, ship a GitHub release, 发版, 发布新版本, or tag
marqdo.
--- ---
# Marqdo release # Marqdo release
@@ -22,8 +24,9 @@ Canonical release playbook for **cflmy/marqdo**. Read this skill **before** tagg
3. **Never commit `vscode-extension/` on `main`** (gitignored). Extension source lives only on branch **`vscode-extension`**. See `doc/design/vscode-extension-commit.md`. 3. **Never commit `vscode-extension/` on `main`** (gitignored). Extension source lives only on branch **`vscode-extension`**. See `doc/design/vscode-extension-commit.md`.
4. **Do not release from a dirty tree** (except intentional release commits you create in this flow). 4. **Do not release from a dirty tree** (except intentional release commits you create in this flow).
5. **Tag format** is always `vX.Y.Z` matching root `Cargo.toml` `version = "X.Y.Z"`. 5. **Tag format** is always `vX.Y.Z` matching root `Cargo.toml` `version = "X.Y.Z"`.
6. Prefer **tag push → GitHub Actions** (`.github/workflows/release.yml`) for Windows CLI + VSIX + zips. Local packaging is fallback / verification. 6. Prefer **tag push → GitHub Actions** (`.github/workflows/release.yml`) for **both** Windows and **Linux** install assets. Local packaging is fallback / verification.
7. After network errors: apply [reference.md § Proxy](reference.md); retry; do not silently skip uploads. If GitHub stays unreachable but **HK jump** (`hk.cflmy.de`) works, use `scripts/push-via-hk-jump.py` (Paramiko CONNECT) — see reference § **HK SSH jump**. 7. After network errors: apply [reference.md § Proxy](reference.md). **First try** `https://proxy.cflmy.top/github.com/cflmy/marqdo.git` (this clone’s usual `origin`). Retry; do not silently skip uploads. If the reverse-proxy still drops long pushes, use **HK jump** (`hk.cflmy.de`) via `scripts/push-via-hk-jump.py` — see reference § **Proxy** / **HK SSH jump**.
8. **Do not ship a GitHub Release without the Linux extension/native zip.** Job `linux` must attach `marqdo-VER-native-x86_64-unknown-linux-gnu.zip` (and the Linux CLI bundle). Missing Linux packages = release incomplete.
## Defaults (after version is confirmed) ## Defaults (after version is confirmed)
@@ -106,7 +109,16 @@ release: vVER — <one-line highlight>
EOF EOF
``` ```
Push `main`: `git push origin main` (with proxy/`all` perms if needed; on persistent GitHub failure use [reference § HK SSH jump](reference.md)). Push `main` (this repo’s `origin` is usually the reverse proxy):
```bash
# origin typically: https://proxy.cflmy.top/github.com/cflmy/marqdo.git
git push origin main
# one-shot if origin still points at github.com:
git push https://proxy.cflmy.top/github.com/cflmy/marqdo.git HEAD:main
```
If that times out: [reference § HK SSH jump](reference.md).
## Phase 3 — VS Code / Cursor extension ## Phase 3 — VS Code / Cursor extension
@@ -127,15 +139,19 @@ git tag -a "TAG" -m "TAG"
git push origin "TAG" git push origin "TAG"
``` ```
This runs `.github/workflows/release.yml` (Windows): CLI exe/zip, stdlib zip, ext zip, source zip, public zip, VSIX. This runs `.github/workflows/release.yml`:
If tag push fails: [reference.md § Proxy](reference.md), retry once; then report. - **windows** — CLI exe/zip, stdlib zip, ext zip, source zip, public zip, VSIX, Windows native zip
- **linux** (`needs: windows`) — **required** Linux native plugins zip + Linux CLI bundle (`ext/` + `native/*.so`)
If tag push fails: [reference.md § Proxy](reference.md) (`proxy.cflmy.top` first), retry once; then HK jump.
## Phase 5 — Release notes & assets ## Phase 5 — Release notes & assets
1. Wait for Actions success: `gh run list --workflow=Release --limit 3` / open the run URL. 1. Wait for Actions success: `gh run list --workflow=Release --limit 3` / open the run URL. **Both** `windows` and `linux` jobs must be green.
2. Ensure GitHub Release for `TAG` exists with assets (workflow uses `softprops/action-gh-release`). 2. Ensure GitHub Release for `TAG` exists with assets (workflow uses `softprops/action-gh-release`).
3. **Rewrite release body** (workflow body is a stub) with **中英双语** — see [reference.md § Notes template](reference.md). `gh release edit TAG --notes-file …`. 3. Confirm Linux assets exist: `marqdo-VER-native-x86_64-unknown-linux-gnu.zip` and `marqdo-VER-x86_64-unknown-linux-gnu.zip`. If missing, do **not** call the release done — re-run / upload.
4. **Rewrite release body** (workflow body is a stub) with **中英双语** — see [reference.md § Notes template](reference.md). `gh release edit TAG --notes-file …`.
4. Include: Highlights, Breaking, Install (`ext add`, plugins build), Downloads table, WASM (`marqdo wasm build`), links to CHANGELOG/README, extension branch note. 4. Include: Highlights, Breaking, Install (`ext add`, plugins build), Downloads table, WASM (`marqdo wasm build`), links to CHANGELOG/README, extension branch note.
5. Optional Linux local extras (not required if CI green): `marqdo wasm build` smoke; document in notes that wasm is built from source via CLI. 5. Optional Linux local extras (not required if CI green): `marqdo wasm build` smoke; document in notes that wasm is built from source via CLI.
@@ -154,11 +170,11 @@ Local Windows fallback: `scripts/release-full.ps1 -Tag TAG -Upload` (see script
| Failure | Action | | Failure | Action |
|---------|--------| |---------|--------|
| `gh` / git TLS or Clash `7890` refused | Unset bad proxy; `required_permissions: ["all"]`; see [reference § Proxy](reference.md) | | `gh` / git TLS or Clash `7890` refused | Unset bad proxy; `required_permissions: ["all"]`; see [reference § Proxy](reference.md) |
| GitHub blocked / `proxy.cflmy.top` push timeout | **HK SSH jump**: `scripts/push-via-hk-jump.py` (ask user for HK password/key; never commit). See reference § **HK SSH jump** | | GitHub blocked | **`origin` via proxy.cflmy.top** (see below), then HK jump |
| Tag exists | Stop; ask user to bump or delete tag (no force on shared tags without explicit order) | | Tag exists | Stop; ask user to bump or delete tag (no force on shared tags without explicit order) |
| CI red | Fix on main, move tag only if user explicitly allows delete+re-push tag | | CI red | Fix on main, move tag only if user explicitly allows delete+re-push tag |
| VSIX missing | Fetch `vscode-extension`, build locally, `gh release upload TAG dist/*.vsix` | | VSIX missing | Fetch `vscode-extension`, build locally, `gh release upload TAG dist/*.vsix` |
| Partial assets | Re-run workflow or upload missing files only | | Linux native/CLI zip missing | Incomplete release — fix `linux` job or `gh release upload`; do not skip |
## Do not ## Do not
+45 -15
View File
@@ -25,21 +25,24 @@ gh release list --limit 3 2>/dev/null || true
## Asset matrix (CI tag `v*`) ## Asset matrix (CI tag `v*`)
Produced by `.github/workflows/release.yml` on **windows-latest**: Produced by `.github/workflows/release.yml` on **windows-latest** (`windows` job) and **ubuntu-latest** (`linux` job, **required**, `needs: windows`):
| Asset | Role | | Asset | Role | Job |
|-------|------| |-------|------|-----|
| `marqdo-VER-x86_64-pc-windows-msvc.exe` | CLI (stdlib embedded) | | `marqdo-VER-x86_64-pc-windows-msvc.exe` | CLI (stdlib embedded) | windows |
| `marqdo-VER-x86_64-pc-windows-msvc.zip` | `marqdo.exe` + `lib/` | | `marqdo-VER-x86_64-pc-windows-msvc.zip` | `marqdo.exe` + `lib/` + `ext/` + native DLL | windows |
| `marqdo-VER-stdlib.zip` | `lib/` only | | `marqdo-VER-stdlib.zip` | `lib/` only | windows |
| `marqdo-VER-ext.zip` | Official `ext/` L1 | | `marqdo-VER-ext.zip` | Official `ext/` L1 | windows |
| `marqdo-VER-native-x86_64-pc-windows-msvc.zip` | Prebuilt Windows plugins (`native/*.dll`) | | `marqdo-VER-native-x86_64-pc-windows-msvc.zip` | Prebuilt Windows plugins (`native/*.dll`) | windows |
| `marqdo-VER-native-x86_64-unknown-linux-gnu.zip` | Prebuilt Linux plugins (`native/lib*.so`) | | `marqdo-VER-native-x86_64-unknown-linux-gnu.zip` | Prebuilt Linux plugins (`native/lib*.so`) — **must ship** | linux |
| `marqdo-VER-source.zip` | `git archive` of tagged commit | | `marqdo-VER-x86_64-unknown-linux-gnu.zip` | Linux CLI + `lib/` + `ext/` + native `.so` — **must ship** | linux |
| `marqdo-VER.vsix` | VS Code / Cursor (from branch `vscode-extension`) | | `marqdo-VER-source.zip` | `git archive` of tagged commit | windows |
| `marqdo-VER-public.zip` | Static user docs (`marqdo view output public`) | | `marqdo-VER.vsix` | VS Code / Cursor (from branch `vscode-extension`) | windows |
| `marqdo-VER-public.zip` | Static user docs (`marqdo view output public`) | windows |
Not CI-uploaded (document in notes): Linux/macOS build from source; WASM via `marqdo wasm build` → `dist/wasm/`. Not CI-uploaded (document in notes): macOS build from source; WASM via `marqdo wasm build` → `dist/wasm/`.
A release **without** the Linux native zip is incomplete (`marqdo ext add` on Linux cannot download prebuilts).
## Doc sync checklist (Phase 2 detail) ## Doc sync checklist (Phase 2 detail)
@@ -189,7 +192,9 @@ marqdo wasm build
| Asset | 内容 / Contents | | Asset | 内容 / Contents |
|-------|-----------------| |-------|-----------------|
| `marqdo-*-windows-msvc.exe` | CLI(内置 stdlib) | | `marqdo-*-windows-msvc.exe` | CLI(内置 stdlib) |
| `marqdo-*-windows-msvc.zip` | exe + `lib/` | | `marqdo-*-windows-msvc.zip` | exe + `lib/` + `ext/`(含 native) |
| `marqdo-*-unknown-linux-gnu.zip` | Linux CLI + `lib/` + `ext/` + `.so` |
| `marqdo-*-native-*.zip` | 预编译 `web`/`agent`/`quantum`/`linalg`(Win + **Linux 必出**) |
| `marqdo-*-stdlib.zip` | 仅 `lib/` | | `marqdo-*-stdlib.zip` | 仅 `lib/` |
| `marqdo-*-ext.zip` | 官方 `ext/` | | `marqdo-*-ext.zip` | 官方 `ext/` |
| `marqdo-*-source.zip` | 源码快照 | | `marqdo-*-source.zip` | 源码快照 |
@@ -206,7 +211,32 @@ marqdo wasm build
## Proxy & auth (network recovery) ## Proxy & auth (network recovery)
Symptoms seen in this project: broken local Clash on `127.0.0.1:7890`, flaky `proxy.cflmy.top` HTTPS (short GET OK, long `git push` / connect timeouts), TLS failures, `gh` needing token, Cursor agent sandbox with only `lo`. Symptoms seen in this project: broken local Clash on `127.0.0.1:7890`, flaky GitHub TLS, `gh` needing token, Cursor agent sandbox with only `lo`.
### `proxy.cflmy.top` (try this first)
This machine’s `origin` is typically:
```
https://proxy.cflmy.top/github.com/cflmy/marqdo.git
```
Push / fetch / tag through that remote (HTTPS reverse proxy to GitHub):
```bash
git remote -v # confirm origin uses proxy.cflmy.top
git push origin main
git push origin vVER
git push origin vscode-extension
# one-shot if origin still points at github.com:
git push https://proxy.cflmy.top/github.com/cflmy/marqdo.git HEAD:main
git push https://proxy.cflmy.top/github.com/cflmy/marqdo.git vVER
```
Short GETs via the proxy often work; **long `git push` may still time out**. If push hangs or drops, skip Clash retries and go to **HK SSH jump** below.
`gh` against `api.github.com` may still need a direct path or HK jump (the reverse proxy is for `github.com` git, not always the API).
### Diagnose ### Diagnose
+29 -26
View File
@@ -15,7 +15,7 @@ description: >-
Marqdo = **Markdown markers as syntax**. A `.mq.md` file is both documentation and a runnable program. Read this skill **before** inventing syntax from Markdown habits or Python. Marqdo = **Markdown markers as syntax**. A `.mq.md` file is both documentation and a runnable program. Read this skill **before** inventing syntax from Markdown habits or Python.
Canonical design (repo): `doc/design/markdown-mapping.md`, `doc/design/keywords.md`. Deeper tables: [reference.md](reference.md). Copy-paste patterns: [examples.md](examples.md). Canonical design (repo): [`markdown-mapping-v0.3.md`](../../doc/design/markdown-mapping-v0.3.md) (**v0.3 · runtime**), `doc/design/keywords.md`. Legacy v0.2 notes: `doc/design/markdown-mapping.md` (historical). Deeper tables: [reference.md](reference.md). Copy-paste patterns: [examples.md](examples.md).
**Authoring / library craft** (GFM-first, no json glue, how to develop Marqdo): use **[marqdo-dev](../marqdo-dev/SKILL.md)** whenever writing or refactoring `.mq.md`, `lib/*`, or `ext/*`. **Authoring / library craft** (GFM-first, no json glue, how to develop Marqdo): use **[marqdo-dev](../marqdo-dev/SKILL.md)** whenever writing or refactoring `.mq.md`, `lib/*`, or `ext/*`.
@@ -24,19 +24,19 @@ Canonical design (repo): `doc/design/markdown-mapping.md`, `doc/design/keywords.
## Hard rules (do not violate) ## Hard rules (do not violate)
1. **File suffix** must be `.mq.md` (never plain `.md` for executable sources). 1. **File suffix** must be `.mq.md` (never plain `.md` for executable sources).
2. **Output is not `**bold**`.** Print with `> print text=…` (or `> 打印 内容=…`). Bold `**…**` is **return value only**. 2. **`**…**` = code** (assign / call). **`*…*` = return value**. Output is **not** either marker — use `> print text=…` / `**print text="…"**` / `> 打印 内容=…`.
3. **Prose vs code:** after a blank line, an unmarked first line starts a **comment paragraph**; every following non-blank line stays comment until the next blank line. Put a **blank line** between narration and executable lines. 3. **Prose:** unmarked narrative may contain `` `名` `` (declare/ref), inline `**code**`, and `*return*`. Soft Markdown emphasis that is **not** code-shaped (`**说明**`, mid-line `*only*`) is ignored — see [code-as-docs-gaps.md](../../doc/design/code-as-docs-gaps.md). Dead `` `名` `` (never read) is OK and does not become a param.
4. **Do not invent keywords** `if` / `else` / `while` / `for` / `def` / `return`. Control flow is Markdown: **`+` params** (under heading), **`1.` `2.` … branches**, **`-` loops**, arm `N. *` = else, `#` = **object/type**, `##`+ = **function/method**, `**…**` = return. 4. **Do not invent keywords** `if` / `else` / `while` / `for` / `def` / `return`. Control flow is Markdown: **`1.` `2.` … branches**, **`-` loops**, arm `N. *` = else, `#` = **object/type**, `##`+ = **function/method**. Params: prefer prose `` `名` `` / `` `名`=默认 `` (inferred); `` + `名` `` still accepted.
5. **Identifiers use backticks** — params `` + `name` ``. **Exemptions:** foreach `` - [item](coll) ``; footnote `` name[^key] ``; **inside italic `*…*` / bold `**…**`**, bare ids are **variables** (Python-style unified namespace) and method-call receivers are bare too. **Drop the backticks on value-expression variable names and method receivers inside `*…*` / `**…**`** — they are redundant once the `*…*`/`**…**` markers mark the segment as code: `*分类 = 分类[^苹果]*`, `**n * 2**`, `*p = > page.主体装配 组件=home*`. **Text literals must be quoted**: `*a = > text.split value=src sep=","*`. Backticks **still required** where a bare word is *not* a variable in **standalone `>` calls** (bare = text there): `` > str `n` ``, `` > `obj`.method ``. **No trailing space** inside `*…*` / `**…**` wrapped code: the closing marker must touch the last token directly (`*a = 1*`, `**n**`), never `` *a = 1 * ``. 5. **Identifiers:** `` `名` `` in prose; inside `*…*` / `**…**`, bare ids are **variables**. **Text literals must be quoted** in bold/italic: `**print text="hi"**`. Standalone `>` calls: bare words = text; vars need ticks: `` > str `n` ``.
6. **Structure lines are not wrapped in italics.** `#` `>` `+` `-` `|` lines stand alone; use `*…*` only for general statements (bindings / expressions). 6. **Structure lines** (`#` `>` `+` `-` `|` `1.`) need not be wrapped in bold.
7. **Paths:** In bare *expressions* `/` is division. In **call args / param defaults / table cells**, unspaced `a/b` and quoted `".marqdo/agent-kb"` are path text — no `json.parse` needed. Numeric ratios that must stay text use quotes (`"1/5"`, `"16/9"`); bare `1/5` is division. 7. **Paths:** In bare expressions `/` is division. In call args / defaults / table cells, unspaced `a/b` and quoted paths are text.
8. Prefer ending side-effect-only function bodies with a lone `---` or `***` line (or `****` empty return) so later siblings are not swallowed. 8. Prefer ending side-effect-only bodies with `*None*` / `*无*` / whole-line `**` / `****` when the next lines must belong to an outer function. Lone `---` / `***` are Markdown thematic breaks (skipped everywhere), not function end.
9. **`ext/**` never calls `host_*`.** Agent/OKF helpers are plugin names (`agent_kb_*`, …) after `plugin.load`. Do **not** add agent/OKF domain code to `src/host/` (core bloat). See `doc/design/ext-agent.md` §4. 9. **`ext/**` never calls `host_*`.** Agent/OKF helpers are plugin names (`agent_kb_*`, …) after `plugin.load`. Do **not** add agent/OKF domain code to `src/host/` (core bloat). See `doc/design/ext-agent.md` §4.
10. **Browser (route C/D/E/F):** client logic is Marqdo on WASM; official bridge is host glue and **may** implement lists, routing, storage, WebSocket, canvas, file read, observers — authors **must not hand-write business JS**. Use `web.client_embed` / `data-mq-source-url` auto-mount. Client effects: prefer **GFM tables + `lib/browser`** ([marqdo-dev](../marqdo-dev/SKILL.md)). 10. **Browser (route C/D/E/F):** client logic is Marqdo on WASM; official bridge is host glue and **may** implement lists, routing, storage, WebSocket, canvas, file read, observers — authors **must not hand-write business JS**. Use `web.client_embed` / `data-mq-source-url` auto-mount. Client effects: prefer **GFM tables + `lib/browser`** ([marqdo-dev](../marqdo-dev/SKILL.md)).
11. **Code-as-documentation / no bag glue:** Prefer **GFM tables** for maps, lists, wire, commands. Prefer **`table.put` / named helpers** over `json.set` / `json.append` chains. `lib/json` is for parse/stringify/quote only — not a dict builder. Unreadable json pipelines are a style bug. 11. **Code-as-documentation / no bag glue:** Prefer **GFM tables** for maps, lists, wire, commands. Prefer **`table.put` / named helpers** over `json.set` / `json.append` chains. `lib/json` is for parse/stringify/quote only — not a dict builder. Unreadable json pipelines are a style bug.
12. **Bracket-marked calls:** Function name may be marked with `[函数名]`; bare words before `[` are boolean modifiers (`礼貌 [问候] x` → `礼貌=True`). `]` immediately followed by `(` is **index** `[key](coll)`, not a call. Prefer `[k](c)` over footnote index in new code. See [bracket-call-modifiers.md](../../doc/design/bracket-call-modifiers.md).
## Markup → meaning (v0.3)
## Markup → meaning (v0.2)
| Marker | Meaning | | Marker | Meaning |
|--------|---------| |--------|---------|
@@ -47,15 +47,17 @@ Canonical design (repo): `doc/design/markdown-mapping.md`, `doc/design/keywords.
| `- …` inside body | Loop (`while` or `` [item](coll) `` / `` [`item`](`coll`) ``) | | `- …` inside body | Loop (`while` or `` [item](coll) `` / `` [`item`](`coll`) ``) |
| Line `N. *` | Else arm | | Line `N. *` | Else arm |
| `> fn args` | Call (named `k=v` or positional) | | `> fn args` | Call (named `k=v` or positional) |
| `修饰 [fn] args` | Bracket-marked call; leading words → `名=True` |
| `` > `obj`.method args `` | Method call (`obj` must be a map with `_type`) | | `` > `obj`.method args `` | Method call (`obj` must be a map with `_type`) |
| Frontmatter `import bind:path.mq.md` / `导入` | Import file (bind library name) | | Frontmatter `import bind:path.mq.md` / `导入` | Import file (bind library name) |
| Frontmatter `import bind:lib.member` / `导入` | Short name for a library member (same keyword; no separate `use`) | | Frontmatter `import bind:lib.member` / `导入` | Short name for a library member (same keyword; no separate `use`) |
| `> lib.member …` / `> lib.Type.member …` | Call via bare dotted path (instance methods need `` `var`.m ``) | | `> lib.member …` / `> lib.Type.member …` | Call via bare dotted path (instance methods need `` `var`.m ``) |
| `*…*` | Statement (bind / expr) — closing `*` touches last token, **no trailing space**; bare ids are variables | | `**…**` | **Code** (assign / call) — closing `**` touches last token; bare ids are variables; quote text literals |
| `**…**` | Return value — closing `**` touches last token, **no trailing space**; bare ids are variables | | `*…*` | **Return value** — closing `*` touches last token; bare ids are variables |
| `****` or `**` + spaces + `**` | Return `None` and end function body | | `****` / whole-line `**` / `*None*` | Return `None` and end function body |
| Lone `---` / `***` in function body | End function body (no value) | | Lone `---` / `***` | Markdown thematic break (skip; not function end) |
| GFM table after empty RHS bind | Collection (1-col list / ≥2-col map / `@`·`行`·`row` → list of maps); `` `x`[^1] `` / `` `m`[^key] `` | | GFM table after empty RHS bind | Collection; get with `[key](coll)` (preferred) or legacy `` `m`[^key] `` |
| `- [item](coll)` | Foreach (unchanged) |
| `` ```lang `` | Foreign code block (via `lib/foreign`) | | `` ```lang `` | Foreign code block (via `lib/foreign`) |
| `` `"text"` `` | Quoted string (`\n` `\t` `\\` `\"`; `` `var` `` inside); bare tokens unescaped | | `` `"text"` `` | Quoted string (`\n` `\t` `\\` `\"`; `` `var` `` inside); bare tokens unescaped |
| Unmarked prose | Comment | | Unmarked prose | Comment |
@@ -90,27 +92,28 @@ Chinese builtins (same functions, no import):
> print text=Hello, `who`! > print text=Hello, `who`!
--- *None*
``` ```
- Call: `> name key=value` or `> name value`. - Call: `> name key=value` or `> name value`.
- Nested helpers use deeper `#` (`##`, `###`, …). - Nested helpers use deeper `#` (`##`, `###`, …).
- After a helper with only side effects, end with `---` / `***`. - After a helper with only side effects, end with `*None*` / whole-line `**` / `****` when later lines must stay in the outer function. Lone `---` is only a thematic break (skipped).
- In bold assigns, prefer bare calls: `**摘要 = 结账摘要 …**` (omit `>`).
## Statements, returns, branches ## Statements, returns, branches
```markdown ```markdown
*x = 1* **x = 1**
*y = x + 2* **y = x + 2**
## add_one ## add_one
+ `n` + `n`
**n + 1** *n + 1*
``` ```
```markdown ```markdown
*n = 0* **n = 0**
1. `n` > 0 1. `n` > 0
> print text=positive > print text=positive
@@ -133,9 +136,9 @@ import clock:lib/time.mq.md
# main # main
*xs = > text.split value="a,b,c" sep=","* **xs = > text.str_split s="a,b,c" sep=","**
> print text=`xs` > print text=`xs`
*t = > clock.now_unix* **t = > clock.now_unix**
``` ```
- Import **English** or **Chinese** library file; call that file’s API names via `lib.member` (do not mix languages). - Import **English** or **Chinese** library file; call that file’s API names via `lib.member` (do not mix languages).
@@ -196,7 +199,7 @@ data/ # sqlite runtime (gitignore)
**Typical flow:** `db.init` → `page.compose_*` → `app` + `static` / `listen`. Client: `marqdo wasm build -o static` + `web.client_embed source="/static/client.mq.md"` — **no author JS**; bridge may implement rich host effects ([browser-wasm-e.md](../../doc/roadmap/browser-wasm-e.md) · [browser-app](../../examples/browser-app/)). **Typical flow:** `db.init` → `page.compose_*` → `app` + `static` / `listen`. Client: `marqdo wasm build -o static` + `web.client_embed source="/static/client.mq.md"` — **no author JS**; bridge may implement rich host effects ([browser-wasm-e.md](../../doc/roadmap/browser-wasm-e.md) · [browser-app](../../examples/browser-app/)).
**Shipped surface (W0–W7 + P3 + W8 + route D mount):** middleware + JSON API (`app.configure`); transactions, pagination, FTS search (`db.migrate`, `db.fts`, `db.search`); security (argon2, CSRF, SQLite sessions, login rate limit); SEO / RSS / Markdown (`page.meta`, `route_rss`, `lib/net.markdown_parse`); upload / download / gallery; sitemap / robots / error pages / redirects; RBAC (`app.gate`, user `role`); audit timestamps + FK in `db.init`; ETag on downloads; **W8** site icons (`app.icons` → `/favicon.ico`), head resource tables (`page.head`), image assembly (`make_images` / `page.images`); **D** `client_embed` auto-mount + DOM effect helpers (`text_patch` / `dom_patch`). **Shipped surface (W0–W7 + P3 + W8 + route D mount):** middleware + JSON API (`app.configure`); transactions, pagination, FTS search (`db.migrate`, `db.fts`, `db.search`); security (argon2, CSRF, SQLite sessions, login rate limit); SEO / RSS / Markdown (`page.meta`, `route_rss`, `lib/net.markdown_parse`); upload / download / gallery; sitemap / robots / error pages / redirects; RBAC (`app.gate`, user `role`); audit timestamps + FK in `db.init`; ETag on downloads; **W8** site icons (`app.icons` → `/favicon.ico`), head resource tables (`page.head`), image assembly (`make_images` / `page.images`); **表驱动引言** `page.compose_intro` / `页面.引言装配`(属性/值/样式表 → `.main-intro`,避免手写 HTML 字符串);**D** `client_embed` auto-mount + DOM effect helpers (`text_patch` / `dom_patch`).
Design: [ext-web.md](../../doc/design/ext-web.md) · assets: [web-assets-and-images.md](../../doc/design/web-assets-and-images.md) · capability matrix: [web-net-capabilities.md](../../doc/design/web-net-capabilities.md) · example: [examples/marqdo-blog/](../../examples/marqdo-blog/) · client: [examples/web-client-site/](../../examples/web-client-site/). Design: [ext-web.md](../../doc/design/ext-web.md) · assets: [web-assets-and-images.md](../../doc/design/web-assets-and-images.md) · capability matrix: [web-net-capabilities.md](../../doc/design/web-net-capabilities.md) · example: [examples/marqdo-blog/](../../examples/marqdo-blog/) · client: [examples/web-client-site/](../../examples/web-client-site/).
@@ -257,7 +260,7 @@ Examples: [linalg-svd](../../examples/linalg-svd/) · [linalg-least-squares](../
| `* > print text=hi *` | `> print text=hi` | | `* > print text=hi *` | `> print text=hi` |
| `` *`a` = 1 * `` (trailing space + backticks) | `*a = 1*` — bare bind, no trailing space before `*` / `**` | | `` *`a` = 1 * `` (trailing space + backticks) | `*a = 1*` — bare bind, no trailing space before `*` / `**` |
| `*xs = > text.split value=a,b sep=,*` (bare text args) | `*xs = > text.split value="a,b" sep=","*` — quote text literals; bare words are variables | | `*xs = > text.split value=a,b sep=,*` (bare text args) | `*xs = > text.split value="a,b" sep=","*` — quote text literals; bare words are variables |
| Forgetting `---` after nested `##` helper | Add `---` / `***` / `****` | | Forgetting empty return after nested `##` helper when outer continues | Add `*None*` / `**` / `****` (not `---`) |
| Import `lib/text` then call bare `split` | `> text.split …` (qualified) | | Import `lib/text` then call bare `split` | `> text.split …` (qualified) |
| Import `lib/text` then call `拆分` | Match file language (`text.split`, not 文本) | | Import `lib/text` then call `拆分` | Match file language (`text.split`, not 文本) |
| `json.set` / `json.append` to build maps or lists | GFM tables; sparse `table.put`; named helpers (`browser.*`, `web.*`) | | `json.set` / `json.append` to build maps or lists | GFM tables; sparse `table.put`; named helpers (`browser.*`, `web.*`) |
@@ -277,7 +280,7 @@ Examples: [linalg-svd](../../examples/linalg-svd/) · [linalg-least-squares](../
- [ ] Print via `print` / `打印`, not bold - [ ] Print via `print` / `打印`, not bold
- [ ] Blank lines separate comment paragraphs from code - [ ] Blank lines separate comment paragraphs from code
- [ ] `# main` exists when the file is an entry program - [ ] `# main` exists when the file is an entry program
- [ ] Nested functions ended with `---` / `***` / `****` when needed - [ ] Nested side-effect helpers ended with `*None*` / `**` / `****` when the outer function continues
- [ ] Imports and call names share the same language file - [ ] Imports and call names share the same language file
- [ ] Data shaped as **GFM tables** (or short helpers) — no `json.set` / `json.append` glue - [ ] Data shaped as **GFM tables** (or short helpers) — no `json.set` / `json.append` glue
- [ ] Web sites: tables + web classes only (no JSON glue); `data/` gitignored - [ ] Web sites: tables + web classes only (no JSON glue); `data/` gitignored
+94 -64
View File
@@ -1,5 +1,7 @@
# Marqdo examples (AI) # Marqdo examples (AI)
v0.3: `**…**` = code (assign / call); `*…*` = return. Prefer `[key](coll)` over footnote get. Bracket calls: `礼貌 [问候] x`.
## 1. Hello (English) ## 1. Hello (English)
```markdown ```markdown
@@ -16,7 +18,7 @@
> 打印 内容=你好,世界! > 打印 内容=你好,世界!
``` ```
## 3. Function + named call + body end ## 3. Function + named call + empty return
```markdown ```markdown
# main # main
@@ -30,22 +32,24 @@ Greeting via a nested function:
> print text=Hello, `who`! > print text=Hello, `who`!
--- *None*
``` ```
Or end with a whole-line empty bold return: `**` / `****`. Lone `---` is a thematic break (skipped), not function end.
## 4. Bindings and return ## 4. Bindings and return
```markdown ```markdown
# main # main
*a = 2* **a = 2**
*b = > add_one n=`a`* **b = add_one n=`a`**
> print text=`b` **打印 内容=`b`**
## add_one ## add_one
+ `n` + `n`
**n + 1** *n + 1*
``` ```
## 5. Branch with else ## 5. Branch with else
@@ -53,7 +57,7 @@ Greeting via a nested function:
```markdown ```markdown
# main # main
*n = 0* **n = 0**
1. `n` > 0 1. `n` > 0
> print text=positive > print text=positive
@@ -78,8 +82,7 @@ Greeting via a nested function:
> print text=`果` > print text=`果`
``` ```
## 6b. Map table + link-index get
## 6b. Map table + footnote get
```markdown ```markdown
# main # main
@@ -90,13 +93,20 @@ Greeting via a nested function:
|------|------| |------|------|
| 水果 | 蔬菜 | | 水果 | 蔬菜 |
*种 = 分类[^苹果]* **种 = [苹果](分类)**
> print text=`种` **打印 内容=`种`**
*第一 = 篮子[^1]* `篮子` =
| 果 |
|----|
| 苹果 |
**第一 = [1](篮子)**
**打印 内容=`第一`**
``` ```
One column → list; ≥2 columns + one data row → map; ≥2 columns + many rows → map of lists. Data cells are expressions (same as call-arg values): bare words, numbers, `` `var` ``, quoted strings; URLs and `gpt-4o-mini` stay text via path/hyphen folding. Footnotes: lists use 1-based digit indices; maps use key text (including digit keys like `[^00]`). Foreach on a map walks **keys**. One column → list; ≥2 columns + one data row → map; ≥2 columns + many rows → map of lists. Prefer `[key](coll)` (lists are 1-based). Legacy `` coll[^key] `` still parses. Foreach on a map walks **keys**.
Row-oriented records (SQL-like): first header `@` / `行` / `row` → list of maps (marker column excluded): Row-oriented records (SQL-like): first header `@` / `行` / `row` → list of maps (marker column excluded):
@@ -107,10 +117,27 @@ Row-oriented records (SQL-like): first header `@` / `行` / `row` → list of ma
|----|------|------| |----|------|------|
| 1 | 苹果 | 2 | | 1 | 苹果 | 2 |
*名 = 订单[^1][^品名]* **名 = [品名]([1](订单))**
``` ```
## 6c. Browser effects — tables + lib/browser (not json.set) ## 6c. Bracket-marked call + modifiers
```markdown
# main
**打印 内容=(礼貌 [问候] "Marqdo")**
## 问候
+ `谁`
+ `礼貌`=False
**出 = `礼貌` + ", " + `谁` + "!"**
*出*
```
`礼貌 [问候] …` → `礼貌=True`. `]` immediately followed by `(` is index, not a call.
## 6d. Browser effects — tables + lib/browser (not json.set)
```markdown ```markdown
--- ---
@@ -128,8 +155,8 @@ import browser:lib/browser.mq.md
**`wire`** **`wire`**
## bump ## bump
*`count` = count + 1* **count = count + 1**
*`label` = > str count* **label = str count**
**> browser.set_text sel="#count" text=label** **> browser.set_text sel="#count" text=label**
``` ```
@@ -145,8 +172,8 @@ import text:lib/text.mq.md
# main # main
*parts = > split value=a,b,c sep=,* **parts = [text.str_split] s="a,b,c" sep=","**
> print text=`parts` **打印 内容=`parts`**
``` ```
## 7b. Mid M1 — regex + encoding (no plugin) ## 7b. Mid M1 — regex + encoding (no plugin)
@@ -159,10 +186,10 @@ import enc:lib/encoding.mq.md
# main # main
*`ok` = > re.is_match text="a@b.c" pattern="@"* **`ok` = [re.is_match] text="a@b.c" pattern="@"**
*`b64` = > enc.base64_encode text="hi"* **`b64` = [enc.base64_encode] text="hi"**
> print text=`ok` **打印 内容=`ok`**
> print text=`b64` **打印 内容=`b64`**
``` ```
## 7c. Mid M6 — log + uuid ## 7c. Mid M6 — log + uuid
@@ -178,8 +205,8 @@ import uuid:lib/uuid.mq.md
> log.info text="start" > log.info text="start"
> log.set_level level="debug" > log.set_level level="debug"
> log.debug text="detail" > log.debug text="detail"
*id = > uuid.v4* **id = [uuid.v4]**
> print text=`id` **打印 内容=`id`**
``` ```
## 8. Comment paragraphs (blank-line rule) ## 8. Comment paragraphs (blank-line rule)
@@ -188,7 +215,7 @@ import uuid:lib/uuid.mq.md
# main # main
This whole paragraph is a comment, including lines that look like code: This whole paragraph is a comment, including lines that look like code:
*not_executed = 1* **not_executed = 1**
> print text=also still comment > print text=also still comment
After a blank line, code runs: After a blank line, code runs:
@@ -206,13 +233,13 @@ import math:lib/math.mq.md
# main # main
*t = > num value=3.5* **t = > num value=3.5**
> print text=`t` **打印 内容=`t`**
``` ```
## 10. Object handle + method ## 10. Object handle + method
See `tests/structure/object-handle.mq.md` and `ext/llm.mq.md`: `# Type` constructs a map with `_type`; methods use `` > `obj`.method `` and read `self` / `自`. See `tests/structure/object-handle.mq.md` and `ext/ai/llm.mq.md`: `# Type` constructs a map with `_type`; methods use `` > `obj`.method `` and read `self` / `自`.
## 10b. Object inheritance ## 10b. Object inheritance
@@ -222,16 +249,16 @@ See `tests/structure/object-handle.mq.md` and `ext/llm.mq.md`: `# Type` construc
## hello ## hello
+ `who` + `who`
*msg = "Hello, `who`!"* **msg = "Hello, `who`!"**
**msg** *msg*
# Loud = > Greeter # Loud = > Greeter
## hello ## hello
+ `who` + `who`
*msg = "HELLO, `who`!"* **msg = "HELLO, `who`!"**
**msg** *msg*
``` ```
`_type` stays the most specific name (`Loud`). Methods walk the base chain; same-name `##` on the child overrides. **No implicit super** — if the child needs parent fields, call the parent explicitly: `_type` stays the most specific name (`Loud`). Methods walk the base chain; same-name `##` on the child overrides. **No implicit super** — if the child needs parent fields, call the parent explicitly:
@@ -240,9 +267,9 @@ See `tests/structure/object-handle.mq.md` and `ext/llm.mq.md`: `# Type` construc
# Child = > Parent # Child = > Parent
+ `name` + `name`
*self = > Parent name=`name`* **self = > Parent name=`name`**
*self = > json.set map=`self` key=extra value=1* **self = [table.put] in=`self` at="extra" value=1**
**self** *self*
``` ```
## 11. Agent layout (ABI) ## 11. Agent layout (ABI)
@@ -256,9 +283,9 @@ import agent:ext/agent.mq.md
> load_native > load_native
*ws = > agent* **ws = > agent**
*n = > `ws`.ensure_layout* **n = > `ws`.ensure_layout**
> print text=`n` **打印 内容=`n`**
``` ```
Requires `MARQDO_AGENT_PLUGIN` pointing at the built `agent` shared library (see `doc/design/ext-agent.md`). Requires `MARQDO_AGENT_PLUGIN` pointing at the built `agent` shared library (see `doc/design/ext-agent.md`).
@@ -266,14 +293,14 @@ Requires `MARQDO_AGENT_PLUGIN` pointing at the built `agent` shared library (see
## 12. What not to emit ## 12. What not to emit
```markdown ```markdown
# BAD — bold is return, not print # BAD — bare bold that is not code-shaped (decorative OK); do not use bold/italic as print
**Hello** **Hello**
# BAD — Python control keywords # BAD — Python control keywords
if x > 0: if x > 0:
print(x) print(x)
# BAD — wrapping a call in italics # BAD — wrapping a call in italics as if it were a statement
*> print text=hi* *> print text=hi*
# BAD — old branch syntax (removed) # BAD — old branch syntax (removed)
@@ -290,6 +317,10 @@ if x > 0:
> print text=y-pos > print text=y-pos
2. * 2. *
> print text=y-other > print text=y-other
# GOOD — print / return
**打印 内容="hi"**
*n + 1*
``` ```
## 13. Dynamic site (ext/web, minimal) ## 13. Dynamic site (ext/web, minimal)
@@ -316,14 +347,14 @@ import db:db/index.mq.md
| title | posts.title | | | title | posts.title | |
| body | posts.summary | | | body | posts.summary | |
*store = > db.open* **store = > db.open**
*css = "body{font-family:sans-serif}"* **css = "body{font-family:sans-serif}"**
*page = > web.page title="Hello"* **page = > web.page title="Hello"**
*page = > page.compose_components components=`shell`* **page = > page.compose_components components=`shell`**
*page = > page.compose_main main=`main`* **page = > page.compose_main main=`main`**
*page = > page.css css=`css`* **page = > page.css css=`css`**
*app = > web.app page=`page` port=8080* **app = > web.app page=`page` port=8080**
*app = > app.static prefix="/static" dir="static"* **app = > app.static prefix="/static" dir="static"**
> listen app=`app` > listen app=`app`
``` ```
@@ -347,13 +378,13 @@ import quantum:ext/quantum/quantum.mq.md
| 1 | H | 0 | | 1 | H | 0 |
| 2 | CX | 0,1 | | 2 | CX | 0,1 |
*qc = > quantum.circuit qubits=2 steps=`steps`* **qc = > quantum.circuit qubits=2 steps=`steps`**
*rho = > `qc`.density* **rho = > `qc`.density**
*red = > `rho`.partial_trace keep=0* **red = > `rho`.partial_trace keep=0**
*sch = > `qc`.schmidt cut=1* **sch = > `qc`.schmidt cut=1**
*_ = > `qc`.draw kind="circuit" theme="dark"* **_ = > `qc`.draw kind="circuit" theme="dark"**
*_ = > `qc`.draw kind="hinton"* **_ = > `qc`.draw kind="hinton"**
> print text=`red` **打印 内容=`red`**
``` ```
- Full lab: `examples/quantum-entanglement/`. Bell-only: `examples/quantum-bell/`. - Full lab: `examples/quantum-entanglement/`. Bell-only: `examples/quantum-bell/`.
@@ -369,19 +400,18 @@ import la:ext/linalg/linalg.mq.md
# main # main
*`A` = > la.symbol name="A" rows=2 cols=2* **`A` = > la.symbol name="A" rows=2 cols=2**
*`B` = > la.symbol name="B" rows=2 cols=2* **`B` = > la.symbol name="B" rows=2 cols=2**
*`C` = `A` + `B`* **`C` = `A` + `B`**
*`P` = `A` * `B`* **`P` = `A` * `B`**
*`s` = > `P`.T.simplify* <!-- prefer: *`Pt` = > `P`.T* then simplify -->
``` ```
Prefer: Prefer:
```markdown ```markdown
*`env` = > la.declare table=`shapes`* **`env` = > la.declare table=`shapes`**
*`P` = env[^A] * env[^B]* **`P` = [A](env) * [B](env)**
*`t` = > `P`.T_ascii* **`t` = > `P`.T_ascii**
``` ```
- Infix `+` / `-` / `*`;`ascii` / `T_ascii` 默认化简(`raw=True` 可关)。 - Infix `+` / `-` / `*`;`ascii` / `T_ascii` 默认化简(`raw=True` 可关)。
+3 -2
View File
@@ -18,7 +18,7 @@ marqdo ext remove llm|agent|web|quantum|linalg
Diagnostics look like `path:line:col: message` (1-based line/col). Diagnostics look like `path:line:col: message` (1-based line/col).
**v0.2 surface:** parameters `` + `name` ``; branches `` 1. `cond` `` / `` 2. * `` (same-indent restart at `1.` = **new** branch statement); loops `` - [item](coll) `` or `` - [`item`](`coll`) ``; identifiers in backticks (foreach header may omit ticks). See `doc/design/markdown-mapping.md`. **v0.3 surface:** `**…**` = code; `*…*` = return; parameters `` + `name` `` (or prose-inferred); branches `` 1. `cond` `` / `` 2. * `` (same-indent restart at `1.` = **new** branch statement); loops `` - [item](coll) ``; get `` [key](coll) ``; bracket calls `` mod [fn] args ``. See `doc/design/markdown-mapping-v0.3.md`.
Stdlib search order for `lib/…` imports: `MARQDO_LIB`, `./lib`, directory of the `marqdo` executable (and a few parents). Prefer the **bundle zip** (`marqdo.exe` + `lib/`) over a bare exe. Stdlib search order for `lib/…` imports: `MARQDO_LIB`, `./lib`, directory of the `marqdo` executable (and a few parents). Prefer the **bundle zip** (`marqdo.exe` + `lib/`) over a bare exe.
@@ -183,7 +183,8 @@ See `doc/design/call-arguments.md`.
| Doc | Topic | | Doc | Topic |
|-----|--------| |-----|--------|
| `doc/design/markdown-mapping.md` | Syntax constitution | | `doc/design/markdown-mapping-v0.3.md` | Syntax constitution (runtime) |
| `doc/design/markdown-mapping.md` | Legacy v0.2 notes |
| `doc/design/objects.md` | `#` objects / `##` methods | | `doc/design/objects.md` | `#` objects / `##` methods |
| `doc/design/keywords.md` | Builtins / keywords | | `doc/design/keywords.md` | Builtins / keywords |
| `doc/design/return-hr-and-code-surface.md` | Function end / surfaces | | `doc/design/return-hr-and-code-surface.md` | Function end / surfaces |
+42 -14
View File
@@ -124,10 +124,11 @@ jobs:
## Marqdo ${{ github.ref_name }} ## Marqdo ${{ github.ref_name }}
### 亮点 / Highlights ### 亮点 / Highlights
- **Go libweb 默认(W-G0–W-G14)**:网页原生插件 Go 重写;anlian-mq 验收;Release 含预编译 web.dll/libweb.so - **v1.0.2**:表驱动页面引言 `compose_intro` / `引言装配`;web-site Demo 与后台门禁加固
- **Go libweb default (W-G0–W-G14)**: web plugin rewritten in Go; anlian-mq acceptance; prebuilt natives in Release - **v1.0.2**: table-bound page intro (`compose_intro`); web-site demo + desk auth polish
- **GAP-11/12**:表单插槽 · `MARQDO_EXT` 导入提示 - **v1.0.1**:修复 Go `libweb` 动态路由 `{param}` 查询代入、详情 Markdown、CSS 数字误报
- Details: [CHANGELOG](https://github.com/cflmy/marqdo/blob/main/CHANGELOG.md) · [ADR 0004](https://github.com/cflmy/marqdo/blob/main/doc/adr/0004-web-plugin-go.md) - **Linux 包必出**:`*-native-x86_64-unknown-linux-gnu.zip` + Linux CLI bundle
- Details: [CHANGELOG](https://github.com/cflmy/marqdo/blob/main/CHANGELOG.md) · [mapping v0.3](https://github.com/cflmy/marqdo/blob/main/doc/design/markdown-mapping-v0.3.md)
### Downloads ### Downloads
@@ -135,7 +136,8 @@ jobs:
|-------|----------| |-------|----------|
| `marqdo-*-windows-msvc.exe` | CLI with **embedded** official stdlib | | `marqdo-*-windows-msvc.exe` | CLI with **embedded** official stdlib |
| `marqdo-*-windows-msvc.zip` | `marqdo.exe` + `lib/` + `ext/`(含 native DLL) | | `marqdo-*-windows-msvc.zip` | `marqdo.exe` + `lib/` + `ext/`(含 native DLL) |
| `marqdo-*-native-*.zip` | 预编译 `web`/`agent`/`quantum` 插件 | | `marqdo-*-native-*.zip` | 预编译 `web`/`agent`/`quantum`/`linalg`(Windows DLL + **Linux .so 必出**) |
| `marqdo-*-unknown-linux-gnu.zip` | Linux CLI + `lib/` + `ext/` + native `.so` |
| `marqdo-*-stdlib.zip` | `lib/` only | | `marqdo-*-stdlib.zip` | `lib/` only |
| `marqdo-*-ext.zip` | Official `ext/` L1 sources | | `marqdo-*-ext.zip` | Official `ext/` L1 sources |
| `marqdo-*-source.zip` | Source snapshot (`git archive`) | | `marqdo-*-source.zip` | Source snapshot (`git archive`) |
@@ -156,8 +158,11 @@ jobs:
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
linux-native: linux:
runs-on: ubuntu-latest runs-on: ubuntu-latest
# Wait until Windows has created the GitHub Release, then attach Linux zips
# (required: native plugins for `marqdo ext add` on Linux + CLI bundle).
needs: windows
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
@@ -169,28 +174,51 @@ jobs:
with: with:
go-version: "1.23.x" go-version: "1.23.x"
- name: Build official plugins (release) - name: Install zip + cgo toolchain
run: sudo apt-get update && sudo apt-get install -y zip gcc libc6-dev
- name: Build Linux CLI + official plugins
run: | run: |
set -euo pipefail
cargo build --release
cargo build --release -p marqdo_plugin_agent -p marqdo_plugin_quantum -p marqdo_plugin_linalg cargo build --release -p marqdo_plugin_agent -p marqdo_plugin_quantum -p marqdo_plugin_linalg
bash ./scripts/build-web-plugin.sh bash ./scripts/build-web-plugin.sh
- name: Package native zip - name: Package Linux native zip + CLI bundle
run: | run: |
set -euo pipefail set -euo pipefail
VER="${GITHUB_REF_NAME#v}" VER="${GITHUB_REF_NAME#v}"
TARGET="x86_64-unknown-linux-gnu" TARGET="x86_64-unknown-linux-gnu"
mkdir -p dist/stage-native/native mkdir -p dist/stage-native/native
cp target/release/libweb.so dist/stage-native/native/libweb.so for lib in libweb.so libagent.so libquantum.so liblinalg.so; do
cp target/release/libagent.so dist/stage-native/native/libagent.so src="target/release/${lib}"
cp target/release/libquantum.so dist/stage-native/native/libquantum.so if [[ ! -f "$src" && "$lib" == libweb.so ]]; then
cp target/release/liblinalg.so dist/stage-native/native/liblinalg.so src="plugins/web/build/libweb.so"
fi
test -f "$src" || { echo "missing $src" >&2; exit 1; }
cp "$src" "dist/stage-native/native/${lib}"
done
(cd dist/stage-native && zip -r "../marqdo-${VER}-native-${TARGET}.zip" .) (cd dist/stage-native && zip -r "../marqdo-${VER}-native-${TARGET}.zip" .)
echo "NATIVE=marqdo-${VER}-native-${TARGET}.zip" >> "$GITHUB_ENV" echo "NATIVE=marqdo-${VER}-native-${TARGET}.zip" >> "$GITHUB_ENV"
- name: Upload Linux native plugins stage="dist/stage-linux"
rm -rf "$stage"
mkdir -p "$stage/ext/native" "$stage/lib"
cp target/release/marqdo "$stage/marqdo"
chmod +x "$stage/marqdo"
cp -a lib/. "$stage/lib/"
cp -a ext/. "$stage/ext/"
cp dist/stage-native/native/*.so "$stage/ext/native/"
linux_zip="marqdo-${VER}-${TARGET}.zip"
(cd "$stage" && zip -r "../${linux_zip}" .)
echo "LINUX_ZIP=${linux_zip}" >> "$GITHUB_ENV"
- name: Upload Linux packages
uses: softprops/action-gh-release@v2 uses: softprops/action-gh-release@v2
with: with:
files: dist/${{ env.NATIVE }} files: |
dist/${{ env.NATIVE }}
dist/${{ env.LINUX_ZIP }}
fail_on_unmatched_files: true fail_on_unmatched_files: true
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+3
View File
@@ -76,3 +76,6 @@ plugins/*/tmp/
# Go web plugin c-shared build output (./scripts/build-web-plugin.sh) # Go web plugin c-shared build output (./scripts/build-web-plugin.sh)
/plugins/web/build/ /plugins/web/build/
# ephemeral sqlite / test artifacts
tests/ext/:memory:
+75
View File
@@ -8,6 +8,81 @@
### Changed ### Changed
## v1.0.2 — 2026-09-16
### Highlights
**表驱动页面引言(`compose_intro` / `引言装配`)**:英雄区用 GFM「属性 / 值 / 样式」表声明,不再手写 HTML 字符串;WWW Demo 样站与后台门禁一并加固。
```bash
git checkout v1.0.2
cargo build --release
bash ./scripts/build-web-plugin.sh
# 或:解压 Release 的 marqdo-1.0.2-*-native-*.zip / Linux CLI zip
marqdo run examples/web-site-zh/index.mq.md
```
### Added
- Go `libweb`:`web_compose_intro` — 将引言表装配为 `.main-intro` HTML;中英 API `页面.引言装配` / `page.compose_intro`(`ext/web`)。
- 验收样例:`tests/ext/web-intro-compose.mq.md`;`examples/web-site` / `web-site-zh` 升级为表驱动引言 + 文学风壳层 + 卡片→详情路由。
### Fixed
- 后台样站:导航/侧栏/页脚槽位与门禁登录挂载对齐;表单字段加宽便于创建。
### Changed
- Demo 叙述与种子数据面向 WWW Industry / 可复现演示;作者仍零业务 JS、零手写 `.css`。
## v1.0.1 — 2026-09-15
### Highlights
**ext/web(Go libweb)回归修复**:动态路由查询条件恢复 `{param}` 代入;详情 SSR + Markdown;样式表数字不再误报。
```bash
git checkout v1.0.1
cargo build --release
bash ./scripts/build-web-plugin.sh
# 或:解压 Release 的 marqdo-1.0.1-*-native-*.zip / Linux CLI zip
marqdo run examples/marqdo-blog/index.mq.md
```
### Added
- Go web plugin:详情页正文 Markdown(goldmark GFM),对齐 Rust `pulldown-cmark` 路径。
### Fixed
- **动态路由 `{param}` 未代入查询条件**(`ext/web` Go):`selectPageData` 递归展开 `query` 全部字符串叶子;`data-slot-src` / `_route` 同步替换。`examples/marqdo-blog` `/post/{slug}` 详情 SSR 恢复。
- **样式表数字单元格误报「可疑 `/` 除法」**:`cssValueSuspicious` 不再把合法 `z-index`/`opacity` 等 number 当警告。
- Go 1.22+ ServeMux:`/static/` 与 `/static/favicon.svg` 的 GET/HEAD 注册冲突导致博客启动 panic。
- Rust archive 同步:`resolve_placeholders` 递归 + CSS number 误报收窄(非默认构建路径)。
## v1.0.0 — 2026-09-14
### Highlights
**Markdown 语法映射 v0.3 成为 1.0 宪法**:`**粗体**` = 代码,`*斜体*` = 返回,叙述里的 `` `名` `` 声明并推断形参。这是相对 v0.4 / 旧 `*语句*`/`**返回**` 的破坏性对调。Linux 预编译拓展包与 CLI bundle 为 Release 必出资产。
```bash
git checkout v1.0.0
cargo build --release
# Linux:也可直接解压 Release 的 marqdo-1.0.0-x86_64-unknown-linux-gnu.zip
marqdo run tests/markup-v03/inc-prose.mq.md
```
### Added
- **Markup v0.3 运行时闭环**:粗体=`代码`、斜体=`返回`、叙述 `` `名` `` 声明与形参推断为唯一映射;金样 `tests/markup-v03/`。
- **方括号标记调用**与前置修饰语:`礼貌 [问候] x`;取元主语法 `[键](集合)`(脚注取元过渡保留)。
- **代码即文档叙述面 G1–G4**:模块级 `---` 跳过、装饰性强调、浮点面量、动态键。
- **粗体表达式语句** `**n + 1**`;`--dump-lines` 标注 `[decl]/[bold]/[italic]`;`--dump-ast` 显示 inferred 形参与死绑定。
- **Release Linux 包必出**:`linux` job 上传 `*-native-x86_64-unknown-linux-gnu.zip` 与 Linux CLI bundle。
### Fixed
- 行首 `` `名`… `` 叙述不再当语句(修复 pages CI:`public/features/16-fs-mid2.mq.md`)。
- 句中斜体强调(`*very important*` / `*foo.bar*`)不再误收束函数;Decl 名须为标识符;残缺粗体保持 GAP 恢复。
- 胶合 `` `名`=default …prose `` 为 Decl 而非赋值。
### Changed
- 教程 / Skill / `lib` / `ext` / `public` 对齐 v0.3 标记;view 推断形参 `chip inferred`。
## v0.4.0 — 2026-09-13 ## v0.4.0 — 2026-09-13
### Highlights ### Highlights
Generated
+2 -2
View File
@@ -572,7 +572,7 @@ checksum = "0ceec5bc11778974d1bcb055b18002eba7f4b3518b6a0081b3af5f21666da9ad"
[[package]] [[package]]
name = "marqdo" name = "marqdo"
version = "0.3.9" version = "1.0.2"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"assert_cmd", "assert_cmd",
@@ -603,7 +603,7 @@ dependencies = [
[[package]] [[package]]
name = "marqdo-wasm" name = "marqdo-wasm"
version = "0.3.9" version = "1.0.2"
dependencies = [ dependencies = [
"marqdo", "marqdo",
"serde_json", "serde_json",
+1 -1
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "marqdo" name = "marqdo"
version = "0.4.0" version = "1.0.2"
edition = "2021" edition = "2021"
license = "Apache-2.0" license = "Apache-2.0"
description = "Marqdo — Markdown markers as an interpreted programming language" description = "Marqdo — Markdown markers as an interpreted programming language"
+23 -23
View File
@@ -23,23 +23,23 @@ Marqdo 把 Markdown **标记当作编程语法**:同一个 `.mq.md` 文件,
--- ---
## 语法速览(v0.2) ## 语法速览(v0.3)
| 标记 | 含义 | | 标记 | 含义 |
|------|------| |------|------|
| 无标记行 | 注释(空行分段) | | 无标记行 | 叙述(注释);行内 `` `名` `` 可声明 |
| `*…*` | 程序语句 | | `**…**` | **代码**(赋值 / 调用 / 表达式) |
| `**…**` | **返回值**(架构) | | `*…*` | **返回值**(整行、`返回*n*`、或表达式形) |
| `****` / `**` + 空白 + `**` | **空返回**(`None`),并结束本函数体 | | `****` / 整行 `**` / `*None*` | **空返回**(`None`),并结束本函数体 |
| `> print …` 等 | 输出等副作用 = **普通函数**,非架构标记 | | `> print …` 等 | 输出等副作用 = **普通函数**,非架构标记 |
| `#` | 对象 / 类型(构造体;`# main` = 入口) | | `#` | 对象 / 类型(构造体;`# main` = 入口) |
| `##` … | 函数 / 方法(按标题深度嵌套) | | `##` … | 函数 / 方法(按标题深度嵌套) |
| `` > `obj`.method … `` | 方法调用(`obj` 为带 `_type` 的 map) | | `` > `obj`.method … `` | 方法调用(`obj` 为带 `_type` 的 map) |
| `+` / `1.` … | 函数头下 `` + `名` `` = 形参;体内 `1.` `2.` … = 分支(`N. *` = else) | | 叙述 `` `名` `` / `` `名`=默认 `` | 形参由体推断(`` + `名` `` 仍可用) |
| `-` | 循环(`` - `条件` `` 或 `` - [项](集合) `` / `` - [`项`](`集合`) ``) | | `1.` … | 体内 `1.` `2.` … = 分支(`N. *` = else) |
| 表格 | 集合 | | `-` | 循环(`` - `条件` `` 或 `` - [项](集合) ``) |
| 函数体内单独一行 `---` / `***` | **结束本函数体**(无返回值收束;见 mapping §11) | | 表格 | 集合;取元优先 `[键](集合)` |
| 文件开头成对 `---` … `---` | Frontmatter(元信息 / 导入),与函数结束符消歧 | | 单独一行 `---` / `***` | **叙述分隔**(跳过;不是函数收束) |
```markdown ```markdown
# main # main
@@ -47,19 +47,18 @@ Marqdo 把 Markdown **标记当作编程语法**:同一个 `.mq.md` 文件,
> 问候 谁=World > 问候 谁=World
## 问候 ## 问候
+ `谁`
> print text=Hello `谁`! 向`谁`问好。
--- **print text="Hello " + 谁**
*None*
## 加一 ## 加一
+ `n`
**`n` + 1** 对于输入变量`n`,执行**n=n+1**接着返回*n*。
``` ```
完整约定:[markdown-mapping.md](doc/design/markdown-mapping.md)。 完整约定:[markdown-mapping-v0.3.md](doc/design/markdown-mapping-v0.3.md)。
--- ---
@@ -99,9 +98,9 @@ marqdo catalog public -o .marqdo
--- ---
## 现状(v0.4.0) ## 现状(v1.0.2)
- 映射与解释器:Phase I 树遍历 + 字节码后端可用;金样例在 `tests/` - 映射与解释器:**v0.3 语法宪法**(`**` 代码 / `*` 返回 / 叙述声明);Phase I 树遍历 + 字节码后端;金样例在 `tests/` 与 `tests/markup-v03/`
- **对象**:`#` = 类型/构造,`##`+ = 函数/方法;见 [objects.md](doc/design/objects.md) - **对象**:`#` = 类型/构造,`##`+ = 函数/方法;见 [objects.md](doc/design/objects.md)
- **`marqdo view`**:文档浏览器(Structure + 函数大纲/搜索 + Execution + Variables 浮窗) - **`marqdo view`**:文档浏览器(Structure + 函数大纲/搜索 + Execution + Variables 浮窗)
- **`marqdo debug`**:独立调试页(断点 / 单步 / locals;默认端口 7430;页面 favicon / 品牌使用官方 Logo) - **`marqdo debug`**:独立调试页(断点 / 单步 / locals;默认端口 7430;页面 favicon / 品牌使用官方 Logo)
@@ -109,7 +108,7 @@ marqdo catalog public -o .marqdo
- **`marqdo version --check`**:与 GitHub 最新 release 对比 - **`marqdo version --check`**:与 GitHub 最新 release 对比
- 标准库:**内置于二进制**(v0.1.2+);磁盘 `lib/` 或 `MARQDO_LIB` 可覆盖。模块含文本、表、**浏览器效应**、文件、系统、时间、JSON、网络、数学、外联、插件、**自写回**、**子任务**;**中层 Mid M1–M6** + **Mid2 M7–M10**(datetime/url/toml/html/fs++/stats/log.fields 等,见 [stdlib-mid.md](doc/design/stdlib-mid.md) · [stdlib-mid2.md](doc/design/stdlib-mid2.md)) - 标准库:**内置于二进制**(v0.1.2+);磁盘 `lib/` 或 `MARQDO_LIB` 可覆盖。模块含文本、表、**浏览器效应**、文件、系统、时间、JSON、网络、数学、外联、插件、**自写回**、**子任务**;**中层 Mid M1–M6** + **Mid2 M7–M10**(datetime/url/toml/html/fs++/stats/log.fields 等,见 [stdlib-mid.md](doc/design/stdlib-mid.md) · [stdlib-mid2.md](doc/design/stdlib-mid2.md))
- **官方扩展库 `ext/`**(**非** stdlib,本版收口): - **官方扩展库 `ext/`**(**非** stdlib,本版收口):
- **`web`**:W0–W7 + P3 + **W8**;**定制 C0–C4**;**宿主 H1–H2**(`proxy`/`invoke`,见 [ext-hosting.md](doc/roadmap/ext-hosting.md));原生层默认 **Go `libweb`**([ADR 0004](doc/adr/0004-web-plugin-go.md),`scripts/build-web-plugin.sh`);示例 [marqdo-blog](examples/marqdo-blog/) · [anlian-mq](examples/anlian-mq/);生产路径见 [web-asgi-servers-and-marqdo.md](doc/design/web-asgi-servers-and-marqdo.md) - **`web`**:W0–W7 + P3 + **W8**;**定制 C0–C4**;**宿主 H1–H2**(`proxy`/`invoke`,见 [ext-hosting.md](doc/roadmap/ext-hosting.md));**表驱动引言**(`compose_intro` / `引言装配`);原生层默认 **Go `libweb`**([ADR 0004](doc/adr/0004-web-plugin-go.md),`scripts/build-web-plugin.sh`);示例 [web-site](examples/web-site/) · [web-site-zh](examples/web-site-zh/) · [marqdo-blog](examples/marqdo-blog/) · [anlian-mq](examples/anlian-mq/);生产路径见 [web-asgi-servers-and-marqdo.md](doc/design/web-asgi-servers-and-marqdo.md)
- **`quantum`**:Q0–Q7 + Q8a/b 主题 SVG;示例 [quantum-entanglement](examples/quantum-entanglement/) - **`quantum`**:Q0–Q7 + Q8a/b 主题 SVG;示例 [quantum-entanglement](examples/quantum-entanglement/)
- **`linalg`**:L0–L6 + 公式文档面(中缀 / `declare` / 展示化简);示例 [linalg-transpose](examples/linalg-transpose/) · [linalg-svd](examples/linalg-svd/) · [linalg-least-squares](examples/linalg-least-squares/) - **`linalg`**:L0–L6 + 公式文档面(中缀 / `declare` / 展示化简);示例 [linalg-transpose](examples/linalg-transpose/) · [linalg-svd](examples/linalg-svd/) · [linalg-least-squares](examples/linalg-least-squares/)
- **`agent`**:A1–A4 + **MCP Server stdio**(`mcp_server`);宿主缺口见 [ext-hosting.md](doc/roadmap/ext-hosting.md) · [agent-framework-gaps-after-a4.md](doc/research/agent-framework-gaps-after-a4.md) - **`agent`**:A1–A4 + **MCP Server stdio**(`mcp_server`);宿主缺口见 [ext-hosting.md](doc/roadmap/ext-hosting.md) · [agent-framework-gaps-after-a4.md](doc/research/agent-framework-gaps-after-a4.md)
@@ -121,12 +120,12 @@ marqdo catalog public -o .marqdo
- **浏览器 Marqdo(WASM)**:`marqdo wasm build` + 官方 bridge 自启(作者零业务 JS;桥内可含列表/路由/storage/ws/文件/Canvas/音频/Observer/拖放);`lib/browser` + GFM;`web.client_embed`;示例 [browser-hello](examples/browser-hello/) · [browser-app](examples/browser-app/) · [browser-media](examples/browser-media/) · [web-client-site](examples/web-client-site/)([ADR 0002](doc/adr/0002-browser-marqdo-wasm.md) · [D](doc/roadmap/browser-wasm-d.md) · [E](doc/roadmap/browser-wasm-e.md) · [F](doc/roadmap/browser-wasm-f.md)) - **浏览器 Marqdo(WASM)**:`marqdo wasm build` + 官方 bridge 自启(作者零业务 JS;桥内可含列表/路由/storage/ws/文件/Canvas/音频/Observer/拖放);`lib/browser` + GFM;`web.client_embed`;示例 [browser-hello](examples/browser-hello/) · [browser-app](examples/browser-app/) · [browser-media](examples/browser-media/) · [web-client-site](examples/web-client-site/)([ADR 0002](doc/adr/0002-browser-marqdo-wasm.md) · [D](doc/roadmap/browser-wasm-d.md) · [E](doc/roadmap/browser-wasm-e.md) · [F](doc/roadmap/browser-wasm-f.md))
- 选型:[ADR 0001 — Rust](doc/adr/0001-implementation-language.md) · [ADR 0002 — 浏览器 WASM](doc/adr/0002-browser-marqdo-wasm.md)(C0–C5 完结,见 [roadmap/browser-wasm.md](doc/roadmap/browser-wasm.md))· [ADR 0003 — 异步效应](doc/adr/0003-browser-async-effects.md) - 选型:[ADR 0001 — Rust](doc/adr/0001-implementation-language.md) · [ADR 0002 — 浏览器 WASM](doc/adr/0002-browser-marqdo-wasm.md)(C0–C5 完结,见 [roadmap/browser-wasm.md](doc/roadmap/browser-wasm.md))· [ADR 0003 — 异步效应](doc/adr/0003-browser-async-effects.md)
### 如何使用最新 Marqdo(v0.4.0) ### 如何使用最新 Marqdo(v1.0.2)
```bash ```bash
# 1) 源码安装(跟 tag 或 main) # 1) 源码安装(跟 tag 或 main)
git clone https://github.com/cflmy/marqdo.git && cd marqdo git clone https://github.com/cflmy/marqdo.git && cd marqdo
git checkout v0.4.0 # 或留在 main git checkout v1.0.2 # 或留在 main
cargo build --release cargo build --release
export PATH="$PWD/target/release:$PATH" export PATH="$PWD/target/release:$PATH"
marqdo version marqdo version
@@ -150,6 +149,7 @@ marqdo ext add llm # 或:大模型(纯 .mq.md)
# 离线:解压 Windows zip(已含 ext/native)或手动放下 native zip;MARQDO_EXT_NO_DOWNLOAD=1 # 离线:解压 Windows zip(已含 ext/native)或手动放下 native zip;MARQDO_EXT_NO_DOWNLOAD=1
# 4) 动态站示例(扩展装好后) # 4) 动态站示例(扩展装好后)
marqdo run examples/web-site-zh/index.mq.md # 表驱动引言 Demo
marqdo run examples/marqdo-blog/index.mq.md marqdo run examples/marqdo-blog/index.mq.md
marqdo run examples/anlian-mq/index.mq.md # W-G14 验收站 marqdo run examples/anlian-mq/index.mq.md # W-G14 验收站
# 浏览器打开终端打印的 listen 地址;/favicon.ico 与 logo 装配见 W8 # 浏览器打开终端打印的 listen 地址;/favicon.ico 与 logo 装配见 W8
@@ -158,8 +158,8 @@ marqdo run examples/anlian-mq/index.mq.md # W-G14 验收站
marqdo wasm build marqdo wasm build
# → dist/wasm/ … 见 examples/browser-hello/ # → dist/wasm/ … 见 examples/browser-hello/
# 6) Windows:也可从 GitHub Releases 下载 exe / zip / vsix # 6) Releases:Windows exe/zip/vsix;Linux CLI zip + native `.so` zip
# https://github.com/cflmy/marqdo/releases/tag/v0.4.0 # https://github.com/cflmy/marqdo/releases/tag/v1.0.2
``` ```
开发期也可用 `cargo run -- …` 代替已安装的 `marqdo`: 开发期也可用 `cargo run -- …` 代替已安装的 `marqdo`:
+1 -1
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "marqdo-wasm" name = "marqdo-wasm"
version = "0.4.0" version = "1.0.2"
edition = "2021" edition = "2021"
license = "Apache-2.0" license = "Apache-2.0"
description = "Marqdo interpreter as WebAssembly (browser host bridge)" description = "Marqdo interpreter as WebAssembly (browser host bridge)"
+4 -1
View File
@@ -15,7 +15,10 @@
| 文档 | 摘要 | | 文档 | 摘要 |
|------|------| |------|------|
| [design/markdown-mapping.md](design/markdown-mapping.md) | **v0.1 语法宪法** | | [design/markdown-mapping.md](design/markdown-mapping.md) | **v0.2 语法宪法(现行运行时)** |
| [design/markdown-mapping-v0.3.md](design/markdown-mapping-v0.3.md) | **v0.3 草案:叙述统一 · 粗体代码 · 斜体返回 · 形参体推断** |
| [adr/0005-prose-unified-markup.md](adr/0005-prose-unified-markup.md) | **Proposed:采纳 mapping v0.3** |
| [roadmap/markup-v0.3.md](roadmap/markup-v0.3.md) | **Markup v0.3 实现路线(M0–M5)** |
| [design/objects.md](design/objects.md) | **`#` 对象 / `##` 函数与方法** | | [design/objects.md](design/objects.md) | **`#` 对象 / `##` 函数与方法** |
| [design/ai-skill.md](design/ai-skill.md) | **AI 接入 Skill**([`skills/marqdo/`](../skills/marqdo/)) | | [design/ai-skill.md](design/ai-skill.md) | **AI 接入 Skill**([`skills/marqdo/`](../skills/marqdo/)) |
| [design/code-vs-comment.md](design/code-vs-comment.md) | 叙述 / 可执行 / 外联 | | [design/code-vs-comment.md](design/code-vs-comment.md) | 叙述 / 可执行 / 外联 |
+53
View File
@@ -0,0 +1,53 @@
# ADR 0005:叙述统一的 Markup 映射(粗体即代码 · 斜体即返回 · 形参体推断)
| | |
|---|---|
| Status | **Accepted** |
| Date | 2026-09-13 |
| Related | [markdown-mapping-v0.3.md](../design/markdown-mapping-v0.3.md) · [markdown-mapping.md](../design/markdown-mapping.md) · [return-hr-and-code-surface.md](../design/return-hr-and-code-surface.md) · [roadmap/markup-v0.3.md](../roadmap/markup-v0.3.md) |
## Context
- Marqdo 的产品承诺是「代码即文档 / 文档即代码」:`.mq.md` 打开是文章,运行是程序。
- v0.2([markdown-mapping.md](../design/markdown-mapping.md))为消歧做了硬隔离:无标记 = 注释;`*…*` = 语句;`**…**` = 返回;调用必须 `>`;形参必须 `` + `名` ``。
- 该隔离使叙述与程序**视觉割裂**;且与 AI/Markdown 习惯相反(模型偏好用 `**` 强调「要做的事」)。
- 产品方重新审视后,希望合法化如下写法:
```markdown
## 加一函数
对于输入变量`n`,我们执行操作**n=n+1**接着返回*n*。
# main
> 加一函数 37
或者可以直接这么调用**加一函数 37**
```
## Decision
1. 采纳 **Markup 映射 v0.3** 为下一版语言宪法草案,全文见 [markdown-mapping-v0.3.md](../design/markdown-mapping-v0.3.md)。
2. **角色对调**:`**…**` = 代码段(含可省略 `>` 的调用);`*…*` = 返回值。
3. **叙述中的** `` `名` ``:**首次未赋值 = 声明变量**;未使用不报错;**仅当可执行面读取时升为形参**(见设计 §4.4 · §8.2)。不设「提及性」专用语法。
4. **形参默认由函数体/叙述推断**(升参);`` + `名` `` 仅作迁移兼容。
5. **`>` 调用面保留**(可选)。
6. **空返回**用标记而非关键字:推荐 `---` / `***`;显式 `*None*` / `*无*`;整行 `**`;兼容 `****`(设计 §7.2)。
7. **不做 v0.2 双模式兼容**(摸索阶段允许破坏性变更);旧 `.mq.md` 须改写。
8. 金样例门禁:`tests/markup-v03/`;存量 suite 随后迁移。
## Consequences
### Positive
- 叙述与代码共用 Markdown 习惯,文档可读性上升。
- 更贴合 AI 生成粗体「操作」的偏好,降低错用标记。
- 去掉形参表仪式,函数更像「带名字的说明段落」。
### Negative / Risks
- **破坏性**:与 v0.2 金样例、Skill、教程、大量 `lib/`/`ext/` 源码不兼容,必须分波迁移或双模式。
- 段内扫描与形参推断增加解析/语义复杂度——空返回与升参规则已在设计 §7.2 / §8.2 钉死;其余 §12 项用金样例收口。
- view/catalog/LSP 高亮规则需同步。
### Neutral
- `#` / `##` 对象体系、标准库、插件 ABI、关键字最小集不变。
- 输出仍是 `print` / `打印`,不是粗体/斜体。
+54
View File
@@ -0,0 +1,54 @@
# 方括号标记调用与前置修饰语
| | |
|---|---|
| 状态 | **Active** |
| 日期 | 2026-09-14 |
| 相关 | [call-arguments.md](call-arguments.md) · [collection-access-link.md](collection-access-link.md) · [markdown-mapping-v0.3.md](markdown-mapping-v0.3.md) |
---
## 1. 动机
无标记时,修饰语+函数名与函数名+实参都是词列,**无法消歧**。消歧标记必须来自 Marqdo 语法,**不能**依赖任一自然语言词法(「的」、形容词位置等)。
## 2. 形状
```text
修饰语… [函数名] 实参…
```
| 例子 | 含义 |
|------|------|
| `[问候] marqdo` | 调用 `问候`,位置实参 |
| `礼貌 [问候] marqdo` | 另加 `礼貌=True` |
| `正式 礼貌 [问候] marqdo` | `正式=True` `礼貌=True` |
| `[结账摘要] 品名="拿铁" 杯数=2` | 仅具名实参 |
| `[问候] ([格式化] `名字`)` | 嵌套:内层整段用 `()` |
旧形保留:`> 问候 …`、`**问候 …**`、`礼貌=True` 显式具名。
## 3. 与取元 / foreach
| 形状 | 语义 |
|------|------|
| `[X](Y)`(`]` 后**紧邻** `(`) | 取元 |
| `[X]`(`]` 后不是 `(`) | 函数名标记 |
| `- [X](Y)` | foreach |
## 4. 修饰语绑定
- `[` 前按空白切开;每段为标识(可 `` `名` ``)。
- 降为 `Named(名, Bool(true))`,再与 `]` 后实参合并。
- 与显式同名具名冲突 → 诊断。
- **核心不剥语言词缀**;形参叫 `礼貌` 则写 `礼貌 [问候]`。
## 5. AST
`CallExpr.pre_modifiers: Vec<String>`;求值/字节码在绑参前展开。
## 6. 修订历史
| 日期 | 说明 |
|------|------|
| 2026-09-14 | 初稿并落地 |
+17 -10
View File
@@ -2,9 +2,9 @@
| | | | | |
|---|---| |---|---|
| 状态 | 已定(v0.1 增补) | | 状态 | 已定(v0.1 增补;2026-09-14:方括号标记调用) |
| 日期 | 2026-08-07 | | 日期 | 2026-08-07 |
| 相关 | [markdown-mapping.md](markdown-mapping.md) · [keywords.md](keywords.md) · [module-namespace.md](module-namespace.md) | | 相关 | [markdown-mapping.md](markdown-mapping.md) · [keywords.md](keywords.md) · [module-namespace.md](module-namespace.md) · [bracket-call-modifiers.md](bracket-call-modifiers.md) |
--- ---
@@ -16,20 +16,26 @@
|------|------|------| |------|------|------|
| **具名**(保留) | `> 问候 谁=Marqdo` | `名=值`;值可含空格(至下一 `名=`) | | **具名**(保留) | `> 问候 谁=Marqdo` | `名=值`;值可含空格(至下一 `名=`) |
| **位置**(新增) | `> 问候 Marqdo` | 按形参声明顺序绑定 | | **位置**(新增) | `> 问候 Marqdo` | 按形参声明顺序绑定 |
| **方括号标记**(增补) | `礼貌 [问候] Marqdo` | `[函数名]` 消歧;`[` 前裸词 → `名=True`;见 [bracket-call-modifiers.md](bracket-call-modifiers.md) |
二者可混用:位置实参按「尚未被具名绑定的形参」从左到右填充。具名不可绑定同一形参两次;位置实参不得出现在「已出现具名实参」之后(对齐常见「位置在前、关键字在后」习惯)。 二者可混用:位置实参按「尚未被具名绑定的形参」从左到右填充。具名不可绑定同一形参两次;位置实参不得出现在「已出现具名实参」之后(对齐常见「位置在前、关键字在后」习惯)。前置修饰语与显式同名具名冲突则报错。
--- ---
## 2. 文法(调用尾部) ## 2. 文法(调用尾部)
``` ```
call_tail ::= callee arg* call_tail ::= bracket_call | classic_call
bracket_call ::= modifier* '[' callee ']' arg*
classic_call ::= callee arg*
arg ::= named | positional arg ::= named | positional
named ::= ident '=' value named ::= ident '=' value
positional ::= value_token positional ::= value_token | '(' call_tail ')'
modifier ::= ident # 展开为 ident=True;核心不剥语言词缀
``` ```
- `]` 后**紧邻** `(` → **取元** `[key](collection)`,不是 callee 标记(见 [collection-access-link.md](collection-access-link.md))。
- 嵌套调用:把内层整段放进 `()`,例如 `[问候] ([格式化] "x")`。
- `value`(具名右侧):可含空格与 `` `var` `` 插值,直到下一个 `ident=` 边界。 - `value`(具名右侧):可含空格与 `` `var` `` 插值,直到下一个 `ident=` 边界。
- `value_token`(位置):空白分隔的一个词法单元——数字、`` `名` ``、标识/文本词;**不含空格**。多词字符串请用具名,例如 `> print text=Hello World!`。 - `value_token`(位置):空白分隔的一个词法单元——数字、`` `名` ``、标识/文本词;**不含空格**。多词字符串请用具名,例如 `> print text=Hello World!`。
- 实参值中 `` `变量` `` 后**紧跟** `[^…]` 时按**脚注取元**解析(可链式),而非文本:`> print text=苹果单价:`水果价格`[^苹果]`、`> print text=`订单`[^2][^品名]`。 - 实参值中 `` `变量` `` 后**紧跟** `[^…]` 时按**脚注取元**解析(可链式),而非文本:`> print text=苹果单价:`水果价格`[^苹果]`、`> print text=`订单`[^2][^品名]`。
@@ -44,13 +50,14 @@ positional ::= value_token
## 3. 绑定算法 ## 3. 绑定算法
1. 收集具名 → 映射;冲突则报错。 1. 将前置修饰语展开为 `名=True` 具名(与显式具名冲突则报错)。
2. 按函数形参表顺序:若具名已提供则用之,否则取下一个位置实参。 2. 收集具名 → 映射;冲突则报错。
3. 位置实参有余、或必填形参仍缺 → 报错(内置 `input` 的 `prompt` 可缺省)。 3. 按函数形参表顺序:若具名已提供则用之,否则取下一个位置实参。
4. 用户函数:额外具名键仍写入调用环境(便于扩展);位置实参不可超过形参数目。 4. 位置实参有余、或必填形参仍缺 → 报错(内置 `input` 的 `prompt` 可缺省)。
5. 用户函数:额外具名键仍写入调用环境(便于扩展);位置实参不可超过形参数目。
--- ---
## 4. 金样例 ## 4. 金样例
见 `tests/structure/positional-call.mq.md`、`tests/structure/ns/`(点号路径 / `use`)与 `tests/structure/import/`(导入解析)。 见 `tests/structure/positional-call.mq.md`、`tests/structure/bracket-call.mq.md`、`tests/structure/ns/`(点号路径 / `use`)与 `tests/structure/import/`(导入解析)。
+119
View File
@@ -0,0 +1,119 @@
# 代码即文档 · 叙述面摩擦(v0.3 实测)
| | |
|---|---|
| 状态 | **Done** |
| 日期 | 2026-09-14 |
| 触发 | `examples/code-as-docs/index.mq.md` 试跑 |
| 宪法 | [markdown-mapping-v0.3.md](markdown-mapping-v0.3.md) |
| 路线 | [code-as-docs-gaps.md](../roadmap/code-as-docs-gaps.md) |
---
## 0. 原则
修复必须同时服务:
1. **代码即文档**:人读 Markdown 时自然段落、分隔线、强调不应被误伤。
2. **适配 LLM 输出**:模型习惯写 `---` 分段、`**加粗强调**`、`0.85` 小数、`` map[^`key`] `` 动态键——运行时应尽量「写出来就能跑」。
3. **可执行标记仍清晰**:真正的赋值 / 调用 / 返回不被误判成装饰。
---
## 1. 四个问题(实测)
### G1 — 模块级 `---` 被当成结构错误
| | |
|---|---|
| 现象 | 文件标题段落后写 Markdown 分隔线 `---`,报 `expected heading … got: ---` |
| 根因 | 词法上整行 `-`/`*` 为 Code;旧实现把函数体内 `---` 当收束,模块顶却当非法。现统一为叙述跳过 |
| 人/LLM 期望 | 任意处 `---` = GFM thematic break = **叙述噪音** |
| 决议 | **处处** frame 行 skip;副作用收束用 `*None*` / `**` / `****`(返回即结束函数体解析) |
### G2 — 叙述里的 `**强调**` / `*斜体强调*` 被当成代码/返回
| | |
|---|---|
| 现象 | 「本文件既是**说明**也是**程序**」→ 粗体 `说明` 不是赋值/调用,解析失败;`*only*` 类英文强调升成返回/`only` 变量 |
| 根因 | v0.3 叙述扫描凡 `**…**` / `*…*` 一律可执行([prose.rs](../../src/parse/prose.rs));Skill 曾禁止强调,但与 LLM/Markdown 习惯冲突 |
| 人/LLM 期望 | 装饰性强调可出现;**像代码的**粗体/斜体仍执行 |
| 决议 | **形状启发式**(见 §2):像代码则执行,否则当作叙述装饰(不产生 Stmt,不升参) |
### G3 — 小数面量 `0.85` 不可用
| | |
|---|---|
| 现象 | `**x = 0.85**` → `trailing input: ".85"`;`28 * 0.85` 解析错乱;即便进到求值,`*` 仍只接受 int |
| 根因 | 表达式主词只吃整数字面量(`Literal` 无 `Num`);运行时已有 `Value::Num`,二元运算未接浮点 |
| 人/LLM 期望 | `0.85`、`3.14`、`折扣=0.85` 可写可算 |
| 决议 | 解析 `数字.数字` → `Literal::Num`;`*` `/` `+` `-` 及比较在 `Int`/`Num` 间提升(与已有 `cmp_ord` 一致) |
### G4 — 动态脚注键 `` 菜单[^`名`] ``
| | |
|---|---|
| 现象 | `` 菜单[^`名`] `` → `missing map key ``名`` `(把字面 `` `名` `` 当键,或解析失败) |
| 根因 | `[^label]` 的 label 仅为**静态字符串**;AST `Expr::Index { label: String }` 无变量槽 |
| 人/LLM 期望 | 表/映射按变量取键:`` `菜单`[^`品名`] `` 或 `菜单[^`品名`]` |
| 决议 | 支持 `` [^`ident`] `` → 运行时用变量值作键(文本化后走现有 footnote get);静态 `[^拿铁]` 不变 |
---
## 2. 粗体/斜体「像代码」启发式
### 粗体 `**inner**` → 可执行,当且仅当
满足任一:
- 含 `=`(赋值 / 命名参数调用);或
- 以 `>` 开头(显式调用);或
- 含运算符 / 索引 / 调用形:`+ - * / ( ) [ ]`;或
- 空白分词 ≥2 段,且其后段含数字面量、引号串、或 `=`(如 `**加一 37**`、`**print text="hi"**`)
否则(如 `**说明**`、`**代码即文档**`)→ **装饰,忽略**。
### 斜体 `*inner*` → 返回,当且仅当
满足任一:
- 空 / `None` / `无` / `空` / bool 字面;或
- 以 `>` 开头;或
- 含 `=` 或运算符 / 索引;或
- **整行**仅为 `*…*`(含缩进)——整行返回 `*总额*` / `*n*`;或
- 行内且前方紧邻「返回」二字(叙述「接着返回*n*」)
否则行内简单词(如 `*only*`、`*named*`)→ **装饰,忽略**。
> 整行 `*n*` 仍是返回;行内「返回*n*。」仍是返回。英文强调词在句中被忽略。
---
## 3. 非目标
- 不恢复 v0.2 双模式
- 不引入 `if`/`return` 关键字
- 不把任意 `**任意自然语言句子**` 都当代码(必须过 §2)
- 动态键第一期只做 `` [^`ident`] ``,不做完整表达式 `[^a+b]`
---
## 4. 验收
| 用例 | 期望 |
|------|------|
| 顶层段落之间的 `---` | 可解析、可运行 |
| 「既是**说明**也是**程序**」 | 可解析;无 Stmt |
| `**应付 = 原价 * 0.85**` / `折扣`=0.85 | 数值正确(浮点) |
| `` **价 = 菜单[^`名`]** ``(`名` 已绑定) | 取到对应价 |
| `examples/code-as-docs/index.mq.md` | 用回浮点折扣与动态键后仍绿 |
| 既有 `tests/markup-v03/*` 与 gold | 不回归 |
---
## 5. 修订历史
| 日期 | 说明 |
|------|------|
| 2026-09-14 | 初稿:四缝 + 启发式 + 验收 |
| 2026-09-14 | 落地:G1–G4 实现 + 金样;顶层 Comment 引言 skip |
+16 -13
View File
@@ -2,8 +2,12 @@
| | | | | |
|---|---| |---|---|
| 状态 | 与 mapping v0.1 / keywords 对齐(成段注释) | | 状态 | 与 mapping **v0.3** 对齐(现行运行时) |
| 日期 | 2026-08-04 | | 日期 | 2026-09-14 |
| 取代 | 本文曾按 v0.2(`*语句*` / `**返回**`)叙述;旧对照见 [markdown-mapping.md](markdown-mapping.md) |
| 相关 | [markdown-mapping-v0.3.md](markdown-mapping-v0.3.md) §4 |
「Markup」在此仓库 = Marqdo **把 Markdown 标记映射成语法** 的那一层,不是另一个语言。
--- ---
@@ -11,19 +15,18 @@
| 层 | 形态 | 角色 | | 层 | 形态 | 角色 |
|----|------|------| |----|------|------|
| **叙述面** | 成段注释(空行分段) | 注释;段内任意标记无语义 | | **叙述面** | 普通段落 | 注释;行内 `` `名` `` 可声明/引用;装饰性 `**强调**` / `*斜体*` 不执行 |
| **Marqdo 可执行面** | 结构标记 + `*语句*` + `**返回**` | 本语言程序 | | **Marqdo 可执行面** | 结构标记 + **`**代码**`** + **`*返回*`** | 本语言程序 |
| **外联面** | ` ```lang ` | 其它语言(FFI) | | **外联面** | ` ```lang ` | 其它语言(FFI) |
输出属于可执行面里的**函数调用**(`> print …`),见 [keywords.md](keywords.md)。 输出属于可执行面里的**函数调用**(`> print …` / `**print …**`),见 [keywords.md](keywords.md)。
### 成段注释 ### 成段注释
- 以**空行**划分段落。 - 以**空行**划分段落。
- 段首行:首字符非标记 → 注释。 - 段首行:首字符非标记 → 注释段;段内续行一律叙述(即使以 `` ` `` / `-` 开头)。
- 段内续行:一律注释(即使以 `` ` `` / `-` / `**` 等开头)。 - 段内仍扫描行内可执行位:`` `名` ``、代码形 `**…**`、返回形 `*…*`。
- **例外**:整行仅为 `**expr**`(或 `****`)→ Marqdo **返回**;`**强调**` 后还有文字 → 仍是叙述注释。 - 叙述段与独立结构行(`>` `#`)之间**建议空一行**,否则 `> print` 可能被吞进注释段。
- 叙述段与可执行代码之间**必须空一行**,否则 `> print` 等会被吞进注释段。
--- ---
@@ -31,8 +34,8 @@
| 标记/形式 | 角色 | 是否架构级 | | 标记/形式 | 角色 | 是否架构级 |
|-----------|------|------------| |-----------|------|------------|
| `*…*` | 程序语句 | 是 | | `**…**` | 代码(赋值 / 调用 / 表达式语句) | 是 |
| `**…**` | 返回值 | 是 | | `*…*` | 返回值(整行、`返回*n*`、或表达式形) | 是 |
| `****` / 空粗体 | 空返回 + 结束函数体 | 是 | | `****` / 整行 `**` / `*None*` | 空返回 + 结束函数体 | 是 |
| `> print …` | 打印副作用 | 否(内置函数) | | `> print …` | 打印副作用 | 否(内置函数) |
| 函数体 `---` / `***` | 结束函数体 | 是(边界) | | 函数体 `---` / `***` | 叙述分隔(跳过,**不**结束函数体) | 否 |
+64
View File
@@ -0,0 +1,64 @@
# 集合取元:GFM 链接形
| | |
|---|---|
| 状态 | **Active(运行时)** |
| 日期 | 2026-09-14 |
| 相关 | [tables-maps-footnotes.md](../roadmap/tables-maps-footnotes.md) · [markdown-mapping-v0.3.md](markdown-mapping-v0.3.md) · [code-as-docs-gaps.md](code-as-docs-gaps.md) |
---
## 1. 决议
表达式取元的**主语法**为 Markdown 链接外形,与 foreach 同构:
| 角色 | 写法 |
|------|------|
| **取元(表达式)** | `[键](集合)` |
| **遍历(语句)** | `- [项](集合)`(不变) |
| **脚注取元(过渡)** | `` 集合[^键] `` 仍解析,新代码勿写 |
心智:**方括号 = 取出的名字,圆括号 = 从哪取。**
```markdown
**价 = [拿铁](菜单)**
**价 = [`名`](菜单)**
**第一 = [1](篮子)**
- [行](今日订单)
**名 = [品名](行)**
```
## 2. 细则
| 写法 | 语义 |
|------|------|
| `[拿铁](菜单)` | 静态键;`菜单` 为变量(粗体/斜体内) |
| `` [`名`](菜单) `` | 动态键(求值 `名` 再作键) |
| `[1](篮子)` | List **1-based** 下标(同脚注约定) |
| `[1]([苹果](货架))` | 嵌套链式 |
与 `- [项](集合)` 消歧:仅 **表达式位置** 的 `[…](…)` 为取元;`-` 行头仍为 foreach。
## 3. 迁移
`` `菜单`[^拿铁] `` / `菜单[^拿铁]` → `[拿铁](菜单)`(**基与键左右对调**)。
| 区域 | 约定 |
|------|------|
| 新代码 / examples / public | **只用**链接形 |
| `tests/structure/footnote*` · `interp-footnote*` | 脚注兼容门禁(保留) |
| 其余 structure / ext / lib 金样 | 已迁链接形 |
脚注路径保留至另行决定移除之日;Skill / 教程 / 新示例只用链接形。
## 4. 非目标
- 点号 map 访问、`在`、箭头取元、`(键)[集合]`
- 循环语法糖(`←` / `in` / 自然语言)
## 5. 修订历史
| 日期 | 说明 |
|------|------|
| 2026-09-14 | 初稿并落地主语法 |
+9 -18
View File
@@ -16,27 +16,17 @@
tests/ tests/
README.md README.md
gold.rs # 集成测试入口 gold.rs # 集成测试入口
structure/ # 代码基础结构(Markup 架构) structure/ # 代码基础结构(Markup 架构 · v0.2)
hello.mq.md …
nested-call.mq.md
positional-call.mq.md
branch.mq.md
loop.mq.md
collection.mq.md
import/
main.mq.md
utils.mq.md
ns/
helpers.mq.md
path3.mq.md
use.mq.md
keywords/ # 关键字与内置名 keywords/ # 关键字与内置名
print.mq.md …
bool-logic.mq.md markup-v03/ # Markup 映射 v0.3 草案金样例(实现前 ignore)
README.md
inc-prose.mq.md
…
ext/ ext/
agent-run-live.mq.md …
errors/ # 期望失败(诊断文案稳定后再加金样例) errors/ # 期望失败(诊断文案稳定后再加金样例)
ns-instance-method.mq.md
… …
``` ```
@@ -51,6 +41,7 @@ tests/
|------|--------|----------| |------|--------|----------|
| **structure** | `#`/`##`、形参 `+`、`1.` 分支、`-` 循环、表、导入、点号路径 / `use`、位置/具名实参 | 关键字边角 | | **structure** | `#`/`##`、形参 `+`、`1.` 分支、`-` 循环、表、导入、点号路径 / `use`、位置/具名实参 | 关键字边角 |
| **keywords** | `True`/`False`/`None`、`and`/`or`/`not`、`print`/`input` 约定 | 复杂控制流(可极简) | | **keywords** | `True`/`False`/`None`、`and`/`or`/`not`、`print`/`input` 约定 | 复杂控制流(可极简) |
| **markup-v03** | v0.3:叙述声明、粗体代码、斜体返回、升参、空返回、双调用面(见 [markdown-mapping-v0.3.md](markdown-mapping-v0.3.md)) | 在 `--markup v0.3` 落地前 `#[ignore]` |
| **errors** | 未定义名、实参错误、语法错误的诊断 | 成功路径 | | **errors** | 未定义名、实参错误、语法错误的诊断 | 成功路径 |
未单独建夹、但应覆盖的其它测试(`src/**` 单测或日后 `tests/runtime/`): 未单独建夹、但应覆盖的其它测试(`src/**` 单测或日后 `tests/runtime/`):
+55
View File
@@ -0,0 +1,55 @@
# 标准库 / 扩展库:代码即文档
| | |
|---|---|
| 状态 | **Active** |
| 日期 | 2026-09-14 |
| 相关 | [code-as-docs-gaps.md](code-as-docs-gaps.md) · [bracket-call-modifiers.md](bracket-call-modifiers.md) · [collection-access-link.md](collection-access-link.md) · [stdlib.md](stdlib.md) · [marqdo-dev skill](../../.cursor/skills/marqdo-dev/SKILL.md) · [roadmap](../roadmap/lib-ext-code-as-docs.md) |
---
## 1. 目标
`lib/*` 与 `ext/*` 的 `.mq.md` 应**可当说明书读、可当程序跑**。薄库不写长文;厚领域库(web / quantum / …)仍用叙述承载意图,但数据与调用面与用户程序同一套标记。
## 2. 薄库模板(默认)
每个导出函数 / 方法尽量按此骨架(中英分文件锁步):
1. **目的句**(一句人话,无标记即可)。
2. **叙述形参**:正文里出现 `` `名` `` / `` `名`=默认 ``(推断签名);过渡期可保留 `` + `名` ``。
3. **一例**:粗体或 `>` 调用;优先可读表面。
4. **实现**:短;取元用 `[键](集合)`,**禁止新增**脚注取元 `` `m`[^k] ``(旧解析仍可用)。
调用示例(三种等价,试点期任选;新叙述优先括号标记或粗体):
```markdown
**出 = [put] 入=`表` 键="a" 值=1**
**出 = put 入=`表` 键="a" 值=1**
> put 入=`表` 键="a" 值=1
```
带布尔开关时可用前置修饰:`严格 [parse] text=`源`` → `严格=True`(形参名与修饰语字面一致;核心不剥「的」等词缀)。
## 3. 硬约束
| 要 | 不要 |
|----|------|
| GFM 表作数据;`table.put` / 具名助手 | `json.set` 链当字典构造器 |
| 作者程序用 `[k](c)` 取元;`- [项](集合)` foreach | 新代码写 `` m[^k] `` |
| 中英 API 对称(见 [stdlib-i18n.md](stdlib-i18n.md)) | 只改一侧 |
| 一例跑通即文档(public/stdlib 或 examples) | 另开第二套「文档站」手写说明 |
**库函数体内的叙述坑:** 函数体里的链接形 `[k](c)`、以及单独的 `**强调**` 会被当成可执行代码。库内说明用「链接取元 / link-index」等字面描述;可执行示例放在 `public/stdlib` 或 `examples/`,不要写在 `##` 体内当叙述。
## 4. 波次
见 [roadmap/lib-ext-code-as-docs.md](../roadmap/lib-ext-code-as-docs.md):先稳定调用表面,再 M1 试点 table/text/json,其后批次 lib → ext。
## 5. 修订历史
| 日期 | 说明 |
|------|------|
| 2026-09-14 | 初稿(随括号调用落地) |
+618
View File
@@ -0,0 +1,618 @@
# Marqdo 语法映射 v0.3(叙述统一 · 粗体即代码)
| | |
|---|---|
| 状态 | **Accepted · 现行运行时目标(实现中)** |
| 日期 | 2026-09-13 |
| 取代 | [markdown-mapping.md](markdown-mapping.md) **v0.2(已废止为运行时宪法)** |
| ADR | [0005-prose-unified-markup.md](../adr/0005-prose-unified-markup.md) |
| 路线 | [markup-v0.3.md](../roadmap/markup-v0.3.md) |
| 相关 | [code-vs-comment.md](code-vs-comment.md) · [return-hr-and-code-surface.md](return-hr-and-code-surface.md) · [call-arguments.md](call-arguments.md) · [objects.md](objects.md) · [keywords.md](keywords.md) |
> **名词:** 本文「Markup」指 Marqdo **如何把 Markdown 标记映射成语法**(`**` 代码、`*` 返回、`` `名` `` 声明),不是另一个语言。产品仍是 Marqdo。
> **v0.3 为唯一映射。** 不做 v0.2 双模式 / `--markup` 版本身份。摸索阶段允许破坏性变更;旧 `.mq.md`(`*语句*` / `**返回**`)须改写。金样例见 `tests/markup-v03/`。
---
## 0. 一句话
让 **Markdown 叙述本身成为程序的一部分**:普通文字里用 `` `名` `` 出现变量(首次未赋值 = 声明);用 **`**…**` 粗体** 包裹可执行代码(含调用,不必再写 `>`);用 **`*…*` 斜体** 表示返回值。函数形参**不再手写 `+` 列表**,由函数体内的声明/赋值自行推断。
---
## 1. 动机(为何推翻 v0.2 的部分定论)
v0.2 为了「标记即语法」的清晰边界,做了这些硬隔离:
| v0.2 | 代价 |
|------|------|
| 无标记行 = 纯注释;变量只能写在 `*…*` / 结构行里 | 叙述与代码割裂,「文档即代码」读起来像两套语言叠在一起 |
| `*…*` = 语句,`**…**` = 返回 | 与常见 Markdown/AI 习惯相反:模型更爱用 `**` 强调「要执行的东西」,读者也更易看见粗体 |
| 调用必须 `>` | 行间调用要另起结构行,叙述中夹调用不自然 |
| 形参必须 `` + `名` `` | 仪式感强;函数头像「另一套签名语言」,与正文脱节 |
古早示例(当时不能跑,正是本文要合法化的目标面):
```markdown
## 加一函数
对于输入变量`n`,我们执行操作**n=n+1**接着返回*n*。
# main
我要调用加一函数可以采用这样的办法:
> 加一函数 37
或者可以直接这么调用**加一函数 37**
```
目标:上述文件在 v0.3 下应能解析、求值,且**读起来仍是一篇正常中文说明**。
---
## 2. 哲学(设计原则)
### P1 — 叙述统一(Prose-unified)
- Marqdo 注释采用 **Markdown 叙述**(段落、列表中的说明文字),不是第二种注释语法。
- **变量可以出现在正常文字之间**:用 Markdown 行内代码 `` `n` `` 标识标识符。
- **第一次出现且未赋值 = 声明变量**;之后的出现 = 引用。赋值发生在粗体代码段内(或兼容的结构赋值形)。
- **未使用的变量无害**(不报错、不升参);真正的输入由「可执行面读取」升为形参(§8)。
- 这样「说明文字」与「程序名字」共用同一套 Markdown 视觉习惯,整体更和谐。
### P2 — 粗体即代码(Bold-as-code)
- **`**…**` = 代码段**(可执行):赋值、表达式、函数/方法调用、可内联的短语句。
- 选择粗体的原因:
1. **AI 输出偏好**:模型天然爱用 `**` 强调「重要操作」;把粗体定为可执行,降低「模型写了强调却被当成返回」的错配。
2. **行间显眼**:在长段落里,粗体比斜体更容易被扫到。
- 粗体代码段内的调用 **允许不写 `>`**:`**加一函数 37**` 与 `> 加一函数 37` 语义等价(见 §6)。
- **`>` 保留为可选调用面**(blockquote 风格、独立行、兼容 v0.2 迁移与 AI 已学会的形态)。
### P3 — 斜体即返回(Italic-as-return)
- **`*…*` = 返回值**(架构级),与粗体代码形成对立、易读的一对:
- 做了什么 → 粗体
- 结果是什么 → 斜体
- **空返回 / 无值收束**(已决议,见 §7.2):推荐 `*None*` / `*无*`;整行 `**`;兼容 `****`。`---` / `***` 仅为叙述分隔(跳过),**不再**结束函数体。
- **输出仍不是返回**:打印继续用内置 `print` / `打印`(副作用函数),不把粗体或斜体当成「打印到终端」的语法。
### P4 — 形参由体推断(Body-inferred params)
- **不再要求**作者手写 `` + `名` `` 形参表(v0.3 默认关闭;过渡期可兼容,见 §8)。
- 函数体内:
- **只声明、未赋默认** → **必选形参**(调用时必须提供)。
- **声明同时赋值**(含默认值字面量)→ **可选形参**(带默认值)。
- 推断顺序与绑定规则见 §8;与位置/具名实参规则对齐 [call-arguments.md](call-arguments.md) 的精神(可修订附录)。
### P5 — 标记仍承载控制流(不变)
- **不引入** `if` / `else` / `while` / `for` / `def` / `return` 关键字。
- `#` = 对象/类型,`##`+ = 函数/方法([objects.md](objects.md) 不变)。
- 分支仍用 `1.` `2.` …;循环仍用 `-`;结构行不必再包粗体(见 §5)。
### P6 — 其它「代码即文档」补强(本版一并采纳)
| 思路 | 说明 |
|------|------|
| **渐进披露** | 读者可只读叙述;运行时只执行标记与推断出的声明。同一文件服务人与机器。 |
| **最小仪式** | 能从正文看出的签名,就不在函数头重复写一遍。 |
| **双调用面** | 独立行 `>` 适合「步骤清单」;行间 `**f …**` 适合「嵌在句子里的动作」。 |
| **标识符视觉统一** | 叙述、代码、形参一律优先 `` `名` ``;粗体/斜体内部允许裸名(与 v0.2 斜体/粗体内规则同类)。 |
| **段落仍可整段注释** | 不含任何可执行标记、且无「声明性 `` `名` ``」义务的纯说明段,行为与注释相同(见 §4 消歧)。 |
| **迁移可观测** | `--dump-lines` / `--dump-ast` 必须能区分「叙述中的声明」与「粗体代码」与「斜体返回」。 |
---
## 3. 与 v0.2 对照(角色对调摘要)
| 概念 | v0.2 | v0.3 |
|------|------|------|
| 程序语句 / 代码段 | `*…*` | `**…**` |
| 返回值 | `**…**` | `*…*` |
| 独立调用 | 必须 `>` | `>` **或** `**callee …**` |
| 形参 | 标题下 `` + `名` `` | **体推断**(`+` 过渡兼容) |
| 叙述中的变量 | 一般为注释,不可声明 | `` `名` `` 可声明/引用 |
| 无标记纯文字 | 成段注释 | 仍为叙述;**若含声明性反引号则参与绑定图**(见 §4) |
这是一次 **架构级标记对调**,不是局部糖。金样例、教程、Skill、扩展库需按路线图分波迁移。
---
## 4. 叙述、声明与注释
### 4.1 三层模型(修订)
| 层 | 形态 | 角色 |
|----|------|------|
| **叙述面** | 普通 Markdown 段落、列表说明 | 给人读;其中的 `` `名` `` 可进入**绑定图** |
| **可执行面** | 结构标记(`#` `>` `+` `-` `1.` 表…)+ **`**代码**`** + **`*返回*`** | 求值 |
| **外联面** | ` ```lang ` | FFI(不变) |
### 4.2 变量在叙述中的出现
语法:Markdown **行内代码** `` `标识符` ``。
| 出现形态 | 语义 |
|----------|------|
| 全文(当前函数/对象作用域)**首次**出现 `` `n` ``,且此前/同句无对 `n` 的赋值 | **声明变量**(进入绑定图;是否升为形参见 §8) |
| 已声明之后再次 `` `n` `` | **引用**(不生成新绑定) |
| 粗体内 `**n = …**` / `**n=n+1**` | **赋值**(若首次赋值且未见声明,则声明+赋值一并发生) |
| 叙述中 `` `n`=1 ``(反引号名紧贴 `=`,无粗体) | **带初值的声明**(形参默认或局部初值;见 §8) |
推荐作者写法(与动机示例一致):
```markdown
对于输入变量`n`,我们执行操作**n=n+1**接着返回*n*。
```
- `` `n` `` → 声明变量;因随后在代码中**读取**未先由局部独力定义 → 升为必选形参(§8)
- `**n=n+1**` → 代码段(赋值)
- `*n*` → 返回
### 4.3 何为「纯注释」
满足下列**全部**条件的段落,不产生绑定、不求值:
1. 不含结构标记行;
2. 不含 `**…**` / 作为返回的 `*…*`(见 §7);
3. 不含任何 `` `标识符` ``。
仍建议:**叙述段与独立结构代码行之间空一行**,降低人读与差分时的视觉粘连(解析器在 v0.3 下不再依赖「空行分段注释升级」作为唯一边界,但空行仍是作者卫生习惯)。
### 4.4 提及性反引号:一律视作变量(已决议)
**不另设「仅提及、不声明」语法。** 叙述里凡出现合法标识符 code span `` `名` ``,一律按 **变量** 处理(首次 = 声明,其后 = 引用)。
| 情况 | 处理 |
|------|------|
| 谈到某名但可执行代码**从未读写**它 | 仍是绑定图中的变量;**对求值无影响**(死绑定) |
| 与其它语言对照 | 类似 Python 写了未用局部、JS 未用 `let`——默认可忽略;实现可对「从未读写」发**可选 lint**,**不得**因此报错或拒绝运行 |
| 是否变成函数形参 | **否**(仅声明、从未在可执行面被读取)——见 §8.2「升参条件」 |
| 是否需要 `` 提及`n` `` 等前缀 | **不需要**;避免第二套反引号方言 |
例(合法、无副作用):
```markdown
## 说明性函数
本文顺便提到`Markdown`与`GFM`,但真正的输入只有`题干`。
**print text=题干**
---
```
- `` `Markdown` `` / `` `GFM` `` → 变量声明,未使用 → 不进形参表、不改行为
- `` `题干` `` → 声明且在粗体中读取 → 必选形参
**否决**:为「提及」单独做转义/前缀(曾列于开放点);若将来作者强烈需要「叙述中的等宽字但不进绑定图」,另开增强案,不阻塞 v0.3 核心。
### 4.5 成段规则相对 v0.2 的变化
v0.2:「段首无标记 → 整段注释,续行永不升级」。
v0.3:
- 叙述段落**可以**内含可执行粗体/斜体返回;解析器做**段内扫描**,抽出 `` `名` ``、`**…**`、`*…*`。
- 独立结构行(行首 `#` `>` `-` `1.` `|` 等)仍整行分类为代码。
- **否决维持**:「整行无标记 = 默认可执行代码」。无标记且无反引号声明的文字永不单独变成语句。
---
## 5. 映射总表(v0.3)
| 标记 | 语义 |
|------|------|
| `#` … `######` | `#` = 对象/类型;`##`+ = 函数/方法(同 [objects.md](objects.md)) |
| 叙述中 `` `名` `` | 声明或引用(§4) |
| `**…**` | **代码段**(赋值、表达式、调用) |
| `*…*` | **返回值**(含显式空值,见 §7.2) |
| `>` 行 | **调用**(可选面,与粗体内调用等价) |
| `` + `名` `` | **过渡兼容**:显式形参;新代码不推荐 |
| 体内 `1.` `2.` … | 分支 |
| 体内 `-` | 循环 |
| `N. *` | else 臂(此处 `*` 仍是「空条件」标记,**不是**返回值;见 §7.3) |
| GFM 表格 | 集合(不变) |
| 表达式 `[键](集合)` | **取元**(与 foreach 同形;见 [collection-access-link.md](collection-access-link.md)) |
| `修饰… [函数名] 实参…` | **方括号标记调用**(前置修饰 → `名=True`;见 [bracket-call-modifiers.md](bracket-call-modifiers.md)) |
| `` 集合[^键] `` | **过渡**:旧脚注取元(仍可用) |
| ` ```lang ` | 外联(不变) |
| 单独一行 `---` / `***` | **叙述分隔**(跳过;模块顶与函数体内相同) |
| 整行恰 `**` 或 `****` / `*None*` / `*无*` | **空返回**并结束本函数体(见 §7.2) |
### 结构行与粗体
行首已是结构标记的构造(`#` `>` `+` `-` `|`、`1.`)**不必**再包 `**…**`。
粗体用于:**嵌在叙述中的代码**,以及「我想把这一小段标成可执行」的行间片段。
---
## 6. 调用
### 6.1 调用表面
```markdown
> 加一函数 37
**加一函数 37**
礼貌 [问候] marqdo
```
前两种解析为对 `加一函数` 的调用;第三种为**方括号标记调用**(`[` `]` 标出函数名,前置裸词展开为 `名=True`)。实参位置或具名绑定;详见 [call-arguments.md](call-arguments.md) · [bracket-call-modifiers.md](bracket-call-modifiers.md)。
| 形式 | 典型用途 |
|------|----------|
| `> …` | 步骤列表、独立可执行行、与 v0.2/AI 习惯兼容 |
| `**…**` | 嵌在句子中:「或者可以直接这么调用**加一函数 37**」 |
| `**x = 加一 37**` | 粗体赋值右侧为调用时**可省略 `>`**(代码即文档首选;`> 加一 37` 仍合法) |
| `修饰… [函数] 实参…` | 叙述里需要「形容词 + 动词」时消歧;与 `[键](集合)` 取元靠 `]` 后是否紧邻 `(` 区分 |
### 6.2 粗体内调用的判别
粗体内容在去掉外层 `**` 后,按下列优先级分类:
1. 含 `=` 且左侧为可赋值目标(标识符 / 脚注左值等)→ **赋值语句**(可含右侧调用)。
2. 否则,若首词为已知函数/方法/内置/导入成员(Pass 名表可见)→ **调用**。
3. 否则 → **表达式语句**(求值后丢弃,或在语句位置非法则诊断)。
示例:
| 粗体内容 | 分类 |
|----------|------|
| `n=n+1` | 赋值 |
| `加一函数 37` | 调用 |
| `加一函数 n=37` | 调用(具名) |
| `n + 1` | 表达式(单独出现时;作返回应写 `*n + 1*`) |
| `print text=hi` / `打印 内容=你好` | 调用(内置) |
### 6.3 方法调用
- 独立行:`` > `对象`.方法 … ``(兼容)或 `> 对象.方法 …`(若接收者规则允许)。
- 粗体内:`**对象.方法 …**` / `**p = page.主体装配 组件=home**`。
- 粗体/斜体内裸名 = 变量(延续 v0.2「段内统一命名空间」精神)。
### 6.4 实参
具名 + 位置混用规则继承 [call-arguments.md](call-arguments.md);v0.3 仅把「形参列表来源」从 `+` 行改为**推断签名**(§8)。独立 `>` 行上裸词仍为文本字面量;粗体内调用的裸词为变量(与 v0.2「段内调用」一致)。
---
## 7. 返回
### 7.1 斜体返回
```markdown
*n*
*n + 1*
*"ok"*
```
斜体内部值语法与 v0.2 粗体返回内部相同(裸词 = 变量;文本须引号)。
### 7.2 空返回与收束(已决议)
Marqdo **不引入** `return` 关键字;「无值结束」用标记表达。对照常见语言:
| 语言 | 无值 / 空返回 | Marqdo v0.3 对应 |
|------|----------------|------------------|
| Python | `return` / `return None` | 显式 `*None*`·`*无*` |
| Go | 无结果函数里的 `return` | `*None*` / 整行 `**` / `****` |
| Rust | `()` 或函数末尾隐式 unit | 同上;或下一标题 / EOF 自然结束 |
| JavaScript | `return;` → `undefined` | 同上 → 运行时 `None` |
| Marqdo 历史 | `---` 收束;`****` | `---` 已改为叙述跳过;`****` 仍兼容 |
#### 形式层级(推荐自上而下)
| 优先级 | 形式 | 语义 | 说明 |
|--------|------|------|------|
| **1. 显式空值** | `*None*` 或 `*无*`(整段或行内返回位) | 返回 `None` **并结束本函数体解析** | 对齐 Python `return None`;副作用函数首选;外层续写依赖此收束 |
| **2. 空斜体标记** | **整行** trim 后恰为两个星号:`**` | 同上 | 词法钉死:`^\s*\*\*\s*$` → **空斜体返回**,**不得**当成粗体开闭 |
| **3. 兼容** | 整行 `****`(四个星号) | 同空返回 | 迁移期识别 |
| **(非收束)** | 整行 `---` / `***` | **仅叙述分隔**,跳过 | 不再结束函数;见 [code-as-docs-gaps.md](code-as-docs-gaps.md) |
```markdown
## 只打印
**print text=hi**
*None*
## 空斜体行
**print text=hi**
**
## 分割线不收束(下一标题才结束)
**print text=hi**
---
```
#### 词法消歧(空斜体 vs 粗体)
1. **整行恰好 `**`(两个 `*`)** → 空返回(规则 2),不是未闭合粗体。
2. **粗体代码**至少包住一个非空内容:`**x**`、`**n=1**`;不允许「空粗体代码段」作为语句。
3. **四个星号整行 `****`** → 兼容空返回(规则 3),不解释为「空粗体代码」。
4. 行内出现的 `**…**`(两侧还有叙述文字)按正常粗体代码扫描,不走「整行空返回」。
#### 与「有返回值」的关系
- 需要把值交回调用方 → 用非空斜体:`*n*`、`*n + 1*`(返回即结束本函数体解析)。
- 只做副作用、不要值 → 优先 `*None*` / `*无*` / 整行 `**`。
- 下一标题或 EOF 也可结束体;**不要**再靠 `---` 收束。
### 7.3 与 else 臂 `N. *` 的消歧
有序列表臂头 `2. *` 中的 `*` 表示 **else**,不是返回。判别:行匹配 `^\s*\d+\.\s+\*\s*$`(可带尾注)→ 分支 else;不进入返回扫描。
### 7.4 输出
```markdown
**print text=Hello**
> print text=Hello
```
打印是调用,不是返回。禁止把 `*Hello*` / `**Hello**` 解释为「打印 Hello」(延续 v0.2 决议精神,仅对调标记)。
---
## 8. 形参推断
### 8.1 目标签名
对每个 `## 函数`(及方法),在 Pass1 收集体之后得到:
```text
params: Vec<{ name, default: Option<Expr>, span }>
```
### 8.2 收集规则(函数作用域)
扫描该函数标题之下、下一同级/更高级标题之前的所有节点,维护**绑定图**与**形参表**(二者分离):
#### A. 绑定图(所有变量)
1. **声明事件**:叙述或代码中的首次 `` `名` ``,或粗体内首次对 `名` 的赋值左值。
2. **默认/初值事件**:叙述 `` `名`=默认表达式 ``;或符合 §8.3 的「形参默认」赋值。
3. **排除出绑定图**(不建变量):
- 循环变量 `` - [项](集合) `` 中的 `项`(循环自有绑定);
- `self` / `自`(方法自动注入)。
凡进入绑定图的名字都是**变量**——包括「只在叙述里出现、可执行代码从未读写」的名字(§4.4)。未使用 → **不报错**。
#### B. 升为形参的条件(升参)
名字已在绑定图中,且满足下列之一,才进入 `params`:
| 升参种类 | 条件 |
|----------|------|
| **必选形参** | 在可执行面(`**…**` / `*…*` / `>` / 结构语句)中存在对 `名` 的**读取**,且该读取无法单靠「不依赖外部输入的局部赋值」满足——典型:先声明、后 `n=n+1` / `*n*` / `**print text=n**` 等读到未先行赋成纯局部常量 |
| **可选形参** | 有默认/初值事件(`` `名`=… `` 或 §8.3 默认赋值),供调用方覆盖 |
**不升参**:仅叙述声明、可执行面零读取(死绑定)→ 留在绑定图,**不进** `params`,调用签名不变。
**顺序**:按升参名字的**首次声明事件**在源码中的出现序。
**仍排除**:分支/块内纯局部(金样例钉启发式);显式 `+` 合并见 §8.4。
### 8.3 「形参默认」与「函数体赋值」的区分
```markdown
## 问候
对`谁`打招呼,默认`礼貌`=False。
**print text=谁**
```
- `` `谁` `` → 必选
- `` `礼貌`=False `` → 可选,默认 `False`
- 体里的 `**print …**` 不是给 `谁` 赋默认值
```markdown
## 加一函数
输入`n`。**n=n+1**返回*n*。
```
- `` `n` `` 先声明 → 必选
- `**n=n+1**` 是**体语句**(对已声明形参赋值),**不是**默认值
判别启发式(实现契约):
- 若赋值右值**依赖同名左值**(如 `n=n+1`)→ 体语句。
- 若赋值出现在「该名被当作输入读取」之前,且右值不依赖未绑定的同名 → 可作为默认值候选。
- 叙述形 `` `名`=字面量 `` 优先视为默认值声明。
### 8.4 显式 `+` 形参(过渡)
- 若函数标题下仍有 `` + `名` `` 行:与推断结果**合并**;冲突时 **显式 `+` 胜出**并诊断警告。
- 迁移完成后(路线图 M4)可改为:存在 `+` 则关闭推断,或直接废弃 `+`。
### 8.5 调用绑定
与现有一致:具名优先,位置按「尚未绑定的形参」从左到右填充。缺必选形参 → 语义错误。
---
## 9. 完整示例(规范金样意向)
### 9.1 加一(动机例)
```markdown
## 加一函数
对于输入变量`n`,我们执行操作**n=n+1**接着返回*n*。
# main
我要调用加一函数可以采用这样的办法:
> 加一函数 37
或者可以直接这么调用**加一函数 37**
```
期望:
- 签名:`加一函数(n)`
- `# main` 两次调用均返回 `38`(第二次若未绑定到打印,至少 AST/求值结果为 38;可用 `**print text=…**` 观测)。
### 9.2 带默认值
```markdown
## 问候
向`谁`问好;`礼貌`=False 时用短句。
1. 礼貌
**print text=您好,**
**print text=谁**
2. *
**print text=嗨,**
**print text=谁**
---
# main
**问候 谁=Marqdo 礼貌=True**
> 问候 Marqdo
```
### 9.3 对象方法(不变骨架)
```markdown
# 计数器
## 加
将`self`的`值`增加`delta`(`delta`=1)。
**值 = 值 + delta**
*self*
# main
*c = > 计数器*
**c.加 3**
```
(方法形参推断含 `delta`;`self` 自动。)
---
## 10. AST / 管线变更要点(设计约束)
详细里程碑见 [markup-v0.3.md](../roadmap/markup-v0.3.md)。此处只钉**语义 → 树**的约束,供实现对照:
### 10.1 行分类(lex / line-class)
新增或调整类别:
| 类别 | 说明 |
|------|------|
| `Prose` | 叙述行;需**内联扫描** |
| `BoldCode` | 整行或片段 `**…**` |
| `ItalicReturn` | 整行或片段 `*…*`(非 else 臂) |
| `CallLine` | `>` 调用(保留) |
| … | 原有 Heading / List / Table / Fence / Hr |
**内联扫描**产出 `InlineBit`:`Text` | `IdentDecl/Ref` | `BoldCode` | `ItalicReturn`。
### 10.2 AST 节点调整(建议)
```text
Param { name, default?, inferred: bool, span } // inferred=true 表示来自体推断
Stmt::
Assign { … } // 多由 BoldCode 解析
Call { … } // CallLine 或 BoldCode 判别为调用
Return { value } // 由 ItalicReturn 解析(原由 Bold)
ExprStmt { … } // 可选:纯表达式粗体
Prose { bits } // 可选:保留叙述结构供 view/catalog;求值阶段只消费 Decl
FnDef.params:
由 InferParams(body + prose bits) 填充,再合并显式 +
```
`Stmt::Return` 的**语法来源**从粗体改为斜体;dump 文本应写 `return←italic`。
### 10.3 Pass1 / Pass2
- Pass1:收集 `#`/`##` 结构;建绑定图;跑 **ParamInfer(升参)**;登记名表。
- Pass2:粗体内调用名解析;叙述 Decl 不重复建参。
- 诊断:**必选缺失**、`+` 与推断冲突、空返回词法歧义(非整行 `**` 的残缺粗体)。
- Lint(可选、默认关或降级为 hint):绑定图中「从未读写」的死变量——**不得**当错误。
### 10.4 双后端
树遍历与字节码均消费同一 AST;字节码发射仅跟随 `Stmt`/`Expr` 变化,不感知 Markdown 标记。
---
## 11. 破坏性切换(无双模式)
**产品决定(2026-09-13):** 直接以 v0.3 为唯一运行时映射;**不**保留 `--markup v0.2` / 双 edition。旧语法金样例与库文件在迁移完成前可能失败——可接受。
| 阶段 | 行为 |
|------|------|
| 现在 | 解析器切到 v0.3;`tests/markup-v03/` 为门禁 |
| 随后 | 批量改写 `tests/structure|keywords`、`lib/`、`ext/`、Skill、`public/` |
| 文档 | `markdown-mapping.md` 改为指向本文;ADR 0005 → Accepted |
**机械改写:**
- 语句 `*a = 1*` → `**a = 1**`
- 返回 `**x**` → `*x*`
- 粗体内文本字面量须引号:`**print text="hi"**`(裸词 = 变量)
- 调用可保留 `>` 或改为粗体
- `` + `n` `` 可删,改为叙述 `` `n` `` + 升参
---
## 12. 开放问题 / 已决议
| # | 议题 | 状态 | 决议摘要 |
|---|------|------|----------|
| 1 | 空返回词法 | **已决议** | §7.2:推荐 `*None*`/`*无*`;整行 `**`;兼容 `****`;`---` 仅叙述跳过 |
| 2 | 提及性反引号 | **已决议** | §4.4:一律视作变量;未使用不报错、不升参;不设提及前缀 |
| 3 | 粗体内调用 vs 赋值 | **已落地** | §6.2:可赋值左值 → 赋值;否则表达式优先、再裸调用;`**n + 1**` = ExprStmt |
| 4 | `` `n`+1 `` 误声明 | **已落地** | Decl 名须为标识符;`` `n+1` `` 不升 Decl |
| 5 | 叙述强调斜体 vs 返回 | **已落地** | 整行 / `返回*…*` / 表达式形才当返回;`*only*` `*very important*` `*foo.bar*` 为叙述 |
| 6 | 一行多 `**…**` | **已落地** | 允许,按出现序执行(`tests/markup-v03/multi-bold.mq.md`) |
| 7 | view 展示 prose Decl | **已落地** | Structure / Functions 大纲:`inferred` 形参标注(`chip inferred`) |
---
## 13. 非目标
- 不把整篇无标记 Markdown 变成可执行程序。
- 不引入 `def` / `return` 关键字(空返回用标记,见 §7.2)。
- 不改变 `#` / `##` 对象体系与 ext 插件 ABI。
- 不在本文阶段修改解释器代码(见路线图)。
- 不为「提及」另发明一套反引号方言(§4.4)。
---
## 14. 验收标准(设计完成 ≠ 实现完成)
设计稿验收:
- [x] 哲学 P1–P6 成文
- [x] 与 v0.2 对照表
- [x] 形参推断规则可实现(含升参 vs 死绑定)
- [x] 动机示例在语义上闭合
- [x] AST/管线约束与路线图挂接
- [x] ADR 记录决策意向
- [x] **空返回**对照其它语言并钉死词法
- [x] **提及/未使用变量**政策钉死
实现验收:
- [x] 金样例夹具 `tests/markup-v03/`(`gold.rs` `markup_v03_*`)
- [x] 动机示例金样例通过(`inc-prose.mq.md`)
- [x] `--dump-ast` 可见 inferred params 与死绑定;`--dump-lines` 标注 `[decl]` / `[bold]` / `[italic]`
- [x] 空返回四种形式金样例通过
- [x] 无 v0.2 双模式(默认即 v0.3)
---
## 15. 修订历史
| 日期 | 说明 |
|------|------|
| 2026-09-13 | 初稿:叙述统一、粗体代码、斜体返回、形参体推断;Proposed |
| 2026-09-13 | 决议空返回(§7.2)与提及性反引号(§4.4);形参改为「升参」与绑定图分离(§8.2) |
| 2026-09-14 | §7.2:`---` 不再收束;返回语句结束函数体解析;空返回首选 `*None*` |
| 2026-09-14 | 取元主语法改为 `[键](集合)`;脚注取元过渡保留 |
+2 -1
View File
@@ -2,9 +2,10 @@
| | | | | |
|---|---| |---|---|
| 状态 | 已定论(修订:形参 `+`、分支 `1.`、同级再 `1.` 为新分支、标识符反引号、`-` 专用于循环) | | 状态 | **历史文档(v0.2 · 已废止为运行时)** — 现行见 **[markdown-mapping-v0.3.md](markdown-mapping-v0.3.md)** |
| 日期 | 2026-08-07 | | 日期 | 2026-08-07 |
| 取代 | v0.1 中「函数头 `-` 形参 / 裸名形参与遍历变量 / `+` 分支」 | | 取代 | v0.1 中「函数头 `-` 形参 / 裸名形参与遍历变量 / `+` 分支」 |
| 被取代 | **[markdown-mapping-v0.3.md](markdown-mapping-v0.3.md)**(粗体即代码 · 斜体即返回 · 无双模式兼容) |
| 相关 | [objects.md](objects.md) · [code-vs-comment.md](code-vs-comment.md) · [return-hr-and-code-surface.md](return-hr-and-code-surface.md) · [module-namespace.md](module-namespace.md) | | 相关 | [objects.md](objects.md) · [code-vs-comment.md](code-vs-comment.md) · [return-hr-and-code-surface.md](return-hr-and-code-surface.md) · [module-namespace.md](module-namespace.md) |
Markdown **标记即语法**。输出**不是**语言架构原语,而是内置函数 **`print`**(英文;见 [keywords.md](keywords.md))。 Markdown **标记即语法**。输出**不是**语言架构原语,而是内置函数 **`print`**(英文;见 [keywords.md](keywords.md))。
+2 -2
View File
@@ -23,9 +23,9 @@ marqdo dump FILE --stage lines|tokens|ast|sema|all
| 标志 | 阶段 | 输出内容 | | 标志 | 阶段 | 输出内容 |
|------|------|----------| |------|------|----------|
| `--dump-lines` | 行分类 | 每行:`LINE kind=Comment\|Code\|Blank` + 原文预览 | | `--dump-lines` | 行分类 | 每行:`kind=Comment\|Code\|Blank` + 原文;v0.3 行内位 `[decl n]` / `[bold …]` / `[italic …]` |
| `--dump-tokens` | 词法 | Token 流:`type lexeme line:col` | | `--dump-tokens` | 词法 | Token 流:`type lexeme line:col` |
| `--dump-ast` | 语法 | S 表达式或缩进树(模块/函数/语句) | | `--dump-ast` | 语法 | 模块/函数/语句;形参带 `inferred`;叙述死绑定 `dead=[…]` |
| `--dump-sema` | 语义 | 作用域、导入图、提升后的符号表 | | `--dump-sema` | 语义 | 作用域、导入图、提升后的符号表 |
| `--trace-eval` | 求值 | **JSON 行**(stderr):语句级事件,含 `path` / `span`(`line:col`) | | `--trace-eval` | 求值 | **JSON 行**(stderr):语句级事件,含 `path` / `span`(`line:col`) |
| `--dump-bytecode` | 字节码 | 反汇编 `Program`(指令旁带 `@line:col`;见 [bytecode.md](bytecode.md)) | | `--dump-bytecode` | 字节码 | 反汇编 `Program`(指令旁带 `@line:col`;见 [bytecode.md](bytecode.md)) |
+21 -3
View File
@@ -2,18 +2,36 @@
| | | | | |
|---|---| |---|---|
| 状态 | 已决议(并入 mapping v0.1 + keywords;2026-08-04 修订函数收束) | | 状态 | **v0.2 已决议**(现行实现);**v0.3 拟对调 `*` / `**` 角色**(见下) |
| 日期 | 2026-08-04 | | 日期 | 2026-08-04 |
| 修订 | 2026-09-13:挂接 [markdown-mapping-v0.3.md](markdown-mapping-v0.3.md) |
--- ---
## 决议 ## 决议(v0.2 · 现行)
1. **`*…*` = 程序语句**。 1. **`*…*` = 程序语句**。
2. **`**…**` = 返回值**(架构级);空粗体 `****` / `** **` = 空返回(`None`)并结束函数体。 2. **`**…**` = 返回值**(架构级);空粗体 `****` / `** **` = 空返回(`None`)并结束函数体。
3. **输出**用内置函数 **`print`**(英文),不是粗体,不是中文名。 3. **输出**用内置函数 **`print`**(英文),不是粗体,不是中文名。
4. **`---` / `***`(函数体顶层)**:结束本函数体(无返回值函数收束);**不是**分支/循环装饰框。 4. **`---` / `***`**:Markdown 叙述分隔(跳过);**不再**结束函数体。无值收束用 `*None*` / 整行 `**` / `****`(见 [markdown-mapping-v0.3.md](markdown-mapping-v0.3.md) §7.2)。
5. **成段注释**:空行分段;段内续行不因首字符升级为代码。 5. **成段注释**:空行分段;段内续行不因首字符升级为代码。
6. **否决**:无标记行 = 默认代码。 6. **否决**:无标记行 = 默认代码。
详见 [keywords.md](keywords.md)、[markdown-mapping.md](markdown-mapping.md)、[code-vs-comment.md](code-vs-comment.md)。 详见 [keywords.md](keywords.md)、[markdown-mapping.md](markdown-mapping.md)、[code-vs-comment.md](code-vs-comment.md)。
---
## v0.3 意向(Proposed · 未实现)
产品方重新审视后,拟在 [ADR 0005](../adr/0005-prose-unified-markup.md) 下**对调**架构标记,并放宽叙述面:
| 概念 | v0.2 | v0.3 草案 |
|------|------|-----------|
| 代码段 / 语句 | `*…*` | `**…**` |
| 返回值 | `**…**` | `*…*` |
| 空返回 | `****` / 空粗体;或 `---` | **推荐 `*None*`/`*无*`**;整行 `**`;兼容 `****`;`---` 仅叙述 |
| 输出 | 仍为 `print` / `打印` | 不变 |
| 无标记 = 默认代码 | 否决 | **仍否决** |
| 叙述中 `` `名` `` | 通常无绑定义 | 一律变量;未使用 OK;升参需可执行面读取 |
完整规则与迁移见 [markdown-mapping-v0.3.md](markdown-mapping-v0.3.md)。**v0.3 已为运行时;本文件历史决议中「`---` 收束」已废止。**
+5 -4
View File
@@ -11,9 +11,9 @@
| 读 | 写 | | 读 | 写 |
|----|----| |----|----|
| 脚注 `` `xs`[^1] `` / `` `m`[^key] `` / 嵌套 `` `m`[^a][^1] `` | **`table.put` / `表.改`** | | 链接取元 `[key](xs)` / `[key](m)` / 嵌套 `[1]([a](m))`(脚注 `` `m`[^k] `` 仍兼容) | **`table.put` / `表.改`** |
`put` / `改` 的 `at=`(`于=`)与脚注同构:文本键、**1-based** 整数下标,或键/下标组成的路径列表。 `put` / `改` 的 `at=`(`于=`)与取元同构:文本键、**1-based** 整数下标,或键/下标组成的路径列表。
```markdown ```markdown
--- ---
@@ -22,7 +22,7 @@ import table:lib/table.mq.md
# main # main
*`h` = > table.put in=None at=Authorization value=Bearer-x* **`h` = [table.put] in=None at="Authorization" value="Bearer-x"**
`xs` = `xs` =
@@ -31,7 +31,8 @@ import table:lib/table.mq.md
| a | | a |
| b | | b |
*`xs` = > table.put in=`xs` at=1 value=A* **`xs` = [table.put] in=`xs` at=1 value="A"**
**打印 内容=[Authorization](h)**
``` ```
`in=None` 且 `at=` 为单个文本键 → 新建单键字典。值一律不可变更新(返回新集合)。 `in=None` 且 `at=` 为单个文本键 → 新建单键字典。值一律不可变更新(返回新集合)。
+2 -1
View File
@@ -4,8 +4,9 @@
|---|---| |---|---|
| 状态 | **S0–S3 + 核心 L1 + Mid M1–M6 + Mid2 M7–M10 已落地** | | 状态 | **S0–S3 + 核心 L1 + Mid M1–M6 + Mid2 M7–M10 已落地** |
| 日期 | 2026-09-09 | | 日期 | 2026-09-09 |
| 相关 | [keywords.md](keywords.md) · [objects.md](objects.md) · [call-arguments.md](call-arguments.md) · [stdlib-i18n.md](stdlib-i18n.md) · [stdlib-modules.md](stdlib-modules.md) · [**stdlib-mid.md**](stdlib-mid.md) · [**stdlib-mid2.md**](stdlib-mid2.md) · [module-namespace.md](module-namespace.md) · [ext-abi.md](ext-abi.md) | | 相关 | [keywords.md](keywords.md) · [objects.md](objects.md) · [call-arguments.md](call-arguments.md) · [lib-code-as-docs.md](lib-code-as-docs.md) · [stdlib-i18n.md](stdlib-i18n.md) · [stdlib-modules.md](stdlib-modules.md) · [**stdlib-mid.md**](stdlib-mid.md) · [**stdlib-mid2.md**](stdlib-mid2.md) · [module-namespace.md](module-namespace.md) · [ext-abi.md](ext-abi.md) |
> **库写法(代码即文档)**:[lib-code-as-docs.md](lib-code-as-docs.md) · [roadmap/lib-ext-code-as-docs.md](../roadmap/lib-ext-code-as-docs.md)。
> **多语言库命名**:见 [stdlib-i18n.md](stdlib-i18n.md)(不设 `lang:`;中英分文件)。 > **多语言库命名**:见 [stdlib-i18n.md](stdlib-i18n.md)(不设 `lang:`;中英分文件)。
> **L1 模块清单**(含 math/foreign/plugin):见 [stdlib-modules.md](stdlib-modules.md)。 > **L1 模块清单**(含 math/foreign/plugin):见 [stdlib-modules.md](stdlib-modules.md)。
> **中层标准库 Mid(M1–M6)**:已落地——[stdlib-mid.md](stdlib-mid.md) · [roadmap/stdlib-mid.md](../roadmap/stdlib-mid.md)。 > **中层标准库 Mid(M1–M6)**:已落地——[stdlib-mid.md](stdlib-mid.md) · [roadmap/stdlib-mid.md](../roadmap/stdlib-mid.md)。
+35
View File
@@ -0,0 +1,35 @@
# View:Markup 表面保真
| | |
|---|---|
| 状态 | **Active** |
| 日期 | 2026-09-14 |
| 相关 | [view.md](view.md) · [bracket-call-modifiers.md](bracket-call-modifiers.md) · [collection-access-link.md](collection-access-link.md) · [markdown-mapping-v0.3.md](markdown-mapping-v0.3.md) |
---
## 1. 目标
`marqdo view` 的 Structure / 表达式展示应**贴近作者写出的 Markup**,而不是内部 AST 的旧拼法。读者从 view 抄回源文件时,应仍是合法、推荐的表面。
## 2. 表面对照
| AST / 概念 | View 优先显示 | 备注 |
|------------|---------------|------|
| `Expr::Index` | `[键](基)` | 嵌套 `[k2]([k1](base))` |
| `InterpPart::Index` | 同上嵌套链接形 | 不再默认 `` `base`[^k] `` |
| `CallExpr` + `bracket_marked` / `pre_modifiers` | `修饰 [callee] 实参…` 或 `[callee] 实参…` | 仅经典 `>` 解析时仍显示 `> callee …` |
| 赋值 / 返回 | 粗体 / 斜体语义即可 | 不强制还原整句叙述 |
| foreach | `- [项](集合)` | 不变 |
## 3. 非目标
- 不把 view 做成第二语法;解析真相仍在 mapping / call-arguments。
- 不删除对脚注取元、旧 `>` 调用的兼容显示需求时,可用次要提示,但默认推荐面优先。
## 4. 修订历史
| 日期 | 说明 |
|------|------|
| 2026-09-14 | 初稿;Index 链接形 + 括号调用修饰表面 |
| 2026-09-14 | `bracket_marked`:无修饰的 `[callee]` 也保真显示 |
+1 -1
View File
@@ -4,7 +4,7 @@
|---|---| |---|---|
| 状态 | 已定(v0.0.2 方向) | | 状态 | 已定(v0.0.2 方向) |
| 日期 | 2026-08-04 | | 日期 | 2026-08-04 |
| 相关 | [examples-and-tests.md](examples-and-tests.md) · [generated-yaml-manifest.md](generated-yaml-manifest.md) · 视觉参考 [id.cflmy.cn](https://id.cflmy.cn) | | 相关 | [examples-and-tests.md](examples-and-tests.md) · [view-markup-surface.md](view-markup-surface.md) · [generated-yaml-manifest.md](generated-yaml-manifest.md) · 视觉参考 [id.cflmy.cn](https://id.cflmy.cn) |
--- ---
+66
View File
@@ -0,0 +1,66 @@
# 路线图:代码即文档叙述面摩擦(G1–G4)
| | |
|---|---|
| 状态 | **Done**(实现已合入工作树;金样绿) |
| 日期 | 2026-09-14 |
| 设计 | [code-as-docs-gaps.md](../design/code-as-docs-gaps.md) |
| 样例 | `examples/code-as-docs/index.mq.md` |
---
## 里程碑
### M1 — 文档与金样夹具
- [x] 设计文档记录 G1–G4 与启发式
- [x] 本路线图
- [x] `tests/markup-v03/` 四缝金样 + `gold.rs` `markup_v03_*`
### M2 — G1 模块级 `---`
- [x] `parse_classified`:顶层 frame 行 skip;顶层 Comment 引言 skip
- [x] 函数体内 `---` / `***` 改为叙述跳过(不再收束;空返回收束)
- [x] 金样:`module-hr.mq.md`
### M3 — G3 浮点面量与运算
- [x] `Literal::Num(f64)`
- [x] `parse_primary` 识别 `digits.digits`(及 `.5` / `3.` 形态)
- [x] `eval_binary` + bytecode Int/Num 提升(Int/Int `/` 仍为整除)
- [x] 金样:`float-discount.mq.md`
### M4 — G2 叙述强调启发式
- [x] `scan_prose_line`:非代码形粗体、非返回形行内斜体 → 丢弃
- [x] 保持 `**n=n+1**`、`**加一 37**`、整行 `*n*`、「返回*n*」
- [x] 更新 Skill:允许装饰性强调;可执行仍看形状
- [x] 金样:`soft-emphasis.mq.md`
### M5 — G4 动态脚注键
- [x] AST:`IndexKey::{Lit,Var}`(`` [^`ident`] ``)
- [x] 解析、求值、bytecode
- [x] 金样:`dynamic-footnote.mq.md`
- [x] 回写 `examples/code-as-docs`(浮点折扣 + 动态键)
### M6 — 出门
- [x] `examples/code-as-docs` 展示四缝修复后的写法
- [x] `cargo test --test gold` 绿
- [x] 设计验收覆盖(见金样)
---
## 顺序建议
G1(小)→ G3(中,Literal/运算)→ G2(启发式,依赖金样钉行为)→ G4(AST 面)→ 回写样例。
---
## 修订历史
| 日期 | 说明 |
|------|------|
| 2026-09-14 | 初稿 |
| 2026-09-14 | 实现完成并勾选 |
+59
View File
@@ -0,0 +1,59 @@
# Roadmap:lib / ext 代码即文档
| | |
|---|---|
| 状态 | **Active** |
| 日期 | 2026-09-14 |
| 相关 | [lib-code-as-docs.md](../design/lib-code-as-docs.md) · [view-markup-surface.md](../design/view-markup-surface.md) · [bracket-call-modifiers.md](../design/bracket-call-modifiers.md) · [collection-access-link.md](../design/collection-access-link.md) |
---
## 0. 总序(防返工)
1. **方括号标记调用**(设计 + AST + 金样)— **已落地**
2. lib / view 设计文档 — **已写**
3. View 表面(Index 链接形、括号调用)— **已落地**
4. 分波改造 `lib/*` → `ext/*`
旧 `>` / 粗体调用、脚注取元解析均保留。
## 1. 里程碑
| 波 | 内容 | 状态 |
|----|------|------|
| **Call** | `pre_modifiers`;`tests/structure/bracket-call.mq.md`;mapping / call-arguments | **done** |
| **M0 View** | `InterpPart::Index` → `[k](base)`;`call_display` 修饰表面 | **done** |
| **M1** | 试点 `lib/table` · `lib/text` · `lib/json`(中英)+ public/stdlib | **done** |
| **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** |
| **M7** | structure collection 金样改链接形;public/stdlib 括号调用例 | **done** |
| **M8** | 教程第 9 章 + Skill examples → 链接取元 / v0.3 标记 | **done** |
| **M9** | 教程其余章节(1–8、10–12、14)全面对齐 v0.3 + 链接取元 | **done** |
| **M10** | public/stdlib 剩余演示统一括号调用;public import 返回面修到 v0.3 | **done** |
| **M11** | View:`bracket_marked` 使无修饰 `[callee]` 也显示括号形 | **done** |
## 2. 验收(出门)
- 括号调用与 `[k](c)` 取元金样并存、不回归。
- 试点库可读:目的句 + 叙述形参 + 一例 + 短实现。
- `cargo test --test gold` 绿。
- 脚注取元金样(`tests/structure/footnote*`)仍保留作兼容门禁。
- 教程与 Skill 示例以链接取元 / `**` 代码 / `*` 返回为准。
## 3. 修订历史
| 日期 | 说明 |
|------|------|
| 2026-09-14 | 初稿;Call + M0 标 done |
| 2026-09-14 | M1 试点 table/text/json + public/stdlib 标 done |
| 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 括号调用 |
| 2026-09-14 | M7 structure collection 金样 + stdlib 括号调用例 |
| 2026-09-14 | M8 教程 + Skill examples 同步 |
| 2026-09-14 | M9 教程全书对齐 v0.3 标记与链接取元 |
| 2026-09-14 | M10 public/stdlib 括号调用扫尾 + import 返回面 |
| 2026-09-14 | M11 View `bracket_marked` 无修饰括号调用表面 |
+111
View File
@@ -0,0 +1,111 @@
# 路线图:Marqdo Markdown 语法映射 v0.3(叙述统一)
「Markup」= Marqdo 把 Markdown 标记当成语法的那一层(不是另一个产品)。v0.3 = 现行映射:粗体代码、斜体返回。
| | |
|---|---|
| 状态 | **Done(v1.0.0)** |
| 日期 | 2026-09-13 |
| 设计 | [markdown-mapping-v0.3.md](../design/markdown-mapping-v0.3.md) |
| ADR | [0005-prose-unified-markup.md](../adr/0005-prose-unified-markup.md) |
| 依赖 | 现有管线 [interpreter.md](interpreter.md) · [pipeline-debug.md](../design/pipeline-debug.md) |
---
## 目标
把 v0.3 宪法落到词法 → AST → 语义 → 双后端,使动机示例(加一函数)成为金样例,并安全迁移存量代码。
---
## 里程碑
### M0 — 设计冻结与双模式骨架(文档 ✅ / 代码 ⏳)
- [x] 设计文档 + ADR Proposed + 本路线图
- [x] **钉死**:空返回词法(设计 §7.2);提及/未使用变量(§4.4);升参 vs 绑定图(§8.2)
- [x] **钉死**:一行多 `**…**` 按序执行(设计 §12 #6)
- [x] **不做双模式** — 直接 v0.3 默认
**出门:** 设计评审通过;旗标可切换;无行为默认变化。
### M1 — 内联扫描与 AST
- [x] 金样例目录 `tests/markup-v03/`(夹具 + `gold.rs` `#[ignore]`;见目录 README)
- [x] `Prose` 行内联扫描:`` `ident` `` / `**…**` / `*…*`
- [x] `Stmt::Return` ← italic;`Stmt` ← bold Assign/Call
- [x] `Param.inferred` + 升参
- [x] `tests/markup-v03/` 金样通过(默认运行时)
**出门:** `cargo test markup_v03`(无 ignore)绿。
### M2 — 形参推断
- [x] `InferParams`:首次 `` `名` `` = 必选;`` `名`=默认 `` = 可选
- [x] 体赋值 `n=n+1` 不误判为默认
- [x] 与显式 `+` 合并规则 + 警告
- [x] 方法 `self`/`自` 排除
- [x] 金样例:默认实参、位置/具名调用、粗体内调用
**出门:** 推断签名与 `+` 兼容套件绿。
### M3 — 调用面与消歧
- [x] `**callee args**` ≡ `> callee args`
- [x] else 臂 `N. *` 与返回斜体消歧
- [x] 一行多 `**…**` 按序执行
- [x] 金样例:`---` / `*None*` / 整行 `**` / 兼容 `****`;叙述死绑定不升参
- [x] 诊断:必选缺失、未知 callee(已有 errors 金样);死变量不报错
- [x] 残缺粗体:与 GAP-06/07「未闭合后恢复」冲突,保持 Comment 跳过恢复,不硬报错
- [x] 粗体内表达式语句:`**n + 1**` 求值后丢弃(非误判为调用)
- [x] 叙述斜体:仅整行 / `返回*…*` / 表达式形当返回(`*very important*` 不收束函数)
**出门:** `tests/markup-v03/*` 覆盖设计 §9 示例。
### M4 — 双后端与工具
- [x] 字节码发射跟随新 Stmt 源
- [x] `view` / Structure:推断形参 `chip inferred` + Functions 大纲标注
- [ ] (可选)`marqdo migrate markup-v03` 机械改写提示/工具
**出门:** tree 与 bytecode 后端对 `markup-v03` 金样一致。
### M5 — 默认切换与存量迁移
- [x] 默认 `MarkupEdition::V03`
- [x] 迁移 `tests/**`、`lib/**`、`ext/**`、`public/**`、教程
- [x] 更新 `.cursor/skills/marqdo/SKILL.md` 硬规则
- [x] 修订 [markdown-mapping.md](../design/markdown-mapping.md) 为 v0.3 正式正文(或声明由 v0.3 文件接任)
- [x] ADR 0005 → **Accepted**
- [x] CHANGELOG / 发版说明(破坏性:标记对调)— **v1.0.0**
**出门:** 全量 gold 默认绿(live LLM 无钥跳过);无 v0.2 双模式。
---
## 非目标(本路线)
- 不改插件 ABI / Go libweb
- 不引入 `def`/`return` 关键字
- M0–M4 不强制改生产 `.mq.md`
---
## 风险
| 风险 | 缓解 |
|------|------|
| 标记对调导致海量假失败 | 双模式 + 分目录金样;默认晚切换 |
| 形参推断误伤局部变量 | 金样例钉启发式;允许过渡期写 `+` |
| 空返回 vs `**` 词法 | §7.2 已钉:整行 `**` = 空返回;推荐优先 `---` |
| 叙述反引号误升参 | §8.2 升参需可执行面读取;死绑定不进 params |
| Skill/AI 仍按 v0.2 生成 | M5 同步 Skill;过渡期文档标明版本 |
---
## 修订历史
| 日期 | 说明 |
|------|------|
| 2026-09-13 | 初稿与设计/ADR 同步 |
| 2026-09-13 | 空返回与提及性反引号决议合入;M0 文档项勾选 |
+5 -2
View File
@@ -167,9 +167,12 @@
--- ---
## 4. 脚注取元(提案) ## 4. 脚注取元(历史 · 过渡保留)
### 4.1 为何用脚注外形 > **主语法已切换为链接形** `[键](集合)`,见 [collection-access-link.md](../design/collection-access-link.md)。
> 本节 `` 集合[^键] `` 仍由运行时接受;**新代码请写链接形**。
### 4.1 为何曾用脚注外形
- Markdown 已有 `[^…]` 引用形态,读者不陌生。 - Markdown 已有 `[^…]` 引用形态,读者不陌生。
- 避免 `篮子[0]` 与链接 / 图片语法纠缠。 - 避免 `篮子[0]` 与链接 / 图片语法纠缠。
+1 -1
View File
@@ -13,7 +13,7 @@
| 传统语言 | Marqdo | | 传统语言 | Marqdo |
|----------|--------| |----------|--------|
| 代码在 `.py`,文档在 `.md` | 代码与文档同在 `.mq.md` | | 代码在 `.py`,文档在 `.md` | 代码与文档同在 `.mq.md` |
| `def` / `if` / `for` / `return` 是关键字 | 用 Markdown 标记 `##` / `1.` / `-` / `**…**` 表达 | | `def` / `if` / `for` / `return` 是关键字 | 用 Markdown 标记 `##` / `1.` / `-` / `**代码**` / `*返回*` 表达 |
| 注释用 `#` 或 `//` | **无标记的叙述就是注释** | | 注释用 `#` 或 `//` | **无标记的叙述就是注释** |
| 大括号 `{}` 或缩进界定代码块 | 标题层级 `#` / `##` 界定作用域 | | 大括号 `{}` 或缩进界定代码块 | 标题层级 `#` / `##` 界定作用域 |
+15 -15
View File
@@ -6,8 +6,8 @@
1. **Frontmatter**(可选):文件开头的成对 `---` 之间的元信息,如标题、导入。 1. **Frontmatter**(可选):文件开头的成对 `---` 之间的元信息,如标题、导入。
2. **对象 / 函数定义**:以 `#` / `##` 开头的标题。 2. **对象 / 函数定义**:以 `#` / `##` 开头的标题。
3. **叙述注释**:无标记的普通文字段落。 3. **叙述注释**:无标记的普通文字段落(可含 `` `名` `` 声明/引用)。
4. **可执行语句**:以标记开头的行。 4. **可执行语句**:粗体代码、独立调用行、标题下的结构行等。
```markdown ```markdown
--- ---
@@ -34,7 +34,7 @@ Marqdo 的注释规则很特别:**无标记的叙述就是注释**,靠空行
# main # main
这段注释里有一行看起来像代码,但它不会执行: 这段注释里有一行看起来像代码,但它不会执行:
*not_executed = 1* **not_executed = 1**
> print text=这也是注释 > print text=这也是注释
空行之后,代码开始运行: 空行之后,代码开始运行:
@@ -44,22 +44,22 @@ Marqdo 的注释规则很特别:**无标记的叙述就是注释**,靠空行
> **注意**:叙述与可执行代码之间**必须空一行**。忘记空行会让本意是注释的文字被当作代码,或让代码被吞进注释段。 > **注意**:叙述与可执行代码之间**必须空一行**。忘记空行会让本意是注释的文字被当作代码,或让代码被吞进注释段。
## 2.3 标记一览表 ## 2.3 标记一览表(markup v0.3)
以下标记表示「这是代码」:
| 标记 | 含义 | | 标记 | 含义 |
|------|------| |------|------|
| `#` | 对象 / 类型(`# main` = 入口) | | `#` | 对象 / 类型(`# main` = 入口) |
| `##` … `######` | 函数 / 方法(嵌套按标题深度) | | `##` … `######` | 函数 / 方法(嵌套按标题深度) |
| `` + `名` `` | 函数标题下的形参 | | `` + `名` `` | 函数标题下的形参(亦可由正文 `` `名` `` 推断) |
| `1.` `2.` … | 条件分支 | | `1.` `2.` … | 条件分支 |
| `-` | 循环(遍历或 while) | | `-` | 循环(遍历或 while) |
| `> 函数 参数` | 调用 | | `> 函数 参数` | 调用(可选;粗体内可不写 `>`) |
| `*…*` | 程序语句(赋值 / 表达式) | | `修饰 [函数] 实参` | 方括号标记调用(前导词 → `名=True`) |
| `**…**` | 返回值 | | `**…**` | **代码**(赋值 / 调用) |
| `*…*` | **返回值** |
| `|` 开头的 GFM 表格 | 集合(列表 / 字典) | | `|` 开头的 GFM 表格 | 集合(列表 / 字典) |
| `---` / `***`(函数体内) | 结束函数体 | | `[键](集合)` | 链接取元 |
| 单独一行 `---` / `***` | Markdown 分隔线(跳过,**不**结束函数体) |
## 2.4 标识符与反引号 ## 2.4 标识符与反引号
@@ -75,7 +75,7 @@ Marqdo 中,**变量、参数名用反引号 `` ` `` 包裹**,这与 Markdown
- `+ `谁`` —— 声明形参 `谁` - `+ `谁`` —— 声明形参 `谁`
- `> print text=Hello, `谁`!` —— 在字符串中引用变量 `谁` - `> print text=Hello, `谁`!` —— 在字符串中引用变量 `谁`
> **注意**:反引号规则有例外。在 `*…*`(斜体语句)和 `**…**`(粗体返回)内部,**裸标识符就是变量**,反引号可以省略(详见 [第 3 章](./03-变量与赋值.md))。 > **注意**:在 `**…**`(粗体代码)和 `*…*`(斜体返回)内部,**裸标识符就是变量**,反引号可以省略(详见 [第 3 章](./03-变量与赋值.md))。
## 2.5 字面量 ## 2.5 字面量
@@ -98,7 +98,7 @@ Marqdo 的字面量:
```markdown ```markdown
> print text=Hello World! # 裸 token,按字面量 > print text=Hello World! # 裸 token,按字面量
*msg = "Hello, `name`!\n"* # 字符串,可插值、可转义 **msg = "Hello, `name`!\n"** # 字符串,可插值、可转义
``` ```
## 2.6 关键字(不可作变量名) ## 2.6 关键字(不可作变量名)
@@ -132,12 +132,12 @@ Marqdo 的字面量:
> print text=你好,`谁`! > print text=你好,`谁`!
--- *None*
## 加一 ## 加一
+ `n` + `n`
**n + 1** *n + 1*
``` ```
运行输出: 运行输出:
+23 -23
View File
@@ -2,34 +2,34 @@
## 3.1 什么是变量 ## 3.1 什么是变量
变量是给数据起的一个名字。Marqdo 中,变量在**斜体语句 `*…*`** 中通过 `=` 绑定: 变量是给数据起的一个名字。Marqdo 中,变量在**粗体代码 `**…**`** 中通过 `=` 绑定:
```markdown ```markdown
*x = 1* **x = 1**
*name = "Marqdo"* **name = "Marqdo"**
*ok = True* **ok = True**
``` ```
> **重要**:在 `*…*` / `**…**` 内部,**裸标识符就是变量**——不需要反引号。这是 Marqdo 的关键约定。 > **重要**:在 `**…**` / `*…*` 内部,**裸标识符就是变量**——不需要反引号。这是 Marqdo 的关键约定。
## 3.2 绑定的三种写法 ## 3.2 绑定的三种写法
### 写法一:斜体语句 `*…*`(推荐) ### 写法一:粗体代码 `**…**`(推荐)
```markdown ```markdown
*x = 1* **x = 1**
*y = x + 2* **y = x + 2**
``` ```
这是最常用的绑定方式。裸标识符就是变量。 这是最常用的绑定方式。裸标识符就是变量。
### 写法二:行首反引号绑定(无 `*…*`) ### 写法二:行首反引号绑定(无粗体)
```markdown ```markdown
`x` = 1 `x` = 1
``` ```
不带 `*…*` 的绑定,变量名**需要反引号**。常用于绑定集合(表格)或公式: 不带 `**…**` 的绑定,变量名**需要反引号**。常用于绑定集合(表格)或公式:
```markdown ```markdown
`篮子` = `篮子` =
@@ -42,29 +42,29 @@
### 写法三:绑定调用结果 ### 写法三:绑定调用结果
```markdown ```markdown
*len_s = > len value="hello"* **len_s = > len value="hello"**
``` ```
`*…*` 内用 `= >` 表示「把调用结果赋给变量」。 粗体内用 `= >` 表示「把调用结果赋给变量」;也可写成无 `>` 的调用形:`**len_s = len value="hello"**`。
## 3.3 引用变量 ## 3.3 引用变量
在 `*…*` 内部,直接写变量名即可: 在 `**…**` / `*…*` 内部,直接写变量名即可:
```markdown ```markdown
*a = 5* **a = 5**
*b = a * 2* **b = a * 2**
> print text=`b` # 独立 > 调用中,变量要反引号 > print text=`b` # 独立 > 调用中,变量要反引号
``` ```
> **关键区别**:在**独立 `>` 调用**(如 `> print …`)里,裸词是**文本**,所以引用变量要加反引号:`> print text=`b``。而在 `*…*` / `**…**` 内,裸词是**变量**:`*b = a * 2*`。 > **关键区别**:在**独立 `>` 调用**(如 `> print …`)里,裸词是**文本**,所以引用变量要加反引号:`> print text=`b``。而在 `**…**` / `*…*` 内,裸词是**变量**:`**b = a * 2**`。
## 3.4 字符串与插值 ## 3.4 字符串与插值
### 双引号字符串 ### 双引号字符串
```markdown ```markdown
*msg = "Hello, World!"* **msg = "Hello, World!"**
``` ```
### 转义字符 ### 转义字符
@@ -87,8 +87,8 @@
字符串内用 `` `变量` `` 插值: 字符串内用 `` `变量` `` 插值:
```markdown ```markdown
*name = "Marqdo"* **name = "Marqdo"**
*msg = "Hello, `name`!"* **msg = "Hello, `name`!"**
> print text=`msg` # 输出:Hello, Marqdo! > print text=`msg` # 输出:Hello, Marqdo!
``` ```
@@ -97,14 +97,14 @@
```markdown ```markdown
# main # main
*name = "Alice"* **name = "Alice"**
*age = 30* **age = 30**
*next_age = age + 1* **next_age = age + 1**
> print text=名字:`name` > print text=名字:`name`
> print text=明年:`next_age` 岁 > print text=明年:`next_age` 岁
*msg = "你好,`name`!你明年 `next_age` 岁。"* **msg = "你好,`name`!你明年 `next_age` 岁。"**
> print text=`msg` > print text=`msg`
``` ```
+12 -10
View File
@@ -2,7 +2,7 @@
## 4.1 输出:`print` / `打印` ## 4.1 输出:`print` / `打印`
`print`(中文 `打印`)是内置函数,用于向标准输出写一行文本。**输出不是 `**粗体**`**——粗体是返回值,不是打印。 `print`(中文 `打印`)是内置函数,用于向标准输出写一行文本。**输出不是粗体、也不是斜体**——粗体是代码,斜体是返回;打印是普通函数调用。
```markdown ```markdown
# main # main
@@ -20,19 +20,21 @@
|------|------|------| |------|------|------|
| `> print text=…` | `> 打印 内容=…` | `text` ≡ `内容` | | `> print text=…` | `> 打印 内容=…` | `text` ≡ `内容` |
粗体内也可写:`**打印 内容="你好"**`(文本字面量须加引号)。
### 输出变量 ### 输出变量
独立 `>` 调用中,变量用反引号: 独立 `>` 调用中,变量用反引号:
```markdown ```markdown
*x = 42* **x = 42**
> print text=`x` # 输出:42 > print text=`x` # 输出:42
``` ```
### 输出拼接 ### 输出拼接
```markdown ```markdown
*name = "Marqdo"* **name = "Marqdo"**
> print text=欢迎使用 `name`! > print text=欢迎使用 `name`!
``` ```
@@ -55,7 +57,7 @@
```markdown ```markdown
# main # main
*name = > input prompt="请输入名字:"* **name = > input prompt="请输入名字:"**
> print text=你好,`name`! > print text=你好,`name`!
``` ```
@@ -68,10 +70,10 @@
这是一个人机问答程序。 这是一个人机问答程序。
*name = > input prompt="你叫什么名字?\n"* **name = > input prompt="你叫什么名字?\n"**
> print text=你好,`name`! > print text=你好,`name`!
*age = > int value=`age_input`* **age = > int value=`age_input`**
``` ```
> **注意**:上面的示例为了展示 `int` 用法,`age_input` 尚未定义。实际中你需要先从 `input` 得到字符串,再用 `int` 转换。完整可运行版本: > **注意**:上面的示例为了展示 `int` 用法,`age_input` 尚未定义。实际中你需要先从 `input` 得到字符串,再用 `int` 转换。完整可运行版本:
@@ -79,12 +81,12 @@
```markdown ```markdown
# main # main
*name = > input prompt="你叫什么名字?\n"* **name = > input prompt="你叫什么名字?\n"**
> print text=你好,`name`! > print text=你好,`name`!
*age_str = > input prompt="你几岁?\n"* **age_str = > input prompt="你几岁?\n"**
*age = > int value=`age_str`* **age = > int value=`age_str`**
*next_age = age + 1* **next_age = age + 1**
> print text=`name`,你明年 `next_age` 岁。 > print text=`name`,你明年 `next_age` 岁。
``` ```
+19 -19
View File
@@ -2,16 +2,16 @@
## 5.1 算术运算符 ## 5.1 算术运算符
在 `*…*` 表达式内部: 在 `**…**` 表达式内部:
```markdown ```markdown
*a = 10* **a = 10**
*b = 3* **b = 3**
*sum = a + b* # 13 **sum = a + b** # 13
*diff = a - b* # 7 **diff = a - b** # 7
*prod = a * b* # 30 **prod = a * b** # 30
*quo = a / b* # 3.33…(浮点除法) **quo = a / b** # 3.33…(浮点除法)
``` ```
| 运算符 | 含义 | | 运算符 | 含义 |
@@ -28,13 +28,13 @@
`+` 也可以拼接字符串: `+` 也可以拼接字符串:
```markdown ```markdown
*first = "Hello, "* **first = "Hello, "**
*second = "World!"* **second = "World!"**
*msg = first + second* **msg = first + second**
> print text=`msg` # Hello, World! > print text=`msg` # Hello, World!
``` ```
> 在 `*…*` 内变量是裸名;若拼接的是字符串字面量,要加引号。 > 在 `**…**` 内变量是裸名;若拼接的是字符串字面量,要加引号。
## 5.3 比较运算符 ## 5.3 比较运算符
@@ -47,7 +47,7 @@
| `<=` | 小于等于 | | `<=` | 小于等于 |
```markdown ```markdown
*n = 5* **n = 5**
1. `n` > 3 1. `n` > 3
> print text=大于 3 > print text=大于 3
@@ -64,8 +64,8 @@
| `not` | `非` | 逻辑非 | | `not` | `非` | 逻辑非 |
```markdown ```markdown
*age = 20* **age = 20**
*has_id = True* **has_id = True**
1. `age` >= 18 and `has_id` 1. `age` >= 18 and `has_id`
> print text=可以进入 > print text=可以进入
@@ -78,7 +78,7 @@
布尔值字面量:`True` / `False`(中文 `真` / `假`)。 布尔值字面量:`True` / `False`(中文 `真` / `假`)。
```markdown ```markdown
*is_admin = False* **is_admin = False**
1. `is_admin` == True 1. `is_admin` == True
> print text=管理员 > print text=管理员
@@ -89,7 +89,7 @@
也可以直接用布尔变量作条件: 也可以直接用布尔变量作条件:
```markdown ```markdown
*flag = True* **flag = True**
1. `flag` 1. `flag`
> print text=为真 > print text=为真
@@ -102,9 +102,9 @@
```markdown ```markdown
# main # main
*score = 85* **score = 85**
*passed = score >= 60* **passed = score >= 60**
*bonus = passed and score >= 80* **bonus = passed and score >= 80**
> print text=及格:`passed` > print text=及格:`passed`
> print text=优秀:`bonus` > print text=优秀:`bonus`
+33 -21
View File
@@ -8,18 +8,18 @@
## 加一 ## 加一
+ `n` + `n`
**n + 1** *n + 1*
``` ```
- `## 加一` —— 函数名 - `## 加一` —— 函数名
- `+ `n`` —— 参数 - `+ `n`` —— 参数
- `**n + 1**` —— 返回值(**粗体 = 返回**) - `*n + 1*` —— 返回值(**斜体 = 返回**)
函数可以挂在 `# main` 之下作为嵌套函数,也可以作为顶层自由函数。 函数可以挂在 `# main` 之下作为嵌套函数,也可以作为顶层自由函数。
## 6.2 调用函数 ## 6.2 调用函数
使用 `>` 调用(具名参数或位置参数): 使用 `>` 或粗体内调用(具名参数或位置参数):
```markdown ```markdown
# main # main
@@ -32,7 +32,7 @@
> print text=Hello, `who`! > print text=Hello, `who`!
--- *None*
``` ```
### 具名 vs 位置 ### 具名 vs 位置
@@ -46,6 +46,17 @@
> 具名实参的值可以含空格,直到下一个 `名=` 边界;位置实参是单个词法单元(不含空格)。 > 具名实参的值可以含空格,直到下一个 `名=` 边界;位置实参是单个词法单元(不含空格)。
### 方括号标记调用
可用 `[函数名]` 标出被调函数;`[` 前的裸词会变成布尔修饰(`名=True`):
```markdown
> 问候 谁=小明 礼貌=True
礼貌 [问候] 小明
```
`]` 后**紧邻** `(` 是链接取元,不是调用(见[第 9 章](./09-集合.md))。
## 6.3 参数与默认值 ## 6.3 参数与默认值
可选参数用 `=默认值`: 可选参数用 `=默认值`:
@@ -66,17 +77,18 @@
```markdown ```markdown
> 问候 谁=小明 > 问候 谁=小明
> 问候 谁=小明 礼貌=True > 问候 谁=小明 礼貌=True
礼貌 [问候] 小明
``` ```
## 6.4 返回值:`**…**` ## 6.4 返回值:`*…*`
用 `**…**` 返回表达式结果: 用 `*…*` 返回表达式结果:
```markdown ```markdown
## 加一 ## 加一
+ `n` + `n`
**n + 1** *n + 1*
``` ```
调用并绑定结果: 调用并绑定结果:
@@ -84,19 +96,19 @@
```markdown ```markdown
# main # main
*b = > 加一 n=1* **b = > 加一 n=1**
> print text=`b` # 2 > print text=`b` # 2
``` ```
### 返回 None:`****` ### 返回 None
`****`(或空粗体 `**` + 空白 + `**`)返回 `None` 并结束函数体: 推荐 `*None*` / `*无*`;也可整行空粗体 `**` 或 `****`:
```markdown ```markdown
## 静默 ## 静默
+ `x` + `x`
**** *None*
``` ```
### 字符串返回 ### 字符串返回
@@ -105,12 +117,12 @@
## 问候语 ## 问候语
+ `谁` + `谁`
**"你好," + 谁 + "!"** *"你好," + 谁 + "!"*
``` ```
## 6.5 结束函数体:`---` / `***` ## 6.5 结束函数体
对于**没有返回值、只有副作用**的函数,用单独一行 `---` 或 `***` 结束函数体,避免后续兄弟语句被吞掉: 副作用函数用斜体返回收束,避免后续兄弟语句被吞进本函数:
```markdown ```markdown
# main # main
@@ -122,20 +134,20 @@
> print text=Hello, `谁`! > print text=Hello, `谁`!
--- *None*
## 下一个函数 ## 下一个函数
... ...
``` ```
> `---` 仅在**函数体顶层单独一行**时表示「结束本函数」;文件开头的成对 `---` 是 frontmatter,不会混淆。 > 单独一行的 `---` / `***` 只是 Markdown 分隔线(跳过),**不再**表示结束函数体。文件开头的成对 `---` 仍是 frontmatter。
## 6.6 完整示例 ## 6.6 完整示例
```markdown ```markdown
# main # main
> 问候 谁=Alice 礼貌=True 礼貌 [问候] Alice
## 问候 ## 问候
+ `谁` + `谁`
@@ -146,12 +158,12 @@
2. * 2. *
> print text=嗨,`谁`! > print text=嗨,`谁`!
--- *None*
## 加一 ## 加一
+ `n` + `n`
**n + 1** *n + 1*
``` ```
输出: 输出:
@@ -172,13 +184,13 @@
## 处理 ## 处理
+ `名字` + `名字`
*上 = > 大写 文本=`名字`* **上 = > 大写 文本=`名字`**
> print text=`上` > print text=`上`
### 大写 ### 大写
+ `文本` + `文本`
**> str `文本`** *> str `文本`*
``` ```
> 深度约定:`##` 是 `#` 的子级,`###` 是 `##` 的子级……按标题深度嵌套。 > 深度约定:`##` 是 `#` 的子级,`###` 是 `##` 的子级……按标题深度嵌套。
+9 -9
View File
@@ -7,7 +7,7 @@ Marqdo 用**有序列表** `1.` `2.` `3.` … 表达条件分支:
```markdown ```markdown
# main # main
*n = 5* **n = 5**
1. `n` > 0 1. `n` > 0
> print text=正数 > print text=正数
@@ -32,7 +32,7 @@ Marqdo 用**有序列表** `1.` `2.` `3.` … 表达条件分支:
在 `1.` 之后的任意臂上,**整行恰为 `*`** 表示 else: 在 `1.` 之后的任意臂上,**整行恰为 `*`** 表示 else:
```markdown ```markdown
*age = 15* **age = 15**
1. `age` >= 18 1. `age` >= 18
> print text=成年 > print text=成年
@@ -43,7 +43,7 @@ Marqdo 用**有序列表** `1.` `2.` `3.` … 表达条件分支:
## 7.3 布尔分支 ## 7.3 布尔分支
```markdown ```markdown
*is_admin = False* **is_admin = False**
1. `is_admin` 1. `is_admin`
> print text=管理员 > print text=管理员
@@ -54,7 +54,7 @@ Marqdo 用**有序列表** `1.` `2.` `3.` … 表达条件分支:
## 7.4 多条件分支 ## 7.4 多条件分支
```markdown ```markdown
*score = 85* **score = 85**
1. `score` >= 90 1. `score` >= 90
> print text=优秀 > print text=优秀
@@ -69,8 +69,8 @@ Marqdo 用**有序列表** `1.` `2.` `3.` … 表达条件分支:
## 7.5 逻辑组合条件 ## 7.5 逻辑组合条件
```markdown ```markdown
*age = 25* **age = 25**
*has_id = True* **has_id = True**
1. `age` >= 18 and `has_id` 1. `age` >= 18 and `has_id`
> print text=可以进入 > print text=可以进入
@@ -85,8 +85,8 @@ Marqdo 用**有序列表** `1.` `2.` `3.` … 表达条件分支:
```markdown ```markdown
# main # main
*a = True* **a = True**
*b = False* **b = False**
1. `a` 1. `a`
> print text=A 为真 > print text=A 为真
@@ -113,7 +113,7 @@ B 为假
```markdown ```markdown
# main # main
*score = 72* **score = 72**
1. `score` >= 90 1. `score` >= 90
> print text=评级:A > print text=评级:A
+6 -6
View File
@@ -61,7 +61,7 @@ Marqdo 用 `-`(无序列表)表达循环。遍历列表用 `- [项](集合)`
黄瓜 黄瓜
``` ```
> 遍历字典遍历的是键;要取值,用脚注取元(见[第 9 章](./09-集合.md))。 > 遍历字典遍历的是键;要取值,用链接取元 `[键](集合)`(见[第 9 章](./09-集合.md))。
## 8.3 while 循环:`- 条件` ## 8.3 while 循环:`- 条件`
@@ -70,11 +70,11 @@ Marqdo 用 `-`(无序列表)表达循环。遍历列表用 `- [项](集合)`
```markdown ```markdown
# main # main
*n = 3* **n = 3**
- `n` > 0 - `n` > 0
> print text=`n` > print text=`n`
*n = n - 1* **n = n - 1**
``` ```
输出: 输出:
@@ -85,7 +85,7 @@ Marqdo 用 `-`(无序列表)表达循环。遍历列表用 `- [项](集合)`
1 1
``` ```
> 循环体内用 `*…*` 语句更新变量。 > 循环体内用 `**…**` 语句更新变量。
## 8.4 嵌套循环 ## 8.4 嵌套循环
@@ -160,10 +160,10 @@ B2
| 4 | | 4 |
| 5 | | 5 |
*sum = 0* **sum = 0**
- [n](数字) - [n](数字)
*sum = sum + n* **sum = sum + n**
> print text=总和:`sum` > print text=总和:`sum`
``` ```
+27 -26
View File
@@ -14,7 +14,7 @@ Marqdo 用 **GFM 表格**直接构造数据集合。表格的**几何形状**决
| 值 | 值 | | 值 | 值 |
``` ```
表格绑定变量名**需要反引号**(不在 `*…*` 内)。 表格绑定变量名**需要反引号**(不在粗体代码 `**…**` 内时)。
## 9.2 单列竖表 → 列表(List) ## 9.2 单列竖表 → 列表(List)
@@ -101,63 +101,64 @@ Marqdo 用 **GFM 表格**直接构造数据集合。表格的**几何形状**决
| ≥2 列 + 0 行 | `Map`(键存在,值空列表) | | ≥2 列 + 0 行 | `Map`(键存在,值空列表) |
| 首列 `@`/`行`/`row` | `List` of `Map`(行向记录) | | 首列 `@`/`行`/`row` | `List` of `Map`(行向记录) |
## 9.7 脚注取元:`[^…]` ## 9.7 链接取元:`[键](集合)`
用 Markdown 脚注外形从集合取元素(**表达式级**,可链式)。 主语法与 foreach 同形:**方括号 = 取出的名字,圆括号 = 从哪取**(见 [collection-access-link.md](../design/collection-access-link.md))。
### 从列表按下标取 ### 从列表按下标取
**下标是 1-based**(与人类读表一致): **下标是 1-based**(与人类读表一致):
```markdown ```markdown
*第一 = 篮子[^1]* **第一 = [1](篮子)**
> print text=`第一` # 苹果 **打印 内容=`第一`**
``` ```
### 从字典按键取 ### 从字典按键取
```markdown ```markdown
*种 = 分类[^苹果]* **种 = [苹果](分类)**
> print text=`种` # 水果 **打印 内容=`种`**
```
### 动态键
```markdown
**名 = "拿铁"**
**价 = [`名`](菜单)**
``` ```
### 嵌套取元 ### 嵌套取元
```markdown ```markdown
*第一种苹果 = 货架[^苹果][^1]* # 先键,再下标 → 红富士 **第一种苹果 = [1]([苹果](货架))**
```
### 基名的反引号
`` 名[^键] `` 与 `` `名`[^键] `` 等价(紧跟 `[^` 时可省略反引号):
```markdown
*种 = `分类`[^苹果]*
``` ```
### 插值中的取元 ### 插值中的取元
在**调用实参值 / 引号字符串**里,`` `变量` `` 后**紧跟**(无空白)`[^…]` 时也按取元解析,而不必先绑定再输出: 在**调用实参值 / 引号字符串**里也可以写链接取元(或过渡期的脚注形):
```markdown ```markdown
> print text=苹果单价:`水果价格`[^苹果] # 输出:苹果单价:5 > print text=苹果单价:[苹果](`水果价格`)
> print text=第一种:`货架`[^苹果][^1] # 链式取元 → 红富士 > print text=第一种:[1]([苹果](`货架`))
> print text="价 `水果价格`[^香蕉] 元" # 引号字符串内也可取元 → 价 3 元
``` ```
> 规则:`` `变量` [^…] ``(**有空白**)时 `[^…]` 仍是普通文本;只有 `` `变量`[^…] ``(无空白)才算取元。 ### 过渡:脚注取元 `` 集合[^键] ``
旧写法 `` 分类[^苹果] `` / `` `分类`[^苹果] `` **仍可解析**;新代码与教程示例请用链接形。脚注兼容金样见 `tests/structure/footnote*`。
> 规则: > 规则:
> - **List**:标签须为纯数字(1-based);`[^0]` 或越界 → 报错。 > - **List**:键须为纯数字(1-based);`[0](…)` 或越界 → 报错。
> - **Map**:标签为键文本(含纯数字键,如 `[^00]`);缺键 → 报错。 > - **Map**:键为键文本;缺键 → 报错。
> - 文末的 `[^1]: …` 定义块仍是注释,与取元无关。 > - 文末的 `[^1]: …` 定义块仍是注释,与取元无关。
> - `]` 后**紧邻** `(` 才是取元;否则 `[名字]` 可能是[方括号标记调用](../design/bracket-call-modifiers.md)。
## 9.8 表格单元格是表达式 ## 9.8 表格单元格是表达式
数据单元格支持表达式(与调用实参值语法相同):裸词、数字、`` `var` ``、算术、引号串。URL / `gpt-4o-mini` 等按路径/连字符折叠为文本。 数据单元格支持表达式(与调用实参值语法相同):裸词、数字、`` `var` ``、算术、引号串。URL / `gpt-4o-mini` 等按路径/连字符折叠为文本。
```markdown ```markdown
*k = "secret"* **k = "secret"**
`cfg` = `cfg` =
@@ -177,7 +178,7 @@ Marqdo 用 **GFM 表格**直接构造数据集合。表格的**几何形状**决
|------|------| |------|------|
| 5 | 3 | | 5 | 3 |
> print text=苹果单价:`水果价格`[^苹果] **打印 内容="苹果单价:" + [苹果](水果价格)**
`购物单` = `购物单` =
@@ -187,7 +188,7 @@ Marqdo 用 **GFM 表格**直接构造数据集合。表格的**几何形状**决
| 2 | 香蕉 | 3 | | 2 | 香蕉 | 3 |
- [行](购物单) - [行](购物单)
> print text=`行`[^品名] × `行`[^数量] **打印 内容=[品名](行) + " × " + [数量](行)**
``` ```
输出: 输出:
+45 -45
View File
@@ -10,13 +10,13 @@ Marqdo 用 `#` 标题定义**对象 / 类型**,用 `##` 定义其下的**方
# 大模型 # 大模型
+ `模型名` + `模型名`
*配置 = > json.parse text={"model":"gpt-4o-mini"}* **配置 = > json.parse text={"model":"gpt-4o-mini"}**
**配置** *配置*
``` ```
- `# 大模型` —— 类型名 - `# 大模型` —— 类型名
- `+ `模型名`` —— 构造参数 - `+ `模型名`` —— 构造参数
- 构造体执行后 `**…**` 返回一个 map,运行时写入 `_type` 字段,形成实例句柄 - 构造体执行后 `*…*` 返回一个 map,运行时写入 `_type` 字段,形成实例句柄
## 10.2 构造实例 ## 10.2 构造实例
@@ -25,27 +25,27 @@ Marqdo 用 `#` 标题定义**对象 / 类型**,用 `##` 定义其下的**方
```markdown ```markdown
# main # main
*模型 = > 大模型 模型名="gpt-4o-mini"* **模型 = > 大模型 模型名="gpt-4o-mini"**
``` ```
## 10.3 定义方法 ## 10.3 定义方法
对象下的 `##` 标题是方法: 对象下的 `##` 标题是方法。读字段优先用链接取元;写字段可用 `json.set` / `table.put`(跨边界序列化时再用 `json.*`):
```markdown ```markdown
# 计数器 # 计数器
+ `初始值` + `初始值`
*状态 = > json.parse text={"n":0}* **状态 = > json.parse text={"n":0}**
*状态 = > json.set map=`状态` key="n" value=`初始值`* **状态 = > json.set map=`状态` key="n" value=`初始值`**
**状态** *状态*
## 加一 ## 加一
*n = > json.get value=`self` key="n"* **n = [n](self)**
*n2 = n + 1* **n2 = n + 1**
*t = > json.set map=`self` key="n" value=`n2`* **t = > json.set map=`self` key="n" value=`n2`**
**t** *t*
``` ```
方法体内自动绑定: 方法体内自动绑定:
@@ -60,18 +60,18 @@ Marqdo 用 `#` 标题定义**对象 / 类型**,用 `##` 定义其下的**方
### 独立 `>` 调用(接收者加反引号) ### 独立 `>` 调用(接收者加反引号)
```markdown ```markdown
*计数器 = > 计数器 初始值=3* **计数器 = > 计数器 初始值=3**
*新值 = > `计数器`.加一* **新值 = > `计数器`.加一**
``` ```
### `*…*` 段内调用(接收者裸名) ### 粗体代码段内调用(接收者裸名)
```markdown ```markdown
*计数器 = > 计数器 初始值=3* **计数器 = > 计数器 初始值=3**
*新值 = > 计数器.加一* **新值 = > 计数器.加一**
``` ```
> **重要**:在 `*…*` / `**…**` 段内,裸词是变量,所以**方法接收者不加反引号**:`*新值 = > 计数器.加一*`。而在独立 `>` 调用中,裸词是文本,接收者需要反引号:`> `计数器`.加一`。 > **重要**:在 `**…**` / `*…*` 段内,裸词是变量,所以**方法接收者不加反引号**:`**新值 = > 计数器.加一**`。而在独立 `>` 调用中,裸词是文本,接收者需要反引号:`` > `计数器`.加一 ``。
## 10.5 完整对象示例 ## 10.5 完整对象示例
@@ -84,27 +84,27 @@ import json:lib/json.mq.md
# main # main
*c = > 计数器 初始值=5* **c = > 计数器 初始值=5**
*ty = > json.get value=`c` key="_type"* **ty = [_type](c)**
> print text=类型:`ty` > print text=类型:`ty`
*c2 = > c.加一* **c2 = > c.加一**
*n = > json.get value=`c2` key="n"* **n = [n](c2)**
> print text=加一后:`n` > print text=加一后:`n`
# 计数器 # 计数器
+ `初始值` + `初始值`
*状态 = > json.parse text={"n":0}* **状态 = > json.parse text={"n":0}**
*状态 = > json.set map=`状态` key="n" value=`初始值`* **状态 = > json.set map=`状态` key="n" value=`初始值`**
**状态** *状态*
## 加一 ## 加一
*n = > json.get value=`self` key="n"* **n = [n](self)**
*n2 = n + 1* **n2 = n + 1**
*t = > json.set map=`self` key="n" value=`n2`* **t = > json.set map=`self` key="n" value=`n2`**
**t** *t*
``` ```
输出: 输出:
@@ -122,16 +122,16 @@ import json:lib/json.mq.md
## hello ## hello
+ `who` + `who`
*msg = "Hello, `who`!"* **msg = "Hello, `who`!"**
**msg** *msg*
# Loud = > Greeter # Loud = > Greeter
## hello ## hello
+ `who` + `who`
*msg = "HELLO, `who`!"* **msg = "HELLO, `who`!"**
**msg** *msg*
``` ```
规则: 规则:
@@ -152,9 +152,9 @@ import json:lib/json.mq.md
# Child = > Parent # Child = > Parent
+ `name` + `name`
*self = > Parent name=`name`* **self = > Parent name=`name`**
*self = > json.set map=`self` key="role" value="child"* **self = > json.set map=`self` key="role" value="child"**
**self** *self*
``` ```
## 10.7 完整继承示例 ## 10.7 完整继承示例
@@ -162,25 +162,25 @@ import json:lib/json.mq.md
```markdown ```markdown
# main # main
*c = > Child name="Ada"* **c = > Child name="Ada"**
*ty = > json.get value=`c` key="_type"* **ty = [_type](c)**
*role = > json.get value=`c` key="role"* **role = [role](c)**
> print text=`ty` > print text=`ty`
> print text=`role` > print text=`role`
# Parent # Parent
+ `name` + `name`
*out = > json.parse text={"role":"parent"}* **out = > json.parse text={"role":"parent"}**
*out = > json.set map=`out` key="name" value=`name`* **out = > json.set map=`out` key="name" value=`name`**
**out** *out*
# Child = > Parent # Child = > Parent
+ `name` + `name`
*self = > Parent name=`name`* **self = > Parent name=`name`**
*self = > json.set map=`self` key="role" value="child"* **self = > json.set map=`self` key="role" value="child"**
**self** *self*
``` ```
输出: 输出:
+12 -10
View File
@@ -41,8 +41,8 @@ import json:lib/json.mq.md
# main # main
*t = > time.now_unix* **t = > time.now_unix**
*s = > time.format unix=`t` pattern="%Y-%m-%d"* **s = > time.format unix=`t` pattern="%Y-%m-%d"**
> print text=`s` > print text=`s`
``` ```
@@ -60,7 +60,7 @@ import agent:ext/ai/agent.mq.md
# main # main
*助手 = > agent.agent model="gpt-4o-mini"* # 库 → 类型:构造 **助手 = > agent.agent model="gpt-4o-mini"** # 库 → 类型:构造
``` ```
`agent.agent` —— `agent` 库中的 `agent` 类型(构造)。 `agent.agent` —— `agent` 库中的 `agent` 类型(构造)。
@@ -77,8 +77,8 @@ import fmt:time.format
# main # main
*t = > time.now_unix* **t = > time.now_unix**
*s = > fmt unix=`t` pattern="%Y-%m-%d"* **s = > fmt unix=`t` pattern="%Y-%m-%d"**
``` ```
`fmt` 现在是 `time.format` 的短名。 `fmt` 现在是 `time.format` 的短名。
@@ -94,7 +94,7 @@ import fmt:time.format
|------|------| |------|------|
| `time.parse` | 库路径(裸名,第一段非变量) | | `time.parse` | 库路径(裸名,第一段非变量) |
| `` > `助手`.step `` | 独立 `>` 调用:实例方法(接收者反引号) | | `` > `助手`.step `` | 独立 `>` 调用:实例方法(接收者反引号) |
| `*回复 = > 助手.step …*` | `*…*` 段内:`助手` 是变量 → 实例方法;否则 → 库路径 | | `**回复 = > 助手.step …**` | 粗体代码段内:`助手` 是变量 → 实例方法;否则 → 库路径 |
```markdown ```markdown
--- ---
@@ -103,8 +103,8 @@ import agent:ext/ai/agent.mq.md
# main # main
*助手 = > agent.agent model="gpt-4o-mini"* **助手 = > agent.agent model="gpt-4o-mini"**
*out = > 助手.step task="你好"* # 助手是变量 → 方法调用 **out = > 助手.step task="你好"** # 助手是变量 → 方法调用
``` ```
## 11.7 完整示例:多模块程序 ## 11.7 完整示例:多模块程序
@@ -125,7 +125,7 @@ project/
## 加倍 ## 加倍
+ `n` + `n`
**n * 2** *n * 2*
``` ```
`lib/问候.mq.md`: `lib/问候.mq.md`:
@@ -135,6 +135,8 @@ project/
+ `谁` + `谁`
> print text=你好,`谁`! > print text=你好,`谁`!
*None*
``` ```
`main.mq.md`: `main.mq.md`:
@@ -147,7 +149,7 @@ import 问候:lib/问候.mq.md
# main # main
*结果 = > 数学.加倍 n=21* **结果 = > 数学.加倍 n=21**
> print text=`结果` > print text=`结果`
> 问候.你好 谁=世界 > 问候.你好 谁=世界
+12 -13
View File
@@ -17,8 +17,8 @@ Marqdo 内置函数无需导入即可使用;更丰富的能力通过导入 `li
> print text=Hello > print text=Hello
*s = "Marqdo"* **s = "Marqdo"**
*n = > len value=`s`* **n = > len value=`s`**
> print text=长度:`n` > print text=长度:`n`
``` ```
@@ -61,15 +61,15 @@ import json:lib/json.mq.md
# main # main
*obj = > json.parse text={"a":1}* **obj = > json.parse text={"a":1}**
*out = > json.stringify value=`obj`* **out = > json.stringify value=`obj`**
> print text=`out` # {"a":1} > print text=`out` # {"a":1}
*nl = > json.parse text={"n":"\n"}* **nl = > json.parse text={"n":"\n"}**
> print text=第一行`nl`[^n]第二行 # 换行还原 > print text=第一行[n](`nl`)第二行 # 换行还原
``` ```
> **字典操作**:本地字典的读取用脚注取元 `变量[^键]`,**不要**用 `json.get`。`json.get` / `json.set` 仅用于跨文本边界的序列化场景(例如与外部 JSON API 交换数据时)。构造字典用 GFM 横表(见[第 9 章](./09-集合.md))。 > **字典操作**:本地字典的读取用链接取元 `[键](变量)`,**不要**用 `json.get`。`json.get` / `json.set` 仅用于跨文本边界的序列化场景(例如与外部 JSON API 交换数据时)。构造字典用 GFM 横表(见[第 9 章](./09-集合.md))。
`json` 常用函数: `json` 常用函数:
| 函数 | 作用 | | 函数 | 作用 |
@@ -90,10 +90,10 @@ import text:lib/text.mq.md
# main # main
*parts = > text.str_split s="a,b,c" sep=","* **parts = > text.str_split s="a,b,c" sep=","**
> print text=`parts` > print text=`parts`
*joined = > text.str_join xs=`parts` sep="-"* **joined = > text.str_join xs=`parts` sep="-"**
> print text=`joined` # a-b-c > print text=`joined` # a-b-c
``` ```
@@ -106,7 +106,7 @@ import math:lib/math.mq.md
# main # main
*值 = > math.num value=3.5* **值 = > math.num value=3.5**
> print text=`值` > print text=`值`
``` ```
@@ -124,7 +124,7 @@ $$
x^2 - 2 x^2 - 2
$$ $$
*_svg = > math.plot formula=`f` var=x min=-3 max=3* **_svg = > math.plot formula=`f` var=x min=-3 max=3**
``` ```
空 RHS 赋值 + 后随 `$$…$$` 绑定一个公式值。 空 RHS 赋值 + 后随 `$$…$$` 绑定一个公式值。
@@ -150,9 +150,8 @@ import llm:ext/llm.mq.md
# main # main
*模型 = > llm.llm model="gpt-4o-mini"* **模型 = > llm.llm model="gpt-4o-mini"**
``` ```
| 扩展 | 功能 | | 扩展 | 功能 |
|------|------| |------|------|
| `llm` | 大模型对话 | | `llm` | 大模型对话 |
+40 -40
View File
@@ -31,30 +31,30 @@ import net:lib/net.mq.md
# main # main
*resp = > net.http_get url="https://api.example.com/status"* **resp = > net.http_get url="https://api.example.com/status"**
> print text=`resp`[^status] > print text=[status](`resp`)
``` ```
`http_post` 默认以 JSON 提交,可用 `content_type=` / `headers=` 覆盖: `http_post` 默认以 JSON 提交,可用 `content_type=` / `headers=` 覆盖:
```markdown ```markdown
*body = > net.http_post url="https://api.example.com/echo" body={"msg":"hi"}* **body = > net.http_post url="https://api.example.com/echo" body={"msg":"hi"}**
> print text=`body` > print text=`body`
``` ```
> **字典操作**:返回值是字典(如 `resp`),直接取元 `resp[^键]`,不要用 `json.get`。 > **字典操作**:返回值是字典(如 `resp`),用链接取元 `[键](resp)`,不要用 `json.get`。
### Cookie 解析 ### Cookie 解析
`cookie_parse` 把 `Cookie` 请求头或 `Set-Cookie` 响应头解析成列表: `cookie_parse` 把 `Cookie` 请求头或 `Set-Cookie` 响应头解析成列表:
```markdown ```markdown
*req = > net.cookie_parse text="session=abc123; theme=dark"* **req = > net.cookie_parse text="session=abc123; theme=dark"**
> print text=`req`[^1][^name] # session > print text=[name]([1](`req`)) # session
> print text=`req`[^1][^value] # abc123 > print text=[value]([1](`req`)) # abc123
*resp = > net.cookie_parse text="id=42; Path=/; HttpOnly; SameSite=Lax" is_response=True* **resp = > net.cookie_parse text="id=42; Path=/; HttpOnly; SameSite=Lax" is_response=True**
> print text=`resp`[^1][^http_only] # True > print text=[http_only]([1](`resp`)) # True
``` ```
### multipart 解析 ### multipart 解析
@@ -62,9 +62,9 @@ import net:lib/net.mq.md
`multipart_parse` 解析 `multipart/form-data` 正文(给定 `boundary`): `multipart_parse` 解析 `multipart/form-data` 正文(给定 `boundary`):
```markdown ```markdown
*parts = > net.multipart_parse body=`body` boundary="----WebKitFormBoundary"* **parts = > net.multipart_parse body=`body` boundary="----WebKitFormBoundary"**
*field = parts[^1]* **field = [1](parts)**
> print text=`field`[^name] > print text=[name](`field`)
``` ```
## 14.3 网页应用(`ext/web`) ## 14.3 网页应用(`ext/web`)
@@ -86,17 +86,17 @@ import web:ext/web/web.mq.md
|------|------| |------|------|
| nav.`导航` | shell.`顶栏` | | nav.`导航` | shell.`顶栏` |
*page = > web.page title="我的站点" intro="<h1>你好</h1>"* **page = > web.page title="我的站点" intro="<h1>你好</h1>"**
*page = > `page`.compose_components components=`首页`* **page = > `page`.compose_components components=`首页`**
*html = > `page`.render* **html = > `page`.render**
> print text=`html` > print text=`html`
``` ```
### 应用 + 路由 + 监听 ### 应用 + 路由 + 监听
```markdown ```markdown
*app = > web.app page=`page` host=127.0.0.1 port=18081* **app = > web.app page=`page` host=127.0.0.1 port=18081**
*app = > `app`.route path="/about" page=`关于`* **app = > `app`.route path="/about" page=`关于`**
> web_listen app=`app` > web_listen app=`app`
``` ```
@@ -105,12 +105,12 @@ import web:ext/web/web.mq.md
### 数据库(SQLite) ### 数据库(SQLite)
```markdown ```markdown
*store = > web.db url="sqlite:site.db"* **store = > web.db url="sqlite:site.db"**
> `store`.init name=articles fields=`字段表` > `store`.init name=articles fields=`字段表`
> `store`.insert table=articles rows=`数据` > `store`.insert table=articles rows=`数据`
*rows = > `store`.select table=articles limit=10* **rows = > `store`.select table=articles limit=10**
- [行](rows) - [行](rows)
> print text=`行`[^title] > print text=[title](`行`)
``` ```
## 14.4 登录鉴权(session / cookie) ## 14.4 登录鉴权(session / cookie)
@@ -125,8 +125,8 @@ import web:ext/web/web.mq.md
| 1 | admin | secret | | 1 | admin | secret |
| 2 | 站长 | pw123 | | 2 | 站长 | pw123 |
*app = > web.app page=`page` admin=True* **app = > web.app page=`page` admin=True**
*app = > `app`.auth users=`管理员` session_ttl=3600* **app = > `app`.auth users=`管理员` session_ttl=3600**
> web_listen app=`app` > web_listen app=`app`
``` ```
@@ -135,16 +135,16 @@ import web:ext/web/web.mq.md
**独立鉴权工具** `web.auth`:登录、校验、登出(不依赖页面),返回 `{ok, session_id, username}`: **独立鉴权工具** `web.auth`:登录、校验、登出(不依赖页面),返回 `{ok, session_id, username}`:
```markdown ```markdown
*auth = > web.auth users=`管理员` session_ttl=3600* **auth = > web.auth users=`管理员` session_ttl=3600**
*login = > `auth`.login username="admin" password="secret"* **login = > `auth`.login username="admin" password="secret"**
1. `login`[^ok] 1. [ok](`login`)
> print text=登录成功:`login`[^username] > print text=登录成功:[username](`login`)
2. * 2. *
> print text=登录失败 > print text=登录失败
*sid = login[^session_id]* **sid = [session_id](login)**
*check = > `auth`.check session_id=`sid`* **check = > `auth`.check session_id=`sid`**
> print text=`check`[^username] > print text=[username](`check`)
> `auth`.logout session_id=`sid` > `auth`.logout session_id=`sid`
``` ```
@@ -154,24 +154,24 @@ import web:ext/web/web.mq.md
`app.route_ws` 注册端点,`web.ws.connect` 单次请求–响应: `app.route_ws` 注册端点,`web.ws.connect` 单次请求–响应:
```markdown ```markdown
*app = > `app`.route_ws path="/live" echo=True* **app = > `app`.route_ws path="/live" echo=True**
> web_listen app=`app` > web_listen app=`app`
``` ```
客户端(另开终端): 客户端(另开终端):
```markdown ```markdown
*ws = > web.ws timeout_sec=30* **ws = > web.ws timeout_sec=30**
*echo = > `ws`.connect url="ws://127.0.0.1:18081/live" message="hi"* **echo = > `ws`.connect url="ws://127.0.0.1:18081/live" message="hi"**
1. `echo`[^ok] 1. [ok](`echo`)
> print text=`echo`[^messages] > print text=[messages](`echo`)
2. * 2. *
> print text=连接失败:`echo`[^error] > print text=连接失败:[error](`echo`)
``` ```
## 14.6 字典操作:用表格与取元,不用 `json.get`/`json.set` ## 14.6 字典操作:用表格与取元,不用 `json.get`/`json.set`
Marqdo 用 **GFM 表格**构造字典、用 **脚注取元 `变量[^键]`** 读取字典——这是语言原生能力,是「代码即文档」的体现。**不要**用 `json.get` / `json.set` 读写本地字典(那只用于文本 ↔ 结构化的序列化,如 `json.parse` / `json.stringify`)。 Marqdo 用 **GFM 表格**构造字典、用 **链接取元 `[键](变量)`** 读取字典——这是语言原生能力,是「代码即文档」的体现。**不要**用 `json.get` / `json.set` 读写本地字典(那只用于文本 ↔ 结构化的序列化,如 `json.parse` / `json.stringify`)。
构造字典(横表,≥2 列 + 1 行): 构造字典(横表,≥2 列 + 1 行):
@@ -186,15 +186,15 @@ Marqdo 用 **GFM 表格**构造字典、用 **脚注取元 `变量[^键]`** 读
读取字典(取元): 读取字典(取元):
```markdown ```markdown
> print text=`配置`[^主机] # 127.0.0.1 > print text=[主机](`配置`) # 127.0.0.1
> print text=`配置`[^端口] # 18081 > print text=[端口](`配置`) # 18081
``` ```
读取函数返回的字典字段,同样直接取元: 读取函数返回的字典字段,同样直接取元:
```markdown ```markdown
*login = > `auth`.login username="admin" password="secret"* **login = > `auth`.login username="admin" password="secret"**
> print text=`login`[^ok] # 而不是 json.get value=`login` key="ok" > print text=[ok](`login`) # 而不是 json.get value=`login` key="ok"
``` ```
## 14.7 下一步 ## 14.7 下一步
+16 -10
View File
@@ -4,6 +4,8 @@
本教程面向所有读者——从没写过代码的文档作者,到熟悉 Python 的工程师。每章都配有可直接运行的完整示例。 本教程面向所有读者——从没写过代码的文档作者,到熟悉 Python 的工程师。每章都配有可直接运行的完整示例。
**现行映射是 markup v0.3**:`**…**` = 代码(赋值 / 调用),`*…*` = 返回;集合取元优先 `[键](集合)`。
## 目录 ## 目录
### 第一部分 · 入门 ### 第一部分 · 入门
@@ -25,7 +27,7 @@
| 章节 | 内容 | 你能学会什么 | | 章节 | 内容 | 你能学会什么 |
|------|------|-------------| |------|------|-------------|
| [第 6 章:函数](./06-函数.md) | 定义、参数、返回值、函数结束 | 封装可复用逻辑 | | [第 6 章:函数](./06-函数.md) | 定义、参数、返回值、括号调用 | 封装可复用逻辑 |
| [第 7 章:条件分支](./07-条件分支.md) | `1.` `2.` 分支、else | 让程序根据条件走不同路线 | | [第 7 章:条件分支](./07-条件分支.md) | `1.` `2.` 分支、else | 让程序根据条件走不同路线 |
| [第 8 章:循环](./08-循环.md) | `-` 遍历、`-` while | 重复执行 | | [第 8 章:循环](./08-循环.md) | `-` 遍历、`-` while | 重复执行 |
@@ -33,7 +35,7 @@
| 章节 | 内容 | 你能学会什么 | | 章节 | 内容 | 你能学会什么 |
|------|------|-------------| |------|------|-------------|
| [第 9 章:集合(表格)](./09-集合.md) | 列表、字典、记录、脚注取元 | 用 Markdown 表格组织数据 | | [第 9 章:集合(表格)](./09-集合.md) | 列表、字典、记录、链接取元 | 用 Markdown 表格组织数据 |
### 第五部分 · 面向对象与模块 ### 第五部分 · 面向对象与模块
@@ -59,27 +61,31 @@
```markdown ```markdown
# main # main
> 问候 谁=World 礼貌 [问候] World
## 问候 ## 问候
+ `谁` + `谁`
+ `礼貌`=False
> print text=Hello, `谁`! 1. `礼貌`
> print text=您好,`谁`!
2. *
> print text=Hello, `谁`!
--- *None*
## 加一 ## 加一
+ `n` + `n`
**n + 1** *n + 1*
``` ```
- `# main` —— 入口 - `# main` —— 入口
- `> 问候 谁=World` —— 调用函数(具名参数) - `礼貌 [问候] World` —— 方括号标记调用(前导词 → `礼貌=True`)
- `## 问候` + `+ `谁`` —— 定义函数及其参数 - `## 问候` + `+ `谁`` —— 定义函数及其参数
- `> print text=…` —— 输出(副作用,是普通函数) - `> print text=…` —— 输出(副作用,是普通函数)
- `**n + 1**` —— 返回值 - `*n + 1*` —— 返回值(斜体)
- 单独一行 `---` —— 结束函数体 - `*None*` —— 无值收束并结束函数体
--- ---
@@ -91,4 +97,4 @@ marqdo run 文件.mq.md
更多运行、浏览、调试、发布方式见 [第 13 章](./13-命令行工具.md)。 更多运行、浏览、调试、发布方式见 [第 13 章](./13-命令行工具.md)。
> **提示**:语法宪法与精确定义见 [`doc/design/markdown-mapping.md`](../design/markdown-mapping.md);本教程是它的通俗讲解版。 > **提示**:语法宪法见 [`doc/design/markdown-mapping-v0.3.md`](../design/markdown-mapping-v0.3.md);本教程是它的通俗讲解版。
+14 -14
View File
@@ -13,7 +13,7 @@ import sys:lib/sys.mq.md
OKF flywheel offline: promote → plan same goal → `cache=hit` (no live LLM required for the hit path). OKF flywheel offline: promote → plan same goal → `cache=hit` (no live LLM required for the hit path).
*p = > plugin.native_path name="agent"* **p = > plugin.native_path name="agent"**
1. `p` 1. `p`
> plugin.load path=`p` > plugin.load path=`p`
2. * 2. *
@@ -21,14 +21,14 @@ OKF flywheel offline: promote → plan same goal → `cache=hit` (no live LLM re
> sys.exit code=1 > sys.exit code=1
> sys.env_set name="OPENAI_API_KEY" value="offline-okf-dummy" > sys.env_set name="OPENAI_API_KEY" value="offline-okf-dummy"
*model = > llm.llm* **model = > llm.llm**
*tools = > json.parse text=[]* **tools = > json.parse text=[]**
*助手 = > agent.agent model=`model` tools=`tools` standing="offline okf flywheel"* **助手 = > agent.agent model=`model` tools=`tools` standing="offline okf flywheel"**
*kb = ".marqdo/agent-kb-example-flywheel"* **kb = ".marqdo/agent-kb-example-flywheel"**
*wb = ".marqdo/agent-runs/example-pong-solid.mq.md"* **wb = ".marqdo/agent-runs/example-pong-solid.mq.md"**
*goal = "Reply with exactly the word pong and nothing else."* **goal = "Reply with exactly the word pong and nothing else."**
*body = "---\ntitle: okf pong\n---\n\n# main\n\n*msg = \"pong\"*\n\n**msg**\n"* **body = "---\ntitle: okf pong\n---\n\n# main\n\n*msg = \"pong\"*\n\n**msg**\n"**
1. > fs.exists path=`kb` 1. > fs.exists path=`kb`
> fs.remove path=`kb` > fs.remove path=`kb`
@@ -37,20 +37,20 @@ OKF flywheel offline: promote → plan same goal → `cache=hit` (no live LLM re
> fs.write_text path=`wb` text=`body` > fs.write_text path=`wb` text=`body`
*prom = > agent_kb_promote kb_dir=`kb` goal=`goal` workbook=`wb`* **prom = > agent_kb_promote kb_dir=`kb` goal=`goal` workbook=`wb`**
*okp = > json.get value=`prom` key="promoted"* **okp = > json.get value=`prom` key="promoted"**
1. `okp` 1. `okp`
> print text=promoted > print text=promoted
2. * 2. *
> print text=promote-fail > print text=promote-fail
> sys.exit code=1 > sys.exit code=1
*out = > `助手`.plan goal=`goal` max_rounds=2 writeback=False kb_dir=`kb` explore_n=0 promote=False* **out = > `助手`.plan goal=`goal` max_rounds=2 writeback=False kb_dir=`kb` explore_n=0 promote=False**
*cache = > json.get value=`out` key="cache"* **cache = > json.get value=`out` key="cache"**
> print text=`cache` > print text=`cache`
*match = > json.get value=`out` key="match"* **match = > json.get value=`out` key="match"**
> print text=`match` > print text=`match`
*val = > json.get value=`out` key="result"* **val = > json.get value=`out` key="result"**
> print text=`val` > print text=`val`
1. `cache` == "hit" 1. `cache` == "hit"
+20 -20
View File
@@ -15,12 +15,12 @@ import time:lib/time.mq.md
Return today's date string (tool visible in source to the model). Return today's date string (tool visible in source to the model).
*u = > time.now_unix* **u = > time.now_unix**
**> time.format unix=`u` pattern="%Y-%m-%d"** *> time.format unix=`u` pattern="%Y-%m-%d"*
# main # main
*p = > plugin.native_path name="agent"* **p = > plugin.native_path name="agent"**
1. `p` 1. `p`
> plugin.load path=`p` > plugin.load path=`p`
2. * 2. *
@@ -35,53 +35,53 @@ Return today's date string (tool visible in source to the model).
|------| |------|
| 获取时间 | | 获取时间 |
*model = > llm.llm* **model = > llm.llm**
*助手 = > agent.agent model=`model` tools=`工具表` standing="You are a Marqdo agent. Prefer CALL:获取时间 when the task needs today's date."* **助手 = > agent.agent model=`model` tools=`工具表` standing="You are a Marqdo agent. Prefer CALL:获取时间 when the task needs today's date."**
Assert constitution markers in the assembled prompt (call site before how-to-act): Assert constitution markers in the assembled prompt (call site before how-to-act):
*ctx = > agent.build_step_context agent=`助手` task="What is today's date? Use the tool in this runbook."* **ctx = > agent.build_step_context agent=`助手` task="What is today's date? Use the tool in this runbook."**
*parts = > split value=`ctx` sep="--- call site ---"* **parts = > split value=`ctx` sep="--- call site ---"**
*n = > len value=`parts`* **n = > len value=`parts`**
1. `n` > 1 1. `n` > 1
> print text=call-site-ok > print text=call-site-ok
2. * 2. *
> print text=call-site-missing > print text=call-site-missing
> sys.exit code=1 > sys.exit code=1
*parts2 = > split value=`ctx` sep="--- source (.mq.md) ---"* **parts2 = > split value=`ctx` sep="--- source (.mq.md) ---"**
*n2 = > len value=`parts2`* **n2 = > len value=`parts2`**
1. `n2` > 1 1. `n2` > 1
> print text=source-ok > print text=source-ok
2. * 2. *
> print text=source-missing > print text=source-missing
> sys.exit code=1 > sys.exit code=1
*parts3 = > split value=`ctx` sep="获取时间"* **parts3 = > split value=`ctx` sep="获取时间"**
*n3 = > len value=`parts3`* **n3 = > len value=`parts3`**
1. `n3` > 1 1. `n3` > 1
> print text=tool-in-source-ok > print text=tool-in-source-ok
2. * 2. *
> print text=tool-in-source-missing > print text=tool-in-source-missing
> sys.exit code=1 > sys.exit code=1
*site = > agent_call_site* **site = > agent_call_site**
*fn = > json.get value=`site` key="function"* **fn = > json.get value=`site` key="function"**
> print text=`fn` > print text=`fn`
Optional live step — set env AGENT_LIVE=1 and put keys in repo-root `.env`: Optional live step — set env AGENT_LIVE=1 and put keys in repo-root `.env`:
*live = > sys.env_get name="AGENT_LIVE"* **live = > sys.env_get name="AGENT_LIVE"**
*key = > sys.env_get name="OPENAI_API_KEY"* **key = > sys.env_get name="OPENAI_API_KEY"**
1. `live` == "1" 1. `live` == "1"
1. `key` 1. `key`
*out = > `助手`.step task="请调用获取时间工具,然后只回复日期字符串。" writeback=False* **out = > `助手`.step task="请调用获取时间工具,然后只回复日期字符串。" writeback=False**
*status = > json.get value=`out` key="status"* **status = > json.get value=`out` key="status"**
> print text=`status` > print text=`status`
*tool = > json.get value=`out` key="tool"* **tool = > json.get value=`out` key="tool"**
> print text=`tool` > print text=`tool`
*result = > json.get value=`out` key="result"* **result = > json.get value=`out` key="result"**
> print text=`result` > print text=`result`
2. * 2. *
> print text=live-skipped-no-key > print text=live-skipped-no-key
+1 -1
View File
@@ -35,7 +35,7 @@ description: 暗恋见君壳层 — head 资源表、导航 HTML、页脚 HTML
| script | "/static/js/feed_board.js" | 真 | | script | "/static/js/feed_board.js" | 真 |
| script | "/static/js/index.js" | 真 | | script | "/static/js/index.js" | 真 |
**`头`** *`头`*
## 导航HTML ## 导航HTML
+46 -46
View File
@@ -10,55 +10,55 @@ import text:lib/text.mq.md
给定帖子行记录列表,输出 `ul.home-posts-list` 标记(首页与列表页共用)。 给定帖子行记录列表,输出 `ul.home-posts-list` 标记(首页与列表页共用)。
*段 = None* **段 = None**
- [帖](行) - [帖](行)
*板 = 帖[^board]* **板 = [board](帖)**
*题 = 帖[^title]* **题 = [title](帖)**
*链 = 帖[^slug]* **链 = [slug](帖)**
*作 = 帖[^author]* **作 = [author](帖)**
*评 = 帖[^comments_count]* **评 = [comments_count](帖)**
*时 = 帖[^created_at]* **时 = [created_at](帖)**
1. not 作 1. not 作
*作 = "匿名"* **作 = "匿名"**
2. * 2. *
1. not 评 1. not 评
*评 = 0* **评 = 0**
2. * 2. *
1. not 时 1. not 时
*时 = ""* **时 = ""**
2. * 2. *
*一项 = "<li><article class=\"home-post-card feed-post-card\"><a href=\"/post/" + 链 + "\" class=\"home-post-card-link feed-post-card-link\"><span class=\"home-post-board feed-post-board\">" + 板 + "</span><div class=\"home-post-body feed-post-body\"><h3 class=\"home-post-title feed-post-title\">" + 题 + "</h3><div class=\"home-post-meta feed-post-meta\"><span class=\"home-post-meta-item feed-post-meta-item\"><span class=\"anlian-icon anlian-icon--user\" aria-hidden=\"true\"></span> " + 作 + "</span><span class=\"home-post-meta-item feed-post-meta-item\"><span class=\"anlian-icon anlian-icon--comment\" aria-hidden=\"true\"></span> " + 评 + "</span><time>" + 时 + "</time></div></div><span class=\"home-post-arrow feed-post-arrow\" aria-hidden=\"true\"><span class=\"anlian-icon anlian-icon--chevron-right\"></span></span></a></article></li>"* **一项 = "<li><article class=\"home-post-card feed-post-card\"><a href=\"/post/" + 链 + "\" class=\"home-post-card-link feed-post-card-link\"><span class=\"home-post-board feed-post-board\">" + 板 + "</span><div class=\"home-post-body feed-post-body\"><h3 class=\"home-post-title feed-post-title\">" + 题 + "</h3><div class=\"home-post-meta feed-post-meta\"><span class=\"home-post-meta-item feed-post-meta-item\"><span class=\"anlian-icon anlian-icon--user\" aria-hidden=\"true\"></span> " + 作 + "</span><span class=\"home-post-meta-item feed-post-meta-item\"><span class=\"anlian-icon anlian-icon--comment\" aria-hidden=\"true\"></span> " + 评 + "</span><time>" + 时 + "</time></div></div><span class=\"home-post-arrow feed-post-arrow\" aria-hidden=\"true\"><span class=\"anlian-icon anlian-icon--chevron-right\"></span></span></a></article></li>"**
*段 = > table.append list=段 item=一项* **段 = > table.append list=段 item=一项**
1. 段 1. 段
*内 = > text.str_join xs=段 sep=""* **内 = > text.str_join xs=段 sep=""**
**"<ul class=\"home-posts-list feed-posts-list\">" + 内 + "</ul>"** *"<ul class=\"home-posts-list feed-posts-list\">" + 内 + "</ul>"*
2. * 2. *
**"<ul class=\"home-posts-list feed-posts-list\"><li class=\"home-posts-empty feed-empty\">暂无帖子,<a href=\"/post/public\">去发帖</a></li></ul>"** *"<ul class=\"home-posts-list feed-posts-list\"><li class=\"home-posts-empty feed-empty\">暂无帖子,<a href=\"/post/public\">去发帖</a></li></ul>"*
## 新闻时间线HTML ## 新闻时间线HTML
+ `行` + `行`
给定新闻行记录列表,输出 `.news-timeline` 标记。 给定新闻行记录列表,输出 `.news-timeline` 标记。
*段 = None* **段 = None**
- [讯](行) - [讯](行)
*题 = 讯[^title]* **题 = [title](讯)**
*链 = 讯[^slug]* **链 = [slug](讯)**
*板 = 讯[^board]* **板 = [board](讯)**
*时 = 讯[^created_at]* **时 = [created_at](讯)**
1. not 板 1. not 板
*板 = ""* **板 = ""**
2. * 2. *
1. not 时 1. not 时
*时 = ""* **时 = ""**
2. * 2. *
*一项 = "<li class=\"news-timeline-item\"><span class=\"news-timeline-node\" aria-hidden=\"true\"></span><article class=\"news-timeline-card\"><div class=\"news-timeline-meta\"><time class=\"news-timeline-date\">" + 时 + "</time><span class=\"news-timeline-board\">" + 板 + "</span></div><h3 class=\"news-timeline-title\"><a href=\"/news/" + 链 + "\" class=\"news-timeline-link\">" + 题 + "</a></h3></article></li>"* **一项 = "<li class=\"news-timeline-item\"><span class=\"news-timeline-node\" aria-hidden=\"true\"></span><article class=\"news-timeline-card\"><div class=\"news-timeline-meta\"><time class=\"news-timeline-date\">" + 时 + "</time><span class=\"news-timeline-board\">" + 板 + "</span></div><h3 class=\"news-timeline-title\"><a href=\"/news/" + 链 + "\" class=\"news-timeline-link\">" + 题 + "</a></h3></article></li>"**
*段 = > table.append list=段 item=一项* **段 = > table.append list=段 item=一项**
1. 段 1. 段
*内 = > text.str_join xs=段 sep=""* **内 = > text.str_join xs=段 sep=""**
**"<div class=\"news-timeline\"><div class=\"news-timeline-rail\" aria-hidden=\"true\"><span class=\"news-timeline-line\"></span><span class=\"news-timeline-arrow\" aria-hidden=\"true\"><span class=\"anlian-icon anlian-icon--chevron-right news-timeline-arrow-icon--right\"></span><span class=\"anlian-icon anlian-icon--chevron-down news-timeline-arrow-icon--down\"></span></span></div><ol class=\"news-timeline-items\">" + 内 + "</ol></div>"** *"<div class=\"news-timeline\"><div class=\"news-timeline-rail\" aria-hidden=\"true\"><span class=\"news-timeline-line\"></span><span class=\"news-timeline-arrow\" aria-hidden=\"true\"><span class=\"anlian-icon anlian-icon--chevron-right news-timeline-arrow-icon--right\"></span><span class=\"anlian-icon anlian-icon--chevron-down news-timeline-arrow-icon--down\"></span></span></div><ol class=\"news-timeline-items\">" + 内 + "</ol></div>"*
2. * 2. *
**"<div class=\"news-timeline\"><div class=\"news-timeline-rail\" aria-hidden=\"true\"><span class=\"news-timeline-line\"></span><span class=\"news-timeline-arrow\" aria-hidden=\"true\"></span></div><ol class=\"news-timeline-items\"><li class=\"news-timeline-item news-timeline-item-empty\"><article class=\"news-timeline-card\"><p class=\"news-timeline-empty\">暂无新闻</p></article></li></ol></div>"** *"<div class=\"news-timeline\"><div class=\"news-timeline-rail\" aria-hidden=\"true\"><span class=\"news-timeline-line\"></span><span class=\"news-timeline-arrow\" aria-hidden=\"true\"></span></div><ol class=\"news-timeline-items\"><li class=\"news-timeline-item news-timeline-item-empty\"><article class=\"news-timeline-card\"><p class=\"news-timeline-empty\">暂无新闻</p></article></li></ol></div>"*
## 板块栏HTML ## 板块栏HTML
+ `板块` + `板块`
@@ -68,30 +68,30 @@ import text:lib/text.mq.md
板块 Tab 栏。`前缀` 如 `/post/ten/`;`查询键` 为 `board_id` 或 `news_board_id`;`全部类` 为 Tab 共用 class(含 js hook)。 板块 Tab 栏。`前缀` 如 `/post/ten/`;`查询键` 为 `board_id` 或 `news_board_id`;`全部类` 为 Tab 共用 class(含 js hook)。
*数据属 = "data-board"* **数据属 = "data-board"**
*全标签 = "全部"* **全标签 = "全部"**
1. 查询键 == "news_board_id" 1. 查询键 == "news_board_id"
*数据属 = "data-news-board"* **数据属 = "data-news-board"**
*全标签 = "所有板块"* **全标签 = "所有板块"**
2. * 2. *
*段 = None* **段 = None**
*全链 = 前缀 + "?" + 查询键 + "=0"* **全链 = 前缀 + "?" + 查询键 + "=0"**
*全项 = "<a href=\"" + 全链 + "\" class=\"" + 全部类 + " active\" " + 数据属 + "=\"0\">" + 全标签 + "</a>"* **全项 = "<a href=\"" + 全链 + "\" class=\"" + 全部类 + " active\" " + 数据属 + "=\"0\">" + 全标签 + "</a>"**
*段 = > table.append list=段 item=全项* **段 = > table.append list=段 item=全项**
- [板](板块) - [板](板块)
*名 = 板[^name]* **名 = [name](板)**
*号 = 板[^id]* **号 = [id](板)**
*链 = 前缀 + "?" + 查询键 + "=" + 号* **链 = 前缀 + "?" + 查询键 + "=" + 号**
*项 = "<a href=\"" + 链 + "\" class=\"" + 全部类 + "\" " + 数据属 + "=\"" + 号 + "\">" + 名 + "</a>"* **项 = "<a href=\"" + 链 + "\" class=\"" + 全部类 + "\" " + 数据属 + "=\"" + 号 + "\">" + 名 + "</a>"**
*段 = > table.append list=段 item=项* **段 = > table.append list=段 item=项**
1. 查询键 == "news_board_id" 1. 查询键 == "news_board_id"
*更多 = "<a href=\"/news\" class=\"home-posts-tab home-posts-tab-more\">全部新闻</a>"* **更多 = "<a href=\"/news\" class=\"home-posts-tab home-posts-tab-more\">全部新闻</a>"**
*段 = > table.append list=段 item=更多* **段 = > table.append list=段 item=更多**
2. * 2. *
*内 = > text.str_join xs=段 sep=""* **内 = > text.str_join xs=段 sep=""**
*栏类 = "home-posts-board-bar"* **栏类 = "home-posts-board-bar"**
1. 查询键 == "news_board_id" 1. 查询键 == "news_board_id"
*栏类 = "home-posts-board-bar home-news-board-bar"* **栏类 = "home-posts-board-bar home-news-board-bar"**
2. * 2. *
**"<div class=\"" + 栏类 + "\" data-feed-board><button type=\"button\" class=\"home-posts-scroll home-posts-scroll-left\" aria-label=\"向左滚动\"><span class=\"anlian-icon anlian-icon--chevron-left\"></span></button><div class=\"home-posts-segment-outer\"><div class=\"home-posts-segment\"><div class=\"home-posts-spotlight\" aria-hidden=\"true\"></div><div class=\"home-posts-tabs-scroll\"><div class=\"home-posts-tabs\" role=\"tablist\">" + 内 + "</div></div></div></div><button type=\"button\" class=\"home-posts-scroll home-posts-scroll-right\" aria-label=\"向右滚动\"><span class=\"anlian-icon anlian-icon--chevron-right\"></span></button></div>"** *"<div class=\"" + 栏类 + "\" data-feed-board><button type=\"button\" class=\"home-posts-scroll home-posts-scroll-left\" aria-label=\"向左滚动\"><span class=\"anlian-icon anlian-icon--chevron-left\"></span></button><div class=\"home-posts-segment-outer\"><div class=\"home-posts-segment\"><div class=\"home-posts-spotlight\" aria-hidden=\"true\"></div><div class=\"home-posts-tabs-scroll\"><div class=\"home-posts-tabs\" role=\"tablist\">" + 内 + "</div></div></div></div><button type=\"button\" class=\"home-posts-scroll home-posts-scroll-right\" aria-label=\"向右滚动\"><span class=\"anlian-icon anlian-icon--chevron-right\"></span></button></div>"*
+1 -1
View File
@@ -12,4 +12,4 @@
| 公聊 | /chat | | 公聊 | /chat |
| sitemap | /sitemap.xml | | sitemap | /sitemap.xml |
**`页脚`** *`页脚`*
@@ -9,13 +9,13 @@ import feed:feed.mq.md
## 帖子十 ## 帖子十
+ `board_id`="0" + `board_id`="0"
*store = > db.打开* **store = > db.打开**
*行 = > store.查询 表="posts" 上限=10 排序="-created_at"* **行 = > store.查询 表="posts" 上限=10 排序="-created_at"**
**> feed.帖子列表HTML 行=`行`** *> feed.帖子列表HTML 行=`行`*
## 新闻五 ## 新闻五
+ `news_board_id`="0" + `news_board_id`="0"
*store = > db.打开* **store = > db.打开**
*行 = > store.查询 表="news" 上限=5 排序="-created_at"* **行 = > store.查询 表="news" 上限=5 排序="-created_at"**
**> feed.新闻时间线HTML 行=`行`** *> feed.新闻时间线HTML 行=`行`*
+27 -27
View File
@@ -12,36 +12,36 @@ import feed:feed.mq.md
查询 notices / boards / news_boards / news(5) / posts(10),拼装首页四段 HTML(不含导航与页脚)。调用方传入已打开的 store。 查询 notices / boards / news_boards / news(5) / posts(10),拼装首页四段 HTML(不含导航与页脚)。调用方传入已打开的 store。
*公告行 = > 库.查询 表="notices" 上限=20 排序="-created_at"* **公告行 = > 库.查询 表="notices" 上限=20 排序="-created_at"**
*板块行 = > 库.查询 表="boards" 上限=50* **板块行 = > 库.查询 表="boards" 上限=50**
*新闻板块行 = > 库.查询 表="news_boards" 上限=50* **新闻板块行 = > 库.查询 表="news_boards" 上限=50**
*新闻行 = > 库.查询 表="news" 上限=5 排序="-created_at"* **新闻行 = > 库.查询 表="news" 上限=5 排序="-created_at"**
*帖子行 = > 库.查询 表="posts" 上限=10 排序="-created_at"* **帖子行 = > 库.查询 表="posts" 上限=10 排序="-created_at"**
*公告段 = None* **公告段 = None**
- [告](公告行) - [告](公告行)
*文 = 告[^content]* **文 = [content](告)**
*时 = 告[^created_at]* **时 = [created_at](告)**
*一项 = "<div class=\"notice-item\"><article class=\"notice-content\">" + 文 + "</article><p class=\"notice-create-time\">" + 时 + "</p></div>"* **一项 = "<div class=\"notice-item\"><article class=\"notice-content\">" + 文 + "</article><p class=\"notice-create-time\">" + 时 + "</p></div>"**
*公告段 = > table.append list=公告段 item=一项* **公告段 = > table.append list=公告段 item=一项**
1. 公告段 1. 公告段
*公告内 = > text.str_join xs=公告段 sep=""* **公告内 = > text.str_join xs=公告段 sep=""**
2. * 2. *
*公告内 = "<p class=\"text-muted\">暂无公告</p>"* **公告内 = "<p class=\"text-muted\">暂无公告</p>"**
*新闻栏 = > feed.板块栏HTML 板块=新闻板块行 前缀="/news/five" 查询键="news_board_id" 全部类="home-posts-tab js-home-news-tab"* **新闻栏 = > feed.板块栏HTML 板块=新闻板块行 前缀="/news/five" 查询键="news_board_id" 全部类="home-posts-tab js-home-news-tab"**
*新闻板 = > feed.新闻时间线HTML 行=新闻行* **新闻板 = > feed.新闻时间线HTML 行=新闻行**
*帖子栏 = > feed.板块栏HTML 板块=板块行 前缀="/post/ten" 查询键="board_id" 全部类="home-posts-tab js-home-post-tab"* **帖子栏 = > feed.板块栏HTML 板块=板块行 前缀="/post/ten" 查询键="board_id" 全部类="home-posts-tab js-home-post-tab"**
*帖子表 = > feed.帖子列表HTML 行=帖子行* **帖子表 = > feed.帖子列表HTML 行=帖子行**
*段 = None* **段 = None**
*英雄 = "<section class=\"hero\"><div class=\"section-wrap\"><header><img src=\"/static/img/logo.svg\" alt=\"logo\" width=\"30\" height=\"30\" decoding=\"async\"><a class=\"head-logo\" href=\"/\"><span>暗恋</span>见君</a></header><div class=\"hero-content\"><div class=\"left\"><h1 class=\"main-text\">期待人们能够继续相信<span style=\"color:#ffd0d0\">爱情</span></h1><h2 class=\"sub-text\">粉玻璃社区 · 匿名与实名同在</h2></div><div class=\"right\"><img src=\"/static/img/bg-hero-640.webp\" alt=\"首页展示图\" width=\"640\" height=\"482\" fetchpriority=\"high\" decoding=\"async\"></div></div><div class=\"social\"></div></div></section>"* **英雄 = "<section class=\"hero\"><div class=\"section-wrap\"><header><img src=\"/static/img/logo.svg\" alt=\"logo\" width=\"30\" height=\"30\" decoding=\"async\"><a class=\"head-logo\" href=\"/\"><span>暗恋</span>见君</a></header><div class=\"hero-content\"><div class=\"left\"><h1 class=\"main-text\">期待人们能够继续相信<span style=\"color:#ffd0d0\">爱情</span></h1><h2 class=\"sub-text\">粉玻璃社区 · 匿名与实名同在</h2></div><div class=\"right\"><img src=\"/static/img/bg-hero-640.webp\" alt=\"首页展示图\" width=\"640\" height=\"482\" fetchpriority=\"high\" decoding=\"async\"></div></div><div class=\"social\"></div></div></section>"**
*段 = > table.append list=段 item=英雄* **段 = > table.append list=段 item=英雄**
*公告区 = "<section class=\"notice\"><div class=\"section-wrap\"><h2 class=\"notice-title\">公告信息</h2><div class=\"notice-content-container\"><div class=\"notice-list\">" + 公告内 + "</div></div></div></section>"* **公告区 = "<section class=\"notice\"><div class=\"section-wrap\"><h2 class=\"notice-title\">公告信息</h2><div class=\"notice-content-container\"><div class=\"notice-list\">" + 公告内 + "</div></div></div></section>"**
*段 = > table.append list=段 item=公告区* **段 = > table.append list=段 item=公告区**
*新闻区 = "<section class=\"news home-news\" id=\"news\"><div class=\"section-wrap home-news-stage\"><h2 class=\"news-title\">新闻动态</h2>" + 新闻栏 + "<div class=\"news-timeline-wrap\"><div id=\"homeNewsPanel\" class=\"news-timeline-panel home-panel-swap\">" + 新闻板 + "</div></div></div></section>"* **新闻区 = "<section class=\"news home-news\" id=\"news\"><div class=\"section-wrap home-news-stage\"><h2 class=\"news-title\">新闻动态</h2>" + 新闻栏 + "<div class=\"news-timeline-wrap\"><div id=\"homeNewsPanel\" class=\"news-timeline-panel home-panel-swap\">" + 新闻板 + "</div></div></div></section>"**
*段 = > table.append list=段 item=新闻区* **段 = > table.append list=段 item=新闻区**
*更多 = "<a href=\"/post\" class=\"home-posts-more-link\">查看更多帖子</a>"* **更多 = "<a href=\"/post\" class=\"home-posts-more-link\">查看更多帖子</a>"**
*帖子区 = "<section class=\"home-posts\" id=\"post\"><div class=\"section-wrap home-posts-stage\"><h2 class=\"home-posts-title\">论坛交流</h2>" + 帖子栏 + "<div id=\"tenPostContainer\" class=\"home-posts-panel home-panel-swap\">" + 帖子表 + 更多 + "</div></div></section>"* **帖子区 = "<section class=\"home-posts\" id=\"post\"><div class=\"section-wrap home-posts-stage\"><h2 class=\"home-posts-title\">论坛交流</h2>" + 帖子栏 + "<div id=\"tenPostContainer\" class=\"home-posts-panel home-panel-swap\">" + 帖子表 + 更多 + "</div></div></section>"**
*段 = > table.append list=段 item=帖子区* **段 = > table.append list=段 item=帖子区**
**> text.str_join xs=段 sep=""** *> text.str_join xs=段 sep=""*
+1 -1
View File
@@ -15,4 +15,4 @@
| 登录 | /admin/login | | | guest | | 登录 | /admin/login | | | guest |
| 后台 | /admin | | | auth | | 后台 | /admin | | | auth |
**`导航`** *`导航`*
+5 -5
View File
@@ -11,8 +11,8 @@ import chrome:chrome.mq.md
导航 + 正文 + 页脚;体类如 `page-home`。 导航 + 正文 + 页脚;体类如 `page-home`。
*顶 = > chrome.导航HTML* **顶 = > chrome.导航HTML**
*底 = > chrome.页脚HTML* **底 = > chrome.页脚HTML**
*鉴权脚本 = "<script>(function(){var c=document.cookie.indexOf('marqdo_sid=')>=0;document.querySelectorAll('.nav-when-guest').forEach(function(el){el.style.display=c?'none':'';});document.querySelectorAll('.nav-when-auth').forEach(function(el){el.style.display=c?'':'none';});})();</script>"* **鉴权脚本 = "<script>(function(){var c=document.cookie.indexOf('marqdo_sid=')>=0;document.querySelectorAll('.nav-when-guest').forEach(function(el){el.style.display=c?'none':'';});document.querySelectorAll('.nav-when-auth').forEach(function(el){el.style.display=c?'':'none';});})();</script>"**
*鉴权样式 = "<style>.nav-when-auth{display:none}</style>"* **鉴权样式 = "<style>.nav-when-auth{display:none}</style>"**
**鉴权样式 + 顶 + "<main class=\"anlian-main " + 体类 + "\">" + 正文 + "</main>" + 底 + 鉴权脚本** *鉴权样式 + 顶 + "<main class=\"anlian-main " + 体类 + "\">" + 正文 + "</main>" + 底 + 鉴权脚本*
+21 -21
View File
@@ -10,16 +10,16 @@ import seed:seed.mq.md
打开 sqlite:data/anlian-mq.db,初始化全部表;帖子建 FTS;若 posts 为空则写入种子。返回 store。 打开 sqlite:data/anlian-mq.db,初始化全部表;帖子建 FTS;若 posts 为空则写入种子。返回 store。
*store = > 网页.数据库 地址="sqlite:data/anlian-mq.db"* **store = > 网页.数据库 地址="sqlite:data/anlian-mq.db"**
*帖子字段 = > schema.posts* **帖子字段 = > schema.posts**
*新闻字段 = > schema.news* **新闻字段 = > schema.news**
*板块字段 = > schema.boards* **板块字段 = > schema.boards**
*新闻板块字段 = > schema.news_boards* **新闻板块字段 = > schema.news_boards**
*公告字段 = > schema.notices* **公告字段 = > schema.notices**
*评论字段 = > schema.comments* **评论字段 = > schema.comments**
*房间字段 = > schema.chat_rooms* **房间字段 = > schema.chat_rooms**
*专题字段 = > schema.topics* **专题字段 = > schema.topics**
*密钥字段 = > schema.api_keys* **密钥字段 = > schema.api_keys**
> `store`.初始化 名=posts 字段=`帖子字段` > `store`.初始化 名=posts 字段=`帖子字段`
> `store`.初始化 名=news 字段=`新闻字段` > `store`.初始化 名=news 字段=`新闻字段`
> `store`.初始化 名=boards 字段=`板块字段` > `store`.初始化 名=boards 字段=`板块字段`
@@ -40,18 +40,18 @@ import seed:seed.mq.md
> `store`.全文 表=posts 列=`全文列` 名=posts_fts > `store`.全文 表=posts 列=`全文列` 名=posts_fts
*已有 = > store.查询 表="posts" 上限=1* **已有 = > store.查询 表="posts" 上限=1**
1. `已有` 1. `已有`
**store** *store*
2. * 2. *
*板块 = > seed.boards* **板块 = > seed.boards**
*新闻板块 = > seed.news_boards* **新闻板块 = > seed.news_boards**
*帖子 = > seed.posts* **帖子 = > seed.posts**
*新闻 = > seed.news* **新闻 = > seed.news**
*公告 = > seed.notices* **公告 = > seed.notices**
*评论 = > seed.comments* **评论 = > seed.comments**
*房间 = > seed.chat_rooms* **房间 = > seed.chat_rooms**
*专题 = > seed.topics* **专题 = > seed.topics**
> `store`.插入 表=boards 行=`板块` > `store`.插入 表=boards 行=`板块`
> `store`.插入 表=news_boards 行=`新闻板块` > `store`.插入 表=news_boards 行=`新闻板块`
> `store`.插入 表=posts 行=`帖子` > `store`.插入 表=posts 行=`帖子`
@@ -60,4 +60,4 @@ import seed:seed.mq.md
> `store`.插入 表=comments 行=`评论` > `store`.插入 表=comments 行=`评论`
> `store`.插入 表=chat_rooms 行=`房间` > `store`.插入 表=chat_rooms 行=`房间`
> `store`.插入 表=topics 行=`专题` > `store`.插入 表=topics 行=`专题`
**store** *store*
+9 -9
View File
@@ -19,7 +19,7 @@
| created_at | timestamp | true | | | created_at | timestamp | true | |
| updated_at | timestamp | true | | | updated_at | timestamp | true | |
**`posts`** *`posts`*
## news ## news
@@ -39,7 +39,7 @@
| created_at | timestamp | true | | | created_at | timestamp | true | |
| updated_at | timestamp | true | | | updated_at | timestamp | true | |
**`news`** *`news`*
## boards ## boards
@@ -53,7 +53,7 @@
| name | text | false | | | name | text | false | |
| slug | text | false | 是 | | slug | text | false | 是 |
**`boards`** *`boards`*
## news_boards ## news_boards
@@ -67,7 +67,7 @@
| name | text | false | | | name | text | false | |
| slug | text | false | 是 | | slug | text | false | 是 |
**`news_boards`** *`news_boards`*
## notices ## notices
@@ -81,7 +81,7 @@
| content | text | false | | content | text | false |
| created_at | timestamp | true | | created_at | timestamp | true |
**`notices`** *`notices`*
## comments ## comments
@@ -98,7 +98,7 @@
| author | text | true | | author | text | true |
| created_at | timestamp | true | | created_at | timestamp | true |
**`comments`** *`comments`*
## chat_rooms ## chat_rooms
@@ -113,7 +113,7 @@
| name | text | false | | | name | text | false | |
| summary | text | true | | | summary | text | true | |
**`chat_rooms`** *`chat_rooms`*
## topics ## topics
@@ -128,7 +128,7 @@
| title | text | false | | | title | text | false | |
| summary | text | true | | | summary | text | true | |
**`topics`** *`topics`*
## api_keys ## api_keys
@@ -143,4 +143,4 @@ API Key 校验用哈希表(应用层 scopes)。
| hash | text | false | | hash | text | false |
| scopes | text | true | | scopes | text | true |
**`api_keys`** *`api_keys`*
+8 -8
View File
@@ -10,7 +10,7 @@
| 2 | 开发 | develop | | 2 | 开发 | develop |
| 3 | 聊天 | chat | | 3 | 聊天 | chat |
**`boards`** *`boards`*
## news_boards ## news_boards
@@ -23,7 +23,7 @@
| 1 | 站务 | site | | 1 | 站务 | site |
| 2 | 技术 | tech | | 2 | 技术 | tech |
**`news_boards`** *`news_boards`*
## posts ## posts
@@ -37,7 +37,7 @@
| 2 | 如何用表格写论坛 | tables-for-forums | 导航、表单、种子数据都是可读表格。 | 若某功能逼你写一长串 json.set,请先审视 ext/web 是否缺命名方法。 | 开发 | 2 | 站务 | 0 | 18 | | 2 | 如何用表格写论坛 | tables-for-forums | 导航、表单、种子数据都是可读表格。 | 若某功能逼你写一长串 json.set,请先审视 ext/web 是否缺命名方法。 | 开发 | 2 | 站务 | 0 | 18 |
| 3 | 公聊室已开放 | chat-open | WebSocket 广播房间。 | 打开 /chat,连上 /chat/ws,消息会扇出给同房间所有人。 | 聊天 | 3 | 站务 | 0 | 9 | | 3 | 公聊室已开放 | chat-open | WebSocket 广播房间。 | 打开 /chat,连上 /chat/ws,消息会扇出给同房间所有人。 | 聊天 | 3 | 站务 | 0 | 9 |
**`posts`** *`posts`*
## news ## news
@@ -50,7 +50,7 @@
| 1 | 站点迁往 Marqdo | migrate-to-marqdo | 原生层换 Go libweb,作者面保持表格。 | 暗恋见君的验收目标:登录、发帖、列表详情、聊天与站长工具都能用 .mq.md 写完。 | 站务 | 1 | | 1 | 站点迁往 Marqdo | migrate-to-marqdo | 原生层换 Go libweb,作者面保持表格。 | 暗恋见君的验收目标:登录、发帖、列表详情、聊天与站长工具都能用 .mq.md 写完。 | 站务 | 1 |
| 2 | 外接 PostgreSQL / Redis | pg-redis | 生产可用外接驱动。 | 本示例默认 sqlite:;把数据库地址换成 postgres:// 即可。 | 技术 | 2 | | 2 | 外接 PostgreSQL / Redis | pg-redis | 生产可用外接驱动。 | 本示例默认 sqlite:;把数据库地址换成 postgres:// 即可。 | 技术 | 2 |
**`news`** *`news`*
## notices ## notices
@@ -64,7 +64,7 @@
| 2 | 站点正用 Marqdo 表格重写验收:导航、首页四段、列表与公聊对齐原站 DOM。 | 2026-09-08 14:30:00 | | 2 | 站点正用 Marqdo 表格重写验收:导航、首页四段、列表与公聊对齐原站 DOM。 | 2026-09-08 14:30:00 |
| 3 | 发帖与评论请遵守社区规范;站务公告将在此置顶。 | 2026-09-10 09:00:00 | | 3 | 发帖与评论请遵守社区规范;站务公告将在此置顶。 | 2026-09-10 09:00:00 |
**`notices`** *`notices`*
## comments ## comments
@@ -77,7 +77,7 @@
| 1 | post | welcome | 终于等到用表格写论坛的一天。 | 路人甲 | 2026-09-10 11:00:00 | | 1 | post | welcome | 终于等到用表格写论坛的一天。 | 路人甲 | 2026-09-10 11:00:00 |
| 2 | post | welcome | 期待人们能够继续相信爱情。 | 见君 | 2026-09-10 12:15:00 | | 2 | post | welcome | 期待人们能够继续相信爱情。 | 见君 | 2026-09-10 12:15:00 |
**`comments`** *`comments`*
## chat_rooms ## chat_rooms
@@ -90,7 +90,7 @@
| 1 | lobby | 大厅 | 全站公共聊天室。 | | 1 | lobby | 大厅 | 全站公共聊天室。 |
| 2 | casual | 闲聊 | 轻松闲聊,勿刷屏。 | | 2 | casual | 闲聊 | 轻松闲聊,勿刷屏。 |
**`chat_rooms`** *`chat_rooms`*
## topics ## topics
@@ -103,4 +103,4 @@
| 1 | glass-ui | 粉玻璃界面 | 首页与列表的毛玻璃视觉专题(占位)。 | | 1 | glass-ui | 粉玻璃界面 | 首页与列表的毛玻璃视觉专题(占位)。 |
| 2 | tables-as-code | 表格即代码 | Marqdo GFM 表装配专题(占位)。 | | 2 | tables-as-code | 表格即代码 | Marqdo GFM 表装配专题(占位)。 |
**`topics`** *`topics`*
+105 -105
View File
@@ -87,124 +87,124 @@ import db:db/index.mq.md
|------|------|------|------|------| |------|------|------|------|------|
| "public/img/favicon-32.png" | icon | "image/png" | 32x32 | "/favicon.ico" | | "public/img/favicon-32.png" | icon | "image/png" | 32x32 | "/favicon.ico" |
*store = > db.打开* **store = > db.打开**
*头 = > chrome.头资源* **头 = > chrome.头资源**
*顶 = > chrome.导航HTML* **顶 = > chrome.导航HTML**
*底 = > chrome.页脚HTML* **底 = > chrome.页脚HTML**
*鉴权补丁 = "<style>.nav-when-auth{display:none}</style><script>(function(){var c=document.cookie.indexOf('marqdo_sid=')>=0;document.querySelectorAll('.nav-when-guest').forEach(function(el){el.style.display=c?'none':'';});document.querySelectorAll('.nav-when-auth').forEach(function(el){el.style.display=c?'':'none';});})();</script>"* **鉴权补丁 = "<style>.nav-when-auth{display:none}</style><script>(function(){var c=document.cookie.indexOf('marqdo_sid=')>=0;document.querySelectorAll('.nav-when-guest').forEach(function(el){el.style.display=c?'none':'';});document.querySelectorAll('.nav-when-auth').forEach(function(el){el.style.display=c?'':'none';});})();</script>"**
*主页体 = > home.装配 库=`store`* **主页体 = > home.装配 库=`store`**
*主页文 = > page.包装 正文=`主页体` 体类="page-home"* **主页文 = > page.包装 正文=`主页体` 体类="page-home"**
*首页 = > 网页.页面 标题="暗恋见君论坛" 引言=`主页文` 壳样式="off" 布局="bare"* **首页 = > 网页.页面 标题="暗恋见君论坛" 引言=`主页文` 壳样式="off" 布局="bare"**
*首页 = > 首页.头装配 表=`头`* **首页 = > 首页.头装配 表=`头`**
*板块行 = > store.查询 表="boards" 上限=50* **板块行 = > store.查询 表="boards" 上限=50**
*帖子行 = > store.查询 表="posts" 上限=50 排序="-created_at"* **帖子行 = > store.查询 表="posts" 上限=50 排序="-created_at"**
*帖子栏 = > feed.板块栏HTML 板块=板块行 前缀="/post" 查询键="board_id" 全部类="feed-tab"* **帖子栏 = > feed.板块栏HTML 板块=板块行 前缀="/post" 查询键="board_id" 全部类="feed-tab"**
*帖子表 = > feed.帖子列表HTML 行=帖子行* **帖子表 = > feed.帖子列表HTML 行=帖子行**
*帖子列表体 = "<section class=\"feed-list-page\"><div class=\"section-wrap\"><h1 class=\"feed-list-title\">论坛交流</h1>" + 帖子栏 + 帖子表 + "<p style=\"margin-top:1rem\"><a href=\"/post/public\">发布帖子</a></p></div></section>"* **帖子列表体 = "<section class=\"feed-list-page\"><div class=\"section-wrap\"><h1 class=\"feed-list-title\">论坛交流</h1>" + 帖子栏 + 帖子表 + "<p style=\"margin-top:1rem\"><a href=\"/post/public\">发布帖子</a></p></div></section>"**
*帖子列表文 = > page.包装 正文=`帖子列表体` 体类="page-post-list"* **帖子列表文 = > page.包装 正文=`帖子列表体` 体类="page-post-list"**
*帖子列表 = > 网页.页面 标题="帖子 · 暗恋见君" 引言=`帖子列表文` 壳样式="off" 布局="bare"* **帖子列表 = > 网页.页面 标题="帖子 · 暗恋见君" 引言=`帖子列表文` 壳样式="off" 布局="bare"**
*帖子列表 = > 帖子列表.头装配 表=`头`* **帖子列表 = > 帖子列表.头装配 表=`头`**
*新闻板块行 = > store.查询 表="news_boards" 上限=50* **新闻板块行 = > store.查询 表="news_boards" 上限=50**
*新闻行 = > store.查询 表="news" 上限=50 排序="-created_at"* **新闻行 = > store.查询 表="news" 上限=50 排序="-created_at"**
*新闻栏 = > feed.板块栏HTML 板块=新闻板块行 前缀="/news" 查询键="news_board_id" 全部类="feed-tab"* **新闻栏 = > feed.板块栏HTML 板块=新闻板块行 前缀="/news" 查询键="news_board_id" 全部类="feed-tab"**
*新闻表 = > feed.新闻时间线HTML 行=新闻行* **新闻表 = > feed.新闻时间线HTML 行=新闻行**
*新闻列表体 = "<section class=\"feed-list-page home-news\"><div class=\"section-wrap\"><h1 class=\"feed-list-title\">新闻动态</h1>" + 新闻栏 + 新闻表 + "</div></section>"* **新闻列表体 = "<section class=\"feed-list-page home-news\"><div class=\"section-wrap\"><h1 class=\"feed-list-title\">新闻动态</h1>" + 新闻栏 + 新闻表 + "</div></section>"**
*新闻列表文 = > page.包装 正文=`新闻列表体` 体类="page-news-list"* **新闻列表文 = > page.包装 正文=`新闻列表体` 体类="page-news-list"**
*新闻列表 = > 网页.页面 标题="新闻 · 暗恋见君" 引言=`新闻列表文` 壳样式="off" 布局="bare"* **新闻列表 = > 网页.页面 标题="新闻 · 暗恋见君" 引言=`新闻列表文` 壳样式="off" 布局="bare"**
*新闻列表 = > 新闻列表.头装配 表=`头`* **新闻列表 = > 新闻列表.头装配 表=`头`**
*帖子页 = > 网页.页面 标题="帖子详情" 引言=`鉴权补丁` 壳样式="off" 布局="stacked"* **帖子页 = > 网页.页面 标题="帖子详情" 引言=`鉴权补丁` 壳样式="off" 布局="stacked"**
*帖子页 = > 帖子页.头装配 表=`头`* **帖子页 = > 帖子页.头装配 表=`头`**
*帖子页 = > 帖子页.壳HTML 导航=`顶` 页脚=`底` 体类="page-post-detail"* **帖子页 = > 帖子页.壳HTML 导航=`顶` 页脚=`底` 体类="page-post-detail"**
*帖子页 = > 帖子页.主体装配 主体=`帖子详情`* **帖子页 = > 帖子页.主体装配 主体=`帖子详情`**
*帖子页 = > 帖子页.查询条件 条件=`帖子条件`* **帖子页 = > 帖子页.查询条件 条件=`帖子条件`**
*帖子页 = > 帖子页.详情 详情=True* **帖子页 = > 帖子页.详情 详情=True**
*新闻页 = > 网页.页面 标题="新闻详情" 引言=`鉴权补丁` 壳样式="off" 布局="stacked"* **新闻页 = > 网页.页面 标题="新闻详情" 引言=`鉴权补丁` 壳样式="off" 布局="stacked"**
*新闻页 = > 新闻页.头装配 表=`头`* **新闻页 = > 新闻页.头装配 表=`头`**
*新闻页 = > 新闻页.壳HTML 导航=`顶` 页脚=`底` 体类="page-news-detail"* **新闻页 = > 新闻页.壳HTML 导航=`顶` 页脚=`底` 体类="page-news-detail"**
*新闻页 = > 新闻页.主体装配 主体=`新闻详情`* **新闻页 = > 新闻页.主体装配 主体=`新闻详情`**
*新闻页 = > 新闻页.查询条件 条件=`新闻条件`* **新闻页 = > 新闻页.查询条件 条件=`新闻条件`**
*新闻页 = > 新闻页.详情 详情=True* **新闻页 = > 新闻页.详情 详情=True**
*发帖表 = > 网页.表单 表="posts" 动作="插入"* **发帖表 = > 网页.表单 表="posts" 动作="插入"**
*发帖表 = > 发帖表.字段 字段=`发帖字段`* **发帖表 = > 发帖表.字段 字段=`发帖字段`**
*发帖表 = > 发帖表.规则 规则=`发帖规则`* **发帖表 = > 发帖表.规则 规则=`发帖规则`**
*发帖引言 = > page.包装 正文="<section class=\"feed-list-page\"><div class=\"section-wrap\"><h1>发布帖子</h1><p>需登录(admin / anlian)</p></div></section>" 体类="page-post-public"* **发帖引言 = > page.包装 正文="<section class=\"feed-list-page\"><div class=\"section-wrap\"><h1>发布帖子</h1><p>需登录(admin / anlian)</p></div></section>" 体类="page-post-public"**
*发帖页 = > 网页.页面 标题="发帖 · 暗恋见君" 引言=`发帖引言` 壳样式="off" 布局="bare"* **发帖页 = > 网页.页面 标题="发帖 · 暗恋见君" 引言=`发帖引言` 壳样式="off" 布局="bare"**
*发帖页 = > 发帖页.头装配 表=`头`* **发帖页 = > 发帖页.头装配 表=`头`**
*发帖页 = > 发帖页.表单装配 id="post" 表单=`发帖表`* **发帖页 = > 发帖页.表单装配 id="post" 表单=`发帖表`**
*房间行 = > store.查询 表="chat_rooms" 上限=50* **房间行 = > store.查询 表="chat_rooms" 上限=50**
*房间段 = None* **房间段 = None**
- [房](房间行) - [房](房间行)
*名 = 房[^name]* **名 = [name](房)**
*链 = 房[^slug]* **链 = [slug](房)**
*摘 = 房[^summary]* **摘 = [summary](房)**
*项 = "<article class=\"chat-room-card\"><h3><a href=\"/chat/" + 链 + "\">" + 名 + "</a></h3><p>" + 摘 + "</p></article>"* **项 = "<article class=\"chat-room-card\"><h3><a href=\"/chat/" + 链 + "\">" + 名 + "</a></h3><p>" + 摘 + "</p></article>"**
*房间段 = > table.append list=房间段 item=项* **房间段 = > table.append list=房间段 item=项**
*房间内 = > text.str_join xs=房间段 sep=""* **房间内 = > text.str_join xs=房间段 sep=""**
*聊天列表体 = "<section class=\"feed-list-page\"><div class=\"section-wrap\"><h1>聊天室</h1><div class=\"chat-room-grid\">" + 房间内 + "</div></div></section>"* **聊天列表体 = "<section class=\"feed-list-page\"><div class=\"section-wrap\"><h1>聊天室</h1><div class=\"chat-room-grid\">" + 房间内 + "</div></div></section>"**
*聊天列表文 = > page.包装 正文=`聊天列表体` 体类="page-chat"* **聊天列表文 = > page.包装 正文=`聊天列表体` 体类="page-chat"**
*聊天列表 = > 网页.页面 标题="聊天 · 暗恋见君" 引言=`聊天列表文` 壳样式="off" 布局="bare"* **聊天列表 = > 网页.页面 标题="聊天 · 暗恋见君" 引言=`聊天列表文` 壳样式="off" 布局="bare"**
*聊天列表 = > 聊天列表.头装配 表=`头`* **聊天列表 = > 聊天列表.头装配 表=`头`**
*大厅体 = "<section class=\"feed-list-page\"><div class=\"section-wrap\"><h1>大厅</h1><div class=\"chat-box\"><div id=\"chat-log\" class=\"chat-log\"></div><p class=\"search-bar\"><input id=\"chat-msg\" placeholder=\"说点什么…\" aria-label=\"消息\"><button id=\"chat-send\" type=\"button\">发送</button></p></div><script src=\"/static/chat.js\"></script></div></section>"* **大厅体 = "<section class=\"feed-list-page\"><div class=\"section-wrap\"><h1>大厅</h1><div class=\"chat-box\"><div id=\"chat-log\" class=\"chat-log\"></div><p class=\"search-bar\"><input id=\"chat-msg\" placeholder=\"说点什么…\" aria-label=\"消息\"><button id=\"chat-send\" type=\"button\">发送</button></p></div><script src=\"/static/chat.js\"></script></div></section>"**
*大厅文 = > page.包装 正文=`大厅体` 体类="page-chat-room"* **大厅文 = > page.包装 正文=`大厅体` 体类="page-chat-room"**
*大厅页 = > 网页.页面 标题="大厅 · 暗恋见君" 引言=`大厅文` 壳样式="off" 布局="bare"* **大厅页 = > 网页.页面 标题="大厅 · 暗恋见君" 引言=`大厅文` 壳样式="off" 布局="bare"**
*大厅页 = > 大厅页.头装配 表=`头`* **大厅页 = > 大厅页.头装配 表=`头`**
*闲聊体 = "<section class=\"feed-list-page\"><div class=\"section-wrap\"><h1>闲聊</h1><div class=\"chat-box\"><div id=\"chat-log\" class=\"chat-log\"></div><p class=\"search-bar\"><input id=\"chat-msg\" placeholder=\"说点什么…\" aria-label=\"消息\"><button id=\"chat-send\" type=\"button\">发送</button></p></div><script src=\"/static/chat.js\"></script></div></section>"* **闲聊体 = "<section class=\"feed-list-page\"><div class=\"section-wrap\"><h1>闲聊</h1><div class=\"chat-box\"><div id=\"chat-log\" class=\"chat-log\"></div><p class=\"search-bar\"><input id=\"chat-msg\" placeholder=\"说点什么…\" aria-label=\"消息\"><button id=\"chat-send\" type=\"button\">发送</button></p></div><script src=\"/static/chat.js\"></script></div></section>"**
*闲聊文 = > page.包装 正文=`闲聊体` 体类="page-chat-room"* **闲聊文 = > page.包装 正文=`闲聊体` 体类="page-chat-room"**
*闲聊页 = > 网页.页面 标题="闲聊 · 暗恋见君" 引言=`闲聊文` 壳样式="off" 布局="bare"* **闲聊页 = > 网页.页面 标题="闲聊 · 暗恋见君" 引言=`闲聊文` 壳样式="off" 布局="bare"**
*闲聊页 = > 闲聊页.头装配 表=`头`* **闲聊页 = > 闲聊页.头装配 表=`头`**
*专题行 = > store.查询 表="topics" 上限=50* **专题行 = > store.查询 表="topics" 上限=50**
*专题段 = None* **专题段 = None**
- [题](专题行) - [题](专题行)
*题名 = 题[^title]* **题名 = [title](题)**
*链 = 题[^slug]* **链 = [slug](题)**
*摘 = 题[^summary]* **摘 = [summary](题)**
*项 = "<article class=\"topic-card\"><h3>" + 题名 + "</h3><p>" + 摘 + "</p><p class=\"text-muted\">slug: " + 链 + "</p></article>"* **项 = "<article class=\"topic-card\"><h3>" + 题名 + "</h3><p>" + 摘 + "</p><p class=\"text-muted\">slug: " + 链 + "</p></article>"**
*专题段 = > table.append list=专题段 item=项* **专题段 = > table.append list=专题段 item=项**
*专题内 = > text.str_join xs=专题段 sep=""* **专题内 = > text.str_join xs=专题段 sep=""**
*专题体 = "<section class=\"feed-list-page\"><div class=\"section-wrap\"><h1>专题书架</h1><div class=\"topic-shelf\">" + 专题内 + "</div></div></section>"* **专题体 = "<section class=\"feed-list-page\"><div class=\"section-wrap\"><h1>专题书架</h1><div class=\"topic-shelf\">" + 专题内 + "</div></div></section>"**
*专题文 = > page.包装 正文=`专题体` 体类="page-topics"* **专题文 = > page.包装 正文=`专题体` 体类="page-topics"**
*专题页 = > 网页.页面 标题="专题 · 暗恋见君" 引言=`专题文` 壳样式="off" 布局="bare"* **专题页 = > 网页.页面 标题="专题 · 暗恋见君" 引言=`专题文` 壳样式="off" 布局="bare"**
*专题页 = > 专题页.头装配 表=`头`* **专题页 = > 专题页.头装配 表=`头`**
*搜索体 = "<section class=\"feed-list-page\"><div class=\"section-wrap\"><h1>搜索</h1><form class=\"search-bar\" method=\"get\" action=\"/search\"><input name=\"q\" placeholder=\"关键词\" aria-label=\"关键词\"><button type=\"submit\">搜</button></form><p class=\"text-muted\">全文检索走 SQLite FTS(posts_fts);结果面板后续可按 q 扩展。</p></div></section>"* **搜索体 = "<section class=\"feed-list-page\"><div class=\"section-wrap\"><h1>搜索</h1><form class=\"search-bar\" method=\"get\" action=\"/search\"><input name=\"q\" placeholder=\"关键词\" aria-label=\"关键词\"><button type=\"submit\">搜</button></form><p class=\"text-muted\">全文检索走 SQLite FTS(posts_fts);结果面板后续可按 q 扩展。</p></div></section>"**
*搜索文 = > page.包装 正文=`搜索体` 体类="page-search"* **搜索文 = > page.包装 正文=`搜索体` 体类="page-search"**
*搜索页 = > 网页.页面 标题="搜索 · 暗恋见君" 引言=`搜索文` 壳样式="off" 布局="bare"* **搜索页 = > 网页.页面 标题="搜索 · 暗恋见君" 引言=`搜索文` 壳样式="off" 布局="bare"**
*搜索页 = > 搜索页.头装配 表=`头`* **搜索页 = > 搜索页.头装配 表=`头`**
*指南体 = "<section class=\"feed-list-page\"><div class=\"section-wrap\"><h1>API 自动化指南</h1><p>使用 Bearer / X-Api-Key 调用自动化接口。本验收切片提供 <code>api_keys</code> 表与 <code>web_api_key_check</code> 原语;业务 scopes 写在 .mq.md。</p><pre>Authorization: Bearer &lt;token&gt;</pre></div></section>"* **指南体 = "<section class=\"feed-list-page\"><div class=\"section-wrap\"><h1>API 自动化指南</h1><p>使用 Bearer / X-Api-Key 调用自动化接口。本验收切片提供 <code>api_keys</code> 表与 <code>web_api_key_check</code> 原语;业务 scopes 写在 .mq.md。</p><pre>Authorization: Bearer &lt;token&gt;</pre></div></section>"**
*指南文 = > page.包装 正文=`指南体` 体类="page-guide"* **指南文 = > page.包装 正文=`指南体` 体类="page-guide"**
*指南页 = > 网页.页面 标题="API 指南 · 暗恋见君" 引言=`指南文` 壳样式="off" 布局="bare"* **指南页 = > 网页.页面 标题="API 指南 · 暗恋见君" 引言=`指南文` 壳样式="off" 布局="bare"**
*指南页 = > 指南页.头装配 表=`头`* **指南页 = > 指南页.头装配 表=`头`**
*应用 = > 网页.应用 页面=`首页` 数据库=`store` 后台=True 主机="127.0.0.1" 端口=18180* **应用 = > 网页.应用 页面=`首页` 数据库=`store` 后台=True 主机="127.0.0.1" 端口=18180**
*应用 = > 应用.路由 路径="/post" 页面=`帖子列表`* **应用 = > 应用.路由 路径="/post" 页面=`帖子列表`**
*应用 = > 应用.路由 路径="/post/public" 页面=`发帖页`* **应用 = > 应用.路由 路径="/post/public" 页面=`发帖页`**
*应用 = > 应用.路由 路径="/post/{slug}" 页面=`帖子页`* **应用 = > 应用.路由 路径="/post/{slug}" 页面=`帖子页`**
*应用 = > 应用.路由 路径="/news" 页面=`新闻列表`* **应用 = > 应用.路由 路径="/news" 页面=`新闻列表`**
*应用 = > 应用.路由 路径="/news/{slug}" 页面=`新闻页`* **应用 = > 应用.路由 路径="/news/{slug}" 页面=`新闻页`**
*应用 = > 应用.路由 路径="/chat" 页面=`聊天列表`* **应用 = > 应用.路由 路径="/chat" 页面=`聊天列表`**
*应用 = > 应用.路由 路径="/chat/lobby" 页面=`大厅页`* **应用 = > 应用.路由 路径="/chat/lobby" 页面=`大厅页`**
*应用 = > 应用.路由 路径="/chat/casual" 页面=`闲聊页`* **应用 = > 应用.路由 路径="/chat/casual" 页面=`闲聊页`**
*应用 = > 应用.路由 路径="/topics" 页面=`专题页`* **应用 = > 应用.路由 路径="/topics" 页面=`专题页`**
*应用 = > 应用.路由 路径="/search" 页面=`搜索页`* **应用 = > 应用.路由 路径="/search" 页面=`搜索页`**
*应用 = > 应用.路由 路径="/guide/automation-api" 页面=`指南页`* **应用 = > 应用.路由 路径="/guide/automation-api" 页面=`指南页`**
*应用 = > 应用.静态 目录="public" 挂载="/static"* **应用 = > 应用.静态 目录="public" 挂载="/static"**
*应用 = > 应用.图标 表=`图标`* **应用 = > 应用.图标 表=`图标`**
*应用 = > 应用.鉴权 用户表=`用户表` 会话时长=7200 登录路径="/accounts/login" 登录回跳="/post/public" 登出回跳="/"* **应用 = > 应用.鉴权 用户表=`用户表` 会话时长=7200 登录路径="/accounts/login" 登录回跳="/post/public" 登出回跳="/"**
*应用 = > 应用.门禁 路径="/post/public" 角色="admin" 匹配="prefix" 拒绝="redirect" 排除="/accounts/login"* **应用 = > 应用.门禁 路径="/post/public" 角色="admin" 匹配="prefix" 拒绝="redirect" 排除="/accounts/login"**
*应用 = > 应用.路由实时 路径="/chat/ws" 模式="broadcast"* **应用 = > 应用.路由实时 路径="/chat/ws" 模式="broadcast"**
*应用 = > 应用.调用 路径="/post/ten" 方法="GET" 函数="fragments.帖子十" 正文="query" 返回="html"* **应用 = > 应用.调用 路径="/post/ten" 方法="GET" 函数="fragments.帖子十" 正文="query" 返回="html"**
*应用 = > 应用.调用 路径="/news/five" 方法="GET" 函数="fragments.新闻五" 正文="query" 返回="html"* **应用 = > 应用.调用 路径="/news/five" 方法="GET" 函数="fragments.新闻五" 正文="query" 返回="html"**
*应用 = > 应用.站点地图 路径="/sitemap.xml" 基址="http://127.0.0.1:18180" 条目=`地图项`* **应用 = > 应用.站点地图 路径="/sitemap.xml" 基址="http://127.0.0.1:18180" 条目=`地图项`**
*应用 = > 应用.爬虫协议 站点地图="http://127.0.0.1:18180/sitemap.xml"* **应用 = > 应用.爬虫协议 站点地图="http://127.0.0.1:18180/sitemap.xml"**
> `应用`.监听 > `应用`.监听
+17 -17
View File
@@ -32,37 +32,37 @@ import sys:lib/sys.mq.md
|----|--------|------|------| |----|--------|------|------|
| 1 | admin | anlian | admin | | 1 | admin | anlian | admin |
*store = > db.打开* **store = > db.打开**
*壳CSS = > shell.全局* **壳CSS = > shell.全局**
*首页 = > 网页.页面 标题="暗恋见君" 引言="<h1>ok</h1>"* **首页 = > 网页.页面 标题="暗恋见君" 引言="<h1>ok</h1>"**
*首页 = > 首页.组件装配 组件=`壳`* **首页 = > 首页.组件装配 组件=`壳`**
*首页 = > 首页.主体装配 主体=`帖子卡片`* **首页 = > 首页.主体装配 主体=`帖子卡片`**
*首页 = > 首页.样式 样式=`壳CSS`* **首页 = > 首页.样式 样式=`壳CSS`**
*应用 = > 网页.应用 页面=`首页` 数据库=`store` 后台=True 主机="127.0.0.1" 端口=18180* **应用 = > 网页.应用 页面=`首页` 数据库=`store` 后台=True 主机="127.0.0.1" 端口=18180**
*应用 = > 应用.鉴权 用户表=`用户表`* **应用 = > 应用.鉴权 用户表=`用户表`**
*应用 = > 应用.门禁 路径="/write" 角色="admin" 匹配="prefix" 拒绝="redirect"* **应用 = > 应用.门禁 路径="/write" 角色="admin" 匹配="prefix" 拒绝="redirect"**
*应用 = > 应用.路由实时 路径="/chat/ws" 模式="broadcast"* **应用 = > 应用.路由实时 路径="/chat/ws" 模式="broadcast"**
*gates = 应用[^gates]* **gates = [gates](应用)**
*n = > len value=`gates`* **n = > len value=`gates`**
1. `n` >= 2 1. `n` >= 2
> print text=gates-ok > print text=gates-ok
2. * 2. *
> print text=gates-fail > print text=gates-fail
> sys.exit code=1 > sys.exit code=1
*ws = 应用[^ws_routes]* **ws = [ws_routes](应用)**
*room = ws[^/chat/ws]* **room = [/chat/ws](ws)**
*mode = room[^mode]* **mode = [mode](room)**
1. `mode` == "broadcast" 1. `mode` == "broadcast"
> print text=ws-ok > print text=ws-ok
2. * 2. *
> print text=ws-fail > print text=ws-fail
> sys.exit code=1 > sys.exit code=1
*list = > store.查询 表="posts" 上限=10* **list = > store.查询 表="posts" 上限=10**
*nr = > len value=`list`* **nr = > len value=`list`**
1. `nr` >= 1 1. `nr` >= 1
> print text=seed-ok > print text=seed-ok
2. * 2. *
+23 -23
View File
@@ -54,7 +54,7 @@ import text:lib/text.mq.md
| .main-intro | margin | 0 auto | | .main-intro | margin | 0 auto |
| .main-intro | padding | 1.25rem 1.5rem 0 | | .main-intro | padding | 1.25rem 1.5rem 0 |
**`基础`** *`基础`*
## 动效 ## 动效
@@ -75,7 +75,7 @@ import text:lib/text.mq.md
| @keyframes cardRise 100% | opacity | "1" | | @keyframes cardRise 100% | opacity | "1" |
| @keyframes cardRise 100% | transform | translateY(0) | | @keyframes cardRise 100% | transform | translateY(0) |
**`动效`** *`动效`*
## 顶栏 ## 顶栏
@@ -126,7 +126,7 @@ import text:lib/text.mq.md
| ul.nav li:first-child a:hover | transform | none | | ul.nav li:first-child a:hover | transform | none |
| ul.nav li:first-child a:hover | background | transparent | | ul.nav li:first-child a:hover | background | transparent |
**`顶栏`** *`顶栏`*
## Hero ## Hero
@@ -223,7 +223,7 @@ import text:lib/text.mq.md
| .page-stage p | margin | "0" | | .page-stage p | margin | "0" |
| .page-stage p | color | var(--muted) | | .page-stage p | color | var(--muted) |
**`Hero`** *`Hero`*
## 卡片 ## 卡片
@@ -336,7 +336,7 @@ import text:lib/text.mq.md
| .search-bar button | font-weight | "600" | | .search-bar button | font-weight | "600" |
| .search-bar button | cursor | pointer | | .search-bar button | cursor | pointer |
**`卡片`** *`卡片`*
## 页脚 ## 页脚
@@ -366,7 +366,7 @@ import text:lib/text.mq.md
| ul.foot-nav a | font-weight | "500" | | ul.foot-nav a | font-weight | "500" |
| ul.foot-nav a:hover | color | var(--accent-text) | | ul.foot-nav a:hover | color | var(--accent-text) |
**`页脚`** *`页脚`*
## 响应式 ## 响应式
@@ -393,25 +393,25 @@ import text:lib/text.mq.md
| (prefers-reduced-motion: reduce) | ul.nav li:first-child a::before | animation | none | | (prefers-reduced-motion: reduce) | ul.nav li:first-child a::before | animation | none |
| (prefers-reduced-motion: reduce) | article.card | animation | none | | (prefers-reduced-motion: reduce) | article.card | animation | none |
**`响应式`** *`响应式`*
## 全局 ## 全局
*基础表 = > 基础* **基础表 = > 基础**
*动效表 = > 动效* **动效表 = > 动效**
*顶栏表 = > 顶栏* **顶栏表 = > 顶栏**
*Hero表 = > Hero* **Hero表 = > Hero**
*卡片表 = > 卡片* **卡片表 = > 卡片**
*页脚表 = > 页脚* **页脚表 = > 页脚**
*响应式表 = > 响应式* **响应式表 = > 响应式**
*css基础 = > 网页.样式装配 名="基础" 表=`基础表`* **css基础 = > 网页.样式装配 名="基础" 表=`基础表`**
*css动效 = > 网页.样式装配 名="动效" 表=`动效表`* **css动效 = > 网页.样式装配 名="动效" 表=`动效表`**
*css顶栏 = > 网页.样式装配 名="顶栏" 表=`顶栏表`* **css顶栏 = > 网页.样式装配 名="顶栏" 表=`顶栏表`**
*cssHero = > 网页.样式装配 名="Hero" 表=`Hero表`* **cssHero = > 网页.样式装配 名="Hero" 表=`Hero表`**
*css卡片 = > 网页.样式装配 名="卡片" 表=`卡片表`* **css卡片 = > 网页.样式装配 名="卡片" 表=`卡片表`**
*css页脚 = > 网页.样式装配 名="页脚" 表=`页脚表`* **css页脚 = > 网页.样式装配 名="页脚" 表=`页脚表`**
*css响应式 = > 网页.样式装配 名="响应式" 表=`响应式表`* **css响应式 = > 网页.样式装配 名="响应式" 表=`响应式表`**
`css段` = `css段` =
@@ -425,5 +425,5 @@ import text:lib/text.mq.md
| `css页脚` | | `css页脚` |
| `css响应式` | | `css响应式` |
*css = > text.str_join xs=`css段` sep=""* **css = > text.str_join xs=`css段` sep=""**
**css** *css*
+75 -75
View File
@@ -8,10 +8,10 @@ import text:lib/text.mq.md
# main # main
*`ticks` = 0* **`ticks` = 0**
*`bag` = ""* **`bag` = ""**
*`path` = "/"* **`path` = "/"**
*`ws_id` = "echo"* **`ws_id` = "echo"**
`wire` = `wire` =
@@ -52,26 +52,26 @@ import text:lib/text.mq.md
|------|----------|---------| |------|----------|---------|
| `wire` | `nav` | `st` | | `wire` | `nav` | `st` |
**boot** *boot*
## add ## add
+ `value`="" + `value`=""
1. `value` != "" 1. `value` != ""
1. `bag` == "" 1. `bag` == ""
*`bag` = value* **`bag` = value**
2. * 2. *
*`bag` = bag + "\n" + value* **`bag` = bag + "\n" + value**
*`parts` = > text.str_split s=bag sep="\n"* **`parts` = > text.str_split s=bag sep="\n"**
*`html` = ""* **`html` = ""**
- [item](parts) - [item](parts)
1. `item` != "" 1. `item` != ""
*`html` = html + "<li><span>" + item + "</span> <button type=\"button\" data-id=\"" + item + "\">删</button></li>"* **`html` = html + "<li><span>" + item + "</span> <button type=\"button\" data-id=\"" + item + "\">删</button></li>"**
*`ret` = > browser.set_html sel="#items" html=html* **`ret` = > browser.set_html sel="#items" html=html**
*`clr` = > browser.set_value sel="#draft" value=""* **`clr` = > browser.set_value sel="#draft" value=""**
*`ret` = > browser.merge a=ret b=clr* **`ret` = > browser.merge a=ret b=clr**
*`f` = > browser.focus sel="#draft"* **`f` = > browser.focus sel="#draft"**
**> browser.merge a=ret b=f** *> browser.merge a=ret b=f*
2. * 2. *
**** ****
@@ -79,25 +79,25 @@ import text:lib/text.mq.md
+ `data_id`="" + `data_id`=""
1. `data_id` != "" 1. `data_id` != ""
*`parts` = > text.str_split s=bag sep="\n"* **`parts` = > text.str_split s=bag sep="\n"**
*`next` = ""* **`next` = ""**
- [item](parts) - [item](parts)
1. `item` != "" 1. `item` != ""
1. `item` != `data_id` 1. `item` != `data_id`
1. `next` == "" 1. `next` == ""
*`next` = item* **`next` = item**
2. * 2. *
*`next` = next + "\n" + item* **`next` = next + "\n" + item**
*`bag` = next* **`bag` = next**
*`parts2` = > text.str_split s=bag sep="\n"* **`parts2` = > text.str_split s=bag sep="\n"**
*`html` = ""* **`html` = ""**
- [item](parts2) - [item](parts2)
1. `item` != "" 1. `item` != ""
*`html` = html + "<li><span>" + item + "</span> <button type=\"button\" data-id=\"" + item + "\">删</button></li>"* **`html` = html + "<li><span>" + item + "</span> <button type=\"button\" data-id=\"" + item + "\">删</button></li>"**
*`ret` = > browser.set_html sel="#items" html=html* **`ret` = > browser.set_html sel="#items" html=html**
*`msg` = "removed " + data_id* **`msg` = "removed " + data_id**
*`t` = > browser.set_text sel="#log" text=msg* **`t` = > browser.set_text sel="#log" text=msg**
**> browser.merge a=ret b=t** *> browser.merge a=ret b=t*
2. * 2. *
**** ****
@@ -110,9 +110,9 @@ import text:lib/text.mq.md
|----|-----|-------| |----|-----|-------|
| set | mq-draft | `value` | | set | mq-draft | `value` |
*`msg` = > browser.set_text sel="#log" text="draft saved"* **`msg` = > browser.set_text sel="#log" text="draft saved"**
*`s` = > browser.storage spec=st* **`s` = > browser.storage spec=st**
**> browser.merge a=msg b=s** *> browser.merge a=msg b=s*
## load_draft ## load_draft
@@ -122,7 +122,7 @@ import text:lib/text.mq.md
|----|-----|------| |----|-----|------|
| get | mq-draft | on_draft | | get | mq-draft | on_draft |
**> browser.storage spec=st** *> browser.storage spec=st*
## on_draft ## on_draft
+ `ok`=True + `ok`=True
@@ -130,47 +130,47 @@ import text:lib/text.mq.md
+ `found`=False + `found`=False
1. `found` 1. `found`
*`ret` = > browser.set_value sel="#draft" value=value* **`ret` = > browser.set_value sel="#draft" value=value**
*`msg` = > browser.set_text sel="#log" text="draft loaded"* **`msg` = > browser.set_text sel="#log" text="draft loaded"**
**> browser.merge a=ret b=msg** *> browser.merge a=ret b=msg*
2. * 2. *
**> browser.set_text sel="#log" text="no draft"** *> browser.set_text sel="#log" text="no draft"*
## start_tick ## start_tick
**> browser.interval ms=1000 then="on_tick" id="tick"** *> browser.interval ms=1000 then="on_tick" id="tick"*
## stop_tick ## stop_tick
**> browser.clear_interval id="tick"** *> browser.clear_interval id="tick"*
## on_tick ## on_tick
+ `ok`=True + `ok`=True
+ `id`="" + `id`=""
*`ticks` = ticks + 1* **`ticks` = ticks + 1**
*`label` = > str ticks* **`label` = > str ticks**
**> browser.set_text sel="#tick" text=label** *> browser.set_text sel="#tick" text=label*
## go_home ## go_home
*`path` = "/"* **`path` = "/"**
**> show_path** *> show_path*
## go_about ## go_about
*`path` = "/about"* **`path` = "/about"**
**> show_path** *> show_path*
## go_net ## go_net
*`path` = "/net"* **`path` = "/net"**
**> show_path** *> show_path*
## on_pop ## on_pop
+ `path`="" + `path`=""
*`path` = path* **`path` = path**
**> show_path** *> show_path*
## show_path ## show_path
*`hide` = > table.put in=None at="hidden" value=""* **`hide` = > table.put in=None at="hidden" value=""**
*`show` = > table.put in=None at="hidden" value=False* **`show` = > table.put in=None at="hidden" value=False**
1. `path` == "/about" 1. `path` == "/about"
`attrs` = `attrs` =
@@ -190,12 +190,12 @@ import text:lib/text.mq.md
| #panel-home | #panel-about | #panel-net | | #panel-home | #panel-about | #panel-net |
|-------------|--------------|------------| |-------------|--------------|------------|
| `show` | `hide` | `hide` | | `show` | `hide` | `hide` |
*`label` = "path: " + path* **`label` = "path: " + path**
*`ret` = > browser.set_text sel="#path" text=label* **`ret` = > browser.set_text sel="#path" text=label**
*`a` = > browser.wrap key="set_attr" value=attrs* **`a` = > browser.wrap key="set_attr" value=attrs**
*`ret` = > browser.merge a=ret b=a* **`ret` = > browser.merge a=ret b=a**
*`nav` = > browser.navigate url=path* **`nav` = > browser.navigate url=path**
**> browser.merge a=ret b=nav** *> browser.merge a=ret b=nav*
## do_fetch_all ## do_fetch_all
@@ -206,15 +206,15 @@ import text:lib/text.mq.md
| 1 | "https://httpbin.org/uuid" | | 1 | "https://httpbin.org/uuid" |
| 2 | "https://httpbin.org/uuid" | | 2 | "https://httpbin.org/uuid" |
*`msg` = > browser.set_text sel="#net-out" text="fetch_all…"* **`msg` = > browser.set_text sel="#net-out" text="fetch_all…"**
*`fa` = > browser.fetch_all requests=reqs then="on_fetch_all"* **`fa` = > browser.fetch_all requests=reqs then="on_fetch_all"**
**> browser.merge a=msg b=fa** *> browser.merge a=msg b=fa*
## on_fetch_all ## on_fetch_all
+ `ok`=True + `ok`=True
+ `results`=None + `results`=None
**> browser.set_text sel="#net-out" text="fetch_all done (see console / results in session)"** *> browser.set_text sel="#net-out" text="fetch_all done (see console / results in session)"*
## ws_open ## ws_open
@@ -224,32 +224,32 @@ import text:lib/text.mq.md
|----|----|-----|-----------|--------------|------------|------------| |----|----|-----|-----------|--------------|------------|------------|
| open | `ws_id` | "wss://echo.websocket.events" | on_ws_open | on_ws_msg | on_ws_err | on_ws_close | | open | `ws_id` | "wss://echo.websocket.events" | on_ws_open | on_ws_msg | on_ws_err | on_ws_close |
**> browser.ws spec=w** *> browser.ws spec=w*
## on_ws_open ## on_ws_open
+ `ok`=True + `ok`=True
+ `id`="" + `id`=""
**> browser.set_text sel="#net-out" text="ws open"** *> browser.set_text sel="#net-out" text="ws open"*
## on_ws_msg ## on_ws_msg
+ `ok`=True + `ok`=True
+ `data`="" + `data`=""
*`msg` = "ws ← " + data* **`msg` = "ws ← " + data**
**> browser.set_text sel="#net-out" text=msg** *> browser.set_text sel="#net-out" text=msg*
## on_ws_err ## on_ws_err
+ `ok`=False + `ok`=False
+ `error`="" + `error`=""
*`msg` = "ws error: " + error* **`msg` = "ws error: " + error**
**> browser.set_text sel="#net-out" text=msg** *> browser.set_text sel="#net-out" text=msg*
## on_ws_close ## on_ws_close
+ `ok`=True + `ok`=True
**> browser.set_text sel="#net-out" text="ws closed"** *> browser.set_text sel="#net-out" text="ws closed"*
## ws_send ## ws_send
+ `value`="" + `value`=""
@@ -260,7 +260,7 @@ import text:lib/text.mq.md
|----|----|------| |----|----|------|
| send | `ws_id` | `value` | | send | `ws_id` | `value` |
**> browser.ws spec=w** *> browser.ws spec=w*
## ws_close ## ws_close
@@ -270,14 +270,14 @@ import text:lib/text.mq.md
|----|----| |----|----|
| close | `ws_id` | | close | `ws_id` |
**> browser.ws spec=w** *> browser.ws spec=w*
## copy_log ## copy_log
*`msg` = > browser.set_text sel="#log" text="copied bag to clipboard"* **`msg` = > browser.set_text sel="#log" text="copied bag to clipboard"**
*`c` = > browser.clipboard text=bag* **`c` = > browser.clipboard text=bag**
**> browser.merge a=msg b=c** *> browser.merge a=msg b=c*
## dl_list ## dl_list
*`msg` = > browser.set_text sel="#log" text="download started"* **`msg` = > browser.set_text sel="#log" text="download started"**
*`d` = > browser.download body=bag filename="items.txt"* **`d` = > browser.download body=bag filename="items.txt"**
**> browser.merge a=msg b=d** *> browser.merge a=msg b=d*
+7 -7
View File
@@ -6,7 +6,7 @@ import browser:lib/browser.mq.md
# main # main
*`count` = 0* **`count` = 0**
`wire` = `wire` =
@@ -15,13 +15,13 @@ import browser:lib/browser.mq.md
| 1 | "#bump" | click | bump | | 1 | "#bump" | click | bump |
| 2 | "#reset" | click | reset | | 2 | "#reset" | click | reset |
**`wire`** *`wire`*
## bump ## bump
*`count` = count + 1* **`count` = count + 1**
*`label` = > str count* **`label` = > str count**
**> browser.set_text sel="#count" text=label** *> browser.set_text sel="#count" text=label*
## reset ## reset
*`count` = 0* **`count` = 0**
**> browser.set_text sel="#count" text="0"** *> browser.set_text sel="#count" text="0"*
+10 -10
View File
@@ -13,12 +13,12 @@ import browser:lib/browser.mq.md
| 1 | "#load" | click | load | | 1 | "#load" | click | load |
| 2 | "#ping" | click | ping | | 2 | "#ping" | click | ping |
**`wire`** *`wire`*
## load ## load
*`msg` = > browser.set_text sel="#status" text="loading…"* **`msg` = > browser.set_text sel="#status" text="loading…"**
*`req` = > browser.fetch url="https://httpbin.org/uuid" then="on_uuid"* **`req` = > browser.fetch url="https://httpbin.org/uuid" then="on_uuid"**
**> browser.merge a=msg b=req** *> browser.merge a=msg b=req*
## on_uuid ## on_uuid
+ `ok` + `ok`
@@ -27,16 +27,16 @@ import browser:lib/browser.mq.md
+ `error`="" + `error`=""
1. ok 1. ok
**> browser.set_text sel="#status" text=body** *> browser.set_text sel="#status" text=body*
2. * 2. *
**> browser.set_text sel="#status" text="fetch failed"** *> browser.set_text sel="#status" text="fetch failed"*
## ping ## ping
*`msg` = > browser.set_text sel="#status" text="wait 600ms…"* **`msg` = > browser.set_text sel="#status" text="wait 600ms…"**
*`t` = > browser.after ms=600 then="on_ping"* **`t` = > browser.after ms=600 then="on_ping"**
**> browser.merge a=msg b=t** *> browser.merge a=msg b=t*
## on_ping ## on_ping
+ `ok`=True + `ok`=True
**> browser.set_text sel="#status" text="pong"** *> browser.set_text sel="#status" text="pong"*
+11 -11
View File
@@ -13,21 +13,21 @@ import table:lib/table.mq.md
|---|--------|------|------| |---|--------|------|------|
| 1 | "#name" | input | on_input | | 1 | "#name" | input | on_input |
**`wire`** *`wire`*
## on_input ## on_input
+ `value`="" + `value`=""
+ `event`="" + `event`=""
1. `value` != "" 1. `value` != ""
*`label` = "你好," + value* **`label` = "你好," + value**
*`ret` = > browser.set_text sel="#echo" text=label* **`ret` = > browser.set_text sel="#echo" text=label**
*`cls` = > browser.set_class sel="#echo" class="hi"* **`cls` = > browser.set_class sel="#echo" class="hi"**
*`ret` = > browser.merge a=ret b=cls* **`ret` = > browser.merge a=ret b=cls**
*`attrs` = > table.put in=None at="data-name" value=value* **`attrs` = > table.put in=None at="data-name" value=value**
*`attr` = > browser.set_attr sel="#echo" attrs=attrs* **`attr` = > browser.set_attr sel="#echo" attrs=attrs**
**> browser.merge a=ret b=attr** *> browser.merge a=ret b=attr*
2. * 2. *
*`ret` = > browser.set_text sel="#echo" text="(等待输入)"* **`ret` = > browser.set_text sel="#echo" text="(等待输入)"**
*`cls` = > browser.set_class sel="#echo" class=""* **`cls` = > browser.set_class sel="#echo" class=""**
**> browser.merge a=ret b=cls** *> browser.merge a=ret b=cls*
+51 -51
View File
@@ -9,7 +9,7 @@ import table:lib/table.mq.md
Route F demo: author data stays in tables; effects via `browser.*`. Route F demo: author data stays in tables; effects via `browser.*`.
*`obs_on` = False* **`obs_on` = False**
`wire` = `wire` =
@@ -25,15 +25,15 @@ Route F demo: author data stays in tables; effects via `browser.*`.
| 8 | "#dropzone" | dragover | on_dragover | | | 8 | "#dropzone" | dragover | on_dragover | |
| 9 | "#dropzone" | drop | on_drop | | | 9 | "#dropzone" | drop | on_drop | |
*`ready` = > browser.set_text sel="#log" text="ready (route F)"* **`ready` = > browser.set_text sel="#log" text="ready (route F)"**
*`boot` = > table.put in=None at="wire" value=wire* **`boot` = > table.put in=None at="wire" value=wire**
**> browser.merge a=boot b=ready** *> browser.merge a=boot b=ready*
## read_text ## read_text
**> browser.read_file sel="#file" then="on_file" as="text"** *> browser.read_file sel="#file" then="on_file" as="text"*
## read_dataurl ## read_dataurl
**> browser.read_file sel="#file" then="on_file" as="data_url"** *> browser.read_file sel="#file" then="on_file" as="data_url"*
## on_file ## on_file
+ `ok`=False + `ok`=False
@@ -46,25 +46,25 @@ Route F demo: author data stays in tables; effects via `browser.*`.
1. `ok` 1. `ok`
1. `as` == "data_url" 1. `as` == "data_url"
*`n` = > len value=data_url* **`n` = > len value=data_url**
*`ns` = > str `n`* **`ns` = > str `n`**
*`preview` = name + " data_url chars=" + ns* **`preview` = name + " data_url chars=" + ns**
*`ret` = > browser.set_text sel="#log" text=preview* **`ret` = > browser.set_text sel="#log" text=preview**
1. `data_url` != "" 1. `data_url` != ""
*`h` = "<img alt=\"preview\" src=\"" + data_url + "\" style=\"max-width:12rem;max-height:8rem\" />"* **`h` = "<img alt=\"preview\" src=\"" + data_url + "\" style=\"max-width:12rem;max-height:8rem\" />"**
*`img` = > browser.set_html sel="#preview" html=h* **`img` = > browser.set_html sel="#preview" html=h**
**> browser.merge a=ret b=img** *> browser.merge a=ret b=img*
2. * 2. *
**ret** *ret*
2. * 2. *
*`n` = > len value=body* **`n` = > len value=body**
*`ns` = > str `n`* **`ns` = > str `n`**
*`ss` = > str `size`* **`ss` = > str `size`**
*`preview` = name + " (" + ss + " B, chars=" + ns + ") ok"* **`preview` = name + " (" + ss + " B, chars=" + ns + ") ok"**
**> browser.set_text sel="#log" text=preview** *> browser.set_text sel="#log" text=preview*
2. * 2. *
*`preview` = "file error: " + error* **`preview` = "file error: " + error**
**> browser.set_text sel="#log" text=preview** *> browser.set_text sel="#log" text=preview*
## draw_box ## draw_box
@@ -78,17 +78,17 @@ Canvas commands as a readable `@` table:
| 2 | strokerect | 20 | 20 | 100 | 60 | | "#122018" | | | 2 | strokerect | 20 | 20 | 100 | 60 | | "#122018" | |
| 3 | filltext | 40 | 55 | | | "#f5faf6" | | Marqdo | | 3 | filltext | 40 | 55 | | | "#f5faf6" | | Marqdo |
*`cv` = > browser.canvas sel="#pad" commands=commands clear=True* **`cv` = > browser.canvas sel="#pad" commands=commands clear=True**
*`msg` = > browser.set_text sel="#log" text="canvas drawn"* **`msg` = > browser.set_text sel="#log" text="canvas drawn"**
**> browser.merge a=cv b=msg** *> browser.merge a=cv b=msg*
## play_tone ## play_tone
*`tone` = > browser.audio op="play" id="demo" src="beep" freq=523 ms=220* **`tone` = > browser.audio op="play" id="demo" src="beep" freq=523 ms=220**
*`msg` = > browser.set_text sel="#log" text="audio beep"* **`msg` = > browser.set_text sel="#log" text="audio beep"**
**> browser.merge a=tone b=msg** *> browser.merge a=tone b=msg*
## start_watch ## start_watch
*`obs_on` = True* **`obs_on` = True**
`obs` = `obs` =
@@ -97,12 +97,12 @@ Canvas commands as a readable `@` table:
| 1 | intersect | "#beacon" | beacon | on_intersect | 0.25 | | 1 | intersect | "#beacon" | beacon | on_intersect | 0.25 |
| 2 | resize | "#pad" | pad | on_resize | | | 2 | resize | "#pad" | pad | on_resize | |
*`o` = > browser.observe specs=obs* **`o` = > browser.observe specs=obs**
*`msg` = > browser.set_text sel="#log" text="observers on"* **`msg` = > browser.set_text sel="#log" text="observers on"**
**> browser.merge a=o b=msg** *> browser.merge a=o b=msg*
## stop_watch ## stop_watch
*`obs_on` = False* **`obs_on` = False**
`ids` = `ids` =
@@ -111,23 +111,23 @@ Canvas commands as a readable `@` table:
| 1 | beacon | | 1 | beacon |
| 2 | pad | | 2 | pad |
*`u` = > browser.unobserve specs=ids* **`u` = > browser.unobserve specs=ids**
*`msg` = > browser.set_text sel="#log" text="observers off"* **`msg` = > browser.set_text sel="#log" text="observers off"**
**> browser.merge a=u b=msg** *> browser.merge a=u b=msg*
## on_intersect ## on_intersect
+ `intersecting`=False + `intersecting`=False
+ `ratio`=0 + `ratio`=0
1. `obs_on` 1. `obs_on`
*`state` = "hidden"* **`state` = "hidden"**
1. `intersecting` 1. `intersecting`
*`state` = "visible"* **`state` = "visible"**
2. * 2. *
--- ---
*`r` = > str `ratio`* **`r` = > str `ratio`**
*`msg` = "beacon " + state + " ratio=" + r* **`msg` = "beacon " + state + " ratio=" + r**
**> browser.set_text sel="#obs" text=msg** *> browser.set_text sel="#obs" text=msg*
2. * 2. *
**** ****
@@ -136,18 +136,18 @@ Canvas commands as a readable `@` table:
+ `height`=0 + `height`=0
1. `obs_on` 1. `obs_on`
*`w` = > str `width`* **`w` = > str `width`**
*`h` = > str `height`* **`h` = > str `height`**
*`msg` = "pad size " + w + "×" + h* **`msg` = "pad size " + w + "×" + h**
**> browser.set_text sel="#obs" text=msg** *> browser.set_text sel="#obs" text=msg*
2. * 2. *
**** ****
## on_drag ## on_drag
+ `drag`="" + `drag`=""
*`msg` = "dragging: " + drag* **`msg` = "dragging: " + drag**
**> browser.set_text sel="#log" text=msg** *> browser.set_text sel="#log" text=msg*
## on_dragover ## on_dragover
**** ****
@@ -155,8 +155,8 @@ Canvas commands as a readable `@` table:
## on_drop ## on_drop
+ `drop_text`="" + `drop_text`=""
*`msg` = "dropped: " + drop_text* **`msg` = "dropped: " + drop_text**
*`h` = "<strong>" + drop_text + "</strong>"* **`h` = "<strong>" + drop_text + "</strong>"**
*`t` = > browser.set_text sel="#log" text=msg* **`t` = > browser.set_text sel="#log" text=msg**
*`box` = > browser.set_html sel="#dropzone" html=h* **`box` = > browser.set_html sel="#dropzone" html=h**
**> browser.merge a=t b=box** *> browser.merge a=t b=box*
+7
View File
@@ -0,0 +1,7 @@
# 代码即文档 · 周末咖啡手账
```bash
marqdo run examples/code-as-docs/index.mq.md
```
菜单与订单是表,计价嵌在段落里,结账像写日记。取元用 `[键](集合)`,循环用 `- [行](订单)`,与 [collection-access-link.md](../../doc/design/collection-access-link.md) 一致。
+86
View File
@@ -0,0 +1,86 @@
---
title: 代码即文档 · 周末咖啡手账
description: >-
一份可读可跑的周末手账:菜单是表,计价写在段落里,结账读起来像日记。
---
周六的咖啡馆手账——下面既是给人看的说明,也是可以 `marqdo run` 的程序。
**说明**性的加粗只是强调;真正算账的步骤也用粗体写在句子里,算完的值用斜体交回去。
---
## 单价
一杯标价为`价`的饮品,默认`杯数`=1。先把**总额 = 价 * 杯数**算清,再返回*总额*。
## 会员折
会员单要原价`原价`;店里默认八五折,记作`折扣`=0.85。
先算**应付 = 原价 * 折扣**,再返回*应付*。
## 结账摘要
客人点了`品名`,单价`价`,杯数`杯数`=1;是否`会员`=False。
按杯数问单价:**小计 = 单价 价=`价` 杯数=`杯数`**。
1. `会员`
**实付 = 会员折 原价=`小计`**
**标签 = "会员价"**
2. *
**实付 = 小计**
**标签 = "原价"**
对账时拼成一句人话:
**文案 = 品名 + " ×" + 杯数 + " → " + 标签 + " " + 实付**
*文案*
## 印章加一
积分卡上的`印`,每喝一杯就**印 = 印 + 1**,接着返回*印*。
# main
今日黑板价目——表格给人扫一眼,程序当字典用:
`菜单` =
| 美式 | 拿铁 | 燕麦拿铁 |
|------|------|----------|
| 18 | 28 | 32 |
---
上午来了位会员,点两杯拿铁。品名写进`名`,价钱从菜单里取:
**名 = "拿铁"**
**价 = [`名`](菜单)**
**摘要 = [结账摘要] 品名=`名` 价=`价` 杯数=2 会员=True**
**打印 内容=`摘要`**
旁桌只要一杯普通美式,对照一下原价:
**对照 = [结账摘要] 品名="美式" 价=[美式](菜单)**
**打印 内容=`对照`**
---
下午把外卖单抄成行表,一行一行结:
`今日订单` =
| @ | 品名 | 单价 | 杯数 | 会员 |
|---|------|------|------|------|
| 1 | 燕麦拿铁 | 32 | 1 | True |
| 2 | 美式 | 18 | 2 | False |
- [行](今日订单)
**一行 = 结账摘要 品名=[品名](行) 价=[单价](行) 杯数=[杯数](行) 会员=[会员](行)**
**打印 内容=`一行`**
打烊前给积分卡盖一个章:
**印 = 41**
**印 = 印章加一 印=`印`**
**打印 内容=`印`**
+6 -6
View File
@@ -21,14 +21,14 @@ $$
\begin{pmatrix}1\\2\\2\end{pmatrix} \begin{pmatrix}1\\2\\2\end{pmatrix}
$$ $$
*`A` = > la.from_formula formula=`A`* **`A` = > la.from_formula formula=`A`**
*`b` = > la.from_formula formula=`b`* **`b` = > la.from_formula formula=`b`**
*`_` = > la.draw factor=`A` kind="heatmap" theme="light" path="ls-heatmap.svg"* **`_` = > la.draw factor=`A` kind="heatmap" theme="light" path="ls-heatmap.svg"**
*`ls` = > la.lstsq a=`A` b=`b`* **`ls` = > la.lstsq a=`A` b=`b`**
*`x` = ls[^x]* **`x` = [x](ls)**
*`resid` = ls[^residual_fro]* **`resid` = [residual_fro](ls)**
> print text=`x` > print text=`x`
> print text=`resid` > print text=`resid`
+5 -5
View File
@@ -15,11 +15,11 @@ $$
\begin{bmatrix}4&0\\0&2\end{bmatrix} \begin{bmatrix}4&0\\0&2\end{bmatrix}
$$ $$
*`M` = > la.from_formula formula=`M`* **`M` = > la.from_formula formula=`M`**
*`f` = > la.factorize matrix=`M` kind="svd"* **`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"* **`_` = > la.draw factor=`f` kind="svd" theme="light" path="svd-structure.svg"**
*`hm` = > la.draw factor=`M` kind="hinton" path="svd-hinton.svg"* **`hm` = > la.draw factor=`M` kind="hinton" path="svd-hinton.svg"**
> print text=`S` > print text=`S`
> print text=svd-ok > print text=svd-ok
+5 -5
View File
@@ -17,11 +17,11 @@ Declare shapes in a table, form \(P = AB\), then check \((AB)^\top = B^\top A^\t
| 1 | A | 2 | 3 | | 1 | A | 2 | 3 |
| 2 | B | 3 | 2 | | 2 | B | 3 | 2 |
*`env` = > la.declare table=`shapes`* **`env` = > la.declare table=`shapes`**
*`A` = env[^A]* **`A` = [A](env)**
*`B` = env[^B]* **`B` = [B](env)**
*`P` = `A` * `B`* **`P` = `A` * `B`**
*`t` = > `P`.T_ascii* **`t` = > `P`.T_ascii**
> print text=`t` > print text=`t`
1. `t` == "B^T*A^T" 1. `t` == "B^T*A^T"
> print text=identity-ok > print text=identity-ok
+1 -1
View File
@@ -10,4 +10,4 @@
| 关于 | /about | | | 关于 | /about | |
| 后台 | /admin | | | 后台 | /admin | |
**`页脚`** *`页脚`*
+1 -1
View File
@@ -12,4 +12,4 @@
| 关于 | /about | | | 关于 | /about | |
| 后台 | /admin | | | 后台 | /admin | |
**`导航`** *`导航`*
+1 -1
View File
@@ -12,4 +12,4 @@
| 发布文章 | /admin/new | | | 发布文章 | /admin/new | |
| 实时终端 | /#live | | | 实时终端 | /#live | |
**`侧栏`** *`侧栏`*
+10 -10
View File
@@ -8,21 +8,21 @@ import seed:seed.mq.md
## 打开 ## 打开
*store = > 网页.数据库 地址="sqlite:data/marqdo-blog.db"* **store = > 网页.数据库 地址="sqlite:data/marqdo-blog.db"**
*字段 = > schema.posts* **字段 = > schema.posts**
*标签字段 = > schema.tags* **标签字段 = > schema.tags**
*关联字段 = > schema.post_tags* **关联字段 = > schema.post_tags**
> `store`.初始化 名=posts 字段=`字段` > `store`.初始化 名=posts 字段=`字段`
> `store`.初始化 名=tags 字段=`标签字段` > `store`.初始化 名=tags 字段=`标签字段`
> `store`.初始化 名=post_tags 字段=`关联字段` > `store`.初始化 名=post_tags 字段=`关联字段`
*行 = > store.查询 表="posts" 上限=1* **行 = > store.查询 表="posts" 上限=1**
1. `行` 1. `行`
**store** *store*
2. * 2. *
*文章 = > seed.posts* **文章 = > seed.posts**
*标签 = > seed.tags* **标签 = > seed.tags**
*关联 = > seed.post_tags* **关联 = > seed.post_tags**
> `store`.插入 表=posts 行=`文章` > `store`.插入 表=posts 行=`文章`
> `store`.插入 表=tags 行=`标签` > `store`.插入 表=tags 行=`标签`
> `store`.插入 表=post_tags 行=`关联` > `store`.插入 表=post_tags 行=`关联`
**store** *store*
+3 -3
View File
@@ -15,7 +15,7 @@
| created_at | text | true | | created_at | text | true |
| updated_at | text | true | | updated_at | text | true |
**`schema`** *`schema`*
## tags ## tags
@@ -29,7 +29,7 @@
| name | text | false | | name | text | false |
| slug | text | false | | slug | text | false |
**`tags`** *`tags`*
## post_tags ## post_tags
@@ -43,4 +43,4 @@
| post_id | integer | false | | post_id | integer | false |
| tag_id | integer | false | | tag_id | integer | false |
**`post_tags`** *`post_tags`*
+3 -3
View File
@@ -13,7 +13,7 @@
| 5 | 会话与登录鉴权 | session-auth | 后台用 session 门禁保护,只有登录用户能发布文章。 | 用 app.鉴权 配置管理员用户表,/admin 下的 CRUD 页面都需要有效会话。 | web | 2026-08-18 | 2026-08-20 | | 5 | 会话与登录鉴权 | session-auth | 后台用 session 门禁保护,只有登录用户能发布文章。 | 用 app.鉴权 配置管理员用户表,/admin 下的 CRUD 页面都需要有效会话。 | web | 2026-08-18 | 2026-08-20 |
| 6 | 数据库与 CRUD | database-crud | 博客的文章、标签、关联全部由 SQLite 支撑。 | db.初始化 建表、db.插入 写种子、后台表单增删改。文章与标签通过 post_tags 关联。 | database | 2026-08-20 | 2026-08-21 | | 6 | 数据库与 CRUD | database-crud | 博客的文章、标签、关联全部由 SQLite 支撑。 | db.初始化 建表、db.插入 写种子、后台表单增删改。文章与标签通过 post_tags 关联。 | database | 2026-08-20 | 2026-08-21 |
**`posts`** *`posts`*
## tags ## tags
@@ -29,7 +29,7 @@
| 4 | 数据库 | database | | 4 | 数据库 | database |
| 5 | 实时 | realtime | | 5 | 实时 | realtime |
**`tags`** *`tags`*
## post_tags ## post_tags
@@ -50,4 +50,4 @@
| 9 | 6 | 4 | | 9 | 6 | 4 |
| 10 | 6 | 1 | | 10 | 6 | 1 |
**`post_tags`** *`post_tags`*
+38 -38
View File
@@ -83,49 +83,49 @@ import db:db/index.mq.md
|----|------|----|------|------|------| |----|------|----|------|------|------|
| "/static/logo.svg" | Marqdo | brand-logo | "/" | 40 | eager | | "/static/logo.svg" | Marqdo | brand-logo | "/" | 40 | eager |
*store = > db.打开* **store = > db.打开**
*首页CSS = > theme.全局* **首页CSS = > theme.全局**
*page = > 网页.页面 标题="Marqdo 博客" 引言="<h1>Marqdo 博客</h1><p>用 web 扩展库搭建的博客:表格装配页面、SQLite 数据、动态路由、实时终端。</p><h2 id=\"live\">实时终端</h2><p id=\"live-status\" class=\"live-pill\">connecting…</p><input id=\"live-msg\" placeholder=\"输入一条消息…\"><button id=\"live-send\" disabled>发送</button><div id=\"live-out\"></div><script src=\"/static/live.js\"></script>"* **page = > 网页.页面 标题="Marqdo 博客" 引言="<h1>Marqdo 博客</h1><p>用 web 扩展库搭建的博客:表格装配页面、SQLite 数据、动态路由、实时终端。</p><h2 id=\"live\">实时终端</h2><p id=\"live-status\" class=\"live-pill\">connecting…</p><input id=\"live-msg\" placeholder=\"输入一条消息…\"><button id=\"live-send\" disabled>发送</button><div id=\"live-out\"></div><script src=\"/static/live.js\"></script>"**
*page = > page.组件装配 组件=`首页`* **page = > page.组件装配 组件=`首页`**
*page = > page.主体装配 主体=`列表`* **page = > page.主体装配 主体=`列表`**
*page = > page.排序 排序="-created_at"* **page = > page.排序 排序="-created_at"**
*page = > page.样式 样式=`首页CSS`* **page = > page.样式 样式=`首页CSS`**
*page = > page.头装配 表=`头资源`* **page = > page.头装配 表=`头资源`**
*page = > page.图片装配 表=`品牌图`* **page = > page.图片装配 表=`品牌图`**
*about = > 网页.页面 标题="关于" 引言="<h1>关于本站</h1><p>一个用 Marqdo 的 web 扩展库(ext/web)写成的博客系统。</p><p>它演示了:GFM 表格装配导航与侧栏、SQLite 驱动的主体绑定、动态路由 /post/{slug}、标签归档、以及受 session 保护的后台 CRUD。</p>"* **about = > 网页.页面 标题="关于" 引言="<h1>关于本站</h1><p>一个用 Marqdo 的 web 扩展库(ext/web)写成的博客系统。</p><p>它演示了:GFM 表格装配导航与侧栏、SQLite 驱动的主体绑定、动态路由 /post/{slug}、标签归档、以及受 session 保护的后台 CRUD。</p>"**
*about = > about.组件装配 组件=`首页`* **about = > about.组件装配 组件=`首页`**
*about = > about.样式 样式=`首页CSS`* **about = > about.样式 样式=`首页CSS`**
*post = > 网页.页面 标题="文章"* **post = > 网页.页面 标题="文章"**
*post = > post.组件装配 组件=`首页`* **post = > post.组件装配 组件=`首页`**
*post = > post.主体装配 主体=`详情绑定`* **post = > post.主体装配 主体=`详情绑定`**
*post = > post.查询条件 条件=`文章条件`* **post = > post.查询条件 条件=`文章条件`**
*post = > post.详情 详情=True* **post = > post.详情 详情=True**
*post = > post.样式 样式=`首页CSS`* **post = > post.样式 样式=`首页CSS`**
*tags = > 网页.页面 标题="标签归档" 引言="<h1>标签归档</h1><p>点击标签查看该主题下的文章。</p>"* **tags = > 网页.页面 标题="标签归档" 引言="<h1>标签归档</h1><p>点击标签查看该主题下的文章。</p>"**
*tags = > tags.组件装配 组件=`首页`* **tags = > tags.组件装配 组件=`首页`**
*tags = > tags.主体装配 主体=`标签列表`* **tags = > tags.主体装配 主体=`标签列表`**
*tags = > tags.链接前缀 前缀="/tag/"* **tags = > tags.链接前缀 前缀="/tag/"**
*tags = > tags.样式 样式=`首页CSS`* **tags = > tags.样式 样式=`首页CSS`**
*tagged = > 网页.页面 标题="标签"* **tagged = > 网页.页面 标题="标签"**
*tagged = > tagged.组件装配 组件=`首页`* **tagged = > tagged.组件装配 组件=`首页`**
*tagged = > tagged.主体装配 主体=`列表`* **tagged = > tagged.主体装配 主体=`列表`**
*tagged = > tagged.查询条件 条件=`标签条件`* **tagged = > tagged.查询条件 条件=`标签条件`**
*tagged = > tagged.排序 排序="-created_at"* **tagged = > tagged.排序 排序="-created_at"**
*tagged = > tagged.样式 样式=`首页CSS`* **tagged = > tagged.样式 样式=`首页CSS`**
*app = > 网页.应用 页面=page 数据库=store 后台=True 主机="127.0.0.1" 端口=18085* **app = > 网页.应用 页面=page 数据库=store 后台=True 主机="127.0.0.1" 端口=18085**
*app = > app.路由 路径="/about" 页面=about* **app = > app.路由 路径="/about" 页面=about**
*app = > app.路由 路径="/post/{slug}" 页面=post* **app = > app.路由 路径="/post/{slug}" 页面=post**
*app = > app.路由 路径="/tags" 页面=tags* **app = > app.路由 路径="/tags" 页面=tags**
*app = > app.路由 路径="/tag/{slug}" 页面=tagged* **app = > app.路由 路径="/tag/{slug}" 页面=tagged**
*app = > app.静态 目录="public" 挂载="/static"* **app = > app.静态 目录="public" 挂载="/static"**
*app = > app.图标 表=`站点图标`* **app = > app.图标 表=`站点图标`**
*app = > app.路由实时 路径="/live" 回显=True* **app = > app.路由实时 路径="/live" 回显=True**
*app = > app.鉴权 用户表=`管理员` 会话时长=3600* **app = > app.鉴权 用户表=`管理员` 会话时长=3600**
> `app`.监听 > `app`.监听
+26 -26
View File
@@ -47,7 +47,7 @@ import text:lib/text.mq.md
| body.has-sidebar | grid-template-areas | "top top" "side main" "foot foot" | | body.has-sidebar | grid-template-areas | "top top" "side main" "foot foot" |
| body.no-sidebar | grid-template-areas | "top" "main" "foot" | | body.no-sidebar | grid-template-areas | "top" "main" "foot" |
**`基础`** *`基础`*
## 顶栏 ## 顶栏
@@ -96,7 +96,7 @@ import text:lib/text.mq.md
| ul.nav li:first-child a | padding-left | .2rem | | ul.nav li:first-child a | padding-left | .2rem |
| ul.nav li:first-child a | padding-right | .2rem | | ul.nav li:first-child a | padding-right | .2rem |
**`顶栏`** *`顶栏`*
## 侧栏 ## 侧栏
@@ -129,7 +129,7 @@ import text:lib/text.mq.md
| ul.side-nav a:hover | transform | translateX(4px) | | ul.side-nav a:hover | transform | translateX(4px) |
| ul.side-nav a:hover | box-shadow | 0 1px 3px rgba(28,25,23,.08) | | ul.side-nav a:hover | box-shadow | 0 1px 3px rgba(28,25,23,.08) |
**`侧栏`** *`侧栏`*
## 主体 ## 主体
@@ -154,7 +154,7 @@ import text:lib/text.mq.md
| .main-intro p | margin | 0 | | .main-intro p | margin | 0 |
| .main-intro p | font-size | 1.05rem | | .main-intro p | font-size | 1.05rem |
**`主体`** *`主体`*
## 卡片 ## 卡片
@@ -210,7 +210,7 @@ import text:lib/text.mq.md
| .content.cards p | font-size | .95rem | | .content.cards p | font-size | .95rem |
| .content.cards p | flex | 1 | | .content.cards p | flex | 1 |
**`卡片`** *`卡片`*
## 页脚 ## 页脚
@@ -240,7 +240,7 @@ import text:lib/text.mq.md
| ul.foot-nav a | text-decoration | none | | ul.foot-nav a | text-decoration | none |
| ul.foot-nav a:hover | color | var(--accent) | | ul.foot-nav a:hover | color | var(--accent) |
**`页脚`** *`页脚`*
## 表单 ## 表单
@@ -341,7 +341,7 @@ import text:lib/text.mq.md
| .site-form .admin-list a | text-decoration | none | | .site-form .admin-list a | text-decoration | none |
| .site-form .admin-list a | font-size | .9rem | | .site-form .admin-list a | font-size | .9rem |
**`表单`** *`表单`*
## 响应式 ## 响应式
@@ -364,29 +364,29 @@ import text:lib/text.mq.md
| (max-width: 860px) | .content.cards | grid-template-columns | 1fr | | (max-width: 860px) | .content.cards | grid-template-columns | 1fr |
| (max-width: 520px) | ul.nav | flex-wrap | wrap | | (max-width: 520px) | ul.nav | flex-wrap | wrap |
**`响应式`** *`响应式`*
## 全局 ## 全局
用 样式装配 函数逐个把段落表装配成 CSS,再拼接成完整样式表。 用 样式装配 函数逐个把段落表装配成 CSS,再拼接成完整样式表。
*基础表 = > 基础* **基础表 = > 基础**
*顶栏表 = > 顶栏* **顶栏表 = > 顶栏**
*侧栏表 = > 侧栏* **侧栏表 = > 侧栏**
*主体表 = > 主体* **主体表 = > 主体**
*卡片表 = > 卡片* **卡片表 = > 卡片**
*页脚表 = > 页脚* **页脚表 = > 页脚**
*表单表 = > 表单* **表单表 = > 表单**
*响应式表 = > 响应式* **响应式表 = > 响应式**
*css基础 = > 网页.样式装配 名="基础" 表=`基础表`* **css基础 = > 网页.样式装配 名="基础" 表=`基础表`**
*css顶栏 = > 网页.样式装配 名="顶栏" 表=`顶栏表`* **css顶栏 = > 网页.样式装配 名="顶栏" 表=`顶栏表`**
*css侧栏 = > 网页.样式装配 名="侧栏" 表=`侧栏表`* **css侧栏 = > 网页.样式装配 名="侧栏" 表=`侧栏表`**
*css主体 = > 网页.样式装配 名="主体" 表=`主体表`* **css主体 = > 网页.样式装配 名="主体" 表=`主体表`**
*css卡片 = > 网页.样式装配 名="卡片" 表=`卡片表`* **css卡片 = > 网页.样式装配 名="卡片" 表=`卡片表`**
*css页脚 = > 网页.样式装配 名="页脚" 表=`页脚表`* **css页脚 = > 网页.样式装配 名="页脚" 表=`页脚表`**
*css表单 = > 网页.样式装配 名="表单" 表=`表单表`* **css表单 = > 网页.样式装配 名="表单" 表=`表单表`**
*css响应式 = > 网页.样式装配 名="响应式" 表=`响应式表`* **css响应式 = > 网页.样式装配 名="响应式" 表=`响应式表`**
`css段` = `css段` =
@@ -401,5 +401,5 @@ import text:lib/text.mq.md
| `css表单` | | `css表单` |
| `css响应式` | | `css响应式` |
*css = > text.str_join xs=`css段` sep=""* **css = > text.str_join xs=`css段` sep=""**
**css** *css*
+4 -4
View File
@@ -19,9 +19,9 @@ H on qubit 0, then CNOT(0→1). Ideal measurement: |00⟩ and |11⟩ each with p
| 1 | H | 0 | | 1 | H | 0 |
| 2 | CX | 0,1 | | 2 | CX | 0,1 |
*qc = > quantum.circuit qubits=2 steps=`steps`* **qc = > quantum.circuit qubits=2 steps=`steps`**
*p = > qc.probabilities* **p = > qc.probabilities**
*_ = > qc.draw path="bell.svg"* **_ = > qc.draw path="bell.svg"**
*_ = > qc.draw kind="probs" path="bell-probs.svg"* **_ = > qc.draw kind="probs" path="bell-probs.svg"**
> print text=`p` > print text=`p`
+15 -15
View File
@@ -18,25 +18,25 @@ Build |Φ⁺⟩ with H then CX. Full-state purity stays 1; tracing out one qubit
| 1 | H | 0 | | 1 | H | 0 |
| 2 | CX | 0,1 | | 2 | CX | 0,1 |
*qc = > quantum.circuit qubits=2 steps=`steps`* **qc = > quantum.circuit qubits=2 steps=`steps`**
*p = > `qc`.probabilities* **p = > `qc`.probabilities**
*rho = > `qc`.density* **rho = > `qc`.density**
*pur = > `rho`.purity* **pur = > `rho`.purity**
*red = > `rho`.partial_trace keep=0* **red = > `rho`.partial_trace keep=0**
*rpur = > `red`.purity* **rpur = > `red`.purity**
*zz = "ZZ"* **zz = "ZZ"**
*ezz = > `qc`.expect obs=`zz`* **ezz = > `qc`.expect obs=`zz`**
*sch = > `qc`.schmidt cut=1* **sch = > `qc`.schmidt cut=1**
*ent = sch[^entropy]* **ent = [entropy](sch)**
*_ = > `qc`.draw path="entangle-circuit.svg" theme="dark"* **_ = > `qc`.draw path="entangle-circuit.svg" theme="dark"**
*_ = > `qc`.draw kind="hinton" path="entangle-hinton.svg"* **_ = > `qc`.draw kind="hinton" path="entangle-hinton.svg"**
*_ = > `qc`.draw kind="qsphere" path="entangle-qsphere.svg"* **_ = > `qc`.draw kind="qsphere" path="entangle-qsphere.svg"**
*_ = > `qc`.draw kind="multibloch" path="entangle-multibloch.svg"* **_ = > `qc`.draw kind="multibloch" path="entangle-multibloch.svg"**
*_ = > `rho`.draw kind="city" path="entangle-city.svg"* **_ = > `rho`.draw kind="city" path="entangle-city.svg"**
> print text=`p` > print text=`p`
> print text=`pur` > print text=`pur`
+6 -6
View File
@@ -18,11 +18,11 @@ H on qubit 0, CX(0→1), CX(0→2). Ideal: |000⟩ and |111⟩ each with probabi
| 2 | CX | 0,1 | | 2 | CX | 0,1 |
| 3 | CX | 0,2 | | 3 | CX | 0,2 |
*qc = > quantum.circuit qubits=3 steps=`steps`* **qc = > quantum.circuit qubits=3 steps=`steps`**
*p = > qc.probabilities* **p = > qc.probabilities**
*_ = > qc.draw path="ghz.svg"* **_ = > qc.draw path="ghz.svg"**
*_ = > qc.draw kind="probs" path="ghz-probs.svg"* **_ = > qc.draw kind="probs" path="ghz-probs.svg"**
*H = > quantum.gate name="H"* **H = > quantum.gate name="H"**
*_ = > H.draw kind="matrix" path="ghz-h-matrix.svg"* **_ = > H.draw kind="matrix" path="ghz-h-matrix.svg"**
> print text=`p` > print text=`p`
+5 -5
View File
@@ -9,11 +9,11 @@ import web:ext/web/web.mq.md
Server page with a counter UI. Client logic lives in `static/client.mq.md` Server page with a counter UI. Client logic lives in `static/client.mq.md`
(loaded by official bridge via `client_embed`). (loaded by official bridge via `client_embed`).
*`embed` = > web.client_embed bridge="/static/marqdo-bridge.js" wasm="/static/marqdo_wasm.wasm" source="/static/client.mq.md" boot=True* **`embed` = > web.client_embed bridge="/static/marqdo-bridge.js" wasm="/static/marqdo_wasm.wasm" source="/static/client.mq.md" boot=True**
*`intro` = "<h1>Marqdo client site</h1><p>SSR + WASM session. No author JS.</p><div id=\"count\">0</div><p><button id=\"bump\" type=\"button\" disabled>Bump</button> <button id=\"reset\" type=\"button\" disabled>Reset</button></p><pre id=\"log\">booting…</pre>" + embed* **`intro` = "<h1>Marqdo client site</h1><p>SSR + WASM session. No author JS.</p><div id=\"count\">0</div><p><button id=\"bump\" type=\"button\" disabled>Bump</button> <button id=\"reset\" type=\"button\" disabled>Reset</button></p><pre id=\"log\">booting…</pre>" + embed**
*page = > web.page title="Marqdo client site" intro=intro* **page = > web.page title="Marqdo client site" intro=intro**
*app = > web.app page=page host="127.0.0.1" port=18090* **app = > web.app page=page host="127.0.0.1" port=18090**
*app = > app.static dir="static" mount="/static"* **app = > app.static dir="static" mount="/static"**
> `app`.listen > `app`.listen
+9 -9
View File
@@ -7,7 +7,7 @@ import table:lib/table.mq.md
# main # main
*`count` = 0* **`count` = 0**
`wire` = `wire` =
@@ -16,15 +16,15 @@ import table:lib/table.mq.md
| 1 | "#bump" | click | bump | | 1 | "#bump" | click | bump |
| 2 | "#reset" | click | reset | | 2 | "#reset" | click | reset |
*`ready` = > browser.set_text sel="#log" text="client.mq.md ready"* **`ready` = > browser.set_text sel="#log" text="client.mq.md ready"**
*`boot` = > table.put in=None at="wire" value=wire* **`boot` = > table.put in=None at="wire" value=wire**
**> browser.merge a=boot b=ready** *> browser.merge a=boot b=ready*
## bump ## bump
*`count` = count + 1* **`count` = count + 1**
*`label` = > str count* **`label` = > str count**
**> browser.set_text sel="#count" text=label** *> browser.set_text sel="#count" text=label*
## reset ## reset
*`count` = 0* **`count` = 0**
**> browser.set_text sel="#count" text="0"** *> browser.set_text sel="#count" text="0"*
@@ -7,4 +7,4 @@
| Marqdo 网络扩展示例 | https://github.com | | | Marqdo 网络扩展示例 | https://github.com | |
| 文档 | /tools | | | 文档 | /tools | |
**`页脚`** *`页脚`*
@@ -12,4 +12,4 @@
| 工具 | /tools | | | 工具 | /tools | |
| 后台 | /admin | | | 后台 | /admin | |
**`导航`** *`导航`*
@@ -12,4 +12,4 @@
| 表单 | /new | | | 表单 | /new | |
| lib/net | /tools | | | lib/net | /tools | |
**`侧栏`** *`侧栏`*
+2 -2
View File
@@ -8,7 +8,7 @@
| title | text | false | | title | text | false |
| body | text | true | | body | text | true |
**`字段`** *`字段`*
## 种子 ## 种子
@@ -20,4 +20,4 @@
| 2 | 登录门禁后台 | /admin 页面需要 session 会话。 | | 2 | 登录门禁后台 | /admin 页面需要 session 会话。 |
| 3 | WebSocket 实时 | /live 端点会把你的消息实时回显。 | | 3 | WebSocket 实时 | /live 端点会把你的消息实时回显。 |
**`行`** *`行`*
+6 -6
View File
@@ -7,13 +7,13 @@ import articles:articles.mq.md
## 打开 ## 打开
*store = > 网页.数据库 地址="sqlite:data/site-net-zh.db"* **store = > 网页.数据库 地址="sqlite:data/site-net-zh.db"**
*字段 = > articles.结构* **字段 = > articles.结构**
> `store`.初始化 名=articles 字段=`字段` > `store`.初始化 名=articles 字段=`字段`
*行 = > store.查询 表="articles" 上限=1* **行 = > store.查询 表="articles" 上限=1**
1. `行` 1. `行`
**store** *store*
2. * 2. *
*种子 = > articles.种子* **种子 = > articles.种子**
> `store`.插入 表=articles 行=`种子` > `store`.插入 表=articles 行=`种子`
**store** *store*
+33 -33
View File
@@ -44,29 +44,29 @@ import db:db/index.mq.md
| title | max:120 | 标题太长 | | title | max:120 | 标题太长 |
| body | max:8000 | 正文太长 | | body | max:8000 | 正文太长 |
*store = > db.打开* **store = > db.打开**
*page = > 网页.页面 标题="网络扩展站" 引言="<h1>网络扩展站</h1><p>SQLite 文章列表、WebSocket 实时小部件、登录门禁后台、以及标准库 lib/net 的解析工具。</p><h2 id=\"live\">实时 WebSocket</h2><p id=\"live-status\">connecting…</p><input id=\"live-msg\" placeholder=\"输入一条消息…\"><button id=\"live-send\" disabled>发送</button><div id=\"live-out\"></div><script src=\"/static/live.js\"></script>"* **page = > 网页.页面 标题="网络扩展站" 引言="<h1>网络扩展站</h1><p>SQLite 文章列表、WebSocket 实时小部件、登录门禁后台、以及标准库 lib/net 的解析工具。</p><h2 id=\"live\">实时 WebSocket</h2><p id=\"live-status\">connecting…</p><input id=\"live-msg\" placeholder=\"输入一条消息…\"><button id=\"live-send\" disabled>发送</button><div id=\"live-out\"></div><script src=\"/static/live.js\"></script>"**
*page = > page.组件装配 组件=`首页`* **page = > page.组件装配 组件=`首页`**
*page = > page.主体装配 主体=`列表`* **page = > page.主体装配 主体=`列表`**
*about = > 网页.页面 标题="关于" 引言="<h1>关于</h1><p>演示网络扩展后的 web 库:会话、登录鉴权、WebSocket、multipart/cookie 解析。</p>"* **about = > 网页.页面 标题="关于" 引言="<h1>关于</h1><p>演示网络扩展后的 web 库:会话、登录鉴权、WebSocket、multipart/cookie 解析。</p>"**
*about = > about.组件装配 组件=`首页`* **about = > about.组件装配 组件=`首页`**
<!-- 工具页:用 lib/net 解析展示 --> <!-- 工具页:用 lib/net 解析展示 -->
*解析请求 = > net.解析Cookie 内容="session=abc123; theme=dark"* **解析请求 = > net.解析Cookie 内容="session=abc123; theme=dark"**
*请求块 = 解析请求[^1]* **请求块 = [1](解析请求)**
*解析响应 = > net.解析Cookie 内容="id=42; Path=/; HttpOnly; SameSite=Lax" 是响应头=True* **解析响应 = > net.解析Cookie 内容="id=42; Path=/; HttpOnly; SameSite=Lax" 是响应头=True**
*响应块 = 解析响应[^1]* **响应块 = [1](解析响应)**
`边界` = ----b `边界` = ----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" `正文` = "--`边界`\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.解析多部分 正文=`正文` 边界=`边界`* **多部分 = > net.解析多部分 正文=`正文` 边界=`边界`**
*字段块 = 多部分[^1]* **字段块 = [1](多部分)**
*文件块 = 多部分[^2]* **文件块 = [2](多部分)**
`工具段` = `工具段` =
@@ -74,26 +74,26 @@ import db:db/index.mq.md
|----| |----|
| <h1>网络工具</h1><p>由 lib/net 提供的解析演示:解析Cookie 与 解析多部分。</p><section class="content cards"> | | <h1>网络工具</h1><p>由 lib/net 提供的解析演示:解析Cookie 与 解析多部分。</p><section class="content cards"> |
| <article><h2>Cookie 请求头</h2><p> | | <article><h2>Cookie 请求头</h2><p> |
| `请求块`[^name]=`请求块`[^value] | | [name](`请求块`)=[value](`请求块`) |
| </p></article><article><h2>Set-Cookie 响应头</h2><p> | | </p></article><article><h2>Set-Cookie 响应头</h2><p> |
| `响应块`[^name]=`响应块`[^value] · HttpOnly=`响应块`[^http_only] | | [name](`响应块`)=[value](`响应块`) · HttpOnly=[http_only](`响应块`) |
| </p></article><article><h2>多部分字段</h2><p> | | </p></article><article><h2>多部分字段</h2><p> |
| `字段块`[^name]=`字段块`[^value] | | [name](`字段块`)=[value](`字段块`) |
| </p></article><article><h2>多部分文件</h2><p> | | </p></article><article><h2>多部分文件</h2><p> |
| `文件块`[^name] · `文件块`[^filename] · `文件块`[^content_type] | | [name](`文件块`) · [filename](`文件块`) · [content_type](`文件块`) |
| </p></article></section> | | </p></article></section> |
*工具引言 = > text.str_join xs=`工具段` sep=""* **工具引言 = > text.str_join xs=`工具段` sep=""**
*tools = > 网页.页面 标题="工具" 引言=`工具引言`* **tools = > 网页.页面 标题="工具" 引言=`工具引言`**
*tools = > tools.组件装配 组件=`首页`* **tools = > tools.组件装配 组件=`首页`**
*article_form = > 网页.表单 表="articles" 动作="插入"* **article_form = > 网页.表单 表="articles" 动作="插入"**
*article_form = > article_form.字段 字段=`文章字段`* **article_form = > article_form.字段 字段=`文章字段`**
*article_form = > article_form.规则 规则=`文章规则`* **article_form = > article_form.规则 规则=`文章规则`**
*new = > 网页.页面 标题="发布" 引言="<h1>发布</h1><p>表单插入到 articles 表。</p>"* **new = > 网页.页面 标题="发布" 引言="<h1>发布</h1><p>表单插入到 articles 表。</p>"**
*new = > new.组件装配 组件=`首页`* **new = > new.组件装配 组件=`首页`**
*new = > new.表单装配 id="article" 表单=article_form* **new = > new.表单装配 id="article" 表单=article_form**
`管理员` = `管理员` =
@@ -101,11 +101,11 @@ import db:db/index.mq.md
|----|--------|------| |----|--------|------|
| 1 | admin | secret | | 1 | admin | secret |
*app = > 网页.应用 页面=page 数据库=store 后台=True 主机="127.0.0.1" 端口=18084* **app = > 网页.应用 页面=page 数据库=store 后台=True 主机="127.0.0.1" 端口=18084**
*app = > app.路由 路径="/about" 页面=about* **app = > app.路由 路径="/about" 页面=about**
*app = > app.路由 路径="/new" 页面=new* **app = > app.路由 路径="/new" 页面=new**
*app = > app.路由 路径="/tools" 页面=tools* **app = > app.路由 路径="/tools" 页面=tools**
*app = > app.静态 目录="public" 挂载="/static"* **app = > app.静态 目录="public" 挂载="/static"**
*app = > app.路由实时 路径="/live" 回显=True* **app = > app.路由实时 路径="/live" 回显=True**
*app = > app.鉴权 用户表=`管理员` 会话时长=3600* **app = > app.鉴权 用户表=`管理员` 会话时长=3600**
> `app`.监听 > `app`.监听
+4 -4
View File
@@ -7,7 +7,7 @@
| background | #ffffff | | background | #ffffff |
| border-bottom | 1px solid #e7e5e4 | | border-bottom | 1px solid #e7e5e4 |
**`顶栏`** *`顶栏`*
## 侧栏面板 ## 侧栏面板
@@ -17,7 +17,7 @@
|------|-----| |------|-----|
| background | #f5f5f4 | | background | #f5f5f4 |
**`侧栏面板`** *`侧栏面板`*
## 卡片标题 ## 卡片标题
@@ -28,7 +28,7 @@
| font-size | 1.15rem | | font-size | 1.15rem |
| margin | 0 0 0.35rem | | margin | 0 0 0.35rem |
**`卡片标题`** *`卡片标题`*
## 卡片正文 ## 卡片正文
@@ -39,4 +39,4 @@
| color | #57534e | | color | #57534e |
| margin | 0 | | margin | 0 |
**`卡片正文`** *`卡片正文`*
+1 -1
View File
@@ -7,4 +7,4 @@
| Marqdo web-net example | https://github.com | | | Marqdo web-net example | https://github.com | |
| Docs | /tools | | | Docs | /tools | |
**`foot`** *`foot`*
+1 -1
View File
@@ -12,4 +12,4 @@ Site top navigation. The Admin tab points at the login-gated admin page.
| Tools | /tools | | | Tools | /tools | |
| Admin | /admin | | | Admin | /admin | |
**`nav`** *`nav`*
+1 -1
View File
@@ -12,4 +12,4 @@ Sidebar index of what this example demonstrates.
| Forms | /new | | | Forms | /new | |
| net lib | /tools | | | net lib | /tools | |
**`side`** *`side`*
+2 -2
View File
@@ -8,7 +8,7 @@
| title | text | false | | title | text | false |
| body | text | true | | body | text | true |
**`fields`** *`fields`*
## seed ## seed
@@ -20,4 +20,4 @@
| 2 | Login-gated admin | The /admin page requires a session cookie. | | 2 | Login-gated admin | The /admin page requires a session cookie. |
| 3 | WebSocket live | The /live endpoint echoes your message in real time. | | 3 | WebSocket live | The /live endpoint echoes your message in real time. |
**`rows`** *`rows`*
+6 -6
View File
@@ -7,13 +7,13 @@ import articles:articles.mq.md
## open ## open
*store = > web.db url="sqlite:data/site-net.db"* **store = > web.db url="sqlite:data/site-net.db"**
*fields = > articles.schema* **fields = > articles.schema**
> `store`.init name=articles fields=`fields` > `store`.init name=articles fields=`fields`
*rows = > store.select table="articles" limit=1* **rows = > store.select table="articles" limit=1**
1. `rows` 1. `rows`
**store** *store*
2. * 2. *
*seed = > articles.seed* **seed = > articles.seed**
> `store`.insert table=articles rows=`seed` > `store`.insert table=articles rows=`seed`
**store** *store*
+33 -33
View File
@@ -31,27 +31,27 @@ import db:db/index.mq.md
Home intro also embeds the live WebSocket widget (HTML is served raw). Home intro also embeds the live WebSocket widget (HTML is served raw).
*store = > db.open* **store = > db.open**
*page = > web.page title="Marqdo Net Site" intro="<h1>Net Site</h1><p>Articles from SQLite, a live WebSocket widget, login-gated admin, and net-library parsing tools.</p><h2 id=\"live\">Live WebSocket</h2><p id=\"live-status\">connecting…</p><input id=\"live-msg\" placeholder=\"type a message…\"><button id=\"live-send\" disabled>send</button><div id=\"live-out\"></div><script src=\"/static/live.js\"></script>"* **page = > web.page title="Marqdo Net Site" intro="<h1>Net Site</h1><p>Articles from SQLite, a live WebSocket widget, login-gated admin, and net-library parsing tools.</p><h2 id=\"live\">Live WebSocket</h2><p id=\"live-status\">connecting…</p><input id=\"live-msg\" placeholder=\"type a message…\"><button id=\"live-send\" disabled>send</button><div id=\"live-out\"></div><script src=\"/static/live.js\"></script>"**
*page = > page.compose_components components=home* **page = > page.compose_components components=home**
*page = > page.compose_main main=index* **page = > page.compose_main main=index**
About page: same shell. About page: same shell.
*about = > web.page title="About" intro="<h1>About</h1><p>Demonstrates the network-extended web library: sessions, auth, WebSocket, multipart/cookie parsing.</p>"* **about = > web.page title="About" intro="<h1>About</h1><p>Demonstrates the network-extended web library: sessions, auth, WebSocket, multipart/cookie parsing.</p>"**
*about = > about.compose_components components=home* **about = > about.compose_components components=home**
<!-- Tools page (lib/net parsing) --> <!-- Tools page (lib/net parsing) -->
Parse a `Cookie` request header with the standard library. Parse a `Cookie` request header with the standard library.
*parsed_req = > net.cookie_parse text="session=abc123; theme=dark"* **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. Parse a `Set-Cookie` response header.
*parsed_resp = > net.cookie_parse text="id=42; Path=/; HttpOnly; SameSite=Lax" is_response=True* **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. Parse a `multipart/form-data` body.
@@ -59,9 +59,9 @@ 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" `_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 = > net.multipart_parse body=`_body` boundary=`_b`**
*mp_title = mp[^1]* **mp_title = [1](mp)**
*mp_cover = mp[^2]* **mp_cover = [2](mp)**
Build the tools page as one HTML intro (intro is served raw). Build the tools page as one HTML intro (intro is served raw).
@@ -71,18 +71,18 @@ 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"> | | <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> | | <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> | | </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> | | </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> | | </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> | | </p></article></section> |
*tools_intro = > text.str_join xs=`tools_parts` sep=""* **tools_intro = > text.str_join xs=`tools_parts` sep=""**
*tools = > web.page title="Tools" intro=`tools_intro`* **tools = > web.page title="Tools" intro=`tools_intro`**
*tools = > tools.compose_components components=home* **tools = > tools.compose_components components=home**
Article create form: field table + rules table. Article create form: field table + rules table.
@@ -101,15 +101,15 @@ Article create form: field table + rules table.
| title | max:120 | Title is too long | | title | max:120 | Title is too long |
| body | max:8000 | Body is too long | | body | max:8000 | Body is too long |
*article_form = > web.form table="articles" action="insert"* **article_form = > web.form table="articles" action="insert"**
*article_form = > article_form.fields fields=article_fields* **article_form = > article_form.fields fields=article_fields**
*article_form = > article_form.rules rules=article_rules* **article_form = > article_form.rules rules=article_rules**
New article page: form embedded in the main slot. New article page: form embedded in the main slot.
*new = > web.page title="Publish" intro="<h1>Publish</h1><p>Form inserts into articles.</p>"* **new = > web.page title="Publish" intro="<h1>Publish</h1><p>Form inserts into articles.</p>"**
*new = > new.compose_components components=home* **new = > new.compose_components components=home**
*new = > new.compose_form id="article" form=article_form* **new = > new.compose_form id="article" form=article_form**
Admin users table (english + chinese column headers both work). Admin users table (english + chinese column headers both work).
@@ -119,11 +119,11 @@ Admin users table (english + chinese column headers both work).
|----|----------|----------| |----|----------|----------|
| 1 | admin | secret | | 1 | admin | secret |
*app = > web.app page=page db=store admin=True host="127.0.0.1" port=18083* **app = > web.app page=page db=store admin=True host="127.0.0.1" port=18083**
*app = > app.route path="/about" page=about* **app = > app.route path="/about" page=about**
*app = > app.route path="/new" page=new* **app = > app.route path="/new" page=new**
*app = > app.route path="/tools" page=tools* **app = > app.route path="/tools" page=tools**
*app = > app.static dir="public" mount="/static"* **app = > app.static dir="public" mount="/static"**
*app = > app.route_ws path="/live" echo=True* **app = > app.route_ws path="/live" echo=True**
*app = > app.auth users=`admins` session_ttl=3600* **app = > app.auth users=`admins` session_ttl=3600**
> `app`.listen > `app`.listen
+4 -4
View File
@@ -7,7 +7,7 @@
| background | #ffffff | | background | #ffffff |
| border-bottom | 1px solid #e7e5e4 | | border-bottom | 1px solid #e7e5e4 |
**`topnav`** *`topnav`*
## side_panel ## side_panel
@@ -17,7 +17,7 @@
|------|-----| |------|-----|
| background | #f5f5f4 | | background | #f5f5f4 |
**`side_panel`** *`side_panel`*
## card_title ## card_title
@@ -28,7 +28,7 @@
| font-size | 1.15rem | | font-size | 1.15rem |
| margin | 0 0 0.35rem | | margin | 0 0 0.35rem |
**`card_title`** *`card_title`*
## card_body ## card_body
@@ -39,4 +39,4 @@
| color | #57534e | | color | #57534e |
| margin | 0 | | margin | 0 |
**`card_body`** *`card_body`*
Loaded 100 of 521 files, more files were not shown because too many files have changed in this diff. Show more