Core.hs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. module Text.Ptolemy.Core where
  2. import Data.Text (Text)
  3. import qualified Data.Text as T
  4. import Data.Vector (Vector)
  5. import qualified Data.Vector as V
  6. type Document = Vector Block
  7. type DocumentList = Vector Document
  8. type Chunk = Vector Inline
  9. data Block
  10. = Plain Chunk
  11. | Para Chunk
  12. | CodeBlock Attr Text
  13. | RawBlock Format Text
  14. | BlockQuote Document
  15. | OrderedList ListAttributes DocumentList
  16. | BulletList DocumentList
  17. | DefinitionList (Vector (Chunk, DocumentList))
  18. | Header Int Attr Chunk
  19. | HorizontalRule
  20. -- | Table ???
  21. | Div Attr Document
  22. | Null
  23. deriving (Eq, Show, Read, Ord)
  24. data Inline
  25. = Str Text
  26. | Emph Chunk
  27. | Strong Chunk
  28. | Strikeout Chunk
  29. | Superscript Chunk
  30. | Subscript Chunk
  31. | SmallCaps Chunk
  32. | Quoted QuoteType Chunk
  33. | Cite (Vector Citation) Chunk
  34. | Code Attr Text
  35. | Space
  36. | SoftBreak
  37. | LineBreak
  38. | Math MathType Text
  39. | RawInline Format Text
  40. | Link Attr Chunk Target
  41. | Image Attr Chunk Target
  42. | Note Document
  43. | Span Attr Chunk
  44. deriving (Eq, Show, Read, Ord)
  45. data Attr = Attr
  46. { attrIdentifier :: Text
  47. , attrClasses :: Vector Text
  48. , attrProps :: Vector (Text, Text)
  49. } deriving (Eq, Show, Read, Ord)
  50. data ListAttributes = ListAttributes
  51. { laWhatever :: Int -- XXX What is this field for?
  52. , laNumberStyle :: ListNumberStyle
  53. , laNumberDelim :: ListNumberDelim
  54. } deriving (Eq, Show, Read, Ord)
  55. data Citation = Citation
  56. { ciId :: Text
  57. , ciPrefix :: Chunk
  58. , ciSuffix :: Chunk
  59. , ciMode :: CitationMode
  60. , ciNoteNum :: Int
  61. , ciHash :: Int
  62. } deriving (Eq, Show, Read, Ord)
  63. data CitationMode
  64. = AuthorInText
  65. | SuppressAuthor
  66. | NormalCitation
  67. deriving (Eq, Show, Read, Ord)
  68. data ListNumberStyle
  69. = DefaultStyle
  70. | Example
  71. | Decimal
  72. | LowerRoman
  73. | UpperRoman
  74. | LowerAlpha
  75. | UpperAlpha
  76. deriving (Eq, Show, Read, Ord)
  77. data ListNumberDelim
  78. = DefaultDelim
  79. | Period
  80. | OneParen
  81. | TwoParens
  82. deriving (Eq, Show, Read, Ord)
  83. data QuoteType = SingleQuote | DoubleQuote
  84. deriving (Eq, Show, Read, Ord)
  85. data MathType = DisplayMath | InlineMath
  86. deriving (Eq, Show, Read, Ord)
  87. newtype Format = Format { fromFormat :: Text }
  88. deriving (Eq, Show, Read, Ord)
  89. data Target = Target
  90. { tgtURL :: Text
  91. , tgtTitle :: Text
  92. } deriving (Eq, Show, Read, Ord)