-
Notifications
You must be signed in to change notification settings - Fork 0
/
testing-solution.html
33 lines (30 loc) · 1.08 KB
/
testing-solution.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Testing Solution</title>
<style type="text/css">
body {color: black; background: white;}
.grey {
color: #888;
}
</style>
</head>
<body>
<h1>Testing Solution</h1>
Running <a href="//stackoverflow.com/questions/5007574/rendering-plaintext-as-html-maintaining-whitespace-without-pre/5007620#5007620">this suggestion</a> on this text:
<pre><code>First line\n Second line, indented four spaces\n Three spaces
<span class=grey>123456789•123456789•123456789•123456789•123456789•123456789•123456789•</span></code></pre>
<h3>Result</h3>
<p>Note a space was lost at the beginning of the last line.</p>
<div><code>
<script type="text/javascript">
var text = 'First line\n Second line, indented four spaces\n Three spaces';
text = text.replace(/\t/g, ' ')
.replace(/ /g, ' ')
.replace(/\r\n|\n|\r/g, '<br />');
document.write(text);
</script><br /><span class=grey>123456789•123456789•123456789</span>
</div></code>
</body>
</html>