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

Markdown syntax in strings in BibTeX entries is not escaped #60

Open
goerz opened this issue Nov 2, 2023 · 4 comments
Open

Markdown syntax in strings in BibTeX entries is not escaped #60

goerz opened this issue Nov 2, 2023 · 4 comments
Labels
bug Something isn't working wontfix This will not be worked on

Comments

@goerz
Copy link
Member

goerz commented Nov 2, 2023

At least some markdown syntax that might occur in a BibTeX entry is not properly escaped by the internal tex_to_markdown function:

julia> import DocumenterCitations: tex_to_markdown

julia> tex_to_markdown("arXiv: [1210.2145](https://arxiv.org/abs/1210.2145)")
"arXiv: [1210.2145](https://arxiv.org/abs/1210.2145)"

People may have .bib files with entries like the above because at some point I speculated on this being a workaround to deal with the missing support for \url/\href. I was actually wrong about that even at the time: you would have been able to put html in the .bib file in the previous version of DocumenterCitations, not markdown. The fact that markdown worked was exploiting a bug even then (the same bug as now).

The correct and only officially suppored way to define a link in a BibTeX entry (as of now) is to use LaTeX syntax:

julia> tex_to_markdown("arXiv: \\href{https://arxiv.org/abs/1210.2145}{1210.2145}")
"arXiv: [1210.2145](https://arxiv.org/abs/1210.2145)"

Specifically for preprint links, it would be recommended to use the eprint field, which is fully supported. See the documentation for details.

I'm not going to go out of my way to fix this bug. First of all, I'm not completely sure how to escape arbitrary markdown for the stdlib markdown parser (I'm not even sure it's always possible)

Presumably, for the above string it would be sufficient to escape the brackets:

julia> import Markdown

julia> Markdown.parse("arXiv: \\[1210.2145\\](https://arxiv.org/abs/1210.2145)")
  arXiv: [1210.2145](https://arxiv.org/abs/1210.2145)

Second, it seems unnecessary to break existing .bib files that use the "workaround".

But, for the record: Having markdown syntax in the .bib file is officially exploiting an bug in DocumenterCitations. I strongly discourage the workaround, and I make no guarantees that it will continue to work. In particular, as soon as someone files a bug report that is due to a failure to escape brackets, I'll have to do something about this.

@goerz goerz added bug Something isn't working wontfix This will not be worked on labels Nov 2, 2023
@kellertuer
Copy link
Contributor

The first way actually does still work (if one is able to type the markdown link correctly) – and since I am lazy I might continue using that ;) For exactly the code you have – that is from the pre-eprint-time and I should change that, that is correct.

@goerz
Copy link
Member Author

goerz commented Nov 2, 2023

That's fine, as long as we're clear that this is officially non-sanctioned ;-)

How do you feel about me checking for the presence of ](http in the .bib strings and printing a warning that "markdown links must be rewritten with the tex-command \href"? Helpful, or too much noise?

@kellertuer
Copy link
Contributor

If we rephrase that to “should“ (since in most cases they work) that's fine with me.

@goerz
Copy link
Member Author

goerz commented Nov 5, 2023

See #64

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants