'Parse `datalines` for a field list containing extension options
matching `option_spec`.
:Parameters:
- `option_spec`: a mapping of option name to conversion
function, which should raise an exception on bad input.
- `datalines`: a list of input strings.
:Return:
- Success value, 1 or 0.
- An option dictionary on success, an error string on failure.'

def parse_extension_options(self, option_spec, datalines):

    node = nodes.field_list()
    (newline_offset, blank_finish) = self.nested_list_parse(datalines, 0, node, initial_state='ExtensionOptions', blank_finish=1)
    if (newline_offset != len(datalines)):
        return (0, 'invalid    option    block')
    try:
        options = utils.extract_extension_options(node, option_spec)
    except KeyError as detail:
        return (0, ('unknown    option:    "%s"' % detail.args[0]))
    except (ValueError, TypeError) as detail:
        return (0, ('invalid    option    value:    %s' % '    '.join(detail.args)))
    except utils.ExtensionOptionError as detail:
        return (0, ('invalid    option    data:    %s' % '    '.join(detail.args)))
    if blank_finish:
        return (1, options)
    else:
        return (0, 'option    data    incompletely    parsed')
