Qt 6.12 LTS is out! See what's new in the release
blog
How to replace - [X] *
-
Markdown checkbox
Mine:// s is a string line. if (s.startsWith("- [ ] ")) s.replace("- [ ] ", "<input type=\"checkbox\">"); if (s.startsWith("- [x] ")) s.replace("- [x] ", "<input type=\"checkbox\" checked>"); if (s.startsWith("- [X] ")) s.replace("- [X] ", "<input type=\"checkbox\" checked>");Target:
// * means strings, add \n at line end if (s.startsWith("- [ ] ")) s.replace("- [ ] *", "<input type=\"checkbox\">*\n"); if (s.startsWith("- [x] ")) s.replace("- [x] *", "<input type=\"checkbox\" checked>*\n"); if (s.startsWith("- [X] ")) s.replace("- [X] *", "<input type=\"checkbox\" checked>*\n"); -
Markdown checkbox
Mine:// s is a string line. if (s.startsWith("- [ ] ")) s.replace("- [ ] ", "<input type=\"checkbox\">"); if (s.startsWith("- [x] ")) s.replace("- [x] ", "<input type=\"checkbox\" checked>"); if (s.startsWith("- [X] ")) s.replace("- [X] ", "<input type=\"checkbox\" checked>");Target:
// * means strings, add \n at line end if (s.startsWith("- [ ] ")) s.replace("- [ ] *", "<input type=\"checkbox\">*\n"); if (s.startsWith("- [x] ")) s.replace("- [x] *", "<input type=\"checkbox\" checked>*\n"); if (s.startsWith("- [X] ")) s.replace("- [X] *", "<input type=\"checkbox\" checked>*\n");@sonichy
We could do this in a couple of ways:if (s.startsWith("- [ ] ")) { s.replace("- [ ] ", "<input type=\"checkbox\">"); s.append("\n"); }or
s.replace(QRegularExpression("^- \\[ \\] (.*)$"), "<input type=\"checkbox\">\\1\n");However, I suspect putting in a
\nnewline will not do what you want. Per your other post and the linked picture there I think you want these "items" on separate lines. Remember that in HTML\nis just the same as any other whitespace character so it will just producer a space and stay on same line. You probably want either to insert a line break, HTML<br>, or possibly put your items into some kind of HTML list (like<dl> <dt>). -
S sonichy has marked this topic as solved