You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

34 lines
712 B

  1. <?php
  2. /**
  3. * Diff API: WP_Text_Diff_Renderer_inline class
  4. *
  5. * @package WordPress
  6. * @subpackage Diff
  7. * @since 4.7.0
  8. */
  9. /**
  10. * Better word splitting than the PEAR package provides.
  11. *
  12. * @since 2.6.0
  13. * @uses Text_Diff_Renderer_inline Extends
  14. */
  15. class WP_Text_Diff_Renderer_inline extends Text_Diff_Renderer_inline {
  16. /**
  17. * @ignore
  18. * @since 2.6.0
  19. *
  20. * @param string $string
  21. * @param string $newlineEscape
  22. * @return string
  23. */
  24. public function _splitOnWords($string, $newlineEscape = "\n") {
  25. $string = str_replace("\0", '', $string);
  26. $words = preg_split( '/([^\w])/u', $string, -1, PREG_SPLIT_DELIM_CAPTURE );
  27. $words = str_replace( "\n", $newlineEscape, $words );
  28. return $words;
  29. }
  30. }