From 2138ef823921ae58a71c6ca367ccfac4e9367ff9 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Wed, 27 Mar 2019 16:52:17 -0700 Subject: ipynb reader: avoid introducing spurious `.0` on integers in metadata. --- src/Text/Pandoc/Readers/Ipynb.hs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/Text') 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)] -- cgit v1.2.3