fun calcNumberOfConsequentEols()

in src/commonMain/kotlin/org/intellij/markdown/parser/markerblocks/MarkdownParserUtil.kt [9:34]


    fun calcNumberOfConsequentEols(pos: LookaheadText.Position, constraints: MarkdownConstraints): Int {
        assert(pos.offsetInCurrentLine == -1)

        var currentPos = pos
        var result = 1

        val isClearLine: (LookaheadText.Position) -> Boolean = { pos ->
            val currentConstraints = constraints.applyToNextLine(pos)
            val constraintsLength = currentConstraints.getCharsEaten(pos.currentLine)

            currentConstraints.upstreamWith(constraints) && (
                    constraintsLength >= pos.currentLine.length ||
                    pos.nextPosition(1 + constraintsLength)?.charsToNonWhitespace() == null)
        }

        while (isClearLine(currentPos)) {
            currentPos = currentPos.nextLinePosition()
                    ?: break//return 5

            result++
            if (result > 4) {
                break
            }
        }
        return result
    }