diff options
author | John MacFarlane <jgm@berkeley.edu> | 2019-03-28 16:20:39 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2019-03-28 16:20:39 -0700 |
commit | 4c9a68e83f2d7b87d11ce32a9c5bb662b332dce4 (patch) | |
tree | 234568617b335fcac4c4f431c9c707f55dabaee2 | |
parent | ba613b2e9ee8c49b20d652ced066c98429bca3a2 (diff) | |
download | pandoc-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.
-rw-r--r-- | src/Text/Pandoc/Writers/Markdown.hs | 5 |
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. |