Handle cleardoublepage and column switches
\cleardoublepage was unsupported and \onecolumn/\twocolumn leaked into the text. The block splitter now treats \cleardoublepage like \newpage/\clearpage (it sets the pending page break) and consumes the two column switches, since the engine lays documents out in a single column. A test alternates the three commands around First/Second/Third, checks at least two pages, all three texts present, and no leaked commands or warnings.
This commit is contained in:
1 parent
c25c38f16a
commit
0a4bc0ade5
4 files changed
+44
-7
No files matched your search
+38
-1
@@ -7649,10 +7649,15 @@ fn paragraphs_with_spacing(
|
||||
pending_break = false;
|
||||
continue;
|
||||
}
|
||||
if chunk == "\\newpage" || chunk == "\\clearpage" {
|
||||
if chunk == "\\newpage" || chunk == "\\clearpage" || chunk == "\\cleardoublepage" {
|
||||
pending_break = true;
|
||||
continue;
|
||||
}
|
||||
if chunk == "\\onecolumn" || chunk == "\\twocolumn" {
|
||||
// The engine lays documents out in one column; the column
|
||||
// switches are consumed without changing the measure.
|
||||
continue;
|
||||
}
|
||||
if let Some(skip) = vertical_skip(chunk) {
|
||||
pending.0 += skip.0;
|
||||
pending.1 += skip.1;
|
||||
@@ -16603,6 +16608,38 @@ A definition.
|
||||
assert!(!svg.contains("numberwithin"), "{svg}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn column_and_double_page_commands_are_handled() {
|
||||
let source = "\\documentclass{article}\n\\begin{document}\n\n\\onecolumn\n\nFirst.\n\n\\cleardoublepage\n\nSecond.\n\n\\twocolumn\n\nThird.\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"]
|
||||
);
|
||||
assert!(value["pageCount"].as_u64().unwrap_or(0) >= 2);
|
||||
let pages = value["pages"].as_array().expect("pages");
|
||||
let mut text = String::new();
|
||||
for page in pages {
|
||||
if let Some(svg) = page["svg"].as_str() {
|
||||
text.push_str(
|
||||
&svg.split('>')
|
||||
.filter_map(|piece| piece.split('<').next())
|
||||
.collect::<String>(),
|
||||
);
|
||||
}
|
||||
}
|
||||
let text: String = text.split_whitespace().collect();
|
||||
assert!(text.contains("First."), "{text}");
|
||||
assert!(text.contains("Second."), "{text}");
|
||||
assert!(text.contains("Third."), "{text}");
|
||||
assert!(!text.contains("onecolumn"), "{text}");
|
||||
assert!(!text.contains("twocolumn"), "{text}");
|
||||
assert!(!text.contains("cleardoublepage"), "{text}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn running_marks_fill_fancy_headers() {
|
||||
let source = "\\documentclass{article}\n\\pagestyle{fancy}\n\\fancyhead[R]{\\rightmark}\n\\markboth{Left title}{Right title}\n\\begin{document}\n\nBody.\n\n\\end{document}\n";
|
||||
|
||||
Reference in new issue
Block a user