aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJohn MacFarlane <[email protected]>2023-08-19 09:52:01 -0700
committerJohn MacFarlane <[email protected]>2023-08-19 09:52:01 -0700
commit70329edcd7afb7b3f8f015b13ab2e734c9e31d05 (patch)
tree34c8363de72e10ae737681f4cdbdb3f25b5f4a97 /test
parent068fce4293eb139f54d4825e1dbdcaf35e34da03 (diff)
LaTeX writer: improve internal links and targets.
We no longer wrap section headings in a `\hypertarget`. This is unnecessary (hyperref creates an anchor based on the label) and it interferes with tagging. In addition, we now use `\hyperref` rather than `\hyperlink` for internal links. Currently `\hypertarget` is still being used for link anchors not on headings. Closes #8744. Thanks to @u-fischer.
Diffstat (limited to 'test')
-rw-r--r--test/Tests/Writers/LaTeX.hs4
-rw-r--r--test/command/1762.md9
-rw-r--r--test/command/5574.md3
-rw-r--r--test/command/6030.md6
-rw-r--r--test/command/6033.md15
-rw-r--r--test/command/6107.md3
-rw-r--r--test/command/6360.md2
-rw-r--r--test/command/7857.md3
-rw-r--r--test/lhs-test.latex3
-rw-r--r--test/lhs-test.latex+lhs3
-rw-r--r--test/writer.latex93
-rw-r--r--test/writers-lang-and-dir.latex12
12 files changed, 53 insertions, 103 deletions
diff --git a/test/Tests/Writers/LaTeX.hs b/test/Tests/Writers/LaTeX.hs
index 35693d478..d1cec5d2b 100644
--- a/test/Tests/Writers/LaTeX.hs
+++ b/test/Tests/Writers/LaTeX.hs
@@ -50,7 +50,7 @@ tests = [ testGroup "code blocks"
, testGroup "definition lists"
[ "with internal link" =: definitionList [(link "#go" "" (str "testing"),
[plain (text "hi there")])] =?>
- "\\begin{description}\n\\tightlist\n\\item[{\\protect\\hyperlink{go}{testing}}]\nhi there\n\\end{description}"
+ "\\begin{description}\n\\tightlist\n\\item[{\\hyperref[go]{testing}}]\nhi there\n\\end{description}"
]
, testGroup "math"
[ "escape |" =: para (math "\\sigma|_{\\{x\\}}") =?>
@@ -60,7 +60,7 @@ tests = [ testGroup "code blocks"
[ "unnumbered header" =:
headerWith ("foo",["unnumbered"],[]) 1
(text "Header 1" <> note (plain $ text "note")) =?>
- "\\hypertarget{foo}{%\n\\section*{\\texorpdfstring{Header 1\\footnote{note}}{Header 1}}\\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" =:
bulletList [header 2 (text "foo")] =?>
"\\begin{itemize}\n\\item ~\n \\subsection{foo}\n\\end{itemize}"
diff --git a/test/command/1762.md b/test/command/1762.md
index c0c34dc24..b35b209aa 100644
--- a/test/command/1762.md
+++ b/test/command/1762.md
@@ -6,13 +6,10 @@
# Three {.unlisted .unnumbered}
^D
-\hypertarget{one}{%
-\section{One}\label{one}}
+\section{One}\label{one}
-\hypertarget{two}{%
-\section*{Two}\label{two}}
+\section*{Two}\label{two}
\addcontentsline{toc}{section}{Two}
-\hypertarget{three}{%
-\section*{Three}\label{three}}
+\section*{Three}\label{three}
```
diff --git a/test/command/5574.md b/test/command/5574.md
index 441b3afd6..4d4c4ec08 100644
--- a/test/command/5574.md
+++ b/test/command/5574.md
@@ -3,6 +3,5 @@ No highlighting inside heading:
% pandoc -t latex
# `foo`{.cpp}
^D
-\hypertarget{foo}{%
-\section{\texorpdfstring{\texttt{foo}}{foo}}\label{foo}}
+\section{\texorpdfstring{\texttt{foo}}{foo}}\label{foo}
```
diff --git a/test/command/6030.md b/test/command/6030.md
index e05bf6e7f..0801f9173 100644
--- a/test/command/6030.md
+++ b/test/command/6030.md
@@ -70,15 +70,13 @@ Three
Four
^D
-\hypertarget{one}{%
-\section{One}\label{one}}
+\section{One}\label{one}
\begin{frame}{One}
One
\end{frame}
-\hypertarget{two}{%
-\subsection{Two}\label{two}}
+\subsection{Two}\label{two}
\begin{frame}{Two}
Two
diff --git a/test/command/6033.md b/test/command/6033.md
index f831daa49..cc1b212bf 100644
--- a/test/command/6033.md
+++ b/test/command/6033.md
@@ -32,11 +32,9 @@
- More text.
^D
-\hypertarget{one}{%
-\section{One}\label{one}}
+\section{One}\label{one}
-\hypertarget{one-a}{%
-\subsection{One-A}\label{one-a}}
+\subsection{One-A}\label{one-a}
\begin{frame}{One-A}
\begin{columns}[T]
@@ -64,8 +62,7 @@
\end{itemize}
\end{frame}
-\hypertarget{one-b}{%
-\subsection{One-B}\label{one-b}}
+\subsection{One-B}\label{one-b}
\begin{frame}{One-B}
\begin{itemize}
@@ -75,11 +72,9 @@
\end{itemize}
\end{frame}
-\hypertarget{two}{%
-\section{Two}\label{two}}
+\section{Two}\label{two}
-\hypertarget{two-a}{%
-\subsection{Two-A}\label{two-a}}
+\subsection{Two-A}\label{two-a}
\begin{frame}{Two-A}
\begin{itemize}
diff --git a/test/command/6107.md b/test/command/6107.md
index 8444172ab..2f9d3353c 100644
--- a/test/command/6107.md
+++ b/test/command/6107.md
@@ -13,8 +13,7 @@ Not much to do about nothing.
## Epilogue {.standout}
^D
-\hypertarget{a-circus}{%
-\section{A circus!}\label{a-circus}}
+\section{A circus!}\label{a-circus}
\begin{frame}{Another silly title}
\protect\hypertarget{another-silly-title}{}
diff --git a/test/command/6360.md b/test/command/6360.md
index 3988710bf..794307a83 100644
--- a/test/command/6360.md
+++ b/test/command/6360.md
@@ -2,5 +2,5 @@
% pandoc -f native -t latex --wrap=none
[Link ("test2",[],[]) [Str "link",Space,Str "to",Space,Str "text",Space,Str "test1"] ("#test1","")]
^D
-\protect\hypertarget{test2}{\protect\hyperlink{test1}{link to text test1}}
+\protect\hypertarget{test2}{\hyperref[test1]{link to text test1}}
```
diff --git a/test/command/7857.md b/test/command/7857.md
index 9a4968e88..9fc128b5d 100644
--- a/test/command/7857.md
+++ b/test/command/7857.md
@@ -10,8 +10,7 @@ my note
ok
^D
-\hypertarget{section}{%
-\section{section}\label{section}}
+\section{section}\label{section}
\note{my note}
diff --git a/test/lhs-test.latex b/test/lhs-test.latex
index 499842ac3..69acd9bd5 100644
--- a/test/lhs-test.latex
+++ b/test/lhs-test.latex
@@ -93,8 +93,7 @@
\begin{document}
-\hypertarget{lhs-test}{%
-\section{lhs test}\label{lhs-test}}
+\section{lhs test}\label{lhs-test}
\texttt{unsplit} is an arrow that takes a pair of values and combines them to
return a single value:
diff --git a/test/lhs-test.latex+lhs b/test/lhs-test.latex+lhs
index 51c70fe1e..b4aeb7186 100644
--- a/test/lhs-test.latex+lhs
+++ b/test/lhs-test.latex+lhs
@@ -60,8 +60,7 @@
\begin{document}
-\hypertarget{lhs-test}{%
-\section{lhs test}\label{lhs-test}}
+\section{lhs test}\label{lhs-test}
\texttt{unsplit} is an arrow that takes a pair of values and combines them to
return a single value:
diff --git a/test/writer.latex b/test/writer.latex
index d5ba851d7..829ab16ab 100644
--- a/test/writer.latex
+++ b/test/writer.latex
@@ -85,44 +85,34 @@ markdown test suite.
\begin{center}\rule{0.5\linewidth}{0.5pt}\end{center}
-\hypertarget{headers}{%
-\section{Headers}\label{headers}}
+\section{Headers}\label{headers}
-\hypertarget{level-2-with-an-embedded-link}{%
\subsection{\texorpdfstring{Level 2 with an \href{/url}{embedded
-link}}{Level 2 with an embedded link}}\label{level-2-with-an-embedded-link}}
+link}}{Level 2 with an embedded link}}\label{level-2-with-an-embedded-link}
-\hypertarget{level-3-with-emphasis}{%
\subsubsection{\texorpdfstring{Level 3 with
-\emph{emphasis}}{Level 3 with emphasis}}\label{level-3-with-emphasis}}
+\emph{emphasis}}{Level 3 with emphasis}}\label{level-3-with-emphasis}
-\hypertarget{level-4}{%
-\paragraph{Level 4}\label{level-4}}
+\paragraph{Level 4}\label{level-4}
-\hypertarget{level-5}{%
-\subparagraph{Level 5}\label{level-5}}
+\subparagraph{Level 5}\label{level-5}
-\hypertarget{level-1}{%
-\section{Level 1}\label{level-1}}
+\section{Level 1}\label{level-1}
-\hypertarget{level-2-with-emphasis}{%
\subsection{\texorpdfstring{Level 2 with
-\emph{emphasis}}{Level 2 with emphasis}}\label{level-2-with-emphasis}}
+\emph{emphasis}}{Level 2 with emphasis}}\label{level-2-with-emphasis}
-\hypertarget{level-3}{%
-\subsubsection{Level 3}\label{level-3}}
+\subsubsection{Level 3}\label{level-3}
with no blank line
-\hypertarget{level-2}{%
-\subsection{Level 2}\label{level-2}}
+\subsection{Level 2}\label{level-2}
with no blank line
\begin{center}\rule{0.5\linewidth}{0.5pt}\end{center}
-\hypertarget{paragraphs}{%
-\section{Paragraphs}\label{paragraphs}}
+\section{Paragraphs}\label{paragraphs}
Here's a regular paragraph.
@@ -137,8 +127,7 @@ here.
\begin{center}\rule{0.5\linewidth}{0.5pt}\end{center}
-\hypertarget{block-quotes}{%
-\section{Block Quotes}\label{block-quotes}}
+\section{Block Quotes}\label{block-quotes}
E-mail style:
@@ -183,8 +172,7 @@ And a following paragraph.
\begin{center}\rule{0.5\linewidth}{0.5pt}\end{center}
-\hypertarget{code-blocks}{%
-\section{Code Blocks}\label{code-blocks}}
+\section{Code Blocks}\label{code-blocks}
Code:
@@ -208,11 +196,9 @@ These should not be escaped: \$ \\ \> \[ \{
\begin{center}\rule{0.5\linewidth}{0.5pt}\end{center}
-\hypertarget{lists}{%
-\section{Lists}\label{lists}}
+\section{Lists}\label{lists}
-\hypertarget{unordered}{%
-\subsection{Unordered}\label{unordered}}
+\subsection{Unordered}\label{unordered}
Asterisks tight:
@@ -283,8 +269,7 @@ Minuses loose:
Minus 3
\end{itemize}
-\hypertarget{ordered}{%
-\subsection{Ordered}\label{ordered}}
+\subsection{Ordered}\label{ordered}
Tight:
@@ -350,8 +335,7 @@ Multiple paragraphs:
Item 3.
\end{enumerate}
-\hypertarget{nested}{%
-\subsection{Nested}\label{nested}}
+\subsection{Nested}\label{nested}
\begin{itemize}
\tightlist
@@ -416,8 +400,7 @@ Same thing but with paragraphs:
Third
\end{enumerate}
-\hypertarget{tabs-and-spaces}{%
-\subsection{Tabs and spaces}\label{tabs-and-spaces}}
+\subsection{Tabs and spaces}\label{tabs-and-spaces}
\begin{itemize}
\item
@@ -433,8 +416,7 @@ Same thing but with paragraphs:
\end{itemize}
\end{itemize}
-\hypertarget{fancy-list-markers}{%
-\subsection{Fancy list markers}\label{fancy-list-markers}}
+\subsection{Fancy list markers}\label{fancy-list-markers}
\begin{enumerate}
\def\labelenumi{(\arabic{enumi})}
@@ -522,8 +504,7 @@ B. Williams
\begin{center}\rule{0.5\linewidth}{0.5pt}\end{center}
-\hypertarget{definition-lists}{%
-\section{Definition Lists}\label{definition-lists}}
+\section{Definition Lists}\label{definition-lists}
Tight using spaces:
@@ -626,8 +607,7 @@ orange fruit
\end{enumerate}
\end{description}
-\hypertarget{html-blocks}{%
-\section{HTML Blocks}\label{html-blocks}}
+\section{HTML Blocks}\label{html-blocks}
Simple block on one line:
@@ -689,8 +669,7 @@ Hr's:
\begin{center}\rule{0.5\linewidth}{0.5pt}\end{center}
-\hypertarget{inline-markup}{%
-\section{Inline Markup}\label{inline-markup}}
+\section{Inline Markup}\label{inline-markup}
This is \emph{emphasized}, and so \emph{is this}.
@@ -722,8 +701,7 @@ a\^{}b c\^{}d, a\textasciitilde b c\textasciitilde d.
\begin{center}\rule{0.5\linewidth}{0.5pt}\end{center}
-\hypertarget{smart-quotes-ellipses-dashes}{%
-\section{Smart quotes, ellipses, dashes}\label{smart-quotes-ellipses-dashes}}
+\section{Smart quotes, ellipses, dashes}\label{smart-quotes-ellipses-dashes}
``Hello,'' said the spider. ``\,`Shelob' is my name.''
@@ -744,8 +722,7 @@ Ellipses\ldots and\ldots and\ldots.
\begin{center}\rule{0.5\linewidth}{0.5pt}\end{center}
-\hypertarget{latex}{%
-\section{LaTeX}\label{latex}}
+\section{LaTeX}\label{latex}
\begin{itemize}
\tightlist
@@ -793,8 +770,7 @@ Cat & 1 \\ \hline
\begin{center}\rule{0.5\linewidth}{0.5pt}\end{center}
-\hypertarget{special-characters}{%
-\section{Special Characters}\label{special-characters}}
+\section{Special Characters}\label{special-characters}
Here is some unicode:
@@ -856,11 +832,9 @@ Minus: -
\begin{center}\rule{0.5\linewidth}{0.5pt}\end{center}
-\hypertarget{links}{%
-\section{Links}\label{links}}
+\section{Links}\label{links}
-\hypertarget{explicit}{%
-\subsection{Explicit}\label{explicit}}
+\subsection{Explicit}\label{explicit}
Just a \href{/url/}{URL}.
@@ -880,8 +854,7 @@ Just a \href{/url/}{URL}.
\href{}{Empty}.
-\hypertarget{reference}{%
-\subsection{Reference}\label{reference}}
+\subsection{Reference}\label{reference}
Foo \href{/url/}{bar}.
@@ -905,8 +878,7 @@ Foo \href{/url/}{bar}.
Foo \href{/url/}{biz}.
-\hypertarget{with-ampersands}{%
-\subsection{With ampersands}\label{with-ampersands}}
+\subsection{With ampersands}\label{with-ampersands}
Here's a \href{http://example.com/?foo=1&bar=2}{link with an ampersand in the
URL}.
@@ -917,8 +889,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}.
-\hypertarget{autolinks}{%
-\subsection{Autolinks}\label{autolinks}}
+\subsection{Autolinks}\label{autolinks}
With an ampersand: \url{http://example.com/?foo=1&bar=2}
@@ -948,8 +919,7 @@ or here: <http://example.com/>
\begin{center}\rule{0.5\linewidth}{0.5pt}\end{center}
-\hypertarget{images}{%
-\section{Images}\label{images}}
+\section{Images}\label{images}
From ``Voyage dans la Lune'' by Georges Melies (1902):
@@ -963,8 +933,7 @@ Here is a movie \includegraphics{movie.jpg} icon.
\begin{center}\rule{0.5\linewidth}{0.5pt}\end{center}
-\hypertarget{footnotes}{%
-\section{Footnotes}\label{footnotes}}
+\section{Footnotes}\label{footnotes}
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 the
diff --git a/test/writers-lang-and-dir.latex b/test/writers-lang-and-dir.latex
index fe474f165..915d2deed 100644
--- a/test/writers-lang-and-dir.latex
+++ b/test/writers-lang-and-dir.latex
@@ -77,8 +77,7 @@
\begin{document}
-\hypertarget{empty-divs-and-spans}{%
-\section{Empty Divs and Spans}\label{empty-divs-and-spans}}
+\section{Empty Divs and Spans}\label{empty-divs-and-spans}
Some text and
@@ -88,8 +87,7 @@ and more text.
Next paragraph with a {span} and a word-thatincludesa{span}right?
-\hypertarget{directionality}{%
-\section{Directionality}\label{directionality}}
+\section{Directionality}\label{directionality}
Some text and
@@ -106,8 +104,7 @@ and a ltr div. with a \RL{rtl span}.
Next paragraph with a \RL{rtl span} and a
word-that-includesa\LR{ltrspan}right?
-\hypertarget{languages}{%
-\section{Languages}\label{languages}}
+\section{Languages}\label{languages}
Some text and
@@ -125,8 +122,7 @@ span}right?
Some \foreignlanguage{spanish}{Spanish text}.
-\hypertarget{combined}{%
-\section{Combined}\label{combined}}
+\section{Combined}\label{combined}
Some text and