aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2019-03-27 16:52:17 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2019-03-27 16:52:17 -0700
commit2138ef823921ae58a71c6ca367ccfac4e9367ff9 (patch)
treeeaa5c5cf4669fd12bc4d759bdbb97bb5f31bf637
parent47aaad705af05514f30f4e85577b991afbf9eb8d (diff)
downloadpandoc-2138ef823921ae58a71c6ca367ccfac4e9367ff9.tar.gz
ipynb reader: avoid introducing spurious `.0` on integers in metadata.
-rw-r--r--pandoc.cabal1
-rw-r--r--src/Text/Pandoc/Readers/Ipynb.hs5
2 files changed, 5 insertions, 1 deletions
diff --git a/pandoc.cabal b/pandoc.cabal
index 7895f535d..d9eb0404f 100644
--- a/pandoc.cabal
+++ b/pandoc.cabal
@@ -375,6 +375,7 @@ library
random >= 1 && < 1.2,
pandoc-types >= 1.17.5 && < 1.18,
aeson >= 0.7 && < 1.5,
+ scientific >= 0.3 && < 0.4,
aeson-pretty >= 0.8.5 && < 0.9,
tagsoup >= 0.14.6 && < 0.15,
base64-bytestring >= 0.1 && < 1.1,
diff --git a/src/Text/Pandoc/Readers/Ipynb.hs b/src/Text/Pandoc/Readers/Ipynb.hs
index 58277be7a..6c8708409 100644
--- a/src/Text/Pandoc/Readers/Ipynb.hs
+++ b/src/Text/Pandoc/Readers/Ipynb.hs
@@ -23,6 +23,7 @@ import Data.List (isPrefixOf)
import Data.Maybe (fromMaybe)
import Data.Digest.Pure.SHA (sha1, showDigest)
import Text.Pandoc.Options
+import qualified Data.Scientific as Scientific
import qualified Text.Pandoc.Builder as B
import Text.Pandoc.Logging
import Text.Pandoc.Definition
@@ -209,7 +210,9 @@ jsonMetaToMeta = M.mapKeys T.unpack . M.map valueToMetaValue
Success xs -> MetaList $ map valueToMetaValue xs
valueToMetaValue (Bool b) = MetaBool b
valueToMetaValue (String t) = MetaString (T.unpack t)
- valueToMetaValue (Number n) = MetaString (show n)
+ valueToMetaValue (Number n)
+ | Scientific.isInteger n = MetaString (show (floor n :: Integer))
+ | otherwise = MetaString (show n)
valueToMetaValue Aeson.Null = MetaString ""
jsonMetaToPairs :: JSONMeta -> [(String, String)]