Return a plaintext representation of a bibitem from the ``.bbl`` file.

    .. note::

        This plaintext representation can be super ugly, contain URLs and so \
        on.

    .. note::

        You need to have ``delatex`` installed system-wide, or to build it in \
                this repo, according to the ``README.md`` before using this \
                function.

    :param bibitem: The text content of the bibitem.
    :returns: A cleaned plaintext citation from the bibitem.

def bibitem_as_plaintext(bibitem):
    """
    Return a plaintext representation of a bibitem from the ``.bbl`` file.

    .. note::

        This plaintext representation can be super ugly, contain URLs and so \
        on.

    .. note::

        You need to have ``delatex`` installed system-wide, or to build it in \
                this repo, according to the ``README.md`` before using this \
                function.

    :param bibitem: The text content of the bibitem.
    :returns: A cleaned plaintext citation from the bibitem.
    """
    try:
        output = subprocess.check_output(["delatex",
                                          "-s"],
                                         input=bibitem.encode("utf-8"))
    except FileNotFoundError:
        script_dir = os.path.dirname(os.path.abspath(__file__))
        output = subprocess.check_output(["%s/../external/opendetex/delatex" %
                                          (script_dir,),
                                          "-s"],
                                         input=bibitem.encode("utf-8"))
    output = output.decode("utf-8")
    output = tools.clean_whitespaces(output)
    return output