override fun fetchListMarker()

in src/commonMain/kotlin/org/intellij/markdown/flavours/gfm/GFMConstraints.kt [25:46]


    override fun fetchListMarker(pos: LookaheadText.Position): CommonMarkdownConstraints.ListMarkerInfo? {
        val baseMarkerInfo = super.fetchListMarker(pos)
                ?: return null

        val line = pos.currentLine
        var offset = pos.offsetInCurrentLine + baseMarkerInfo.markerLength

        while (offset < line.length && (line[offset] == ' ' || line[offset] == '\t')) {
            offset++
        }

        if (offset + 3 <= line.length
                && line[offset] == '['
                && line[offset + 2] == ']'
                && (line[offset + 1] == 'x' || line[offset + 1] == 'X' || line[offset + 1] == ' ')) {
            return CommonMarkdownConstraints.ListMarkerInfo(offset + 3 - pos.offsetInCurrentLine,
                    toCheckboxType(baseMarkerInfo.markerType),
                    baseMarkerInfo.markerLength)
        } else {
            return baseMarkerInfo
        }
    }