Add foreign stdlib with code values and ship v0.0.4.

Bind `lang fences like formulas, run them via local interpreters, polish live-view code cards, and refresh bilingual welcome docs.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
cflmyandCursor committed 2026-08-05 12:50:01 +08:00
1 parent dcd0cdb8f7
commit b5e9d15391
33 files changed
+1044 -199

No files matched your search

+34 -6
View File
@@ -1,23 +1,25 @@
---
title: Welcome to Marqdo
description: User docs home — code is documentation
description: User docs home — code is documentation (English)
> lib/math.mq.md
> lib/foreign.mq.md
---
# main
Hi — thanks for opening this site. Marqdo is a language where **code is documentation**: Markdown markers are the program structure, so what you read is what runs.
Hi — thanks for reading this far. I am Marqdo’s developer. Marqdo is a language where **code is documentation, and documentation is code**: Markdown markers are the program structure, so what you read is what runs.
AI already prefers Markdown. Marqdo asks: why keep docs and code as two worlds? A `.mq.md` file is both. The longer ambition includes OKF-style knowledge YAML and more; for now the focus is a solid interpreter and this site (yes — generated by Marqdo itself).
AI already prefers Markdown-shaped output. The idea was: why keep docs and code as two separate worlds? So Marqdo was born as a “docs are code” language. To keep every source renderable as Markdown, files use the `.mq.md` suffix. From early on we aimed for richer tooling — auto-generated YAML for OKF-style knowledge bases, even auto-generated slides — those are later goals. Happily, it already works well as a blogging tool: yes, this site is generated by Marqdo. And when AI writes Marqdo, you tend to burn fewer tokens — wallets everywhere thank you.
The language is young. You get structure markers, a small bilingual core (`print` / `打印`, …), optional stdlib files under `lib/` (see [`stdlib/`](stdlib/) on this site), local `view`, and static export. Contribute on [GitHub](https://github.com/cflmy/marqdo).
The language is still young: structure markers, bilingual core names (`print` / `打印`, …), importable stdlibs (see [`stdlib/`](stdlib/) on this site), local `view`, and static export. Contribute on [GitHub](https://github.com/cflmy/marqdo).
中文文档请看同目录的 [`00-欢迎.mq.md`](00-欢迎.mq.md)(叙述与内置均用中文)。
A classic hello via a small function:
A small function to say hello:
> greet who=marqdo
Named args allow spaces in values:
Named args can include spaces:
> greet who=marqdo user
@@ -25,3 +27,29 @@ Named args allow spaces in values:
- who
> print text=Welcome, `who`!
---
Beyond the basics above, Marqdo also ships standard libraries: table, time, text, files, system, math, foreign, and more.
Math and foreign deserve a special mention. With the math library you can bind a formula like this:
`f` =
$$
x^2 - 2
$$
Then plot it:
*`_svg` = > plot formula=`f` var=x min=-3 max=3 *
The foreign library lets you call external code, for example:
`hi` =
```python
print("hello-from-python")
```
Under Markdown this stays easy to read — which is the point: Marqdo’s design is code as documentation, documentation as code.
Welcome again — enjoy exploring Marqdo.
+31 -2
View File
@@ -1,13 +1,15 @@
---
title: 欢迎使用 Marqdo
description: 用户文档首页 — 代码即文档(中文版)
> lib/数学.mq.md
> lib/外联.mq.md
---
# main
阅读到这里的朋友你好!我是 Marqdo 的开发者。Marqdo 是一门**代码即文档**的语言:Markdown 标记就是程序结构,你读到的就是能跑的程序。
阅读到这里的朋友你好!我是 Marqdo 的开发者。Marqdo 是一门**代码即文档,文档即代码**的语言:Markdown 标记就是程序结构,你读到的就是能跑的程序。
AI 输出本就偏爱 Markdown。作者的念头是:何必再把文档和代码拆成两套?`.mq.md` 双后缀保证它仍是合法 Markdown。更长远的目标包括 OKF 式知识清单等;眼下先把解释器与本站做好——对,这个站点就是 Marqdo 生成的。
AI 偏爱 Markdown结构的输出。作者的念头是:何必再把文档和代码拆成两套?我们来实现一个文档即代码的语言,所以marqdo应运而生,为了确保代码一定可以被渲染,marqdo的文件后缀定义为了`.mq.md`。在开发之处我们就尝试希望更丰富的支持,自动生成一个yaml文件使得 OKF 式知识库便捷的自动配置,乃至自动生成ppt,自然这都是以后的目标了。不过相当不错的是,至少这会成为一个不错的博客工具——对,这个站点就是 Marqdo 生成的,而且AI输出的时候会节约不少token,你知道的,token烧的太多,钱包会可怜的饿瘦的。
语言仍在起步:结构标记、中英内核双名(`打印` / `print` …)、可导入的标准库(见本站 [`stdlib/`](stdlib/))、本地 `view` 与静态导出。欢迎到 [GitHub](https://github.com/cflmy/marqdo) 一起做。
@@ -25,3 +27,30 @@ English docs: [`00-welcome.mq.md`](00-welcome.mq.md) (English prose and English
- 谁
> 打印 内容=欢迎,`谁`!
---
除了上面的一些基本内容之外,我还开发了这个语言的一些标准库,包括表、时间、文本、文件、系统、数学和外联等标准库。
其中数学库和外联库是我要着重提到的,例如数学库,你可以通过下面的方式调用:
`f` =
$$
x^2 - 2
$$
之后让我们画个图像吧!
*`_svg` = > 绘图 formula=`f` var=x min=-3 max=3 *
外联库则允许你调用外部代码,例如:
`hi` =
```python
print("hello-from-python")
```
这些代码在markdown下面都非常的易读,就像我说的,marqdo的设计思想就是代码即文档,
文档即代码。
最后,再次欢迎你,尽情体验marqdo吧!
+1 -1
View File
@@ -9,7 +9,7 @@
| [`00-welcome.mq.md`](00-welcome.mq.md) / [`00-欢迎.mq.md`](00-欢迎.mq.md) | 首页(英 / 中) |
| [`structure/`](structure/) | 基本结构 |
| [`keywords/`](keywords/) | 关键字与 L0 内置 |
| [`stdlib/`](stdlib/) | **标准库**(导入方式 + text/表/文件/时间/系统/json/网络/数学) |
| [`stdlib/`](stdlib/) | **标准库**(导入方式 + text/表/文件/时间/系统/json/网络/数学/外联) |
| [`features/`](features/) | 特性迭代 |
**不放** `errors/`:失败样例只在 `tests/errors/`。
+1 -1
View File
@@ -11,7 +11,7 @@ English-named files export English APIs; Chinese-named files export Chinese APIs
No extra allow flags: importing a module means you intend to use it. Under marqdo view or static export, exit soft-fails and long sleeps are clamped so the console stays up.
Modules: text (text / 文本), table (table / 表), files (fs / 文件), time (time / 时间), system (sys / 系统), json (json only), net (net / 网络), math (math / 数学).
Modules: text (text / 文本), table (table / 表), files (fs / 文件), time (time / 时间), system (sys / 系统), json (json only), net (net / 网络), math (math / 数学), foreign (foreign / 外联).
Sibling pages in this folder document each module. Chinese overview: 00-索引.mq.md.
+1 -1
View File
@@ -11,7 +11,7 @@ description: 如何导入官方 lib 模块
导入即表示要用对应能力,无需再加允许旗标。marqdo view 或静态导出里,退出会软失败、长睡眠会被钳制,以免拖垮控制台。
模块:文本(text / 文本)、表(table / 表)、文件(fs / 文件)、时间(time / 时间)、系统(sys / 系统)、json(仅 json)、网络(net / 网络)、数学(math / 数学)。
模块:文本(text / 文本)、表(table / 表)、文件(fs / 文件)、时间(time / 时间)、系统(sys / 系统)、json(仅 json)、网络(net / 网络)、数学(math / 数学)、外联(foreign / 外联)。
各模块说明见本目录其它页。English: 00-overview.mq.md.
+20
View File
@@ -0,0 +1,20 @@
---
title: lib/foreign — external languages
description: Run local interpreters from Marqdo (English)
> lib/foreign.mq.md
---
# main
Import lib/foreign.mq.md. Bind a code fence like a formula: empty-RHS assign then a ```lang block. The value type is code. Call run code=`name` to execute via your local interpreter. run_lang runs an inline source string.
`hi` =
```python
print("hello-from-python")
```
Default command is python (Windows) or python3 (Unix). Override with set_cmd, env MARQDO_FOREIGN_PYTHON, or the command box in live view. Failures ask you to check that configuration.
*`out` = > run code=`hi` *
> print text=`out`
+20
View File
@@ -0,0 +1,20 @@
---
title: lib/外联 — 外部语言
description: 从 Marqdo 调用本机解释器(中文)
> lib/外联.mq.md
---
# main
导入 lib/外联.mq.md。代码围栏与公式同构:空 RHS 赋值后跟 lang 代码块,得到 code 类型。用 运行 代码=`名` 调用本机解释器。
`hi` =
```python
print("hello-from-python")
```
默认命令可用 设置命令 或 MARQDO_FOREIGN_PYTHON 覆盖;live view 里可改命令框再点 Run。
*`out` = > 运行 代码=`hi` *
> print text=`out`