From b151b76cbe68375061cb1360b1150d6943c418ce Mon Sep 17 00:00:00 2001 From: Owen Jacobson Date: Thu, 8 May 2025 22:27:56 -0400 Subject: Prevent double-indenting of the first line of a code block. For reasons known only to the author, marked emits code blocks as
your code here
Inline code, on the other hand, is emitted as

Non-code text code text non-code text.

In d15bfb2b9a4872cba99bc966fe5c9c4399b3323c, we added a rule to give inline code nicer leading and trailing space, so that the borders don't directly abut the letters. However, we neglected to consider code blocks; the padding added for inline code also affected their first line, pushing it in slightly. This removes the padding from `` when it is a direct child of a `
`, as per the markup emitted by marked.
---
 ui/styles/messages.css | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/ui/styles/messages.css b/ui/styles/messages.css
index 26fc779..6b451bc 100644
--- a/ui/styles/messages.css
+++ b/ui/styles/messages.css
@@ -175,6 +175,12 @@
 }
 
 .message-body code {
+  /*
+   * Inline code (`like this`).
+   *
+   * Rules added here will also affect code blocks (```like this```) unless
+   * cancelled out in `.message-body pre > code`.
+   */
   white-space: pre-wrap;
   border: 1px solid #312e81;
   border-radius: 0.25rem;
@@ -183,8 +189,14 @@
 }
 
 .message-body pre > code {
+  /*
+   * Code blocks. Must also cancel out rules from inline code (in `.message-body code`), unless
+   * they should affect code blocks as well.
+   */
   white-space: none;
   border: none;
+  padding: 0;
+  margin: 0;
 }
 
 /* For rendered message bodies: */
-- 
cgit v1.2.3