kopia lustrzana https://github.com/miklobit/TiddlyWiki5
Added ability to suppress external links
rodzic
9ab9c9cc42
commit
e85ae59fd8
|
@ -3,7 +3,9 @@ title: $:/core/modules/parsers/newwikitextparser/rules/extlink.js
|
|||
type: application/javascript
|
||||
module-type: wikitextrule
|
||||
|
||||
Wiki text run rule for external links
|
||||
Wiki text run rule for external links.
|
||||
|
||||
External links can be suppressed by preceding them with `~`.
|
||||
|
||||
\*/
|
||||
(function(){
|
||||
|
@ -16,17 +18,23 @@ exports.name = "extlink";
|
|||
|
||||
exports.runParser = true;
|
||||
|
||||
exports.regExpString = "(?:file|http|https|mailto|ftp|irc|news|data):[^\\s'\"]+(?:/|\\b)";
|
||||
var unWikiLink = "~";
|
||||
|
||||
exports.regExpString = unWikiLink + "?(?:file|http|https|mailto|ftp|irc|news|data):[^\\s'\"]+(?:/|\\b)";
|
||||
|
||||
exports.parse = function(match,isBlock) {
|
||||
this.pos = match.index + match[0].length;
|
||||
var macroNode = $tw.Tree.Macro("link",{
|
||||
srcParams: {to: match[0]},
|
||||
content: [$tw.Tree.Text(match[0])],
|
||||
wiki: this.wiki
|
||||
});
|
||||
this.dependencies.mergeDependencies(macroNode.dependencies);
|
||||
return [macroNode];
|
||||
if(match[0].substr(0,1) === unWikiLink) {
|
||||
return [$tw.Tree.Text(match[0].substr(1))];
|
||||
} else {
|
||||
var macroNode = $tw.Tree.Macro("link",{
|
||||
srcParams: {to: match[0]},
|
||||
content: [$tw.Tree.Text(match[0])],
|
||||
wiki: this.wiki
|
||||
});
|
||||
this.dependencies.mergeDependencies(macroNode.dependencies);
|
||||
return [macroNode];
|
||||
}
|
||||
};
|
||||
|
||||
})();
|
||||
|
|
|
@ -7,6 +7,8 @@ HelloThere
|
|||
|
||||
One two three four. With a link to HelloThere. And a link to TiddlyWiki and TiddlyWiki5. And a suppressed link to ~HelloThere. And now a [[pretty link|HelloThere]] and another pretty link: [[Introduction]].
|
||||
|
||||
Here's an http link: http://www.google.com/, and a suppressed link: ~http://www.apple.com/.
|
||||
|
||||
Here's a paragraph with an embedded macro <<image "Motovun Jack.jpg">> and that was it.
|
||||
|
||||
{{{
|
||||
|
|
Ładowanie…
Reference in New Issue