Skip to content

Commit

Permalink
Updated regexps to fix #130 and #131
Browse files Browse the repository at this point in the history
  • Loading branch information
Maboroshy authored Jul 14, 2021
1 parent 0368266 commit 08f43b4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions in-note-text-tagging/in-note-text-tagging.qml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ Script {

// returns a list of all tag names of the note
case "list":
var re = new RegExp("\\B%1([^\\s,;]+)".arg(escapeRegExp(tagMarker)), "gi"),
var re = new RegExp("\\B%1([^\\s,;%1]+)".arg(escapeRegExp(tagMarker)), "gi"),
result, tagNameList = [];

while ((result = re.exec(noteText)) !== null) {
Expand All @@ -139,16 +139,16 @@ Script {
}

// Removes tag marker in note preview and highlights tag name with set color
function noteToMarkdownHtmlHook(note, html, forExport) {
function preNoteToMarkdownHtmlHook(note, text, forExport) {
if (tagHighlightColor == "")
return;

var re = new RegExp("\\B%1([^\\s,;]+)".arg(escapeRegExp(tagMarker)), "gi"), result;
var re = new RegExp("\\B%1([^\\s,;%1]+)".arg(escapeRegExp(tagMarker)), "gi"), result;

while ((result = re.exec(html)) !== null)
html = html.replace(result[0], '<b><font color="%1">%2</font></b>'.arg(tagHighlightColor).arg(result[1]));
while ((result = re.exec(text)) !== null && result !== '')
text = text.replace(result[0], '<b><font color="%1">%2</font></b>'.arg(tagHighlightColor).arg(result[1]));

return html;
return text;
}

// Escapes a string for regular expressions
Expand Down
2 changes: 1 addition & 1 deletion in-note-text-tagging/info.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"script": "in-note-text-tagging.qml",
"authors": ["@Maboroshy"],
"platforms": ["linux", "macos", "windows"],
"version": "0.0.9",
"version": "0.1.0",
"minAppVersion": "20.6.0",
"description" : "With this script you can <b>store your tags in your note-text</b>. Use tags like <i>@tag</i> or <i>@tag_one</i> 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\nIf you start writing a tag you can also use the autocompleter to get a list of already existing tags.\n\nYou can also use this script as template for implementing your own, unique tagging mechanism.\n\n<b>If 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!</b>\nPlease report your experiences."
}

0 comments on commit 08f43b4

Please sign in to comment.