git.iko.soy/typeable/pandoc
on master help sign in
Use \url{} for autolinks in LaTeX writer.
271c3f9fiddlosopher
src/Text/Pandoc/Writers/LaTeX.hs+5−2
@@ -250,9 +250,12 @@ inlineToLaTeX (HtmlInline str) = return ""
250inlineToLaTeX (LineBreak) = return "\\\\\n"
250inlineToLaTeX (LineBreak) = return "\\\\\n"
251inlineToLaTeX Space = return " "
251inlineToLaTeX Space = return " "
252inlineToLaTeX (Link text (src, tit)) = do
252inlineToLaTeX (Link text (src, tit)) = do
253− contents <- inlineListToLaTeX $ deVerb text
254 addToHeader "\\usepackage[breaklinks=true]{hyperref}"
253 addToHeader "\\usepackage[breaklinks=true]{hyperref}"
254+ case text of
255+ [Code x] | x == src -> -- autolink
256+ return $ "\\url{" ++ x ++ "}"
257+ _ -> do contents <- inlineListToLaTeX $ deVerb text
255− return $ "\\href{" ++ src ++ "}{" ++ contents ++ "}"
258+ return $ "\\href{" ++ src ++ "}{" ++ contents ++ "}"
256inlineToLaTeX (Image alternate (source, tit)) = do
259inlineToLaTeX (Image alternate (source, tit)) = do
257 addToHeader "\\usepackage{graphicx}"
260 addToHeader "\\usepackage{graphicx}"
258 return $ "\\includegraphics{" ++ source ++ "}"
261 return $ "\\includegraphics{" ++ source ++ "}"
tests/writer.latex+3−3
@@ -590,17 +590,17 @@ Here's an \href{/script?foo=1&bar=2}{inline link in pointy braces}.
590
590
591\subsection{Autolinks}
591\subsection{Autolinks}
592
592
593−With an ampersand: \href{http://example.com/?foo=1&bar=2}{\texttt{http://example.com/?foo=1\&bar=2}}
593+With an ampersand: \url{http://example.com/?foo=1&bar=2}
594
594
595\begin{itemize}
595\begin{itemize}
596\item In a list?
596\item In a list?
597−\item \href{http://example.com/}{\texttt{http://example.com/}}
597+\item \url{http://example.com/}
598\item It should.
598\item It should.
599\end{itemize}
599\end{itemize}
600An e-mail address: \href{mailto:nobody@nowhere.net}{\texttt{nobody@nowhere.net}}
600An e-mail address: \href{mailto:nobody@nowhere.net}{\texttt{nobody@nowhere.net}}
601
601
602\begin{quote}
602\begin{quote}
603−Blockquoted: \href{http://example.com/}{\texttt{http://example.com/}}
603+Blockquoted: \url{http://example.com/}
604
604
605\end{quote}
605\end{quote}
606Auto-links should not occur here: \verb!<http://example.com/>!
606Auto-links should not occur here: \verb!<http://example.com/>!