Skip to content

write_html: do not render the content of <style> and <script>, like b… - #2044

Merged
andersonhc merged 2 commits into
py-pdf:masterfrom
RavSinghChandan:html-skip-style-script
Oct 21, 2026
Merged

andersonhc merged 2 commits into
py-pdf:masterfrom
RavSinghChandan:html-skip-style-script

Conversation

@RavSinghChandan

Copy link
Copy Markdown

write_html() wrote the content of <style> and <script> elements into the PDF as text. An HTML page or email with a <style> block in its head came out with the CSS printed at the top of the document, for example p { color: red; } followed by the actual text. Browsers never display these elements.

The parser now skips their content, the same way it already skips <title> text unless render_title_tag=True. Inline style attributes are not affected. Added a test comparing documents with <style> / <script> blocks against the same document without them.

@andersonhc
andersonhc merged commit e367fdd into py-pdf:master Oct 21, 2026
23 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.

2 participants