1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-23 10:07:19 +00:00

Freelinks plugin: Add support for ignoring case

This commit is contained in:
jeremy@jermolene.com 2020-05-02 14:07:39 +01:00
parent 5eee11beed
commit 1f354a972e
3 changed files with 9 additions and 2 deletions

View File

@ -1,4 +1,8 @@
title: $:/plugins/tiddlywiki/freelinks/macros/view
tags: $:/tags/Macro/View
<$set name="tv-freelinks" value={{$:/config/Freelinks/Enable}}/>
<$set name="tv-freelinks" value={{$:/config/Freelinks/Enable}}>
<$set name="tv-freelinks-ignore-case" value={{$:/config/Freelinks/IgnoreCase}}/>
</$set>

View File

@ -1,3 +1,5 @@
title: $:/plugins/tiddlywiki/freelinks/settings
<$checkbox tiddler="$:/config/Freelinks/Enable" field="text" checked="yes" unchecked="no" default="no"> <$link to="$:/config/Freelinks/Enable">Enable freelinking within tiddler view templates</$link> </$checkbox>
<$checkbox tiddler="$:/config/Freelinks/IgnoreCase" field="text" checked="yes" unchecked="no" default="no"> <$link to="$:/config/Freelinks/IgnoreCase">Ignore case</$link> </$checkbox>

View File

@ -79,9 +79,10 @@ TextNodeWidget.prototype.execute = function() {
reparts.push("(\\b" + $tw.utils.escapeRegExp(title) + "\\b)");
}
});
var ignoreCase = self.getVariable("tv-freelinks-ignore-case",{defaultValue:"no"}).trim() === "yes";
return {
titles: titles,
regexp: new RegExp(reparts.join("|"),"")
regexp: new RegExp(reparts.join("|"),ignoreCase ? "i" : "")
};
});
// Repeatedly linkify