原计划的"翻转默认 + 旧形硬报错"不可行:`[键](集合)` 与 `[描述](实现)` 外形相同, 翻转会让 506 处取元静默变义,硬报错又拿不到证据。改为**按文件声明**。 一、per-file markup - frontmatter `markup: occlusion`(或 `标记: 遮蔽`)决定该文件模式 - load.rs 先取模式,用 parse::expr::with_markup(线程局部压栈)包住解析 - 同一进程可同时加载两种模式的文件(imports);MARQDO_MARKUP 仍作进程默认 - 好处:迁移逐文件、可增量、可回滚,不存在半迁移的静默错义 二、`marqdo migrate labels [--write|--json]` 改写规则: [键](集合) → [键](access(集合, "键")) [`名`](集合) → [名](access(集合, `名`)) - [项](集合) → - [项](遍历 集合 为 项) 安全模型:改写 → 重解析 → 证明等价 → 才写 - 原文件按 classic 解析得 AST-A;改写后按 occlusion 解析得 AST-B - 反归一化 B(标签与键同名且 payload 为 access 的遮蔽还原成 Index) - Debug(A) == Debug(反归一化(B))(抹掉行号)才写入,否则原文件一字不动 只改代码行(LineKind::Code);表格行只改 **…** 单元格,散文 markdown 链接不碰; 链式索引由内向外改写,已迁移的有守卫不二次改。 三、access 提升为宿主函数 HostFn::Access(u16 id 212) 与旧取元逐字一致(Map 按键 / List 1-based / 缺键 missing map key); 进 HostFn 是为了两个后端共用同一实现,interp 里的特例已删除。 四、顺带修的两处真实语义缺陷 1. payload 继承外层"文本模式":`f text=[k](access(c,k))` 中 access 不被当调用 → `()` 内永远允许 callee(args) 2. 遮蔽形状判定过宽:`[问候] ([格式化] "Bo")` 误判为遮蔽 → 要求 `]` 后紧跟 `(`,否则落回方括号调用 五、全仓迁移结果 migrate labels: 256 index, 23 loop, 80 file written;0 文件被等价性拒绝; 迁移后 cargo test --release → 604 passed / 0 failed;再跑迁移幂等。 等价性检查先后抓出 4 类改写 bug(表格散文链接、payload 文本模式、链式索引、 遮蔽与方括号调用混淆),每类都是先拦下再修工具,未污染文件。 测试:6 个单测 + 3 个集成(干跑不写盘 / 写入后运行输出不变且幂等 / 等价失败文件不动);全量 604 passed / 0 failed(M3 后 595 + 9);双后端一致。 文档:doc/design/change-m7-migration.md
5.0 KiB
markup: occlusion title: Welcome to Marqdo description: User-docs home — code as documentation (English) import math:lib/math.mq.md import foreign:lib/foreign.mq.md
main
Hello — and welcome. I built Marqdo so that code is documentation and documentation is code: Markdown markers are the program structure, so what you read is what runs.
AI systems already favor Markdown-shaped output. That raised a simple question: why keep docs and programs as two separate artifacts? Marqdo is the answer. The .mq.md suffix exists so a file stays renderable as Markdown while remaining executable. Richer OKF-style YAML catalogs and even slide decks are on the roadmap; for now this site itself is generated by Marqdo — and that often saves tokens when an AI is writing with you.
The language is still early: structural markers, English/Chinese builtin aliases (print / 打印 …), an importable standard library (see stdlib/ on this site), local view, and static export. Join in at GitHub.
中文文档请看同目录的 00-欢迎.mq.md(叙述与内置均用中文)。
Want a quick hello? Calls only run when they sit in the entry # main — ## children are methods until something calls them. Try greet who="marqdo". Names can include spaces: greet who="marqdo user".
Beyond the basics, Marqdo ships table, time, text, files, system, math, foreign, and more. Math and foreign deserve a special mention.
Write a math block and bind it with a TeX comment:
% marqdo: var=f
x^2 - 2
Then plot it: _svg = math.plot formula=f var="x" min=-3 max=3
Foreign lets you embed another language. Bind hi to a small Python block:
hi =
print("hello-from-python")
Under Markdown this stays easy to read — which is the point: code as documentation, documentation as code.
One file, three surfaces.
| Surface | What it is |
|---|---|
| Document | ordinary Markdown: prose, tables, links and fenced code |
| Program | the same markers are executable: assignments, calls, returns |
| Knowledge | frontmatter, links and generated catalog entries an agent can query |
The static site you are reading is generated from these files, so the examples are not screenshots. Run the same source and you get the same page.
Foreign v2 is a good example. Probe Python, then run the bound fence:
python = > foreign.probe lang="python"
- ok)
hello = > foreign.run code=
hi
print text=
hello
print text="(python3 not found — install Python to run this cell)"
The same module also supports JSON calls, parallel fan-out, persistent kernels and an explicit state bridge. See stdlib/foreign.mq.md and the full Python walkthrough in features/19-foreign-view-cells.mq.md.
A view document is still a document. Named kernels and a cell order are ordinary bound tables:
`分析内核` =
| 名称 | 语言 | 说明 |
|------|------|------|
| 分析 | python | shared state |
| 复核 | python | isolated state |
`分析单元` =
| 单元 | 内核 | 说明 |
|------|------|------|
| 准备数据 | 分析 | write |
| 计算指标 | 分析 | read |
| 独立复核 | 复核 | validate |
`会话` = > foreign.session kernels=`分析内核` cells=`分析单元`
marqdo view consumes the foreign-owned 会话 handle and turns it into Run All, Step, per-cell kernels, a journal and a state panel. Without 会话, cells are stateless one-shot runs. There is no separate interactive mode or command; marqdo run still executes the file as one program.
Documentation becomes knowledge when it can be discovered, verified and reused. OKF supplies the portable Markdown + YAML shape; EKC projects the repository into catalog layers L0–L4, a graph and an engineering preflight. The source .mq.md remains the only authority; generated artifacts are marked and rebuildable.
| Loop | Question |
|---|---|
| OKF | How do people and agents share a readable knowledge page? |
| EKC | What existing capability, decision, constraint or failure should be reused before creating more? |
| Preflight | REUSE → ADAPT → CREATE |
Read features/20-okf-ekc.mq.md for the concepts and commands.
Welcome again — enjoy exploring Marqdo.
greet
When we meet a visitor who, we print text="Welcome, who!" and close withNone.
install
Install the interpreter (CLI) in any of these ways:
| Way | Notes |
|---|---|
| Ubuntu PPA | sudo add-apt-repository ppa:cflmy/marqdo then sudo apt install marqdo |
| GitHub Releases | Prebuilt Windows / Linux packages from releases |
| From source | cargo build --release (needs a local Rust toolchain) |
Official extensions update independently of the CLI:
marqdo ext add web
marqdo ext add quantum
ext add tries CDN https://ext.marqdo.com first, then GitHub, then the proxy mirror. See features/05-extensions.mq.md.