From e57953b9f04cd05607eb1b75fd9fb194d48feb0a Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 18 Sep 2023 15:59:26 -0700 Subject: [PATCH] Fix uneven indents in LaTeX line block output. Closes #9088. --- src/Text/Pandoc/Writers/LaTeX.hs | 9 +++------ test/command/9088.md | 10 ++++++++++ 2 files changed, 13 insertions(+), 6 deletions(-) create mode 100644 test/command/9088.md diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index 937729c12..1b1966e05 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -744,16 +744,13 @@ inlineListToLaTeX :: PandocMonad m inlineListToLaTeX lst = hcat <$> mapM inlineToLaTeX (fixLineInitialSpaces . fixInitialLineBreaks $ lst) -- nonbreaking spaces (~) in LaTeX don't work after line breaks, - -- so we turn nbsps after hard breaks to \hspace commands. - -- this is mostly used in verse. + -- so we insert a strut: this is mostly used in verse. where fixLineInitialSpaces [] = [] fixLineInitialSpaces (LineBreak : Str s : xs) | Just ('\160', _) <- T.uncons s - = LineBreak : fixNbsps s <> fixLineInitialSpaces xs + = LineBreak : RawInline "latex" "\\strut " : Str s + : fixLineInitialSpaces xs fixLineInitialSpaces (x:xs) = x : fixLineInitialSpaces xs - fixNbsps s = let (ys,zs) = T.span (=='\160') s - in replicate (T.length ys) hspace <> [Str zs] - hspace = RawInline "latex" "\\hspace*{0.333em}" -- We need \hfill\break for a line break at the start -- of a paragraph. See #5591. fixInitialLineBreaks (LineBreak:xs) = diff --git a/test/command/9088.md b/test/command/9088.md new file mode 100644 index 000000000..fca63003d --- /dev/null +++ b/test/command/9088.md @@ -0,0 +1,10 @@ +``` +% pandoc -t latex +| 0 - A +| 1 - B +| 2 - C +^D +~~~0 - A\\ +\strut ~~~1 - B\\ +\strut ~~~2 - C +```