import re


def extract_citation(rawtext):
    """
    Extract citation elements from a raw citations string
    """
    tokens = re.split(r'\s*\{%\s*(.*?)\s*%\}\s*', rawtext)
    if len(tokens) == 3:
        pre_text, keys, post_text = tokens
    else:
        pre_text, keys, post_text = '', tokens[0], ''
    key_list = [key.strip() for key in keys.split(',')]
    return pre_text, key_list, post_text