# Code (blocks) improvements

**URL:** <https://forum.ghost.org/t/code-blocks-improvements/24253>\
**Category:** Developer help\
**Created:** [July 17, 2021, 9:33pm UTC](https://forum.ghost.org/t/code-blocks-improvements/24253 "2021-07-17T21:33:20Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![binaryanomaly](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/binaryanomaly/32/12419_2.png) [@binaryanomaly](https://forum.ghost.org/u/binaryanomaly)\
**Post date:** [July 17, 2021, 9:33pm UTC](https://forum.ghost.org/t/code-blocks-improvements/24253/1 "2021-07-17T21:33:20Z")

</div>

Hi,

I’m having issues with inline code in ghost.

Inline code seems not to be recognized at all using the `code` syntax. The keyboard shortcut (Ctrl/⌘ + Shift + K) seems also not to work, bringing up the Link dialog on my mac in Firefox? ([Using the Editor in Ghost - FAQ](https://ghost.org/help/using-the-editor/#markdown-reference))

Inline code and code blocks are also not available from the context menu if text is selected? That would’ve helped and would be nice and consistent.

And yes, better syntax highlighting would be nice. The prism.js approach seems not to work very well here.

Thanks for improving.

PS: On Ghost Pro so likely not a ghost setup issue.

---

<div class="post-metadata">

**Author:** ![binaryanomaly](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/binaryanomaly/32/12419_2.png) [@binaryanomaly](https://forum.ghost.org/u/binaryanomaly)\
**Post date:** [July 18, 2021, 3:12pm UTC](https://forum.ghost.org/t/code-blocks-improvements/24253/2 "2021-07-18T15:12:24Z")

</div>

I have to add that sometimes using ` in posts destroys the existing code block formatting in posts and changes it to inline code. This is weird and has then to be cumbersomely changed back manually to code blocks.

I think there are definitely a few things wrong with inline code and code block formatting… ☹

Edit:  
[@Ghost.org](https://forum.ghost.org/groups/ghost.org) Where should I report such things if not here?

---

<div class="post-metadata">

**Author:** ![Kevin](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/kevin/32/32_2.png) [@Kevin](https://forum.ghost.org/u/Kevin)\
**Post date:** [July 18, 2021, 10:34pm UTC](https://forum.ghost.org/t/code-blocks-improvements/24253/3 "2021-07-18T22:34:27Z")

</div>

Are you using a non-English keyboard layout?

---

<div class="post-metadata">

**Author:** ![binaryanomaly](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/binaryanomaly/32/12419_2.png) [@binaryanomaly](https://forum.ghost.org/u/binaryanomaly)\
**Post date:** [July 19, 2021, 4:39am UTC](https://forum.ghost.org/t/code-blocks-improvements/24253/4 "2021-07-19T04:39:21Z")

</div>

Hi Kevin, yes I do. That can be an explanation for the keyboard shortcut difficulties but everything else should still work, shouldn’t it?

---

<div class="post-metadata">

**Author:** ![Kevin](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/kevin/32/32_2.png) [@Kevin](https://forum.ghost.org/u/Kevin)\
**Post date:** [July 19, 2021, 8:52am UTC](https://forum.ghost.org/t/code-blocks-improvements/24253/5 "2021-07-19T08:52:39Z")

</div>

> [@binaryanomaly](#):
>
> keyboard shortcut difficulties but everything else should still work, shouldn’t it?

It’s mostly based on key events rather than the contents so certain keyboard layouts with dead keys for characters used in the text expansions can cause problems.

I’ve tested everything you’ve reported using Firefox on Mac using an `en` keyboard layout and haven’t been able to reproduce 🤔 Do you have the same issues in other browsers or when you have all extensions disabled?

> [@binaryanomaly](#):
>
> And yes, better syntax highlighting would be nice. The prism.js approach seems not to work very well here.

Syntax highlighting is predominantly a theme-level concern, you can change it to work however you like when displaying code on your site 🙂

Ghost itself is not a code editor and it’s a niche application for Ghost’s user base so syntax highlighting support is minimal, using the base highlighting provided by the CodeMirror editor not prism.js. For the most-used languages the syntax highlighting will adjust based on the language specified in the code card.

---

<div class="post-metadata">

**Author:** ![binaryanomaly](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/binaryanomaly/32/12419_2.png) [@binaryanomaly](https://forum.ghost.org/u/binaryanomaly)\
**Post date:** [July 19, 2021, 11:51am UTC](https://forum.ghost.org/t/code-blocks-improvements/24253/6 "2021-07-19T11:51:33Z")

</div>

Just tested in Safari:

1. The Keyboard shortcut for inline code formatting works ✅
2. Formatting text as `inline code` with back-ticks does also not work ❌
3. Creating code blocks with 3 back-ticks sometimes works and sometimes ends up with just displaying 4 back-ticks. That works better in FF. 〰

Keyboard Layout is swiss german.

---

<div class="post-metadata">

**Author:** ![Kevin](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/kevin/32/32_2.png) [@Kevin](https://forum.ghost.org/u/Kevin)\
**Post date:** [July 19, 2021, 12:06pm UTC](https://forum.ghost.org/t/code-blocks-improvements/24253/7 "2021-07-19T12:06:20Z")

</div>

There are issues with German keyboards because the backtick is behind a dead key. Some attempts have been made to fix it but browsers don’t (or didn’t) expose the events in question very cleanly so it’s a bit hacky, works differently across browsers/OS, and the behaviour may have changed since the fix was implemented.

Issues:

- [Editor: Backticks using German keyboard doesn't trigger code formatting · Issue #9825 · TryGhost/Ghost · GitHub](https://github.com/TryGhost/Ghost/issues/9825)
- [Inline Code Wrapping Using Backticks Stopped Working in 4.0 · Issue #12789 · TryGhost/Ghost · GitHub](https://github.com/TryGhost/Ghost/issues/12789)

---

<div class="post-metadata">

**Author:** ![Kevin](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/kevin/32/32_2.png) [@Kevin](https://forum.ghost.org/u/Kevin)\
**Post date:** [July 19, 2021, 12:10pm UTC](https://forum.ghost.org/t/code-blocks-improvements/24253/8 "2021-07-19T12:10:12Z")

</div>

One thing that could help with diagnosis/potential fix would be a screenshot of the output from this [keyboard event viewer](https://w3c.github.io/uievents/tools/key-event-viewer.html) when you type a backtick followed by a space (edit: plus two consecutive backticks as a separate screenshot)

---

<div class="post-metadata">

**Author:** ![binaryanomaly](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/binaryanomaly/32/12419_2.png) [@binaryanomaly](https://forum.ghost.org/u/binaryanomaly)\
**Post date:** [July 19, 2021, 2:10pm UTC](https://forum.ghost.org/t/code-blocks-improvements/24253/9 "2021-07-19T14:10:25Z")

</div>

Tbh I don’t even mind so much that Keyboard Shortcuts or Text formatting doesn’t work.

It would be enough if I could reliably use it from the context menu when selecting text. But that functionality is currently absent.

Firefox on mac

 ![FF](https://us1.discourse-cdn.com/flex015/uploads/ghost2/original/2X/7/748156af0ee7abc606f5e0c648ca6f0130ff68e5.png)

Safari

 ![Safari](https://us1.discourse-cdn.com/flex015/uploads/ghost2/original/2X/1/1de677d8d70f5fe1c8c6d2300b2a9b007a969bdb.png)

---

<div class="post-metadata">

**Author:** ![binaryanomaly](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/binaryanomaly/32/12419_2.png) [@binaryanomaly](https://forum.ghost.org/u/binaryanomaly)\
**Post date:** [July 19, 2021, 3:29pm UTC](https://forum.ghost.org/t/code-blocks-improvements/24253/10 "2021-07-19T15:29:29Z")

</div>

2 backticks

FF

 ![FF2](https://us1.discourse-cdn.com/flex015/uploads/ghost2/original/2X/b/b3e1beea3604eb153f1e598688084c3a638a91f3.png)

Safari

 ![safari2](https://us1.discourse-cdn.com/flex015/uploads/ghost2/original/2X/3/330fd14e962c5b42e24a4e15ef4f1aba88aa5cb5.png)
