phase 5: renderer trait + HtmlRenderer
Writer-based `Renderer` trait per SPEC §6.8: object-safe
`fn render(&self, doc, w: &mut dyn Write) -> io::Result<()>` plus
a `render_to_string` convenience. Object safety preserves the option
of `Box<dyn Renderer>` in the LSP layer.
`HtmlRenderer` builder accepts a link-resolution callback (via
`with_link_resolver`) and an optional enclosing template (via
`with_template`). The default resolver mirrors §9: Wiki paths become
`path.html`, interwiki links land in sibling directories
(`../wiki<N>/` / `../wn-<Name>/`), diary entries under `diary/`,
file/local schemes use literal paths, anchor-only collapses to `#`.
Renderer covers every AST node:
- block: heading (centered class), paragraph, hr, blockquote,
preformatted (`language-<lang>` class), math block (with
`\begin{env}` when an environment is set), lists (ordered/unordered
+ every checkbox state, plus recursive sublists), definition list
(dt/dd), table (thead/tbody driven by `is_header`, col/row span as
CSS class hooks), comment (as HTML comment with `--` neutralised),
error node (as `.parse-error` span)
- inline: strong/em + bold-italic, `<del>`, code (escaped),
`<sup>`/`<sub>`, math-inline wrapped in `\(...\)`, keyword spans
with per-keyword class, color spans, wikilink/external/raw URL
anchors, transclusion as `<img>` with sorted attrs
HTML escaping is byte-level (`<>&"'`). Template substitution replaces
`{{content}}` first so a body containing the literal `{{title}}`
isn't double-substituted.
Tests (31 new) cover every block + inline construct, every LinkKind
through the default resolver, HTML escaping, custom resolver
override, template with/without title metadata, and an end-to-end
smoke test on a multi-construct document.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -3,8 +3,8 @@
|
||||
A Vim/Neovim plugin providing full vimwiki syntax support, implemented as a
|
||||
Rust-based language server (LSP).
|
||||
|
||||
> **Status:** Phase 4 (vimwiki parser) complete. End-to-end source → AST works
|
||||
> via `VimwikiSyntax`. Renderer and editor glue still pending.
|
||||
> **Status:** Phase 5 (HTML renderer) complete. End-to-end source → AST → HTML
|
||||
> works via `VimwikiSyntax` + `HtmlRenderer`. LSP and editor glue still pending.
|
||||
|
||||
See [`SPEC.md`](./SPEC.md) for the full project specification.
|
||||
|
||||
@@ -17,8 +17,8 @@ See [`SPEC.md`](./SPEC.md) for the full project specification.
|
||||
| 2 | Syntax Plugin Interface | ✅ done |
|
||||
| 3 | Vimwiki Lexer | ✅ done |
|
||||
| 4 | Vimwiki Parser | ✅ done |
|
||||
| 5 | Renderer | ⏳ next |
|
||||
| 6 | LSP Foundation | ⏳ |
|
||||
| 5 | Renderer | ✅ done |
|
||||
| 6 | LSP Foundation | ⏳ next |
|
||||
| 7 | Semantic Tokens | ⏳ |
|
||||
| 8 | Navigation | ⏳ |
|
||||
| 9 | Editor Glue | ⏳ |
|
||||
|
||||
Reference in New Issue
Block a user