sync: bring Rust crates in line with nuwiki main (v0.4.1)
This commit is contained in:
@@ -385,19 +385,27 @@ fn render_page_html_numbers_headers_when_enabled() {
|
||||
)
|
||||
.unwrap();
|
||||
assert!(
|
||||
html.contains("<div id=\"Intro\"><h1 id=\"Intro\" class=\"header\"><a href=\"#Intro\">1. Intro</a></h1></div>"),
|
||||
html.contains(
|
||||
"<div id=\"Intro\"><h1 id=\"Intro\" class=\"header\"><a href=\"#Intro\">1. Intro</a></h1></div>"
|
||||
),
|
||||
"got: {html}"
|
||||
);
|
||||
assert!(
|
||||
html.contains("<div id=\"Intro-Background\"><h2 id=\"Background\" class=\"header\"><a href=\"#Intro-Background\">1.1. Background</a></h2></div>"),
|
||||
html.contains(
|
||||
"<div id=\"Intro-Background\"><h2 id=\"Background\" class=\"header\"><a href=\"#Intro-Background\">1.1. Background</a></h2></div>"
|
||||
),
|
||||
"got: {html}"
|
||||
);
|
||||
assert!(
|
||||
html.contains("<div id=\"Intro-Methods\"><h2 id=\"Methods\" class=\"header\"><a href=\"#Intro-Methods\">1.2. Methods</a></h2></div>"),
|
||||
html.contains(
|
||||
"<div id=\"Intro-Methods\"><h2 id=\"Methods\" class=\"header\"><a href=\"#Intro-Methods\">1.2. Methods</a></h2></div>"
|
||||
),
|
||||
"got: {html}"
|
||||
);
|
||||
assert!(
|
||||
html.contains("<div id=\"Results\"><h1 id=\"Results\" class=\"header\"><a href=\"#Results\">2. Results</a></h1></div>"),
|
||||
html.contains(
|
||||
"<div id=\"Results\"><h1 id=\"Results\" class=\"header\"><a href=\"#Results\">2. Results</a></h1></div>"
|
||||
),
|
||||
"got: {html}"
|
||||
);
|
||||
}
|
||||
@@ -419,14 +427,45 @@ fn render_page_html_numbering_skips_headers_above_start_level() {
|
||||
)
|
||||
.unwrap();
|
||||
assert!(
|
||||
html.contains("<div id=\"Title\"><h1 id=\"Title\" class=\"header\"><a href=\"#Title\">Title</a></h1></div>"),
|
||||
html.contains(
|
||||
"<div id=\"Title\"><h1 id=\"Title\" class=\"header\"><a href=\"#Title\">Title</a></h1></div>"
|
||||
),
|
||||
"h1 unnumbered, got: {html}"
|
||||
);
|
||||
assert!(
|
||||
html.contains("<div id=\"Title-Section\"><h2 id=\"Section\" class=\"header\"><a href=\"#Title-Section\">1 Section</a></h2></div>"),
|
||||
html.contains(
|
||||
"<div id=\"Title-Section\"><h2 id=\"Section\" class=\"header\"><a href=\"#Title-Section\">1 Section</a></h2></div>"
|
||||
),
|
||||
"got: {html}"
|
||||
);
|
||||
assert!(
|
||||
html.contains(
|
||||
"<div id=\"Title-Section-Sub\"><h3 id=\"Sub\" class=\"header\"><a href=\"#Title-Section-Sub\">1.1 Sub</a></h3></div>"
|
||||
),
|
||||
"got: {html}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn render_page_html_same_page_anchor_uses_current_filename() {
|
||||
// vimwiki parity (#4): `[[#Section]]` resolves to `<page>.html#Section`,
|
||||
// not a bare `#Section`, where <page> is the file being rendered.
|
||||
let ast = parse("= Contents =\n\n[[#Contents]]\n");
|
||||
let c = cfg("/tmp/x");
|
||||
let html = export::render_page_html(
|
||||
&ast,
|
||||
None,
|
||||
"index",
|
||||
DiaryDate::from_ymd(2026, 5, 11).unwrap(),
|
||||
&c.html,
|
||||
None,
|
||||
HashMap::new(),
|
||||
)
|
||||
.unwrap();
|
||||
assert!(
|
||||
html.contains("<a href=\"index.html#Contents\">"),
|
||||
"got: {html}"
|
||||
);
|
||||
assert!(html.contains("<div id=\"Title-Section-Sub\"><h3 id=\"Sub\" class=\"header\"><a href=\"#Title-Section-Sub\">1.1 Sub</a></h3></div>"), "got: {html}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -443,8 +482,18 @@ fn render_page_html_no_header_numbering_by_default() {
|
||||
HashMap::new(),
|
||||
)
|
||||
.unwrap();
|
||||
assert!(html.contains("<div id=\"Intro\"><h1 id=\"Intro\" class=\"header\"><a href=\"#Intro\">Intro</a></h1></div>"), "got: {html}");
|
||||
assert!(html.contains("<div id=\"Intro-Sub\"><h2 id=\"Sub\" class=\"header\"><a href=\"#Intro-Sub\">Sub</a></h2></div>"), "got: {html}");
|
||||
assert!(
|
||||
html.contains(
|
||||
"<div id=\"Intro\"><h1 id=\"Intro\" class=\"header\"><a href=\"#Intro\">Intro</a></h1></div>"
|
||||
),
|
||||
"got: {html}"
|
||||
);
|
||||
assert!(
|
||||
html.contains(
|
||||
"<div id=\"Intro-Sub\"><h2 id=\"Sub\" class=\"header\"><a href=\"#Intro-Sub\">Sub</a></h2></div>"
|
||||
),
|
||||
"got: {html}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user