summaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/blog/md/ParagraphParser.kt
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/moe/nea/blog/md/ParagraphParser.kt')
-rw-r--r--src/main/kotlin/moe/nea/blog/md/ParagraphParser.kt31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/main/kotlin/moe/nea/blog/md/ParagraphParser.kt b/src/main/kotlin/moe/nea/blog/md/ParagraphParser.kt
new file mode 100644
index 0000000..328c49b
--- /dev/null
+++ b/src/main/kotlin/moe/nea/blog/md/ParagraphParser.kt
@@ -0,0 +1,31 @@
+package moe.nea.blog.md
+
+object ParagraphParser : BlockParser {
+ override fun detect(line: String): Boolean {
+ return true
+ }
+
+ override fun parse(parser: MarkdownParser): MarkdownBlock {
+ var text = ""
+ var emptyLineCount = 0
+ while (true) {
+ val line = parser.peekLine() ?: break
+ if (parser.findParserFor(line) != null) break
+ val trimmedLine = parser.consumeLine()!!.trim()
+ if (trimmedLine == "") {
+ emptyLineCount++
+ } else {
+ emptyLineCount = 0
+ }
+ if (emptyLineCount == 2) {
+ break
+ }
+ text += " $trimmedLine"
+ }
+ return Paragraph(parser.parseInlineText(text))
+ }
+
+ override val prio: Int
+ get() = -10
+
+} \ No newline at end of file