def METHOD_NAME(self, block, m, state):
    title = m.group('value')
    depth = None
    options = self.parse_options(m)
    if options:
        depth = dict(options).get('depth')
        if depth:
            try:
                depth = int(depth)
            except (ValueError, TypeError):
                return {
                    'type': 'block_error',
                    'raw': 'TOC depth MUST be integer',
                }
    return {'type': 'toc', 'raw': None, 'params': (title, depth)}