Skip to content

haiku + docs-page: nav-link 缺 display:block, mermaid block 被 <pre> 包裹导致 syntax error #88

Description

@xiataoyue

Environment

  • Agent CLI: Claude Code (/Users/naughtybeds/.local/bin/claude)
  • Model: claude-haiku-4-5-20251001
  • Template: docs-page
  • html-anything: main @ commit fresh clone (2026-05-26)
  • Input: ~3KB markdown with one mermaid sequenceDiagram

Bug 1 — .nav-link 缺少 display: block

In the generated HTML, the left-sidebar nav block looks like:

<aside class="...">
  <div class="mt-3 space-y-1">
    <a href="#overview" class="nav-link active">概览与索引</a>
    <a href="#fig1" class="nav-link">图1:启动连接</a>
    ...
  </div>
</aside>

with this CSS:

.nav-link {
    padding: 0.625rem 1rem;
    color: var(--color-text-muted);
    text-decoration: none;
    border-radius: 0.375rem;
    transition: all 0.2s;
    font-size: 0.9375rem;
    /* ❌ no display: block — anchors stay inline */
}

Result: every nav item collapses onto one wrapped line; space-y-1 is a no-op for inline <a> (it adds margins to direct children, but inline elements don't honor vertical margins).

Fix (one line): add display: block; (or use Tailwind class block on the <a> instead of a custom class).

Reproducibility: consistent across multiple haiku runs of docs-page. A second haiku run with same input did emit display: block correctly — so this is an output-stability issue with the model on this template, not deterministic.

Bug 2 — mermaid block wrapped in <pre> and <br/> tags get eaten

The same haiku run produced:

<div class="mermaid">
    <pre>
sequenceDiagram
    autonumber
    participant App as "App (client.c)"
    App->>Lib: wl_display_connect(NULL)<br/>wayland-client.c:1351
    ...
    </pre>
</div>

Two problems:

  1. <pre> wrapper: Mermaid's init reads <div class="mermaid"> textContent. Browser HTML parsing strips the <pre> start/end tags (they end up empty whitespace), but more importantly the <br/> tags inside are parsed as real <br> elements and don't appear in textContent — they're replaced by a literal newline. Mermaid then sees wl_display_connect(NULL)\nwayland-client.c:1351 as the message text, which is invalid syntax inside a single App->>Lib: … line. Result: "Syntax error in text — mermaid version 10.9.6".

  2. <br/> should be HTML-entity-encoded so mermaid receives the literal string <br/> and applies its own line-break rendering.

Fix: in the mermaid output path, render as:

<div class="mermaid">
sequenceDiagram
    autonumber
    participant App as "App (client.c)"
    App->>Lib: wl_display_connect(NULL)&lt;br/&gt;wayland-client.c:1351
</div>

No <pre>, <br/>&lt;br/&gt;. This works correctly when the agent emits it.

Suggested guardrails in SKILL.md

Adding these two lines to next/src/lib/templates/skills/docs-page/SKILL.md (and possibly shared.ts) would likely eliminate both bugs:

- 任何 .nav-link / .sidebar-item / 自定义类 ➜ 必须含 `display: block` 或同等 `flex`,否则在 sidebar 中会塌成一行。
- Mermaid 块直接写 `<div class="mermaid">…</div>`,**不要嵌套 `<pre>`**;图源里的 `<br/>` 必须 HTML-entity 编码为 `&lt;br/&gt;`。

Repro repo / context

I'm running html-anything against a real markdown doc that contains 5 Mermaid sequence/class diagrams generated from a codebase analysis. Happy to share the input markdown if useful — the bugs are deterministic on this template + this CLI; one fresh haiku run reproduces both.

Thanks for the project! Local agent → HTML loop is a great direction. 🚀

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinggood first issueGood for newcomershelp wantedExtra attention is needed

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions