From 4c9a68e83f2d7b87d11ce32a9c5bb662b332dce4 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Thu, 28 Mar 2019 16:20:39 -0700 Subject: Markdown writer: better rendering of numbers. If the number is integral, we render it as an integral not a float. Closes #5398. --- src/Text/Pandoc/Writers/Markdown.hs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/Text/Pandoc') diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs index 3850dccd2..5f165f7d3 100644 --- a/src/Text/Pandoc/Writers/Markdown.hs +++ b/src/Text/Pandoc/Writers/Markdown.hs @@ -29,6 +29,7 @@ import Data.Maybe (fromMaybe) import Data.Monoid (Any (..)) import Data.Ord (comparing) import qualified Data.Set as Set +import qualified Data.Scientific as Scientific import Data.Text (Text) import qualified Data.Text as T import qualified Data.Vector as V @@ -164,7 +165,9 @@ jsonToYaml (String s) = | not (any isPunctuation x) -> text x | otherwise -> text $ "'" ++ substitute "'" "''" x ++ "'" jsonToYaml (Bool b) = text $ show b -jsonToYaml (Number n) = text $ show n +jsonToYaml (Number n) + | Scientific.isInteger n = text $ show (floor n :: Integer) + | otherwise = text $ show n jsonToYaml _ = empty -- | Return markdown representation of document. -- cgit v1.2.3