Skip to content

Commit 4d5cfc7

Browse files
committed
address review comments: relocate rtrim
1 parent 29be5f5 commit 4d5cfc7

File tree

1 file changed

+35
-34
lines changed

1 file changed

+35
-34
lines changed

lib/marked.js

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4,47 +4,15 @@
44
* https://github.com/markedjs/marked
55
*/
66

7-
var NEW_TEXT = true;
7+
var NEW_TEXT = false;
88

9-
var doLog = true;
9+
var doLog = false;
1010
function log(msg) {
1111
if (doLog) {
1212
console.log(msg);
1313
}
1414
}
1515

16-
// Return str with all trailing {c | all but c} removed
17-
// allButC: Default false
18-
function rtrim(str, c, allButC) {
19-
if (typeof allButC === 'undefined') {
20-
allButC = false;
21-
} else {
22-
allButC = true;
23-
}
24-
var mustMatchC = !allButC;
25-
26-
if (str.length === 0) {
27-
return '';
28-
}
29-
30-
// ix+1 of leftmost that fits description
31-
// i.e. the length of the string we should return
32-
var curr = str.length;
33-
34-
while (curr > 0) {
35-
var currChar = str.charAt(curr - 1);
36-
if (mustMatchC && currChar === c) {
37-
curr--;
38-
} else if (!mustMatchC && currChar !== c) {
39-
curr--;
40-
} else {
41-
break;
42-
}
43-
}
44-
45-
return str.substr(0, curr);
46-
}
47-
4816
;(function(root) {
4917
'use strict';
5018

@@ -1390,6 +1358,39 @@ function splitCells(tableRow) {
13901358
return cells;
13911359
}
13921360

1361+
// Return str with all trailing {c | all but c} removed
1362+
// allButC: Default false
1363+
function rtrim(str, c, allButC) {
1364+
if (typeof allButC === 'undefined') {
1365+
allButC = false;
1366+
} else {
1367+
allButC = true;
1368+
}
1369+
var mustMatchC = !allButC;
1370+
1371+
if (str.length === 0) {
1372+
return '';
1373+
}
1374+
1375+
// ix+1 of leftmost that fits description
1376+
// i.e. the length of the string we should return
1377+
var curr = str.length;
1378+
1379+
while (curr > 0) {
1380+
var currChar = str.charAt(curr - 1);
1381+
if (mustMatchC && currChar === c) {
1382+
curr--;
1383+
} else if (!mustMatchC && currChar !== c) {
1384+
curr--;
1385+
} else {
1386+
break;
1387+
}
1388+
}
1389+
1390+
return str.substr(0, curr);
1391+
}
1392+
1393+
13931394
/**
13941395
* Marked
13951396
*/

0 commit comments

Comments
 (0)