From dc840c2a704433477923e2c269cf6db3efd1e9cc Mon Sep 17 00:00:00 2001 From: yflory Date: Fri, 20 Mar 2020 13:45:45 +0100 Subject: [PATCH] Fix checkboxes in the markdown renderer #511 --- www/common/diffMarked.js | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/www/common/diffMarked.js b/www/common/diffMarked.js index 783aa78a9..73c801ab4 100644 --- a/www/common/diffMarked.js +++ b/www/common/diffMarked.js @@ -117,29 +117,30 @@ define([ // Tasks list var checkedTaskItemPtn = /^\s*(

)?\[[xX]\](<\/p>)?\s*/; var uncheckedTaskItemPtn = /^\s*(

)?\[ ?\](<\/p>)?\s*/; - var bogusCheckPtn = //; + var bogusCheckPtn = //; + var bogusUncheckPtn = //; renderer.listitem = function (text) { var isCheckedTaskItem = checkedTaskItemPtn.test(text); var isUncheckedTaskItem = uncheckedTaskItemPtn.test(text); - var hasBogusInput = bogusCheckPtn.test(text); + var hasBogusCheckedInput = bogusCheckPtn.test(text); + var hasBogusUncheckedInput = bogusUncheckPtn.test(text); + var isCheckbox = true; if (isCheckedTaskItem) { text = text.replace(checkedTaskItemPtn, '') + '\n'; - } - if (isUncheckedTaskItem) { + } else if (isUncheckedTaskItem) { text = text.replace(uncheckedTaskItemPtn, '') + '\n'; - } - if (!isCheckedTaskItem && !isUncheckedTaskItem && hasBogusInput) { - if (/checked/.test(text)) { - text = text.replace(bogusCheckPtn, + } else if (hasBogusCheckedInput) { + text = text.replace(bogusCheckPtn, '') + '\n'; - } else if (/disabled/.test(text)) { - text = text.replace(bogusCheckPtn, + } else if (hasBogusUncheckedInput) { + text = text.replace(bogusUncheckPtn, '') + '\n'; - } + } else { + isCheckbox = false; } - var cls = (isCheckedTaskItem || isUncheckedTaskItem || hasBogusInput) ? ' class="todo-list-item"' : ''; + var cls = (isCheckbox) ? ' class="todo-list-item"' : ''; return '' + text + '\n'; }; restrictedRenderer.listitem = function (text) {