-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Diff lines when deciding what blocks to update
Also add a parameter to not apply optimizations to documents which could be modified. Added workarounds for LinkReferenceDefinition which shouldn't be a top level node.
- Loading branch information
Showing
3 changed files
with
157 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
...own/core/src/test/kotlin/org/jetbrains/jewel/markdown/processing/MarkdownProcessorTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package org.jetbrains.jewel.markdown.processing | ||
|
||
import org.jetbrains.jewel.markdown.BlockWithInlineMarkdown | ||
import org.jetbrains.jewel.markdown.MarkdownBlock | ||
import org.junit.Assert.assertArrayEquals | ||
import org.junit.Assert.assertEquals | ||
import org.junit.Test | ||
|
||
class MarkdownProcessorTest { | ||
|
||
@Test | ||
fun `test my processor`() { | ||
val pp = MarkdownProcessor() | ||
pp.processMarkdownDocument( | ||
""" | ||
|Paragraph 1 | ||
| | ||
|Paragraph 2 | ||
| | ||
|Second paragraph | ||
|not very important | ||
| | ||
|* m1 | ||
|* m2 | ||
""".trimMargin(), | ||
) | ||
val secondProcess = pp.processMarkdownDocument( | ||
""" | ||
|Paragraph 1 | ||
| | ||
|Paragraph 2 | ||
| | ||
|Not a paragraph | ||
|not very important | ||
| | ||
|* m1 | ||
|* m2 | ||
""".trimMargin(), | ||
) | ||
// TODO: update after changing the underlying model, to check the first elements are the same | ||
assertEquals("Paragraph 1", (secondProcess[0] as BlockWithInlineMarkdown).inlineContent.content) | ||
assertEquals("Paragraph 2", (secondProcess[1] as BlockWithInlineMarkdown).inlineContent.content) | ||
assertEquals( | ||
"Not a paragraph not very important", | ||
(secondProcess[2] as BlockWithInlineMarkdown).inlineContent.content, | ||
) | ||
assertArrayEquals( | ||
arrayOf( | ||
"Paragraph(inlineContent=InlineMarkdown(content=m1))", | ||
"Paragraph(inlineContent=InlineMarkdown(content=m2))", | ||
), | ||
(secondProcess[3] as MarkdownBlock.ListBlock).items.flatMap { it.content.map(MarkdownBlock::toString) }.toTypedArray(), | ||
) | ||
} | ||
} |