# How to enable syntax highlighting?

**URL:** https://meta.discourse.org/t/how-to-enable-syntax-highlighting/332908
**Category:** Support
**Created:** [October 26, 2024, 4:45am UTC](https://meta.discourse.org/t/how-to-enable-syntax-highlighting/332908 "2024-10-26T04:45:24Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Yt.w](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/yt.w/32/348367_2.png) [@Yt.w](https://meta.discourse.org/u/Yt.w)
#### Post date: [October 26, 2024, 4:45am UTC](https://meta.discourse.org/t/how-to-enable-syntax-highlighting/332908/1 "2024-10-26T04:45:24Z")

</div>

I did not config any stuff related highlighting and highlighting is not working on my forum.

how I coding

 ![The image shows a screenshot of a code editor with the word "ruby" and a list of commands. (Captioned by AI)](https://global.discourse-cdn.com/meta/original/4X/4/3/c/43cbf51269c61801939e6f607213269fea1be47a.png)

Showing  
 ![image](https://global.discourse-cdn.com/meta/original/4X/9/0/9/909d49c25f326bda1a5c02b0300c4f658bb3c59c.png)

Here is my setting

 ![The image shows a screenshot of a coding software with a highlighted languages box and a dropdown menu, likely for a coding project or task. (Captioned by AI)](https://global.discourse-cdn.com/meta/original/4X/8/6/e/86e249d0feb22b412310a0728911fbda161e1a8c.png)

---

<div class="post-metadata">

### Author: ![Yt.w](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/yt.w/32/348367_2.png) [@Yt.w](https://meta.discourse.org/u/Yt.w)
#### Post date: [October 26, 2024, 5:01am UTC](https://meta.discourse.org/t/how-to-enable-syntax-highlighting/332908/2 "2024-10-26T05:01:47Z")

</div>

![image](https://global.discourse-cdn.com/meta/original/4X/3/3/f/33fb640d7c999236f72db1177e8773bcf8285a93.png)r

the html code looks correct on my site

---

<div class="post-metadata">

### Author: ![Yt.w](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/yt.w/32/348367_2.png) [@Yt.w](https://meta.discourse.org/u/Yt.w)
#### Post date: [October 26, 2024, 5:17am UTC](https://meta.discourse.org/t/how-to-enable-syntax-highlighting/332908/4 "2024-10-26T05:17:37Z")

</div>

Hello, ruby is in my list.  
Sorry that I made a misleading screenshoot

 ![The image shows a list of highlighted languages with several highlighted items, including "python" and "ruby". (Captioned by AI)](https://global.discourse-cdn.com/meta/original/4X/d/5/c/d5c94ca7886ea455dff4fa2c3af3556c58eb7fb6.png)

---

<div class="post-metadata">

### Author: ![Yt.w](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/yt.w/32/348367_2.png) [@Yt.w](https://meta.discourse.org/u/Yt.w)
#### Post date: [October 26, 2024, 3:33pm UTC](https://meta.discourse.org/t/how-to-enable-syntax-highlighting/332908/6 "2024-10-26T15:33:56Z")

</div>

Looks like it was a CORS problem, any one can help me to solve it?

```plaintext
formatter.js:383 Uncaught (in promise) TypeError: Failed to resolve module specifier '/highlight-js/xxx.jp/9797975efac87d28baa695ae13ca72ccaf5120f5.js'. The base URL is about:blank because import() is called from a CORS-cross-origin script.
    at g (formatter.js:383:1)
    at m (formatter.js:383:1)
    at h (formatter.js:383:1)
    at p (formatter.js:383:1)
    at topic-link.js:14:1
    at formatter.js:383:1
    at composer.js:867:1
    at Array.forEach (<anonymous>)
    at k._decorateAndAdopt (composer.js:867:1)
    at k.init (composer.js:867:1)
    at e (jquery.js:10:1)
    at e (jquery.js:10:1)
    at e (jquery.js:10:1)
    at e (jquery.js:10:1)
    at e (jquery.js:10:1)
    at e (jquery.js:10:1)
    at Object.e [as render] (jquery.js:10:1)
    at jquery.js:10:1
    at e.exports (jquery.js:10:1)
    at jquery.js:10:1
    at Object.l [as patch] (jquery.js:10:1)
    at e.exports (jquery.js:10:1)
    at jquery.js:10:1
    at Object.l [as patch] (jquery.js:10:1)
    at e (jquery.js:10:1)
    at e.rerenderWidget (user-status-bubble.js:12:1)
    at invoke (backburner.js.js:280:1)
    at h.flush (backburner.js.js:197:1)
    at p.flush (backburner.js.js:358:1)
    at B._end (backburner.js.js:798:1)
    at B._boundAutorunEnd (backburner.js.js:523:1)

```

---

<div class="post-metadata">

### Author: ![Yt.w](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/yt.w/32/348367_2.png) [@Yt.w](https://meta.discourse.org/u/Yt.w)
#### Post date: [October 27, 2024, 6:08am UTC](https://meta.discourse.org/t/how-to-enable-syntax-highlighting/332908/8 "2024-10-27T06:08:20Z")

</div>

self solved

I changed /lib/highlight\_js.rb  
from

```ruby
def self.path
    "/highlight-js/#{Discourse.current_hostname}/#{version SiteSetting.highlighted_languages}.js"
end

```

to

```ruby
def self.path
    "https://#{Discourse.current_hostname}/highlight-js/#{Discourse.current_hostname}/#{version SiteSetting.highlighted_languages}.js"
end

```

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [November 26, 2024, 6:09am UTC](https://meta.discourse.org/t/how-to-enable-syntax-highlighting/332908/9 "2024-11-26T06:09:13Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
