packages feed

pandoc-types 1.8.2 → 1.9

raw patch · 3 files changed

+90/−45 lines, 3 filesdep ~basedep ~containersPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: base, containers

API changes (from Hackage documentation)

- Text.Pandoc.Builder: (+++) :: Monoid a => a -> a -> a
- Text.Pandoc.Builder: apostrophe :: Inlines
- Text.Pandoc.Builder: ellipses :: Inlines
- Text.Pandoc.Builder: emdash :: Inlines
- Text.Pandoc.Builder: endash :: Inlines
- Text.Pandoc.Builder: type Blocks = Seq Block
- Text.Pandoc.Builder: type Inlines = Seq Inline
- Text.Pandoc.Definition: Apostrophe :: Inline
- Text.Pandoc.Definition: Ellipses :: Inline
- Text.Pandoc.Definition: EmDash :: Inline
- Text.Pandoc.Definition: EnDash :: Inline
+ Text.Pandoc.Builder: (<>) :: Monoid a => a -> a -> a
+ Text.Pandoc.Builder: Blocks :: Seq Block -> Blocks
+ Text.Pandoc.Builder: Inlines :: Seq Inline -> Inlines
+ Text.Pandoc.Builder: class Listable a b
+ Text.Pandoc.Builder: foldMap :: Listable a b => (b -> a) -> a -> a
+ Text.Pandoc.Builder: foldlM :: (Listable a b, Monad m) => (a -> b -> m a) -> a -> a -> m a
+ Text.Pandoc.Builder: instance Data Blocks
+ Text.Pandoc.Builder: instance Data Inlines
+ Text.Pandoc.Builder: instance Eq Blocks
+ Text.Pandoc.Builder: instance Eq Inlines
+ Text.Pandoc.Builder: instance Listable Blocks Block
+ Text.Pandoc.Builder: instance Listable Inlines Inline
+ Text.Pandoc.Builder: instance Monoid Blocks
+ Text.Pandoc.Builder: instance Monoid Inlines
+ Text.Pandoc.Builder: instance Ord Blocks
+ Text.Pandoc.Builder: instance Ord Inlines
+ Text.Pandoc.Builder: instance Read Blocks
+ Text.Pandoc.Builder: instance Read Inlines
+ Text.Pandoc.Builder: instance Show Blocks
+ Text.Pandoc.Builder: instance Show Inlines
+ Text.Pandoc.Builder: instance Typeable Blocks
+ Text.Pandoc.Builder: instance Typeable Inlines
+ Text.Pandoc.Builder: isNull :: Listable a b => a -> Bool
+ Text.Pandoc.Builder: newtype Blocks
+ Text.Pandoc.Builder: newtype Inlines
+ Text.Pandoc.Builder: singleton :: Listable a b => b -> a
+ Text.Pandoc.Builder: trimInlines :: Inlines -> Inlines
+ Text.Pandoc.Builder: unBlocks :: Blocks -> Seq Block
+ Text.Pandoc.Builder: unInlines :: Inlines -> Seq Inline
- Text.Pandoc.Builder: fromList :: [a] -> Seq a
+ Text.Pandoc.Builder: fromList :: Listable a b => [b] -> a
- Text.Pandoc.Builder: toList :: Foldable t => t a -> [a]
+ Text.Pandoc.Builder: toList :: Listable a b => a -> [b]

Files

Text/Pandoc/Builder.hs view
@@ -1,4 +1,5 @@-{-# LANGUAGE TypeSynonymInstances, FlexibleInstances #-}+{-# LANGUAGE TypeSynonymInstances, FlexibleInstances, MultiParamTypeClasses,+    DeriveDataTypeable, GeneralizedNewtypeDeriving #-} {- Copyright (C) 2010 John MacFarlane <jgm@berkeley.edu> @@ -28,16 +29,17 @@  Convenience functions for building pandoc documents programmatically. -Example of use (requires the @OverloadedStrings@ language extension):+Example of use: +> {-# LANGUAGE OverloadedStrings #-} > import Text.Pandoc.Builder > > myDoc :: Pandoc > myDoc = setTitle "My title" $ doc $->   para "This is the first paragraph" +++->   para ("And " +++ emph "another" +++ ".") +++->   bulletList [ para "item one" +++ para "continuation"->              , plain ("item two and a " ++++>   para "This is the first paragraph" <>+>   para ("And " <> emph "another" <> ".") <>+>   bulletList [ para "item one" <> para "continuation"+>              , plain ("item two and a " <> >                  link "/url" "go to url" "link") >              ] @@ -83,12 +85,11 @@ -}  module Text.Pandoc.Builder ( module Text.Pandoc.Definition-                           , Inlines-                           , Blocks-                           , toList-                           , fromList+                           , Inlines(..)+                           , Blocks(..)                            , empty-                           , (+++)+                           , (<>)+                           , Listable(..)                            -- * Document builders                            , doc                            , setTitle@@ -109,10 +110,6 @@                            , codeWith                            , code                            , space-                           , ellipses-                           , emdash-                           , endash-                           , apostrophe                            , linebreak                            , math                            , displayMath@@ -120,6 +117,7 @@                            , link                            , image                            , note+                           , trimInlines                            -- * Block list builders                            , para                            , plain@@ -141,25 +139,88 @@ import Data.String import Data.Monoid import Data.Maybe (fromMaybe)-import Data.Sequence (Seq, fromList, singleton, empty, (><))-import Data.Foldable (Foldable, toList)-import Data.List (groupBy)+import Data.Sequence (Seq, (|>), empty, viewr, viewl, ViewR(..), ViewL(..))+import qualified Data.Sequence as Seq+import Data.Foldable (Foldable)+import qualified Data.Foldable as F+import Data.List (groupBy, intersperse)+import Data.Data+import Data.Typeable import Control.Arrow ((***)) -type Inlines = Seq Inline+(<>) :: Monoid a => a -> a -> a+(<>) = mappend --- Foldable gives us toList--- Monoid gives us mappend, mempty+newtype Inlines = Inlines { unInlines :: Seq Inline }+                deriving (Data, Ord, Eq, Typeable) +-- We show an Inlines just like [Inline].+instance Show Inlines where+  show = show . F.toList . unInlines++instance Read Inlines where+  readsPrec n = map (\(x,y) -> (Inlines . Seq.fromList $ x, y)) . readsPrec n++instance Monoid Inlines where+  mempty = Inlines mempty+  (Inlines xs) `mappend` (Inlines ys) =+    case (viewr xs, viewl ys) of+      (EmptyR, _) -> Inlines ys+      (_, EmptyL) -> Inlines xs+      (xs' :> x, y :< ys') -> Inlines (meld `mappend` ys')+        where meld = case (x, y) of+                          (Space, Space)     -> xs' |> Space+                          (Str t1, Str t2)   -> xs' |> Str (t1 <> t2)+                          (Emph i1, Emph i2) -> xs' |> Emph (i1 <> i2)+                          (Strong i1, Strong i2) -> xs' |> Strong (i1 <> i2)+                          (Subscript i1, Subscript i2) -> xs' |> Subscript (i1 <> i2)+                          (Superscript i1, Superscript i2) -> xs' |> Superscript (i1 <> i2)+                          (Strikeout i1, Strikeout i2) -> xs' |> Strikeout (i1 <> i2)+                          (Space, LineBreak) -> xs' |> LineBreak+                          _                  -> xs' |> x |> y+ instance IsString Inlines where   fromString = text -type Blocks = Seq Block+newtype Blocks = Blocks { unBlocks :: Seq Block }+                deriving (Data, Ord, Eq, Typeable, Monoid) --- | Concatenate two 'Inlines's or two 'Blocks's.-(+++) :: Monoid a => a -> a -> a-(+++) = mappend+-- We show a Blocks just like [Block].+instance Show Blocks where+  show = show . F.toList . unBlocks +instance Read Blocks where+  readsPrec n = map (\(x,y) -> (Blocks . Seq.fromList $ x, y)) . readsPrec n++class Listable a b where+  toList     :: a -> [b]+  fromList   :: [b] -> a+  foldMap    :: (b -> a) -> a -> a+  singleton  :: b -> a+  foldlM     :: Monad m => (a -> b -> m a) -> a -> a -> m a+  isNull     :: a -> Bool++instance Listable Inlines Inline where+  toList         = F.toList . unInlines+  fromList       = Inlines . Seq.fromList+  foldMap f      = F.foldMap f . unInlines+  singleton      = Inlines . Seq.singleton+  foldlM f x     = F.foldlM f x . unInlines+  isNull         = Seq.null . unInlines++instance Listable Blocks Block where+  toList         = F.toList . unBlocks+  fromList       = Blocks . Seq.fromList+  foldMap  f     = F.foldMap f . unBlocks+  singleton      = Blocks . Seq.singleton+  foldlM f x     = F.foldlM f x . unBlocks+  isNull         = Seq.null . unBlocks++-- | Trim leading and trailing Sp (spaces) from an Inlines.+trimInlines :: Inlines -> Inlines+trimInlines (Inlines ils) = Inlines $ Seq.dropWhileL (== Space) $+                            Seq.dropWhileR (== Space) $ ils+ -- Document builders  doc :: Blocks -> Pandoc@@ -234,18 +295,6 @@ space :: Inlines space = singleton Space -emdash :: Inlines-emdash = singleton EmDash--endash :: Inlines-endash = singleton EnDash--apostrophe :: Inlines-apostrophe = singleton Apostrophe--ellipses :: Inlines-ellipses = singleton Ellipses- linebreak :: Inlines linebreak = singleton LineBreak @@ -333,7 +382,7 @@ simpleTable :: [Blocks]   -- ^ Headers             -> [[Blocks]] -- ^ Rows             -> Blocks-simpleTable headers = table empty (mapConst defaults headers) headers+simpleTable headers = table mempty (mapConst defaults headers) headers   where defaults = (AlignDefault, 0)  mapConst :: Functor f => b -> f a -> f b
Text/Pandoc/Definition.hs view
@@ -125,10 +125,6 @@     | Cite [Citation]  [Inline] -- ^ Citation (list of inlines)     | Code Attr String      -- ^ Inline code (literal)     | Space                 -- ^ Inter-word space-    | EmDash                -- ^ Em dash-    | EnDash                -- ^ En dash-    | Apostrophe            -- ^ Apostrophe-    | Ellipses              -- ^ Ellipses     | LineBreak             -- ^ Hard line break     | Math MathType String  -- ^ TeX math (literal)     | RawInline Format String -- ^ Raw inline
pandoc-types.cabal view
@@ -1,5 +1,5 @@ Name:                pandoc-types-Version:             1.8.2+Version:             1.9 Synopsis:            Types for representing a structured document Description:         This package contains definitions for the 'Pandoc' data                      structure, which is used by pandoc to represent@@ -34,7 +34,7 @@                      Text.Pandoc.Generic                      Text.Pandoc.Builder   if impl(ghc >= 6.10)-    Build-depends:     base >= 4 && < 5, syb, containers+    Build-depends:     base >= 4 && < 5, syb, containers >= 0.3   else-    Build-depends:     base >= 3 && < 4, containers+    Build-depends:     base >= 3 && < 4, containers >= 0.3