summaryrefslogtreecommitdiff
path: root/js/lib
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2014-10-31 22:10:45 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2014-10-31 22:10:45 -0700
commit601908591b553b87901bb1122ff4e29d1decd6b1 (patch)
treea69ad063e0e5d0db8b5d99b6389a202188a8f3de /js/lib
parentb14ece9e725175f98011dda8749d046d25b2f2bb (diff)
parent45ca1bc3867a48c75a6c464cf2420e25a8ef74c6 (diff)
Merge branch 'master' into cmake
Diffstat (limited to 'js/lib')
-rw-r--r--js/lib/blocks.js18
1 files changed, 9 insertions, 9 deletions
diff --git a/js/lib/blocks.js b/js/lib/blocks.js
index 109661f..791b74f 100644
--- a/js/lib/blocks.js
+++ b/js/lib/blocks.js
@@ -25,13 +25,13 @@ var detabLine = function(text) {
};
// Attempt to match a regex in string s at offset offset.
-// Return index of match or null.
+// Return index of match or -1.
var matchAt = function(re, s, offset) {
var res = s.slice(offset).match(re);
if (res) {
return offset + res.index;
} else {
- return null;
+ return -1;
}
};
@@ -218,7 +218,7 @@ var incorporateLine = function(ln, line_number) {
container = last_child;
match = matchAt(/[^ ]/, ln, offset);
- if (match === null) {
+ if (match === -1) {
first_nonspace = ln.length;
blank = true;
} else {
@@ -326,10 +326,10 @@ var incorporateLine = function(ln, line_number) {
container.t != 'IndentedCode' &&
container.t != 'HtmlBlock' &&
// this is a little performance optimization:
- matchAt(/^[ #`~*+_=<>0-9-]/,ln,offset) !== null) {
+ matchAt(/^[ #`~*+_=<>0-9-]/,ln,offset) !== -1) {
match = matchAt(/[^ ]/, ln, offset);
- if (match === null) {
+ if (match === -1) {
first_nonspace = ln.length;
blank = true;
} else {
@@ -366,7 +366,7 @@ var incorporateLine = function(ln, line_number) {
container.level = match[0].trim().length; // number of #s
// remove trailing ###s:
container.strings =
- [ln.slice(offset).replace(/(?:(\\#) *#*| *#+) *$/,'$1')];
+ [ln.slice(offset).replace(/^ *#+ *$/, '').replace(/ +#+ *$/,'')];
break;
} else if ((match = ln.slice(first_nonspace).match(/^`{3,}(?!.*`)|^~{3,}(?!.*~)/))) {
@@ -380,7 +380,7 @@ var incorporateLine = function(ln, line_number) {
offset = first_nonspace + fence_length;
break;
- } else if (matchAt(reHtmlBlockOpen, ln, first_nonspace) !== null) {
+ } else if (matchAt(reHtmlBlockOpen, ln, first_nonspace) !== -1) {
// html block
closeUnmatchedBlocks(this);
container = this.addChild('HtmlBlock', line_number, first_nonspace);
@@ -396,7 +396,7 @@ var incorporateLine = function(ln, line_number) {
container.level = match[0][0] === '=' ? 1 : 2;
offset = ln.length;
- } else if (matchAt(reHrule, ln, first_nonspace) !== null) {
+ } else if (matchAt(reHrule, ln, first_nonspace) !== -1) {
// hrule
closeUnmatchedBlocks(this);
container = this.addChild('HorizontalRule', line_number, first_nonspace);
@@ -435,7 +435,7 @@ var incorporateLine = function(ln, line_number) {
// appropriate container.
match = matchAt(/[^ ]/, ln, offset);
- if (match === null) {
+ if (match === -1) {
first_nonspace = ln.length;
blank = true;
} else {