diff --git a/src/Data/Syntax/Markup.hs b/src/Data/Syntax/Markup.hs index be49ebeb7..8e8de14f9 100644 --- a/src/Data/Syntax/Markup.hs +++ b/src/Data/Syntax/Markup.hs @@ -79,3 +79,9 @@ data Image a = Image { imageURL :: ByteString, imageTitle :: ByteString } instance Eq1 Image where liftEq = genericLiftEq instance Show1 Image where liftShowsPrec = genericLiftShowsPrec + +data Code a = Code ByteString + deriving (Eq, Foldable, Functor, GAlign, Generic1, Show, Traversable) + +instance Eq1 Code where liftEq = genericLiftEq +instance Show1 Code where liftShowsPrec = genericLiftShowsPrec diff --git a/src/Language/Markdown/Syntax.hs b/src/Language/Markdown/Syntax.hs index c026f7f28..27e131825 100644 --- a/src/Language/Markdown/Syntax.hs +++ b/src/Language/Markdown/Syntax.hs @@ -28,6 +28,7 @@ type Syntax = , Markup.Paragraph , Markup.UnorderedList -- Inline elements + , Markup.Code , Markup.Emphasis , Markup.Image , Markup.Link @@ -72,7 +73,7 @@ blockQuote = makeTerm <$> symbol BlockQuote <*> children (Markup.BlockQuote <$> -- Inline elements inlineElement :: Assignment -inlineElement = strong <|> emphasis <|> text <|> link <|> image +inlineElement = strong <|> emphasis <|> text <|> link <|> image <|> code strong :: Assignment strong = makeTerm <$> symbol Strong <*> children (Markup.Strong <$> many inlineElement) @@ -89,6 +90,9 @@ link = makeTerm <$> symbol Link <*> (uncurry Markup.Link <$> project (\ (((CMark image :: Assignment image = makeTerm <$> symbol Image <*> (uncurry Markup.Image <$> project (\ (((CMark.IMAGE url title) :. _) :< _) -> (toS url, toS title))) <* source +code :: Assignment +code = makeTerm <$> symbol Code <*> (Markup.Code <$> source) + -- Implementation details