feat(html): html_header_numbering section numbering for HTML export
CI / cargo fmt --check (push) Successful in 51s
CI / cargo clippy (push) Successful in 27s
CI / cargo test (push) Successful in 49s
CI / editor keymaps (push) Successful in 2m52s

Mirror vimwiki's html_header_numbering / html_header_numbering_sym:
top-level headings at or below the start level get a dotted section
number (1, 1.1, 1.2, ...) with a configurable trailing symbol. Off by
default (level 0). Nested headings in lists/quotes stay unnumbered,
matching upstream's document-level-only scan.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-02 00:33:01 +00:00
parent 88114a65a4
commit 79b502fa5c
5 changed files with 184 additions and 3 deletions
+18
View File
@@ -137,6 +137,12 @@ pub struct HtmlConfig {
pub custom_wiki2html_args: String,
/// URL prefix prepended to RSS feed / diary item links (`base_url`).
pub base_url: String,
/// vimwiki `html_header_numbering`: heading level at which automatic
/// section numbering starts in HTML export (`0` = off, the default).
pub html_header_numbering: u8,
/// vimwiki `html_header_numbering_sym`: symbol appended after the
/// section number (e.g. `.` → `1.2. Heading`). Empty by default.
pub html_header_numbering_sym: String,
}
impl Default for HtmlConfig {
@@ -155,6 +161,8 @@ impl Default for HtmlConfig {
custom_wiki2html: String::new(),
custom_wiki2html_args: String::new(),
base_url: String::new(),
html_header_numbering: 0,
html_header_numbering_sym: String::new(),
}
}
}
@@ -650,6 +658,10 @@ struct RawWiki {
custom_wiki2html_args: Option<String>,
#[serde(default)]
base_url: Option<String>,
#[serde(default)]
html_header_numbering: Option<u8>,
#[serde(default)]
html_header_numbering_sym: Option<String>,
// per-wiki keys mirroring vimwiki globals. All optional so
// existing single-wiki configs migrate without touching anything.
#[serde(default)]
@@ -745,6 +757,12 @@ impl From<RawWiki> for WikiConfig {
if let Some(s) = r.base_url {
html.base_url = s;
}
if let Some(n) = r.html_header_numbering {
html.html_header_numbering = n;
}
if let Some(s) = r.html_header_numbering_sym {
html.html_header_numbering_sym = s;
}
let d = wiki_defaults();
WikiConfig {
name: r.name.unwrap_or(derived_name),
+6
View File
@@ -252,6 +252,12 @@ pub fn render_page_html(
if !cfg.color_dic.is_empty() {
r = r.with_colors(cfg.color_dic.clone());
}
if cfg.html_header_numbering > 0 {
r = r.with_header_numbering(
cfg.html_header_numbering,
cfg.html_header_numbering_sym.clone(),
);
}
r.render_to_string(doc)
}