Changeset 13211 for trunk/wp-includes/Text/Diff/Renderer/inline.php
- Timestamp:
- 02/19/2010 01:25:26 AM (17 years ago)
- File:
-
- 1 edited
-
trunk/wp-includes/Text/Diff/Renderer/inline.php (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/Text/Diff/Renderer/inline.php
r8581 r13211 3 3 * "Inline" diff renderer. 4 4 * 5 * $Horde: framework/Text_Diff/Diff/Renderer/inline.php,v 1.21 2008/01/04 10:07:51 jan Exp $ 6 * 7 * Copyright 2004-2008 The Horde Project (http://www.horde.org/) 5 * Copyright 2004-2010 The Horde Project (http://www.horde.org/) 8 6 * 9 7 * See the enclosed file COPYING for license information (LGPL). If you did … … 31 29 /** 32 30 * Number of leading context "lines" to preserve. 31 * 32 * @var integer 33 33 */ 34 34 var $_leading_context_lines = 10000; … … 36 36 /** 37 37 * Number of trailing context "lines" to preserve. 38 * 39 * @var integer 38 40 */ 39 41 var $_trailing_context_lines = 10000; … … 41 43 /** 42 44 * Prefix for inserted text. 45 * 46 * @var string 43 47 */ 44 48 var $_ins_prefix = '<ins>'; … … 46 50 /** 47 51 * Suffix for inserted text. 52 * 53 * @var string 48 54 */ 49 55 var $_ins_suffix = '</ins>'; … … 51 57 /** 52 58 * Prefix for deleted text. 59 * 60 * @var string 53 61 */ 54 62 var $_del_prefix = '<del>'; … … 56 64 /** 57 65 * Suffix for deleted text. 66 * 67 * @var string 58 68 */ 59 69 var $_del_suffix = '</del>'; … … 61 71 /** 62 72 * Header for each change block. 73 * 74 * @var string 63 75 */ 64 76 var $_block_header = ''; 65 77 66 78 /** 79 * Whether to split down to character-level. 80 * 81 * @var boolean 82 */ 83 var $_split_characters = false; 84 85 /** 67 86 * What are we currently splitting on? Used to recurse to show word-level 68 * changes. 87 * or character-level changes. 88 * 89 * @var string 69 90 */ 70 91 var $_split_level = 'lines'; … … 86 107 } 87 108 88 if ($this->_split_level == 'words') { 109 if ($this->_split_level == 'lines') { 110 return implode("\n", $lines) . "\n"; 111 } else { 89 112 return implode('', $lines); 90 } else {91 return implode("\n", $lines) . "\n";92 113 } 93 114 } … … 111 132 function _changed($orig, $final) 112 133 { 113 /* If we've already split on words, don't try to do so again - just 114 * display. */ 134 /* If we've already split on characters, just display. */ 135 if ($this->_split_level == 'characters') { 136 return $this->_deleted($orig) 137 . $this->_added($final); 138 } 139 140 /* If we've already split on words, just display. */ 115 141 if ($this->_split_level == 'words') { 116 142 $prefix = ''; … … 131 157 $nl = "\0"; 132 158 133 /* We want to split on word boundaries, but we need to 134 * preserve whitespace as well. Therefore we split on words, 135 * but include all blocks of whitespace in the wordlist. */ 136 $diff = new Text_Diff($this->_splitOnWords($text1, $nl), 137 $this->_splitOnWords($text2, $nl)); 159 if ($this->_split_characters) { 160 $diff = new Text_Diff('native', 161 array(preg_split('//', $text1), 162 preg_split('//', $text2))); 163 } else { 164 /* We want to split on word boundaries, but we need to preserve 165 * whitespace as well. Therefore we split on words, but include 166 * all blocks of whitespace in the wordlist. */ 167 $diff = new Text_Diff('native', 168 array($this->_splitOnWords($text1, $nl), 169 $this->_splitOnWords($text2, $nl))); 170 } 138 171 139 172 /* Get the diff in inline format. */ 140 $renderer = new Text_Diff_Renderer_inline(array_merge($this->getParams(), 141 array('split_level' => 'words'))); 173 $renderer = new Text_Diff_Renderer_inline 174 (array_merge($this->getParams(), 175 array('split_level' => $this->_split_characters ? 'characters' : 'words'))); 142 176 143 177 /* Run the diff and get the output. */
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)