@@ -6,10 +6,10 @@ import QOwnNotesTypes 1.0
66 * #tag1 #tag2 #tag3 #tag4
77 * @tag_one would tag the note with "tag one" tag.
88 * One or both markers can be enabled independently via the settings.
9- * - The two checkboxes are independent — you can enable # alone, @ alone, both, or freely change the characters
9+ * - The two checkboxes are independent — you can enable # alone, @ alone, both, or freely change the characters
1010 * - If both are disabled, no tags are detected (clean empty return)
11- * - maxTagLength = 0 disables the limit → * quantifier in the regex
12- * - maxTagLength = 32 → {0,31} quantifier (1 mandatory letter + 31 more = 32 total)
11+ * - maxTagLength = 0 disables the limit → * quantifier in the regex
12+ * - maxTagLength = 32 → {0,31} quantifier (1 mandatory letter + 31 more = 32 total)
1313 * - The tagBodyQuantifier() function computes the correct quantifier on each call
1414
1515 */
@@ -74,22 +74,26 @@ Script {
7474 // Returns an array of currently active tag markers
7575 function allMarkers () {
7676 var markers = [];
77- if (useMarker1 && tagMarker) markers .push (tagMarker);
78- if (useMarker2 && tagMarker2) markers .push (tagMarker2);
77+ if (useMarker1 && tagMarker)
78+ markers .push (tagMarker);
79+ if (useMarker2 && tagMarker2)
80+ markers .push (tagMarker2);
7981 return markers;
8082 }
8183
8284 // Returns a regex alternation string matching any active marker, or null if none active
8385 function markerPattern () {
8486 var markers = allMarkers ();
85- if (markers .length === 0 ) return null ;
87+ if (markers .length === 0 )
88+ return null ;
8689 return " (?:" + markers .map (escapeRegExp).join (" |" ) + " )" ;
8790 }
8891
8992 // Returns the quantifier for tag body chars based on maxTagLength setting.
9093 // First letter is always required; this governs the *remaining* characters.
9194 function tagBodyQuantifier () {
92- if (maxTagLength > 0 ) return " {0," + (maxTagLength - 1 ) + " }" ;
95+ if (maxTagLength > 0 )
96+ return " {0," + (maxTagLength - 1 ) + " }" ;
9397 return " *" ;
9498 }
9599
@@ -98,7 +102,8 @@ Script {
98102 */
99103 function autocompletionHook () {
100104 var pattern = markerPattern ();
101- if (! pattern) return [];
105+ if (! pattern)
106+ return [];
102107
103108 // get the current word plus non-word-characters before the word to also get the tag marker
104109 var word = script .noteTextEditCurrentWord (true );
@@ -158,7 +163,8 @@ Script {
158163 */
159164 function noteTaggingHook (note , action , tagName , newTagName ) {
160165 var pattern = markerPattern ();
161- if (! pattern) return action === " list" ? [] : " " ;
166+ if (! pattern)
167+ return action === " list" ? [] : " " ;
162168
163169 var noteText = note .noteText ;
164170 // Match a specific known tag with any active marker.
@@ -231,29 +237,23 @@ Script {
231237 // a letter (including accented/Unicode) as first char.
232238 // Max length is controlled by tagBodyQuantifier().
233239 var excludedChars = allMarkers ().map (escapeRegExp).join (" " );
234- var re = new RegExp (
235- " (?:^|\\ s)" + pattern +
236- " ([a-zA-Z" +
237- " \\ u00C0-\\ u024F" + // Latin Extended A+B
238- " \\ u0250-\\ u02AF" + // IPA Extensions
239- " \\ u0370-\\ u03FF" + // Greek and Coptic
240- " \\ u0400-\\ u052F" + // Cyrillic + Supplement
241- " \\ u0530-\\ u058F" + // Armenian
242- " \\ u05D0-\\ u05FF" + // Hebrew
243- " \\ u0600-\\ u06FF" + // Arabic
244- " \\ u0900-\\ u0D7F" + // Indic (Devanagari, Bengali, Gurmukhi, Gujarati, Oriya, Tamil, Telugu, Kannada, Malayalam)
245- " \\ u0E00-\\ u0EFF" + // Thai and Lao
246- " \\ u10A0-\\ u10FF" + // Georgian
247- " \\ u1200-\\ u137F" + // Ethiopic
248- " \\ u1E00-\\ u1FFF" + // Latin Extended Additional + Greek Extended
249- " \\ u3040-\\ u30FF" + // Hiragana + Katakana
250- " \\ u3400-\\ u4DBF" + // CJK Extension A
251- " \\ u4E00-\\ u9FFF" + // CJK Unified Ideographs
252- " \\ uAC00-\\ uD7AF" + // Hangul Syllables
253- " ]" +
254- " [^\\ s,;" + excludedChars + " ]" + tagBodyQuantifier () + " )" ,
255- " gim"
256- ), result, tagNameList = [];
240+ var re = new RegExp (" (?:^|\\ s)" + pattern + " ([a-zA-Z" + " \\ u00C0-\\ u024F" + // Latin Extended A+B
241+ " \\ u0250-\\ u02AF" + // IPA Extensions
242+ " \\ u0370-\\ u03FF" + // Greek and Coptic
243+ " \\ u0400-\\ u052F" + // Cyrillic + Supplement
244+ " \\ u0530-\\ u058F" + // Armenian
245+ " \\ u05D0-\\ u05FF" + // Hebrew
246+ " \\ u0600-\\ u06FF" + // Arabic
247+ " \\ u0900-\\ u0D7F" + // Indic (Devanagari, Bengali, Gurmukhi, Gujarati, Oriya, Tamil, Telugu, Kannada, Malayalam)
248+ " \\ u0E00-\\ u0EFF" + // Thai and Lao
249+ " \\ u10A0-\\ u10FF" + // Georgian
250+ " \\ u1200-\\ u137F" + // Ethiopic
251+ " \\ u1E00-\\ u1FFF" + // Latin Extended Additional + Greek Extended
252+ " \\ u3040-\\ u30FF" + // Hiragana + Katakana
253+ " \\ u3400-\\ u4DBF" + // CJK Extension A
254+ " \\ u4E00-\\ u9FFF" + // CJK Unified Ideographs
255+ " \\ uAC00-\\ uD7AF" + // Hangul Syllables
256+ " ]" + " [^\\ s,;" + excludedChars + " ]" + tagBodyQuantifier () + " )" , " gim" ), result, tagNameList = [];
257257
258258 while ((result = re .exec (noteText)) !== null ) {
259259 tagName = result[1 ].replace (/ _/ g , " " );
0 commit comments