Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOCX reader: do not issue warning for comments with ext. +styles #10572

Merged
merged 4 commits into from
Jan 30, 2025

Conversation

steven-r
Copy link
Contributor

This fixes #10571 by also allowing Div as a block element

This fixes jgm#10571 by also allowing `Div` as a block element
@tarleb
Copy link
Collaborator

tarleb commented Jan 28, 2025

A different approach could be to "flatten" the style divs before checking that the content is safe. I'd assume that there are still cases where we'd want to show this warning even for Div elements.

@steven-r
Copy link
Contributor Author

A different approach could be to "flatten" the style divs before checking that the content is safe. I'd assume that there are still cases where we'd want to show this warning even for Div elements.

Like this?

  let paraOrPlain :: Block -> Bool
      paraOrPlain (Para _)       = True
      paraOrPlain (Plain _)      = True
      paraOrPlain (Div _ nested) = (all paraOrPlain nested)
      paraOrPlain _              = False

paraOrPlain _ = False
paraOrPlain (Para _) = True
paraOrPlain (Plain _) = True
paraOrPlain (Div _ nested) = (all paraOrPlain nested)
Copy link
Owner

Choose a reason for hiding this comment

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

This is the right approach. But you don't need the () around all paraOrPlain nested.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adjusted the style accordingly

@jgm jgm merged commit 3c8ca60 into jgm:main Jan 30, 2025
10 of 13 checks passed
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.

DOCX reader with docx+styles generate warning on commends
3 participants