Skip to content

Commit

Permalink
Remove Null constructor from Block.
Browse files Browse the repository at this point in the history
[API change]

Closes jgm#91.
  • Loading branch information
jgm authored and tarleb committed Jan 13, 2023
1 parent 6ac7177 commit 2388552
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 12 deletions.
2 changes: 0 additions & 2 deletions src/Text/Pandoc/Arbitrary.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand Down
4 changes: 1 addition & 3 deletions src/Text/Pandoc/Definition.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 0 additions & 2 deletions src/Text/Pandoc/Walk.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
--
Expand Down
6 changes: 1 addition & 5 deletions test/test-pandoc-types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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"}|])
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 2388552

Please sign in to comment.