in src/commonMain/kotlin/org/intellij/markdown/flavours/gfm/GFMMarkerProcessor.kt [28:62]
override fun populateConstraintsTokens(pos: LookaheadText.Position,
constraints: MarkdownConstraints,
productionHolder: ProductionHolder) {
if (constraints !is GFMConstraints || !constraints.hasCheckbox()) {
super.populateConstraintsTokens(pos, constraints, productionHolder)
return
}
val line = pos.currentLine
var offset = pos.offsetInCurrentLine
while (offset < line.length && line[offset] != '[') {
offset++
}
if (offset == line.length) {
super.populateConstraintsTokens(pos, constraints, productionHolder)
return
}
val type = when (constraints.types.lastOrNull()) {
'>' ->
MarkdownTokenTypes.BLOCK_QUOTE
'.', ')' ->
MarkdownTokenTypes.LIST_NUMBER
else ->
MarkdownTokenTypes.LIST_BULLET
}
val middleOffset = pos.offset - pos.offsetInCurrentLine + offset
val endOffset = min(pos.offset - pos.offsetInCurrentLine + constraints.getCharsEaten(pos.currentLine),
pos.nextLineOrEofOffset)
productionHolder.addProduction(listOf(
SequentialParser.Node(pos.offset..middleOffset, type),
SequentialParser.Node(middleOffset..endOffset, GFMTokenTypes.CHECK_BOX)
))
}