fun matchLinkTitle()

in src/commonMain/kotlin/org/intellij/markdown/parser/markerblocks/providers/LinkReferenceDefinitionProvider.kt [139:172]


        fun matchLinkTitle(text: CharSequence, start: Int): IntRange? {
            if (start >= text.length)
                return null

            val endDelim = when (text[start]) {
                '\'' -> '\''
                '"' -> '"'
                '(' -> ')'
                else -> return null
            }

            var offset = start + 1
            var isBlank = false
            while (offset < text.length) {
                val c = text[offset]
                if (c == endDelim)
                    return IntRange(start, offset)
                if (c == '\n') {
                    if (isBlank)
                        return null
                    else
                        isBlank = true
                }
                else if (!isSpace(c)) {
                    isBlank = false
                }

                if (c == '\\' && offset + 1 < text.length && !isSpaceOrNewline(text[offset + 1]))
                    offset++

                offset++
            }
            return null
        }