markdown: Disable definition/reference links in marked.

We had disabled reference style links in bugdown, however,
we hadn't disabled them in marked. This commit rectifies
that and adds test cases for the same.

Fixes #11350.
This commit is contained in:
Rohitt Vashishtha 2019-02-04 10:22:13 +00:00 committed by Tim Abbott
parent 9c68a97472
commit 19672241e6
2 changed files with 11 additions and 8 deletions

View File

@ -356,14 +356,7 @@ Lexer.prototype.token = function(src, top, bq) {
}
// def
if ((!bq && top) && (cap = this.rules.def.exec(src))) {
src = src.substring(cap[0].length);
this.tokens.links[cap[1].toLowerCase()] = {
href: cap[2],
title: cap[3]
};
continue;
}
// We disable definition style links in Zulip.
// table (gfm)
if (top && (cap = this.rules.table.exec(src))) {

View File

@ -120,6 +120,16 @@
"marked_expected_output": "<p> notcode</p>",
"text_content": "notcode"
},
{
"name": "reference_links_disabled",
"input": "Hello [world]\n\n[world]: https://google.com",
"expected_output": "<p>Hello [world]</p>\n<p>[world]: <a href=\"https://google.com\" target=\"_blank\" title=\"https://google.com\">https://google.com</a></p>"
},
{
"name": "reference_links_disabled_2",
"input": "Hello [world][ref-name]\n\n[ref-name]: https://google.com",
"expected_output": "<p>Hello [world][ref-name]</p>\n<p>[ref-name]: <a href=\"https://google.com\" target=\"_blank\" title=\"https://google.com\">https://google.com</a></p>"
},
{
"name": "ulist_standard",
"input": "Some text with a list:\n\n* One item\n* Two items\n* Three items",