Revert "Make Differential linewrap utf-8 aware"
This shouldn't have landed yet.
This reverts commit e5a036e8c9.
This commit is contained in:
@@ -660,54 +660,36 @@ class DifferentialChangesetParser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
protected function lineWrap($l) {
|
||||||
* Hard-wrap a piece of UTF-8 text with embedded HTML tags and entities.
|
|
||||||
*
|
|
||||||
* @param string An HTML string with tags and entities.
|
|
||||||
* @return string Hard-wrapped string.
|
|
||||||
*/
|
|
||||||
protected function lineWrap($line) {
|
|
||||||
$c = 0;
|
$c = 0;
|
||||||
$break_here = array();
|
$len = strlen($l);
|
||||||
|
$ins = array();
|
||||||
// Convert the UTF-8 string into a list of UTF-8 characters.
|
|
||||||
$vector = phutil_utf8v($line);
|
|
||||||
$len = count($vector);
|
|
||||||
$byte_pos = 0;
|
|
||||||
for ($ii = 0; $ii < $len; ++$ii) {
|
for ($ii = 0; $ii < $len; ++$ii) {
|
||||||
// An ampersand indicates an HTML entity; consume the whole thing (until
|
if ($l[$ii] == '&') {
|
||||||
// ";") but treat it all as one character.
|
|
||||||
if ($vector[$ii] == '&') {
|
|
||||||
do {
|
do {
|
||||||
++$ii;
|
++$ii;
|
||||||
} while ($vector[$ii] != ';');
|
} while ($l[$ii] != ';');
|
||||||
++$c;
|
++$c;
|
||||||
// An "<" indicates an HTML tag, consume the whole thing but don't treat
|
} else if ($l[$ii] == '<') {
|
||||||
// it as a character.
|
|
||||||
} else if ($vector[$ii] == '<') {
|
|
||||||
do {
|
do {
|
||||||
++$ii;
|
++$ii;
|
||||||
} while ($vector[$ii] != '>');
|
} while ($l[$ii] != '>');
|
||||||
} else {
|
} else {
|
||||||
++$c;
|
++$c;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Keep track of where we need to break the string later.
|
|
||||||
if ($c == $this->lineWidth) {
|
if ($c == $this->lineWidth) {
|
||||||
$break_here[$ii] = true;
|
$ins[] = ($ii + 1);
|
||||||
$c = 0;
|
$c = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
while (($pos = array_pop($ins))) {
|
||||||
$result = array();
|
$l = substr_replace(
|
||||||
foreach ($vector as $ii => $char) {
|
$l,
|
||||||
$result[] = $char;
|
"<span class=\"over-the-line\">\xE2\xAC\x85</span><br />",
|
||||||
if (isset($break_here[$ii])) {
|
$pos,
|
||||||
$result[] = "<span class=\"over-the-line\">!</span><br />";
|
0);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return $l;
|
||||||
return implode('', $result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user