Open henon opened 6 months ago
Considering that MR was not accepted, I made a crutch. The code for editing the code in the plugin is directly ".obsidian\plugins\todo-sort\main.js"
// src/sort.ts
function sortTodos(plainText, sortOrder) {
const lines = plainText.split("\n");
const lineInfos = lines.map((value, originalIndex) => {
let todoMatch = value.match(/^\s*[-*] \[(.)\]/i); // modify
const todo = !!todoMatch; // modify
const completed = !!todoMatch && todoMatch[1] != " "; // modify
const indentation = value.length - value.trimStart().length;
return { originalIndex, value, todo, completed, indentation };
});
const sortedLineInfos = sortLineInfos(lineInfos, sortOrder);
const lineMap = {};
for (let i = 0; i < sortedLineInfos.length; i++) {
const lineInfo = sortedLineInfos[i];
lineMap[lineInfo.originalIndex] = i;
}
const output = sortedLineInfos.map((lineInfo) => lineInfo.value).join("\n");
return { output, lineMap };
}
Apparently, it is possible to create todo lists with both dashes and astersiks in Obsidian. If the styles are mixed which can happen if you convert bullet points into checkboxes with a hotkey then sorting doesn't work any more.