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 reader does not set 'uri' class on bare external links / autolinks #7672

Closed
gwern opened this issue Nov 6, 2021 · 0 comments
Closed
Labels

Comments

@gwern
Copy link
Contributor

gwern commented Nov 6, 2021

I was looking into why some of my Arxiv abstracts' URL links to Github (using LaTeX \url{}) looked weird when I expected them to be rendered in inline code markup (because a URL is code, and not natural language), and was surprised to see that it looks like the intended use is for you to set CSS on the uri class that a regular autolink generates:

$ echo 'Code is available at <https://github.com/ibm/sau-explore>' | xclip -in
$ xclip -o | pandoc -f markdown -w html
<p>Code is available at <a href="https://github.com/ibm/sau-explore" class="uri">https://github.com/ibm/sau-explore</a></p>

I didn't see any documentation about the purpose of this class, and am guessing from the changelog & the discussion in #4913 but OK, fair enough. I think it would be good to style the contents of an autolink using inline code formatting since it is a literal formal computer language, and often completely opaque to a human reader, however, I can work with uri class. But then, why isn't uri anywhere in my abstracts...?

Turns out, Pandoc is inconsistent in its treatment of autolinks: the LaTeX reader does not set the class like the Markdown reader does:

$ xclip -o | pandoc -f latex -w html
<p>Code is available at <a href="https://github.com/ibm/sau-explore">https://github.com/ibm/sau-explore</a></p>
$ xclip -o | pandoc -f latex -w markdown | pandoc -f markdown -w html
<p>Code is available at <a href="https://github.com/ibm/sau-explore" class="uri">https://github.com/ibm/sau-explore</a></p>

A check of the AST verifies that the problem is that the LaTeX reader doesn't set the uri class when it reads in & converts the \url{} to an autolink, but the Markdown reader does set it on autolinks:

$ xclip -o | pandoc -f latex -w native
[Para [Str "Code",Space,Str "is",Space,Str "available",Space,Str "at",Space,Link ("",[],[]) [Str "https://github.com/ibm/sau-explore"] ("https://github.com/ibm/sau-explore","")]]
$ xclip -o | pandoc -f latex -w markdown | pandoc -f markdown -w native
[Para [Str "Code",Space,Str "is",Space,Str "available",Space,Str "at",Space,Link ("",["uri"],[]) [Str "https://github.com/ibm/sau-explore"] ("https://github.com/ibm/sau-explore","")]]

So it seems that not all readers which support autolinks remember to set the class. (I haven't checked if this applies to autolinked email addresses as well, but seems likely.)

@gwern gwern added the bug label Nov 6, 2021
gwern added a commit to gwern/gwern.net that referenced this issue Nov 7, 2021
@jgm jgm closed this as completed in cc46667 Nov 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant