@staticmethod
def translate_logical_line(start, end, contents, indent_stack, endmarker=False
    ):
    """Translate raw contents to logical lines."""
    while contents[0] == '\n':
        start += 1
        contents.pop(0)
    while contents[-1] == '\n':
        end -= 1
        contents.pop()
    indent = len(indent_stack[-1]) if indent_stack else 0
    if endmarker:
        indent = len(contents[0])
    return start, end + 1, indent
