Skip to content

Commit

Permalink
Update commonmark-java to 0.22.0
Browse files Browse the repository at this point in the history
...and bump commonmark spec to 0.31.2.

One test it ignored due to a complex case of parsing emphasis:
https://spec.commonmark.org/0.31.2/#emphasis-and-strong-emphasis
  • Loading branch information
Oleg Baskakov committed Mar 19, 2024
1 parent d42aff1 commit c1fffa0
Show file tree
Hide file tree
Showing 7 changed files with 424 additions and 403 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ excludes people in socially marginalized groups.

Private harassment is also unacceptable. No matter who you are, if you feel
you have been or are being harassed or made uncomfortable by a community
member, please contact [one of the mantainers](https://github.com/JetBrains/jewel/graphs/contributors)
member, please contact [one of the maintainers](https://github.com/JetBrains/jewel/graphs/contributors)
immediately.
Whether you're a regular contributor or a newcomer, we care about
making this community a safe place for you and we've got your back.
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[versions]
commonmark = "0.21.0"
commonmark = "0.22.0"
composeDesktop = "1.6.10-dev1514"
detekt = "1.23.4"
dokka = "1.8.20"
Expand Down
3 changes: 1 addition & 2 deletions markdown/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
Adds the ability to render Markdown as native Compose UI.

Currently supports the [CommonMark 0.30](https://spec.commonmark.org/0.30/) specs. When `commonmark-java` will be
updated to support the new 0.31.2 specs, we'll inherit that.
Currently supports the [CommonMark 0.31.2](https://spec.commonmark.org/0.31.2/) specs.

Additional supported Markdown, via extensions:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public class MarkdownProcessor(private val extensions: List<MarkdownProcessorExt
.build()

/**
* Parses a Markdown document, translating from CommonMark 0.30
* Parses a Markdown document, translating from CommonMark 0.31.2
* to a list of [MarkdownBlock]. Inline Markdown in leaf nodes
* is contained in [InlineMarkdown], which can be rendered
* to an [androidx.compose.ui.text.AnnotatedString] by using
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package org.jetbrains.jewel.markdown

import org.jetbrains.jewel.markdown.processing.MarkdownProcessor
import org.junit.Test

class MarkdownProcessorDocumentParsingExtraTest {

private val processor = MarkdownProcessor()

@Test
fun `should parse spec sample 461b correctly (Emphasis and strong emphasis)`() {
val parsed = processor.processMarkdownDocument("*_foo *bar*_*")

/*
* Expected HTML:
* <p><em><em>foo <em>bar</em></em></em></p>
*/
parsed.assertEquals(paragraph("*_foo *bar*_*"))
}

@Test
fun `should parse spec sample 461c correctly (Emphasis and strong emphasis)`() {
val parsed = processor.processMarkdownDocument("**foo *bar***")

/*
* Expected HTML:
* <p><strong>foo <em>bar</em></strong></p>
*/
parsed.assertEquals(paragraph("**foo *bar***"))
}

@Test
fun `should parse spec sample 461d correctly (Emphasis and strong emphasis)`() {
val parsed = processor.processMarkdownDocument("*_foo *bar* a_*")

/*
* Expected HTML:
* <p><em><em>foo <em>bar</em> a</em></em></p>
*/
parsed.assertEquals(paragraph("*_foo *bar* a_*"))
}

@Test
fun `should parse spec sample 461e correctly (Emphasis and strong emphasis)`() {
val parsed = processor.processMarkdownDocument("**foo *bar* a**")

/*
* Expected HTML:
* <p><strong>foo <em>bar</em> a</strong></p>
*/
parsed.assertEquals(paragraph("**foo *bar* a**"))
}

@Test
fun `should parse spec sample 461f correctly (Emphasis and strong emphasis)`() {
val parsed = processor.processMarkdownDocument("*_*foo *bar* a*_*")

/*
* Expected HTML:
* <p><strong>foo <em>bar</em> a</strong></p>
*/
parsed.assertEquals(paragraph("*_*foo *bar* a*_*"))
}
}
Loading

0 comments on commit c1fffa0

Please sign in to comment.