WP_Text_Diff_Renderer_inline
Inline diff renderer with improved word splitting for multilingual support.
Source: wp-includes/class-wp-text-diff-renderer-inline.php
Since: 2.6.0 (class), 4.7.0 (separate file)
Extends: Text_Diff_Renderer_inline
Purpose
This class improves upon the PEAR Text_Diff_Renderer_inline by providing better word splitting that handles Unicode characters properly. It’s used internally by WP_Text_Diff_Renderer_Table to generate word-level diffs within changed lines.
Properties
Uses #[AllowDynamicProperties] attribute for PHP 8.2+ compatibility.
Methods
_splitOnWords()
Splits a string into an array of words and delimiters for comparison.
public function _splitOnWords( string $string, string $newlineEscape = "n" ): array
| Parameter | Type | Default | Description |
|---|---|---|---|
$string |
string | — | Text to split into words |
$newlineEscape |
string | "n" |
Replacement for newline characters |
Returns: Array of words and delimiter characters.
Improvements Over PEAR
The parent PEAR class uses a simpler word-splitting regex that may not handle Unicode properly. WordPress’s version:
- Removes null bytes — Strips