# Activate monospace font inside codeblocks in the post editor

**URL:** https://meta.discourse.org/t/activate-monospace-font-inside-codeblocks-in-the-post-editor/206533
**Category:** Feature
**Created:** [October 20, 2021, 10:49am UTC](https://meta.discourse.org/t/activate-monospace-font-inside-codeblocks-in-the-post-editor/206533 "2021-10-20T10:49:19Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![meglio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/meglio/32/71444_2.png) [@meglio](https://meta.discourse.org/u/meglio)
#### Post date: [October 20, 2021, 10:49am UTC](https://meta.discourse.org/t/activate-monospace-font-inside-codeblocks-in-the-post-editor/206533/1 "2021-10-20T10:49:19Z")

</div>

For a medium-to-large code blocks, it’s very impractical to type them with alignment, as people usually do in the code, because a non-monospace is used.

This is a feature request to automatically use monospace font inside the code blocks where we edit the post content.

---

<div class="post-metadata">

### Author: ![IAmGav](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/iamgav/32/235598_2.png) [@IAmGav](https://meta.discourse.org/u/IAmGav)
#### Post date: [October 20, 2021, 10:54am UTC](https://meta.discourse.org/t/activate-monospace-font-inside-codeblocks-in-the-post-editor/206533/2 "2021-10-20T10:54:07Z")

</div>

you mean something like this ?

```plaintext
if(expression)
{
    statement;
    statement;
}
else
{
    statement;
    statement;
}

```

---

<div class="post-metadata">

### Author: ![meglio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/meglio/32/71444_2.png) [@meglio](https://meta.discourse.org/u/meglio)
#### Post date: [October 20, 2021, 10:56am UTC](https://meta.discourse.org/t/activate-monospace-font-inside-codeblocks-in-the-post-editor/206533/3 "2021-10-20T10:56:21Z")

</div>

> [@IAmGav](#):
>
> you mean something like this ?

Hm, not sure what you’re asking about exactly?

---

<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: [October 20, 2021, 11:26am UTC](https://meta.discourse.org/t/activate-monospace-font-inside-codeblocks-in-the-post-editor/206533/4 "2021-10-20T11:26:31Z")

</div>

He wants the font to be different in the composer, not just in the cooked post.

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [October 20, 2021, 12:10pm UTC](https://meta.discourse.org/t/activate-monospace-font-inside-codeblocks-in-the-post-editor/206533/5 "2021-10-20T12:10:51Z")

</div>

@spirobel is working on a WYSIWYG editor …

> [@Discourse Basic Editor](https://meta.discourse.org/t/discourse-basic-editor-beginner-friendly-composer/159431):
>
> Hi, I am working on a plugin at the moment that replaces the standard editor with a wysiwg editor. I think its easier for beginner users like myself and others. Here is a short video on how it works so far and what my plans are: [[Discourse.org - A more user friendly editor for beginners] ](https://www.youtube.com/watch?v=Mkb-igD7j7k) I think it will be finished in the next few months ( depending on my motivation smiley ) I would be interested if others are interested in using this as well. Thaaaanks slightly_smiling_face P…

---

<div class="post-metadata">

### Author: ![meglio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/meglio/32/71444_2.png) [@meglio](https://meta.discourse.org/u/meglio)
#### Post date: [October 20, 2021, 12:27pm UTC](https://meta.discourse.org/t/activate-monospace-font-inside-codeblocks-in-the-post-editor/206533/6 "2021-10-20T12:27:37Z")

</div>

This is great. However, it has been said multiple times that the Discourse team is not going to support a wysiwyg editor officially any time soon, and any non-official plugins in this area are very prone to issues and are hard to keep up to date. I wouldn’t use a non-official plugin in the community I’m launching.

… which is confirmed by the plugin’s author’s recent post:

> [@Discourse Basic Editor](https://meta.discourse.org/t/discourse-basic-editor/159431/54):
>
> they opted against it on philosophical grounds. You can search the forum if you are interested in the details. Their arguments are totally valid and I respect them. Thats why I am working on this.

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [October 20, 2021, 1:54pm UTC](https://meta.discourse.org/t/activate-monospace-font-inside-codeblocks-in-the-post-editor/206533/7 "2021-10-20T13:54:29Z")

</div>

> [@meglio](#):
>
> However, it has been said multiple times that the Discourse team is not going to support a wysiwyg editor officially any time soon

Which is why I pointed you to that plugin 🙂

---

<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: [October 20, 2021, 4:30pm UTC](https://meta.discourse.org/t/activate-monospace-font-inside-codeblocks-in-the-post-editor/206533/8 "2021-10-20T16:30:49Z")

</div>

Another work-around would be to just use CSS to make the composer be fixed-width font. If you have a code-heavy community, that would make sense.

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [October 20, 2021, 5:06pm UTC](https://meta.discourse.org/t/activate-monospace-font-inside-codeblocks-in-the-post-editor/206533/9 "2021-10-20T17:06:43Z")

</div>

Is it even possible to change the font-family in just a subset of a text area content ?

---

<div class="post-metadata">

### Author: ![Johani](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/johani/32/176920_2.png) [@Johani](https://meta.discourse.org/u/Johani)
#### Post date: [October 20, 2021, 6:27pm UTC](https://meta.discourse.org/t/activate-monospace-font-inside-codeblocks-in-the-post-editor/206533/10 "2021-10-20T18:27:20Z")

</div>

> [@meglio](#):
>
> For a medium-to-large code blocks

Why would you even type a medium-to-large code snippet in the composer? That’s what text editors are for.

Type your code in the text editor of your choice (Atom, Visual Studio, Sublime text…etc.), then copy it to the composer in Discourse.

---

<div class="post-metadata">

### Author: ![meglio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/meglio/32/71444_2.png) [@meglio](https://meta.discourse.org/u/meglio)
#### Post date: [October 20, 2021, 9:59pm UTC](https://meta.discourse.org/t/activate-monospace-font-inside-codeblocks-in-the-post-editor/206533/11 "2021-10-20T21:59:16Z")

</div>

Note that I’m not asking for opinions or advice about why I should not do what I want to do.

I’m asking for a technical solution to a very particular problem I described above.

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [October 20, 2021, 10:34pm UTC](https://meta.discourse.org/t/activate-monospace-font-inside-codeblocks-in-the-post-editor/206533/12 "2021-10-20T22:34:40Z")

</div>

> [@meglio](#):
>
> I’m asking for a technical solution to a very particular problem I described above.

I don’t think it’s possible to have a text area in a browser have multiple different font-family for different lines of content. So considering Discourse composer is text-area based, and this isn’t something we plan to change in the near future I don’t see how to address your feature request.

The best you could do is set the whole composer to use a mono spaced font using CSS. Maybe even restrict that change to a specific category or tag.

---

<div class="post-metadata">

### Author: ![meglio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/meglio/32/71444_2.png) [@meglio](https://meta.discourse.org/u/meglio)
#### Post date: [October 21, 2021, 5:08am UTC](https://meta.discourse.org/t/activate-monospace-font-inside-codeblocks-in-the-post-editor/206533/13 "2021-10-21T05:08:48Z")

</div>

> [@Falco](#):
>
> The best you could do is set the whole composer to use a mono spaced font using CSS.

Done that, thanks. Working great, same as when composing wiki entries in Github - they too seem to have mono font in the editor.
