mirror of
https://github.com/github/semantic.git
synced 2024-12-20 13:21:59 +03:00
Define Pretty1 for markup without orphans.
This commit is contained in:
parent
507b2e02ef
commit
143bbe1908
@ -5,8 +5,9 @@ import Algorithm
|
|||||||
import Data.Align.Generic
|
import Data.Align.Generic
|
||||||
import Data.ByteString (ByteString)
|
import Data.ByteString (ByteString)
|
||||||
import Data.Functor.Classes.Eq.Generic
|
import Data.Functor.Classes.Eq.Generic
|
||||||
import Data.Functor.Classes.Pretty.Orphans
|
import Data.Functor.Classes.Pretty
|
||||||
import Data.Functor.Classes.Show.Generic
|
import Data.Functor.Classes.Show.Generic
|
||||||
|
import Data.Text.Encoding (decodeUtf8With)
|
||||||
import GHC.Generics
|
import GHC.Generics
|
||||||
|
|
||||||
|
|
||||||
@ -62,11 +63,14 @@ instance Eq1 ThematicBreak where liftEq = genericLiftEq
|
|||||||
instance Show1 ThematicBreak where liftShowsPrec = genericLiftShowsPrec
|
instance Show1 ThematicBreak where liftShowsPrec = genericLiftShowsPrec
|
||||||
|
|
||||||
data HTMLBlock a = HTMLBlock ByteString
|
data HTMLBlock a = HTMLBlock ByteString
|
||||||
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Pretty1, Show, Traversable)
|
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Show, Traversable)
|
||||||
|
|
||||||
instance Eq1 HTMLBlock where liftEq = genericLiftEq
|
instance Eq1 HTMLBlock where liftEq = genericLiftEq
|
||||||
instance Show1 HTMLBlock where liftShowsPrec = genericLiftShowsPrec
|
instance Show1 HTMLBlock where liftShowsPrec = genericLiftShowsPrec
|
||||||
|
|
||||||
|
instance Pretty1 HTMLBlock where
|
||||||
|
liftPretty _ _ (HTMLBlock s) = pretty ("HTMLBlock" :: String) <+> prettyBytes s
|
||||||
|
|
||||||
newtype Table a = Table [a]
|
newtype Table a = Table [a]
|
||||||
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Pretty1, Show, Traversable)
|
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Pretty1, Show, Traversable)
|
||||||
|
|
||||||
@ -101,25 +105,34 @@ instance Eq1 Emphasis where liftEq = genericLiftEq
|
|||||||
instance Show1 Emphasis where liftShowsPrec = genericLiftShowsPrec
|
instance Show1 Emphasis where liftShowsPrec = genericLiftShowsPrec
|
||||||
|
|
||||||
newtype Text a = Text ByteString
|
newtype Text a = Text ByteString
|
||||||
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Pretty1, Show, Traversable)
|
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Show, Traversable)
|
||||||
|
|
||||||
instance Eq1 Text where liftEq = genericLiftEq
|
instance Eq1 Text where liftEq = genericLiftEq
|
||||||
instance Show1 Text where liftShowsPrec = genericLiftShowsPrec
|
instance Show1 Text where liftShowsPrec = genericLiftShowsPrec
|
||||||
|
|
||||||
|
instance Pretty1 Text where
|
||||||
|
liftPretty _ _ (Text s) = pretty ("Text" :: String) <+> prettyBytes s
|
||||||
|
|
||||||
data Link a = Link { linkURL :: ByteString, linkTitle :: Maybe ByteString }
|
data Link a = Link { linkURL :: ByteString, linkTitle :: Maybe ByteString }
|
||||||
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Pretty1, Show, Traversable)
|
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Show, Traversable)
|
||||||
|
|
||||||
instance Eq1 Link where liftEq = genericLiftEq
|
instance Eq1 Link where liftEq = genericLiftEq
|
||||||
instance Show1 Link where liftShowsPrec = genericLiftShowsPrec
|
instance Show1 Link where liftShowsPrec = genericLiftShowsPrec
|
||||||
|
|
||||||
|
instance Pretty1 Link where
|
||||||
|
liftPretty _ _ (Link u t) = pretty ("Link" :: String) <+> prettyBytes u <+> liftPretty prettyBytes (list . map prettyBytes) t
|
||||||
|
|
||||||
data Image a = Image { imageURL :: ByteString, imageTitle :: Maybe ByteString }
|
data Image a = Image { imageURL :: ByteString, imageTitle :: Maybe ByteString }
|
||||||
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Pretty1, Show, Traversable)
|
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Show, Traversable)
|
||||||
|
|
||||||
instance Eq1 Image where liftEq = genericLiftEq
|
instance Eq1 Image where liftEq = genericLiftEq
|
||||||
instance Show1 Image where liftShowsPrec = genericLiftShowsPrec
|
instance Show1 Image where liftShowsPrec = genericLiftShowsPrec
|
||||||
|
|
||||||
|
instance Pretty1 Image where
|
||||||
|
liftPretty _ _ (Image u t) = pretty ("Image" :: String) <+> prettyBytes u <+> liftPretty prettyBytes (list . map prettyBytes) t
|
||||||
|
|
||||||
data Code a = Code { codeLanguage :: Maybe ByteString, codeContent :: ByteString }
|
data Code a = Code { codeLanguage :: Maybe ByteString, codeContent :: ByteString }
|
||||||
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Pretty1, Show, Traversable)
|
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Show, Traversable)
|
||||||
|
|
||||||
instance Eq1 Code where liftEq = genericLiftEq
|
instance Eq1 Code where liftEq = genericLiftEq
|
||||||
instance Show1 Code where liftShowsPrec = genericLiftShowsPrec
|
instance Show1 Code where liftShowsPrec = genericLiftShowsPrec
|
||||||
@ -135,3 +148,6 @@ newtype Strikethrough a = Strikethrough [a]
|
|||||||
|
|
||||||
instance Eq1 Strikethrough where liftEq = genericLiftEq
|
instance Eq1 Strikethrough where liftEq = genericLiftEq
|
||||||
instance Show1 Strikethrough where liftShowsPrec = genericLiftShowsPrec
|
instance Show1 Strikethrough where liftShowsPrec = genericLiftShowsPrec
|
||||||
|
|
||||||
|
prettyBytes :: ByteString -> Doc ann
|
||||||
|
prettyBytes = pretty . decodeUtf8With (\ _ -> ('\xfffd' <$))
|
||||||
|
Loading…
Reference in New Issue
Block a user