<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def highlight_multiline_block(self, block, start_pattern, end_pattern, state, format):
 """ Highlights given multiline text block. :param block: Text block. :type block: QString :param pattern: Start regex pattern. :type pattern: QRegExp :param pattern: End regex pattern. :type pattern: QRegExp :param format: Format. :type format: QTextCharFormat :param state: Block state. :type state: int :return: Current block matching state. :rtype: bool """


        if self.previousBlockState() == state:
            start = 0
            extend = 0
        else:
            start = start_pattern.indexIn(block)
            extend = start_pattern.matchedLength()

        while start >= 0:
            end = end_pattern.indexIn(block, start + extend)
            if end >= extend:
                length = end - start + extend + end_pattern.matchedLength()
                self.setCurrentBlockState(0)
            else:
                self.setCurrentBlockState(state)
                length = block.length() - start + extend
            self.setFormat(start, length, format)
            start = start_pattern.indexIn(block, start + length)

        if self.currentBlockState() == state:
            return True
        else:
            return False