# Project Docs in Markdown

The FullStacked Cloud Console renders the Markdown files of a project (`*.md`, `*.markdown`) as documentation: GitHub Flavored Markdown, Mermaid diagrams, LaTeX formulas and live HTML/CSS/JS previews. Open a project in the Console: **Files** preselects the root `README.md`, and every Markdown file opens in **Rendered** mode, with **Code** for the raw source and **Split** (writers only) to edit with a live preview.

This page lists what the renderer supports, so documentation written for it, by hand or by an agent, renders the first time.

## GitHub Flavored Markdown

| Feature | Syntax | Notes |
| :--- | :--- | :--- |
| Headings | `#` to `######` | Each heading gets a GitHub-style id (`## Getting Started` → `#getting-started`) that links can target. |
| Line breaks | a single newline | A single newline inside a paragraph is a line break, as in GitHub comments. Leave a blank line to start a new paragraph. |
| Tables, task lists, strikethrough, autolinks | GFM | `- [x] done`, `~~old~~`, bare `https://` URLs. |
| Code fences | ```` ```ts ```` | Syntax-highlighted with a **Copy** button: TypeScript/TSX, JavaScript/JSX, JSON, HTML/XML/SVG, CSS, SQL, Python, Go, Bash/sh/zsh/`.env`/Dockerfile, YAML/TOML and Markdown. Other languages show as plain text. |
| Alerts | `> [!NOTE]` | `NOTE`, `TIP`, `IMPORTANT`, `WARNING` and `CAUTION`, as on GitHub. |
| Raw HTML | `<details>`, `<kbd>`, `<img>`, ... | Sanitized: scripts, event handlers, `<style>`, `<form>`, `<iframe>`, `<object>` and `<embed>` are removed. Use a [live preview](#html-css-js-live-previews) for interactive HTML. |

```markdown
> [!TIP]
> Run `npm run dev` before opening the app.

| Engine | Port |
| :--- | ---: |
| PostgreSQL | 5432 |
```

### Links

Links resolve like files in the repository, relative to the folder of the open document:

| Link | Opens |
| :--- | :--- |
| `#getting-started` | That heading of the same document. |
| `./setup.md`, `../docs/api.md#errors`, `/README.md` | That file in **Files** (with its heading), with Back/Forward history. A leading `/` is the repository root. |
| `src/db.ts#L10-L24` | That source file, lines 10 to 24 highlighted. |
| A path of a Git submodule | The submodule's repository (another project, or its external host). |
| `https://...`, `mailto:...` | A new browser tab. |

### Images

Relative image paths (`![Schema](./assets/schema.png)`, or `<img src="../diagrams/flow.svg">`) are read from the repository on the same branch, so they render in private projects too. Supported types: PNG, JPEG, GIF, WebP, SVG and AVIF. External `https://` images and `data:image/...` URIs work as is.

## Mermaid diagrams

A ```` ```mermaid ```` fence renders as a diagram card with zoom (50% to 300%), **Expand** (fullscreen with pan, wheel and pinch zoom, **Fit** and **1:1**) and **Copy** (the diagram source). A diagram with a syntax error shows the error in its card; the rest of the document still renders.

````markdown
```mermaid
flowchart LR
    App["index.tsx"] --> Action["actions/add-todo.ts"]
    Action --> DB[("PostgreSQL")]
```
````

Supported diagram types: `flowchart`, `graph`, `sequenceDiagram`, `classDiagram`, `stateDiagram` (and `-v2`), `erDiagram`, `journey`, `gantt`, `pie`, `quadrantChart`, `requirementDiagram`, `gitGraph`, `C4Context` / `C4Container` / `C4Component` / `C4Dynamic` / `C4Deployment`, `mindmap`, `timeline`, `zenuml`, `sankey-beta`, `xychart-beta`, `block-beta`, `packet-beta`, `kanban`, `architecture-beta`, `radar-beta` and `treemap-beta`.

### Diagrams are validated on commit and push

Every ```` ```mermaid ```` block of a Markdown file must pass these checks:

1. The first statement names one of the diagram types above.
2. Block openers are closed by `end`: `subgraph` in flowcharts, `loop`, `alt`, `opt`, `par`, `critical`, `break`, `rect` and `box` in sequence diagrams, and so on.
3. Brackets and double quotes are balanced. Quote labels that contain brackets or parentheses: `A["parse(input)"]`.

A commit of the dev state (Console, REST or MCP `projects_commit`) with an invalid diagram fails with `422 INVALID_DIAGRAMS` and the file, line and message of each issue. A `git push` is rejected per branch in the same way (Markdown files the branch adds or changes, up to 1000 files, files over 2 MiB skipped). Check diagrams before committing with `POST https://git.fullstacked.cloud/api/v1/projects/:id/validate-diagrams` (`{ branch?, file_path? }`) or the MCP tool `projects_validate_diagrams`.

To show Mermaid source as code instead of a diagram, wrap it in a longer fence (four backticks around the three-backtick block, as in the example above).

## Formulas (LaTeX)

Formulas render with KaTeX, which is only loaded for documents that contain math.

| Kind | Syntax | Renders as |
| :--- | :--- | :--- |
| Display | `$$ ... $$` or `\[ ... \]` on their own lines, or a ```` ```math ```` fence (also `latex`, `katex`, `tex`) | A **Formula** card, centered, with a **Copy** button for the LaTeX source. |
| Inline | `$...$` or `\( ... \)` inside text | Inline math; hovering shows the LaTeX source. |
| Inline, display style | `$$...$$` inside a paragraph | A full-size formula kept in the line. |

````markdown
The monthly cost is $C = n \cdot p$ for $n$ seats at price $p$.

$$
\text{latency}_{p95} = \min\{ t : P(T \le t) \ge 0.95 \}
$$

```math
\sum_{i=1}^{n} i = \frac{n(n+1)}{2}
```
````

Inline `$...$` follows Pandoc's rules so prices stay text: the opening `$` must be followed by a non-space, the closing `$` preceded by a non-space and not followed by a digit, and a span of only digits is never math. `It costs $5 or $10` stays plain text. Escape a dollar sign that should never start math as `\$`.

A formula with a LaTeX error renders with the error highlighted instead of failing the document. Underscores inside `\text{...}` are escaped for you (`\text{max_retries}` works).

## HTML/CSS/JS live previews

Document UI with a live preview rather than a static code block: the Console runs it in a sandboxed frame with a toolbar to switch **Dark** / **Light**, the width (**100%**, **768px**, **375px**), the mode (**Preview**, **Split**, **Code** with **All** / **HTML** / **CSS** / **JS** tabs), **Reload** and **Copy**.

Open a preview with any of these fences, with an optional title:

- ```` ```html/css/js title="Pricing card" ````
- ```` ```html preview ````, ```` ```html:preview ````, ```` ```html-preview ````
- ```` ```ui-snippet ````, ```` ```ui ````, ```` ```snippet ````

or with a `<ui-preview title="...">`, `<snippet>` or `<ui>` tag around the content.

````markdown
```html/css/js title="Status badge"
<style>
  .badge { display: inline-flex; gap: 6px; padding: 2px 8px; border-radius: 999px;
           font: 12px system-ui; background: #10301f; color: #4ade80; }
  .badge.off { background: #3a1414; color: #f87171; }
</style>
<span class="badge" id="b">● Online</span>
<button id="t">Toggle</button>
<script>
  document.getElementById("t").onclick = () => {
    const b = document.getElementById("b");
    b.classList.toggle("off");
    b.textContent = b.classList.contains("off") ? "● Offline" : "● Online";
  };
</script>
```
````

How a preview runs:

| Fact | Consequence |
| :--- | :--- |
| Every `<style>` block becomes the CSS, every inline `<script>` the JS (run after the markup), the rest the HTML | Write one self-contained block; order between them does not matter. |
| Sandboxed frame (`sandbox="allow-scripts allow-modals"`) with an opaque origin | No access to the Console, its cookies or storage. `localStorage` and `sessionStorage` are unavailable: keep state in variables. |
| Content Security Policy `default-src 'none'`: only inline scripts and styles | No `fetch`, XHR or WebSocket, and no external scripts or stylesheets (`<script src>`, CDN links, web font CSS). Images, fonts and media may come from `data:`, `blob:` or `https:` URLs. Prefer inline SVG. |
| Base styles: 16px padding, system font, dark (`#0b101b`) or light (`#ffffff`) background following the toolbar | Style for both themes, or set your own background. |
| The frame grows with its content, up to 4000px | No fixed heights needed. |
| An uncaught error or rejected promise shows an error banner with **Reload** | Check the banner when a preview stays blank. |

Previews are not validated on commit. The documentation portal and plain Git hosts show them as code.

## Checklist for agents

1. Put project documentation in `README.md` and `docs/*.md`; link pages with relative paths (`./api.md#errors`) and source files with line ranges (`src/db.ts#L10-L24`).
2. Draw architecture and flows with ```` ```mermaid ````; quote labels containing brackets, close every `subgraph` / `loop` / `alt` with `end`, and run `projects_validate_diagrams` before `projects_commit`.
3. Write math as `$...$` inline and `$$...$$` (or ```` ```math ````) for display; escape literal dollars as `\$`.
4. Show UI with ```` ```html/css/js title="..." ```` blocks: inline `<style>`, markup and `<script>`, no network, no external assets, inline SVG for icons.
5. Keep images in the repository (`./assets/...`) and reference them relatively.
6. Raw HTML is sanitized: no scripts, styles or forms outside a live preview.
