|
@@ -1,4 +1,4 @@
|
|
|
-;/*! showdown 28-05-2017 */
|
|
|
+;/*! showdown 30-05-2017 */
|
|
|
(function(){
|
|
|
/**
|
|
|
* Created by Tivie on 13-07-2015.
|
|
@@ -1350,17 +1350,16 @@ showdown.subParser('anchors', function (text, options, globals) {
|
|
|
|
|
|
text = globals.converter._dispatch('anchors.before', text, options, globals);
|
|
|
|
|
|
- var writeAnchorTag = function (wholeMatch, m1, m2, m3, m4, m5, m6, m7) {
|
|
|
- if (showdown.helper.isUndefined(m7)) {
|
|
|
- m7 = '';
|
|
|
+ var writeAnchorTag = function (wholeMatch, linkText, linkId, url, m5, m6, title) {
|
|
|
+ if (showdown.helper.isUndefined(title)) {
|
|
|
+ title = '';
|
|
|
}
|
|
|
- wholeMatch = m1;
|
|
|
- var linkText = m2,
|
|
|
- linkId = m3.toLowerCase(),
|
|
|
- url = m4,
|
|
|
- title = m7;
|
|
|
+ linkId = linkId.toLowerCase();
|
|
|
|
|
|
- if (!url) {
|
|
|
+ // Special case for explicit empty url
|
|
|
+ if (wholeMatch.search(/\(<?\s*>? ?(['"].*['"])?\)$/m) > -1) {
|
|
|
+ url = '';
|
|
|
+ } else if (!url) {
|
|
|
if (!linkId) {
|
|
|
// lower-case and turn embedded newlines into spaces
|
|
|
linkId = linkText.toLowerCase().replace(/ ?\n/g, ' ');
|
|
@@ -1373,12 +1372,7 @@ showdown.subParser('anchors', function (text, options, globals) {
|
|
|
title = globals.gTitles[linkId];
|
|
|
}
|
|
|
} else {
|
|
|
- if (wholeMatch.search(/\(\s*\)$/m) > -1) {
|
|
|
- // Special case for explicit empty url
|
|
|
- url = '';
|
|
|
- } else {
|
|
|
- return wholeMatch;
|
|
|
- }
|
|
|
+ return wholeMatch;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1405,16 +1399,21 @@ showdown.subParser('anchors', function (text, options, globals) {
|
|
|
};
|
|
|
|
|
|
// First, handle reference-style links: [link text] [id]
|
|
|
- text = text.replace(/(\[((?:\[[^\]]*]|[^\[\]])*)][ ]?(?:\n[ ]*)?\[(.*?)])()()()()/g, writeAnchorTag);
|
|
|
+ text = text.replace(/\[((?:\[[^\]]*]|[^\[\]])*)] ?(?:\n *)?\[(.*?)]()()()()/g, writeAnchorTag);
|
|
|
|
|
|
// Next, inline-style links: [link text](url "optional title")
|
|
|
- text = text.replace(/(\[((?:\[[^\]]*]|[^\[\]])*)]\([ \t]*()<?(.*?(?:\(.*?\).*?)?)>?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,
|
|
|
+ // cases with crazy urls like ./image/cat1).png
|
|
|
+ text = text.replace(/\[((?:\[[^\]]*]|[^\[\]])*)]()[ \t]*\([ \t]?<([^>]*)>(?:[ \t]*((["'])([^"]*?)\5))?[ \t]?\)/g,
|
|
|
+ writeAnchorTag);
|
|
|
+
|
|
|
+ // normal cases
|
|
|
+ text = text.replace(/\[((?:\[[^\]]*]|[^\[\]])*)]()[ \t]*\([ \t]?<?([\S]+?(?:\([\S]*?\)[\S]*?)?)>?(?:[ \t]*((["'])([^"]*?)\5))?[ \t]?\)/g,
|
|
|
writeAnchorTag);
|
|
|
|
|
|
// handle reference-style shortcuts: [link text]
|
|
|
// These must come last in case you've also got [link test][1]
|
|
|
// or [link test](/foo)
|
|
|
- text = text.replace(/(\[([^\[\]]+)])()()()()()/g, writeAnchorTag);
|
|
|
+ text = text.replace(/\[([^\[\]]+)]()()()()()/g, writeAnchorTag);
|
|
|
|
|
|
// Lastly handle GithubMentions if option is enabled
|
|
|
if (options.ghMentions) {
|
|
@@ -2174,7 +2173,8 @@ showdown.subParser('images', function (text, options, globals) {
|
|
|
|
|
|
text = globals.converter._dispatch('images.before', text, options, globals);
|
|
|
|
|
|
- var inlineRegExp = /!\[(.*?)]\s?\([ \t]*()<?(\S+?)>?(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*(?:(['"])(.*?)\6[ \t]*)?\)/g,
|
|
|
+ var inlineRegExp = /!\[([^\]]*?)][ \t]*()\([ \t]?<?([\S]+?(?:\([\S]*?\)[\S]*?)?)>?(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*(?:(["'])([^"]*?)\6)?[ \t]?\)/g,
|
|
|
+ crazyRegExp = /!\[([^\]]*?)][ \t]*()\([ \t]?<([^>]*)>(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*(?:(?:(["'])([^"]*?)\6))?[ \t]?\)/g,
|
|
|
referenceRegExp = /!\[([^\]]*?)] ?(?:\n *)?\[(.*?)]()()()()()/g,
|
|
|
refShortcutRegExp = /!\[([^\[\]]+)]()()()()()/g;
|
|
|
|
|
@@ -2189,8 +2189,11 @@ showdown.subParser('images', function (text, options, globals) {
|
|
|
if (!title) {
|
|
|
title = '';
|
|
|
}
|
|
|
+ // Special case for explicit empty url
|
|
|
+ if (wholeMatch.search(/\(<?\s*>? ?(['"].*['"])?\)$/m) > -1) {
|
|
|
+ url = '';
|
|
|
|
|
|
- if (url === '' || url === null) {
|
|
|
+ } else if (url === '' || url === null) {
|
|
|
if (linkId === '' || linkId === null) {
|
|
|
// lower-case and turn embedded newlines into spaces
|
|
|
linkId = altText.toLowerCase().replace(/ ?\n/g, ' ');
|
|
@@ -2244,6 +2247,10 @@ showdown.subParser('images', function (text, options, globals) {
|
|
|
text = text.replace(referenceRegExp, writeImageTag);
|
|
|
|
|
|
// Next, handle inline images: 
|
|
|
+ // cases with crazy urls like ./image/cat1).png
|
|
|
+ text = text.replace(crazyRegExp, writeImageTag);
|
|
|
+
|
|
|
+ // normal cases
|
|
|
text = text.replace(inlineRegExp, writeImageTag);
|
|
|
|
|
|
// handle reference-style shortcuts: |[img text]
|