diff options
Diffstat (limited to 'src/test/kotlin/moe/nea/blog/md')
4 files changed, 86 insertions, 2 deletions
diff --git a/src/test/kotlin/moe/nea/blog/md/test/BlockQuoteTest.kt b/src/test/kotlin/moe/nea/blog/md/test/BlockQuoteTest.kt index 635dd88..c4f7f99 100644 --- a/src/test/kotlin/moe/nea/blog/md/test/BlockQuoteTest.kt +++ b/src/test/kotlin/moe/nea/blog/md/test/BlockQuoteTest.kt @@ -8,9 +8,13 @@ class BlockQuoteTest : MarkdownTest() { assertDocumentFormat( """ <quote> + <p> hi + </p> <quote> + <p> hello + </p> </quote> </quote> """.trimIndent(), @@ -26,7 +30,9 @@ class BlockQuoteTest : MarkdownTest() { assertDocumentFormat( """ <quote> + <p> hi + </p> <code language=kotlin> fun helloWorld(): Unit = "Hello, World!".let(::println) diff --git a/src/test/kotlin/moe/nea/blog/md/test/ListTest.kt b/src/test/kotlin/moe/nea/blog/md/test/ListTest.kt index 0ac8f1e..241929f 100644 --- a/src/test/kotlin/moe/nea/blog/md/test/ListTest.kt +++ b/src/test/kotlin/moe/nea/blog/md/test/ListTest.kt @@ -7,13 +7,19 @@ class ListTest : MarkdownTest() { fun testBasicList() { assertDocumentFormat( """ + <p> Some Text: + </p> <list> <element> + <p> First + </p> </element> <element> + <p> Second + </p> </element> </list> """.trimIndent(), @@ -28,14 +34,22 @@ class ListTest : MarkdownTest() { fun testBlockContinuation() { assertDocumentFormat( """ + <p> Some Text: + </p> <list> <element> + <p> First More First + </p> </element> <element> + <p> Second + </p> + <p> More Second + </p> </element> </list> """.trimIndent(), @@ -53,18 +67,26 @@ class ListTest : MarkdownTest() { fun testNestedLists() { assertDocumentFormat( """ + <p> Some Text: + </p> <list> <element> + <p> First + </p> <list> <element> + <p> Another List + </p> </element> </list> </element> <element> + <p> Second + </p> </element> </list> """.trimIndent(), diff --git a/src/test/kotlin/moe/nea/blog/md/test/MarkdownTest.kt b/src/test/kotlin/moe/nea/blog/md/test/MarkdownTest.kt index 3e01acc..f2aef71 100644 --- a/src/test/kotlin/moe/nea/blog/md/test/MarkdownTest.kt +++ b/src/test/kotlin/moe/nea/blog/md/test/MarkdownTest.kt @@ -9,14 +9,19 @@ import kotlin.test.assertEquals abstract class MarkdownTest { + open fun registerExtraParser(parser: MarkdownParser) { + } + fun parseInline(string: String): MarkdownFormat { val parser = MarkdownParser(string) parser.addDefaultParsers() + registerExtraParser(parser) return parser.parseInlineText(string) } fun parseDoc(string: String): Document { val parser = MarkdownParser(string) parser.addDefaultParsers() + registerExtraParser(parser) return parser.readDocument() } diff --git a/src/test/kotlin/moe/nea/blog/md/test/ParagraphTest.kt b/src/test/kotlin/moe/nea/blog/md/test/ParagraphTest.kt index 9e12cfe..19f4552 100644 --- a/src/test/kotlin/moe/nea/blog/md/test/ParagraphTest.kt +++ b/src/test/kotlin/moe/nea/blog/md/test/ParagraphTest.kt @@ -1,15 +1,63 @@ package moe.nea.blog.md.test +import moe.nea.blog.md.MarkdownParser +import moe.nea.blog.md.ext.NoteBlockParser import kotlin.test.Test class ParagraphTest : MarkdownTest() { + override fun registerExtraParser(parser: MarkdownParser) { + parser.addParser(NoteBlockParser) + } + + @Test + fun testNonImmediateParagraph() { + assertDocumentFormat( + """ + |<note type=note> + | <code language=assembly> + | xor eax, eax + | ret + | </code> + |</note> + |<list> + | <element> + | <p> + | Test + | </p> + | <code language=assembly> + | inc eax + | ret + | </code> + | </element> + |</list> + """.trimMargin(), + """ + |!!! note + | + | ```assembly + | xor eax, eax + | ret + | ``` + | + | - Test + | + | ```assembly + | inc eax + | ret + | ``` + """.trimMargin(), + ) + } @Test fun testParagraph() { assertDocumentFormat(""" + |<p> |a b - | + |</p> + |<p> |c d + |</p> """.trimMargin(), """ |a |b @@ -23,9 +71,12 @@ class ParagraphTest : MarkdownTest() { @Test fun testCodeBlock() { assertDocumentFormat(""" + |<p> |a b - | + |</p> + |<p> |c d + |</p> |<code language=java> |public static final String TEST = "TEST"; |</code> |