Can one create a HTML link that returns a bibtex entry from a given doi that would work in a GitHub wiki?

124 views Asked by At

Suppose that one has a doi address, say http://doi.org/10.1103/PhysRevA.54.1098, and you would like to create a HTML link in a static webpage, say <link>, such that when the user clicks on the <link> a text file is loaded containing the bibtex entry for the associated doi. Now, I know how to fetch the bibtex record using curl or Python for example:

curl -LH "Accept: application/x-bibtex" http://dx.doi.org/10.1103/PhysRevA.54.1098

or (based on a program by Christian at https://scipython.com/blog/doi-to-bibtex/)

def create_bibtex_ref(entry):
    url = create_doi_link(entry['doi'])
    if not url=='':
        req = urllib.request.Request(url)
        req.add_header('Accept', 'application/x-bibtex')
        try:
            with urllib.request.urlopen(req) as f:
                bibtex = f.read().decode()
            return bibtex
        except HTTPError as e:
            if e.code == 404:
                print('DOI not found.')
            else:
                print('Service unavailable.')
            sys.exit(1)

I suppose that one could use Javascript, or something similar, to make this link work in an HTML document (although I do not know how to do this). But I would like to put this link inside a GitHib wiki where these capabilities are not available (that I know about). Something like

[Get Bibtex Entry](<the link that I need>)

or

<a href="the link that I need">Get Bibtex Entry</a>

What options are there, if any? (And yes I am currently stuck with a GitHub wiki at this point.) Of course, if you precompute the bibtex entries using one of the above methods you could point the link to a position in a different file. I wish to avoid this type of precomputed solution if possible.

0

There are 0 answers