Skip to content

A platform for community discussion. Free, open, simple.

FIX: ensure [date-range don't clashes with checklist

Régis Hanol36659531f779
diff --git a/plugins/checklist/test/javascripts/lib/checklist-test.js b/plugins/checklist/test/javascripts/lib/checklist-test.js
index e4785969e73..3ebc8351259 100644
--- a/plugins/checklist/test/javascripts/lib/checklist-test.js
+++ b/plugins/checklist/test/javascripts/lib/checklist-test.js
@@ -10,7 +10,10 @@ let currentRaw;
async function prepare(raw) {
const cooked = await cook(raw, {
- siteSettings: { checklist_enabled: true },
+ siteSettings: {
+ checklist_enabled: true,
+ discourse_local_dates_enabled: true,
+ },
});
const widget = { attrs: {}, scheduleRerender() {} };
@@ -38,6 +41,23 @@ acceptance("discourse-checklist | checklist", function (needs) {
]);
});
+ test("does not clash with date-range bbcode", async function (assert) {
+ const [$elem, updated] = await prepare(`
+[date-range from=2024-03-22 to=2024-03-23]
+
+[ ] task 1
+[ ] task 2
+[x] task 3
+ `);
+
+ assert.equal($elem.find(".discourse-local-date").length, 2);
+ assert.equal($elem.find(".chcklst-box").length, 3);
+ $elem.find(".chcklst-box")[0].click();
+
+ const output = await updated;
+ assert.ok(output.includes("[x] task 1"));
+ });
+
test("does not check an image URL", async function (assert) {
const [$elem, updated] = await prepare(`
![](upload://zLd8FtsWc2ZSg3cZKIhwvhYxTcn.jpg)
diff --git a/plugins/discourse-local-dates/assets/javascripts/lib/discourse-markdown/discourse-local-dates.js b/plugins/discourse-local-dates/assets/javascripts/lib/discourse-markdown/discourse-local-dates.js
index cebf0969433..664162434d1 100644
--- a/plugins/discourse-local-dates/assets/javascripts/lib/discourse-markdown/discourse-local-dates.js
+++ b/plugins/discourse-local-dates/assets/javascripts/lib/discourse-markdown/discourse-local-dates.js
@@ -115,7 +115,7 @@ function defaultDateConfig() {
}
function parseTagAttributes(tag) {
- const matchString = tag.replace(/‘|’|„|“|«|»|”/g, '"');
+ const matchString = tag.replace(/[‘’„“«»”]/g, '"');
return parseBBCodeTag(
"[date date" + matchString + "]",
@@ -162,7 +162,9 @@ function addLocalRange(buffer, matches, state) {
addSingleLocalDate(buffer, state, config);
}
if (config.range) {
- closeBuffer(buffer, state, "→");
+ const token = new state.Token("text", "", 0);
+ token.content = "→";
+ buffer.push(token);
}
if (parsed.attrs.to) {
[date, time] = parsed.attrs.to.split("T");