From c4a81fb941adf6c3bf524916c46623685d276f32 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Fri, 3 May 2019 22:41:24 -0700 Subject: metaToJSON: treat digits starting with 0 as a string... not a number. Closes #5479. --- src/Text/Pandoc/Writers/Shared.hs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Text/Pandoc/Writers/Shared.hs b/src/Text/Pandoc/Writers/Shared.hs index 948308b50..e99758cba 100644 --- a/src/Text/Pandoc/Writers/Shared.hs +++ b/src/Text/Pandoc/Writers/Shared.hs @@ -109,6 +109,9 @@ metaValueToJSON blockWriter inlineWriter (MetaMap metamap) = toJSON <$> metaValueToJSON blockWriter inlineWriter (MetaList xs) = toJSON <$> Traversable.mapM (metaValueToJSON blockWriter inlineWriter) xs metaValueToJSON _ _ (MetaBool b) = return $ toJSON b +metaValueToJSON _ inlineWriter (MetaString s@('0':_)) = + -- don't treat string with leading 0 as string (#5479) + toJSON <$> inlineWriter (Builder.toList (Builder.text s)) metaValueToJSON _ inlineWriter (MetaString s) = case safeRead s of Just (n :: Scientific) -> return $ Aeson.Number n -- cgit v1.2.3