diff --git a/Changelog.md b/Changelog.md
--- a/Changelog.md
+++ b/Changelog.md
@@ -1,3 +1,7 @@
+### 0.3.0.0
+
+- Compatibility with Pandoc *3.0*.
+
 ### 0.2.4.0
 
 - More granular Cabal build plan which lets skipping unneeded dependencies.
diff --git a/LICENSE b/LICENSE
--- a/LICENSE
+++ b/LICENSE
@@ -1,7 +1,7 @@
 The following license covers this documentation, and the source code, except
 where otherwise indicated.
 
-Copyright 2016-2022, Alexey Radkov. All rights reserved.
+Copyright 2016-2023, Alexey Radkov. All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are met:
diff --git a/pandoc-stylefrommeta.cabal b/pandoc-stylefrommeta.cabal
--- a/pandoc-stylefrommeta.cabal
+++ b/pandoc-stylefrommeta.cabal
@@ -1,5 +1,5 @@
 name:                    pandoc-stylefrommeta
-version:                 0.2.4.0
+version:                 0.3.0.0
 synopsis:                Pandoc filter to customize links, images and paragraphs
 description:             Pandoc filter to customize links, images and paragraphs
         (with restrictions). Styles are read from the metadata of the document:
@@ -11,7 +11,7 @@
 author:                  Alexey Radkov <alexey.radkov@gmail.com>
 maintainer:              Alexey Radkov <alexey.radkov@gmail.com>
 stability:               stable
-copyright:               2016-2022 Alexey Radkov
+copyright:               2016-2023 Alexey Radkov
 category:                Text
 build-type:              Simple
 cabal-version:           1.20
@@ -47,6 +47,5 @@
   else
     build-depends:       extra
 
-  default-extensions:    CPP
   main-is:               styleFromMeta.hs
 
diff --git a/styleFromMeta.hs b/styleFromMeta.hs
--- a/styleFromMeta.hs
+++ b/styleFromMeta.hs
@@ -1,4 +1,4 @@
-{-# LANGUAGE ViewPatterns, PatternGuards, PatternSynonyms #-}
+{-# LANGUAGE CPP, ViewPatterns, PatternGuards, PatternSynonyms #-}
 
 #if MIN_VERSION_pandoc_types(1,20,0)
 {-# LANGUAGE OverloadedStrings #-}
@@ -28,6 +28,10 @@
 import           Text.Pandoc.Error (PandocError)
 #endif
 
+#if MIN_VERSION_pandoc(3,0,0)
+import           Text.Pandoc.Format (FlavoredFormat (..))
+#endif
+
 #if MIN_VERSION_pandoc_types(1,20,0)
 type STRING = T.Text
 rEPLACE :: STRING -> STRING -> STRING -> STRING
@@ -58,6 +62,20 @@
 rUNGETWRITER = id
 #endif
 
+#if MIN_VERSION_pandoc(3,0,0)
+tOWRITERFORMAT :: Format -> FlavoredFormat
+tOWRITERFORMAT (Format "tex") = FlavoredFormat "latex" mempty
+tOWRITERFORMAT (Format fmt)   = FlavoredFormat fmt mempty
+tOFORMATNAME :: FlavoredFormat -> STRING
+tOFORMATNAME = formatName
+#else
+tOWRITERFORMAT :: Format -> STRING
+tOWRITERFORMAT (Format "tex") = "latex"
+tOWRITERFORMAT (Format fmt)   = fmt
+tOFORMATNAME :: STRING -> STRING
+tOFORMATNAME = id
+#endif
+
 #if MIN_TOOL_VERSION_ghc(7,10,1)
 pattern Style :: STRING -> Inline
 #endif
@@ -164,11 +182,11 @@
 
 renderBlocks :: Format -> [Block] -> STRING
 renderBlocks fm p =
-    let fmt = toWriterFormat fm
+    let fmt = tOWRITERFORMAT fm
         writer = getWriter fmt
         doc = Pandoc (Meta M.empty) p
     in case rUNGETWRITER writer of
-        Left _ -> error $ "Unknown format " ++ tOSTRING fmt
+        Left _ -> error $ "Unknown format " ++ tOSTRING (tOFORMATNAME fmt)
 #if MIN_VERSION_pandoc(2,0,0)
         Right (TextWriter w, _) ->
             case runPure $ w def doc of
@@ -186,10 +204,6 @@
 
 renderInlines :: Format -> [Inline] -> STRING
 renderInlines fm p = renderBlocks fm [Plain p]
-
-toWriterFormat :: Format -> STRING
-toWriterFormat (Format "tex") = "latex"
-toWriterFormat (Format fmt)   = fmt
 
 main :: IO ()
 main = toJSONFilter styleFromMeta
