Skip to content

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

FIX: Replace censored watched word consistently (#12486)

Bianca Nenciud7bd62d9cf88
diff --git a/app/assets/javascripts/pretty-text/engines/discourse-markdown/censored.js b/app/assets/javascripts/pretty-text/engines/discourse-markdown/censored.js
index f643c4f5b80..0280d5d411f 100644
--- a/app/assets/javascripts/pretty-text/engines/discourse-markdown/censored.js
+++ b/app/assets/javascripts/pretty-text/engines/discourse-markdown/censored.js
@@ -3,6 +3,10 @@ import { censorFn } from "pretty-text/censored-words";
function recurse(tokens, apply) {
let i;
for (i = 0; i < tokens.length; i++) {
+ if (tokens[i].type === "html_raw" && tokens[i].onebox) {
+ continue;
+ }
+
apply(tokens[i]);
if (tokens[i].children) {
recurse(tokens[i].children, apply);
diff --git a/app/assets/javascripts/pretty-text/engines/discourse-markdown/onebox.js b/app/assets/javascripts/pretty-text/engines/discourse-markdown/onebox.js
index f1eb387877d..173964f17c4 100644
--- a/app/assets/javascripts/pretty-text/engines/discourse-markdown/onebox.js
+++ b/app/assets/javascripts/pretty-text/engines/discourse-markdown/onebox.js
@@ -81,6 +81,7 @@ function applyOnebox(state, silent) {
child.type = "html_raw";
child.content = cached;
child.inline = true;
+ child.onebox = true;
text.type = "html_raw";
text.content = "";