Debian Codegraph @

tests/ie-newline-copy-paste.html

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