diff --git a/briar-desktop/src/main/kotlin/org/briarproject/briar/desktop/blog/HtmlText.kt b/briar-desktop/src/main/kotlin/org/briarproject/briar/desktop/blog/HtmlText.kt
index 3e677fba077f4f08543095f51a6a301b1d32d9a9..706668e7645ad1c03f3a46fa594ec88794056336 100644
--- a/briar-desktop/src/main/kotlin/org/briarproject/briar/desktop/blog/HtmlText.kt
+++ b/briar-desktop/src/main/kotlin/org/briarproject/briar/desktop/blog/HtmlText.kt
@@ -255,6 +255,14 @@ fun HtmlText(
                 popIndent()
             }
 
+            fun startPre() {
+                pushIndent(20.sp)
+            }
+
+            fun endPre() {
+                popIndent()
+            }
+
             fun addLink(node: Element) {
                 val start = cursorPosition
                 val end = start + node.text().length
@@ -375,6 +383,7 @@ fun HtmlText(
                                 "br" -> appendAndUpdateCursor("\n")
                                 "blockquote" -> startBlockQuote()
                                 "p" -> startParagraph()
+                                "pre" -> startPre()
                                 // else -> throw Exception("Unsupported tag '${node.tagName()}'")
                             }
                         }
@@ -405,6 +414,7 @@ fun HtmlText(
 
                             "p" -> endParagraph()
                             "blockquote" -> endBlockQuote()
+                            "pre" -> endPre()
                         }
                     }
                 }
diff --git a/briar-desktop/src/test/kotlin/org/briarproject/briar/desktop/blog/TestCode.kt b/briar-desktop/src/test/kotlin/org/briarproject/briar/desktop/blog/TestCode.kt
new file mode 100644
index 0000000000000000000000000000000000000000..2a162e1e65f923f678bb7dbe0d6993e5f0ac626a
--- /dev/null
+++ b/briar-desktop/src/test/kotlin/org/briarproject/briar/desktop/blog/TestCode.kt
@@ -0,0 +1,50 @@
+/*
+ * Briar Desktop
+ * Copyright (C) 2023 The Briar Project
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package org.briarproject.briar.desktop.blog
+
+import org.intellij.lang.annotations.Language
+import org.jetbrains.annotations.NonNls
+
+fun main() = testHtml(testHtml)
+
+@NonNls
+@Language("HTML")
+private val testHtml = """
+        <h1>Code blocks</h1>
+        This example contains a code block. It starts right here:
+        <pre><code>
+        $ ls -lrth /
+        drwxr-xr-x  14 root root 4,0K Jan  4  2023 usr
+        drwxr-xr-x   2 root root 4,0K Jan  4  2023 srv
+        drwxr-xr-x  11 root root 4,0K Jan  4  2023 var
+        drwx------   2 root root  16K Apr  7  2023 lost+found
+        </code></pre>
+        And here's some more regular text.
+        <p>Then there's more text and another code block:</p>
+        <pre>
+        drwxr-xr-x   5 root root 4,0K Nov 17  2023 boot
+        drwx------   8 root root 4,0K Mar 29 14:27 root
+        drwxr-xr-x  10 root root 4,0K Apr 13 14:44 opt
+        dr-xr-xr-x 533 root root    0 Apr 23 11:41 proc
+        dr-xr-xr-x  13 root root    0 Apr 23 11:41 sys
+        drwxr-xr-x   4 root root 4,0K Apr 26 15:47 home
+        drwxr-xr-x  23 root root 4,9K Aug 13 10:10 dev
+        </pre>
+        that's it.
+""".trimIndent()