Skip to content

Commit 10f5df5

Browse files
author
luginf
committed
adding readme + fix
1 parent db3154f commit 10f5df5

2 files changed

Lines changed: 83 additions & 7 deletions

File tree

zettelkasten/README.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Zettelkasten for QOwnNotes
2+
3+
A QOwnNotes script that adds [Zettelkasten](https://en.wikipedia.org/wiki/Zettelkasten) support: unique IDs for notes and permanent wiki-links that survive note renames.
4+
5+
## Concept
6+
7+
In the Zettelkasten method, each note carries a **permanent unique ID** embedded in its content or filename. Links between notes are based on this ID, not on the filename. This means a note can be renamed freely without breaking any link pointing to it.
8+
9+
This script implements that principle inside QOwnNotes using the native `[[filename|id]]` wiki-link format.
10+
11+
## Link format
12+
13+
```
14+
[[MyNote|20260430143012]]
15+
```
16+
17+
- The left part (`MyNote`) is what QOwnNotes uses to resolve the link (Ctrl+click to open).
18+
- The right part (`20260430143012`) is the permanent ZK ID, used by this script to repair links when the filename changes.
19+
20+
## Actions
21+
22+
Three toolbar buttons are registered:
23+
24+
| Button | Action |
25+
|--------|--------|
26+
| **ZK-ID** | Insert a new unique ZK ID at the cursor position |
27+
| **ZK-Link** | Open a searchable dialog to pick a note and insert a `[[filename\|id]]` link |
28+
| **ZK-Fix** | Scan all notes and repair every link whose filename is out of date |
29+
30+
## ID format
31+
32+
IDs are generated from the current date and time using a configurable format string.
33+
34+
Available tokens:
35+
36+
| Token | Value |
37+
|-------|-------|
38+
| `%Y` | 4-digit year |
39+
| `%M` | 2-digit month |
40+
| `%D` | 2-digit day |
41+
| `%h` | 2-digit hour |
42+
| `%m` | 2-digit minute |
43+
| `%s` | 2-digit second |
44+
45+
Examples:
46+
47+
| Format | Result |
48+
|--------|--------|
49+
| `%Y%M%D%h%m%s` *(default)* | `20260430143012` |
50+
| `id%Y%M%Dx%h%m%s` | `id20260430x143012` |
51+
| `%Y-%M-%D` | `2026-04-30` |
52+
53+
## ID detection
54+
55+
When searching for a note's ZK ID, the script checks the **filename** first, then the full **note body**. Only the first match is used.
56+
57+
The detection pattern is a configurable ECMAScript regex. The default `\d{14}` matches any 14-digit timestamp. If you use a custom format with a prefix (e.g. `id%Y%M%Dx%h%m%s`), update the regex accordingly — for example `id\d{8}x\d{6}`.
58+
59+
## Rename resilience
60+
61+
When you rename a note in QOwnNotes, any `[[oldName|id]]` links in other notes become stale. This script fixes them automatically in two ways:
62+
63+
- **Automatic** — when you open the renamed note, the script silently rewrites every backlink pointing to it with the new filename. This happens in the background with no interruption.
64+
- **Manual** — click **ZK-Fix** at any time to repair all stale links across the entire vault in one pass.
65+
66+
> **Note:** QOwnNotes may show a native dialog asking whether to replace link occurrences after a rename. That dialog does not understand the `[[filename|id]]` format and will not change anything. You can safely click *No* and let this script handle it, or disable the dialog entirely in *Settings → Notes*.
67+
68+
## Settings
69+
70+
All settings are accessible in *Settings → Scripting → Zettelkasten*:
71+
72+
| Setting | Default | Description |
73+
|---------|---------|-------------|
74+
| ID generation format | `%Y%M%D%h%m%s` | Format string for new IDs |
75+
| ID detection pattern | `\d{14}` | ECMAScript regex to locate IDs in filenames and content |
76+
| Auto-repair backlinks on note open | enabled | Automatically fix stale backlinks when a note with a ZK ID is opened |

zettelkasten/zettelkasten.qml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,20 @@ Script {
3232
property string notesDir: ""
3333

3434
property variant settingsVariables: [
35-
{
36-
"identifier": "idRegex",
37-
"name": "ID detection pattern (ECMAScript regex)",
38-
"description": "Pattern used to detect Zettelkasten IDs in note filenames and content.\nDefault matches 14-digit timestamps: \\d{14}",
39-
"type": "string",
40-
"default": "\\d{14}"
41-
},
4235
{
4336
"identifier": "idFormat",
4437
"name": "ID generation format",
4538
"description": "Format string for generating new IDs.\nTokens: %Y=year %M=month %D=day %h=hour %m=minute %s=second\nLiteral characters are kept as-is.\n\nExamples:\n %Y%M%D%h%m%s → 20260430143012\n id%Y%M%Dx%h%m%s → id20260430x143012\n %Y-%M-%D → 2026-04-30",
4639
"type": "string",
4740
"default": "%Y%M%D%h%m%s"
4841
},
42+
{
43+
"identifier": "idRegex",
44+
"name": "ID detection pattern (ECMAScript regex)",
45+
"description": "Pattern used to detect Zettelkasten IDs in note filenames and content.\nDefault matches 14-digit timestamps: \\d{14}",
46+
"type": "string",
47+
"default": "\\d{14}"
48+
},
4949
{
5050
"identifier": "autoRepairLinks",
5151
"name": "Auto-repair backlinks on note open",

0 commit comments

Comments
 (0)