1
0
Fork 0
mirror of https://github.com/marty-oehme/scripts.git synced 2024-12-22 07:58:08 +00:00

Merge pull request #12 from qownnotes/Maboroshy-patch-1

Fixed tags with multiple spaces
This commit is contained in:
Maboroshy 2017-10-05 23:46:44 +04:00 committed by GitHub
commit a7bcd8c660

View file

@ -33,7 +33,7 @@ Script {
*/
function noteTaggingHook(note, action, tagName, newTagName) {
var noteText = note.noteText;
var tagRegExp = RegExp("\\B%1($|\\s|\\b)".arg(escapeRegExp(tagMarker + tagName).replace(" ", "_")));
var tagRegExp = RegExp("\\B%1($|\\s|\\b)".arg(escapeRegExp(tagMarker + tagName).replace(/ /g, "_")));
switch (action) {
// adds the tag "tagName" to the note
@ -46,7 +46,7 @@ Script {
}
// add the tag at the end of the note
noteText += "\n" + tagMarker + tagName.replace(" ", "_");
noteText += "\n" + tagMarker + tagName.replace(/ /g, "_");
return noteText;
break;
@ -62,7 +62,7 @@ Script {
// the new note text has to be returned so that the note can be updated
// returning an empty string indicates that nothing has to be changed
case "rename":
noteText.replace(tagRegExp, tagMarker + newTagName.replace(" ", "_"));
noteText = noteText.replace(tagRegExp, tagMarker + newTagName.replace(/ /g, "_"));
return noteText;
break;
@ -72,7 +72,7 @@ Script {
result, tagNameList = [];
while ((result = re.exec(noteText)) !== null) {
var tagName = result[1].replace("_", " ");
var tagName = result[1].replace(/_/g, " ");
// add the tag if it wasn't in the list
if (tagNameList.indexOf(tagName) == -1) {