Fix uneven indents in LaTeX line block output.

Closes #9088.
This commit is contained in:
John MacFarlane
2023-09-18 15:59:26 -07:00
parent 0d27947b96
commit e57953b9f0
2 changed files with 13 additions and 6 deletions
+3 -6
View File
@@ -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) =
+10
View File
@@ -0,0 +1,10 @@
```
% pandoc -t latex
| 0 - A
| 1 - B
| 2 - C
^D
~~~0 - A\\
\strut ~~~1 - B\\
\strut ~~~2 - C
```