Conversation
- Enable html:true by default so HTML comments (<!-- -->) are passed
through as-is instead of being escaped as visible text
- Fix --strikethrough-- to use <s> tag instead of <del>, consistent
with markdown ~~strikethrough~~ rendering
- Remove + item ordered list editor highlighting rule (was applying
an unwanted heading style to list lines)
- Fix basePath undefined variable → path in relative URL resolution
- Register txt2tags_link before adding autolink/wikilink rules:
ruler.before("txt2tags_link", ...) threw "Parser rule not found"
when called before txt2tags_link was itself registered, aborting
the entire plugin initialisation and breaking all txt2tags rendering
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…namespace In Qt5, importing a JS file in QML binds the module's top-level `this` to the QML global scope, so UMD modules export their constructors onto the component via `g = this; g.markdownit = f()`, and `this.markdownit` works in init(). In Qt6, the module's top-level `this` is the module namespace object (e.g. MarkdownIt, MarkdownItTxt2tags), not the QML component scope. So the constructors land on `MarkdownIt.markdownit` etc., and `this.markdownit` in init() is undefined — causing silent init failure and a blank preview. Fix: resolve each constructor with `Namespace.name || this.name` so that Qt6 uses the module namespace and Qt5 falls back to the component scope. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
In Qt6 QML, JavaScript files imported via 'import "foo.js" as Foo' run in strict mode where `this` at the top level is undefined. The UMD wrappers in markdown-it, markdown-it-deflist, markdown-it-katex and markdown-it-txt2tags all fell back to `g = this` when window/global/self were undefined, then threw TypeError setting a property on undefined. Fix: insert `globalThis` before the `this` fallback in each UMD chain. globalThis is always the real global object in Qt6's JS engine. In init(), resolve constructors via `_g = globalThis || this` so that Qt6 uses globalThis (where the modules now export) and Qt5 falls back to the component scope (where the modules previously exported via this). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The root cause of Qt6 breakage: UMD modules used `g = this; g.markdownit = f()` where `this` at module top-level is undefined in Qt6 strict mode, so the assignment threw and nothing was exported. Fix: declare `var markdownit` and `var markdownitTxt2tags` at the top level of each JS file (outside the IIFE). Top-level vars are always accessible via the QML module qualifier (MarkdownIt.markdownit, MarkdownItTxt2tags.markdownitTxt2tags) in both Qt5 and Qt6 — no runtime this/globalThis lookup needed. Also removed the unused deflist and katex plugins to simplify the script. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
You are changing two scripts with that PR. |
|
@Maboroshy, are you ok with those changes? |
| @@ -4,7 +4,7 @@ | |||
| "script": "in-note-text-tagging.qml", | |||
| "authors": ["@Maboroshy"], | |||
There was a problem hiding this comment.
Pull request overview
This PR improves the in-note text tagging script by expanding tag detection to support multiple configurable markers (defaulting to #), and by tightening the “tag boundary” rules (requiring whitespace/start-of-line before a tag).
Changes:
- Add settings to enable/disable two independent tag markers (
tagMarker/tagMarker2) and amaxTagLengthlimit for tag extraction. - Update tag parsing and autocompletion logic to recognize tags prefixed by any enabled marker and to avoid matching tags preceded by non-whitespace.
- Bump script version to
0.2.1.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| in-note-text-tagging/info.json | Version bump for the script release. |
| in-note-text-tagging/in-note-text-tagging.qml | Adds multi-marker support, max tag length handling, and updated regex-based detection/replacement logic. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
|
|
||
| const tag = tagMarker + tagName.replace(/ /g, "_"); | ||
| var tag = tagMarker + tagName.replace(/ /g, "_"); |
There was a problem hiding this comment.
In the "add" action, noteText.search(tagRegExp) > 0 fails to detect an existing tag at the start of the note (search returns 0). This can cause duplicate tags to be added. Use a condition that treats index 0 as found (e.g., >= 0 / !== -1).
There was a problem hiding this comment.
Fixed. Changed > 0 to !== -1 on line 169 so a tag at position 0 (start of note) is correctly detected as
already existing, preventing duplicates.
|
|
||
| const tag = tagMarker + tagName.replace(/ /g, "_"); | ||
| var tag = tagMarker + tagName.replace(/ /g, "_"); | ||
|
|
There was a problem hiding this comment.
var tag = tagMarker + ... always uses the primary marker when writing tags. If useMarker1 is disabled (and only the secondary marker is enabled), the script will still insert tags with the disabled marker. Pick the marker to write based on which marker(s) are enabled (e.g., prefer primary if enabled, otherwise secondary).
| case "rename": | ||
| return noteText.replace(tagRegExp, tagMarker + newTagName.replace(/ /g, "_")); | ||
| return noteText.replace(tagRegExp, "$1" + tagMarker + newTagName.replace(/ /g, "_")); |
There was a problem hiding this comment.
The rename replacement uses tagMarker (primary) regardless of which marker was actually present in the note text, so renaming an @tag can silently turn it into a #newTag (and it also breaks if useMarker1 is off). Consider capturing the matched marker in the regex (or otherwise determining which marker matched) and reusing that marker in the replacement.
There was a problem hiding this comment.
As you say. That was so long ago, I'm not into reviewing them. I'm certainly not against the progress. |
|
Fine with me then. 😉 |
Changed > 0 to !== -1 on line 169 so a tag at position 0 (start of note) is correctly detected as already existing, preventing duplicates.
fix non white space before a tag. Allow to use either # or @ for tags (# is default because it's generally more used, but we can change that if needed)
It looks like the other PR is still mixed up with this one...