LaTeX writer: allow alt text in figure to wrap.

Closes #11924.
This commit is contained in:
John MacFarlane
2026-10-02 10:00:31 -07:00
parent dc8f449fc7
commit 2d244c7180
5 changed files with 14 additions and 8 deletions
+2 -1
View File
@@ -1205,7 +1205,8 @@ inlineToLaTeX (Image attr@(_,_,kvs) description (source, _)) = do
_ -> ["keepaspectratio"]) <>
maybe [] (\x -> ["page=" <> literal x]) (lookup "page" kvs) <>
maybe [] (\x -> ["trim=" <> literal x]) (lookup "trim" kvs) <>
maybe [] (\x -> ["alt=" <> braces (literal x)]) mbalt <>
maybe [] (\x -> ["alt=" <>
braces (hsep $ map literal $ T.words x)]) mbalt <>
maybe [] (const ["clip"]) (lookup "clip" kvs)
options = if null optList
then empty
+2 -2
View File
@@ -70,7 +70,7 @@ tests = [ testGroup "code blocks"
"\\begin{description}\n\\item[foo] ~ \n\\subsection{bar}\n\nbaz\n\\end{description}"
, "containing image" =:
header 1 (image "imgs/foo.jpg" "" (text "Alt text")) =?>
"\\section{\\texorpdfstring{\\protect\\pandocbounded{\\includegraphics[keepaspectratio,alt={Alt text}]{imgs/foo.jpg}}}{Alt text}}"
"\\section{\\texorpdfstring{\\protect\\pandocbounded{\\includegraphics[keepaspectratio,alt={Alt\ntext}]{imgs/foo.jpg}}}{Alt text}}"
]
, testGroup "inline code"
[ "struck out and highlighted" =:
@@ -249,7 +249,7 @@ tests = [ testGroup "code blocks"
(plain $ image (pack "img.jpg") (pack "") (text "alt text"))
=?>
"\\begin{figure}[htbp]\n\\centering\n"
<> "\\pandocbounded{\\includegraphics[keepaspectratio,alt={alt text}]{img.jpg}}\n"
<> "\\pandocbounded{\\includegraphics[keepaspectratio,alt={alt\ntext}]{img.jpg}}\n"
<> "\\caption{caption}\n\\end{figure}"
]
]
+6 -3
View File
@@ -12,7 +12,8 @@
^D
\begin{figure}
\centering
\pandocbounded{\includegraphics[keepaspectratio,alt={This is a figure.}]{img.jpg}}
\pandocbounded{\includegraphics[keepaspectratio,alt={This is a
figure.}]{img.jpg}}
\caption{This is a figure.}
\end{figure}
@@ -50,7 +51,8 @@ Right & Left & Center & Default \\
\begin{figure}
\centering
\caption{This is a figure.}
\pandocbounded{\includegraphics[keepaspectratio,alt={This is a figure.}]{img.jpg}}
\pandocbounded{\includegraphics[keepaspectratio,alt={This is a
figure.}]{img.jpg}}
\end{figure}
\begin{longtable}[]{@{}rlcl@{}}
@@ -86,7 +88,8 @@ Right & Left & Center & Default \\
^D
\begin{figure}
\centering
\pandocbounded{\includegraphics[keepaspectratio,alt={This is a figure.}]{img.jpg}}
\pandocbounded{\includegraphics[keepaspectratio,alt={This is a
figure.}]{img.jpg}}
\caption{This is a figure.}
\end{figure}
+2 -1
View File
@@ -60,7 +60,8 @@
\begin{figure}
\centering
\pandocbounded{\includegraphics[keepaspectratio,alt={This is a test x = 5}]{test.png}}
\pandocbounded{\includegraphics[keepaspectratio,alt={This is a test x =
5}]{test.png}}
\caption{This is a test
\protect\VERB|\NormalTok{x }\OperatorTok{=} \DecValTok{5}|}
\end{figure}
+2 -1
View File
@@ -4,7 +4,8 @@
^D
\begin{figure}
\centering
\pandocbounded{\includegraphics[keepaspectratio,page=13,trim=1cm,clip,width=4cm,alt={Global frog population.}]{slides.pdf}}
\pandocbounded{\includegraphics[keepaspectratio,page=13,trim=1cm,clip,width=4cm,alt={Global
frog population.}]{slides.pdf}}
\caption{Global frog population.}
\end{figure}