mirror of
https://github.com/marty-oehme/scripts.git
synced 2024-12-22 07:58:08 +00:00
Add option to ignore repeated tag markers
When listing tags of a note, this adds the option to only look for tags which contain a single tag marker at the beginning and ignore the others. So if your tag marker is @, and the option is enabled it will display @some_tag as a tag but ignore @@no_tag.
This commit is contained in:
parent
b7af3d9443
commit
f1f52efb68
1 changed files with 12 additions and 1 deletions
|
@ -9,6 +9,7 @@ import QOwnNotesTypes 1.0
|
||||||
|
|
||||||
Script {
|
Script {
|
||||||
property string tagMarker
|
property string tagMarker
|
||||||
|
property bool ignoreDoubleMarkers
|
||||||
property bool putToBeginning
|
property bool putToBeginning
|
||||||
property string tagHighlightColor
|
property string tagHighlightColor
|
||||||
|
|
||||||
|
@ -20,6 +21,13 @@ Script {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"default": "@",
|
"default": "@",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"identifier": "ignoreDoubleMarkers",
|
||||||
|
"name": "Ignore repeated tag markers",
|
||||||
|
"description": "If enabled tags preceded by the same marker multiple times (such as @@no_tag) will be ignored.",
|
||||||
|
"type": "boolean",
|
||||||
|
"default": "false",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"identifier": "putToBeginning",
|
"identifier": "putToBeginning",
|
||||||
"name": "Put tags to beginning of note rather than to end",
|
"name": "Put tags to beginning of note rather than to end",
|
||||||
|
@ -129,9 +137,12 @@ Script {
|
||||||
|
|
||||||
// add the tag if it wasn't in the list
|
// add the tag if it wasn't in the list
|
||||||
if (tagNameList.indexOf(tagName) == -1) {
|
if (tagNameList.indexOf(tagName) == -1) {
|
||||||
|
// add the tag if it contains no duplicate tagMarkers or the check is disabled
|
||||||
|
if(ignoreDoubleMarkers == false || tagName.startsWith(escapeRegExp(tagMarker)) == false) {
|
||||||
tagNameList.push(tagName);
|
tagNameList.push(tagName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return tagNameList;
|
return tagNameList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue