From 9694713e35b27f39a4914f8b2804add9022ba27a Mon Sep 17 00:00:00 2001 From: Maboroshy Date: Wed, 4 Oct 2017 21:55:16 +0300 Subject: [PATCH 1/4] Added tag marker setting and multi-word tags --- in-note-text-tagging/in-note-text-tagging.qml | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/in-note-text-tagging/in-note-text-tagging.qml b/in-note-text-tagging/in-note-text-tagging.qml index aea30e9..3c8f0ff 100644 --- a/in-note-text-tagging/in-note-text-tagging.qml +++ b/in-note-text-tagging/in-note-text-tagging.qml @@ -4,8 +4,21 @@ import QOwnNotesTypes 1.0 /** * This script handles tagging in a note for tags in the note text like: * @tag1 @tag2 @tag3 + * @tag_one would tag the note with "tag one" tag. */ Script { + property string tagMarker + + property variant settingsVariables: [ + { + "identifier": "tagMarker", + "name": "Tag word marker", + "description": "A word that starts with this characters is recognized as tag\n", + "type": "string", + "default": "@", + } + ] + /** * Handles note tagging for a note * @@ -20,7 +33,7 @@ Script { */ function noteTaggingHook(note, action, tagName, newTagName) { var noteText = note.noteText; - var tagRegExp = RegExp("\\B@" + escapeRegExp(tagName) + "\\b"); + var tagRegExp = RegExp("\\B%1($|\\s|\\b)".arg(escapeRegExp(tagMarker + tagName).replace(" ", "_"))); switch (action) { // adds the tag "tagName" to the note @@ -33,7 +46,7 @@ Script { } // add the tag at the end of the note - noteText += "\n@" + tagName; + noteText += "\n" + tagMarker + tagName.replace(" ", "_"); return noteText; break; @@ -49,17 +62,17 @@ 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 = noteText.replace(tagRegExp, "@" + newTagName); + noteText.replace(tagRegExp, tagMarker + newTagName.replace(" ", "_")); return noteText; break; // returns a list of all tag names of the note case "list": - var re = new RegExp("\\B@([^\\s,]+)", "gi"), + var re = new RegExp("\\B%1([^\\s,;]+)".arg(escapeRegExp(tagMarker)), "gi"), result, tagNameList = []; while ((result = re.exec(noteText)) !== null) { - var tagName = result[1]; + var tagName = result[1].replace("_", " "); // add the tag if it wasn't in the list if (tagNameList.indexOf(tagName) == -1) { From 9a1f96bfa89f1a241a49189e976af15b11cb377f Mon Sep 17 00:00:00 2001 From: Maboroshy Date: Wed, 4 Oct 2017 22:22:11 +0300 Subject: [PATCH 2/4] Bumped up version and decribed new features --- in-note-text-tagging/info.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/in-note-text-tagging/info.json b/in-note-text-tagging/info.json index 88a5995..1955983 100644 --- a/in-note-text-tagging/info.json +++ b/in-note-text-tagging/info.json @@ -4,7 +4,7 @@ "script": "in-note-text-tagging.qml", "authors": ["@pbek"], "platforms": ["linux", "macos", "windows"], - "version": "0.0.1", + "version": "0.0.2", "minAppVersion": "17.09.9", - "description" : "With this script you can store your tags in your note-text. Use tags like @tag inside your note-text to tag your notes.\n\nYou also are able to use the functionality of the QOwnNotes user-interface to tag with this tags inside your note texts, like for adding a tag to the current note as well as bulk operations for adding and removing tags to your note. If you rename a tag inside QOwnNotes the text-tags in your notes are also updated.\n\nYou can also use this script as template for implementing your own, unique tagging mechanism.\n\nIf you install this script you will loose all links between notes and tags and instead your in-note tags will be used!\n\nThis functionality is still experimental!\nPlease report your experiences." + "description" : "With this script you can store your tags in your note-text. Use tags like @tag or @tag_one for 'tag one' inside your note-text to tag your notes. You can change '@' to something else in script settings\n\nYou also are able to use the functionality of the QOwnNotes user-interface to tag with this tags inside your note texts, like for adding a tag to the current note as well as bulk operations for adding and removing tags to your note. If you rename a tag inside QOwnNotes the text-tags in your notes are also updated.\n\nYou can also use this script as template for implementing your own, unique tagging mechanism.\n\nIf you install this script you will loose all links between notes and tags and instead your in-note tags will be used!\n\nThis functionality is still experimental!\nPlease report your experiences." } From f36ccbcbe5ddd3f208348e70c3c7945e98b4c34c Mon Sep 17 00:00:00 2001 From: Maboroshy Date: Wed, 4 Oct 2017 22:23:10 +0300 Subject: [PATCH 3/4] Added tag marker setting and multi-word tags --- in-note-text-tagging/in-note-text-tagging.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/in-note-text-tagging/in-note-text-tagging.qml b/in-note-text-tagging/in-note-text-tagging.qml index 3c8f0ff..566161a 100644 --- a/in-note-text-tagging/in-note-text-tagging.qml +++ b/in-note-text-tagging/in-note-text-tagging.qml @@ -13,7 +13,7 @@ Script { { "identifier": "tagMarker", "name": "Tag word marker", - "description": "A word that starts with this characters is recognized as tag\n", + "description": "A word that starts with this characters is recognized as tag", "type": "string", "default": "@", } From 408e43ea8ce67021af16e48d2bc4fd5986550ee8 Mon Sep 17 00:00:00 2001 From: Maboroshy Date: Wed, 4 Oct 2017 22:25:45 +0300 Subject: [PATCH 4/4] Bumped up version and decribed new features --- in-note-text-tagging/info.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/in-note-text-tagging/info.json b/in-note-text-tagging/info.json index 1955983..788a9a6 100644 --- a/in-note-text-tagging/info.json +++ b/in-note-text-tagging/info.json @@ -6,5 +6,5 @@ "platforms": ["linux", "macos", "windows"], "version": "0.0.2", "minAppVersion": "17.09.9", - "description" : "With this script you can store your tags in your note-text. Use tags like @tag or @tag_one for 'tag one' inside your note-text to tag your notes. You can change '@' to something else in script settings\n\nYou also are able to use the functionality of the QOwnNotes user-interface to tag with this tags inside your note texts, like for adding a tag to the current note as well as bulk operations for adding and removing tags to your note. If you rename a tag inside QOwnNotes the text-tags in your notes are also updated.\n\nYou can also use this script as template for implementing your own, unique tagging mechanism.\n\nIf you install this script you will loose all links between notes and tags and instead your in-note tags will be used!\n\nThis functionality is still experimental!\nPlease report your experiences." + "description" : "With this script you can store your tags in your note-text. Use tags like @tag or @tag_one for 'tag one' inside your note-text to tag your notes. You can change '@' to something else in script settings.\n\nYou also are able to use the functionality of the QOwnNotes user-interface to tag with this tags inside your note texts, like for adding a tag to the current note as well as bulk operations for adding and removing tags to your note. If you rename a tag inside QOwnNotes the text-tags in your notes are also updated.\n\nYou can also use this script as template for implementing your own, unique tagging mechanism.\n\nIf you install this script you will loose all links between notes and tags and instead your in-note tags will be used!\n\nThis functionality is still experimental!\nPlease report your experiences." }