diff --git a/test/fix.js b/test/fix.js index 1988736d..5cc0036a 100644 --- a/test/fix.js +++ b/test/fix.js @@ -60,14 +60,3 @@ fs.readdirSync(dir).forEach(function(file) { fs.writeFileSync(file, html); })(); - -// markdown parses backslashes in a very primitive -// way because it's not a real parser. i cannot -// include this test, because marked parses backslashes -// in a very different way. -(function(ext) { - fs.writeFileSync(dir + '/backslash_escapes.text', - 'hello world \\[how](are you) today'); - fs.writeFileSync(dir + '/backslash_escapes.html', - '
hello world [how](are you) today
'); -})(); diff --git a/test/index.js b/test/index.js index 736f9786..ff7943b8 100644 --- a/test/index.js +++ b/test/index.js @@ -99,13 +99,16 @@ main: main.bench = function(name, func) { if (!files) { load(); - // remove these as they affect the + // change certain tests. to allow // comparison to older benchmark times. fs.readdirSync(__dirname + '/new').forEach(function(name) { if (name.split('.').pop() === 'html') return; if (name === 'main.text') return; delete files[name]; }); + files['backslash_escapes.text'] = { + text: 'hello world \\[how](are you) today' + }; } var start = Date.now() diff --git a/test/tests/backslash_escapes.html b/test/tests/backslash_escapes.html index 271c3084..43458738 100644 --- a/test/tests/backslash_escapes.html +++ b/test/tests/backslash_escapes.html @@ -1 +1,118 @@ -hello world [how](are you) today
\ No newline at end of file +These should all get escaped:
+ +Backslash: \
+ +Backtick: `
+ +Asterisk: *
+ +Underscore: _
+ +Left brace: {
+ +Right brace: }
+ +Left bracket: [
+ +Right bracket: ]
+ +Left paren: (
+ +Right paren: )
+ +Greater-than: >
+ +Hash: #
+ +Period: .
+ +Bang: !
+ +Plus: +
+ +Minus: -
+ +These should not, because they occur within a code block:
+ +Backslash: \\
+
+Backtick: \`
+
+Asterisk: \*
+
+Underscore: \_
+
+Left brace: \{
+
+Right brace: \}
+
+Left bracket: \[
+
+Right bracket: \]
+
+Left paren: \(
+
+Right paren: \)
+
+Greater-than: \>
+
+Hash: \#
+
+Period: \.
+
+Bang: \!
+
+Plus: \+
+
+Minus: \-
+
+
+Nor should these, which occur in code spans:
+ +Backslash: \\
Backtick: \`
Asterisk: \*
Underscore: \_
Left brace: \{
Right brace: \}
Left bracket: \[
Right bracket: \]
Left paren: \(
Right paren: \)
Greater-than: \>
Hash: \#
Period: \.
Bang: \!
Plus: \+
Minus: \-
These should get escaped, even though they're matching pairs for +other Markdown constructs:
+ +*asterisks*
+ +_underscores_
+ +`backticks`
+ +This is a code span with a literal backslash-backtick sequence: \`
This is a tag with unescaped backticks bar.
+ +This is a tag with backslashes bar.
diff --git a/test/tests/backslash_escapes.text b/test/tests/backslash_escapes.text index 27014ea3..5b014cb3 100644 --- a/test/tests/backslash_escapes.text +++ b/test/tests/backslash_escapes.text @@ -1 +1,120 @@ -hello world \[how](are you) today \ No newline at end of file +These should all get escaped: + +Backslash: \\ + +Backtick: \` + +Asterisk: \* + +Underscore: \_ + +Left brace: \{ + +Right brace: \} + +Left bracket: \[ + +Right bracket: \] + +Left paren: \( + +Right paren: \) + +Greater-than: \> + +Hash: \# + +Period: \. + +Bang: \! + +Plus: \+ + +Minus: \- + + + +These should not, because they occur within a code block: + + Backslash: \\ + + Backtick: \` + + Asterisk: \* + + Underscore: \_ + + Left brace: \{ + + Right brace: \} + + Left bracket: \[ + + Right bracket: \] + + Left paren: \( + + Right paren: \) + + Greater-than: \> + + Hash: \# + + Period: \. + + Bang: \! + + Plus: \+ + + Minus: \- + + +Nor should these, which occur in code spans: + +Backslash: `\\` + +Backtick: `` \` `` + +Asterisk: `\*` + +Underscore: `\_` + +Left brace: `\{` + +Right brace: `\}` + +Left bracket: `\[` + +Right bracket: `\]` + +Left paren: `\(` + +Right paren: `\)` + +Greater-than: `\>` + +Hash: `\#` + +Period: `\.` + +Bang: `\!` + +Plus: `\+` + +Minus: `\-` + + +These should get escaped, even though they're matching pairs for +other Markdown constructs: + +\*asterisks\* + +\_underscores\_ + +\`backticks\` + +This is a code span with a literal backslash-backtick sequence: `` \` `` + +This is a tag with unescaped backticks bar. + +This is a tag with backslashes bar.