phase 17: html export commands + extended template vars
HtmlRenderer (nuwiki-core):
- `with_var(k, v)` / `with_vars(map)` add arbitrary `{{key}}`
substitution alongside the existing `{{title}}` / `{{content}}`.
Substitution order: content → title → user vars, so a rendered body
that happens to contain a literal `{{title}}` isn't double-processed.
WikiConfig (nuwiki-lsp/config):
- New `html: HtmlConfig` field with per-wiki export options matching
vimwiki's `g:vimwiki_*` keys: `html_path`, `template_path`,
`template_default`, `template_ext`, `template_date_format`,
`css_name`, `auto_export`, `html_filename_parameterization`,
`exclude_files`. Defaults: `<root>/_html` and `<root>/_templates`.
- `RawWiki` accepts all of the above through `initializationOptions`
(and `workspace/didChangeConfiguration` reload).
New `export` module (pure helpers):
- `output_path_for` — page name → on-disk HTML path. Slugifies only
the final segment when `html_filename_parameterization = true` so
the `diary/` subdir survives.
- `template_for` — primary/fallback path lookup tuple.
- `fallback_template` — minimal in-memory page used when neither
template file exists.
- `format_date` — strftime subset (`%Y`/`%m`/`%d`/`%%`) so we don't
depend on `chrono`/`time`.
- `build_toc_html` — nested `<ul class="toc">` from the doc's
headings, with HTML escaping.
- `compute_root_path` — `../` prefix per directory depth for
stylesheet hrefs in nested pages.
- `is_excluded` — glob matcher supporting `*`, `**`, `?`. Used by
the `allToHtml*` walker against `exclude_files`.
- `render_page_html` — wires the above into HtmlRenderer with
`{{date}}`, `{{root_path}}`, `{{toc}}`, `{{css}}` populated.
- `DEFAULT_CSS` — minimal stylesheet bundled for first-time exports.
New commands:
- `nuwiki.export.currentToHtml` — render the current buffer; honours
`%nohtml` and `%template`; ensures CSS exists.
- `nuwiki.export.allToHtml` — walk the wiki root, skip pages matched
by `exclude_files` and `%nohtml`, and only re-export pages whose
source is newer than the existing HTML (incremental behaviour
matching `:VimwikiAll2HTML`).
- `nuwiki.export.allToHtmlForce` — same but unconditional re-export.
- `nuwiki.export.browse` — alias of currentToHtml that returns the
`file://` URL of the rendered page in the response so the client
can open it.
- `nuwiki.export.rss` — write `<html_path>/rss.xml` listing the
wiki's diary entries newest-first.
- `did_save` handler — runs the auto-export equivalent when the
resolved wiki has `auto_export = true`.
LSP capability:
- `text_document_sync` switched from `Kind(FULL)` to `Options(...)`
so the server can register a `save` notification (otherwise
clients never push `did_save` events).
Tests: 33 new in `phase17_html_export.rs` covering HtmlConfig
defaults + JSON-shape config, the `format_date` subset (including
the `%%` escape and pass-through for unsupported specifiers),
root-path computation, output-path slugification rules, the glob
matcher (single-star, globstar, question-mark, non-match),
template_for primary/fallback selection, render_page_html for the
title/content/date/root_path triad and the override-by-extras flow,
and side-effecting disk paths (write_page creates parents, picks up
on-disk template, RSS is newest-first, ensure_css is idempotent).
Total 357 tests pass; fmt + clippy clean.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1382,14 +1382,11 @@ Deferred because the value proposition over the existing
|
||||
`workspace/rename` flow is marginal and the editor-side support is
|
||||
inconsistent across clients.
|
||||
|
||||
### 13.3 v1.1 phases 17–19
|
||||
### 13.3 v1.1 phases 18–19
|
||||
|
||||
Tracked in §10 with status `⏳`. Not "missing" from earlier phases —
|
||||
they're future work in the v1.1 roadmap:
|
||||
|
||||
- **Phase 17** — HTML export commands (`nuwiki.export.*`), template
|
||||
resolution, CSS file management, auto-export. Brings in
|
||||
`html_path` / `template_path` / `color_dic` / etc. config keys.
|
||||
- **Phase 18** — Multi-wiki. Data structures (Wiki aggregate,
|
||||
per-wiki index) already landed in Phase 11; this phase is the
|
||||
config-shape change and the picker commands.
|
||||
@@ -1397,6 +1394,15 @@ they're future work in the v1.1 roadmap:
|
||||
keymaps, text objects, folding (P14 already resolved in favour of
|
||||
LSP `foldingRange` + `foldexpr` fallback).
|
||||
|
||||
Phase 17 (HTML export commands) shipped with the focused command
|
||||
surface (`currentToHtml` / `allToHtml[Force]` / `browse` / `rss`),
|
||||
template-file + fallback resolution, the `{{date}}` / `{{root_path}}`
|
||||
/ `{{toc}}` / `{{css}}` template variables, and `did_save` auto-export
|
||||
when `auto_export = true`. `color_dic` integration with the
|
||||
`ColorNode` renderer is still open (it's only useful once `colorize`
|
||||
from §13.1 lands), as is the §13.1 `link.pasteUrl` follow-up that
|
||||
depends on the same export config.
|
||||
|
||||
### 13.4 §9 syntax checklist status
|
||||
|
||||
The §9 checklist tracks every vimwiki-syntax surface. Items currently
|
||||
|
||||
Reference in New Issue
Block a user