Skip to content

Commit

Permalink
Fixed newline problems
Browse files Browse the repository at this point in the history
  • Loading branch information
Denis Olshin committed May 23, 2012
1 parent d77d167 commit 2440972
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion index.htm
Expand Up @@ -119,7 +119,8 @@ <h4>Memory dump:</h4>
$code = $_REQUEST['code'];
}
$code = htmlspecialchars($code);
$code = str_replace(array(" ", "\n"), array("&nbsp;", "<br/>"), $code);
$code = "<div>".str_replace(array(" ", "\n"), array("&nbsp;", "</div><div>"), $code)."</div>";
$code = str_replace("<div></div>", "<div><br/></div>", $code);
echo $code;?></div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion js/ui.js
Expand Up @@ -192,7 +192,7 @@ function pad(v, w) {
}

function getText(e) {
return ge(e).innerHTML.replace(/\n/g, "").replace(/<(?:br|\/div|\/p)>/g, "\n").replace(/<.*?>/g, "").replace(/&nbsp;/g, " ");
return ge(e).innerHTML.replace(/\n/g, "").replace(/(?:<\/div><div>|<\/p><p>|<\/div>|(?!^)<div>|(?!^)<p>)/g, "\n").replace(/<.*?>/g, "").replace(/&nbsp;/g, " ");
}
function htmlEscape(s) {
return s.split(" ").join("&nbsp;").split("<").join("&lt;");
Expand Down

0 comments on commit 2440972

Please sign in to comment.