Browse Source

First pass at packed, richer versions of basic Pandoc types

Getty Ritter 8 years ago
parent
commit
b45d2cc2dc
2 changed files with 112 additions and 3 deletions
  1. 106 0
      ptolemy-core/Text/Ptolemy/Core.hs
  2. 6 3
      ptolemy-core/ptolemy-core.cabal

+ 106 - 0
ptolemy-core/Text/Ptolemy/Core.hs

@@ -0,0 +1,106 @@
+module Text.Ptolemy.Core where
+
+import           Data.Text (Text)
+import qualified Data.Text as T
+import           Data.Vector (Vector)
+import qualified Data.Vector as V
+
+type Document = Vector Block
+type DocumentList = Vector Document
+type Chunk = Vector Inline
+
+data Block
+  = Plain Chunk
+  | Para Chunk
+  | CodeBlock Attr Text
+  | RawBlock Format Text
+  | BlockQuote Document
+  | OrderedList ListAttributes DocumentList
+  | BulletList DocumentList
+  | DefinitionList (Vector (Chunk, DocumentList))
+  | Header Int Attr Chunk
+  | HorizontalRule
+--  | Table ???
+  | Div Attr Document
+  | Null
+    deriving (Eq, Show, Read, Ord)
+
+data Inline
+  = Str Text
+  | Emph Chunk
+  | Strong Chunk
+  | Strikeout Chunk
+  | Superscript Chunk
+  | Subscript Chunk
+  | SmallCaps Chunk
+  | Quoted QuoteType Chunk
+  | Cite (Vector Citation) Chunk
+  | Code Attr Text
+  | Space
+  | SoftBreak
+  | LineBreak
+  | Math MathType Text
+  | RawInline Format Text
+  | Link Attr Chunk Target
+  | Image Attr Chunk Target
+  | Note Document
+  | Span Attr Chunk
+    deriving (Eq, Show, Read, Ord)
+
+data Attr = Attr
+  { attrIdentifier :: Text
+  , attrClasses :: Vector Text
+  , attrProps :: Vector (Text, Text)
+  } deriving (Eq, Show, Read, Ord)
+
+data ListAttributes = ListAttributes
+  { laWhatever    :: Int -- XXX What is this field for?
+  , laNumberStyle :: ListNumberStyle
+  , laNumberDelim :: ListNumberDelim
+  } deriving (Eq, Show, Read, Ord)
+
+data Citation = Citation
+  { ciId      :: Text
+  , ciPrefix  :: Chunk
+  , ciSuffix  :: Chunk
+  , ciMode    :: CitationMode
+  , ciNoteNum :: Int
+  , ciHash    :: Int
+  } deriving (Eq, Show, Read, Ord)
+
+data CitationMode
+  = AuthorInText
+  | SuppressAuthor
+  | NormalCitation
+    deriving (Eq, Show, Read, Ord)
+
+data ListNumberStyle
+  = DefaultStyle
+  | Example
+  | Decimal
+  | LowerRoman
+  | UpperRoman
+  | LowerAlpha
+  | UpperAlpha
+    deriving (Eq, Show, Read, Ord)
+
+data ListNumberDelim
+  = DefaultDelim
+  | Period
+  | OneParen
+  | TwoParens
+    deriving (Eq, Show, Read, Ord)
+
+data QuoteType = SingleQuote | DoubleQuote
+  deriving (Eq, Show, Read, Ord)
+
+data MathType = DisplayMath | InlineMath
+  deriving (Eq, Show, Read, Ord)
+
+newtype Format = Format { fromFormat :: Text }
+  deriving (Eq, Show, Read, Ord)
+
+data Target = Target
+  { tgtURL   :: Text
+  , tgtTitle :: Text
+  } deriving (Eq, Show, Read, Ord)

+ 6 - 3
ptolemy-core/ptolemy-core.cabal

@@ -7,14 +7,16 @@ license-file:     LICENSE
 author:           Getty Ritter
 maintainer:       gettyritter@gmail.com
 copyright:        ©2016 Getty Ritter
-category: Text
+category:         Text
 build-type:       Simple
-cabal-version:    >=1.0
+cabal-version:    >= 1.2
 
 library
+  exposed-modules:     Text.Ptolemy.Core
   ghc-options:         -Wall
-  build-depends:       base >=4.7 && <4.9
+  build-depends:       base >=4.7 && <4.9,
+                       vector,
+                       text
   default-language:    Haskell2010
   default-extensions:  OverloadedStrings,
                        ScopedTypeVariables