preliminary djot changes to IR made
This commit is contained in:
parent
c90d2e45b8
commit
24606a9204
1 changed files with 102 additions and 16 deletions
118
src/IR.hs
118
src/IR.hs
|
|
@ -6,13 +6,23 @@ newtype Document = Doc [Element]
|
||||||
deriving (Show)
|
deriving (Show)
|
||||||
|
|
||||||
data Element
|
data Element
|
||||||
= Heading Heading
|
= Heading Heading Attrs
|
||||||
| Code Code
|
| Code Code
|
||||||
| BlockQuote BlockQuote
|
| BlockQuote BlockQuote
|
||||||
| List List
|
| List List Attrs
|
||||||
| HTML HTML
|
| -- Markdown only, DJOT will produce a RawBlock with an html type
|
||||||
| Paragraph Paragraph
|
HTML HTML
|
||||||
|
| Paragraph Paragraph Attrs
|
||||||
| HorizontalRule
|
| HorizontalRule
|
||||||
|
| -- TODO
|
||||||
|
Table Table Attrs
|
||||||
|
| -- Djot :::
|
||||||
|
Container [Element] Attrs
|
||||||
|
| -- TODO
|
||||||
|
Footnote Footnote Attrs
|
||||||
|
| DescriptionList DescriptionList Attrs
|
||||||
|
| RawBlock RawBlock Attrs
|
||||||
|
| TaskList TaskList Attrs
|
||||||
deriving (Show)
|
deriving (Show)
|
||||||
|
|
||||||
-- Removed: BlankLine
|
-- Removed: BlankLine
|
||||||
|
|
@ -29,15 +39,15 @@ data Code = C
|
||||||
}
|
}
|
||||||
deriving (Show)
|
deriving (Show)
|
||||||
|
|
||||||
data BlockQuote = Q [InlineText] deriving (Show)
|
data BlockQuote = Q [Element] deriving (Show)
|
||||||
|
|
||||||
data ListItem = LI
|
data ListItem = LI
|
||||||
{ content :: [InlineText], -- Flatten continuations into here
|
{ content :: [Element], -- Flatten continuations into here
|
||||||
child :: Maybe List
|
child :: Maybe List
|
||||||
}
|
}
|
||||||
deriving (Show)
|
deriving (Show)
|
||||||
|
|
||||||
data ListType = Ordered | Unordered deriving (Show)
|
data ListType = Ordered {start_number :: Text, style :: Text} | Unordered {style :: Text} deriving (Show)
|
||||||
|
|
||||||
data List = L
|
data List = L
|
||||||
{ list_type :: ListType,
|
{ list_type :: ListType,
|
||||||
|
|
@ -45,7 +55,7 @@ data List = L
|
||||||
}
|
}
|
||||||
deriving (Show)
|
deriving (Show)
|
||||||
|
|
||||||
data HTML
|
newtype HTML
|
||||||
= HTMLTag
|
= HTMLTag
|
||||||
{ html_content :: Text
|
{ html_content :: Text
|
||||||
}
|
}
|
||||||
|
|
@ -54,23 +64,99 @@ data HTML
|
||||||
newtype Paragraph = P [InlineText] deriving (Show)
|
newtype Paragraph = P [InlineText] deriving (Show)
|
||||||
|
|
||||||
data InlineText
|
data InlineText
|
||||||
= Text Text -- Combined Normal and Escaped
|
= Text Text Attrs -- Combined Normal and Escaped
|
||||||
| Bold [InlineText]
|
| Bold [InlineText] Attrs
|
||||||
| Italic [InlineText]
|
| Italic [InlineText] Attrs
|
||||||
| Crossed [InlineText]
|
| Crossed [InlineText] Attrs
|
||||||
| Underlined [InlineText]
|
| Underlined [InlineText]
|
||||||
| InlineCode Text
|
| InlineCode Text Attrs
|
||||||
| Link
|
| Link
|
||||||
{ linkText :: [InlineText],
|
{ linkText :: [InlineText],
|
||||||
url :: Text,
|
url :: Text,
|
||||||
title :: Maybe Text
|
title :: Maybe Text,
|
||||||
|
misc_attrs :: Attrs
|
||||||
}
|
}
|
||||||
| Image
|
| Image
|
||||||
{ altText :: Text,
|
{ altText :: Text,
|
||||||
url :: Text,
|
url :: Text,
|
||||||
title :: Maybe Text
|
title :: Maybe Text,
|
||||||
|
misc_attrs :: Attrs
|
||||||
}
|
}
|
||||||
| HTMLInline {inline_html_content :: Text}
|
| -- Markdown only DJOT uses RawInline
|
||||||
|
HTMLInline {inline_html_content :: Text}
|
||||||
|
| Superscript [InlineText] Attrs
|
||||||
|
| Subscript [InlineText] Attrs
|
||||||
|
| Highlighted [InlineText] Attrs
|
||||||
|
| -- different HTML element than Underlined
|
||||||
|
Insert [InlineText] Attrs
|
||||||
|
| Math Math Attrs
|
||||||
|
| -- TODO
|
||||||
|
FootnoteReference {label :: Text, attrs :: Attrs}
|
||||||
|
| Symbol Text
|
||||||
|
| RawInline RawInline Attrs
|
||||||
|
| Span [InlineText] Attrs
|
||||||
|
| LineBreak
|
||||||
|
deriving (Show)
|
||||||
|
|
||||||
|
data Attrs = Attrs
|
||||||
|
{ attrId :: Maybe Text,
|
||||||
|
attrClasses :: [Text],
|
||||||
|
attrKV :: [(Text, Text)]
|
||||||
|
}
|
||||||
|
deriving (Show)
|
||||||
|
|
||||||
|
emptyAttrs :: Attrs
|
||||||
|
emptyAttrs = Attrs {attrId = Nothing, attrClasses = [], attrKV = []}
|
||||||
|
|
||||||
|
data Math
|
||||||
|
= InlineLaTeX Text
|
||||||
|
| BlockLaTeX Text
|
||||||
|
deriving (Show)
|
||||||
|
|
||||||
|
data Alignment = AlignLeft | AlignRight | AlignCenter | AlignDefault
|
||||||
|
deriving (Show)
|
||||||
|
|
||||||
|
data TableCell = TC
|
||||||
|
{ cellContent :: [InlineText],
|
||||||
|
cellAlign :: Alignment
|
||||||
|
}
|
||||||
|
deriving (Show)
|
||||||
|
|
||||||
|
newtype TableRow = TR [TableCell] deriving (Show)
|
||||||
|
|
||||||
|
data Table = T
|
||||||
|
{ tableCaption :: Maybe [InlineText],
|
||||||
|
tableHead :: Maybe TableRow,
|
||||||
|
tableBody :: [TableRow]
|
||||||
|
}
|
||||||
|
deriving (Show)
|
||||||
|
|
||||||
|
newtype DescriptionList = DL {items :: [DefinitionItem]} deriving (Show)
|
||||||
|
|
||||||
|
data DefinitionItem = Def
|
||||||
|
{ defTitle :: [InlineText],
|
||||||
|
defContent :: [Element]
|
||||||
|
}
|
||||||
|
deriving (Show)
|
||||||
|
|
||||||
|
data Footnote = F {label :: Text, content :: [Element]} deriving (Show)
|
||||||
|
|
||||||
|
newtype TaskList = TL {items :: [Task]} deriving (Show)
|
||||||
|
|
||||||
|
data Task = Ta
|
||||||
|
{ checked :: Bool,
|
||||||
|
content :: [Element]
|
||||||
|
}
|
||||||
|
deriving (Show)
|
||||||
|
|
||||||
|
data RawInline = RI
|
||||||
|
{
|
||||||
|
}
|
||||||
|
deriving (Show)
|
||||||
|
|
||||||
|
data RawBlock = RB
|
||||||
|
{
|
||||||
|
}
|
||||||
deriving (Show)
|
deriving (Show)
|
||||||
|
|
||||||
-- for processing math
|
-- for processing math
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue