fun matchLinkDefinition()

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


        fun matchLinkDefinition(text: CharSequence, startOffset: Int): List<IntRange>? {
            var offset = MarkerBlockProvider.passSmallIndent(text, startOffset)
            val linkLabel = matchLinkLabel(text, offset) ?: return null
            offset = linkLabel.last + 1
            if (offset >= text.length || text[offset] != ':')
                return null
            offset++

            offset = passOneNewline(text, offset)

            val destination = matchLinkDestination(text, offset) ?: return null
            offset = destination.last + 1
            offset = passOneNewline(text, offset)

            val title = matchLinkTitle(text, offset)

            val result = ArrayList<IntRange>()
            result.add(linkLabel)
            result.add(destination)
            if (title != null) {
                offset = title.last + 1
                while (offset < text.length && isSpace(text[offset]))
                    offset++
                if (offset >= text.length || text[offset] == '\n') {
                    result.add(title)
                }
            }

            return result
        }