diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
index fd1904ab3..7a9999f19 100644
--- a/.idea/inspectionProfiles/Project_Default.xml
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -3,6 +3,7 @@
+
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index 5b013282b..0b8fdcb06 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -17,6 +17,7 @@ poko = "0.13.1"
[libraries]
commonmark-core = { module = "org.commonmark:commonmark", version.ref = "commonmark" }
commonmark-ext-autolink = { module = "org.commonmark:commonmark-ext-autolink", version.ref = "commonmark" }
+commonmark-ext-gfm-tables = { module = "org.commonmark:commonmark-ext-gfm-tables", version.ref = "commonmark" }
filePicker = { module = "com.darkrockstudios:mpfilepicker", version = "3.1.0" }
diff --git a/markdown/core/api/core.api b/markdown/core/api/core.api
index e732e11cf..5950bbef3 100644
--- a/markdown/core/api/core.api
+++ b/markdown/core/api/core.api
@@ -233,6 +233,20 @@ public final class org/jetbrains/jewel/markdown/MarkdownBlock$CodeBlock$Indented
public abstract interface class org/jetbrains/jewel/markdown/MarkdownBlock$CustomBlock : org/jetbrains/jewel/markdown/MarkdownBlock {
}
+public final class org/jetbrains/jewel/markdown/MarkdownBlock$CustomBlock$DefaultCustomBlock : org/jetbrains/jewel/markdown/MarkdownBlock$CustomBlock {
+ public static final synthetic fun box-impl (Lorg/commonmark/node/CustomBlock;)Lorg/jetbrains/jewel/markdown/MarkdownBlock$CustomBlock$DefaultCustomBlock;
+ public static fun constructor-impl (Lorg/commonmark/node/CustomBlock;)Lorg/commonmark/node/CustomBlock;
+ public fun equals (Ljava/lang/Object;)Z
+ public static fun equals-impl (Lorg/commonmark/node/CustomBlock;Ljava/lang/Object;)Z
+ public static final fun equals-impl0 (Lorg/commonmark/node/CustomBlock;Lorg/commonmark/node/CustomBlock;)Z
+ public final fun getNativeBlock ()Lorg/commonmark/node/CustomBlock;
+ public fun hashCode ()I
+ public static fun hashCode-impl (Lorg/commonmark/node/CustomBlock;)I
+ public fun toString ()Ljava/lang/String;
+ public static fun toString-impl (Lorg/commonmark/node/CustomBlock;)Ljava/lang/String;
+ public final synthetic fun unbox-impl ()Lorg/commonmark/node/CustomBlock;
+}
+
public final class org/jetbrains/jewel/markdown/MarkdownBlock$Heading : org/jetbrains/jewel/markdown/BlockWithInlineMarkdown, org/jetbrains/jewel/markdown/MarkdownBlock {
public static final synthetic fun box-impl (Lorg/commonmark/node/Heading;)Lorg/jetbrains/jewel/markdown/MarkdownBlock$Heading;
public static fun constructor-impl (Lorg/commonmark/node/Heading;)Lorg/commonmark/node/Heading;
@@ -406,6 +420,11 @@ public abstract interface class org/jetbrains/jewel/markdown/extensions/Markdown
public abstract fun processMarkdownBlock (Lorg/commonmark/node/CustomBlock;Lorg/jetbrains/jewel/markdown/processing/MarkdownProcessor;)Lorg/jetbrains/jewel/markdown/MarkdownBlock$CustomBlock;
}
+public final class org/jetbrains/jewel/markdown/extensions/MarkdownBlockProcessorExtension$DefaultImpls {
+ public static fun canProcess (Lorg/jetbrains/jewel/markdown/extensions/MarkdownBlockProcessorExtension;Lorg/commonmark/node/CustomBlock;)Z
+ public static fun processMarkdownBlock (Lorg/jetbrains/jewel/markdown/extensions/MarkdownBlockProcessorExtension;Lorg/commonmark/node/CustomBlock;Lorg/jetbrains/jewel/markdown/processing/MarkdownProcessor;)Lorg/jetbrains/jewel/markdown/MarkdownBlock$CustomBlock;
+}
+
public abstract interface class org/jetbrains/jewel/markdown/extensions/MarkdownBlockRendererExtension {
public abstract fun canRender (Lorg/jetbrains/jewel/markdown/MarkdownBlock$CustomBlock;)Z
public abstract fun render (Lorg/jetbrains/jewel/markdown/MarkdownBlock$CustomBlock;Lorg/jetbrains/jewel/markdown/rendering/MarkdownBlockRenderer;Lorg/jetbrains/jewel/markdown/rendering/InlineMarkdownRenderer;Landroidx/compose/runtime/Composer;I)V
@@ -417,6 +436,10 @@ public abstract interface class org/jetbrains/jewel/markdown/extensions/Markdown
public abstract fun getTextRendererExtension ()Lorg/commonmark/renderer/text/TextContentRenderer$TextContentRendererExtension;
}
+public final class org/jetbrains/jewel/markdown/extensions/MarkdownProcessorExtension$DefaultImpls {
+ public static fun getProcessorExtension (Lorg/jetbrains/jewel/markdown/extensions/MarkdownProcessorExtension;)Lorg/jetbrains/jewel/markdown/extensions/MarkdownBlockProcessorExtension;
+}
+
public abstract interface class org/jetbrains/jewel/markdown/extensions/MarkdownRendererExtension {
public abstract fun getBlockRenderer ()Lorg/jetbrains/jewel/markdown/extensions/MarkdownBlockRendererExtension;
}
diff --git a/markdown/core/src/main/kotlin/org/jetbrains/jewel/markdown/MarkdownBlock.kt b/markdown/core/src/main/kotlin/org/jetbrains/jewel/markdown/MarkdownBlock.kt
index 1b7ccdb32..503deeaee 100644
--- a/markdown/core/src/main/kotlin/org/jetbrains/jewel/markdown/MarkdownBlock.kt
+++ b/markdown/core/src/main/kotlin/org/jetbrains/jewel/markdown/MarkdownBlock.kt
@@ -1,6 +1,7 @@
package org.jetbrains.jewel.markdown
import org.commonmark.node.Block
+import org.commonmark.node.CustomBlock as CMCustomBlock
import org.commonmark.node.Heading as CMHeading
import org.commonmark.node.Paragraph as CMParagraph
@@ -22,7 +23,10 @@ public sealed interface MarkdownBlock {
) : CodeBlock
}
- public interface CustomBlock : MarkdownBlock
+ public interface CustomBlock : MarkdownBlock {
+ @JvmInline
+ public value class DefaultCustomBlock(public val nativeBlock: CMCustomBlock) : CustomBlock
+ }
@JvmInline
public value class Heading(
diff --git a/markdown/core/src/main/kotlin/org/jetbrains/jewel/markdown/extensions/MarkdownBlockProcessorExtension.kt b/markdown/core/src/main/kotlin/org/jetbrains/jewel/markdown/extensions/MarkdownBlockProcessorExtension.kt
index 860797a7b..378aeee52 100644
--- a/markdown/core/src/main/kotlin/org/jetbrains/jewel/markdown/extensions/MarkdownBlockProcessorExtension.kt
+++ b/markdown/core/src/main/kotlin/org/jetbrains/jewel/markdown/extensions/MarkdownBlockProcessorExtension.kt
@@ -11,7 +11,7 @@ public interface MarkdownBlockProcessorExtension {
*
* @param block The [CustomBlock] to parse
*/
- public fun canProcess(block: CustomBlock): Boolean
+ public fun canProcess(block: CustomBlock): Boolean = false
/**
* Processes the [block] as a [MarkdownBlock.CustomBlock], if possible. Note
@@ -19,5 +19,5 @@ public interface MarkdownBlockProcessorExtension {
* [block], as implementations might throw an exception for unsupported
* block types.
*/
- public fun processMarkdownBlock(block: CustomBlock, processor: MarkdownProcessor): MarkdownBlock.CustomBlock?
+ public fun processMarkdownBlock(block: CustomBlock, processor: MarkdownProcessor): MarkdownBlock.CustomBlock? = null
}
diff --git a/markdown/core/src/main/kotlin/org/jetbrains/jewel/markdown/extensions/MarkdownProcessorExtension.kt b/markdown/core/src/main/kotlin/org/jetbrains/jewel/markdown/extensions/MarkdownProcessorExtension.kt
index 039f5c895..31470140e 100644
--- a/markdown/core/src/main/kotlin/org/jetbrains/jewel/markdown/extensions/MarkdownProcessorExtension.kt
+++ b/markdown/core/src/main/kotlin/org/jetbrains/jewel/markdown/extensions/MarkdownProcessorExtension.kt
@@ -32,5 +32,6 @@ public interface MarkdownProcessorExtension {
* is already be handled by [org.jetbrains.jewel.markdown.processing.MarkdownProcessor]
* or another [org.jetbrains.jewel.markdown.extensions.MarkdownProcessorExtension].
*/
- public val processorExtension: MarkdownBlockProcessorExtension?
+ public val processorExtension: MarkdownBlockProcessorExtension
+ get() = object : MarkdownBlockProcessorExtension {}
}
diff --git a/markdown/core/src/main/kotlin/org/jetbrains/jewel/markdown/processing/MarkdownProcessor.kt b/markdown/core/src/main/kotlin/org/jetbrains/jewel/markdown/processing/MarkdownProcessor.kt
index 7c39b704f..8fc02dff8 100644
--- a/markdown/core/src/main/kotlin/org/jetbrains/jewel/markdown/processing/MarkdownProcessor.kt
+++ b/markdown/core/src/main/kotlin/org/jetbrains/jewel/markdown/processing/MarkdownProcessor.kt
@@ -23,6 +23,7 @@ import org.jetbrains.jewel.foundation.ExperimentalJewelApi
import org.jetbrains.jewel.markdown.InlineMarkdown
import org.jetbrains.jewel.markdown.MarkdownBlock
import org.jetbrains.jewel.markdown.MarkdownBlock.CodeBlock
+import org.jetbrains.jewel.markdown.MarkdownBlock.CustomBlock.DefaultCustomBlock
import org.jetbrains.jewel.markdown.MarkdownBlock.ListBlock
import org.jetbrains.jewel.markdown.MimeType
import org.jetbrains.jewel.markdown.extensions.MarkdownProcessorExtension
@@ -189,8 +190,9 @@ public class MarkdownProcessor(
is ThematicBreak -> MarkdownBlock.ThematicBreak
is HtmlBlock -> toMarkdownHtmlBlockOrNull()
is CustomBlock -> {
- extensions.find { it.processorExtension?.canProcess(this) == true }
+ extensions.find { it.processorExtension.canProcess(this) }
?.processorExtension?.processMarkdownBlock(this, this@MarkdownProcessor)
+ ?: DefaultCustomBlock(this)
}
else -> null
diff --git a/markdown/extension/autolink/src/main/kotlin/org/jetbrains/jewel/markdown/extension/autolink/AutolinkProcessorExtension.kt b/markdown/extension/autolink/src/main/kotlin/org/jetbrains/jewel/markdown/extension/autolink/AutolinkProcessorExtension.kt
index ad8161dea..bb759c391 100644
--- a/markdown/extension/autolink/src/main/kotlin/org/jetbrains/jewel/markdown/extension/autolink/AutolinkProcessorExtension.kt
+++ b/markdown/extension/autolink/src/main/kotlin/org/jetbrains/jewel/markdown/extension/autolink/AutolinkProcessorExtension.kt
@@ -3,10 +3,10 @@ package org.jetbrains.jewel.markdown.extension.autolink
import org.commonmark.ext.autolink.AutolinkExtension
import org.commonmark.parser.Parser.ParserExtension
import org.commonmark.renderer.text.TextContentRenderer
-import org.jetbrains.jewel.markdown.extensions.MarkdownBlockProcessorExtension
import org.jetbrains.jewel.markdown.extensions.MarkdownProcessorExtension
public object AutolinkProcessorExtension : MarkdownProcessorExtension {
+
override val parserExtension: ParserExtension
get() = AutolinkExtension.create() as ParserExtension
@@ -15,6 +15,4 @@ public object AutolinkProcessorExtension : MarkdownProcessorExtension {
*/
override val textRendererExtension: TextContentRenderer.TextContentRendererExtension?
get() = null
- override val processorExtension: MarkdownBlockProcessorExtension?
- get() = null
}
diff --git a/markdown/extension/gfm-tables/api/gfm-tables.api b/markdown/extension/gfm-tables/api/gfm-tables.api
new file mode 100644
index 000000000..871a0a451
--- /dev/null
+++ b/markdown/extension/gfm-tables/api/gfm-tables.api
@@ -0,0 +1,35 @@
+public final class org/jetbrains/jewel/markdown/extensions/tables/GitHubTableBlockRenderer : org/jetbrains/jewel/markdown/extensions/MarkdownBlockRendererExtension {
+ public static final field $stable I
+ public fun (Lorg/jetbrains/jewel/markdown/extensions/tables/TableStyling;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling;)V
+ public fun canRender (Lorg/jetbrains/jewel/markdown/MarkdownBlock$CustomBlock;)Z
+ public fun render (Lorg/jetbrains/jewel/markdown/MarkdownBlock$CustomBlock;Lorg/jetbrains/jewel/markdown/rendering/MarkdownBlockRenderer;Lorg/jetbrains/jewel/markdown/rendering/InlineMarkdownRenderer;Landroidx/compose/runtime/Composer;I)V
+}
+
+public final class org/jetbrains/jewel/markdown/extensions/tables/GitHubTableProcessorExtension : org/jetbrains/jewel/markdown/extensions/MarkdownProcessorExtension {
+ public static final field $stable I
+ public static final field INSTANCE Lorg/jetbrains/jewel/markdown/extensions/tables/GitHubTableProcessorExtension;
+ public fun getParserExtension ()Lorg/commonmark/parser/Parser$ParserExtension;
+ public fun getProcessorExtension ()Lorg/jetbrains/jewel/markdown/extensions/MarkdownBlockProcessorExtension;
+ public fun getTextRendererExtension ()Lorg/commonmark/renderer/text/TextContentRenderer$TextContentRendererExtension;
+}
+
+public final class org/jetbrains/jewel/markdown/extensions/tables/GitHubTableRendererExtension : org/jetbrains/jewel/markdown/extensions/MarkdownRendererExtension {
+ public static final field $stable I
+ public fun (Lorg/jetbrains/jewel/markdown/extensions/tables/TableStyling;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling;)V
+ public fun getBlockRenderer ()Lorg/jetbrains/jewel/markdown/extensions/MarkdownBlockRendererExtension;
+}
+
+public final class org/jetbrains/jewel/markdown/extensions/tables/TableStyling {
+ public static final field $stable I
+ public static final field Companion Lorg/jetbrains/jewel/markdown/extensions/tables/TableStyling$Companion;
+ public synthetic fun (JJLkotlin/jvm/internal/DefaultConstructorMarker;)V
+ public fun equals (Ljava/lang/Object;)Z
+ public final fun getBorderColor-0d7_KjU ()J
+ public final fun getHeadColor-0d7_KjU ()J
+ public fun hashCode ()I
+ public fun toString ()Ljava/lang/String;
+}
+
+public final class org/jetbrains/jewel/markdown/extensions/tables/TableStyling$Companion {
+}
+
diff --git a/markdown/extension/gfm-tables/build.gradle.kts b/markdown/extension/gfm-tables/build.gradle.kts
new file mode 100644
index 000000000..6503f2df6
--- /dev/null
+++ b/markdown/extension/gfm-tables/build.gradle.kts
@@ -0,0 +1,23 @@
+plugins {
+ jewel
+ `jewel-publish`
+ `jewel-check-public-api`
+ alias(libs.plugins.composeDesktop)
+}
+
+dependencies {
+ implementation(projects.markdown.core)
+ implementation(libs.commonmark.ext.gfm.tables)
+
+ testImplementation(compose.desktop.uiTestJUnit4)
+}
+
+publicApiValidation {
+ // TODO Oleg remove this once migrated to value classes
+ excludedClassRegexes = setOf("org.jetbrains.jewel.markdown.extensions.github.alerts.*")
+}
+
+publishing.publications.named("main") {
+ val ijpTarget = project.property("ijp.target") as String
+ artifactId = "jewel-markdown-extension-${project.name}-$ijpTarget"
+}
diff --git a/markdown/extension/gfm-tables/src/main/kotlin/org/jetbrains/jewel/markdown/extensions/tables/GitHubTableBlockRenderer.kt b/markdown/extension/gfm-tables/src/main/kotlin/org/jetbrains/jewel/markdown/extensions/tables/GitHubTableBlockRenderer.kt
new file mode 100644
index 000000000..ec203def9
--- /dev/null
+++ b/markdown/extension/gfm-tables/src/main/kotlin/org/jetbrains/jewel/markdown/extensions/tables/GitHubTableBlockRenderer.kt
@@ -0,0 +1,97 @@
+package org.jetbrains.jewel.markdown.extensions.tables
+
+import androidx.compose.foundation.background
+import androidx.compose.foundation.border
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.RowScope
+import androidx.compose.foundation.layout.fillMaxSize
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.padding
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.unit.dp
+import org.commonmark.ext.gfm.tables.TableBlock
+import org.commonmark.ext.gfm.tables.TableBody
+import org.commonmark.ext.gfm.tables.TableHead
+import org.commonmark.node.Node
+import org.jetbrains.jewel.markdown.InlineMarkdown
+import org.jetbrains.jewel.markdown.MarkdownBlock.CustomBlock
+import org.jetbrains.jewel.markdown.extensions.MarkdownBlockRendererExtension
+import org.jetbrains.jewel.markdown.rendering.InlineMarkdownRenderer
+import org.jetbrains.jewel.markdown.rendering.MarkdownBlockRenderer
+import org.jetbrains.jewel.markdown.rendering.MarkdownStyling
+import org.jetbrains.jewel.markdown.toInlineNode
+import org.jetbrains.jewel.ui.component.Text
+
+public class GitHubTableBlockRenderer(
+ private val styling: TableStyling,
+ private val rootStyling: MarkdownStyling,
+) : MarkdownBlockRendererExtension {
+
+ override fun canRender(block: CustomBlock): Boolean =
+ block is CustomBlock.DefaultCustomBlock && block.nativeBlock is TableBlock
+
+ @Composable
+ private fun RowScope.TableCell(
+ text: List,
+ inlineRenderer: InlineMarkdownRenderer,
+ ) {
+ Text(
+ text = inlineRenderer.renderAsAnnotatedString(text, rootStyling.paragraph.inlinesStyling),
+ Modifier
+ .border(1.dp, styling.borderColor)
+ .weight(1.0f)
+ .padding(8.dp),
+ )
+ }
+
+ @Composable
+ override fun render(
+ block: CustomBlock,
+ blockRenderer: MarkdownBlockRenderer,
+ inlineRenderer: InlineMarkdownRenderer,
+ ) {
+ if (block !is CustomBlock.DefaultCustomBlock) return
+
+ val head = block.nativeBlock.firstChild as TableHead
+ val body = block.nativeBlock.lastChild as TableBody
+
+ Column(Modifier.fillMaxSize().padding(16.dp)) {
+ head.forEachChild { row ->
+ Row(Modifier.background(styling.headColor)) {
+ row.forEachChild { cell ->
+ TableCell(text = cell.children().map { it.toInlineNode() }, inlineRenderer)
+ }
+ }
+ }
+ body.forEachChild { row ->
+ Row(Modifier.fillMaxWidth()) {
+ row.forEachChild { cell ->
+ TableCell(text = cell.children().map { it.toInlineNode() }, inlineRenderer)
+ }
+ }
+ }
+ }
+ }
+
+ @Composable
+ private fun Node.children(): List = buildList {
+ var child = firstChild
+
+ while (child != null) {
+ add(child)
+ child = child.next
+ }
+ }
+}
+
+@Composable
+private fun Node.forEachChild(action: @Composable (Node) -> Unit) {
+ var child = firstChild
+
+ while (child != null) {
+ action(child)
+ child = child.next
+ }
+}
diff --git a/markdown/extension/gfm-tables/src/main/kotlin/org/jetbrains/jewel/markdown/extensions/tables/GitHubTableProcessorExtension.kt b/markdown/extension/gfm-tables/src/main/kotlin/org/jetbrains/jewel/markdown/extensions/tables/GitHubTableProcessorExtension.kt
new file mode 100644
index 000000000..eb36ab896
--- /dev/null
+++ b/markdown/extension/gfm-tables/src/main/kotlin/org/jetbrains/jewel/markdown/extensions/tables/GitHubTableProcessorExtension.kt
@@ -0,0 +1,12 @@
+package org.jetbrains.jewel.markdown.extensions.tables
+
+import org.commonmark.ext.gfm.tables.TablesExtension
+import org.commonmark.parser.Parser.ParserExtension
+import org.commonmark.renderer.text.TextContentRenderer.TextContentRendererExtension
+import org.jetbrains.jewel.markdown.extensions.MarkdownProcessorExtension
+
+public object GitHubTableProcessorExtension : MarkdownProcessorExtension {
+
+ override val parserExtension: ParserExtension = TablesExtension.create() as ParserExtension
+ override val textRendererExtension: TextContentRendererExtension = TablesExtension.create() as TextContentRendererExtension
+}
diff --git a/markdown/extension/gfm-tables/src/main/kotlin/org/jetbrains/jewel/markdown/extensions/tables/GitHubTableRendererExtension.kt b/markdown/extension/gfm-tables/src/main/kotlin/org/jetbrains/jewel/markdown/extensions/tables/GitHubTableRendererExtension.kt
new file mode 100644
index 000000000..6f4ae9d6f
--- /dev/null
+++ b/markdown/extension/gfm-tables/src/main/kotlin/org/jetbrains/jewel/markdown/extensions/tables/GitHubTableRendererExtension.kt
@@ -0,0 +1,14 @@
+package org.jetbrains.jewel.markdown.extensions.tables
+
+import org.jetbrains.jewel.markdown.extensions.MarkdownBlockRendererExtension
+import org.jetbrains.jewel.markdown.extensions.MarkdownRendererExtension
+import org.jetbrains.jewel.markdown.rendering.MarkdownStyling
+
+public class GitHubTableRendererExtension(
+ alertStyling: TableStyling,
+ rootStyling: MarkdownStyling,
+) : MarkdownRendererExtension {
+
+ override val blockRenderer: MarkdownBlockRendererExtension =
+ GitHubTableBlockRenderer(alertStyling, rootStyling)
+}
diff --git a/markdown/extension/gfm-tables/src/main/kotlin/org/jetbrains/jewel/markdown/extensions/tables/TableStyling.kt b/markdown/extension/gfm-tables/src/main/kotlin/org/jetbrains/jewel/markdown/extensions/tables/TableStyling.kt
new file mode 100644
index 000000000..0ef64ef57
--- /dev/null
+++ b/markdown/extension/gfm-tables/src/main/kotlin/org/jetbrains/jewel/markdown/extensions/tables/TableStyling.kt
@@ -0,0 +1,13 @@
+package org.jetbrains.jewel.markdown.extensions.tables
+
+import androidx.compose.ui.graphics.Color
+import org.jetbrains.jewel.foundation.GenerateDataFunctions
+
+@GenerateDataFunctions
+public class TableStyling(
+ public val headColor: Color,
+ public val borderColor: Color,
+) {
+
+ public companion object
+}
diff --git a/markdown/int-ui-standalone-styling/api/int-ui-standalone-styling.api b/markdown/int-ui-standalone-styling/api/int-ui-standalone-styling.api
index c70cd0973..8eafd826f 100644
--- a/markdown/int-ui-standalone-styling/api/int-ui-standalone-styling.api
+++ b/markdown/int-ui-standalone-styling/api/int-ui-standalone-styling.api
@@ -113,3 +113,10 @@ public final class org/jetbrains/jewel/intui/markdown/styling/extension/github/a
public static synthetic fun light-gaOEZmc$default (Lorg/jetbrains/jewel/markdown/extensions/github/alerts/WarningAlertStyling$Companion;Landroidx/compose/foundation/layout/PaddingValues;FJLandroidx/compose/ui/graphics/PathEffect;ILandroidx/compose/ui/text/TextStyle;Ljava/lang/String;JJILjava/lang/Object;)Lorg/jetbrains/jewel/markdown/extensions/github/alerts/WarningAlertStyling;
}
+public final class org/jetbrains/jewel/intui/markdown/styling/extension/github/alerts/GitHubTableDefaultStylingKt {
+ public static final fun dark-WkMS-hQ (Lorg/jetbrains/jewel/markdown/extensions/tables/TableStyling$Companion;JJ)Lorg/jetbrains/jewel/markdown/extensions/tables/TableStyling;
+ public static synthetic fun dark-WkMS-hQ$default (Lorg/jetbrains/jewel/markdown/extensions/tables/TableStyling$Companion;JJILjava/lang/Object;)Lorg/jetbrains/jewel/markdown/extensions/tables/TableStyling;
+ public static final fun light-WkMS-hQ (Lorg/jetbrains/jewel/markdown/extensions/tables/TableStyling$Companion;JJ)Lorg/jetbrains/jewel/markdown/extensions/tables/TableStyling;
+ public static synthetic fun light-WkMS-hQ$default (Lorg/jetbrains/jewel/markdown/extensions/tables/TableStyling$Companion;JJILjava/lang/Object;)Lorg/jetbrains/jewel/markdown/extensions/tables/TableStyling;
+}
+
diff --git a/markdown/int-ui-standalone-styling/build.gradle.kts b/markdown/int-ui-standalone-styling/build.gradle.kts
index 57a0ae2ae..17dbdb446 100644
--- a/markdown/int-ui-standalone-styling/build.gradle.kts
+++ b/markdown/int-ui-standalone-styling/build.gradle.kts
@@ -9,6 +9,7 @@ dependencies {
api(projects.markdown.core)
api(projects.intUi.intUiStandalone)
compileOnly(projects.markdown.extension.gfmAlerts)
+ compileOnly(projects.markdown.extension.gfmTables)
testImplementation(compose.desktop.uiTestJUnit4)
}
diff --git a/markdown/int-ui-standalone-styling/src/main/kotlin/org/jetbrains/jewel/intui/markdown/styling/extension/github/alerts/GitHubTableDefaultStyling.kt b/markdown/int-ui-standalone-styling/src/main/kotlin/org/jetbrains/jewel/intui/markdown/styling/extension/github/alerts/GitHubTableDefaultStyling.kt
new file mode 100644
index 000000000..d32fd8dbd
--- /dev/null
+++ b/markdown/int-ui-standalone-styling/src/main/kotlin/org/jetbrains/jewel/intui/markdown/styling/extension/github/alerts/GitHubTableDefaultStyling.kt
@@ -0,0 +1,20 @@
+package org.jetbrains.jewel.intui.markdown.styling.extension.github.alerts
+
+import androidx.compose.ui.graphics.Color
+import org.jetbrains.jewel.markdown.extensions.tables.TableStyling
+
+public fun TableStyling.Companion.dark(
+ headColor: Color = Color.DarkGray,
+ borderColor: Color = Color.Gray,
+): TableStyling = TableStyling(
+ headColor,
+ borderColor,
+)
+
+public fun TableStyling.Companion.light(
+ headColor: Color = Color.LightGray,
+ borderColor: Color = Color.Gray,
+): TableStyling = TableStyling(
+ headColor,
+ borderColor,
+)
diff --git a/samples/standalone/build.gradle.kts b/samples/standalone/build.gradle.kts
index 2d8714780..c3028a4b9 100644
--- a/samples/standalone/build.gradle.kts
+++ b/samples/standalone/build.gradle.kts
@@ -13,8 +13,10 @@ dependencies {
implementation(projects.intUi.intUiStandalone)
implementation(projects.intUi.intUiDecoratedWindow)
implementation(projects.markdown.intUiStandaloneStyling)
- implementation(projects.markdown.extension.gfmAlerts)
implementation(projects.markdown.extension.autolink)
+ implementation(projects.markdown.extension.gfmAlerts)
+ implementation(projects.markdown.extension.gfmTables)
+
implementation(compose.desktop.currentOs) {
exclude(group = "org.jetbrains.compose.material")
}
diff --git a/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/view/markdown/MarkdownPreview.kt b/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/view/markdown/MarkdownPreview.kt
index f3f6aba6e..8c5dccafc 100644
--- a/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/view/markdown/MarkdownPreview.kt
+++ b/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/view/markdown/MarkdownPreview.kt
@@ -35,6 +35,9 @@ import org.jetbrains.jewel.markdown.extension.autolink.AutolinkProcessorExtensio
import org.jetbrains.jewel.markdown.extensions.github.alerts.AlertStyling
import org.jetbrains.jewel.markdown.extensions.github.alerts.GitHubAlertProcessorExtension
import org.jetbrains.jewel.markdown.extensions.github.alerts.GitHubAlertRendererExtension
+import org.jetbrains.jewel.markdown.extensions.tables.GitHubTableProcessorExtension
+import org.jetbrains.jewel.markdown.extensions.tables.GitHubTableRendererExtension
+import org.jetbrains.jewel.markdown.extensions.tables.TableStyling
import org.jetbrains.jewel.markdown.processing.MarkdownProcessor
import org.jetbrains.jewel.markdown.rendering.InlineMarkdownRenderer
import org.jetbrains.jewel.markdown.rendering.MarkdownBlockRenderer
@@ -54,7 +57,7 @@ internal fun MarkdownPreview(
remember(isDark) { if (isDark) MarkdownStyling.dark() else MarkdownStyling.light() }
var markdownBlocks by remember { mutableStateOf(emptyList()) }
- val extensions = listOf(GitHubAlertProcessorExtension, AutolinkProcessorExtension)
+ val extensions = listOf(GitHubAlertProcessorExtension, GitHubTableProcessorExtension, AutolinkProcessorExtension)
val processor = remember { MarkdownProcessor(extensions) }
LaunchedEffect(rawMarkdown) {
@@ -69,7 +72,10 @@ internal fun MarkdownPreview(
if (isDark) {
MarkdownBlockRenderer.dark(
styling = markdownStyling,
- rendererExtensions = listOf(GitHubAlertRendererExtension(AlertStyling.dark(), markdownStyling)),
+ rendererExtensions = listOf(
+ GitHubAlertRendererExtension(AlertStyling.dark(), markdownStyling),
+ GitHubTableRendererExtension(TableStyling.dark(), markdownStyling),
+ ),
inlineRenderer = InlineMarkdownRenderer.default(extensions),
) { url ->
Desktop.getDesktop().browse(URI.create(url))
@@ -77,7 +83,10 @@ internal fun MarkdownPreview(
} else {
MarkdownBlockRenderer.light(
styling = markdownStyling,
- rendererExtensions = listOf(GitHubAlertRendererExtension(AlertStyling.light(), markdownStyling)),
+ rendererExtensions = listOf(
+ GitHubAlertRendererExtension(AlertStyling.light(), markdownStyling),
+ GitHubTableRendererExtension(TableStyling.light(), markdownStyling),
+ ),
inlineRenderer = InlineMarkdownRenderer.default(extensions),
) { url ->
Desktop.getDesktop().browse(URI.create(url))
diff --git a/settings.gradle.kts b/settings.gradle.kts
index 69a2b6a3e..b68810659 100644
--- a/settings.gradle.kts
+++ b/settings.gradle.kts
@@ -38,6 +38,7 @@ include(
":markdown:core",
":markdown:extension:autolink",
":markdown:extension:gfm-alerts",
+ ":markdown:extension:gfm-tables",
":markdown:int-ui-standalone-styling",
":markdown:ide-laf-bridge-styling",
":samples:ide-plugin",