Skip to content
This repository was archived by the owner on Apr 22, 2020. It is now read-only.

Commit 8984e1d

Browse files
author
mikesamuel@gmail.com
committed
Tweaked newlines
1 parent 363a264 commit 8984e1d

3 files changed

Lines changed: 10 additions & 8 deletions

File tree

js-modules/extractSourceSpans.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ function extractSourceSpans(node) {
7878
if (!isPreformatted) {
7979
text = text.replace(/[ \t\r\n]+/g, ' ');
8080
} else {
81-
text = text.replace(/\r\n?/g, '\n'); // Normalize newlines.
81+
text = text.replace(/\r\n?/g, '\r\n'); // Normalize newlines.
8282
}
8383
// TODO: handle tabs here?
8484
chunks[k] = text;
@@ -93,7 +93,7 @@ function extractSourceSpans(node) {
9393
walk(node);
9494

9595
return {
96-
source: chunks.join('').replace(/\n$/, ''),
96+
source: chunks.join('').replace(/\r\n$/, ''),
9797
spans: spans
9898
};
99-
}
99+
}

js-modules/numberLines.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* Given a DOM subtree, wraps it in a list, and puts each line into its own
33
* list item.
4-
*
4+
*
55
* @param {Node} node modified in place. Its content is pulled into an
66
* HTMLOListElement, and each line is moved into a separate list item.
77
* This requires cloning elements, so the input might not have unique
@@ -88,7 +88,9 @@ function numberLines(node, opt_startLineNum) {
8888
var parent = limit.parentNode;
8989
if (parent) {
9090
// We clone the parent chain.
91-
// This helps us resurrect important
91+
// This helps us resurrect important styling elements that cross lines.
92+
// E.g. in <i>Foo<br>Bar</i>
93+
// should be rewritten to <li><i>Foo</i></li><li><i>Bar</i></li>.
9294
var parentClone = breakLeftOf(parent, 1);
9395
// Move the clone and everything to the right of the original
9496
// onto the cloned parent.

tests/prettify_test.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,7 +1295,7 @@ <h1>Go mode</h1>
12951295
fmt.Printf("Hello, world; or &#x039a;&#x03b1;&#x03bb;&#x03b7;&#x03bc;&#x03ad;&#x03c1;&#x03b1; &#x03ba;&#x03cc;&#x03c3;&#x03bc;&#x03b5;; or &#x3053;&#x3093;&#x306b;&#x3061;&#x306f; &#x4e16;&#x754c;\n") // Semicolon inserted here
12961296
}
12971297

1298-
/* " */ "foo /* " /*/ */
1298+
/* " */ &quot;foo /* " /*/ */
12991299
</pre>
13001300

13011301
Test IE by copy/pasting content here.
@@ -1305,8 +1305,8 @@ <h1>Go mode</h1>
13051305
<script type="text/javascript">
13061306
/**
13071307
* maps ids of rewritten code to the expected output.
1308-
* For brevity, <span class="foo"> has been changed to `FOO and close span tags
1309-
* have been changed to `END.
1308+
* For brevity, <span class="foo"> has been changed to `FOO and </span>
1309+
* has been changed to `END.
13101310
*/
13111311
var goldens = {
13121312
bash: (

0 commit comments

Comments
 (0)