Skip to content

Commit 948b4f2

Browse files
committed
list-maker: make "Clear list formatting" support checkbox lists
Signed-off-by: Patrizio Bekerle <[email protected]>
1 parent 4d83ade commit 948b4f2

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

list-maker/info.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"script": "list-maker.qml",
55
"authors": ["@Maboroshy", "@pbek"],
66
"platforms": ["linux", "macos", "windows"],
7-
"version": "0.1.2",
7+
"version": "0.1.3",
88
"minAppVersion": "17.07.8",
99
"description": "This script adds toolbar buttons and context menu items to change selected text formatting:\n- make it an ordered list with numbers or letters;\n- make it an unordered list with markers of your choice;\n- clear any list formatting.\n\nIdented lines in numbered list will become a sub-list (1.1., 1.2...). Using buttons on a list will override it's formatting with the one you choose. If the first line is part of the ordered list, other lines will continue the list:\n<i>\n2. First selected line\n Some new line\n3. Ordered list line\n- marked list line\na. A first line of another ordered list\nb. A second line of another ordered list\n</i>\nWill become:\n<i>\n2. First selected line\n 2.1. Some new line\n3. Ordered list line\n4. marked list line\n5. A first line of another ordered list\n6. A second line of another ordered list\n</i>\nUnordered list marks and letters used for ordered list can be altered in the script settings.\n\nYou can also replace letters with Chinese/Japanese numbers or any other characters to use them for ordered lists.\n"
1010
}

list-maker/list-maker.qml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ Script {
4040
// This will clear the text of all list formatting the script uses
4141
function clearLine(text) {
4242
var line = text;
43+
44+
// Remove checkbox list formatting (e.g., "- [ ] " or "- [x] ")
45+
line = line.replace(/^(\s*)[-*+] \[[^\]]*\] (.*)$/gm, "$1$2");
46+
4347
var lineType = getListType(line);
4448

4549
while (lineType != "none") {

0 commit comments

Comments
 (0)