From def5de6d28b0621d51b669fd71425254aa5ab29f Mon Sep 17 00:00:00 2001 From: VISHAL DEEPAK Date: Tue, 30 Nov 2021 02:18:20 +0530 Subject: [PATCH] Remove extra script tag from embedded gists to prevent them from mixing up (#14674) --- app/javascript/utilities/gist.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/javascript/utilities/gist.js b/app/javascript/utilities/gist.js index bd9d5fa2a..fd7b06aa8 100644 --- a/app/javascript/utilities/gist.js +++ b/app/javascript/utilities/gist.js @@ -30,11 +30,13 @@ function getGistTags(nodes) { function loadEmbeddedGists(postscribe, gistTags) { for (const gistTag of gistTags) { - postscribe(gistTag, gistTag.firstElementChild.outerHTML, { + const gistWrapper = gistTag.firstElementChild; + postscribe(gistTag, gistWrapper.outerHTML, { beforeWrite(text) { return gistTag.childElementCount > 3 ? '' : text; }, }); + gistWrapper.remove(); } }