mirror of
https://github.com/github/semantic.git
synced 2025-01-03 04:51:57 +03:00
commit
f6ff15290a
@ -66,6 +66,24 @@ data HTMLBlock a = HTMLBlock ByteString
|
||||
instance Eq1 HTMLBlock where liftEq = genericLiftEq
|
||||
instance Show1 HTMLBlock where liftShowsPrec = genericLiftShowsPrec
|
||||
|
||||
newtype Table a = Table [a]
|
||||
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Show, Traversable)
|
||||
|
||||
instance Eq1 Table where liftEq = genericLiftEq
|
||||
instance Show1 Table where liftShowsPrec = genericLiftShowsPrec
|
||||
|
||||
newtype TableRow a = TableRow [a]
|
||||
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Show, Traversable)
|
||||
|
||||
instance Eq1 TableRow where liftEq = genericLiftEq
|
||||
instance Show1 TableRow where liftShowsPrec = genericLiftShowsPrec
|
||||
|
||||
newtype TableCell a = TableCell [a]
|
||||
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Show, Traversable)
|
||||
|
||||
instance Eq1 TableCell where liftEq = genericLiftEq
|
||||
instance Show1 TableCell where liftShowsPrec = genericLiftShowsPrec
|
||||
|
||||
|
||||
-- Inline elements
|
||||
|
||||
@ -110,3 +128,9 @@ data LineBreak a = LineBreak
|
||||
|
||||
instance Eq1 LineBreak where liftEq = genericLiftEq
|
||||
instance Show1 LineBreak where liftShowsPrec = genericLiftShowsPrec
|
||||
|
||||
newtype Strikethrough a = Strikethrough [a]
|
||||
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Show, Traversable)
|
||||
|
||||
instance Eq1 Strikethrough where liftEq = genericLiftEq
|
||||
instance Show1 Strikethrough where liftShowsPrec = genericLiftShowsPrec
|
||||
|
@ -33,6 +33,9 @@ type Syntax =
|
||||
, Markup.Section
|
||||
, Markup.ThematicBreak
|
||||
, Markup.UnorderedList
|
||||
, Markup.Table
|
||||
, Markup.TableRow
|
||||
, Markup.TableCell
|
||||
-- Inline elements
|
||||
, Markup.Code
|
||||
, Markup.Emphasis
|
||||
@ -41,6 +44,7 @@ type Syntax =
|
||||
, Markup.Link
|
||||
, Markup.Strong
|
||||
, Markup.Text
|
||||
, Markup.Strikethrough
|
||||
-- Assignment errors; cmark does not provide parse errors.
|
||||
, Syntax.Error
|
||||
, []
|
||||
@ -57,7 +61,7 @@ assignment = makeTerm <$> symbol Document <*> children (Markup.Document <$> many
|
||||
-- Block elements
|
||||
|
||||
blockElement :: Assignment
|
||||
blockElement = paragraph <|> list <|> blockQuote <|> codeBlock <|> thematicBreak <|> htmlBlock <|> section
|
||||
blockElement = paragraph <|> list <|> blockQuote <|> codeBlock <|> thematicBreak <|> htmlBlock <|> section <|> table
|
||||
|
||||
paragraph :: Assignment
|
||||
paragraph = makeTerm <$> symbol Paragraph <*> children (Markup.Paragraph <$> many inlineElement)
|
||||
@ -90,11 +94,19 @@ thematicBreak = makeTerm <$> symbol ThematicBreak <*> pure Markup.ThematicBreak
|
||||
htmlBlock :: Assignment
|
||||
htmlBlock = makeTerm <$> symbol HTMLBlock <*> (Markup.HTMLBlock <$> source)
|
||||
|
||||
table :: Assignment
|
||||
table = makeTerm <$> symbol Table <*> children (Markup.Table <$> many tableRow)
|
||||
|
||||
tableRow :: Assignment
|
||||
tableRow = makeTerm <$> symbol TableRow <*> children (Markup.TableRow <$> many tableCell)
|
||||
|
||||
tableCell :: Assignment
|
||||
tableCell = makeTerm <$> symbol TableCell <*> children (Markup.TableCell <$> many inlineElement)
|
||||
|
||||
-- Inline elements
|
||||
|
||||
inlineElement :: Assignment
|
||||
inlineElement = strong <|> emphasis <|> text <|> link <|> htmlInline <|> image <|> code <|> lineBreak <|> softBreak
|
||||
inlineElement = strong <|> emphasis <|> strikethrough <|> text <|> link <|> htmlInline <|> image <|> code <|> lineBreak <|> softBreak
|
||||
|
||||
strong :: Assignment
|
||||
strong = makeTerm <$> symbol Strong <*> children (Markup.Strong <$> many inlineElement)
|
||||
@ -102,6 +114,9 @@ strong = makeTerm <$> symbol Strong <*> children (Markup.Strong <$> many inlineE
|
||||
emphasis :: Assignment
|
||||
emphasis = makeTerm <$> symbol Emphasis <*> children (Markup.Emphasis <$> many inlineElement)
|
||||
|
||||
strikethrough :: Assignment
|
||||
strikethrough = makeTerm <$> symbol Strikethrough <*> children (Markup.Strikethrough <$> many inlineElement)
|
||||
|
||||
text :: Assignment
|
||||
text = makeTerm <$> symbol Text <*> (Markup.Text <$> source)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user