diff options
| author | John MacFarlane <jgm@berkeley.edu> | 2023-06-27 11:41:12 -0700 |
|---|---|---|
| committer | John MacFarlane <jgm@berkeley.edu> | 2023-06-27 11:41:12 -0700 |
| commit | da717de334d41b6dbac76bd8338ffaf2d7e75e25 (patch) | |
| tree | 01786d395e29c90a1bc042f0fb4e53539aa12cf4 /src | |
| parent | e0bea476bf3932e32b2e15827dfded61fcd9e87a (diff) | |
Fix toTextM for Windows.
We forgot to filter out CRs as we do in toText.
Diffstat (limited to 'src')
| -rw-r--r-- | src/Text/Pandoc/Class/PandocMonad.hs | 3 |
1 files changed, 2 insertions, 1 deletions
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@ |
