marqdo

Welcome to Marqdook

00-welcome.mq.md

文档

math:lib/math.mq.mdforeign: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? `marqdo run` executes the entry `# main`. Try greet who="marqdo". Names can include spaces: greet who="marqdo user".

This version also runs one function on its own. marqdo call takes the file, the function and named arguments. The page you read is the program that runs. What that is for, and why it matters, is in features/22-call.mq.md.

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:

formula 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:

code hi python
print("hello-from-python")
hello-from-python


— 20ms

Under Markdown this stays easy to read — which is the point: code as documentation, documentation as code.

One file, three surfaces.

SurfaceWhat it is
Documentordinary Markdown: prose, tables, links and fenced code
Programthe same markers are executable: assignments, calls, returns
Knowledgefrontmatter, 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"
  1. [ok](access(python, "ok"))
    hello = > foreign.run code=`hi`
    > print text=hello
  2. else
    > 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:

code text
`分析内核` =

| 名称 | 语言 | 说明 |
|------|------|------|
| 分析 | 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.

LoopQuestion
OKFHow do people and agents share a readable knowledge page?
EKCWhat existing capability, decision, constraint or failure should be reused before creating more?
PreflightREUSE → ADAPT → CREATE

Read features/20-okf-ekc.mq.md for the concepts and commands.

Welcome again — enjoy exploring Marqdo.

greet

说明
who=marqdo user
When we meet a visitor who, we print text="Welcome, `who`!" and close withNone.

install

说明

Install the interpreter (CLI) in any of these ways:

WayNotes
Ubuntu PPA`sudo add-apt-repository ppa:cflmy/marqdo` then `sudo apt install marqdo`
GitHub ReleasesPrebuilt Windows / Linux packages from [releases](https://github.com/cflmy/marqdo/releases)
From source`cargo build --release` (needs a local Rust toolchain)

Official extensions update independently of the CLI:

code text
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.

Functions
Variables
  • _svg text
    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 520 360" width="520" height="360" role="img" aria-label="function plot"> <defs> <marker id="arrow" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"> <path d="M 0 0 L 10 5 L 0 10 z" fill="#4b5563"/> </marker> </defs> <style> .grid { stroke: #e5e7eb; stroke-width: 1; } .axis { stroke: #4b5563; stroke-width: 1.5; } .tick { stroke: #4b5563; stroke-width: 1; } .curve { fill: none; stroke: #1f6feb; stroke-width: 2; } .pt { fill: #1f6feb; } .axis-label { font: 12px ui-sans-serif, system-ui, sans-serif; fill: #374151; font-weight: 600; } .tick-label { font: 10px ui-sans-serif, system-ui, sans-serif; fill: #6b7280; } </style> <line x1="36.00" y1="36" x2="36.00" y2="324" class="grid"/><line x1="110.67" y1="36" x2="110.67" y2="324" class="grid"/><line x1="185.33" y1="36" x2="185.33" y2="324" class="grid"/><line x1="260.00" y1="36" x2="260.00" y2="324" class="grid"/><line x1="334.67" y1="36" x2="334.67" y2="324" class="grid"/><line x1="409.33" y1="36" x2="409.33" y2="324" class="grid"/><line x1="484.00" y1="36" x2="484.00" y2="324" class="grid"/><line x1="36" y1="310.91" x2="484" y2="310.91" class="grid"/><line x1="36" y1="252.73" x2="484" y2="252.73" class="grid"/><line x1="36" y1="194.55" x2="484" y2="194.55" class="grid"/><line x1="36" y1="136.36" x2="484" y2="136.36" class="grid"/><line x1="36" y1="78.18" x2="484" y2="78.18" class="grid"/><line x1="36" y1="252.73" x2="484" y2="252.73" class="axis" marker-end="url(#arrow)"/><line x1="260.00" y1="324" x2="260.00" y2="36" class="axis" marker-end="url(#arrow)"/><text x="488.00" y="256.73" class="axis-label">x</text><text x="266.00" y="40.00" class="axis-label">y</text><line x1="36.00" y1="248.73" x2="36.00" y2="256.73" class="tick"/><text x="36.00" y="266.73" text-anchor="middle" class="tick-label">-3</text><line x1="110.67" y1="248.73" x2="110.67" y2="256.73" class="tick"/><text x="110.67" y="266.73" text-anchor="middle" class="tick-label">-2</text><line x1="185.33" y1="248.73" x2="185.33" y2="256.73" class="tick"/><text x="185.33" y="266.73" text-anchor="middle" class="tick-label">-1</text><line x1="334.67" y1="248.73" x2="334.67" y2="256.73" class="tick"/><text x="334.67" y="266.73" text-anchor="middle" class="tick-label">1</text><line x1="409.33" y1="248.73" x2="409.33" y2="256.73" class="tick"/><text x="409.33" y="266.73" text-anchor="middle" class="tick-label">2</text><line x1="484.00" y1="248.73" x2="484.00" y2="256.73" class="tick"/><text x="484.00" y="266.73" text-anchor="middle" class="tick-label">3</text><line x1="256.00" y1="310.91" x2="264.00" y2="310.91" class="tick"/><text x="252.00" y="310.91" text-anchor="end" dominant-baseline="middle" class="tick-label">-2</text><line x1="256.00" y1="194.55" x2="264.00" y2="194.55" class="tick"/><text x="252.00" y="194.55" text-anchor="end" dominant-baseline="middle" class="tick-label">2</text><line x1="256.00" y1="136.36" x2="264.00" y2="136.36" class="tick"/><text x="252.00" y="136.36" text-anchor="end" dominant-baseline="middle" class="tick-label">4</text><line x1="256.00" y1="78.18" x2="264.00" y2="78.18" class="tick"/><text x="252.00" y="78.18" text-anchor="end" dominant-baseline="middle" class="tick-label">6</text><text x="252.00" y="266.73" class="tick-label">0</text><path d="M 36.00 49.09 L 38.24 54.30 L 40.48 59.46 L 42.72 64.56 L 44.96 69.62 L 47.20 74.62 L 49.44 79.57 L 51.68 84.46 L 53.92 89.31 L 56.16 94.10 L 58.40 98.84 L 60.64 103.52 L 62.88 108.16 L 65.12 112.74 L 67.36 117.27 L 69.60 121.75 L 71.84 126.17 L 74.08 130.54 L 76.32 134.86 L 78.56 139.13 L 80.80 143.35 L 83.04 147.51 L 85.28 151.62 L 87.52 155.68 L 89.76 159.68 L 92.00 163.64 L 94.24 167.54 L 96.48 171.39 L 98.72 175.18 L 100.96 178.93 L 103.20 182.62 L 105.44 186.26 L 107.68 189.84 L 109.92 193.38 L 112.16 196.86 L 114.40 200.29 L 116.64 203.67 L 118.88 206.99 L 121.12 210.27 L 123.36 213.49 L 125.60 216.65 L 127.84 219.77 L 130.08 222.83 L 132.32 225.84 L 134.56 228.80 L 136.80 231.71 L 139.04 234.56 L 141.28 237.36 L 143.52 240.11 L 145.76 242.81 L 148.00 245.45 L 150.24 248.05 L 152.48 250.59 L 154.72 253.07 L 156.96 255.51 L 159.20 257.89 L 161.44 260.22 L 163.68 262.50 L 165.92 264.72 L 168.16 266.90 L 170.40 269.02 L 172.64 271.09 L 174.88 273.10 L 177.12 275.07 L 179.36 276.98 L 181.60 278.84 L 183.84 280.64 L 186.08 282.40 L 188.32 284.10 L 190.56 285.75 L 192.80 287.35 L 195.04 288.89 L 197.28 290.38 L 199.52 291.82 L 201.76 293.21 L 204.00 294.55 L 206.24 295.83 L 208.48 297.06 L 210.72 298.24 L 212.96 299.36 L 215.20 300.44 L 217.44 301.46 L 219.68 302.43 L 221.92 303.34 L 224.16 304.21 L 226.40 305.02 L 228.64 305.78 L 230.88 306.48 L 233.12 307.14 L 235.36 307.74 L 237.60 308.29 L 239.84 308.79 L 242.08 309.23 L 244.32 309.63 L 246.56 309.97 L 248.80 310.25 L 251.04 310.49 L 253.28 310.67 L 255.52 310.80 L 257.76 310.88 L 260.00 310.91 L 262.24 310.88 L 264.48 310.80 L 266.72 310.67 L 268.96 310.49 L 271.20 310.25 L 273.44 309.97 L 275.68 309.63 L 277.92 309.23 L 280.16 308.79 L 282.40 308.29 L 284.64 307.74 L 286.88 307.14 L 289.12 306.48 L 291.36 305.78 L 293.60 305.02 L 295.84 304.21 L 298.08 303.34 L 300.32 302.43 L 302.56 301.46 L 304.80 300.44 L 307.04 299.36 L 309.28 298.24 L 311.52 297.06 L 313.76 295.83 L 316.00 294.55 L 318.24 293.21 L 320.48 291.82 L 322.72 290.38 L 324.96 288.89 L 327.20 287.35 L 329.44 285.75 L 331.68 284.10 L 333.92 282.40 L 336.16 280.64 L 338.40 278.84 L 340.64 276.98 L 342.88 275.07 L 345.12 273.10 L 347.36 271.09 L 349.60 269.02 L 351.84 266.90 L 354.08 264.72 L 356.32 262.50 L 358.56 260.22 L 360.80 257.89 L 363.04 255.51 L 365.28 253.07 L 367.52 250.59 L 369.76 248.05 L 372.00 245.45 L 374.24 242.81 L 376.48 240.11 L 378.72 237.36 L 380.96 234.56 L 383.20 231.71 L 385.44 228.80 L 387.68 225.84 L 389.92 222.83 L 392.16 219.77 L 394.40 216.65 L 396.64 213.49 L 398.88 210.27 L 401.12 206.99 L 403.36 203.67 L 405.60 200.29 L 407.84 196.86 L 410.08 193.38 L 412.32 189.84 L 414.56 186.26 L 416.80 182.62 L 419.04 178.93 L 421.28 175.18 L 423.52 171.39 L 425.76 167.54 L 428.00 163.64 L 430.24 159.68 L 432.48 155.68 L 434.72 151.62 L 436.96 147.51 L 439.20 143.35 L 441.44 139.13 L 443.68 134.86 L 445.92 130.54 L 448.16 126.17 L 450.40 121.75 L 452.64 117.27 L 454.88 112.74 L 457.12 108.16 L 459.36 103.52 L 461.60 98.84 L 463.84 94.10 L 466.08 89.31 L 468.32 84.46 L 470.56 79.57 L 472.80 74.62 L 475.04 69.62 L 477.28 64.56 L 479.52 59.46 L 481.76 54.30 L 484.00 49.09" class="curve"/> </svg>
  • description text
    User-docs home — code as documentation (English)
  • f formula
    $$x^{2} - 2$$
  • hello text
    hello-from-python
  • hi code · python
    ```python print("hello-from-python") ```
  • markup text
    occlusion
  • python map · 6
    langpython
    cmdpython3 --version
    path/usr/bin/python3
    okTrue
    versionPython 3.12.3
    error
  • title text
    Welcome to Marqdo
可执行知识(辅助)

main.greet function

Target
mq://public/00-welcome/function/main/greet
Signature
(who: any) → any
Effects
output.write
Verification
parse: passed; resolve: passed; contract: unchecked; tests: unknown; evidence: unverified(尚无来源记录)
制品摘要
sha256:ee3796174f80b… (未检查锁定状态)
Depends on
none
Execution
尚无该知识的运行记录(知识预览不执行)。

main.install function

Target
mq://public/00-welcome/function/main/install
Signature
() → any
Effects
pure
Verification
parse: passed; resolve: passed; contract: unchecked; tests: unknown; evidence: unverified(尚无来源记录)
制品摘要
sha256:c093f733a11c9… (未检查锁定状态)
Depends on
none
Execution
尚无该知识的运行记录(知识预览不执行)。

运行与结果

Welcome, marqdo! Welcome, marqdo user! hello-from-python
xy-3-2-1123-22460
完整源码
---
markup: occlusion
title: Welcome to Marqdo
description: User-docs home — code as documentation (English)
import:
  math: lib/math.mq.md
  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/`](stdlib/) on this site), local `view`, and static export. Join in at [GitHub](https://github.com/cflmy/marqdo).

中文文档请看同目录的 [`00-欢迎.mq.md`](00-欢迎.mq.md)(叙述与内置均用中文)。

Want a quick hello? `marqdo run` executes the entry `# main`. Try **greet who="marqdo"**. Names can include spaces: **greet who="marqdo user"**.

This version also runs one function on its own. `marqdo call` takes the file, the function and named arguments. The page you read is the program that runs. What that is for, and why it matters, is in [features/22-call.mq.md](features/22-call.mq.md).

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` =
```python
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"**

1. [ok](access(`python`, "ok"))
  **hello = > foreign.run code=`hi`**
  > print text=`hello`
2. *
  > 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](stdlib/foreign.mq.md) and the full Python walkthrough in [features/19-foreign-view-cells.mq.md](features/19-foreign-view-cells.mq.md).

A view document is still a document. Named kernels and a cell order are ordinary bound tables:

```text
`分析内核` =

| 名称 | 语言 | 说明 |
|------|------|------|
| 分析 | 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](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 with*None*.

## 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](https://github.com/cflmy/marqdo/releases) |
| From source | `cargo build --release` (needs a local Rust toolchain) |

Official extensions update independently of the CLI:

```text
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`](features/05-extensions.mq.md).

Variable