Skip to content

Commit 666b39f

Browse files
committed
Merge remote-tracking branch 'origin/master' into SageMath-support
2 parents 965b467 + a4caa40 commit 666b39f

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ pandoc-plot uses [Semantic Versioning](http://semver.org/spec/v2.0.0.html)
55
## Release 1.5.0
66

77
* Added support for [Sage](https://www.sagemath.org/) (#44)
8+
* Fixed an issue where the parsing of default save format from configuration was overly restrictive (#42).
89

910
## Release 1.4.1
1011

src/Text/Pandoc/Filter/Plot/Monad/Types.hs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ where
3434
import Data.Char (toLower)
3535
import Data.List (intersperse)
3636
import Data.String (IsString (..))
37-
import Data.Text (Text, pack)
38-
import Data.Yaml (FromJSON, ToJSON (toJSON))
37+
import Data.Text (Text, pack, unpack)
38+
import Data.Yaml (FromJSON(..), ToJSON (toJSON), withText)
3939
import GHC.Generics (Generic)
4040
import System.FilePath (splitFileName)
4141
import System.Info (os)
@@ -232,12 +232,16 @@ instance IsString SaveFormat where
232232
mconcat
233233
[ s,
234234
" is not one of the valid save formats : ",
235-
mconcat $ intersperse ", " $ show <$> saveFormats
235+
mconcat $ intersperse ", " $ show <$> saveFormats,
236+
" (and lowercase variations). "
236237
]
237238
where
238239
saveFormats = enumFromTo minBound maxBound :: [SaveFormat]
239240

240-
instance FromJSON SaveFormat
241+
-- | Use the IsString instance to parse JSON so that the parsing is flexible
242+
-- with respect to uppercase/lowercase (#42)
243+
instance FromJSON SaveFormat where
244+
parseJSON = withText "SaveFormat" (pure . fromString . unpack)
241245

242246
instance ToJSON SaveFormat where
243247
toJSON = toJSON . extension

0 commit comments

Comments
 (0)