diff options
| author | John MacFarlane <jgm@berkeley.edu> | 2018-11-06 22:54:43 -0800 | 
|---|---|---|
| committer | John MacFarlane <jgm@berkeley.edu> | 2018-11-06 22:54:43 -0800 | 
| commit | 6619b96dd70296112c2e31f9a1df6b8b6d1d698e (patch) | |
| tree | 68e766b590b231ee8a69958b9f3af5afdf3693e3 /src/Text | |
| parent | 985db7b0a8a090e7654642651c75bffcf53f8d38 (diff) | |
| download | pandoc-6619b96dd70296112c2e31f9a1df6b8b6d1d698e.tar.gz | |
Text.Pandoc.Pretty: don't render BreakingSpace at end of line...
or beginning of line.
Closes #5050.
Diffstat (limited to 'src/Text')
| -rw-r--r-- | src/Text/Pandoc/Pretty.hs | 11 | 
1 files changed, 9 insertions, 2 deletions
| diff --git a/src/Text/Pandoc/Pretty.hs b/src/Text/Pandoc/Pretty.hs index ec1d36a68..a6e150a81 100644 --- a/src/Text/Pandoc/Pretty.hs +++ b/src/Text/Pandoc/Pretty.hs @@ -239,7 +239,7 @@ render linelen doc = fromString . mconcat . reverse . output $  renderDoc :: (IsString a, Monoid a)            => Doc -> DocState a -renderDoc = renderList . toList . unDoc +renderDoc = renderList . dropWhile (== BreakingSpace) . toList . unDoc  data IsBlock = IsBlock Int [String] @@ -280,6 +280,9 @@ renderList [BlankLines _] = return ()  renderList (BlankLines m : BlankLines n : xs) =    renderList (BlankLines (max m n) : xs) +renderList (BlankLines num : BreakingSpace : xs) = +  renderList (BlankLines num : xs) +  renderList (BlankLines num : xs) = do    st <- get    case output st of @@ -290,6 +293,9 @@ renderList (BlankLines num : xs) = do  renderList (CarriageReturn : BlankLines m : xs) =    renderList (BlankLines m : xs) +renderList (CarriageReturn : BreakingSpace : xs) = +  renderList (CarriageReturn : xs) +  renderList (CarriageReturn : xs) = do    st <- get    if newlines st > 0 || null xs @@ -302,7 +308,8 @@ renderList (NewLine : xs) = do    outp (-1) "\n"    renderList xs -renderList (BreakingSpace : CarriageReturn : xs) = renderList (CarriageReturn:xs) +renderList (BreakingSpace : CarriageReturn : xs) = +  renderList (CarriageReturn:xs)  renderList (BreakingSpace : NewLine : xs) = renderList (NewLine:xs)  renderList (BreakingSpace : BlankLines n : xs) = renderList (BlankLines n:xs)  renderList (BreakingSpace : BreakingSpace : xs) = renderList (BreakingSpace:xs) | 
