fun processPosition()

in src/commonMain/kotlin/org/intellij/markdown/parser/MarkerProcessor.kt [63:98]


    fun processPosition(pos: LookaheadText.Position): LookaheadText.Position? {
        updateStateInfo(pos)

        var shouldRecalcNextPos = false

        if (pos.offset >= nextInterestingPosForExistingMarkers) {
            processMarkers(pos)
            shouldRecalcNextPos = true
        }

        if (MarkerBlockProvider.isStartOfLineWithConstraints(pos, stateInfo.currentConstraints)
                && markersStack.lastOrNull()?.allowsSubBlocks() != false) {
            val newMarkerBlocks = createNewMarkerBlocks(pos, productionHolder)
            for (newMarkerBlock in newMarkerBlocks) {
                addNewMarkerBlock(newMarkerBlock)
                shouldRecalcNextPos = true
            }
        }

        if (shouldRecalcNextPos) {
            nextInterestingPosForExistingMarkers = calculateNextPosForExistingMarkers(pos)
        }

        if (pos.offsetInCurrentLine == -1
                || MarkerBlockProvider.isStartOfLineWithConstraints(pos, stateInfo.currentConstraints)) {
            val delta = stateInfo.nextConstraints.getCharsEaten(pos.currentLine) - pos.offsetInCurrentLine
            if (delta > 0) {
                if (pos.offsetInCurrentLine != -1 && stateInfo.nextConstraints.indent <= topBlockConstraints.indent) {
                    populateConstraintsTokens(pos, stateInfo.nextConstraints, productionHolder)
                }
                return pos.nextPosition(delta)
            }
        }

        return pos.nextPosition(nextInterestingPosForExistingMarkers - pos.offset)
    }