aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc
diff options
context:
space:
mode:
Diffstat (limited to 'src/Text/Pandoc')
-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