diff --git a/readme.md b/readme.md index ec8fc05..77ba467 100644 --- a/readme.md +++ b/readme.md @@ -6,6 +6,37 @@ other changes should be required. See the [Markdown.kt](src/commonMain/kotlin/nl/astraeus/markdown/parser/Markdown.kt) class for the format of the output. +## JVM & JS versions available on maven central + + implementation("nl.astraeus:markdown-parser:1.0.4") + +## Usage + +```kotlin +val markdown = markdown("# Markdown\n\nMy **markdown** text.") +``` + +This will give you a list of MarkdownPart elements: + +- MarkdownPart.Header(text="Markdown", size=1) +- MarkdownPart.Paragraph(parts= + - Text("My ") + - Bold("markdown") + - Text(" text.\n") + ) + +A paragraph can be parsed separately, e.g. + +```koltin +val paragraph = parseParagraph("My **markdown** text.") +``` + +Which will produce a paragraph element with 3 parts: + +- Text("My ") +- Bold("markdown") +- Text(" text.\n") + ## Mark down support ### Headers @@ -64,12 +95,9 @@ You can create code blocks by indenting lines with two (or more) spaces or inlin Also code blocks are supported: -```java -// java code -public class Example { - public static void main(String[] args) { - System.out.println("Hello, World!"); - } +```kotlin +fun main() { + val md = markdown("Markdown text") } ``` diff --git a/src/commonTest/kotlin/nl/astraeus/markdown/parser/ParseTest.kt b/src/commonTest/kotlin/nl/astraeus/markdown/parser/ParseTest.kt index c2e8ce7..4fd2087 100644 --- a/src/commonTest/kotlin/nl/astraeus/markdown/parser/ParseTest.kt +++ b/src/commonTest/kotlin/nl/astraeus/markdown/parser/ParseTest.kt @@ -66,6 +66,15 @@ class ParseTest { printMarkdownParts(md) } + @Test + fun testHeading() { + val input = "# Markdown\n\nMy **markdown** text." + + val md = markdown(input) + + printMarkdownParts(md) + } + private fun printMarkdownParts(md: List) { for (part in md) { if (part is MarkdownPart.Paragraph) {