git.iko.soy/typeable/pandoc
on master help sign in
Don't add a newline if there's already one.
commitfdb7a5b79fd180c77cf72d8b0d0f75b334ed56e1 authorJohn MacFarlane <jgm@berkeley.edu> dateWed 21 Aug 2019, 08:59 (7 years ago) parent92debe4
1 file changed+5−4
src/Text/Pandoc/App.hs+5−4
src/Text/Pandoc/App.hs+5−4
@@ -299,10 +299,11 @@ convertWithOpts opts = do
299299 TL.unpack (TE.decodeUtf8With TE.lenientDecode err')
300300
301301 Nothing -> do
302− let addNl = if standalone
303− then id
304− else (<> T.singleton '\n')
305− output <- addNl <$> f writerOptions doc
302+ let ensureNl t
303+ | standalone = t
304+ | T.null t || T.last t /= '\n' = t <> T.singleton '\n'
305+ | otherwise = t
306+ output <- ensureNl <$> f writerOptions doc
306307 writerFn eol outputFile =<<
307308 if optSelfContained opts && htmlFormat format
308309 -- TODO not maximally efficient; change type