mirror of
https://github.com/showdownjs/showdown.git
synced 2024-03-22 13:30:55 +08:00
fix reference link impostors
This commit is contained in:
parent
b03e34ae4e
commit
b432da1eee
|
@ -6,14 +6,19 @@
|
|||
showdown.subParser('stripLinkDefinitions', function (text, options, globals) {
|
||||
'use strict';
|
||||
|
||||
var regex = /^ {0,3}\[(.+)]:[ \t]*\n?[ \t]*<?([^>\s]+)>?(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*\n?[ \t]*(?:(\n*)["|'(](.+?)["|')][ \t]*)?(?:\n+|(?=¨0))/gm,
|
||||
base64Regex = /^ {0,3}\[(.+)]:[ \t]*\n?[ \t]*<?(data:.+?\/.+?;base64,[A-Za-z0-9+/=\n]+?)>?(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*\n?[ \t]*(?:(\n*)["|'(](.+?)["|')][ \t]*)?(?:\n\n|(?=¨0)|(?=\n\[))/gm;
|
||||
var regex = /^ {0,3}\[([^\]]+)]:[ \t]*\n?[ \t]*<?([^>\s]+)>?(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*\n?[ \t]*(?:(\n*)["|'(](.+?)["|')][ \t]*)?(?:\n+|(?=¨0))/gm,
|
||||
base64Regex = /^ {0,3}\[([^\]]+)]:[ \t]*\n?[ \t]*<?(data:.+?\/.+?;base64,[A-Za-z0-9+/=\n]+?)>?(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*\n?[ \t]*(?:(\n*)["|'(](.+?)["|')][ \t]*)?(?:\n\n|(?=¨0)|(?=\n\[))/gm;
|
||||
|
||||
// attacklab: sentinel workarounds for lack of \A and \Z, safari\khtml bug
|
||||
text += '¨0';
|
||||
|
||||
var replaceFunc = function (wholeMatch, linkId, url, width, height, blankLines, title) {
|
||||
|
||||
// if there aren't two instances of linkId it must not be a reference link so back out
|
||||
linkId = linkId.toLowerCase();
|
||||
if (text.toLowerCase().split(linkId).length - 1 < 2) {
|
||||
return wholeMatch;
|
||||
}
|
||||
if (url.match(/^data:.+?\/.+?;base64,/)) {
|
||||
// remove newlines
|
||||
globals.gUrls[linkId] = url.replace(/\s/g, '');
|
||||
|
|
3
test/issues/reference-link-impostors.html
Normal file
3
test/issues/reference-link-impostors.html
Normal file
|
@ -0,0 +1,3 @@
|
|||
<p>[We] are going to show [you]: sunshine!</p>
|
||||
<p>[x]: take out the garbage<br />
|
||||
[ ]: bring up the coal</p>
|
4
test/issues/reference-link-impostors.md
Normal file
4
test/issues/reference-link-impostors.md
Normal file
|
@ -0,0 +1,4 @@
|
|||
[We] are going to show [you]: sunshine!
|
||||
|
||||
[x]: take out the garbage
|
||||
[ ]: bring up the coal
|
Loading…
Reference in New Issue
Block a user