diff options
author | John MacFarlane <jgm@berkeley.edu> | 2019-08-21 08:59:15 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2019-08-25 14:24:31 -0700 |
commit | fdb7a5b79fd180c77cf72d8b0d0f75b334ed56e1 (patch) | |
tree | 8d9f7f7537586cb664ee7154f48d40d552a1052e /src/Text/Pandoc | |
parent | 92debe4b9e4bd578290cb24375693d644acb1744 (diff) | |
download | pandoc-fdb7a5b79fd180c77cf72d8b0d0f75b334ed56e1.tar.gz |
Don't add a newline if there's already one.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r-- | src/Text/Pandoc/App.hs | 9 |
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 |