editor-auto-list - how to add [ ] to * and #

93 views
Skip to first unread message

Sapphireslinger

unread,
Jan 14, 2021, 12:55:33 AMJan 14
to TiddlyWiki
Saq's editor-autolist ($:/plugins/sq/editor-autolist) makes * and # lists effortless.

But tgrosinger's minimalist little checklist ($:/plugins/tgrosinger/tw5-checklist) uses [ ] lists.

How do I add [ ] to * and # in Saq's code?

I tried editing part of $:/plugins/sq/editor-autolist/editor-operation-autolist like so:

var listPrefixRegex = /^((\*|#|[ ])+).*/;
var match = prevLine.match(listPrefixRegex);
//ensure we only handle lines starting with * or # if(match != null && match[1]) {
var trimmed = match[0].replace(/\s\s*$/, '');
var prefixRegEx = /^((\*|#|[ ])+)$/;

But It didn't work.

Sapphireslinger

unread,
Jan 20, 2021, 4:56:36 AMJan 20
to TiddlyWiki
May I ask how do I add [ ] to * and # in Saq's editor-autolist plugin?

Frédéric Demers

unread,
Oct 9, 2021, 7:00:43 AMOct 9
to TiddlyWiki
Hi there! 
I have solved this a while back for myself, but only saw this question yesterday! I hope you didn't wait all this time!

I recommend the following 3 changes in the file $:/plugins/sq/editor-autolist/editor-operation-autolist:

//change line 19 from: var listPrefixRegex = /^((\*|#)+).*/; to:
var listPrefixRegex = /^((\*|#|\[ |\[x)+).*/;

//change line 50 from: var prefixRegEx = /^((\*|#)+)$/; to:
var prefixRegEx = /^((\*|#|\[ \]|\[x\])+)$/;

//insert after line 62 (var prefix = match[1];)
if (prefix == "[ " || prefix == "[x") {prefix += "]";}
Reply all
Reply to author
Forward
0 new messages