You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit c7ba29e
Browse filesBrowse the repository at this point in the historyBrowse files
luginf
committed
We're making the new-note-namer script upgrade-safe for existing users. The code and README are
updated with backward-compatible migration logic for the renamed heading setting.
Copy file name to clipboardExpand all lines: new-note-namer/new-note-namer.qml
+22-4Lines changed: 22 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -13,6 +13,7 @@ QtObject {
13
13
property string _searchTerm:""
14
14
property string customHeadingOpen
15
15
property string customHeadingClose
16
+
property bool underlineHeading // deprecated — kept so existing stored settings still load
16
17
property variant settingsVariables: [
17
18
{
18
19
'identifier':'extraDialogForTitle',
@@ -54,6 +55,13 @@ QtObject {
54
55
'type':'string',
55
56
'default':''
56
57
},
58
+
{
59
+
'identifier':'underlineHeading',
60
+
'name':'Underline heading (deprecated)',
61
+
'description':'Deprecated: use "Heading style" above instead. Kept so that users upgrading from v0.0.2 automatically keep their Setext-heading preference without needing to change settings.',
62
+
'type':'boolean',
63
+
'default':'false'
64
+
},
57
65
]
58
66
59
67
functionhandleNewNoteHeadlineHook(headline) {
@@ -70,26 +78,36 @@ QtObject {
70
78
}
71
79
returnbuildHeadline(name);
72
80
}
81
+
// Migration helper: underlineHeading=true from v0.0.2 maps to Setext ("1").
82
+
// headingStyle "1" or "2" set explicitly always wins.
83
+
functioneffectiveHeadingStyle() {
84
+
if (headingStyle ==="0"&& underlineHeading) {
85
+
return"1";
86
+
}
87
+
return headingStyle;
88
+
}
73
89
functionbuildHeadline(name) {
74
-
if (headingStyle ==="2") {
90
+
var style =effectiveHeadingStyle();
91
+
if (style ==="2") {
75
92
return customHeadingOpen + name + customHeadingClose;
76
93
}
77
-
if (headingStyle==="1") {
94
+
if (style==="1") {
78
95
return name +"\n"+"=".repeat(name.length);
79
96
}
80
97
return"# "+ name; // "0" (ATX) or unset
81
98
}
82
99
functionextractTitle(noteText) {
83
100
var firstLine = (noteText ||"").split("\n")[0];
84
-
if (headingStyle ==="2") {
101
+
var style =effectiveHeadingStyle();
102
+
if (style ==="2") {
85
103
var t =firstLine.slice(customHeadingOpen.length);
86
104
var closeLen =customHeadingClose.length;
87
105
if (closeLen >0&&t.slice(-closeLen) === customHeadingClose) {
88
106
t =t.slice(0, t.length- closeLen);
89
107
}
90
108
return t;
91
109
}
92
-
if (headingStyle==="1") {
110
+
if (style==="1") {
93
111
return firstLine; // setext: first line is the bare title
0 commit comments