Skip to content

fix(utils): keep whitespace of elements nested in <pre> in htmlToText - #4348

Merged
barjin merged 2 commits into
apify:masterfrom
b84330808:fix-html-to-text-nested-pre
Nov 5, 2026
Merged

barjin merged 2 commits into
apify:masterfrom
b84330808:fix-html-to-text-nested-pre

Conversation

@b84330808

Copy link
Copy Markdown

htmlToText only kept whitespace for text nodes whose direct parent is <pre>. Code blocks are usually <pre><code>…</code></pre>, so their indentation and line breaks were collapsed into one line. The "inside <pre>" state is now passed down while walking the tree.

Whitespace was only preserved for text nodes whose direct parent is <pre>,
so <pre><code>...</code></pre>, the usual markup for code blocks, was
collapsed into a single line.
@github-actions github-actions Bot added the t-tooling Issues with this label are in the ownership of the tooling team. label Nov 4, 2026
@janbuchar
janbuchar requested a review from barjin November 4, 2026 16:06

@barjin barjin 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.

Thank you for your contribution @b84330808, lgtm.

I pushed one small commit on top, so code blocks keep their full indentation.

@barjin
barjin enabled auto-merge (squash) November 5, 2026 16:15
@barjin
barjin merged commit b04cf00 into apify:master Nov 5, 2026
18 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

t-tooling Issues with this label are in the ownership of the tooling team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants