mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-17 15:55:14 +00:00
Merge pull request #1916 from scks1/fix/latex-break-star
craft-latex: a starred line break shows no star
This commit is contained in:
2 files changed
+22
No files matched your search
@@ -167,6 +167,14 @@ impl Lexer<'_> {
|
||||
let m = self.until("\\]");
|
||||
self.out.push(Tok::Math(m, true));
|
||||
}
|
||||
'\\' => {
|
||||
// `\\*` breaks the line as `\\` does; the star only forbids a page
|
||||
// break there.
|
||||
if self.peek() == Some('*') {
|
||||
self.bump();
|
||||
}
|
||||
self.out.push(Tok::Cmd(sym.to_string()));
|
||||
}
|
||||
_ => self.out.push(Tok::Cmd(sym.to_string())),
|
||||
}
|
||||
continue;
|
||||
|
||||
@@ -494,3 +494,17 @@ fn a_tabular_row_keeps_the_cells_a_table_row_holds() {
|
||||
assert_eq!(t.rows.first().map(Vec::len), Some(craft_wordmodel::table::MAX_COLS));
|
||||
assert_eq!(t.rows.get(1).map(Vec::len), Some(2));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_starred_line_break_shows_no_star() {
|
||||
// `\\*` (a line break with no page break after it) left its `*` in the text.
|
||||
for src in ["a\\\\*b", "a\\\\*[3pt]b", "a\\\\b"] {
|
||||
let p = paras(&format!("\\begin{{document}}{src}\\end{{document}}"));
|
||||
assert_eq!(p.len(), 1, "{src}");
|
||||
assert_eq!(p[0].text().replace(['\n', '\u{B}'], "|"), "a|b", "{src}");
|
||||
}
|
||||
let flow = parse("\\begin{document}\\begin{tabular}{ll}a & b \\\\* c & d\\end{tabular}\\end{document}");
|
||||
let Some(FBlock::Table(t)) = flow.blocks.first() else { panic!("{:?}", flow.blocks) };
|
||||
assert_eq!(t.rows.len(), 2, "{t:?}");
|
||||
assert_eq!(t.rows[1].iter().map(|c| c.text().trim().to_string()).collect::<Vec<_>>(), ["c", "d"]);
|
||||
}
|
||||
Reference in new issue
Block a user