-
Hi, I want to be able to style an hyperlink in a code span like so: The link works, and redirect correctly TeX File:
markdown file:
Thanks for your help and time. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
With your definitions, Perhaps you can set up a conditional such as |
Beta Was this translation helpful? Give feedback.
-
Based on @Witiko 's answers. The issue is to style the à Markdown source:
OriginOrigin render:
Origin Tex: % override hyperlinks to render inline
\global\def\markdownRendererLink#1#2#3#4{%
\href{#3}{#1}%
}
% override markdown render of inline code
\global\def\markdownRendererCodeSpan#1{%
\codeinline{#1}
} FixTo be able to style a code span depending on if it's a link or not, we need to save if a expl3 syntax\ExplSyntaxOn% enable expl3 syntax
% declare boolean value named: isRenderingHyperLink
\bool_new:N \l_isRenderingHyperLink_bool
% override markdown render of inline code
\cs_gset:Npn
\markdownRendererCodeSpan#1
{
\codeinline
{
% if value is true color text in cyan
\bool_if:NTF \l_isRenderingHyperLink_bool
{ \textcolor { cyan } { #1 } }
{ #1 }
}
}
% override hyperlinks to render inline
\cs_gset:Npn
\markdownRendererLink#1#2#3#4
{
% set boolean value to true
\bool_set_true:N \l_isRenderingHyperLink_bool
\href { #3 } { #1 }
% set boolean value to false
\bool_set_false:N \l_isRenderingHyperLink_bool
}
\ExplSyntaxOff% disable expl3 syntax ifthen package syntax% declare boolean value named: islink
\newcommand{\islink}{FALSE}
% override markdown render of inline code
\global\def\markdownRendererCodeSpan#1{%
\codeinline{%
\ifthenelse{\equal{\islink}{TRUE}}%
{%
\textcolor{cyan}{#1}%
}
{%
#1%
}
}
}
% override hyperlinks to render inline
\global\def\markdownRendererLink#1#2#3#4{%
\renewcommand{\islink}{TRUE}% set boolean value to true
\href{#3}{#1}
\renewcommand{\islink}{FALSE}% set boolean value to false
} In both approach, the result is: The % define inline code style
\newtcbox{\codeinline}[1][]{
verbatim,
on line,
arc=0mm,
boxsep=0mm,
left=3pt,
right=3pt,
top=1pt,
bottom=1pt,
boxrule=1pt} Thank you @Witiko for your time and work. |
Beta Was this translation helpful? Give feedback.
Based on @Witiko 's answers.
The issue is to style the à
code span
when it's part of a hyperref URL.Markdown source:
Origin
Origin render:
Origin Tex:
Fix
To be able to style a code span depending on if it's a link or not, we need to save if a
markdownRendererLink
is being rendered with the help of a variable. Then when rendering a code span withmarkdownRendererCodeSpan
, …