git.iko.soy/typeable/pandoc
on master help sign in
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.

commit976e7e2054c2a4c889c3f02b83fdd092513f22b4 authorJohn MacFarlane <jgm@berkeley.edu> dateFri 18 Mar 2016, 16:36 (11 years ago) parente821b05
1 file changed+11−1
src/Text/Pandoc/Writers/ConTeXt.hs+11−1
src/Text/Pandoc/Writers/ConTeXt.hs+11−1
@@ -279,7 +279,17 @@ blockListToConTeXt lst = liftM vcat $ mapM blockToConTeXt lst
279279-- | Convert list of inline elements to ConTeXt.
280280inlineListToConTeXt :: [Inline] -- ^ Inlines to convert
281281 -> State WriterState Doc
282−inlineListToConTeXt lst = liftM hcat $ mapM inlineToConTeXt lst
282+inlineListToConTeXt lst = liftM hcat $ mapM inlineToConTeXt $ addStruts lst
283+ -- We add a \strut after a line break that precedes a space,
284+ -- or the space gets swallowed
285+ where addStruts (LineBreak : s : xs) | isSpacey s =
286+ LineBreak : RawInline (Format "context") "\\strut " : s :
287+ addStruts xs
288+ addStruts (x:xs) = x : addStruts xs
289+ addStruts [] = []
290+ isSpacey Space = True
291+ isSpacey (Str ('\160':_)) = True
292+ isSpacey _ = False
283293
284294-- | Convert inline element to ConTeXt
285295inlineToConTeXt :: Inline -- ^ Inline to convert