def highlight_source(linenumber, index, lines, offset=None):
    """Extracts a few relevant lines from a file content given as a list
        of lines, adding line number information and identifying
        a particular line.

        When dealing with a ``SyntaxError`` or its subclasses, offset is an
        integer normally used by Python to indicate the position of
        the error with a ``^``, like::

            if True
                  ^

        which, in this case, points to a missing colon. We use the same
        representation in this case.
    """
    if lines is None:
        return '', ''
    if index is None:
        print('problem in highlight_source(): index is None')
        index = 0
    new_lines = []
    problem_line = ''
    nb_digits = len(str(linenumber + index))
    no_mark = '       {:%d}: ' % nb_digits
    with_mark = '    -->{:%d}: ' % nb_digits
    if offset is not None:
        offset_mark = ' ' * (8 + nb_digits + offset) + '^'
    i = linenumber - index
    for line in lines:
        if i == linenumber:
            num = with_mark.format(i)
            problem_line = line
            new_lines.append(num + line.rstrip())
            if offset is not None:
                new_lines.append(offset_mark)
            break
        else:
            num = no_mark.format(i)
        new_lines.append(num + line.rstrip())
        i += 1
    return '\n'.join(new_lines), problem_line
