diff options
author | John MacFarlane <jgm@berkeley.edu> | 2016-03-18 16:36:56 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2016-03-18 16:36:56 -0700 |
commit | 976e7e2054c2a4c889c3f02b83fdd092513f22b4 (patch) | |
tree | c37d5d0731ae2fe2c55209fe215a156a74165bc2 | |
parent | e821b05125c8b18a1c09a5d4fd62ee7483704bbb (diff) | |
download | pandoc-976e7e2054c2a4c889c3f02b83fdd092513f22b4.tar.gz |
ConTeXt writer: fix whitespace at line beginning in line blocks.
Add a `\strut` after `\crlf` before space.
Closes #2744, #2745. Thanks to @c-foster.
This uses the fix suggested by @c-foster.
Mid-line spaces are still not supported, because of limitations
of the Markdown parser.
-rw-r--r-- | src/Text/Pandoc/Writers/ConTeXt.hs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Writers/ConTeXt.hs b/src/Text/Pandoc/Writers/ConTeXt.hs index 498e2d10f..8d54d62bd 100644 --- a/src/Text/Pandoc/Writers/ConTeXt.hs +++ b/src/Text/Pandoc/Writers/ConTeXt.hs @@ -279,7 +279,17 @@ blockListToConTeXt lst = liftM vcat $ mapM blockToConTeXt lst -- | Convert list of inline elements to ConTeXt. inlineListToConTeXt :: [Inline] -- ^ Inlines to convert -> State WriterState Doc -inlineListToConTeXt lst = liftM hcat $ mapM inlineToConTeXt lst +inlineListToConTeXt lst = liftM hcat $ mapM inlineToConTeXt $ addStruts lst + -- We add a \strut after a line break that precedes a space, + -- or the space gets swallowed + where addStruts (LineBreak : s : xs) | isSpacey s = + LineBreak : RawInline (Format "context") "\\strut " : s : + addStruts xs + addStruts (x:xs) = x : addStruts xs + addStruts [] = [] + isSpacey Space = True + isSpacey (Str ('\160':_)) = True + isSpacey _ = False -- | Convert inline element to ConTeXt inlineToConTeXt :: Inline -- ^ Inline to convert |