diff options
| author | John MacFarlane <[email protected]> | 2021-10-02 08:26:35 -0700 |
|---|---|---|
| committer | John MacFarlane <[email protected]> | 2021-10-02 12:04:42 -0700 |
| commit | 650b13e2d6952efc3bf07c496ffc10c8a09830c4 (patch) | |
| tree | 3b9950341ff72700a4a4eba518f151f595e67a2e /src/Text | |
| parent | 9fa2d0892e37f0f1e4cbc397603ce0bcfc135eca (diff) | |
Docx reader spacing fix: avoid creating `Str ""`.
Diffstat (limited to 'src/Text')
| -rw-r--r-- | src/Text/Pandoc/Readers/Docx.hs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Readers/Docx.hs b/src/Text/Pandoc/Readers/Docx.hs index c311fb367..c45dc2d1d 100644 --- a/src/Text/Pandoc/Readers/Docx.hs +++ b/src/Text/Pandoc/Readers/Docx.hs @@ -530,14 +530,22 @@ trimSps = trimlSps . trimrSps SoftBreak :< xs -> trimlSps $ Many xs LineBreak :< xs -> trimlSps $ Many xs Str t :< xs - | startsWithSpace t -> Many (Str (T.dropWhile (==' ') t) <| xs) + | startsWithSpace t -> + let t' = T.dropWhile (==' ') t + in if T.null t' + then trimlSps $ Many xs + else Many (Str t' <| xs) _ -> Many ils trimrSps (Many ils) = case viewr ils of (xs :> SoftBreak) -> trimrSps $ Many xs (xs :> LineBreak) -> trimrSps $ Many xs (xs :> Str t) - | endsWithSpace t -> Many (xs |> Str (T.dropWhileEnd (==' ') t)) + | endsWithSpace t -> + let t' = T.dropWhileEnd (==' ') t + in if T.null t' + then trimrSps $ Many xs + else Many (xs |> Str t') _ -> Many ils startsWithSpace t = case T.uncons t of Just (' ',_) -> True |
