Beispiel #1
0
def get_csl_item(url) -> dict:
    """
    Generate a CSL JSON item for a URL. Currently, does not work
    for most PDF URLs unless they are from known domains where
    persistent identifiers can be extracted.
    """
    from manubot.cite.citekey import citekey_to_csl_item, url_to_citekey

    try:

        citekey = url_to_citekey(url)
        citekey = RHCiteKey(citekey)
        csl_item = citekey_to_csl_item(citekey)

        if not csl_item:
            raise Exception(f"Error searching for paper: {url}")
        return csl_item
    except Exception as e:
        raise ManubotProcessingError(e)
Beispiel #2
0
def test_url_to_citekey(url, citekey):
    assert url_to_citekey(url) == citekey