We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| 1 | <?php |
||
| 43 | class Dewidow_Fix extends Abstract_Node_Fix { |
||
| 44 | const SPACE_BETWEEN = '[\s]+'; // \s includes all special spaces (but not ZWSP) with the u flag. |
||
| 45 | const WIDOW = '[\w\p{M}\-' . U::ZERO_WIDTH_SPACE . U::SOFT_HYPHEN . ']+?'; // \w includes all alphanumeric Unicode characters but not composed characters. |
||
| 46 | |||
| 47 | const REGEX_START = '/ |
||
| 48 | (?: |
||
| 49 | \A |
||
| 50 | | |
||
| 51 | (?: |
||
| 52 | (?<space_before> # subpattern 1: space before (note: ZWSP is not a space) |
||
| 53 | [\s' . U::ZERO_WIDTH_SPACE . U::SOFT_HYPHEN . ']+ |
||
| 54 | ) |
||
| 55 | (?<neighbor> # subpattern 2: neighbors widow (short as possible) |
||
| 56 | [^\s' . U::ZERO_WIDTH_SPACE . U::SOFT_HYPHEN . ']+? |
||
| 57 | ) |
||
| 58 | ) |
||
| 59 | ) |
||
| 60 | (?<space_between> # subpattern 3: space between |
||
| 61 | ' . self::SPACE_BETWEEN . ' |
||
| 62 | ) |
||
| 63 | (?<widow> # subpattern 4: widow |
||
| 64 | ' . self::WIDOW . ' |
||
| 65 | (?: |
||
| 66 | ' . self::SPACE_BETWEEN . self::WIDOW . ' |
||
| 67 | ){0,'; // The maximum number of repetitions is missing. |
||
| 68 | |||
| 69 | const REGEX_END = |
||
| 70 | '}) |
||
| 71 | (?<trailing> # subpattern 5: any trailing punctuation or spaces |
||
| 72 | [^\w\p{M}]* |
||
| 73 | ) |
||
| 74 | \Z |
||
| 75 | /Sxu'; |
||
| 76 | |||
| 77 | const MASKED_NARROW_SPACE = '__NO_BREAK_NARROW_SPACE__'; |
||
| 78 | |||
| 79 | /** |
||
| 80 | * Apply the fix to a given textnode. |
||
| 81 | * |
||
| 82 | * @param \DOMText $textnode Required. |
||
| 83 | * @param Settings $settings Required. |
||
| 84 | * @param bool $is_title Optional. Default false. |
||
| 85 | */ |
||
| 86 | public function apply( \DOMText $textnode, Settings $settings, $is_title = false ) { |
||
| 98 | |||
| 99 | /** |
||
| 100 | * Dewidow a given text fragment. |
||
| 101 | * |
||
| 102 | * @param string $text The text fragment to dewidow. |
||
| 103 | * @param array $func An array of string functions. |
||
| 104 | * @param int $max_pull Maximum number of characters pulled from previous line. |
||
| 105 | * @param int $max_length Maximum widow length. |
||
| 106 | * @param int $word_number Maximum number of words allowed in widow. |
||
| 107 | * @param string $narrow_space The narrow no-break space character. |
||
| 108 | * |
||
| 109 | * @return string |
||
| 110 | */ |
||
| 111 | protected function dewidow( $text, array $func, $max_pull, $max_length, $word_number, $narrow_space ) { |
||
| 142 | |||
| 143 | /** |
||
| 144 | * Strip zero-width space and soft hyphens from the given string. |
||
| 145 | * |
||
| 146 | * @param string $string Required. |
||
| 147 | * |
||
| 148 | * @return string |
||
| 149 | */ |
||
| 150 | protected static function strip_breaking_characters( $string ) { |
||
| 153 | |||
| 154 | /** |
||
| 155 | * Strip zero-width space and soft hyphens from the given string. |
||
| 156 | * |
||
| 157 | * @param string $string Required. |
||
| 158 | * @param string $narrow_space The narrow no-break space character. |
||
| 159 | * |
||
| 160 | * @return string |
||
| 161 | */ |
||
| 162 | protected static function make_space_nonbreaking( $string, $narrow_space ) { |
||
| 175 | } |
||
| 176 |