# Probleem met codeblokopmaak in Discourse – rode tekst en onbedoelde markering

**URL:** https://meta.discourse.org/t/issue-with-code-block-formatting-in-discourse-red-text-and-unintended-highlighting/321315
**Category:** Support
**Tags:** code
**Created:** [12 augustus 2024 om 18:09 UTC](https://meta.discourse.org/t/issue-with-code-block-formatting-in-discourse-red-text-and-unintended-highlighting/321315 "2024-08-12T18:09:22Z")
**Posts on this page:** 4
**Page:** 2

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [12 augustus 2024 om 21:48 UTC](https://meta.discourse.org/t/issue-with-code-block-formatting-in-discourse-red-text-and-unintended-highlighting/321315/21 "2024-08-12T21:48:33Z")

</div>

> [@alex10](#):
>
> This is what it looks like in my text editor:

Isn’t that exactly what it looks like in your Discourse image? (Except in your editor `import` and `as` are **bold** )

---

<div class="post-metadata">

### Author: ![bryce](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bryce/32/377822_2.png) [@bryce](https://meta.discourse.org/u/bryce)
#### Post date: [12 augustus 2024 om 22:53 UTC](https://meta.discourse.org/t/issue-with-code-block-formatting-in-discourse-red-text-and-unintended-highlighting/321315/22 "2024-08-12T22:53:26Z")

</div>

Hi Alex,  
I think @Moin has the right idea–I’m seeing some styling applied to the code blocks that looks like it’s probably coming from **Custom CSS/HTML** in the theme.

 ![This image shows a computer screen displaying a code editor with a Python script that includes various imports and function definitions. (Captioned by AI)](https://global.discourse-cdn.com/meta/original/4X/5/5/5/555d09462f6f6609457d1c749582ff2d9bebc843.png)

I think this line (`font-family: Consolas;`) could be safely removed since it’s overriding these existing styles which use the same font but also specify fallback options:

```css
code, pre {
    font-family: var(--d-font-family--monospace);
}

:root {
    --d-font-family--monospace: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace;
}

```

Maybe your computer isn’t able to display Consolas and is just falling back to the default (non-monospace) font. You can check here to see if that CSS is present:

 ![](https://global.discourse-cdn.com/meta/original/4X/1/a/7/1a705db313b88d495c02f71b7b0837f84844aa22.png)

---

<div class="post-metadata">

### Author: ![bryce](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bryce/32/377822_2.png) [@bryce](https://meta.discourse.org/u/bryce)
#### Post date: [13 augustus 2024 om 16:46 UTC](https://meta.discourse.org/t/issue-with-code-block-formatting-in-discourse-red-text-and-unintended-highlighting/321315/24 "2024-08-13T16:46:10Z")

</div>

Ah, I also just noticed we do have an official theme component for customizing code block appearance:

> [@Custom Code](https://meta.discourse.org/t/custom-code/108059):
>
> discourse2Summary Custom Code allows you to customize the font and colors for source shared on the site.eyeglassesPreview [Preview on Discourse Theme Creator](https://discourse.theme-creator.io/theme/Discourse/custom-code)hammer_and_wrenchRepository Link [https://github.com/discourse/discourse-custom-code](https://github.com/discourse/discourse-custom-code)open_bookNew to Discourse Themes? [Beginner’s guide to using Discourse Themes](https://meta.discourse.org/t/beginners-guide-to-using-discourse-themes/91966) Install this theme component Features Generally, the fonts used to write code are part of the [monospace family](https://fonts.google.com/?category=Monospace). The most known fonts are: [Inc…](https://fonts.google.com/specimen/Inconsolata)

---

<div class="post-metadata">

### Author: ![alex10](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/alex10/32/575949_2.png) [@alex10](https://meta.discourse.org/u/alex10)
#### Post date: [13 augustus 2024 om 19:24 UTC](https://meta.discourse.org/t/issue-with-code-block-formatting-in-discourse-red-text-and-unintended-highlighting/321315/25 "2024-08-13T19:24:13Z")

</div>

I think this was likely the issue but I didn’t verify. I ended up switching themes and it resolved the issue. Thanks, everyone, for your input! And thank you again, Bryce, for finding the theme component for customizing code block appearance.

[Previous page](https://meta.discourse.org/t/issue-with-code-block-formatting-in-discourse-red-text-and-unintended-highlighting/321315.md?page=1)
