blob: c37e215f82d13a6b85b8637eeb4067d078c493f3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
package moe.nea.blog.md
object BlockQuoteParser : BlockParser {
override fun detect(line: String): Boolean {
return line.startsWith("> ")
}
override fun parse(parser: MarkdownParser): MarkdownBlock {
parser.pushPreProcessor(
LinePreProcessor.whileIgnoringFirst(
parser.getIndent()
) { _, line ->
if (!line.startsWith("> ") && line != ">") {
null
} else {
" " + line.substring(2)
}
}
)
parser.pushIndent(2)
val blocks = mutableListOf<MarkdownBlock>()
while (true) {
val child = parser.readChildBlock() ?: break
blocks.add(child)
}
parser.popPreProcessor()
parser.popIndent()
return BlockQuote(parser.mergeBlocks(blocks))
}
override val prio: Int
get() = 10
}
|