equal
deleted
inserted
replaced
174 */ |
174 */ |
175 $line = apply_filters( 'process_text_diff_html', $processed_line, $line, 'added' ); |
175 $line = apply_filters( 'process_text_diff_html', $processed_line, $line, 'added' ); |
176 } |
176 } |
177 |
177 |
178 if ( $this->_show_split_view ) { |
178 if ( $this->_show_split_view ) { |
179 $r .= '<tr>' . $this->emptyLine() . $this->emptyLine() . $this->addedLine( $line ) . "</tr>\n"; |
179 $r .= '<tr>' . $this->emptyLine() . $this->addedLine( $line ) . "</tr>\n"; |
180 } else { |
180 } else { |
181 $r .= '<tr>' . $this->addedLine( $line ) . "</tr>\n"; |
181 $r .= '<tr>' . $this->addedLine( $line ) . "</tr>\n"; |
182 } |
182 } |
183 } |
183 } |
184 return $r; |
184 return $r; |
199 |
199 |
200 /** This filter is documented in wp-includes/wp-diff.php */ |
200 /** This filter is documented in wp-includes/wp-diff.php */ |
201 $line = apply_filters( 'process_text_diff_html', $processed_line, $line, 'deleted' ); |
201 $line = apply_filters( 'process_text_diff_html', $processed_line, $line, 'deleted' ); |
202 } |
202 } |
203 if ( $this->_show_split_view ) { |
203 if ( $this->_show_split_view ) { |
204 $r .= '<tr>' . $this->deletedLine( $line ) . $this->emptyLine() . $this->emptyLine() . "</tr>\n"; |
204 $r .= '<tr>' . $this->deletedLine( $line ) . $this->emptyLine() . "</tr>\n"; |
205 } else { |
205 } else { |
206 $r .= '<tr>' . $this->deletedLine( $line ) . "</tr>\n"; |
206 $r .= '<tr>' . $this->deletedLine( $line ) . "</tr>\n"; |
207 } |
207 } |
208 } |
208 } |
209 return $r; |
209 return $r; |
224 |
224 |
225 /** This filter is documented in wp-includes/wp-diff.php */ |
225 /** This filter is documented in wp-includes/wp-diff.php */ |
226 $line = apply_filters( 'process_text_diff_html', $processed_line, $line, 'unchanged' ); |
226 $line = apply_filters( 'process_text_diff_html', $processed_line, $line, 'unchanged' ); |
227 } |
227 } |
228 if ( $this->_show_split_view ) { |
228 if ( $this->_show_split_view ) { |
229 $r .= '<tr>' . $this->contextLine( $line ) . $this->emptyLine() . $this->contextLine( $line ) . "</tr>\n"; |
229 $r .= '<tr>' . $this->contextLine( $line ) . $this->contextLine( $line ) . "</tr>\n"; |
230 } else { |
230 } else { |
231 $r .= '<tr>' . $this->contextLine( $line ) . "</tr>\n"; |
231 $r .= '<tr>' . $this->contextLine( $line ) . "</tr>\n"; |
232 } |
232 } |
233 } |
233 } |
234 return $r; |
234 return $r; |
272 $diff = $renderer->render( $text_diff ); |
272 $diff = $renderer->render( $text_diff ); |
273 |
273 |
274 // If they're too different, don't include any <ins> or <del>'s. |
274 // If they're too different, don't include any <ins> or <del>'s. |
275 if ( preg_match_all( '!(<ins>.*?</ins>|<del>.*?</del>)!', $diff, $diff_matches ) ) { |
275 if ( preg_match_all( '!(<ins>.*?</ins>|<del>.*?</del>)!', $diff, $diff_matches ) ) { |
276 // Length of all text between <ins> or <del>. |
276 // Length of all text between <ins> or <del>. |
277 $stripped_matches = strlen( strip_tags( join( ' ', $diff_matches[0] ) ) ); |
277 $stripped_matches = strlen( strip_tags( implode( ' ', $diff_matches[0] ) ) ); |
278 // Since we count length of text between <ins> or <del> (instead of picking just one), |
278 // Since we count length of text between <ins> or <del> (instead of picking just one), |
279 // we double the length of chars not in those tags. |
279 // we double the length of chars not in those tags. |
280 $stripped_diff = strlen( strip_tags( $diff ) ) * 2 - $stripped_matches; |
280 $stripped_diff = strlen( strip_tags( $diff ) ) * 2 - $stripped_matches; |
281 $diff_ratio = $stripped_matches / $stripped_diff; |
281 $diff_ratio = $stripped_matches / $stripped_diff; |
282 if ( $diff_ratio > $this->_diff_threshold ) { |
282 if ( $diff_ratio > $this->_diff_threshold ) { |
317 $r .= $this->_added( array( $final_line ), false ); |
317 $r .= $this->_added( array( $final_line ), false ); |
318 } elseif ( $final_rows[ $row ] < 0 ) { // Final is blank. This is really a deleted row. |
318 } elseif ( $final_rows[ $row ] < 0 ) { // Final is blank. This is really a deleted row. |
319 $r .= $this->_deleted( array( $orig_line ), false ); |
319 $r .= $this->_deleted( array( $orig_line ), false ); |
320 } else { // A true changed row. |
320 } else { // A true changed row. |
321 if ( $this->_show_split_view ) { |
321 if ( $this->_show_split_view ) { |
322 $r .= '<tr>' . $this->deletedLine( $orig_line ) . $this->emptyLine() . $this->addedLine( $final_line ) . "</tr>\n"; |
322 $r .= '<tr>' . $this->deletedLine( $orig_line ) . $this->addedLine( $final_line ) . "</tr>\n"; |
323 } else { |
323 } else { |
324 $r .= '<tr>' . $this->deletedLine( $orig_line ) . '</tr><tr>' . $this->addedLine( $final_line ) . "</tr>\n"; |
324 $r .= '<tr>' . $this->deletedLine( $orig_line ) . '</tr><tr>' . $this->addedLine( $final_line ) . "</tr>\n"; |
325 } |
325 } |
326 } |
326 } |
327 } |
327 } |