Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions __tests__/simple-markdown-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,19 @@ describe("simple markdown", function() {
]);
});

it("should allow one level of balanced parens in link urls", function() {
var parsed = inlineParse("[link]((foo)and(bar))");
validateParse(parsed, [{
type: "link",
content: [{
"content": "link",
"type": "text"
}],
target: "(foo)and(bar)",
title: undefined
}]);
})

it("should parse basic <autolinks>", function() {
var parsed = inlineParse("<http://www.google.com>");
validateParse(parsed, [{
Expand Down
2 changes: 1 addition & 1 deletion simple-markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ var TABLES = (function() {

var LINK_INSIDE = "(?:\\[[^\\]]*\\]|[^\\[\\]]|\\](?=[^\\[]*\\]))*";
var LINK_HREF_AND_TITLE =
"\\s*<?((?:[^\\s\\\\]|\\\\.)*?)>?(?:\\s+['\"]([\\s\\S]*?)['\"])?\\s*";
"\\s*<?((?:\\([^)]*\\)|[^\\s\\\\]|\\\\.)*?)>?(?:\\s+['\"]([\\s\\S]*?)['\"])?\\s*";
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two minor things I think this might not handle yet are:

  1. It allows unescaped opening quotes in the match, which results in confusing matches, such as: [link](http://example.com/test((hi)) rendering to <a href="http://example.com/test((hi)">link</a>.

    • I think we might be able to just add ( to the list of forbidden characters in the parenthesis capture like \\([^()]*\\) to avoid this.
  2. Escaping the closing ), like: [link](http://example.com/test(hi\)). It's... pretty unlikely that anyone really needs that 😄, but we do support it in other places.

    • I think something like: \\((?:[^)\\\\]|\\\\.)*\\) instead of \\([^)]*\\) might let that work (see how the later block uses [^\\s\\\\]|\\\\. to do the same thing).

var AUTOLINK_MAILTO_CHECK_R = /mailto:/i;

var parseRef = function(capture, state, refNode /* : RefNode */) {
Expand Down