ajalt / clikt

Multiplatform command line interface parsing for Kotlin
https://ajalt.github.io/clikt/
Apache License 2.0
2.56k stars 123 forks source link

Unable to format Markdown in help text #562

Closed mikaelstaldal closed 2 weeks ago

mikaelstaldal commented 3 weeks ago

I get this error when trying to format Markdown in help text according to https://ajalt.github.io/clikt/documenting/#markdown-in-help-texts with Clikt 5.0.1 and Mordant 3.0.0:

Exception in thread "main" java.lang.NoSuchFieldError: Class org.intellij.markdown.flavours.gfm.GFMElementTypes does not have member field 'org.intellij.markdown.IElementType INLINE_MATH'
    at com.github.ajalt.mordant.markdown.MarkdownRenderer.parseInlines(MarkdownRenderer.kt:213)
    at com.github.ajalt.mordant.markdown.MarkdownRenderer.innerInlines$lambda$11(MarkdownRenderer.kt:329)
    at kotlin.text.StringsKt__AppendableKt.appendElement(Appendable.kt:84)
    at kotlin.collections.CollectionsKt___CollectionsKt.joinTo(_Collections.kt:3493)
    at kotlin.collections.CollectionsKt___CollectionsKt.joinToString(_Collections.kt:3510)
    at kotlin.collections.CollectionsKt___CollectionsKt.joinToString$default(_Collections.kt:3509)
    at com.github.ajalt.mordant.markdown.MarkdownRenderer.innerInlines(MarkdownRenderer.kt:329)
    at com.github.ajalt.mordant.markdown.MarkdownRenderer.innerInlines$default(MarkdownRenderer.kt:327)
    at com.github.ajalt.mordant.markdown.MarkdownRenderer.parseStructure(MarkdownRenderer.kt:124)
    at com.github.ajalt.mordant.markdown.MarkdownRenderer.parseBlocks$lambda$0(MarkdownRenderer.kt:72)
    at com.github.ajalt.mordant.table.TableDslKt.verticalLayout(TableDsl.kt:370)
    at com.github.ajalt.mordant.markdown.MarkdownRenderer.parseBlocks(MarkdownRenderer.kt:57)
    at com.github.ajalt.mordant.markdown.MarkdownRenderer.parseFile(MarkdownRenderer.kt:53)
    at com.github.ajalt.mordant.markdown.MarkdownRenderer.render(MarkdownRenderer.kt:47)
    at com.github.ajalt.mordant.markdown.Markdown.document(Markdown.kt:25)
    at com.github.ajalt.mordant.markdown.Markdown.render(Markdown.kt:31)
    at com.github.ajalt.mordant.widgets.Padded.render(Padding.kt:110)
    at com.github.ajalt.mordant.table.VerticalLayout.render(VerticalLayout.kt:70)
    at com.github.ajalt.mordant.rendering.Widget$DefaultImpls.render$default(Widget.kt:7)
    at com.github.ajalt.mordant.terminal.Terminal.render(Terminal.kt:231)
    at com.github.ajalt.clikt.output.MordantHelpFormatter.formatHelp(MordantHelpFormatter.kt:58)
    at com.github.ajalt.clikt.core.BaseCliktCommand.getFormattedHelp(BaseCliktCommand.kt:279)
    at com.github.ajalt.clikt.core.BaseCliktCommand.echoFormattedHelp(BaseCliktCommand.kt:292)
    at com.github.ajalt.clikt.core.CoreCliktCommandKt.main(CoreCliktCommand.kt:113)

Open source code: https://gitlab.com/chromaway/core-tools/chromia-cli/blob/e25270a378e25d20f5968a32930e837222b5532a/chromia-cli/src/main/kotlin/com/chromia/cli/command/QueryCommand.kt#L26

mikaelstaldal commented 2 weeks ago

Oh, never mind, it was a classpath issue on our end, we ended up using a too old version of Jetbrains's Markdown lib. Pinning version 0.7.3 fixed the issue.