1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-08-08 23:03:50 +00:00

Changed link code to generate ordinary <A> tags

This commit is contained in:
Jeremy Ruston 2011-12-06 09:21:45 +00:00
parent e7cda202fb
commit e3b1def010
2 changed files with 15 additions and 14 deletions

View File

@ -437,21 +437,21 @@ WikiTextRules.rules = [
this.lookaheadRegExp.lastIndex = w.matchStart; this.lookaheadRegExp.lastIndex = w.matchStart;
var lookaheadMatch = this.lookaheadRegExp.exec(w.source); var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
if(lookaheadMatch && lookaheadMatch.index == w.matchStart) { if(lookaheadMatch && lookaheadMatch.index == w.matchStart) {
var e; var e = {type: "a", children: []};
var text = lookaheadMatch[1]; var text = lookaheadMatch[1];
if(lookaheadMatch[3]) { if(lookaheadMatch[3]) {
// Pretty bracketted link // Pretty bracketted link
var link = lookaheadMatch[3]; var link = lookaheadMatch[3];
if(!lookaheadMatch[2] && WikiTextRules.isExternalLink(w,link)) {
e = {type: "a", children: []};
} else {
e = {type: "tiddlerLink", children: []};
}
WikiTextRules.setAttr(e,"href",link); WikiTextRules.setAttr(e,"href",link);
if(!lookaheadMatch[2] && WikiTextRules.isExternalLink(w,link)) {
WikiTextRules.setAttr(e,"className","externalLink");
} else {
WikiTextRules.setAttr(e,"className","tiddlyLink");
}
} else { } else {
// Simple bracketted link // Simple bracketted link
e = {type: "tiddlerLink", children: []};
WikiTextRules.setAttr(e,"href",text); WikiTextRules.setAttr(e,"href",text);
WikiTextRules.setAttr(e,"className","tiddlyLink");
} }
w.output.push(e); w.output.push(e);
e.children.push({type: "text", value: text}); e.children.push({type: "text", value: text});
@ -479,8 +479,9 @@ WikiTextRules.rules = [
} }
} }
if(w.autoLinkWikiWords) { if(w.autoLinkWikiWords) {
var link = {type: "tiddlerLink", children: []}; var link = {type: "a", children: []};
WikiTextRules.setAttr(link,"href",w.matchText); WikiTextRules.setAttr(link,"href",w.matchText);
WikiTextRules.setAttr(link,"className","tiddlyLink");
w.output.push(link); w.output.push(link);
w.outputText(link.children,w.matchStart,w.nextMatch); w.outputText(link.children,w.matchStart,w.nextMatch);
} else { } else {

View File

@ -45,9 +45,9 @@ wikiTest({ tiddlers:
children: [ { type: 'text', value: 'text' } ] }, children: [ { type: 'text', value: 'text' } ] },
{ type: 'text', { type: 'text',
value: ' of the first tiddler, with a link to the ' }, value: ' of the first tiddler, with a link to the ' },
{ type: 'tiddlerLink', { type: 'a',
children: [ { type: 'text', value: 'SecondTiddler' } ], children: [ { type: 'text', value: 'SecondTiddler' } ],
attributes: {href: 'SecondTiddler'} }, attributes: {href: 'SecondTiddler', className: 'tiddlyLink' } },
{ type: 'text', value: ', too.' } ] }, { type: 'text', value: ', too.' } ] },
{ tiddler: 'SecondTiddler', { tiddler: 'SecondTiddler',
output: output:
@ -70,13 +70,13 @@ wikiTest({ tiddlers:
{ tiddler: 'ThirdTiddler', { tiddler: 'ThirdTiddler',
output: output:
[ { type: 'text', value: 'An explicit link ' }, [ { type: 'text', value: 'An explicit link ' },
{ type: 'tiddlerLink', { type: 'a',
children: [ { type: 'text', value: 'Fourth Tiddler' } ], children: [ { type: 'text', value: 'Fourth Tiddler' } ],
attributes: { href: 'Fourth Tiddler' } }, attributes: { href: 'Fourth Tiddler', className: 'tiddlyLink' } },
{ type: 'text', value: ' and ' }, { type: 'text', value: ' and ' },
{ type: 'tiddlerLink', { type: 'a',
children: [ { type: 'text', value: 'a pretty link' } ], children: [ { type: 'text', value: 'a pretty link' } ],
attributes: { href: 'Fourth Tiddler' } } ] }, attributes: { href: 'Fourth Tiddler', className: 'tiddlyLink' } } ] },
{ tiddler: 'Fourth Tiddler', { tiddler: 'Fourth Tiddler',
output: output:
[ { type: 'text', value: 'An image ' }, [ { type: 'text', value: 'An image ' },