Skip to content

feat(truncatehtml): gate void element preservation behind a feature - #1367

Merged
jasmith-hs merged 1 commit into
masterfrom
jasmith_hubspot/truncatehtml-void-feature-flag
Nov 6, 2026
Merged

jasmith-hs merged 1 commit into
masterfrom
jasmith_hubspot/truncatehtml-void-feature-flag

Conversation

@jasmith-hs

Copy link
Copy Markdown
Contributor

Description

Puts the truncatehtml void element preservation from #1366 behind a new built-in feature, PRESERVE_VOID_IN_TRUNCATE_HTML. The feature is inactive by default, so truncatehtml behaves exactly as it did before #1366 unless a consumer opts in.

  • Inactive (default): every element with blank text is removed, including void elements such as <br>, <img> and <hr>, matching pre-Preserve void elements before the truncation point in truncatehtml #1366 output.
  • Active: void elements before the truncation point are kept, along with blank parents that contain them (e.g. <p><img></p>). Void elements after the truncation point are still removed.

Enable it with:

FeatureConfig.newBuilder()
  .add(BuiltInFeatures.PRESERVE_VOID_IN_TRUNCATE_HTML, FeatureStrategies.ACTIVE)
  .build()

BRAVE

Backwards Compatibility

Rollout and Rollback Plan

  • Consumers enable PRESERVE_VOID_IN_TRUNCATE_HTML through FeatureConfig when ready. A DateTimeFeatureActivationStrategy or a custom strategy can be used for gradual rollout.
  • Rollback: deactivate the feature, or revert this PR.

Automated Testing

Verification

  • Covered by unit tests; no runtime verification beyond that.

Expect Dependencies to Fail

REVIEWERS: Please review both the code changes and the answers above, and validate that they match the expectations for BRAVE

This description was authored by Claude Code.

🤖 Generated with Claude Code

Adds the PRESERVE_VOID_IN_TRUNCATE_HTML built-in feature. When inactive
(the default), truncatehtml removes blank void elements as it did before
#1366. When active, void elements before the truncation point are kept.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@jasmith-hs jasmith-hs self-assigned this Nov 6, 2026
@jasmith-hs
jasmith-hs marked this pull request as ready for review November 6, 2026 20:43
@jasmith-hs
jasmith-hs merged commit 94d47cf into master Nov 6, 2026
10 checks passed
@jasmith-hs
jasmith-hs deleted the jasmith_hubspot/truncatehtml-void-feature-flag branch November 6, 2026 22:16
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