HTML export diverges from upstream vimwiki :VimwikiAll2HTML output (headings, code fences, tag ids) #6
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
When rendering the same
.wikisources with the same templates, the HTML produced by nuwiki's export (nuwiki.export.allToHtmlForce/:VimwikiAll2HTML) is not identical to the HTML produced by upstream vimwiki's:VimwikiAll2HTML. The same set of files is generated (no page missing or extra), but every file differs, in several systematic ways.Raising this to check whether byte-for-byte parity with vimwiki is a goal, or whether these are intentional (and generally cleaner) reimplementation choices. A couple of the differences are user-visible with a custom template.
Environment
nuwiki-ls(x86_64-unknown-linux-gnu release binary), Neovim 0.12master) under Vim 9.2*.wikifiles, sametemplate_path/template_default/template_ext, sameg:vimwiki_listandg:vimwiki_*globals (global_ext=0,toc_header_level=2,html_header_numbering=0)What matches
Inter-page links (
href="foo.html"), tables (<table>/<tr>/<th>/<td>), blockquotes, todo-list classes (done0..4,rejected),class="tag", and the flat headingids used by intra-page TOC links.Differences
1. Heading markup (structural)
nuwiki drops the wrapping
<div>with its hierarchical (parent-scoped)id, theclass="header", and the in-heading self-link<a href="#...">. Result: no clickable header anchor links, nothing for CSS to hook via.header, and deep-links to the hierarchical ids no longer resolve. (Flatids are preserved, so normal TOC links still work.)2. Code fences (most visible difference)
nuwiki's form is arguably more correct (a real
language-*class that highlight.js consumes directly), but it is a different DOM shape, so syntax highlighting renders differently between the two.3. Tag anchor ids
:tag:inline tags:nuwiki prefixes the anchor id with
tag-, so deep-links to a tag anchor (#wiki) break.4. Same-page anchor hrefs
href="index.html#Contents"(vimwiki) vshref="#Contents"(nuwiki). Both resolve; the format differs.5. Entity encoding (stricter in nuwiki)
'->'in attribute values;"->"inside<code>. Same rendering, different bytes.6. List markup
nuwiki closes
<li>/</ul>and is compact (one item per line); vimwiki leaves<li>unclosed with blank lines. Both are valid HTML5.7. Auto-generated
style.cssvimwiki emits its full ~187-line default stylesheet; nuwiki emits a ~1-line minimal one. Different content (no impact when a template supplies its own CSS).
8. Whitespace / size
nuwiki output is roughly half the line count for the same page (e.g. 401 -> 216 lines), with much less inter-element whitespace.
Question
Are 1–3 (headings without
class="header"/self-anchor/hierarchical id, the<pre><code class="language-*">code-fence shape, and thetag-id prefix) intended, or should nuwiki match vimwiki's output? Happy to provide a full per-file unified diff if useful.Fixed in v0.4.0 (commit
8fdfa9e). The exported HTML now matches upstream vimwiki's:VimwikiAll2HTMLon the structural differences you flagged:<div id="{hierarchical-id}"><h{n} id="{flat-id}" class="header"><a href="#{hierarchical-id}">…</a></h{n}></div>. The flatidstays on the heading so intra-page TOC /#anchorlinks keep resolving, and the hierarchical id +.header+ self-anchor are back for CSS and deep-links.<pre python>(the verbatim text after{{{dropped in as raw attributes), instead of<pre><code class="language-python">.id="wiki", no moretag-prefix. (This also fixed a real inconsistency: the LSP reported[[Page#wiki]]as a valid link while the exported HTML emittedid="tag-wiki", so that link was actually broken.)[[#Contents]]now resolves toindex.html#Contentsrather than a bare#Contents.style.css— the auto-generated default is now vimwiki's stock stylesheet verbatim, so a fresh export looks identical out of the box and the.header/.tag/.toc/done*classes are styled.Left intentionally unchanged: #5 (entity encoding — stricter is safer), #6 (list whitespace) and #8 (overall whitespace) are valid HTML5 with no template impact, so I didn't chase byte-for-byte parity there. Centered headings and the
<div class="toc">Contents wrapper also keep their current form.To pick it up, update the plugin and reinstall the server binary:
:Lazy update nuwiki, then:NuwikiInstall(or:lua require('nuwiki').install()), then restart.nuwiki-lsbinaries are attached to the v0.4.0 release.If you still have your comparison setup handy, a fresh
:VimwikiAll2HTMLdiff against v0.4.0 would be very welcome — especially to confirm the exact markup for theContentsheading and any multi-word/centered headings, since my test cases used single-word headings. Thanks for the thorough report!Re-ran the same comparison against v0.4.0 (cloned
v0.4.0, the v0.4.0nuwiki-lsbinary, identical.wikisources/templates, diffed against upstream vimwiki under Vim 9.2). Thanks — the structural fixes are confirmed. ✅Confirmed fixed (now identical to vimwiki, ignoring the intentional encoding/whitespace below)
Current Tasks,Tips and Tricks,Element galleryall now emit<div id="{Parent}-{Section}"><h2 id="{Section}" class="header"><a href="#{Parent}-{Section}">…</a></h2></div>. Your worry about single-word-only test cases was unfounded — multi-word headings match.<pre python>,<pre shell>,<pre java>— exact match.id="wiki"/id="meta"/id="work", notag-prefix.href="index.html#Contents"again.One structural difference remains: the
Contents/ TOC headingThis is the exact markup you asked about — it still diverges:
Unlike every other heading (which now gets the full treatment), the TOC header is missing three things vs vimwiki:
id="Contents"on the wrapping<div>(v0.4.0's div has onlyclass="toc"),class="header"on the<h2>,<a href="#Contents">…</a>inside it.The
#Contentsanchor still resolves (the<h2>keepsid="Contents"), so it isn't broken — just inconsistent with how regular headings now render.Notes
style.css: now vimwiki's stock 187-line sheet. Not quite byte-verbatim — the embedded base64 for two checkbox icons (.rejected,.done4) differs slightly from current upstream, looks like a vimwiki-version skew in the bundled images. Cosmetic, and moot when a template supplies its own CSS.'→',"→") and list/whitespace — consistent within each output, anchors resolve fine.Happy to share the full per-file diff if helpful. Nice turnaround on this!
Two follow-up rendering bugs found while reviewing the exported pages are now fixed in v0.4.1 (commit
a653903):== TODO ==) was rendering as an inline<span class="todo">badge with an emptyid, instead of a styled header. Now renders as a normal header (<div id="TODO"><h2 id="TODO" class="header"><a href="#TODO">TODO</a></h2></div>); keyword text is kept in the id (= My TODO list =→id="My TODO list"). Keyword badges still render in body text.[[page|Task [B-1]]]closed at the first]], truncating the description toTask [B-1and leaking a stray]. The close-scan is now bracket-aware, so the[B-1]is preserved and the link closes correctly.Combined with the earlier parity work (#1–4, #7), this closes out the issue. Grab the new
nuwiki-lsfrom the v0.4.1 release (:NuwikiInstall) and re-run the export. Thanks again for the detailed reports — please reopen if anything still looks off.