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

Yoast / wordpress-seo / f573dbc51e254dc6d384cf22bd619f70539e5cb0

12 Jan 2026 02:06PM UTC coverage: 53.171% (-0.1%) from 53.315%
f573dbc51e254dc6d384cf22bd619f70539e5cb0

Pull #22877

github

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

8228 of 14788 branches covered (55.64%)

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.

29662 of 56472 relevant lines covered (52.53%)

51059.56 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