jgm / pandoc

Universal markup converter
https://pandoc.org
Other
34.29k stars 3.37k forks source link

link style in ConTeXt #8602

Closed twsh closed 1 year ago

twsh commented 1 year ago

When I convert this markdown to PDF via ConTeXt, the automatic URL is monospaced:

Automatic: <https://example.com>

Normal: [example.com](https://example.com)

(The same thing happens with URLs when I use citeproc.)

I used the command: pandoc --to=context --output=foo.pdf foo.md.

I get the same with pandoc --to=context --variable=linkstyle:normal --output=foo.pdf foo.md.

Using the 'linkstyle' variable gives me this in my ConTeXt:

\setupinteraction
  [state=start,
  style=normal,
  color=,
  contrastcolor=]

I thought that would avoid the monospaced URLs, but it doesn't.

One thing that I discovered when I tried to work out why, is that adding this to my ConTeXt code gives me what I wanted: \setupurl[style=normal]: tex.stackexchange.com/a/674357/451

I'm not confident that I know ConTeXt well enough, but I wonder whether adding this to the ConTeXt template would be a good idea?

\setupurl[style=$linkstyle$]

If no 'linkstyle' is set, this will result in URLs in the main font, not the monospaced font. This matches the behaviour of the LaTeX template, which sets \urlstyle{same} by default.

jgm commented 1 year ago

Sounds good to me. Do you want to make a PR?

twsh commented 1 year ago

Sure. I will need to take some time to test it, and see if I need to do anything else with \setupurl.

twsh commented 1 year ago

It seems to me now that we don't need the $linkstyle$ and that \setupurl[style=] would be better. The 'bare' urls inherit the link styles anyway, except for 'normal' for some reason. I've tested it with all the link styles. The result is what I would expect: all links match the rest of the document.

The only downside I can see is that someone might want their urls to be monospace. This is a matter of taste, and some users of Pandoc do want it: https://github.com/jgm/pandoc/pull/8429. After this change, they can do that with the 'type' link style. But, that will affect all links, including links to sections in the document, so it won't just be the automatic URLs (and the urls inserted by citeproc) that are monospace.

For comparison: the LaTeX template defaults to all links in the main font. There is an option to set a 'urlstyle' variable. This allows for automatic links, including emails, to be monospace by using the 'tt' option. In that case, the option affects the appearance of both \url and \nolinkurl, the latter of which is used for emails. That doesn't affect non-automatic links, or links to sections. So there will be a difference between ConTeXt and LaTeX.