diff --git a/CHANGELOG.md b/CHANGELOG.md
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,15 @@
+## v0.3.1.1 (2023-07-10)
+
+  - Update upper bounds to allow:
+      - `base-4.18`
+      - `text-2.0`
+      - `pandoc-types-1.23`
+      - `linear-1.22`
+      - `diagrams-core-1.5`
+      - `hashable-1.4`
+      - `optparse-applicative-0.18`
+  - Test up through GHC 9.6
+
 ## v0.3.1 (2020-06-11)
 
   - New `-a` option for outputting an absolute path
diff --git a/diagrams-pandoc.cabal b/diagrams-pandoc.cabal
--- a/diagrams-pandoc.cabal
+++ b/diagrams-pandoc.cabal
@@ -1,5 +1,5 @@
 name:                diagrams-pandoc
-version:             0.3.1
+version:             0.3.1.1
 synopsis:            A Pandoc filter to express diagrams inline using the Haskell EDSL _Diagrams_
 description: 'diagrams-pandoc' replaces appropriately marked code
     blocks in pandoc input with images.  The code blocks are compiled
@@ -16,24 +16,24 @@
 Bug-reports:         http://github.com/diagrams/diagrams-pandoc/issues
 Extra-source-files:  README.md, CHANGELOG.md
 cabal-version:       >=1.10
-Tested-with:         GHC ==8.2.2 || ==8.4.3 || ==8.6.5 || ==8.8.3 || ==8.10.1
+Tested-with:         GHC ==8.8.4 || ==8.10.7 || ==9.0.2 || ==9.2.7 || ==9.4.5 || ==9.6.1
 Source-repository head
   type:     git
   location: http://github.com/diagrams/diagrams-pandoc.git
 
 library
-  build-depends:       base >= 4.6 && < 4.15,
-                       text >= 1.2 && < 1.3,
-                       pandoc-types >= 1.20 && < 1.21,
+  build-depends:       base >= 4.6 && < 4.19,
+                       text >= 1.2 && < 2.1,
+                       pandoc-types >= 1.20 && < 1.24,
                        diagrams-lib >= 1.3 && < 1.5,
-                       linear >= 1.10 && < 1.21,
+                       linear >= 1.10 && < 1.23,
                        diagrams-builder >= 0.7 && < 0.9,
                        diagrams-cairo >= 1.3 && < 1.5,
                        directory >= 1.2 && < 1.4,
                        filepath >= 1.3 && < 1.5,
                        diagrams-svg >= 1.4 && < 1.5,
-                       diagrams-core >= 1.4 && < 1.5,
-                       hashable >= 1.2 && < 1.4,
+                       diagrams-core >= 1.4 && < 1.6,
+                       hashable >= 1.2 && < 1.5,
                        svg-builder >= 0.1 && < 0.2
   exposed-modules: Text.Pandoc.Diagrams
   default-language: Haskell2010
@@ -43,15 +43,15 @@
 executable diagrams-pandoc
   main-is:             src/Main.hs
   other-extensions:    CPP
-  build-depends:       base >= 4.6 && < 4.15,
-                       text >= 1.2 && < 1.3,
-                       pandoc-types >= 1.20 && < 1.21,
+  build-depends:       base >= 4.6 && < 4.19,
+                       text >= 1.2 && < 2.1,
+                       pandoc-types >= 1.20 && < 1.24,
                        diagrams-lib >= 1.3 && < 1.5,
-                       linear >= 1.10 && < 1.21,
+                       linear >= 1.10 && < 1.23,
                        diagrams-builder >= 0.7 && < 0.9,
                        diagrams-cairo >= 1.3 && < 1.5,
                        directory >= 1.2 && < 1.4,
                        filepath >= 1.3 && < 1.5,
                        diagrams-pandoc,
-                       optparse-applicative >= 0.11 && < 0.16
+                       optparse-applicative >= 0.11 && < 0.19
   default-language:    Haskell2010
diff --git a/src/Text/Pandoc/Diagrams.hs b/src/Text/Pandoc/Diagrams.hs
--- a/src/Text/Pandoc/Diagrams.hs
+++ b/src/Text/Pandoc/Diagrams.hs
@@ -27,9 +27,10 @@
 import           System.FilePath                 (pathSeparator, (<.>), (</>))
 import           System.IO
 import           Text.Pandoc.Definition
+import Data.Maybe (maybeToList)
 
 backendExt :: Opts -> String
-backendExt Opts {_backend = SVG, ..} = "svg"
+backendExt Opts {_backend = SVG } = "svg"
 backendExt Opts {_backend = Cairo, ..} = case _outFormat of
   "beamer" -> "pdf"
   "latex"  -> "pdf"
@@ -56,17 +57,17 @@
 insertDiagrams :: Opts -> Block -> IO [Block]
 insertDiagrams opts@Opts{..} (CodeBlock (ident, classes, attrs) code)
     | "diagram-haskell" `elem` classes = do
-      i <- img
+      i <- maybeToList <$> img
       return $ case echo of
-        Above -> [bl', i]
-        Below -> [i, bl']
-    | "diagram" `elem` classes = (:[]) <$> img
+        Above -> bl' : i
+        Below -> i <> [bl']
+    | "diagram" `elem` classes = maybeToList <$> img
   where
     img = do
         d <- compileDiagram opts attrs code
         return $ case d of
-            Left _err     -> Null  -- TODO log an error here
-            Right imgName -> Plain
+            Left _err     -> Nothing  -- TODO log an error here
+            Right imgName -> Just $ Para
               [Image ("",[],[]) []
                  (if _absolutePath then T.cons pathSeparator imgName else imgName,"")
               ] -- no alt text, no title
