Skip to content

fix: preserve align attribute on block elements during sanitization#24

Merged
developer0hye merged 1 commit into
mainfrom
fix/align-center
Mar 11, 2026
Merged

fix: preserve align attribute on block elements during sanitization#24
developer0hye merged 1 commit into
mainfrom
fix/align-center

Conversation

@developer0hye

Copy link
Copy Markdown
Owner

Summary

  • <p align="center">, <h1 align="center"> etc. were losing their align attribute during HTML sanitization
  • The align attribute was only whitelisted for <img> tags, but GitHub READMEs commonly use it on <p>, <h1>, <div> for center-aligned headers (e.g., mermaid-js/mermaid)
  • Promoted align from img-specific to a generic attribute so it's preserved on all safe tags

Test plan

  • Added preserves_align_attribute_on_block_elements test with fixture using <p align="center"> and <h1 align="center">
  • All existing tests pass

The align attribute was only allowed on <img> tags, causing
<p align="center"> and <h1 align="center"> patterns (common in
GitHub READMEs like mermaid-js/mermaid) to lose center alignment
when converted with MarkNest. Promote align to a generic attribute
so it is preserved on all safe tags.

Signed-off-by: Yonghye Kwon <developer.0hye@gmail.com>
@developer0hye developer0hye merged commit a42e47a into main Mar 11, 2026
2 checks passed
@developer0hye developer0hye deleted the fix/align-center branch March 11, 2026 12:52
@developer0hye developer0hye mentioned this pull request Mar 11, 2026
2 tasks
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