summaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/blog/md/LinePreProcessor.kt
blob: 7938cbe748657aefba6ba50b4e718bd7413a8f5b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
package moe.nea.blog.md

fun interface LinePreProcessor {
    fun preprocess(lineIndex: Int, line: String): String?

    companion object {
        fun whileIgnoringFirst(indent: Int, wrapped: LinePreProcessor): LinePreProcessor {
            return LinePreProcessor { lineIndex, line ->
                line.take(indent) + wrapped.preprocess(lineIndex, line.drop(indent))
            }
        }
    }
}