Skip to content

XML minimal diff saving bug with text markup - #9326

Merged
nschneid merged 7 commits into
masterfrom
xml-markup-diff-fix
Jul 29, 2026
Merged

XML minimal diff saving bug with text markup#9326
nschneid merged 7 commits into
masterfrom
xml-markup-diff-fix

Conversation

@nschneid

Copy link
Copy Markdown
Collaborator

closes #9324

This lists the markup fields in TAGS_WITH_MARKUP, which seems to do the trick. I don't fully understand why this matters though...

nschneid added 2 commits July 26, 2026 00:58
… such for XML minimal diff algorithm to work correctly
@codecov

codecov Bot commented Jul 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.89%. Comparing base (5e8c8d6) to head (4d40dd4).
⚠️ Report is 7 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #9326   +/-   ##
=======================================
  Coverage   96.89%   96.89%           
=======================================
  Files          35       35           
  Lines        3702     3704    +2     
=======================================
+ Hits         3587     3589    +2     
  Misses        115      115           
Files with missing lines Coverage Δ
python/acl_anthology/utils/xml.py 96.58% <100.00%> (+0.05%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented Jul 26, 2026

Copy link
Copy Markdown

Build successful. Some useful links:

This preview will be removed when the branch is merged.

@mbollmann mbollmann left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two of the tags don't belong here, the rest must be added, yes.

Comment thread python/acl_anthology/utils/xml.py Outdated
@mbollmann

Copy link
Copy Markdown
Member

Okay, if I remove tex-math from TAGS_WITH_MARKUP, this test fails:

    (
        "<abstract><tex-math>a</tex-math> <b>xxx</b></abstract>",
        "<abstract><tex-math>a</tex-math> xxx</abstract>",
        "<abstract><tex-math>a</tex-math> <b>xxx</b></abstract>",
    ),

Pretty wild to me that this wasn’t caught earlier. In any case, adding this to TAGS_WITH_MARKUP is only accidentally doing the right thing here and shouldn't be correct. I will investigate.

@mbollmann

Copy link
Copy Markdown
Member

I think the solution is to just stop the minimal-diff algorithm from recursing further into markup-containing tags. Strange that (i) this wasn’t how it already worked, and (ii) we haven’t encountered a situation triggering a bug from this earlier.

@nschneid

Copy link
Copy Markdown
Collaborator Author

I was confused by TAGS_WITH_MARKUP as it mixes what are two distinct categories in my mind: (a) markup tag names like "b" and (b) MarkupText-valued publication attributes like "abstract".

It would be great if the list could be limited to category (b) and that was sufficient to block recursing into the MarkupText when computing the minimal diff.

@nschneid

Copy link
Copy Markdown
Collaborator Author

Also worth noting that the list of MarkupText-valued attributes could be extended in the future e.g. for awards (#9101).

@mbollmann

mbollmann commented Jul 26, 2026

Copy link
Copy Markdown
Member

I was confused by TAGS_WITH_MARKUP as it mixes what are two distinct categories in my mind: (a) markup tag names like "b" and (b) MarkupText-valued publication attributes like "abstract".

It would be great if the list could be limited to category (b) and that was sufficient to block recursing into the MarkupText when computing the minimal diff.

It’s not just for the minimal-diff, but also for indentation. I don’t think there is any mixing of categories here: TAGS_WITH_MARKUP lists all the tags which may contain MarkupText according to the RelaxNG schema. It’s a one-to-one correspondence.

@mbollmann

Copy link
Copy Markdown
Member

Incidentally, that’s why tex-math doesn’t belong there: It may appear within a MarkupText block, but it may not itself contain any MarkupText. The semantics of TAGS_WITH_MARKUP is the latter.

@nschneid

Copy link
Copy Markdown
Collaborator Author

How is it used for indentation?

@nschneid

Copy link
Copy Markdown
Collaborator Author

Incidentally, that’s why tex-math doesn’t belong there: It may appear within a MarkupText block, but it may not itself contain any MarkupText. The semantics of TAGS_WITH_MARKUP is the latter.

Then <url> should also be excluded? The schema restricts it to URIs.

@mbollmann

Copy link
Copy Markdown
Member

Then <url> should also be excluded? The schema restricts it to URIs.

Yes, that's what I commented above and why I already removed it again.

@mbollmann

Copy link
Copy Markdown
Member

How is it used for indentation?

From a quick look at the code: Markup-containing tags are not recursed into and will not get indentation after them if they have children. It may be that for this purpose, listing the "high-level" markup tags suffices, but I still contend that the semantics of TAGS_WITH_MARKUP is unambiguous and clearly documented.

@nschneid

Copy link
Copy Markdown
Collaborator Author

@mbollmann What's the next step here?

@mbollmann

Copy link
Copy Markdown
Member

@mbollmann What's the next step here?

Merging. :)

Since I pushed my own changes here I’d find it weird to self-approve, but @mjpost has done this now, so I think we’re good.

@nschneid

Copy link
Copy Markdown
Collaborator Author

Oh, hmm, I want to try some more test cases as I'm not sure:

  • Will recursing be blocked for <url> and <tex-math>?
  • Does <par/> belong in TAGS_WITH_MARKUP? It doesn't contain any text.

@mbollmann

Copy link
Copy Markdown
Member
  • Will recursing be blocked for <url> and <tex-math>?

They can never contain any children, as per the schema, so by their nature they can’t be recursed into.

  • Does <par/> belong in TAGS_WITH_MARKUP? It doesn't contain any text.

Oh, that’s a good point, by the semantics I have given it indeed probably doesn’t belong there.

@nschneid

Copy link
Copy Markdown
Collaborator Author

Also, I just realized that if titles and abstracts aren't being recursed into, then by definition any markup isn't being recursed into.

@nschneid
nschneid requested a review from mbollmann July 28, 2026 23:12
@nschneid

Copy link
Copy Markdown
Collaborator Author

(cannot merge because changes were requested)

@mjpost

mjpost commented Jul 29, 2026

Copy link
Copy Markdown
Member

I assume you addressed his comments? I removed him as a reviewer, not sure why it's blocked

@nschneid

Copy link
Copy Markdown
Collaborator Author

Hmm I had to explicitly dismiss the review. That was confusing

@nschneid
nschneid merged commit 8a76bff into master Jul 29, 2026
17 checks passed
@nschneid
nschneid deleted the xml-markup-diff-fix branch July 29, 2026 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Weird behavior when updating and saving an abstract with changes to markup

3 participants