@Doc is not Markdown
It's a structured notation designed from the ground up for three audiences: humans who write content, AI that generates it, and compilers that render it.
@Doc 不是 Markdown
它是一種從零構建的結構化標記語言,專為三種使用者設計:撰寫內容的人類、生成內容的 AI,以及渲染它的編譯器
@Doc 做到了 Markdown 做不到的事,同時比 HTML 簡單十倍
- Markdown 沒辦法表達 這個按鈕是 primary variant
- Markdown 沒辦法定義表格的視覺樣式
- HTML 可以做到,但要寫一堆標籤和 class
Markdown was designed for humans to write, and for a single output: HTML. It has no concept of semantic intent, no structure for AI to reason about, and no way to compile to multiple targets without ambiguity.
@Doc separates structure from presentation. The same source file compiles cleanly to Tailwind JIT HTML, inline-style HTML, or any future render target — without changing a single character of the source.
Markdown 是為人類書寫而設計的,且只有一個輸出目標:HTML 它沒有語義意圖的概念,沒有供 AI 推理的結構,也無法在不產生歧義的情況下編譯到多個目標
@Doc 將結構與展示分離 同一份原始文件可以乾淨地編譯為 Tailwind JIT HTML、行內樣式 HTML,或任何未來的渲染目標——原始碼一字不改
Every node follows the same structure:
@node(modifier){styles}[content](action)
每個節點遵循相同的結構:
| Slot / 槽位 | Role / 角色 | Example / 範例 |
|---|---|---|
@node |
Node type / 節點類型 | @btn, @h1, @card |
(modifier) |
Variant or attribute / 變體或屬性 | (primary), (ja) |
{styles} |
Visual styles or metadata / 樣式或元數據 | {w-300px bg-fff} |
[content] |
Content slot — globally unique / 內容槽位——全域唯一 | [Submit] |
(action) |
Trailing trigger / 尾綴動作 | (submit), (install) |
[] has one meaning everywhere in @Doc: content. No escaping hell
[] 在 @Doc 中只有一個含義:內容徹底告別字元逃逸地獄
@seo {
"title": "@Doc 2026 Spec",
"description": "AI-native semantic document runtime"
}
@h1[@Doc 專案規範]
這是普通段落,其中包含行內語義節點:這是 @lang(ja)[日本語] 的展現
@card(featured){w-300px bg-f8f9fa text-sm}[
@title[AI 原生語言]
@text[具有確定性語法的結構化標記語言,專為雙向 AST 設計]
@btn(primary)[立即開始](install)
]
@table[
@cols[id,name,price]
@data[
[1,早餐,60]
[2,午餐,80]
[3,晚餐,90]
]
]
The same AST compiles to two output tracks without touching the source:
同一份 AST 可編譯為兩種輸出,無需修改原始碼:
Route A — Tailwind JIT
<button class="text-lg w-[120px] bg-[#fff]">Submit</button>Route B — Universal Inline Style
<button class="text-lg" style="width: 120px; background-color: #fff;">Submit</button>Dynamic values are stored in the AST as structured data ({ prop: "w", value: "120px" }), not raw strings. The adapter decides how to render them.
動態值在 AST 中以結構化資料儲存({ prop: "w", value: "120px" }),而非原始字串由後端適配器決定如何渲染
The immutable skeleton of any document.
文件骨架,不可再分割的原子
@h1 @h2 @h3 @p @quote @code @list @img @link @table
Two modes:
兩種行為模式:
- Inline Semantic — renders as a tagged inline element:
@lang(ja)[日本語] - Block Metadata — injects config into the host, renders no HTML:
@seo{...}
Generating HTML directly from LLMs is brittle. Hallucinated tags, unclosed elements, and inconsistent class names are hard to catch downstream.
直接讓 LLM 生成 HTML 很脆弱幻覺標籤、未閉合元素、不一致的 class 名稱都難以在下游捕捉
@Doc gives the model a constrained, deterministic grammar to generate into. Errors surface at parse time, not render time. And because [] is the only bracket with content semantics, the model doesn't need to reason about bracket collision.
@Doc 為模型提供一套受約束的確定性語法 錯誤在解析時暴露,而非渲染時 因為 [] 是唯一具備內容語義的括號,模型無需推理括號衝突問題
Token cost is also lower: w-300px instead of Tailwind's arbitrary value syntax w-[300px] — the bracket is restored by the compiler, not generated by the model.
Token 成本也更低:使用 w-300px 而非 Tailwind 的任意值語法 w-[300px]——括號由編譯器補回,而非由模型生成
Drop the parser and adapters into your pipeline. Feed it @Doc source, get structured AST out, render with whichever adapter fits your stack.
將 Parser 和 Adapters 加入你的 pipeline 輸入 @Doc 原始碼,輸出結構化 AST,用符合你技術棧的適配器渲染
import { tokenize } from './Lexer';
import { DocParser } from './Parser';
import { DocTranspiler } from './Adapters';
const tokens = tokenize(source);
const ast = new DocParser(tokens).parse();
const html = ast.map(node => DocTranspiler.toTailwindHTML(node)).join('\n');@Doc is intentionally not a programming language.
@Doc 刻意不是程式語言
- No variables / 無變數
- No conditionals / 無條件判斷
- No loops / 無迴圈
- No macros / 無巨集系統
Logic lives in the host application. @Doc owns structure, not behavior.
邏輯由 Host 應用負責 @Doc 只負責結構,不負責行為
Early development. Parser, Lexer, and dual-track Adapters are functional. Playground and CLI coming.
早期開發階段 Parser、Lexer 與雙線適配器已可運作 Playground 與 CLI 即將推出
MIT
