Merge branch 'use-texorpdfstring' of https://github.com/wilx/pandoc into wilx-use-texorpdfstring
Conflicts: src/Text/Pandoc/Writers/LaTeX.hs tests/Tests/Writers/LaTeX.hs
This commit is contained in:
commit
544f3e5b45
5 changed files with 47 additions and 36 deletions
|
@ -613,6 +613,7 @@ sectionHeader :: Bool -- True for unnumbered
|
||||||
sectionHeader unnumbered ref level lst = do
|
sectionHeader unnumbered ref level lst = do
|
||||||
txt <- inlineListToLaTeX lst
|
txt <- inlineListToLaTeX lst
|
||||||
lab <- text `fmap` toLabel ref
|
lab <- text `fmap` toLabel ref
|
||||||
|
plain <- stringToLaTeX TextString $ foldl (++) "" $ map stringify lst
|
||||||
let noNote (Note _) = Str ""
|
let noNote (Note _) = Str ""
|
||||||
noNote x = x
|
noNote x = x
|
||||||
let lstNoNotes = walk noNote lst
|
let lstNoNotes = walk noNote lst
|
||||||
|
@ -625,7 +626,9 @@ sectionHeader unnumbered ref level lst = do
|
||||||
then return empty
|
then return empty
|
||||||
else do
|
else do
|
||||||
return $ brackets txtNoNotes
|
return $ brackets txtNoNotes
|
||||||
let stuffing = star <> optional <> braces txt
|
let stuffing = star <> optional <> braces (text "\\texorpdfstring"
|
||||||
|
<> braces txt
|
||||||
|
<> braces (text plain))
|
||||||
book <- gets stBook
|
book <- gets stBook
|
||||||
opts <- gets stOptions
|
opts <- gets stOptions
|
||||||
let level' = if book || writerChapters opts then level - 1 else level
|
let level' = if book || writerChapters opts then level - 1 else level
|
||||||
|
|
|
@ -52,7 +52,7 @@ tests = [ testGroup "code blocks"
|
||||||
[ "unnumbered header" =:
|
[ "unnumbered header" =:
|
||||||
headerWith ("foo",["unnumbered"],[]) 1
|
headerWith ("foo",["unnumbered"],[]) 1
|
||||||
(text "Header 1" <> note (plain $ text "note")) =?>
|
(text "Header 1" <> note (plain $ text "note")) =?>
|
||||||
"\\section*{Header 1\\footnote{note}}\\label{foo}\n\\addcontentsline{toc}{section}{Header 1}\n"
|
"\\section*{\\texorpdfstring{Header 1\\footnote{note}}{Header 1}}\\label{foo}\n\\addcontentsline{toc}{section}{Header 1}\n"
|
||||||
, "in list item" =:
|
, "in list item" =:
|
||||||
bulletList [header 2 (text "foo")] =?>
|
bulletList [header 2 (text "foo")] =?>
|
||||||
"\\begin{itemize}\n\\item ~\n \\subsection{foo}\n\\end{itemize}"
|
"\\begin{itemize}\n\\item ~\n \\subsection{foo}\n\\end{itemize}"
|
||||||
|
|
|
@ -70,7 +70,7 @@
|
||||||
|
|
||||||
\begin{document}
|
\begin{document}
|
||||||
|
|
||||||
\section{lhs test}\label{lhs-test}
|
\section{\texorpdfstring{lhs test}{lhs test}}\label{lhs-test}
|
||||||
|
|
||||||
\texttt{unsplit} is an arrow that takes a pair of values and combines them to
|
\texttt{unsplit} is an arrow that takes a pair of values and combines them to
|
||||||
return a single value:
|
return a single value:
|
||||||
|
|
|
@ -51,7 +51,7 @@
|
||||||
|
|
||||||
\begin{document}
|
\begin{document}
|
||||||
|
|
||||||
\section{lhs test}\label{lhs-test}
|
\section{\texorpdfstring{lhs test}{lhs test}}\label{lhs-test}
|
||||||
|
|
||||||
\texttt{unsplit} is an arrow that takes a pair of values and combines them to
|
\texttt{unsplit} is an arrow that takes a pair of values and combines them to
|
||||||
return a single value:
|
return a single value:
|
||||||
|
|
|
@ -72,32 +72,34 @@ markdown test suite.
|
||||||
|
|
||||||
\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}
|
\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}
|
||||||
|
|
||||||
\section{Headers}\label{headers}
|
\section{\texorpdfstring{Headers}{Headers}}\label{headers}
|
||||||
|
|
||||||
\subsection{Level 2 with an \href{/url}{embedded
|
\subsection{\texorpdfstring{Level 2 with an \href{/url}{embedded
|
||||||
link}}\label{level-2-with-an-embedded-link}
|
link}}{Level 2 with an embedded link}}\label{level-2-with-an-embedded-link}
|
||||||
|
|
||||||
\subsubsection{Level 3 with \emph{emphasis}}\label{level-3-with-emphasis}
|
\subsubsection{\texorpdfstring{Level 3 with
|
||||||
|
\emph{emphasis}}{Level 3 with emphasis}}\label{level-3-with-emphasis}
|
||||||
|
|
||||||
\paragraph{Level 4}\label{level-4}
|
\paragraph{\texorpdfstring{Level 4}{Level 4}}\label{level-4}
|
||||||
|
|
||||||
\subparagraph{Level 5}\label{level-5}
|
\subparagraph{\texorpdfstring{Level 5}{Level 5}}\label{level-5}
|
||||||
|
|
||||||
\section{Level 1}\label{level-1}
|
\section{\texorpdfstring{Level 1}{Level 1}}\label{level-1}
|
||||||
|
|
||||||
\subsection{Level 2 with \emph{emphasis}}\label{level-2-with-emphasis}
|
\subsection{\texorpdfstring{Level 2 with
|
||||||
|
\emph{emphasis}}{Level 2 with emphasis}}\label{level-2-with-emphasis}
|
||||||
|
|
||||||
\subsubsection{Level 3}\label{level-3}
|
\subsubsection{\texorpdfstring{Level 3}{Level 3}}\label{level-3}
|
||||||
|
|
||||||
with no blank line
|
with no blank line
|
||||||
|
|
||||||
\subsection{Level 2}\label{level-2}
|
\subsection{\texorpdfstring{Level 2}{Level 2}}\label{level-2}
|
||||||
|
|
||||||
with no blank line
|
with no blank line
|
||||||
|
|
||||||
\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}
|
\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}
|
||||||
|
|
||||||
\section{Paragraphs}\label{paragraphs}
|
\section{\texorpdfstring{Paragraphs}{Paragraphs}}\label{paragraphs}
|
||||||
|
|
||||||
Here's a regular paragraph.
|
Here's a regular paragraph.
|
||||||
|
|
||||||
|
@ -111,7 +113,7 @@ There should be a hard line break\\here.
|
||||||
|
|
||||||
\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}
|
\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}
|
||||||
|
|
||||||
\section{Block Quotes}\label{block-quotes}
|
\section{\texorpdfstring{Block Quotes}{Block Quotes}}\label{block-quotes}
|
||||||
|
|
||||||
E-mail style:
|
E-mail style:
|
||||||
|
|
||||||
|
@ -156,7 +158,7 @@ And a following paragraph.
|
||||||
|
|
||||||
\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}
|
\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}
|
||||||
|
|
||||||
\section{Code Blocks}\label{code-blocks}
|
\section{\texorpdfstring{Code Blocks}{Code Blocks}}\label{code-blocks}
|
||||||
|
|
||||||
Code:
|
Code:
|
||||||
|
|
||||||
|
@ -180,9 +182,9 @@ These should not be escaped: \$ \\ \> \[ \{
|
||||||
|
|
||||||
\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}
|
\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}
|
||||||
|
|
||||||
\section{Lists}\label{lists}
|
\section{\texorpdfstring{Lists}{Lists}}\label{lists}
|
||||||
|
|
||||||
\subsection{Unordered}\label{unordered}
|
\subsection{\texorpdfstring{Unordered}{Unordered}}\label{unordered}
|
||||||
|
|
||||||
Asterisks tight:
|
Asterisks tight:
|
||||||
|
|
||||||
|
@ -253,7 +255,7 @@ Minuses loose:
|
||||||
Minus 3
|
Minus 3
|
||||||
\end{itemize}
|
\end{itemize}
|
||||||
|
|
||||||
\subsection{Ordered}\label{ordered}
|
\subsection{\texorpdfstring{Ordered}{Ordered}}\label{ordered}
|
||||||
|
|
||||||
Tight:
|
Tight:
|
||||||
|
|
||||||
|
@ -319,7 +321,7 @@ Multiple paragraphs:
|
||||||
Item 3.
|
Item 3.
|
||||||
\end{enumerate}
|
\end{enumerate}
|
||||||
|
|
||||||
\subsection{Nested}\label{nested}
|
\subsection{\texorpdfstring{Nested}{Nested}}\label{nested}
|
||||||
|
|
||||||
\begin{itemize}
|
\begin{itemize}
|
||||||
\itemsep1pt\parskip0pt\parsep0pt
|
\itemsep1pt\parskip0pt\parsep0pt
|
||||||
|
@ -384,7 +386,8 @@ Same thing but with paragraphs:
|
||||||
Third
|
Third
|
||||||
\end{enumerate}
|
\end{enumerate}
|
||||||
|
|
||||||
\subsection{Tabs and spaces}\label{tabs-and-spaces}
|
\subsection{\texorpdfstring{Tabs and
|
||||||
|
spaces}{Tabs and spaces}}\label{tabs-and-spaces}
|
||||||
|
|
||||||
\begin{itemize}
|
\begin{itemize}
|
||||||
\item
|
\item
|
||||||
|
@ -400,7 +403,8 @@ Same thing but with paragraphs:
|
||||||
\end{itemize}
|
\end{itemize}
|
||||||
\end{itemize}
|
\end{itemize}
|
||||||
|
|
||||||
\subsection{Fancy list markers}\label{fancy-list-markers}
|
\subsection{\texorpdfstring{Fancy list
|
||||||
|
markers}{Fancy list markers}}\label{fancy-list-markers}
|
||||||
|
|
||||||
\begin{enumerate}
|
\begin{enumerate}
|
||||||
\def\labelenumi{(\arabic{enumi})}
|
\def\labelenumi{(\arabic{enumi})}
|
||||||
|
@ -488,7 +492,8 @@ B. Williams
|
||||||
|
|
||||||
\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}
|
\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}
|
||||||
|
|
||||||
\section{Definition Lists}\label{definition-lists}
|
\section{\texorpdfstring{Definition
|
||||||
|
Lists}{Definition Lists}}\label{definition-lists}
|
||||||
|
|
||||||
Tight using spaces:
|
Tight using spaces:
|
||||||
|
|
||||||
|
@ -591,7 +596,7 @@ orange fruit
|
||||||
\end{enumerate}
|
\end{enumerate}
|
||||||
\end{description}
|
\end{description}
|
||||||
|
|
||||||
\section{HTML Blocks}\label{html-blocks}
|
\section{\texorpdfstring{HTML Blocks}{HTML Blocks}}\label{html-blocks}
|
||||||
|
|
||||||
Simple block on one line:
|
Simple block on one line:
|
||||||
|
|
||||||
|
@ -653,7 +658,7 @@ Hr's:
|
||||||
|
|
||||||
\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}
|
\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}
|
||||||
|
|
||||||
\section{Inline Markup}\label{inline-markup}
|
\section{\texorpdfstring{Inline Markup}{Inline Markup}}\label{inline-markup}
|
||||||
|
|
||||||
This is \emph{emphasized}, and so \emph{is this}.
|
This is \emph{emphasized}, and so \emph{is this}.
|
||||||
|
|
||||||
|
@ -685,7 +690,8 @@ spaces: a\^{}b c\^{}d, a\textasciitilde{}b c\textasciitilde{}d.
|
||||||
|
|
||||||
\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}
|
\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}
|
||||||
|
|
||||||
\section{Smart quotes, ellipses, dashes}\label{smart-quotes-ellipses-dashes}
|
\section{\texorpdfstring{Smart quotes, ellipses,
|
||||||
|
dashes}{Smart quotes, ellipses, dashes}}\label{smart-quotes-ellipses-dashes}
|
||||||
|
|
||||||
``Hello,'' said the spider. ``\,`Shelob' is my name.''
|
``Hello,'' said the spider. ``\,`Shelob' is my name.''
|
||||||
|
|
||||||
|
@ -706,7 +712,7 @@ Ellipses\ldots{}and\ldots{}and\ldots{}.
|
||||||
|
|
||||||
\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}
|
\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}
|
||||||
|
|
||||||
\section{LaTeX}\label{latex}
|
\section{\texorpdfstring{LaTeX}{LaTeX}}\label{latex}
|
||||||
|
|
||||||
\begin{itemize}
|
\begin{itemize}
|
||||||
\itemsep1pt\parskip0pt\parsep0pt
|
\itemsep1pt\parskip0pt\parsep0pt
|
||||||
|
@ -754,7 +760,8 @@ Cat & 1 \\ \hline
|
||||||
|
|
||||||
\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}
|
\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}
|
||||||
|
|
||||||
\section{Special Characters}\label{special-characters}
|
\section{\texorpdfstring{Special
|
||||||
|
Characters}{Special Characters}}\label{special-characters}
|
||||||
|
|
||||||
Here is some unicode:
|
Here is some unicode:
|
||||||
|
|
||||||
|
@ -816,9 +823,9 @@ Minus: -
|
||||||
|
|
||||||
\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}
|
\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}
|
||||||
|
|
||||||
\section{Links}\label{links}
|
\section{\texorpdfstring{Links}{Links}}\label{links}
|
||||||
|
|
||||||
\subsection{Explicit}\label{explicit}
|
\subsection{\texorpdfstring{Explicit}{Explicit}}\label{explicit}
|
||||||
|
|
||||||
Just a \href{/url/}{URL}.
|
Just a \href{/url/}{URL}.
|
||||||
|
|
||||||
|
@ -838,7 +845,7 @@ Just a \href{/url/}{URL}.
|
||||||
|
|
||||||
\href{}{Empty}.
|
\href{}{Empty}.
|
||||||
|
|
||||||
\subsection{Reference}\label{reference}
|
\subsection{\texorpdfstring{Reference}{Reference}}\label{reference}
|
||||||
|
|
||||||
Foo \href{/url/}{bar}.
|
Foo \href{/url/}{bar}.
|
||||||
|
|
||||||
|
@ -866,7 +873,8 @@ Foo \href{/url/}{bar}.
|
||||||
|
|
||||||
Foo \href{/url/}{biz}.
|
Foo \href{/url/}{biz}.
|
||||||
|
|
||||||
\subsection{With ampersands}\label{with-ampersands}
|
\subsection{\texorpdfstring{With
|
||||||
|
ampersands}{With ampersands}}\label{with-ampersands}
|
||||||
|
|
||||||
Here's a \href{http://example.com/?foo=1\&bar=2}{link with an ampersand in the
|
Here's a \href{http://example.com/?foo=1\&bar=2}{link with an ampersand in the
|
||||||
URL}.
|
URL}.
|
||||||
|
@ -878,7 +886,7 @@ Here's an \href{/script?foo=1\&bar=2}{inline link}.
|
||||||
|
|
||||||
Here's an \href{/script?foo=1\&bar=2}{inline link in pointy braces}.
|
Here's an \href{/script?foo=1\&bar=2}{inline link in pointy braces}.
|
||||||
|
|
||||||
\subsection{Autolinks}\label{autolinks}
|
\subsection{\texorpdfstring{Autolinks}{Autolinks}}\label{autolinks}
|
||||||
|
|
||||||
With an ampersand: \url{http://example.com/?foo=1\&bar=2}
|
With an ampersand: \url{http://example.com/?foo=1\&bar=2}
|
||||||
|
|
||||||
|
@ -908,7 +916,7 @@ or here: <http://example.com/>
|
||||||
|
|
||||||
\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}
|
\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}
|
||||||
|
|
||||||
\section{Images}\label{images}
|
\section{\texorpdfstring{Images}{Images}}\label{images}
|
||||||
|
|
||||||
From ``Voyage dans la Lune'' by Georges Melies (1902):
|
From ``Voyage dans la Lune'' by Georges Melies (1902):
|
||||||
|
|
||||||
|
@ -922,7 +930,7 @@ Here is a movie \includegraphics{movie.jpg} icon.
|
||||||
|
|
||||||
\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}
|
\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}
|
||||||
|
|
||||||
\section{Footnotes}\label{footnotes}
|
\section{\texorpdfstring{Footnotes}{Footnotes}}\label{footnotes}
|
||||||
|
|
||||||
Here is a footnote reference,\footnote{Here is the footnote. It can go
|
Here is a footnote reference,\footnote{Here is the footnote. It can go
|
||||||
anywhere after the footnote reference. It need not be placed at the end of
|
anywhere after the footnote reference. It need not be placed at the end of
|
||||||
|
|
Loading…
Add table
Reference in a new issue