Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LaTeX renderer prototype for links ignores the text and the title for relative references #127

Closed
Witiko opened this issue May 12, 2022 · 0 comments
Labels
bug latex Related to the LaTeX interface and implementation
Milestone

Comments

@Witiko
Copy link
Owner

Witiko commented May 12, 2022

Since version 2.15.0, Markdown has supported the relativeReferences option that enables the user to specify relative references in autolinks (e.g. see <#my-table>). The LaTeX renderer prototype for links special-cases relative references and typesets them using the \ref command, ignoring the text and the title of the references:

markdown/markdown.dtx

Lines 23143 to 23169 in a8e5838

% \begin{markdown}
% If the URL begins with a hash sign, then we assume that it is a relative
% reference. Otherwise, we assume that it is an absolute URL.
% \end{markdown}
% \begin{macrocode}
\tl_set:Nx
\l_tmpa_tl
{ \str_range:nnn { ##3 } { 1 } { 1 } }
\str_if_eq:NNTF
\l_tmpa_tl
\c_hash_str
{
\exp_args:No
\markdownLaTeXRendererRelativeLink
{ \str_range:nnn { ##3 } { 2 } { -1 } }
}{
\markdownLaTeXRendererAbsoluteLink { ##1 } { ##2 } { ##3 } { ##4 }
}
}
\next
}
\ExplSyntaxOff
\def\markdownLaTeXRendererAbsoluteLink#1#2#3#4{%
#1\footnote{\ifx\empty#4\empty\else#4: \fi\texttt<\url{#3}\texttt>}}
\def\markdownLaTeXRendererRelativeLink#1{%
\ref{#1}}
% \end{macrocode}

However, this also affects relative references in direct links (e.g. see [my table](#my-table "some title")) and indirect links (e.g. see [my table][] ... [my table]: #my-table "some title"), where a user may expect that the text and the title would not be ignored.

Hats off to @drehak for discovering the issue.

@Witiko Witiko added bug latex Related to the LaTeX interface and implementation labels May 12, 2022
@Witiko Witiko modified the milestones: 2.16.0, 2.15.1 May 12, 2022
Witiko added a commit that referenced this issue May 17, 2022
Previously in LaTeX, both `<#fragment>` and `[some text](#fragment
"title")` would produce the `\ref{fragment}` command with the default
link renderer prototype. Now, only `<#fragment>` produces
`\ref{fragment}`, whereas `[some text](#fragment "title")` becomes
`some text\footnote{title: \url{#fragment}}`. Closes #127.
@Witiko Witiko closed this as completed in 7f3fd9b May 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug latex Related to the LaTeX interface and implementation
Projects
None yet
Development

No branches or pull requests

1 participant