Cover nameref with a label on the next line

The heading-label fix and the title table interact: a label directly under
\section (no blank line) must still resolve \nameref to the heading title and
\autoref to "Section <n>". A preview test now pins that combination, rendering
"Introduction and Section 1" with no warnings and no "??".

No production code changed in this increment.
This commit is contained in:
gloamxun committed 2026-10-27 02:40:54 +08:00
1 parent 22d5332658
commit ae810867f7
4 files changed
+27 -5

No files matched your search

+22
View File
@@ -16722,6 +16722,28 @@ A definition.
assert!(!svg.contains("numberwithin"), "{svg}");
}
#[test]
fn nameref_resolves_labels_on_the_next_line() {
let source = "\\documentclass{article}\n\\begin{document}\n\n\\section{Introduction}\n\\label{sec:intro}\n\nSee \\nameref{sec:intro} and \\autoref{sec:intro}.\n\n\\end{document}\n";
let json = preview_json(source).expect("preview");
let value: serde_json::Value = serde_json::from_str(&json).expect("JSON");
assert_eq!(
value["warnings"].as_array().map(Vec::len),
Some(0),
"{}",
value["warnings"]
);
let svg = value["pages"][0]["svg"].as_str().expect("svg");
let text: String = svg
.split('>')
.filter_map(|piece| piece.split('<').next())
.collect::<String>()
.split_whitespace()
.collect();
assert!(text.contains("IntroductionandSection1"), "{text}");
assert!(!text.contains("??"), "{text}");
}
#[test]
fn headings_pagestyle_puts_the_number_in_the_header() {
let source = "\\documentclass{article}\n\\pagestyle{headings}\n\\begin{document}\n\nFirst.\n\n\\newpage\n\nSecond.\n\n\\end{document}\n";