in src/commonMain/kotlin/org/intellij/markdown/flavours/gfm/table/GitHubTableMarkerProvider.kt [13:36]
override fun createMarkerBlocks(pos: LookaheadText.Position, productionHolder: ProductionHolder, stateInfo: MarkerProcessor.StateInfo): List<MarkerBlock> {
val currentConstraints = stateInfo.currentConstraints
if (stateInfo.nextConstraints != currentConstraints) {
return emptyList()
}
val currentLineFromPosition = pos.currentLineFromPosition
if (!currentLineFromPosition.contains('|')) {
return emptyList()
}
val split = GitHubTableMarkerBlock.splitByPipes(currentLineFromPosition)
val numberOfHeaderCells = split
.mapIndexed { i, s -> (i > 0 && i < split.lastIndex) || s.isNotBlank() }
.count { it }
if (numberOfHeaderCells == 0) {
return emptyList()
}
val nextLine = getNextLineFromConstraints(pos, currentConstraints) ?: return emptyList()
if (countSecondLineCells(nextLine) == numberOfHeaderCells) {
return listOf(GitHubTableMarkerBlock(pos, currentConstraints, productionHolder, numberOfHeaderCells))
}
return emptyList()
}