aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2019-08-21 08:59:15 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2019-08-25 14:24:31 -0700
commitfdb7a5b79fd180c77cf72d8b0d0f75b334ed56e1 (patch)
tree8d9f7f7537586cb664ee7154f48d40d552a1052e /src/Text
parent92debe4b9e4bd578290cb24375693d644acb1744 (diff)
downloadpandoc-fdb7a5b79fd180c77cf72d8b0d0f75b334ed56e1.tar.gz
Don't add a newline if there's already one.
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/App.hs9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/Text/Pandoc/App.hs b/src/Text/Pandoc/App.hs
index 4897366c3..741f2d37b 100644
--- a/src/Text/Pandoc/App.hs
+++ b/src/Text/Pandoc/App.hs
@@ -299,10 +299,11 @@ convertWithOpts opts = do
TL.unpack (TE.decodeUtf8With TE.lenientDecode err')
Nothing -> do
- let addNl = if standalone
- then id
- else (<> T.singleton '\n')
- output <- addNl <$> f writerOptions doc
+ let ensureNl t
+ | standalone = t
+ | T.null t || T.last t /= '\n' = t <> T.singleton '\n'
+ | otherwise = t
+ output <- ensureNl <$> f writerOptions doc
writerFn eol outputFile =<<
if optSelfContained opts && htmlFormat format
-- TODO not maximally efficient; change type