diff --git a/CHANGELOG.md b/CHANGELOG.md
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
 # Revision history for scripths
 
+## 0.2.0.2 -- 2026-03-14
+
+* Stop adding extra white space to code cells.
+
 ## 0.2.0.1 -- 2026-03-01
 
 * Fix issue with SVG mime type.
diff --git a/scripths.cabal b/scripths.cabal
--- a/scripths.cabal
+++ b/scripths.cabal
@@ -1,6 +1,6 @@
 cabal-version:      3.0
 name:               scripths
-version:            0.2.0.1
+version:            0.2.0.2
 synopsis:           GHCi scripts for standalone execution and Markdown documentation.
 description:        GHCi scripts for standalone execution (with dependency resolution) and Markdown documentation (produces inline output).
 homepage:           https://www.datahaskell.org/
diff --git a/src/ScriptHs/Markdown.hs b/src/ScriptHs/Markdown.hs
--- a/src/ScriptHs/Markdown.hs
+++ b/src/ScriptHs/Markdown.hs
@@ -39,7 +39,7 @@
         let
             prose = T.unlines acc
             (codeLines, rest') = fmap (drop 1) (break ((== fence) . T.strip) rest)
-            (output, rest'') = case (dropWhile ((== "") . T.strip) rest') of
+            (output, rest'') = case dropWhile ((== "") . T.strip) rest' of
                 (x : xs) ->
                     if not (T.isPrefixOf "> <!-- sabela:mime" x)
                         then (Nothing, rest')
@@ -63,12 +63,8 @@
 
 fenceCodeSegment :: Text -> Text -> Text
 fenceCodeSegment lang output
-    | T.null output = ""
-    | otherwise = T.unlines ["", fence <> lang, ensureNewLine output, fence, ""]
-  where
-    ensureNewLine t
-        | "\n" `T.isSuffixOf` t = t
-        | otherwise = T.snoc t '\n'
+    | T.null (T.strip output) = ""
+    | otherwise = T.unlines ["", fence <> lang, T.stripEnd output, fence, ""]
 
 reassemble :: [Segment] -> Text
 reassemble = T.concat . map renderSegment
@@ -81,7 +77,7 @@
 blockQuote :: CodeOutput -> Text
 blockQuote (CodeOutput mimeType t) =
     let
-        ls = ["<!-- sabela:mime " <> mimeIndicator mimeType <> " -->"] ++ T.lines t
+        ls = ("<!-- sabela:mime " <> mimeIndicator mimeType <> " -->") : T.lines t
         trimmed = reverse $ dropWhile T.null $ reverse ls
         quoted = T.unlines $ map (\l -> if T.null l then "> " else "> " <> l) trimmed
      in
