REFACTOR: Remove `Discourse.SiteSettings` from highlightSyntax

REFACTOR: Remove Discourse.SiteSettings from highlightSyntax

diff --git a/app/assets/javascripts/admin/components/highlighted-code.js b/app/assets/javascripts/admin/components/highlighted-code.js
index 9159bb5..1c62c4c 100644
--- a/app/assets/javascripts/admin/components/highlighted-code.js
+++ b/app/assets/javascripts/admin/components/highlighted-code.js
@@ -6,6 +6,6 @@ export default Component.extend({
   @on("didInsertElement")
   @observes("code")
   _refresh: function() {
-    highlightSyntax($(this.element));
+    highlightSyntax($(this.element), this.siteSettings);
   }
 });
diff --git a/app/assets/javascripts/admin/models/theme.js b/app/assets/javascripts/admin/models/theme.js
index 0b96660..b8b5bc0 100644
--- a/app/assets/javascripts/admin/models/theme.js
+++ b/app/assets/javascripts/admin/models/theme.js
@@ -321,7 +321,8 @@ const Theme = RestModel.extend({
             }
           }
         );
-        highlightSyntax();
+        // TODO: Models shouldn't be updating the DOM
+        highlightSyntax(undefined, this.siteSettings);
       } else {
         return this.save({ remote_update: true }).then(() =>
           this.set("changed", false)
diff --git a/app/assets/javascripts/discourse/app/initializers/post-decorations.js b/app/assets/javascripts/discourse/app/initializers/post-decorations.js
index 9fb4440..c906d9f 100644
--- a/app/assets/javascripts/discourse/app/initializers/post-decorations.js
+++ b/app/assets/javascripts/discourse/app/initializers/post-decorations.js
@@ -9,9 +9,14 @@ export default {
   initialize(container) {
     withPluginApi("0.1", api => {
       const siteSettings = container.lookup("site-settings:main");
-      api.decorateCooked(highlightSyntax, {
-        id: "discourse-syntax-highlighting"
-      });
+      api.decorateCooked(
+        elem => {
+          return highlightSyntax(elem, siteSettings);
+        },
+        {
+          id: "discourse-syntax-highlighting"
+        }
+      );
 
       api.decorateCookedElement(
         elem => {
diff --git a/app/assets/javascripts/discourse/app/lib/highlight-syntax.js b/app/assets/javascripts/discourse/app/lib/highlight-syntax.js
index 404e73c..cc2a2f3 100644
--- a/app/assets/javascripts/discourse/app/lib/highlight-syntax.js
+++ b/app/assets/javascripts/discourse/app/lib/highlight-syntax.js
@@ -3,8 +3,8 @@ let _moreLanguages = [];
 
 import loadScript from "discourse/lib/load-script";
 
-export default function highlightSyntax($elem) {
-  const selector = Discourse.SiteSettings.autohighlight_all_code
+export default function highlightSyntax($elem, siteSettings) {
+  const selector = siteSettings.autohighlight_all_code
       ? "pre code"
       : "pre code[class]",
     path = Discourse.HighlightJSPath;

GitHub sha: 98fee7aa