Hello community,
here is the log from the commit of package ghc-pandoc-types for
openSUSE:Factory checked in at 2019-12-27 13:55:50
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/ghc-pandoc-types (Old)
and /work/SRC/openSUSE:Factory/.ghc-pandoc-types.new.6675 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "ghc-pandoc-types"
Fri Dec 27 13:55:50 2019 rev:26 rq:759465 version:1.20
Changes:
--------
--- /work/SRC/openSUSE:Factory/ghc-pandoc-types/ghc-pandoc-types.changes
2019-10-18 14:34:27.848078337 +0200
+++
/work/SRC/openSUSE:Factory/.ghc-pandoc-types.new.6675/ghc-pandoc-types.changes
2019-12-27 13:55:53.420731417 +0100
@@ -1,0 +2,63 @@
+Wed Nov 13 03:02:28 UTC 2019 - [email protected]
+
+- Update pandoc-types to version 1.20.
+ [1.20]
+
+ * Change all uses of String in type definitions to strict Text
+ (Christian Despres) [API change]. The MetaValue instances using String
+ have been kept, and parallel ones using Text were added.
+
+ * Remove the Arbitrary Text orphan instance (Christian Despres).
+ This instance should not have been in the Text.Pandoc.Arbitrary, since
+ it would have been exported with the rest of the instances in that
+ module. Instead, more shrink* functions were added to compensate for
+ the absence of this instance.
+
+ * Add Text.Pandoc.Legacy.Definition (Christian Despres).
+ To ease the transition to Text, this module provides an interface
+ compatible with the String one, so that any unqualified imports of
+ Text.Pandoc.Definition in other packages can be replaced by
+ Text.Pandoc.Legacy.Definition without other code changes. This is done
+ with PatternSynonyms.
+
+ Some of the constructors of the types Meta, MetaValue, Block, Inline,
+ Format, and Citation required PatternSynonym handling. The Attr and
+ Target types had to be redefined, and certain functions had to be
+ rewritten to handle String or the old Attr and Target types in this
+ module. This module otherwise exports the definitions in
+ Text.Pandoc.Definition unchanged.
+
+ This is not a perfect drop-in replacement, since some imports like
+ Inline(..) will no longer work. This may also cause incomplete pattern
+ warnings when used, since the coverage checker does not seem to be
+ aware of PatternSynonyms.
+
+ * Add Text.Pandoc.Legacy.Builder (Christian Despres).
+ Like Text.Pandoc.Legacy.Definition, this modules provides a
+ compatibility interface while the transition to Text takes
+ place. Unlike that module, this module only requires redefining the
+ ToMetaValue and HasMeta classes and a few functions so that they use
+ the old types. No PatternSynonyms are required.
+
+ * Change Semigroup/Monoid instance for Meta.
+ Previously `<>` was left-biased, so if meta1 and meta2 both
+ contained a field 'foo', the value from meta1 would be retained
+ in `meta1 <> meta2`, and the value from meta2 ignored.
+ This is counterintuitive and doesn't work well with pandoc;
+ for example, we want to be able to override a value in an
+ earlier `--metadata-file` with a later one on the command line.
+
+ It also makes the behavior of metadata more like other
+ things (such as reference links, where later definitions
+ take precedence over earlier ones).
+
+ Note that this change may break some current workflows,
+ if one is relying on metadata fields that occur later in
+ a document to be overridden by those occurring earlier.
+
+-------------------------------------------------------------------
+Fri Nov 8 16:14:21 UTC 2019 - Peter Simons <[email protected]>
+
+- Drop obsolete group attributes.
+
+-------------------------------------------------------------------
Old:
----
pandoc-types-1.17.6.1.tar.gz
New:
----
pandoc-types-1.20.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ ghc-pandoc-types.spec ++++++
--- /var/tmp/diff_new_pack.JPTgaB/_old 2019-12-27 13:55:55.312732331 +0100
+++ /var/tmp/diff_new_pack.JPTgaB/_new 2019-12-27 13:55:55.316732333 +0100
@@ -19,11 +19,10 @@
%global pkg_name pandoc-types
%bcond_with tests
Name: ghc-%{pkg_name}
-Version: 1.17.6.1
+Version: 1.20
Release: 0
Summary: Types for representing a structured document
License: GPL-2.0-only
-Group: Development/Libraries/Haskell
URL: https://hackage.haskell.org/package/%{pkg_name}
Source0:
https://hackage.haskell.org/package/%{pkg_name}-%{version}/%{pkg_name}-%{version}.tar.gz
BuildRequires: ghc-Cabal-devel
@@ -34,6 +33,7 @@
BuildRequires: ghc-deepseq-devel
BuildRequires: ghc-rpm-macros
BuildRequires: ghc-syb-devel
+BuildRequires: ghc-text-devel
BuildRequires: ghc-transformers-devel
%if %{with tests}
BuildRequires: ghc-HUnit-devel
@@ -64,7 +64,6 @@
%package devel
Summary: Haskell %{pkg_name} library development files
-Group: Development/Libraries/Haskell
Requires: %{name} = %{version}-%{release}
Requires: ghc-compiler = %{ghc_version}
Requires(post): ghc-compiler = %{ghc_version}
++++++ pandoc-types-1.17.6.1.tar.gz -> pandoc-types-1.20.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pandoc-types-1.17.6.1/Text/Pandoc/Arbitrary.hs
new/pandoc-types-1.20/Text/Pandoc/Arbitrary.hs
--- old/pandoc-types-1.17.6.1/Text/Pandoc/Arbitrary.hs 2019-08-23
20:00:14.000000000 +0200
+++ new/pandoc-types-1.20/Text/Pandoc/Arbitrary.hs 2019-11-12
17:27:21.000000000 +0100
@@ -1,17 +1,25 @@
{-# OPTIONS_GHC -fno-warn-orphans #-}
-{-# LANGUAGE FlexibleInstances, ScopedTypeVariables #-}
+{-# LANGUAGE FlexibleInstances, ScopedTypeVariables, OverloadedStrings #-}
-- provides Arbitrary instance for Pandoc types
module Text.Pandoc.Arbitrary ()
where
import Test.QuickCheck
import Control.Applicative (Applicative ((<*>), pure), (<$>))
import Control.Monad (forM)
+import Data.Text (Text)
+import qualified Data.Text as T
import Text.Pandoc.Definition
import Text.Pandoc.Builder
-realString :: Gen String
-realString = resize 8 $ listOf $ frequency [ (9, elements [' '..'\127'])
- , (1, elements ['\128'..'\9999']) ]
+realString :: Gen Text
+realString = fmap T.pack $ resize 8 $ listOf $ frequency [ (9, elements ['
'..'\127'])
+ , (1, elements
['\128'..'\9999']) ]
+
+shrinkText :: Text -> [Text]
+shrinkText xs = T.pack <$> shrink (T.unpack xs)
+
+shrinkText2 :: (Text, Text) -> [(Text, Text)]
+shrinkText2 = liftShrink2 shrinkText shrinkText
arbAttr :: Gen Attr
arbAttr = do
@@ -20,6 +28,12 @@
keyvals <- elements [[],[("start","22")],[("a","11"),("b_2","a b c")]]
return (id',classes',keyvals)
+shrinkAttr :: Attr -> [Attr]
+shrinkAttr (a, b, c)
+ = [ (a', b', c') | a' <- shrinkText a,
+ b' <- liftShrink shrinkText b,
+ c' <- liftShrink shrinkText2 c ]
+
instance Arbitrary Inlines where
arbitrary = (fromList :: [Inline] -> Inlines) <$> arbitrary
shrink = fmap fromList . ((++) <$> shrink <*> flattenShrinkInlines) . toList
@@ -85,7 +99,7 @@
instance Arbitrary Inline where
arbitrary = resize 3 $ arbInline 2
- shrink (Str s) = Str <$> shrink s
+ shrink (Str s) = Str <$> shrinkText s
shrink (Emph ils) = Emph <$> shrinkInlineList ils
shrink (Strong ils) = Strong <$> shrinkInlineList ils
shrink (Strikeout ils) = Strikeout <$> shrinkInlineList ils
@@ -95,22 +109,22 @@
shrink (Quoted qtype ils) = Quoted qtype <$> shrinkInlineList ils
shrink (Cite cits ils) = (Cite cits <$> shrinkInlineList ils)
++ (flip Cite ils <$> shrink cits)
- shrink (Code attr s) = (Code attr <$> shrink s)
- ++ (flip Code s <$> shrink attr)
+ shrink (Code attr s) = (Code attr <$> shrinkText s)
+ ++ (flip Code s <$> shrinkAttr attr)
shrink Space = []
shrink SoftBreak = []
shrink LineBreak = []
- shrink (Math mtype s) = Math mtype <$> shrink s
- shrink (RawInline fmt s) = RawInline fmt <$> shrink s
+ shrink (Math mtype s) = Math mtype <$> shrinkText s
+ shrink (RawInline fmt s) = RawInline fmt <$> shrinkText s
shrink (Link attr ils target) = [Link attr ils' target | ils' <-
shrinkInlineList ils]
- ++ [Link attr ils target' | target' <- shrink
target]
- ++ [Link attr' ils target | attr' <- shrink
attr]
+ ++ [Link attr ils target' | target' <-
shrinkText2 target]
+ ++ [Link attr' ils target | attr' <- shrinkAttr
attr]
shrink (Image attr ils target) = [Image attr ils' target | ils' <-
shrinkInlineList ils]
- ++ [Image attr ils target' | target' <- shrink
target]
- ++ [Image attr' ils target | attr' <- shrink
attr]
+ ++ [Image attr ils target' | target' <-
shrinkText2 target]
+ ++ [Image attr' ils target | attr' <-
shrinkAttr attr]
shrink (Note blks) = Note <$> shrinkBlockList blks
shrink (Span attr s) = (Span attr <$> shrink s)
- ++ (flip Span s <$> shrink attr)
+ ++ (flip Span s <$> shrinkAttr attr)
arbInlines :: Int -> Gen [Inline]
arbInlines n = listOf1 (arbInline n) `suchThat` (not . startsWithSpace)
@@ -150,9 +164,9 @@
shrink (Plain ils) = Plain <$> shrinkInlineList ils
shrink (Para ils) = Para <$> shrinkInlineList ils
shrink (LineBlock lns) = LineBlock <$> shrinkInlinesList lns
- shrink (CodeBlock attr s) = (CodeBlock attr <$> shrink s)
- ++ (flip CodeBlock s <$> shrink attr)
- shrink (RawBlock fmt s) = RawBlock fmt <$> shrink s
+ shrink (CodeBlock attr s) = (CodeBlock attr <$> shrinkText s)
+ ++ (flip CodeBlock s <$> shrinkAttr attr)
+ shrink (RawBlock fmt s) = RawBlock fmt <$> shrinkText s
shrink (BlockQuote blks) = BlockQuote <$> shrinkBlockList blks
shrink (OrderedList listAttrs blksList) = OrderedList listAttrs <$>
shrinkBlocksList blksList
shrink (BulletList blksList) = BulletList <$> shrinkBlocksList blksList
@@ -164,7 +178,7 @@
++ [x:xs' | xs' <- shrinkDefinitionList
xs]
shrinkDefinitionList [] = []
shrink (Header n attr ils) = (Header n attr <$> shrinkInlineList ils)
- ++ (flip (Header n) ils <$> shrink attr)
+ ++ (flip (Header n) ils <$> shrinkAttr attr)
shrink HorizontalRule = []
shrink (Table caption aligns widths cells rows) =
-- TODO: shrink number of columns
@@ -185,7 +199,7 @@
++ [x:xs' | xs' <- shrinkRows xs]
shrinkRows [] = []
shrink (Div attr blks) = (Div attr <$> shrinkBlockList blks)
- ++ (flip Div blks <$> shrink attr)
+ ++ (flip Div blks <$> shrinkAttr attr)
shrink Null = []
arbBlock :: Int -> Gen Block
@@ -238,7 +252,7 @@
instance Arbitrary Citation where
arbitrary
- = Citation <$> listOf (elements $ ['a'..'z'] ++ ['0'..'9'] ++ ['_'])
+ = Citation <$> fmap T.pack (listOf $ elements $ ['a'..'z'] ++
['0'..'9'] ++ ['_'])
<*> arbInlines 1
<*> arbInlines 1
<*> arbitrary
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pandoc-types-1.17.6.1/Text/Pandoc/Builder.hs
new/pandoc-types-1.20/Text/Pandoc/Builder.hs
--- old/pandoc-types-1.17.6.1/Text/Pandoc/Builder.hs 2019-08-23
20:00:14.000000000 +0200
+++ new/pandoc-types-1.20/Text/Pandoc/Builder.hs 2019-11-12
17:27:21.000000000 +0100
@@ -1,6 +1,6 @@
{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses, DeriveDataTypeable,
GeneralizedNewtypeDeriving, CPP, StandaloneDeriving, DeriveGeneric,
- DeriveTraversable #-}
+ DeriveTraversable, OverloadedStrings #-}
{-
Copyright (C) 2010-2019 John MacFarlane
@@ -167,12 +167,13 @@
import Text.Pandoc.Definition
import Data.String
import qualified Data.Map as M
+import Data.Text (Text)
+import qualified Data.Text as T
import Data.Sequence (Seq, (|>), viewr, viewl, ViewR(..), ViewL(..))
import qualified Data.Sequence as Seq
import Data.Traversable (Traversable)
import Data.Foldable (Foldable)
import qualified Data.Foldable as F
-import Data.List (groupBy)
import Data.Data
import Control.Arrow ((***))
import GHC.Generics (Generic)
@@ -228,7 +229,7 @@
mappend = (<>)
instance IsString Inlines where
- fromString = text
+ fromString = text . T.pack
-- | Trim leading and trailing spaces and softbreaks from an Inlines.
trimInlines :: Inlines -> Inlines
@@ -266,18 +267,24 @@
instance ToMetaValue Bool where
toMetaValue = MetaBool
-instance {-# OVERLAPPING #-} ToMetaValue String where
+instance ToMetaValue Text where
toMetaValue = MetaString
+instance {-# OVERLAPPING #-} ToMetaValue String where
+ toMetaValue = MetaString . T.pack
+
instance ToMetaValue a => ToMetaValue [a] where
toMetaValue = MetaList . map toMetaValue
-instance ToMetaValue a => ToMetaValue (M.Map String a) where
+instance ToMetaValue a => ToMetaValue (M.Map Text a) where
toMetaValue = MetaMap . M.map toMetaValue
+instance ToMetaValue a => ToMetaValue (M.Map String a) where
+ toMetaValue = MetaMap . M.map toMetaValue . M.mapKeys T.pack
+
class HasMeta a where
- setMeta :: ToMetaValue b => String -> b -> a -> a
- deleteMeta :: String -> a -> a
+ setMeta :: ToMetaValue b => Text -> b -> a -> a
+ deleteMeta :: Text -> a -> a
instance HasMeta Meta where
setMeta key val (Meta ms) = Meta $ M.insert key (toMetaValue val) ms
@@ -302,12 +309,12 @@
-- | Convert a 'String' to 'Inlines', treating interword spaces as 'Space's
-- or 'SoftBreak's. If you want a 'Str' with literal spaces, use 'str'.
-text :: String -> Inlines
+text :: Text -> Inlines
text = fromList . map conv . breakBySpaces
- where breakBySpaces = groupBy sameCategory
+ where breakBySpaces = T.groupBy sameCategory
sameCategory x y = is_space x == is_space y
- conv xs | all is_space xs =
- if any is_newline xs
+ conv xs | T.all is_space xs =
+ if T.any is_newline xs
then SoftBreak
else Space
conv xs = Str xs
@@ -320,7 +327,7 @@
is_newline '\n' = True
is_newline _ = False
-str :: String -> Inlines
+str :: Text -> Inlines
str = singleton . Str
emph :: Inlines -> Inlines
@@ -354,11 +361,11 @@
cite cts = singleton . Cite cts . toList
-- | Inline code with attributes.
-codeWith :: Attr -> String -> Inlines
+codeWith :: Attr -> Text -> Inlines
codeWith attrs = singleton . Code attrs
-- | Plain inline code.
-code :: String -> Inlines
+code :: Text -> Inlines
code = codeWith nullAttr
space :: Inlines
@@ -371,38 +378,38 @@
linebreak = singleton LineBreak
-- | Inline math
-math :: String -> Inlines
+math :: Text -> Inlines
math = singleton . Math InlineMath
-- | Display math
-displayMath :: String -> Inlines
+displayMath :: Text -> Inlines
displayMath = singleton . Math DisplayMath
-rawInline :: String -> String -> Inlines
+rawInline :: Text -> Text -> Inlines
rawInline format = singleton . RawInline (Format format)
-link :: String -- ^ URL
- -> String -- ^ Title
+link :: Text -- ^ URL
+ -> Text -- ^ Title
-> Inlines -- ^ Label
-> Inlines
link = linkWith nullAttr
linkWith :: Attr -- ^ Attributes
- -> String -- ^ URL
- -> String -- ^ Title
+ -> Text -- ^ URL
+ -> Text -- ^ Title
-> Inlines -- ^ Label
-> Inlines
linkWith attr url title x = singleton $ Link attr (toList x) (url, title)
-image :: String -- ^ URL
- -> String -- ^ Title
+image :: Text -- ^ URL
+ -> Text -- ^ Title
-> Inlines -- ^ Alt text
-> Inlines
image = imageWith nullAttr
imageWith :: Attr -- ^ Attributes
- -> String -- ^ URL
- -> String -- ^ Title
+ -> Text -- ^ URL
+ -> Text -- ^ Title
-> Inlines -- ^ Alt text
-> Inlines
imageWith attr url title x = singleton $ Image attr (toList x) (url, title)
@@ -427,14 +434,14 @@
lineBlock = singleton . LineBlock . map toList
-- | A code block with attributes.
-codeBlockWith :: Attr -> String -> Blocks
+codeBlockWith :: Attr -> Text -> Blocks
codeBlockWith attrs = singleton . CodeBlock attrs
-- | A plain code block.
-codeBlock :: String -> Blocks
+codeBlock :: Text -> Blocks
codeBlock = codeBlockWith nullAttr
-rawBlock :: String -> String -> Blocks
+rawBlock :: Text -> Text -> Blocks
rawBlock format = singleton . RawBlock (Format format)
blockQuote :: Blocks -> Blocks
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pandoc-types-1.17.6.1/Text/Pandoc/Definition.hs
new/pandoc-types-1.20/Text/Pandoc/Definition.hs
--- old/pandoc-types-1.17.6.1/Text/Pandoc/Definition.hs 2019-08-23
20:00:14.000000000 +0200
+++ new/pandoc-types-1.20/Text/Pandoc/Definition.hs 2019-11-12
17:27:21.000000000 +0100
@@ -78,9 +78,10 @@
import Data.Aeson hiding (Null)
import qualified Data.Aeson.Types as Aeson
import qualified Data.Map as M
+import Data.Text (Text)
+import qualified Data.Text as T
import GHC.Generics (Generic)
import Data.String
-import Data.Char (toLower)
import Control.DeepSeq
import Paths_pandoc_types (version)
import Data.Version (Version, versionBranch)
@@ -97,21 +98,21 @@
mappend = (<>)
-- | Metadata for the document: title, authors, date.
-newtype Meta = Meta { unMeta :: M.Map String MetaValue }
+newtype Meta = Meta { unMeta :: M.Map Text MetaValue }
deriving (Eq, Ord, Show, Read, Typeable, Data, Generic)
instance Semigroup Meta where
- (Meta m1) <> (Meta m2) = Meta (M.union m1 m2)
- -- note: M.union is left-biased, so if there are fields in both m1
- -- and m2, m1 wins.
+ (Meta m1) <> (Meta m2) = Meta (M.union m2 m1)
+ -- note: M.union is left-biased, so if there are fields in both m2
+ -- and m1, m2 wins.
instance Monoid Meta where
mempty = Meta M.empty
mappend = (<>)
-data MetaValue = MetaMap (M.Map String MetaValue)
+data MetaValue = MetaMap (M.Map Text MetaValue)
| MetaList [MetaValue]
| MetaBool Bool
- | MetaString String
+ | MetaString Text
| MetaInlines [Inline]
| MetaBlocks [Block]
deriving (Eq, Ord, Show, Read, Typeable, Data, Generic)
@@ -125,7 +126,7 @@
-- Helper functions to extract metadata
-- | Retrieve the metadata value for a given @key@.
-lookupMeta :: String -> Meta -> Maybe MetaValue
+lookupMeta :: Text -> Meta -> Maybe MetaValue
lookupMeta key (Meta m) = M.lookup key m
-- | Extract document title from metadata; works just like the old @docTitle@.
@@ -187,7 +188,7 @@
| TwoParens deriving (Eq, Ord, Show, Read, Typeable,
Data, Generic)
-- | Attributes: identifier, classes, key-value pairs
-type Attr = (String, [String], [(String, String)])
+type Attr = (Text, [Text], [(Text, Text)])
nullAttr :: Attr
nullAttr = ("",[],[])
@@ -196,25 +197,25 @@
type TableCell = [Block]
-- | Formats for raw blocks
-newtype Format = Format String
+newtype Format = Format Text
deriving (Read, Show, Typeable, Data, Generic, ToJSON, FromJSON)
instance IsString Format where
- fromString f = Format $ map toLower f
+ fromString f = Format $ T.toCaseFold $ T.pack f
instance Eq Format where
- Format x == Format y = map toLower x == map toLower y
+ Format x == Format y = T.toCaseFold x == T.toCaseFold y
instance Ord Format where
- compare (Format x) (Format y) = compare (map toLower x) (map toLower y)
+ compare (Format x) (Format y) = compare (T.toCaseFold x) (T.toCaseFold y)
-- | Block element.
data Block
= Plain [Inline] -- ^ Plain text, not a paragraph
| Para [Inline] -- ^ Paragraph
| LineBlock [[Inline]] -- ^ Multiple non-breaking lines
- | CodeBlock Attr String -- ^ Code block (literal) with attributes
- | RawBlock Format String -- ^ Raw block
+ | CodeBlock Attr Text -- ^ Code block (literal) with attributes
+ | RawBlock Format Text -- ^ Raw block
| BlockQuote [Block] -- ^ Block quote (list of blocks)
| OrderedList ListAttributes [[Block]] -- ^ Ordered list (attributes
-- and a list of items, each a list of blocks)
@@ -239,14 +240,14 @@
data QuoteType = SingleQuote | DoubleQuote deriving (Show, Eq, Ord, Read,
Typeable, Data, Generic)
-- | Link target (URL, title).
-type Target = (String, String)
+type Target = (Text, Text)
-- | Type of math element (display or inline).
data MathType = DisplayMath | InlineMath deriving (Show, Eq, Ord, Read,
Typeable, Data, Generic)
-- | Inline elements.
data Inline
- = Str String -- ^ Text (string)
+ = Str Text -- ^ Text (string)
| Emph [Inline] -- ^ Emphasized text (list of inlines)
| Strong [Inline] -- ^ Strongly emphasized text (list of inlines)
| Strikeout [Inline] -- ^ Strikeout text (list of inlines)
@@ -255,19 +256,19 @@
| SmallCaps [Inline] -- ^ Small caps text (list of inlines)
| Quoted QuoteType [Inline] -- ^ Quoted text (list of inlines)
| Cite [Citation] [Inline] -- ^ Citation (list of inlines)
- | Code Attr String -- ^ Inline code (literal)
+ | Code Attr Text -- ^ Inline code (literal)
| Space -- ^ Inter-word space
| SoftBreak -- ^ Soft line break
| LineBreak -- ^ Hard line break
- | Math MathType String -- ^ TeX math (literal)
- | RawInline Format String -- ^ Raw inline
+ | Math MathType Text -- ^ TeX math (literal)
+ | RawInline Format Text -- ^ Raw inline
| Link Attr [Inline] Target -- ^ Hyperlink: alt text (list of inlines),
target
| Image Attr [Inline] Target -- ^ Image: alt text (list of inlines),
target
| Note [Block] -- ^ Footnote or endnote
| Span Attr [Inline] -- ^ Generic inline container with attributes
deriving (Show, Eq, Ord, Read, Typeable, Data, Generic)
-data Citation = Citation { citationId :: String
+data Citation = Citation { citationId :: Text
, citationPrefix :: [Inline]
, citationSuffix :: [Inline]
, citationMode :: CitationMode
@@ -286,10 +287,10 @@
-- ToJSON/FromJSON instances. We do this by hand instead of deriving
-- from generics, so we can have more control over the format.
-taggedNoContent :: String -> Value
+taggedNoContent :: Text -> Value
taggedNoContent x = object [ "t" .= x ]
-tagged :: ToJSON a => String -> a -> Value
+tagged :: ToJSON a => Text -> a -> Value
tagged x y = object [ "t" .= x, "c" .= y ]
instance FromJSON MetaValue where
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pandoc-types-1.17.6.1/Text/Pandoc/JSON.hs
new/pandoc-types-1.20/Text/Pandoc/JSON.hs
--- old/pandoc-types-1.17.6.1/Text/Pandoc/JSON.hs 2019-08-23
20:00:14.000000000 +0200
+++ new/pandoc-types-1.20/Text/Pandoc/JSON.hs 2019-11-12 17:27:21.000000000
+0100
@@ -76,6 +76,7 @@
import Text.Pandoc.Walk
import Data.Maybe (listToMaybe)
import qualified Data.ByteString.Lazy as BL
+import qualified Data.Text as T
import Data.Aeson
import System.Environment (getArgs)
@@ -126,4 +127,4 @@
toJSONFilter f = getArgs >>= toJSONFilter . f
instance (ToJSONFilter a) => ToJSONFilter (Maybe Format -> a) where
- toJSONFilter f = getArgs >>= toJSONFilter . f . fmap Format . listToMaybe
+ toJSONFilter f = getArgs >>= toJSONFilter . f . fmap (Format . T.pack) .
listToMaybe
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pandoc-types-1.17.6.1/Text/Pandoc/Legacy/Builder.hs
new/pandoc-types-1.20/Text/Pandoc/Legacy/Builder.hs
--- old/pandoc-types-1.17.6.1/Text/Pandoc/Legacy/Builder.hs 1970-01-01
01:00:00.000000000 +0100
+++ new/pandoc-types-1.20/Text/Pandoc/Legacy/Builder.hs 2019-11-12
17:27:21.000000000 +0100
@@ -0,0 +1,162 @@
+{-# LANGUAGE FlexibleInstances #-}
+
+module Text.Pandoc.Legacy.Builder
+ ( module Text.Pandoc.Legacy.Definition
+ , B.Many(..)
+ , B.Inlines
+ , B.Blocks
+ , (<>)
+ , B.singleton
+ , B.toList
+ , B.fromList
+ , B.isNull
+ , B.doc
+ , ToMetaValue(..)
+ , HasMeta(..)
+ , B.setTitle
+ , B.setAuthors
+ , B.setDate
+ , text
+ , str
+ , B.emph
+ , B.strong
+ , B.strikeout
+ , B.superscript
+ , B.subscript
+ , B.smallcaps
+ , B.singleQuoted
+ , B.doubleQuoted
+ , B.cite
+ , codeWith
+ , code
+ , B.space
+ , B.softbreak
+ , B.linebreak
+ , math
+ , displayMath
+ , rawInline
+ , link
+ , linkWith
+ , image
+ , imageWith
+ , B.note
+ , spanWith
+ , B.trimInlines
+ , B.para
+ , B.plain
+ , B.lineBlock
+ , codeBlockWith
+ , codeBlock
+ , rawBlock
+ , B.blockQuote
+ , B.bulletList
+ , B.orderedListWith
+ , B.orderedList
+ , B.definitionList
+ , B.header
+ , headerWith
+ , B.horizontalRule
+ , B.table
+ , B.simpleTable
+ , divWith
+ ) where
+
+import qualified Data.Map as M
+import qualified Data.Text as T
+import qualified Text.Pandoc.Builder as B
+import Text.Pandoc.Legacy.Definition
+import Data.Semigroup (Semigroup(..))
+
+fromLegacyAttr :: Attr -> B.Attr
+fromLegacyAttr (a, b, c) = (T.pack a, map T.pack b, map pack2 c)
+ where
+ pack2 (x, y) = (T.pack x, T.pack y)
+
+class ToMetaValue a where
+ toMetaValue :: a -> B.MetaValue
+
+instance ToMetaValue B.MetaValue where
+ toMetaValue = id
+
+instance ToMetaValue B.Blocks where
+ toMetaValue = B.MetaBlocks . B.toList
+
+instance ToMetaValue B.Inlines where
+ toMetaValue = MetaInlines . B.toList
+
+instance ToMetaValue Bool where
+ toMetaValue = MetaBool
+
+instance {-# OVERLAPPING #-} ToMetaValue String where
+ toMetaValue = MetaString
+
+instance ToMetaValue a => ToMetaValue [a] where
+ toMetaValue = MetaList . map toMetaValue
+
+instance ToMetaValue a => ToMetaValue (M.Map String a) where
+ toMetaValue = MetaMap . M.map toMetaValue
+
+class HasMeta a where
+ setMeta :: ToMetaValue b => String -> b -> a -> a
+ deleteMeta :: String -> a -> a
+
+instance HasMeta Meta where
+ setMeta key val (B.Meta ms) = B.Meta $ M.insert (T.pack key) (toMetaValue
val) ms
+ deleteMeta key (B.Meta ms) = B.Meta $ M.delete (T.pack key) ms
+
+instance HasMeta Pandoc where
+ setMeta key val (Pandoc (B.Meta ms) bs) =
+ Pandoc (B.Meta $ M.insert (T.pack key) (toMetaValue val) ms) bs
+ deleteMeta key (Pandoc (B.Meta ms) bs) =
+ Pandoc (B.Meta $ M.delete (T.pack key) ms) bs
+
+text :: String -> B.Inlines
+text = B.text . T.pack
+
+str :: String -> B.Inlines
+str = B.str . T.pack
+
+codeWith :: Attr -> String -> B.Inlines
+codeWith a = B.codeWith (fromLegacyAttr a) . T.pack
+
+code :: String -> B.Inlines
+code = B.code . T.pack
+
+math :: String -> B.Inlines
+math = B.math . T.pack
+
+displayMath :: String -> B.Inlines
+displayMath = B.displayMath . T.pack
+
+rawInline :: String -> String -> B.Inlines
+rawInline s = B.rawInline (T.pack s) . T.pack
+
+link :: String -> String -> B.Inlines -> B.Inlines
+link s = B.link (T.pack s) . T.pack
+
+linkWith :: Attr -> String -> String -> B.Inlines -> B.Inlines
+linkWith a s = B.linkWith (fromLegacyAttr a) (T.pack s) . T.pack
+
+image :: String -> String -> B.Inlines -> B.Inlines
+image s = B.image (T.pack s) . T.pack
+
+imageWith :: Attr -> String -> String -> B.Inlines -> B.Inlines
+imageWith a s = B.imageWith (fromLegacyAttr a) (T.pack s) . T.pack
+
+spanWith :: Attr -> B.Inlines -> B.Inlines
+spanWith = B.spanWith . fromLegacyAttr
+
+codeBlockWith :: Attr -> String -> B.Blocks
+codeBlockWith a = B.codeBlockWith (fromLegacyAttr a) . T.pack
+
+codeBlock :: String -> B.Blocks
+codeBlock = B.codeBlock . T.pack
+
+rawBlock :: String -> String -> B.Blocks
+rawBlock s = B.rawBlock (T.pack s) . T.pack
+
+headerWith :: Attr -> Int -> B.Inlines -> B.Blocks
+headerWith = B.headerWith . fromLegacyAttr
+
+divWith :: Attr -> B.Blocks -> B.Blocks
+divWith = B.divWith . fromLegacyAttr
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/pandoc-types-1.17.6.1/Text/Pandoc/Legacy/Definition.hs
new/pandoc-types-1.20/Text/Pandoc/Legacy/Definition.hs
--- old/pandoc-types-1.17.6.1/Text/Pandoc/Legacy/Definition.hs 1970-01-01
01:00:00.000000000 +0100
+++ new/pandoc-types-1.20/Text/Pandoc/Legacy/Definition.hs 2019-11-12
17:27:21.000000000 +0100
@@ -0,0 +1,208 @@
+{-# LANGUAGE PatternSynonyms, ViewPatterns #-}
+
+module Text.Pandoc.Legacy.Definition
+ ( D.Pandoc(..)
+ , D.Meta
+ , pattern Meta
+ , unMeta
+ , D.MetaValue ( D.MetaList
+ , D.MetaBool
+ , D.MetaInlines
+ , D.MetaBlocks
+ )
+ , pattern MetaMap
+ , pattern MetaString
+ , D.nullMeta
+ , D.isNullMeta
+ , lookupMeta
+ , D.docTitle
+ , D.docAuthors
+ , D.docDate
+ , D.Block ( D.Plain
+ , D.Para
+ , D.LineBlock
+ , D.BlockQuote
+ , D.OrderedList
+ , D.BulletList
+ , D.DefinitionList
+ , D.HorizontalRule
+ , D.Table
+ , D.Null
+ )
+ , pattern CodeBlock
+ , pattern RawBlock
+ , pattern Header
+ , pattern Div
+ , D.Inline ( D.Emph
+ , D.Strong
+ , D.Strikeout
+ , D.Superscript
+ , D.Subscript
+ , D.SmallCaps
+ , D.Quoted
+ , D.Cite
+ , D.Space
+ , D.SoftBreak
+ , D.LineBreak
+ , D.Note
+ )
+ , pattern Str
+ , pattern Code
+ , pattern Math
+ , pattern RawInline
+ , pattern Link
+ , pattern Image
+ , pattern Span
+ , D.Alignment(..)
+ , D.ListAttributes
+ , D.ListNumberStyle(..)
+ , D.ListNumberDelim(..)
+ , D.Format
+ , pattern Format
+ , Attr
+ , nullAttr
+ , D.TableCell
+ , D.QuoteType(..)
+ , Target
+ , D.MathType(..)
+ , D.Citation
+ , pattern Citation
+ , citationId
+ , citationPrefix
+ , citationSuffix
+ , citationMode
+ , citationNoteNum
+ , citationHash
+ , D.CitationMode(..)
+ , D.pandocTypesVersion
+ ) where
+
+import qualified Text.Pandoc.Definition as D
+import qualified Data.Map as M
+import qualified Data.Text as T
+
+unpack2 :: (T.Text, T.Text) -> (String, String)
+unpack2 (x, y) = (T.unpack x, T.unpack y)
+
+pack2 :: (String, String) -> (T.Text, T.Text)
+pack2 (x, y) = (T.pack x, T.pack y)
+
+toLegacyMap :: M.Map T.Text a -> M.Map String a
+toLegacyMap = M.mapKeys T.unpack
+
+fromLegacyMap :: M.Map String a -> M.Map T.Text a
+fromLegacyMap = M.mapKeys T.pack
+
+toLegacyAttr :: D.Attr -> Attr
+toLegacyAttr (a, b, c) = (T.unpack a, map T.unpack b, map unpack2 c)
+
+fromLegacyAttr :: Attr -> D.Attr
+fromLegacyAttr (a, b, c) = (T.pack a, map T.pack b, map pack2 c)
+
+pattern Meta :: M.Map String D.MetaValue -> D.Meta
+pattern Meta {unMeta} <- D.Meta (toLegacyMap -> unMeta)
+ where
+ Meta = D.Meta . fromLegacyMap
+
+pattern MetaMap :: M.Map String D.MetaValue -> D.MetaValue
+pattern MetaMap x <- D.MetaMap (toLegacyMap -> x)
+ where
+ MetaMap = D.MetaMap . fromLegacyMap
+
+pattern MetaString :: String -> D.MetaValue
+pattern MetaString x <- D.MetaString (T.unpack -> x)
+ where
+ MetaString = D.MetaString . T.pack
+
+lookupMeta :: String -> D.Meta -> Maybe D.MetaValue
+lookupMeta = D.lookupMeta . T.pack
+
+pattern CodeBlock :: Attr -> String -> D.Block
+pattern CodeBlock a s <- D.CodeBlock (toLegacyAttr -> a) (T.unpack -> s)
+ where
+ CodeBlock a = D.CodeBlock (fromLegacyAttr a) . T.pack
+
+pattern RawBlock :: D.Format -> String -> D.Block
+pattern RawBlock f s <- D.RawBlock f (T.unpack -> s)
+ where
+ RawBlock f = D.RawBlock f . T.pack
+
+pattern Header :: Int -> Attr -> [D.Inline] -> D.Block
+pattern Header n a i <- D.Header n (toLegacyAttr -> a) i
+ where
+ Header n = D.Header n . fromLegacyAttr
+
+pattern Div :: Attr -> [D.Block] -> D.Block
+pattern Div a b <- D.Div (toLegacyAttr -> a) b
+ where
+ Div = D.Div . fromLegacyAttr
+
+pattern Str :: String -> D.Inline
+pattern Str s <- D.Str (T.unpack -> s)
+ where
+ Str = D.Str . T.pack
+
+pattern Code :: Attr -> String -> D.Inline
+pattern Code a s <- D.Code (toLegacyAttr -> a) (T.unpack -> s)
+ where
+ Code a = D.Code (fromLegacyAttr a) . T.pack
+
+pattern Math :: D.MathType -> String -> D.Inline
+pattern Math m s <- D.Math m (T.unpack -> s)
+ where
+ Math m = D.Math m . T.pack
+
+pattern RawInline :: D.Format -> String -> D.Inline
+pattern RawInline f s <- D.RawInline f (T.unpack -> s)
+ where
+ RawInline f = D.RawInline f . T.pack
+
+pattern Link :: Attr -> [D.Inline] -> Target -> D.Inline
+pattern Link a i t <- D.Link (toLegacyAttr -> a) i (unpack2 -> t)
+ where
+ Link a i = D.Link (fromLegacyAttr a) i . pack2
+
+pattern Image :: Attr -> [D.Inline] -> Target -> D.Inline
+pattern Image a i t <- D.Image (toLegacyAttr -> a) i (unpack2 -> t)
+ where
+ Image a i = D.Image (fromLegacyAttr a) i . pack2
+
+pattern Span :: Attr -> [D.Inline] -> D.Inline
+pattern Span a i <- D.Span (toLegacyAttr -> a) i
+ where
+ Span = D.Span . fromLegacyAttr
+
+pattern Format :: String -> D.Format
+pattern Format x <- D.Format (T.unpack -> x)
+ where
+ Format x = D.Format $ T.pack x
+
+type Attr = (String, [String], [(String, String)])
+
+nullAttr :: Attr
+nullAttr = ("", [], [])
+
+type Target = (String, String)
+
+pattern Citation
+ :: String
+ -> [D.Inline]
+ -> [D.Inline]
+ -> D.CitationMode
+ -> Int
+ -> Int
+ -> D.Citation
+pattern Citation
+ { citationId
+ , citationPrefix
+ , citationSuffix
+ , citationMode
+ , citationNoteNum
+ , citationHash } <- D.Citation (T.unpack -> citationId)
+ citationPrefix
+ citationSuffix
+ citationMode
+ citationNoteNum
+ citationHash
+ where
+ Citation = D.Citation . T.pack
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pandoc-types-1.17.6.1/benchmark/bench.hs
new/pandoc-types-1.20/benchmark/bench.hs
--- old/pandoc-types-1.17.6.1/benchmark/bench.hs 2019-08-23
20:00:14.000000000 +0200
+++ new/pandoc-types-1.20/benchmark/bench.hs 2019-11-12 17:27:21.000000000
+0100
@@ -4,6 +4,7 @@
import Text.Pandoc.Definition (Pandoc, Inline (Str))
import Text.Pandoc.Walk (walk)
import Text.Pandoc.Builder
+import qualified Data.Text as T
main :: IO ()
main =
@@ -14,16 +15,16 @@
]
prependZeroWidthSpace :: Inline -> Inline
-prependZeroWidthSpace (Str s) = Str ('\8203' : s)
+prependZeroWidthSpace (Str s) = Str (T.cons '\8203' s)
prependZeroWidthSpace x = x
prependZeroWidthSpace' :: Inline -> [Inline]
-prependZeroWidthSpace' (Str s) = [Str ('\8203' : s)]
+prependZeroWidthSpace' (Str s) = [Str (T.cons '\8203' s)]
prependZeroWidthSpace' x = [x]
prependZeroWidthSpace'' :: [Inline] -> [Inline]
prependZeroWidthSpace'' (Str s : xs) =
- Str ('\8203' : s) : prependZeroWidthSpace'' xs
+ Str (T.cons '\8203' s) : prependZeroWidthSpace'' xs
prependZeroWidthSpace'' (x : xs) =
x : prependZeroWidthSpace'' xs
prependZeroWidthSpace'' [] = []
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pandoc-types-1.17.6.1/changelog
new/pandoc-types-1.20/changelog
--- old/pandoc-types-1.17.6.1/changelog 2019-09-24 18:17:32.000000000 +0200
+++ new/pandoc-types-1.20/changelog 2019-11-12 17:32:19.000000000 +0100
@@ -1,5 +1,58 @@
-[1.17.6.1]
+[1.20]
+
+ * Change all uses of String in type definitions to strict Text
+ (Christian Despres) [API change]. The MetaValue instances using String
+ have been kept, and parallel ones using Text were added.
+
+ * Remove the Arbitrary Text orphan instance (Christian Despres).
+ This instance should not have been in the Text.Pandoc.Arbitrary, since
+ it would have been exported with the rest of the instances in that
+ module. Instead, more shrink* functions were added to compensate for
+ the absence of this instance.
+
+ * Add Text.Pandoc.Legacy.Definition (Christian Despres).
+ To ease the transition to Text, this module provides an interface
+ compatible with the String one, so that any unqualified imports of
+ Text.Pandoc.Definition in other packages can be replaced by
+ Text.Pandoc.Legacy.Definition without other code changes. This is done
+ with PatternSynonyms.
+
+ Some of the constructors of the types Meta, MetaValue, Block, Inline,
+ Format, and Citation required PatternSynonym handling. The Attr and
+ Target types had to be redefined, and certain functions had to be
+ rewritten to handle String or the old Attr and Target types in this
+ module. This module otherwise exports the definitions in
+ Text.Pandoc.Definition unchanged.
+
+ This is not a perfect drop-in replacement, since some imports like
+ Inline(..) will no longer work. This may also cause incomplete pattern
+ warnings when used, since the coverage checker does not seem to be
+ aware of PatternSynonyms.
+ * Add Text.Pandoc.Legacy.Builder (Christian Despres).
+ Like Text.Pandoc.Legacy.Definition, this modules provides a
+ compatibility interface while the transition to Text takes
+ place. Unlike that module, this module only requires redefining the
+ ToMetaValue and HasMeta classes and a few functions so that they use
+ the old types. No PatternSynonyms are required.
+
+ * Change Semigroup/Monoid instance for Meta.
+ Previously `<>` was left-biased, so if meta1 and meta2 both
+ contained a field 'foo', the value from meta1 would be retained
+ in `meta1 <> meta2`, and the value from meta2 ignored.
+ This is counterintuitive and doesn't work well with pandoc;
+ for example, we want to be able to override a value in an
+ earlier `--metadata-file` with a later one on the command line.
+
+ It also makes the behavior of metadata more like other
+ things (such as reference links, where later definitions
+ take precedence over earlier ones).
+
+ Note that this change may break some current workflows,
+ if one is relying on metadata fields that occur later in
+ a document to be overridden by those occurring earlier.
+
+[1.17.6.1]
* Relax version bound for string-qq.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pandoc-types-1.17.6.1/pandoc-types.cabal
new/pandoc-types-1.20/pandoc-types.cabal
--- old/pandoc-types-1.17.6.1/pandoc-types.cabal 2019-09-24
18:16:57.000000000 +0200
+++ new/pandoc-types-1.20/pandoc-types.cabal 2019-11-12 17:32:13.000000000
+0100
@@ -1,5 +1,5 @@
Name: pandoc-types
-Version: 1.17.6.1
+Version: 1.20
Synopsis: Types for representing a structured document
Description: @Text.Pandoc.Definition@ defines the 'Pandoc' data
structure, which is used by pandoc to represent
@@ -46,9 +46,12 @@
Text.Pandoc.Builder
Text.Pandoc.JSON
Text.Pandoc.Arbitrary
+ Text.Pandoc.Legacy.Builder
+ Text.Pandoc.Legacy.Definition
Other-modules: Paths_pandoc_types
Build-depends: base >= 4.5 && < 5,
containers >= 0.3,
+ text,
deepseq >= 1.4.1 && < 1.5,
syb >= 0.1 && < 0.8,
ghc-prim >= 0.2,
@@ -69,6 +72,7 @@
syb,
aeson >= 0.6.2 && < 1.5,
containers >= 0.3,
+ text,
bytestring >= 0.9 && < 0.11,
test-framework >= 0.3 && < 0.9,
test-framework-hunit >= 0.2 && < 0.4,
@@ -84,5 +88,6 @@
hs-source-dirs: benchmark
build-depends: pandoc-types,
base >= 4.5 && < 5,
+ text,
criterion >= 1.0 && < 1.6
ghc-options: -rtsopts -Wall -fno-warn-unused-do-bind -O2
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pandoc-types-1.17.6.1/test/test-pandoc-types.hs
new/pandoc-types-1.20/test/test-pandoc-types.hs
--- old/pandoc-types-1.17.6.1/test/test-pandoc-types.hs 2019-08-23
20:00:14.000000000 +0200
+++ new/pandoc-types-1.20/test/test-pandoc-types.hs 2019-11-12
17:27:21.000000000 +0100
@@ -7,12 +7,13 @@
import Data.Generics
import Data.List (tails)
import Test.HUnit (Assertion, assertEqual, assertFailure)
-import Data.Char (toUpper)
import Data.Aeson (FromJSON, ToJSON, encode, decode)
import Test.Framework
import Test.Framework.Providers.QuickCheck2 (testProperty)
import Test.Framework.Providers.HUnit (testCase)
import qualified Data.Map as M
+import Data.Text (Text)
+import qualified Data.Text as T
import Data.String.QQ
import Data.ByteString.Lazy (ByteString)
import qualified Data.Monoid as Monoid
@@ -37,7 +38,7 @@
query (mconcat . map f . tails) d
inlineTrans :: Inline -> Inline
-inlineTrans (Str xs) = Str $ map toUpper xs
+inlineTrans (Str xs) = Str $ T.toUpper xs
inlineTrans (Emph xs) = Strong xs
inlineTrans x = x
@@ -62,7 +63,7 @@
blocksTrans [Div _ xs] = xs
blocksTrans xs = xs
-inlineQuery :: Inline -> String
+inlineQuery :: Inline -> Text
inlineQuery (Str xs) = xs
inlineQuery _ = ""