import re


def strip_outer_dollars(value):
    """Strip surrounding dollars signs from TeX string, ignoring leading and
    trailing whitespace"""
    if value is None:
        return '{}'
    value = value.strip()
    m = re.match(r'^\$(.*)\$$', value)
    if m is not None:
        value = m.groups()[0]
    return value