# Revise semantic HTML

> The HTML dialect read and written by agent tools and ReviseDocument.create().

Read tools (`read_blocks_from_index`, `read_specific_blocks`, `search_document`) return `context.html` in Revise semantic HTML. Structural mutations (`insert_block`, `replace_block`, `append_to_paragraph`) and `ReviseDocument.create({ html })` accept the same format.

It is a constrained semantic subset, not general browser HTML/CSS: the Yjs document model is the source of truth, and tool calls never reparse untouched blocks.

## Block elements

| Tag | Meaning | Notable attributes |
| --- | --- | --- |
| `<p>` | Paragraph | `id`, `style` (`text-align`, margins, indents, borders) |
| `<h1>`–`<h6>` | Heading (levels 1–6) | `id` |
| `<center>` | Centered paragraph | `id` |
| `<ul>`, `<ol>`, `<li>` | Bulleted or numbered list | `id`, `start`, `data-numbering-format`, `data-numbering-chain-id`, `data-indent-level` |
| `<table>`, `<thead>`, `<tbody>`, `<tr>`, `<th>`, `<td>` | Table | `id` on `<table>`/`<tr>`/`<td>`, `colspan`, `rowspan`, `data-borders`, `data-padding`, `data-cell-padding` |
| `<pre>` | Code block | `id`, `data-language` |
| `<div class="container">` | Callout / bordered container | `id` |
| `<img />` | Image block | `id`, `src`, `alt`, `width`, `height` |
| `<latex>` | Display math block | `id` |
| `<page-break />` | Hard page break | `id` |
| `<section-break />` | Section break | `id` |
| `<toc />` | Table of contents | `id` |
| `<hr />` | Horizontal rule | `id` |

## Inline elements

| Tag | Meaning |
| --- | --- |
| `<b>`, `<strong>` | Bold |
| `<i>`, `<em>` | Italic |
| `<u>` | Underline |
| `<s>`, `<strike>`, `<del>` | Strikethrough |
| `<code>` | Inline code |
| `<latex-inline>` | Inline LaTeX math |
| `<sup>`, `<sub>` | Superscript, subscript |
| `<mark color="...">` | Highlight (`yellow`, `orange`, `green`, `blue`, `purple`, `pink`, `gray`; default `yellow`) |
| `<a href="...">` | Hyperlink |
| `<br />` | Soft line break inside a block |
| `<span style="...">` | Inline CSS (`color`, `background-color`, `font-family`, `font-size`, `letter-spacing`, `font-variant: small-caps`, `text-transform: uppercase`) |

### Footnotes and endnotes

Create a note inline during `insert_block` or `replace_block`:

```html
<p>Liability is capped at annual fees.<sup data-footnote="Excluding gross negligence.">1</sup></p>
<p>See schedule.<sup data-footnote="Attached as Exhibit B." data-note-kind="endnote">i</sup></p>
```

Existing note references in read output carry `data-footnote-ref="<noteId>"`.

### Comments and tracked views

- Read tools mark comment anchors with `<comment-thread id="c1">anchored text</comment-thread>`.
- On `revise/server`, `doc.viewHtml(html, "tracked")` wraps pending changes in `<ins data-change-id="..." data-author="...">` and `<del data-change-id="..." data-author="...">`.

## Example

Typical `context.html` returned by `read_blocks_from_index`:

```html
<h1 id="b0">Master Services Agreement</h1>
<p id="b1">This Agreement is governed by the laws of <b>Delaware</b>.<sup data-footnote-ref="fn1">1</sup></p>
<table id="b2">
  <tr id="r0"><th>Role</th><th>Hourly Rate</th></tr>
  <tr id="r1"><td>Partner</td><td>$650</td></tr>
</table>
```

Valid input for `ReviseDocument.create({ html })` or `insert_block` (`id` attributes are optional on new blocks—the engine assigns stable IDs):

```html
<h2>Payment Terms</h2>
<p>Invoices are due within <b>30 days</b> of receipt.<sup data-footnote="Late balances accrue 1.5% monthly interest.">1</sup></p>
<ul>
  <li>Wire transfer in USD</li>
  <li>ACH to the designated account</li>
</ul>
<page-break />
```

## Unsupported HTML

`<script>`, `<style>`, arbitrary `<div>` wrappers (other than `<div class="container">`), CSS layout (`flex`, `grid`, `position`, `float`), and form inputs are ignored or stripped. Do not mutate `DocRoot` directly; author changes through semantic HTML tools or `replaceAll()`.
