From 2388552a49f6718f7f1f8a6ad45e20d88aa601f1 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Fri, 1 Oct 2021 15:17:13 -0700 Subject: [PATCH] Remove Null constructor from Block. [API change] Closes #91. --- src/Text/Pandoc/Arbitrary.hs | 2 -- src/Text/Pandoc/Definition.hs | 4 +--- src/Text/Pandoc/Walk.hs | 2 -- test/test-pandoc-types.hs | 6 +----- 4 files changed, 2 insertions(+), 12 deletions(-) diff --git a/src/Text/Pandoc/Arbitrary.hs b/src/Text/Pandoc/Arbitrary.hs index 8a743a3..74a5144 100644 --- a/src/Text/Pandoc/Arbitrary.hs +++ b/src/Text/Pandoc/Arbitrary.hs @@ -88,7 +88,6 @@ instance Arbitrary Blocks where flattenTableFoot ft flattenBlock (Figure _ capt blks) = flattenCaption capt <> blks flattenBlock (Div _ blks) = blks - flattenBlock Null = [] flattenCaption (Caption Nothing body) = body flattenCaption (Caption (Just ils) body) = Para ils : body @@ -211,7 +210,6 @@ instance Arbitrary Block where [Figure attr' capt blks | attr' <- shrinkAttr attr] shrink (Div attr blks) = (Div attr <$> shrinkBlockList blks) ++ (flip Div blks <$> shrinkAttr attr) - shrink Null = [] arbBlock :: Int -> Gen Block arbBlock n = frequency $ [ (10, Plain <$> arbInlines (n-1)) diff --git a/src/Text/Pandoc/Definition.hs b/src/Text/Pandoc/Definition.hs index ce55bb4..abc1c96 100644 --- a/src/Text/Pandoc/Definition.hs +++ b/src/Text/Pandoc/Definition.hs @@ -88,7 +88,7 @@ module Text.Pandoc.Definition ( Pandoc(..) import Data.Generics (Data, Typeable) import Data.Ord (comparing) -import Data.Aeson hiding (Null) +import Data.Aeson import Data.Aeson.TH (deriveJSON) import qualified Data.Aeson.Types as Aeson import qualified Data.Map as M @@ -305,8 +305,6 @@ data Block | Figure Attr Caption [Block] -- | Generic block container with attributes | Div Attr [Block] - -- | Nothing - | Null deriving (Eq, Ord, Read, Show, Typeable, Data, Generic) -- | Type of quotation marks to use in Quoted inline. diff --git a/src/Text/Pandoc/Walk.hs b/src/Text/Pandoc/Walk.hs index a6333fe..b60d78a 100644 --- a/src/Text/Pandoc/Walk.hs +++ b/src/Text/Pandoc/Walk.hs @@ -485,7 +485,6 @@ walkBlockM f (Div attr bs') = Div attr <$> walkM f bs' walkBlockM _ x@CodeBlock {} = return x walkBlockM _ x@RawBlock {} = return x walkBlockM _ HorizontalRule = return HorizontalRule -walkBlockM _ Null = return Null walkBlockM f (Table attr capt as hs bs fs) = do capt' <- walkM f capt hs' <- walkM f hs @@ -523,7 +522,6 @@ queryBlock f (Figure _ capt blks) = query f capt <> query f blks queryBlock f (Div _ bs) = query f bs -queryBlock _ Null = mempty -- | Helper method to walk to elements nested below @'MetaValue'@ nodes. -- diff --git a/test/test-pandoc-types.hs b/test/test-pandoc-types.hs index a1d79a0..882a683 100644 --- a/test/test-pandoc-types.hs +++ b/test/test-pandoc-types.hs @@ -149,7 +149,7 @@ t_metainlines = ( MetaInlines [Space, SoftBreak] ) t_metablocks :: (MetaValue, ByteString) -t_metablocks = ( MetaBlocks [Null,Null], [s|{"t":"MetaBlocks","c":[{"t":"Null"},{"t":"Null"}]}|]) +t_metablocks = ( MetaBlocks [HorizontalRule,HorizontalRule], [s|{"t":"MetaBlocks","c":[{"t":"HorizontalRule"},{"t":"HorizontalRule"}]}|]) t_singlequote :: (QuoteType, ByteString) t_singlequote = (SingleQuote, [s|{"t":"SingleQuote"}|]) @@ -464,9 +464,6 @@ t_div = ( Div ("id", ["kls"], [("k1", "v1"), ("k2", "v2")]) [Para [Str "Hello"]] , [s|{"t":"Div","c":[["id",["kls"],[["k1","v1"],["k2","v2"]]],[{"t":"Para","c":[{"t":"Str","c":"Hello"}]}]]}|] ) -t_null :: (Block, ByteString) -t_null = (Null, [s|{"t":"Null"}|]) - -- headers and rows are padded to a consistent number of -- cells in order to avoid syntax errors after conversion, see -- jgm/pandoc#4059. @@ -757,7 +754,6 @@ tests = , testEncodeDecode "Table" t_table , testEncodeDecode "Figure" t_figure , testEncodeDecode "Div" t_div - , testEncodeDecode "Null" t_null ] , testGroup "Table" [ testEncodeDecode "Row" t_row