From da717de334d41b6dbac76bd8338ffaf2d7e75e25 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Tue, 27 Jun 2023 11:41:12 -0700 Subject: Fix toTextM for Windows. We forgot to filter out CRs as we do in toText. --- src/Text/Pandoc/Class/PandocMonad.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/Text') diff --git a/src/Text/Pandoc/Class/PandocMonad.hs b/src/Text/Pandoc/Class/PandocMonad.hs index 6228c296b..75ad85d91 100644 --- a/src/Text/Pandoc/Class/PandocMonad.hs +++ b/src/Text/Pandoc/Class/PandocMonad.hs @@ -412,7 +412,7 @@ withPaths (p:ps) action fp = -- with source position. toTextM :: PandocMonad m => FilePath -> B.ByteString -> m T.Text toTextM fp bs = - case TSE.decodeUtf8' . dropBOM $ bs of + case TSE.decodeUtf8' . filterCRs . dropBOM $ bs of Left (TSE.DecodeError _ (Just w)) -> case B.elemIndex w bs of Just offset -> @@ -425,6 +425,7 @@ toTextM fp bs = if "\xEF\xBB\xBF" `B.isPrefixOf` bs' then B.drop 3 bs' else bs' + filterCRs = B.filter (/=13) -- | Returns @fp@ if the file exists in the current directory; otherwise -- searches for the data file relative to @/subdir/@. Returns @Nothing@ -- cgit v1.2.3