aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Writers
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2019-03-28 16:20:39 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2019-03-28 16:20:39 -0700
commit4c9a68e83f2d7b87d11ce32a9c5bb662b332dce4 (patch)
tree234568617b335fcac4c4f431c9c707f55dabaee2 /src/Text/Pandoc/Writers
parentba613b2e9ee8c49b20d652ced066c98429bca3a2 (diff)
downloadpandoc-4c9a68e83f2d7b87d11ce32a9c5bb662b332dce4.tar.gz
Markdown writer: better rendering of numbers.
If the number is integral, we render it as an integral not a float. Closes #5398.
Diffstat (limited to 'src/Text/Pandoc/Writers')
-rw-r--r--src/Text/Pandoc/Writers/Markdown.hs5
1 files changed, 4 insertions, 1 deletions
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.