def _replace_ref(matched, citations):
    """citations: ref => index"""
    cite = matched[7:-3]
    if cite not in citations:
        citations[cite] = len(citations) + 1
    return '[[{i}]](#PYPPL-REF-{i}){{.pyppl-report-refindex}}'.format(i=
        citations[cite])
