<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def tokenize_math(text):
 r"""Prevents math from being tokenized. :param Buffer text: iterator over line, with current position '$' '$$' """

    if text.startswith('$') and (
       text.position == 0 or text.peek(-1) != '\\' or text.endswith(r'\\')):
        starter = '$$' if text.startswith('$$') else '$'
        return TokenWithPosition(text.forward(len(starter)), text.position)