mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-26 19:47:20 +00:00
Get external links working again
We no longer use the `<$link>` widget for external links. Instead the parser generates `<a>` elements. This makes things simpler, but does mean that the `target=_blank` behaviour is baked into the parser. Probably we should introduce a new `<$extlink>` widget that generates an `<a>` element with a configurable `target` attribute
This commit is contained in:
parent
d3df2c5860
commit
632970cd86
@ -2,7 +2,7 @@
|
||||
Contributing to <a class=' tw-tiddlylink tw-tiddlylink-resolves' href='http://five.tiddlywiki.com/static/TiddlyWiki5.html'>
|
||||
TiddlyWiki5</a></h1><p>
|
||||
<a class=' tw-tiddlylink tw-tiddlylink-resolves' href='http://five.tiddlywiki.com/static/TiddlyWiki5.html'>
|
||||
TiddlyWiki5</a> welcomes contributions to its code and documentation via <a class=' tw-tiddlylink tw-tiddlylink-missing' href='http://five.tiddlywiki.com/static/https%3A%2F%2Fgithub.com%2FJermolene%2FTiddlyWiki5.html'>
|
||||
TiddlyWiki5</a> welcomes contributions to its code and documentation via <a href='https://github.com/Jermolene/TiddlyWiki5' target='_blank'>
|
||||
GitHub</a>. Please take a moment to read these notes to help make the process as smooth as possible.</p><h2 class=''>
|
||||
Bug Reports</h2><p>
|
||||
From the perspective of the developers, a bug report that says little more than "it doesn't work" can be frustrating. For effective debugging, we need as much information as possible. At a minimum, please try to include:</p><ul>
|
||||
@ -14,9 +14,9 @@ Expected behaviour</li><li>
|
||||
Context (OS, browser etc.)</li></ul><p>
|
||||
There's a lot of good material on the web about bug reports:</p><ul>
|
||||
<li>
|
||||
<a class=' tw-tiddlylink tw-tiddlylink-missing' href='http://five.tiddlywiki.com/static/http%3A%2F%2Fmhay68.tumblr.com%2Fpost%2F1648223018%2Fwhat-makes-a-good-bug-report.html'>
|
||||
<a href='http://mhay68.tumblr.com/post/1648223018/what-makes-a-good-bug-report' target='_blank'>
|
||||
http://mhay68.tumblr.com/post/1648223018/what-makes-a-good-bug-report</a></li><li>
|
||||
<a class=' tw-tiddlylink tw-tiddlylink-missing' href='http://five.tiddlywiki.com/static/http%3A%2F%2Fwww.chiark.greenend.org.uk%2F~sgtatham%2Fbugs.html.html'>
|
||||
<a href='http://www.chiark.greenend.org.uk/~sgtatham/bugs.html' target='_blank'>
|
||||
http://www.chiark.greenend.org.uk/~sgtatham/bugs.html</a></li></ul><h2 class=''>
|
||||
Pull Requests</h2><p>
|
||||
Like other <a class=' tw-tiddlylink tw-tiddlylink-resolves' href='http://five.tiddlywiki.com/static/OpenSource.html'>
|
||||
@ -26,9 +26,9 @@ ContributorLicenseAgreement</a> from individual contributors before contribution
|
||||
UnaMesa</a> Association (the legal entity that owns <a class=' tw-tiddlylink tw-tiddlylink-resolves' href='http://five.tiddlywiki.com/static/TiddlyWiki.html'>
|
||||
TiddlyWiki</a> on behalf of the community).</p><ul>
|
||||
<li>
|
||||
For individuals use: <a class=' tw-tiddlylink tw-tiddlylink-missing' href='http://five.tiddlywiki.com/static/https%3A%2F%2Fgithub.com%2FJermolene%2FTiddlyWiki5%2Ftree%2Fmaster%2Flicenses%2Fcla-individual.md.html'>
|
||||
For individuals use: <a href='https://github.com/Jermolene/TiddlyWiki5/tree/master/licenses/cla-individual.md' target='_blank'>
|
||||
CLA-individual</a></li><li>
|
||||
For entities use: <a class=' tw-tiddlylink tw-tiddlylink-missing' href='http://five.tiddlywiki.com/static/https%3A%2F%2Fgithub.com%2FJermolene%2FTiddlyWiki5%2Ftree%2Fmaster%2Flicenses%2Fcla-entity.md.html'>
|
||||
For entities use: <a href='https://github.com/Jermolene/TiddlyWiki5/tree/master/licenses/cla-entity.md' target='_blank'>
|
||||
CLA-entity</a></li></ul><p>
|
||||
<em>
|
||||
This is a first pass at a CLA for <a class=' tw-tiddlylink tw-tiddlylink-resolves' href='http://five.tiddlywiki.com/static/TiddlyWiki.html'>
|
||||
@ -49,7 +49,7 @@ Go to your github repo and create a pull request.</strong></p><p>
|
||||
<strong>
|
||||
Thank you!</strong></p><h4 class=''>
|
||||
Attribution</h4><p>
|
||||
The CLA documents used for this project where created using <a class=' tw-tiddlylink tw-tiddlylink-missing' href='http://five.tiddlywiki.com/static/http%3A%2F%2Fwww.harmonyagreements.org.html'>
|
||||
The CLA documents used for this project where created using <a href='http://www.harmonyagreements.org' target='_blank'>
|
||||
Harmony Project Templates</a>. "HA-CLA-I-LIST Version 1.0" for "CLA-individual" and "HA-CLA-E-LIST Version 1.0" for "CLA-entity"
|
||||
</p><p>
|
||||
<em>
|
||||
|
@ -26,7 +26,7 @@ exports.types = {inline: true};
|
||||
exports.init = function(parser) {
|
||||
this.parser = parser;
|
||||
// Regexp to match
|
||||
this.matchRegExp = /~?(?:file|http|https|mailto|ftp|irc|news|data):[^\s'"<>]+(?:\/|\b)/mg;
|
||||
this.matchRegExp = /~?(?:file|http|https|mailto|ftp|irc|news|data|skype):[^\s'"<>]+(?:\/|\b)/mg;
|
||||
};
|
||||
|
||||
exports.parse = function() {
|
||||
@ -38,9 +38,10 @@ exports.parse = function() {
|
||||
} else {
|
||||
return [{
|
||||
type: "element",
|
||||
tag: "$link",
|
||||
tag: "a",
|
||||
attributes: {
|
||||
to: {type: "string", value: this.match[0]}
|
||||
href: {type: "string", value: this.match[0]},
|
||||
target: {type: "string", value: "_blank"}
|
||||
},
|
||||
children: [{
|
||||
type: "text", text: this.match[0]
|
||||
|
@ -27,22 +27,41 @@ 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;
|
||||
return [{
|
||||
type: "element",
|
||||
tag: "$link",
|
||||
attributes: {
|
||||
to: {type: "string", value: link}
|
||||
},
|
||||
children: [{
|
||||
type: "text", text: text
|
||||
}]
|
||||
}];
|
||||
if(isLinkExternal(link)) {
|
||||
return [{
|
||||
type: "element",
|
||||
tag: "a",
|
||||
attributes: {
|
||||
href: {type: "string", value: link},
|
||||
target: {type: "string", value: "_blank"}
|
||||
},
|
||||
children: [{
|
||||
type: "text", text: text
|
||||
}]
|
||||
}];
|
||||
} else {
|
||||
return [{
|
||||
type: "element",
|
||||
tag: "$link",
|
||||
attributes: {
|
||||
to: {type: "string", value: link}
|
||||
},
|
||||
children: [{
|
||||
type: "text", text: text
|
||||
}]
|
||||
}];
|
||||
}
|
||||
};
|
||||
|
||||
})();
|
||||
|
10
readme.md
10
readme.md
@ -10,13 +10,13 @@ node.js application</a>.</p><p>
|
||||
TiddlyWiki5</a> is currently in alpha, meaning it is working but incomplete. It is a great time to get involved and support its <a class=' tw-tiddlylink tw-tiddlylink-resolves' href='http://five.tiddlywiki.com/static/RoadMap.html'>
|
||||
future development</a>:</p><ul>
|
||||
<li>
|
||||
Explore its features online at <a class=' tw-tiddlylink tw-tiddlylink-missing' href='http://five.tiddlywiki.com/static/http%3A%2F%2Ffive.tiddlywiki.com%2F.html'>
|
||||
Explore its features online at <a href='http://five.tiddlywiki.com/' target='_blank'>
|
||||
http://five.tiddlywiki.com/</a></li><li>
|
||||
Join the discussions on <a class=' tw-tiddlylink tw-tiddlylink-missing' href='http://five.tiddlywiki.com/static/http%3A%2F%2Fgroups.google.com%2Fgroup%2FTiddlyWikiDev.html'>
|
||||
Join the discussions on <a href='http://groups.google.com/group/TiddlyWikiDev' target='_blank'>
|
||||
the TiddlyWikiDev Google Group</a></li><li>
|
||||
Get involved in the <a class=' tw-tiddlylink tw-tiddlylink-missing' href='http://five.tiddlywiki.com/static/https%3A%2F%2Fgithub.com%2FJermolene%2FTiddlyWiki5.html'>
|
||||
Get involved in the <a href='https://github.com/Jermolene/TiddlyWiki5' target='_blank'>
|
||||
development on GitHub</a></li><li>
|
||||
Follow <a class=' tw-tiddlylink tw-tiddlylink-missing' href='http://five.tiddlywiki.com/static/http%3A%2F%2Ftwitter.com%2F%23!%2FTiddlyWiki.html'>
|
||||
Follow <a href='http://twitter.com/#!/TiddlyWiki' target='_blank'>
|
||||
@TiddlyWiki on Twitter</a> for the latest news</li></ul><p>
|
||||
<em>
|
||||
<a class=' tw-tiddlylink tw-tiddlylink-resolves' href='http://five.tiddlywiki.com/static/TiddlyWiki.html'>
|
||||
@ -33,7 +33,7 @@ TiddlyWikiFiles</a>. For example, the following command loads the tiddlers from
|
||||
TiddlyWiki</a> HTML file and then saves one of them in HTML:</p><pre>
|
||||
node tiddlywiki.js --verbose --load mywiki.html --rendertiddler ReadMe ./readme.html</pre><p>
|
||||
In order to use <a class=' tw-tiddlylink tw-tiddlylink-resolves' href='http://five.tiddlywiki.com/static/TiddlyWiki5.html'>
|
||||
TiddlyWiki5</a> on the command line you must first install node.js from <a class=' tw-tiddlylink tw-tiddlylink-missing' href='http://five.tiddlywiki.com/static/http%3A%2F%2Fnodejs.org%2F.html'>
|
||||
TiddlyWiki5</a> on the command line you must first install node.js from <a href='http://nodejs.org/' target='_blank'>
|
||||
http://nodejs.org/</a></p><h2 class=''>
|
||||
Usage</h2><p>
|
||||
Running <code>
|
||||
|
Loading…
Reference in New Issue
Block a user