Links and transclusions in railroad diagrams

This commit is contained in:
Astrid Elocson
2015-01-06 01:39:24 +00:00
parent 71357a8e39
commit 2f42c9fb8d
11 changed files with 233 additions and 76 deletions

View File

@@ -27,18 +27,13 @@ exports.init = function(parser) {
this.matchRegExp = /\[\[(.*?)(?:\|(.*?))?\]\]/mg;
};
var isLinkExternal = function(to) {
var externalRegExp = /(?:file|http|https|mailto|ftp|irc|news|data|skype):[^\s<>{}\[\]`|'"\\^~]+(?:\/|\b)/i;
return externalRegExp.test(to);
};
exports.parse = function() {
// Move past the match
this.parser.pos = this.matchRegExp.lastIndex;
// Process the link
var text = this.match[1],
link = this.match[2] || text;
if(isLinkExternal(link)) {
if($tw.utils.isLinkExternal(link)) {
return [{
type: "element",
tag: "a",