Skip to content

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

@goerz

Description

@goerz

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingwontfixThis will not be worked on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions