Skip to content

Commit

Permalink
em: Allow escaped underscores in em again
Browse files Browse the repository at this point in the history
This was a regression in 0.0.8.

See [this marked.js issue](markedjs/marked#641).

Test plan: `make test`
  • Loading branch information
ariabuckles committed Feb 1, 2016
1 parent 4d68a37 commit 9504ca5
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
35 changes: 35 additions & 0 deletions __tests__/simple-markdown-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,41 @@ describe("simple markdown", function() {
}]);
});

it("should allow escaped underscores in underscore italics", function() {
var parsed1 = inlineParse("_ABC\\_DEF_");
validateParse(parsed1, [{
type: "em",
content: [{
type: "text",
content: "ABC",
}, {
type: "text",
content: "_",
}, {
type: "text",
content: "DEF",
}]
}]);

var parsed2 = inlineParse("_**ABC\\_DEF**_");
validateParse(parsed2, [{
type: "em",
content: [{
type: "strong",
content: [{
type: "text",
content: "ABC",
}, {
type: "text",
content: "_",
}, {
type: "text",
content: "DEF",
}]
}]
}]);
});

// TODO(aria): Make this pass:
it.skip("should parse complex combined bold/italics", function() {
var parsed = inlineParse("***bold** italics*");
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "simple-markdown",
"version": "0.0.8",
"version": "0.0.9",
"description": "Javascript markdown parsing, made simple",
"main": "simple-markdown.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion simple-markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -1189,7 +1189,7 @@ var defaultRules = {
new RegExp(
// only match _s surrounding words.
"^\\b_" +
"((?:__|[^_])+?)_" +
"((?:__|\\\\[\\s\\S]|[^\\_])+?)_" +
"\\b" +
// Or match *s:
"|" +
Expand Down

0 comments on commit 9504ca5

Please sign in to comment.