Strange syntax highlighting in <pre><code> and/or triple `-escaped text


Basically I want to list some text/table without any sort of syntax highlight but that seems impossible to do.

I’ve tried adding 4 spaces, multiple tabs, triple ```, changing the syntax hightlight to markdown, text and leaving it completely out but in the end Discourse always chooses coffeescript for my text.

Just after saving, the text turns out like

but after refreshing the site the syntax highlight gets applied again:

I want to display it similarly to github; similar red highlighting (perl) appears in the Onebox too:

Screenshot for reference, even right after creating the topic this was all grey and after a refresh it was red again.

(Jeff Atwood) #2

I am not sure what the magic words are there (is “text” correct @sam), I suggest using 4 space indents aka ctrl+k instead.

Like this

You must have the site setting enabled that forces syntax highlighting for all pre blocks, but this is not the default?


I tried text, txt, md and markdown.

That setting was enabled. I’ve now turned it off, edited the post and rebuilt HTML: the same highlight still appears.

In the post (and in the title) I clarified that I did try using 4 spaces.

(Jeff Atwood) #4

Also entirely possible this is a new Ember 1.8 or 1.9 related bug!


Welp, bump. Still can’t use these code blocks :frowning:

(Sam Saffron) #6
def test
def test

working fine here:

def test

def test

(Sam Saffron) #7

ahh… just realised, you probably have “autohighlight all code” enabled by mistake in your site settings (off by default) which would cause your issue.

changing to support.


That setting is off.

Actually, doing triple `` and text does fix the issue, but it shouldn’t happen when the setting is off right?

See, without text:

Abreviature  Meaning

AA        Anti-Aliasing
AF        Anisotropic Filtering
ATX       The 2nd largest Form Factor
BIOS      Basic Input Output System
BSOD      BlueScreen of Death
CF        Crossfire (AMD's version of SLI)
CMOS      BIOS memory
CPU       Central Processing Unit or Processor
dB        Decibels
DDR(3-4)  Double Data Rate
DIMM      RAM module/stick
DOA       Dead on Arrival
DP        DisplayPort
DPI       Dots Per Inch
DVI       Digital Video Interface
FPS       Frames per Second
GDDR      Graphics Double Data Rate
GHz       Gigahertz
HDD       Hard Disk Drive
HDMI      High-Definition Multimedia Interface
HDR       High Dynamic-Range
Hz        Hertz, display refresh rate
HT        Intel Hyper Threading
IPS       In-Plane Switching
LCD       Liquid-Crystal Display
MFAA      Multi-Frame Anti-Aliasing
MSAA      Multi-Sampling Anti-Aliasing
NIC       Network Interface Card
OC        Overclock
OEM       Original Equipment Manufacturer
OS        Operating System
OSD       On-Screen Display
PCB       Printed Circuit Board
PCI-e     Expansion slots for GPUs or other devices
PLS       Super PLS
PSU       Power Supply Unit
PWM       Pulse Width Modulation
RAID      Redundant Array of Independent Drives
RAM       Random Access Memory
RMA       Return Merchandise Authorization
SATA      Mass storage port
SFF       Small Form Factor
SLI       Scalable Link Interface (NVIDIA's version of Crossfire)
SMART     Self-Monitoring Analysis and Reporting Technology
SSAO      Screen Space Ambient Occlusion
SSAA      Super-Sampling Anti-Aliasing
SSD       Solid State Drive
TDP       Thermal Design Power
UEFI      Unified Extensible Firmware Interface
VCORE     CPU Core Voltage
VRM       Voltage Regulator Module

(Kane York) #9

What’s broken is that highlight.js doesn’t have an detector for plain text, because that isn’t what it was built for. So it always runs on triple-backtick blocks, and tries to always come up with something to highlight.


I think I got that, but that raises the question why autohighlight all code even exists if it gets autohighlighted always anyway?

Or does that only apply to 4-space-indented stuff?

(Jeff Atwood) #11

I am pretty sure we support an explicit plain text indication (can’t remember if it is “plain” or “text” or both) for the triple backticks now. In fact you brought it up above…

But yeah, 100% operating as designed – triple backticks means “this is gonna be source code” unless you tell it otherwise.