git.iko.soy/typeable/pandoc
on master help sign in
Merge branch 'use-texorpdfstring' of https://github.com/wilx/pandoc into wilx-use-texorpdfstring
544f3e5John MacFarlane
src/Text/Pandoc/Writers/LaTeX.hs+4−1
@@ -613,6 +613,7 @@ sectionHeader :: Bool -- True for unnumbered
613sectionHeader unnumbered ref level lst = do
613sectionHeader unnumbered ref level lst = do
614 txt <- inlineListToLaTeX lst
614 txt <- inlineListToLaTeX lst
615 lab <- text `fmap` toLabel ref
615 lab <- text `fmap` toLabel ref
616+ plain <- stringToLaTeX TextString $ foldl (++) "" $ map stringify lst
616 let noNote (Note _) = Str ""
617 let noNote (Note _) = Str ""
617 noNote x = x
618 noNote x = x
618 let lstNoNotes = walk noNote lst
619 let lstNoNotes = walk noNote lst
@@ -625,7 +626,9 @@ sectionHeader unnumbered ref level lst = do
625 then return empty
626 then return empty
626 else do
627 else do
627 return $ brackets txtNoNotes
628 return $ brackets txtNoNotes
628− let stuffing = star <> optional <> braces txt
629+ let stuffing = star <> optional <> braces (text "\\texorpdfstring"
630+ <> braces txt
631+ <> braces (text plain))
629 book <- gets stBook
632 book <- gets stBook
630 opts <- gets stOptions
633 opts <- gets stOptions
631 let level' = if book || writerChapters opts then level - 1 else level
634 let level' = if book || writerChapters opts then level - 1 else level
tests/Tests/Writers/LaTeX.hs+1−1
@@ -52,7 +52,7 @@ tests = [ testGroup "code blocks"
52 [ "unnumbered header" =:
52 [ "unnumbered header" =:
53 headerWith ("foo",["unnumbered"],[]) 1
53 headerWith ("foo",["unnumbered"],[]) 1
54 (text "Header 1" <> note (plain $ text "note")) =?>
54 (text "Header 1" <> note (plain $ text "note")) =?>
55− "\\section*{Header 1\\footnote{note}}\\label{foo}\n\\addcontentsline{toc}{section}{Header 1}\n"
55+ "\\section*{\\texorpdfstring{Header 1\\footnote{note}}{Header 1}}\\label{foo}\n\\addcontentsline{toc}{section}{Header 1}\n"
56 , "in list item" =:
56 , "in list item" =:
57 bulletList [header 2 (text "foo")] =?>
57 bulletList [header 2 (text "foo")] =?>
58 "\\begin{itemize}\n\\item ~\n \\subsection{foo}\n\\end{itemize}"
58 "\\begin{itemize}\n\\item ~\n \\subsection{foo}\n\\end{itemize}"
tests/lhs-test.latex+1−1
@@ -70,7 +70,7 @@
70
70
71\begin{document}
71\begin{document}
72
72
73−\section{lhs test}\label{lhs-test}
73+\section{\texorpdfstring{lhs test}{lhs test}}\label{lhs-test}
74
74
75\texttt{unsplit} is an arrow that takes a pair of values and combines them to
75\texttt{unsplit} is an arrow that takes a pair of values and combines them to
76return a single value:
76return a single value:
tests/lhs-test.latex+lhs+1−1
@@ -51,7 +51,7 @@
51
51
52\begin{document}
52\begin{document}
53
53
54−\section{lhs test}\label{lhs-test}
54+\section{\texorpdfstring{lhs test}{lhs test}}\label{lhs-test}
55
55
56\texttt{unsplit} is an arrow that takes a pair of values and combines them to
56\texttt{unsplit} is an arrow that takes a pair of values and combines them to
57return a single value:
57return a single value:
tests/writer.latex+40−32
@@ -72,32 +72,34 @@ markdown test suite.
72
72
73\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}
73\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}
74
74
75−\section{Headers}\label{headers}
75+\section{\texorpdfstring{Headers}{Headers}}\label{headers}
76
76
77−\subsection{Level 2 with an \href{/url}{embedded
77+\subsection{\texorpdfstring{Level 2 with an \href{/url}{embedded
78−link}}\label{level-2-with-an-embedded-link}
78+link}}{Level 2 with an embedded link}}\label{level-2-with-an-embedded-link}
79
79
80+\subsubsection{\texorpdfstring{Level 3 with
80−\subsubsection{Level 3 with \emph{emphasis}}\label{level-3-with-emphasis}
81+\emph{emphasis}}{Level 3 with emphasis}}\label{level-3-with-emphasis}
81
82
82−\paragraph{Level 4}\label{level-4}
83+\paragraph{\texorpdfstring{Level 4}{Level 4}}\label{level-4}
83
84
84−\subparagraph{Level 5}\label{level-5}
85+\subparagraph{\texorpdfstring{Level 5}{Level 5}}\label{level-5}
85
86
86−\section{Level 1}\label{level-1}
87+\section{\texorpdfstring{Level 1}{Level 1}}\label{level-1}
87
88
89+\subsection{\texorpdfstring{Level 2 with
88−\subsection{Level 2 with \emph{emphasis}}\label{level-2-with-emphasis}
90+\emph{emphasis}}{Level 2 with emphasis}}\label{level-2-with-emphasis}
89
91
90−\subsubsection{Level 3}\label{level-3}
92+\subsubsection{\texorpdfstring{Level 3}{Level 3}}\label{level-3}
91
93
92with no blank line
94with no blank line
93
95
94−\subsection{Level 2}\label{level-2}
96+\subsection{\texorpdfstring{Level 2}{Level 2}}\label{level-2}
95
97
96with no blank line
98with no blank line
97
99
98\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}
100\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}
99
101
100−\section{Paragraphs}\label{paragraphs}
102+\section{\texorpdfstring{Paragraphs}{Paragraphs}}\label{paragraphs}
101
103
102Here's a regular paragraph.
104Here's a regular paragraph.
103
105
@@ -111,7 +113,7 @@ There should be a hard line break\\here.
111
113
112\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}
114\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}
113
115
114−\section{Block Quotes}\label{block-quotes}
116+\section{\texorpdfstring{Block Quotes}{Block Quotes}}\label{block-quotes}
115
117
116E-mail style:
118E-mail style:
117
119
@@ -156,7 +158,7 @@ And a following paragraph.
156
158
157\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}
159\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}
158
160
159−\section{Code Blocks}\label{code-blocks}
161+\section{\texorpdfstring{Code Blocks}{Code Blocks}}\label{code-blocks}
160
162
161Code:
163Code:
162
164
@@ -180,9 +182,9 @@ These should not be escaped: \$ \\ \> \[ \{
180
182
181\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}
183\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}
182
184
183−\section{Lists}\label{lists}
185+\section{\texorpdfstring{Lists}{Lists}}\label{lists}
184
186
185−\subsection{Unordered}\label{unordered}
187+\subsection{\texorpdfstring{Unordered}{Unordered}}\label{unordered}
186
188
187Asterisks tight:
189Asterisks tight:
188
190
@@ -253,7 +255,7 @@ Minuses loose:
253 Minus 3
255 Minus 3
254\end{itemize}
256\end{itemize}
255
257
256−\subsection{Ordered}\label{ordered}
258+\subsection{\texorpdfstring{Ordered}{Ordered}}\label{ordered}
257
259
258Tight:
260Tight:
259
261
@@ -319,7 +321,7 @@ Multiple paragraphs:
319 Item 3.
321 Item 3.
320\end{enumerate}
322\end{enumerate}
321
323
322−\subsection{Nested}\label{nested}
324+\subsection{\texorpdfstring{Nested}{Nested}}\label{nested}
323
325
324\begin{itemize}
326\begin{itemize}
325\itemsep1pt\parskip0pt\parsep0pt
327\itemsep1pt\parskip0pt\parsep0pt
@@ -384,7 +386,8 @@ Same thing but with paragraphs:
384 Third
386 Third
385\end{enumerate}
387\end{enumerate}
386
388
389+\subsection{\texorpdfstring{Tabs and
387−\subsection{Tabs and spaces}\label{tabs-and-spaces}
390+spaces}{Tabs and spaces}}\label{tabs-and-spaces}
388
391
389\begin{itemize}
392\begin{itemize}
390\item
393\item
@@ -400,7 +403,8 @@ Same thing but with paragraphs:
400 \end{itemize}
403 \end{itemize}
401\end{itemize}
404\end{itemize}
402
405
406+\subsection{\texorpdfstring{Fancy list
403−\subsection{Fancy list markers}\label{fancy-list-markers}
407+markers}{Fancy list markers}}\label{fancy-list-markers}
404
408
405\begin{enumerate}
409\begin{enumerate}
406\def\labelenumi{(\arabic{enumi})}
410\def\labelenumi{(\arabic{enumi})}
@@ -488,7 +492,8 @@ B. Williams
488
492
489\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}
493\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}
490
494
495+\section{\texorpdfstring{Definition
491−\section{Definition Lists}\label{definition-lists}
496+Lists}{Definition Lists}}\label{definition-lists}
492
497
493Tight using spaces:
498Tight using spaces:
494
499
@@ -591,7 +596,7 @@ orange fruit
591\end{enumerate}
596\end{enumerate}
592\end{description}
597\end{description}
593
598
594−\section{HTML Blocks}\label{html-blocks}
599+\section{\texorpdfstring{HTML Blocks}{HTML Blocks}}\label{html-blocks}
595
600
596Simple block on one line:
601Simple block on one line:
597
602
@@ -653,7 +658,7 @@ Hr's:
653
658
654\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}
659\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}
655
660
656−\section{Inline Markup}\label{inline-markup}
661+\section{\texorpdfstring{Inline Markup}{Inline Markup}}\label{inline-markup}
657
662
658This is \emph{emphasized}, and so \emph{is this}.
663This is \emph{emphasized}, and so \emph{is this}.
659
664
@@ -685,7 +690,8 @@ spaces: a\^{}b c\^{}d, a\textasciitilde{}b c\textasciitilde{}d.
685
690
686\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}
691\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}
687
692
693+\section{\texorpdfstring{Smart quotes, ellipses,
688−\section{Smart quotes, ellipses, dashes}\label{smart-quotes-ellipses-dashes}
694+dashes}{Smart quotes, ellipses, dashes}}\label{smart-quotes-ellipses-dashes}
689
695
690``Hello,'' said the spider. ``\,`Shelob' is my name.''
696``Hello,'' said the spider. ``\,`Shelob' is my name.''
691
697
@@ -706,7 +712,7 @@ Ellipses\ldots{}and\ldots{}and\ldots{}.
706
712
707\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}
713\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}
708
714
709−\section{LaTeX}\label{latex}
715+\section{\texorpdfstring{LaTeX}{LaTeX}}\label{latex}
710
716
711\begin{itemize}
717\begin{itemize}
712\itemsep1pt\parskip0pt\parsep0pt
718\itemsep1pt\parskip0pt\parsep0pt
@@ -754,7 +760,8 @@ Cat & 1 \\ \hline
754
760
755\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}
761\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}
756
762
763+\section{\texorpdfstring{Special
757−\section{Special Characters}\label{special-characters}
764+Characters}{Special Characters}}\label{special-characters}
758
765
759Here is some unicode:
766Here is some unicode:
760
767
@@ -816,9 +823,9 @@ Minus: -
816
823
817\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}
824\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}
818
825
819−\section{Links}\label{links}
826+\section{\texorpdfstring{Links}{Links}}\label{links}
820
827
821−\subsection{Explicit}\label{explicit}
828+\subsection{\texorpdfstring{Explicit}{Explicit}}\label{explicit}
822
829
823Just a \href{/url/}{URL}.
830Just a \href{/url/}{URL}.
824
831
@@ -838,7 +845,7 @@ Just a \href{/url/}{URL}.
838
845
839\href{}{Empty}.
846\href{}{Empty}.
840
847
841−\subsection{Reference}\label{reference}
848+\subsection{\texorpdfstring{Reference}{Reference}}\label{reference}
842
849
843Foo \href{/url/}{bar}.
850Foo \href{/url/}{bar}.
844
851
@@ -866,7 +873,8 @@ Foo \href{/url/}{bar}.
866
873
867Foo \href{/url/}{biz}.
874Foo \href{/url/}{biz}.
868
875
876+\subsection{\texorpdfstring{With
869−\subsection{With ampersands}\label{with-ampersands}
877+ampersands}{With ampersands}}\label{with-ampersands}
870
878
871Here's a \href{http://example.com/?foo=1\&bar=2}{link with an ampersand in the
879Here's a \href{http://example.com/?foo=1\&bar=2}{link with an ampersand in the
872URL}.
880URL}.
@@ -878,7 +886,7 @@ Here's an \href{/script?foo=1\&bar=2}{inline link}.
878
886
879Here's an \href{/script?foo=1\&bar=2}{inline link in pointy braces}.
887Here's an \href{/script?foo=1\&bar=2}{inline link in pointy braces}.
880
888
881−\subsection{Autolinks}\label{autolinks}
889+\subsection{\texorpdfstring{Autolinks}{Autolinks}}\label{autolinks}
882
890
883With an ampersand: \url{http://example.com/?foo=1\&bar=2}
891With an ampersand: \url{http://example.com/?foo=1\&bar=2}
884
892
@@ -908,7 +916,7 @@ or here: <http://example.com/>
908
916
909\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}
917\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}
910
918
911−\section{Images}\label{images}
919+\section{\texorpdfstring{Images}{Images}}\label{images}
912
920
913From ``Voyage dans la Lune'' by Georges Melies (1902):
921From ``Voyage dans la Lune'' by Georges Melies (1902):
914
922
@@ -922,7 +930,7 @@ Here is a movie \includegraphics{movie.jpg} icon.
922
930
923\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}
931\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}
924
932
925−\section{Footnotes}\label{footnotes}
933+\section{\texorpdfstring{Footnotes}{Footnotes}}\label{footnotes}
926
934
927Here is a footnote reference,\footnote{Here is the footnote. It can go
935Here is a footnote reference,\footnote{Here is the footnote. It can go
928 anywhere after the footnote reference. It need not be placed at the end of
936 anywhere after the footnote reference. It need not be placed at the end of