• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Yoast / wordpress-seo / eae09a5317839fc74ea9f16ed4e805d121db50bc

12 Jan 2026 12:44PM UTC coverage: 53.301% (-0.01%) from 53.315%
eae09a5317839fc74ea9f16ed4e805d121db50bc

Pull #22877

github

web-flow
Merge 58047efaf into 3d1950c99
Pull Request #22877: Convert RichText content to HTML string before rendering

8774 of 16284 branches covered (53.88%)

Branch coverage included in aggregate %.

0 of 9 new or added lines in 1 file covered. (0.0%)

131 existing lines in 3 files now uncovered.

32856 of 61819 relevant lines covered (53.15%)

46643.19 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/packages/js/src/structured-data-blocks/how-to/utils/convertToHTMLString.js
1
import { toHTMLString } from "@wordpress/rich-text";
2
import { renderToString } from "@wordpress/element";
3

NEW
4
export const convertToHTMLString = ( contents ) => {
×
NEW
5
        if ( ! Array.isArray( contents ) ) {
×
NEW
6
                return contents;
×
7
        }
NEW
8
        return contents.map( ( item ) => {
×
NEW
9
                if ( typeof item === "string" ) {
×
NEW
10
                        return item;
×
11
                }
12
                // Use renderToString for the image elements.
NEW
13
                if ( item && item.type === "img" && item.props ) {
×
NEW
14
                        return renderToString( item );
×
15
                }
16
                // Otherwise, assume it's a RichText format object (which handles br, etc.)
NEW
17
                return toHTMLString( item );
×
18
        } ).join( "" );
19
};
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc