1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-12-24 00:50:28 +00:00

Removed detection of external vs. internal links

This should be deferred until at least rendering, and possibly until
the runtime navigation handler
This commit is contained in:
Jeremy Ruston 2011-12-08 13:16:07 +00:00
parent be52fbb5d1
commit 3bef25194c
3 changed files with 5 additions and 33 deletions

View File

@ -111,20 +111,6 @@ WikiTextRules.enclosedTextHelper = function(w) {
}
};
WikiTextRules.isExternalLink = function(w,link) {
var urlRegExp = new RegExp(textPrimitives.urlPattern,"mg");
if(urlRegExp.exec(link)) {
// Definitely an external link
return true;
}
if(link.indexOf(".")!=-1 || link.indexOf("\\")!=-1 || link.indexOf("/")!=-1 || link.indexOf("#")!=-1) {
// Link contains . / \ or # so is probably an external link
return true;
}
// Otherwise assume it is not an external link
return false;
};
WikiTextRules.rules = [
{
name: "table",
@ -445,15 +431,9 @@ WikiTextRules.rules = [
// Pretty bracketted link
var link = lookaheadMatch[3];
WikiTextRules.setAttr(e,"href",link);
if(!lookaheadMatch[2] && WikiTextRules.isExternalLink(w,link)) {
WikiTextRules.setAttr(e,"className","externalLink");
} else {
WikiTextRules.setAttr(e,"className","tiddlyLink");
}
} else {
// Simple bracketted link
WikiTextRules.setAttr(e,"href",text);
WikiTextRules.setAttr(e,"className","tiddlyLink");
}
w.output.push(e);
e.children.push({type: "text", value: text});
@ -483,7 +463,6 @@ WikiTextRules.rules = [
if(w.autoLinkWikiWords) {
var link = {type: "a", children: []};
WikiTextRules.setAttr(link,"href",w.matchText);
WikiTextRules.setAttr(link,"className","tiddlyLink");
w.output.push(link);
w.outputText(link.children,w.matchStart,w.nextMatch);
} else {
@ -516,18 +495,11 @@ WikiTextRules.rules = [
if(lookaheadMatch && lookaheadMatch.index == w.matchStart) {
var e = w.output;
if(lookaheadMatch[5]) {
var link = lookaheadMatch[5],t;
if(WikiTextRules.isExternalLink(w,link)) {
var link = lookaheadMatch[5],
t = {type: "a", children: []};
w.output.push(t);
e = t.children;
} else {
t = {type: "tiddlerLink", children: []};
w.output.push(t);
e = t.children;
}
WikiTextRules.setAttr(t,"href",link);
WikiTextRules.setAttr(t,"className","imageLink");
w.output.push(t);
e = t.children;
}
var img = {type: "img"};
e.push(img);

View File

@ -1 +1 @@
This is the <strong>text</strong> of the first tiddler, with a <span style="font-size:8em;color:red;">link</span> to the <a href="SecondTiddler" className="tiddlyLink">SecondTiddler</a>, too.
This is the <strong>text</strong> of the first tiddler, with a <span style="font-size:8em;color:red;">link</span> to the <a href="SecondTiddler">SecondTiddler</a>, too.

View File

@ -1 +1 @@
An explicit link <a href="Fourth Tiddler" className="tiddlyLink">Fourth Tiddler</a> and <a href="Fourth Tiddler" className="tiddlyLink">a pretty link</a>
An explicit link <a href="Fourth Tiddler">Fourth Tiddler</a> and <a href="Fourth Tiddler">a pretty link</a>