summaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-05-03 00:02:29 +0200
committerLinnea Gräf <nea@nea.moe>2024-05-03 00:02:29 +0200
commit1b563a0378998f2fed28bf81b8e254cb47742503 (patch)
tree0ab727813c2150b8293ebcd3d16bfe5ea4e25562 /src/main/kotlin/moe/nea
parent7e24b934bbd424669a1c935894dd8799d4db0348 (diff)
downloadblog-infra-master.tar.gz
blog-infra-master.tar.bz2
blog-infra-master.zip
Improve paragraph detectionHEADmaster
Diffstat (limited to 'src/main/kotlin/moe/nea')
-rw-r--r--src/main/kotlin/moe/nea/blog/md/MarkdownParser.kt10
-rw-r--r--src/main/kotlin/moe/nea/blog/md/Paragraph.kt4
-rw-r--r--src/main/kotlin/moe/nea/blog/md/ext/NoteBlocks.kt2
3 files changed, 14 insertions, 2 deletions
diff --git a/src/main/kotlin/moe/nea/blog/md/MarkdownParser.kt b/src/main/kotlin/moe/nea/blog/md/MarkdownParser.kt
index 673a0ed..4705d4b 100644
--- a/src/main/kotlin/moe/nea/blog/md/MarkdownParser.kt
+++ b/src/main/kotlin/moe/nea/blog/md/MarkdownParser.kt
@@ -21,7 +21,15 @@ class MarkdownParser(source: String) {
}
fun readChildBlock(): MarkdownBlock? {
- val peek = peekLine() ?: return null
+ var peek = ""
+ while (true) {
+ peek = peekLine() ?: return null
+ if (peek.isBlank()) {
+ consumeLine()
+ } else {
+ break
+ }
+ }
val blockParser = findParserFor(peek) ?: ParagraphParser
return blockParser.parse(this)
}
diff --git a/src/main/kotlin/moe/nea/blog/md/Paragraph.kt b/src/main/kotlin/moe/nea/blog/md/Paragraph.kt
index 54f688b..f715e53 100644
--- a/src/main/kotlin/moe/nea/blog/md/Paragraph.kt
+++ b/src/main/kotlin/moe/nea/blog/md/Paragraph.kt
@@ -6,7 +6,11 @@ import java.io.PrintStream
data class Paragraph(val format: MarkdownFormat) : MarkdownBlock {
override fun debugFormat(indent: Int, printStream: PrintStream) {
printStream.indent(indent)
+ printStream.println("<p>")
+ printStream.indent(indent)
format.debugFormat(printStream)
printStream.println()
+ printStream.indent(indent)
+ printStream.println("</p>")
}
} \ No newline at end of file
diff --git a/src/main/kotlin/moe/nea/blog/md/ext/NoteBlocks.kt b/src/main/kotlin/moe/nea/blog/md/ext/NoteBlocks.kt
index a1f977f..6d13063 100644
--- a/src/main/kotlin/moe/nea/blog/md/ext/NoteBlocks.kt
+++ b/src/main/kotlin/moe/nea/blog/md/ext/NoteBlocks.kt
@@ -13,7 +13,7 @@ import java.io.PrintStream
data class NoteBlock(val noteType: String, val child: MarkdownBlock) : MarkdownBlock {
override fun debugFormat(indent: Int, printStream: PrintStream) {
printStream.indent(indent)
- printStream.println("<note type=\"$noteType\">")
+ printStream.println("<note type=$noteType>")
child.debugFormat(indent + 2, printStream)