forked from googlearchive/code-prettify
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathie-newline-copy-paste.html
More file actions
144 lines (102 loc) · 4.37 KB
/
Copy pathie-newline-copy-paste.html
File metadata and controls
144 lines (102 loc) · 4.37 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<title>IE Newline Copy/Paste Info Gathering</title>
<body>
<p>
I'm trying to squash, <a href="https://github.com/google/code-prettify/issues/20">once</a> and <a href="https://github.com/google/code-prettify/issues/104">for</a> <a href="https://github.com/google/code-prettify/issues/128">all</a>, the problems with newlines in
<tt><PRE></tt>s in IE. I can't run 3 versions of IE, so I'd
really appreciate any help from people who have IE open and running.
</p>
<p>
Please copy from START through END below and paste it into the
textarea below.
Then hit Ctrl-A, Ctrl-C to copy the textarea contents, and paste that
into an email.
Please also copy and paste the RESULTS section below and include it in
the email response as well and send it
to <a href="mailto:mikesamuel@gmail.com">me</a> or respond to the
discussion list.
</p>
<p>
In case you're interested, there are two problems: choosing a way to
split lines that doesn't introduce too few or extra newlines, and a
way to make sure that the resulting code can be copy-pasted into a
plain text editors such as the textarea below. This is my attempt to
gather information on both issues by IE version.
</p>
cheers.
</body>
<script>
function makeCodeJoiningOn(text, htmlNewline, start, end) {
start = start || '';
end = end || '';
var code = document.createElement('PRE');
code.innerHTML = start + ['before', '[' + text + ']', 'after'].join(htmlNewline) + end;
code.id = text.replace('+', 'plus').replace(/[^\w\-_]/g, '_');
document.body.appendChild(code);
}
</script>
<h2>START</h2>
<script>makeCodeJoiningOn('CR', ' \r');</script>
<script>makeCodeJoiningOn('CRLF', ' \r\n');</script>
<script>makeCodeJoiningOn('LFCR', ' \n \r');</script>
<script>makeCodeJoiningOn('LF', ' \n');</script>
<script>makeCodeJoiningOn('VTAB', ' \u000b');</script>
<script>makeCodeJoiningOn('x2028', ' \u2028');</script>
<script>makeCodeJoiningOn('x2029', ' \u2029');</script>
<script>makeCodeJoiningOn('BR', ' <br>');</script>
<script>makeCodeJoiningOn('CR+BR', ' \r<br>');</script>
<script>makeCodeJoiningOn('CRLF+BR', ' \r\n<br>');</script>
<script>makeCodeJoiningOn('LFCR+BR', ' \n\r<br>');</script>
<script>makeCodeJoiningOn('LF+BR', ' \n<br>');</script>
<script>makeCodeJoiningOn('VTAB+BR', ' \u000b<br>');</script>
<script>makeCodeJoiningOn('x2028+BR', ' \u2028<br>');</script>
<script>makeCodeJoiningOn('x2029+BR', ' \u2029<br>');</script>
<script>makeCodeJoiningOn('BR+CR', ' <br>\r');</script>
<script>makeCodeJoiningOn('BR+CRLF', ' <br>\r\n');</script>
<script>makeCodeJoiningOn('BR+LFCR', ' <br>\n\r');</script>
<script>makeCodeJoiningOn('BR+LF', ' <br>\n');</script>
<script>makeCodeJoiningOn('BR+LF', ' <br>\n');</script>
<script>makeCodeJoiningOn('BR+VTAB', ' <br>\u000b');</script>
<script>makeCodeJoiningOn('BR+x2028', ' <br>\u2028');</script>
<script>makeCodeJoiningOn('BR+x2029', ' <br>\u2029');</script>
<script>makeCodeJoiningOn('divs', '</div><div>', '<div>', '<\/div>');</script>
<script>makeCodeJoiningOn('ul', '<li>', '<ul style=list-style:none;padding:0;margin:0><li>', '<\/ul>');</script>
<pre id=notgen-cr>before
[Not generated via innerHTML CR]
after</pre>
<pre id=notgen-br>before<br>[Not generated via innerHTML BR]<br>after</pre>
<pre id=notgen-brcr>before<br>
[Not generated via innerHTML CR + BR]<br>
after</pre>
<pre id=notgen-crbr>before
<br>[Not generated via innerHTML BR + CR]
<br>after</pre>
<h2>END</h2>
<pre id=threelines>one
two
three</pre>
<h2>RESULTS</h2>
<script>(function () {
var threelines = document.getElementById('threelines');
var codeElements = document.getElementsByTagName('PRE');
var threelinesHeight = threelines.offsetHeight;
var ok = [];
var bad = [];
for (var i = 0, n = codeElements.length; i < n; ++i) {
var codeElement = codeElements[i];
if (codeElement !== threelines) {
var codeElementHeight = codeElement.offsetHeight;
(Math.abs(threelinesHeight - codeElementHeight) < 3
? ok : bad).push(codeElement.id + ':' + codeElementHeight);
}
}
function emit(text) {
var p = document.createElement('P');
p.appendChild(document.createTextNode(text));
document.body.appendChild(p);
}
emit(navigator.userAgent);
emit('Ok: ' + ok);
emit('Bad: ' + bad);
})();</script>
<h2>TEXTAREA</h2>
<textarea style="font-size: 50%" cols=40 rows=50></textarea>