Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,17 @@ fn render_added_or_deleted(block: &Block, tag: DiffTag, out: &mut String) {
)
.unwrap();
}
// A deleted equation must not take a number, or every later number
// shifts by one. The set rule is scoped to the wrapper.
Block::Equation { content, .. } if tag == DiffTag::Deleted => {
write!(
out,
"#{}[#set math.equation(numbering: none)\n{}]",
func,
escape_content(content, escape_refs)
)
.unwrap();
}
// Raw blocks and equations are content-mode; they can be wrapped.
Block::RawBlock { content } | Block::Equation { content, .. } => {
write!(out, "#{}[{}]", func, escape_content(content, escape_refs)).unwrap();
Expand Down
10 changes: 10 additions & 0 deletions tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,3 +209,13 @@ fn test_indented_line_comment_does_not_split_paragraph() {
// A whitespace-only line would be treated as a paragraph break by Typst.
assert!(!output.contains("\n \n"));
}

#[test]
fn test_deleted_equation_takes_no_number() {
let old = "#set math.equation(numbering: \"(1)\")\n\n$ y $\n\n$ z $ <eq-z>\n\nSee @eq-z.\n";
let new = "#set math.equation(numbering: \"(1)\")\n\n$ z $ <eq-z>\n\nSee @eq-z.\n";
let output = run_diff(old, new);

// Numbered, the deleted equation would push `@eq-z` from (1) to (2).
assert!(output.contains("#diff-deleted[#set math.equation(numbering: none)\n$ y $]"));
}