Skip to content

Conversation

dchacke
Copy link

@dchacke dchacke commented Sep 23, 2025

I needed a way to ignore attributes because I’m diffing markdown-generated html.

Some markdown libraries assign ids to headings based on content. For example:

# heading

Will generate:

<h1 id="heading">heading</h1>

If a user changes that to # heading foo, they will only care that the content of the heading changed. They won’t care that the id changed to "heading-foo". They won’t even know that such an id even exists, so causing it to display a modification to the entire heading would only confuse the user. They would only want to see the insertion of “foo”.

I did my best to add passing tests but I was unsure about one thing: diff.ts:587, areNodesEqual(previousSibling, formattingNode) did not require the new option, for some reason. All tests already pass without changing it to areNodesEqual(previousSibling, formattingNode, false, ignoreAttributes). I don’t know why. Maybe I’m missing a test case.

@dchacke
Copy link
Author

dchacke commented Sep 23, 2025

Btw, it looks like there are some outdated NPM packages with security vulnerabilities such as this one: https://nvd.nist.gov/vuln/detail/CVE-2023-45311

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.

1 participant