[JEWEL-748] Define delimited inlines extension API, implement strikethrough

This includes a bunch of changes to the Markdown inline APIs to better align with CommonMark and our actual needs; a clean-up of the previous half-hearted attempt at supporting custom inline nodes (it did not and could never have worked in the way it was implemented), and some misc tweaks and cleanup.

closes https://github.com/JetBrains/intellij-community/pull/2915

(cherry picked from commit 70ef3e792dc4f64fd4d2afc6aa02f8c190203443)


(cherry picked from commit 606d5a2004d373e961229af09b367f0ccf2ceae4)

IJ-MR-155570

GitOrigin-RevId: 793138291f4f0c131949c08d0bfa037f843335d3
This commit is contained in:
Sebastiano Poggi
2025-02-10 17:32:32 +00:00
committed by intellij-monorepo-bot
parent 962a5a2046
commit eea1240eca
44 changed files with 1020 additions and 307 deletions

1
.idea/modules.xml generated
View File

@@ -721,6 +721,7 @@
<module fileurl="file://$PROJECT_DIR$/platform/jewel/markdown/core/intellij.platform.jewel.markdown.core.iml" filepath="$PROJECT_DIR$/platform/jewel/markdown/core/intellij.platform.jewel.markdown.core.iml" />
<module fileurl="file://$PROJECT_DIR$/platform/jewel/markdown/extension/autolink/intellij.platform.jewel.markdown.extension.autolink.iml" filepath="$PROJECT_DIR$/platform/jewel/markdown/extension/autolink/intellij.platform.jewel.markdown.extension.autolink.iml" />
<module fileurl="file://$PROJECT_DIR$/platform/jewel/markdown/extension/gfm-alerts/intellij.platform.jewel.markdown.extension.gfmAlerts.iml" filepath="$PROJECT_DIR$/platform/jewel/markdown/extension/gfm-alerts/intellij.platform.jewel.markdown.extension.gfmAlerts.iml" />
<module fileurl="file://$PROJECT_DIR$/platform/jewel/markdown/extension/gfm-strikethrough/intellij.platform.jewel.markdown.extension.gfmStrikethrough.iml" filepath="$PROJECT_DIR$/platform/jewel/markdown/extension/gfm-strikethrough/intellij.platform.jewel.markdown.extension.gfmStrikethrough.iml" />
<module fileurl="file://$PROJECT_DIR$/platform/jewel/markdown/extension/gfm-tables/intellij.platform.jewel.markdown.extension.gfmTables.iml" filepath="$PROJECT_DIR$/platform/jewel/markdown/extension/gfm-tables/intellij.platform.jewel.markdown.extension.gfmTables.iml" />
<module fileurl="file://$PROJECT_DIR$/platform/jewel/markdown/ide-laf-bridge-styling/intellij.platform.jewel.markdown.ideLafBridgeStyling.iml" filepath="$PROJECT_DIR$/platform/jewel/markdown/ide-laf-bridge-styling/intellij.platform.jewel.markdown.ideLafBridgeStyling.iml" />
<module fileurl="file://$PROJECT_DIR$/platform/jewel/markdown/int-ui-standalone-styling/intellij.platform.jewel.markdown.intUiStandaloneStyling.iml" filepath="$PROJECT_DIR$/platform/jewel/markdown/int-ui-standalone-styling/intellij.platform.jewel.markdown.intUiStandaloneStyling.iml" />

View File

@@ -17,6 +17,7 @@ import androidx.compose.ui.unit.Constraints
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import kotlin.math.max
import org.jetbrains.jewel.foundation.modifier.thenIf
/**
* A simple table that sizes columns to take as much room as they need. If the horizontal space available is less than
@@ -34,7 +35,7 @@ import kotlin.math.max
* @param rowCount The number of rows this table has.
* @param columnCount The number of columns this table has.
* @param cellBorderColor The color of the cell borders. Set to [Color.Unspecified] to avoid drawing the borders — in
* which case, the [cellBorderWidth] acts as padding.
* which case, the [cellBorderWidth] acts as a padding.
* @param modifier Modifier to apply to the table.
* @param cellBorderWidth The width of the table's borders.
* @param rows The rows that make up the table. Each row is a list of composables, one per row cell.
@@ -214,7 +215,3 @@ private fun Modifier.drawTableBorders(
)
}
}
// TODO remove this once thenIf is moved to foundation
private inline fun Modifier.thenIf(precondition: Boolean, action: Modifier.() -> Modifier): Modifier =
if (precondition) action() else this

View File

@@ -18,6 +18,7 @@ ktfmtGradlePlugin = "0.20.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-strikethrough = { module = "org.commonmark:commonmark-ext-gfm-strikethrough", 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" }

View File

@@ -14,12 +14,12 @@ Additional supported Markdown, via extensions:
* Autolink (standard CommonMark, but provided as extension) — see [`extension-autolink`](extension/autolink)
* Tables ([GitHub Flavored Markdown](https://github.github.com/gfm/#tables-extension-)) — see [
`extension-gfm-tables`](extension/gfm-tables)
* Strikethrough ([GitHub Flavored Markdown](https://github.github.com/gfm/#strikethrough-extension-))
[alerts-specs]: https://github.com/orgs/community/discussions/16925
On the roadmap, but not currently supported — in no particular order:
* Strikethrough ([GitHub Flavored Markdown](https://github.github.com/gfm/#strikethrough-extension-))
* Image loading (via [Coil 3](https://coil-kt.github.io/coil/upgrading_to_coil3/))
* Task list items ([GitHub Flavored Markdown](https://github.github.com/gfm/#task-list-items-extension-))
* Keyboard shortcuts highlighting (specialized HTML handling)
@@ -159,4 +159,4 @@ You can see this in action running the Standalone sample, and selecting Markdown
The following image shows the Jewel Markdown renderer displaying the Jewel readme.
![Image showing the Markdown renderer page from the Jewel standalone sample](../art/docs/markdown-renderer.png)
![Image showing the Markdown renderer page from the Jewel standalone sample](../art/docs/markdown-renderer.png)

View File

@@ -10,12 +10,13 @@ public final class org/jetbrains/jewel/markdown/InlineMarkdown$Code : org/jetbra
public fun toString ()Ljava/lang/String;
}
public abstract interface class org/jetbrains/jewel/markdown/InlineMarkdown$CustomNode : org/jetbrains/jewel/markdown/InlineMarkdown {
public abstract fun contentOrNull ()Ljava/lang/String;
public abstract interface class org/jetbrains/jewel/markdown/InlineMarkdown$CustomDelimitedNode : org/jetbrains/jewel/markdown/InlineMarkdown, org/jetbrains/jewel/markdown/WithInlineMarkdown {
public abstract fun getClosingDelimiter ()Ljava/lang/String;
public abstract fun getOpeningDelimiter ()Ljava/lang/String;
}
public final class org/jetbrains/jewel/markdown/InlineMarkdown$CustomNode$DefaultImpls {
public static fun contentOrNull (Lorg/jetbrains/jewel/markdown/InlineMarkdown$CustomNode;)Ljava/lang/String;
public final class org/jetbrains/jewel/markdown/InlineMarkdown$CustomDelimitedNode$DefaultImpls {
public static fun getClosingDelimiter (Lorg/jetbrains/jewel/markdown/InlineMarkdown$CustomDelimitedNode;)Ljava/lang/String;
}
public final class org/jetbrains/jewel/markdown/InlineMarkdown$Emphasis : org/jetbrains/jewel/markdown/InlineMarkdown, org/jetbrains/jewel/markdown/WithInlineMarkdown {
@@ -264,14 +265,14 @@ public abstract interface class org/jetbrains/jewel/markdown/extensions/Markdown
public abstract fun render (Lorg/jetbrains/jewel/markdown/MarkdownBlock$CustomBlock;Lorg/jetbrains/jewel/markdown/rendering/MarkdownBlockRenderer;Lorg/jetbrains/jewel/markdown/rendering/InlineMarkdownRenderer;ZLkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function0;Landroidx/compose/runtime/Composer;I)V
}
public abstract interface class org/jetbrains/jewel/markdown/extensions/MarkdownInlineProcessorExtension {
public abstract fun canProcess (Lorg/commonmark/node/CustomNode;)Z
public abstract fun processInlineMarkdown (Lorg/commonmark/node/CustomNode;Lorg/jetbrains/jewel/markdown/processing/MarkdownProcessor;)Lorg/jetbrains/jewel/markdown/InlineMarkdown$CustomNode;
public abstract interface class org/jetbrains/jewel/markdown/extensions/MarkdownDelimitedInlineProcessorExtension {
public abstract fun canProcess (Lorg/commonmark/node/Delimited;)Z
public abstract fun processDelimitedInline (Lorg/commonmark/node/Delimited;Lorg/jetbrains/jewel/markdown/processing/MarkdownProcessor;)Lorg/jetbrains/jewel/markdown/InlineMarkdown$CustomDelimitedNode;
}
public abstract interface class org/jetbrains/jewel/markdown/extensions/MarkdownInlineRendererExtension {
public abstract fun canRender (Lorg/jetbrains/jewel/markdown/InlineMarkdown$CustomNode;)Z
public abstract fun render (Lorg/jetbrains/jewel/markdown/InlineMarkdown$CustomNode;Lorg/jetbrains/jewel/markdown/rendering/InlineMarkdownRenderer;Z)V
public abstract interface class org/jetbrains/jewel/markdown/extensions/MarkdownDelimitedInlineRendererExtension {
public abstract fun canRender (Lorg/jetbrains/jewel/markdown/InlineMarkdown$CustomDelimitedNode;)Z
public abstract fun render (Lorg/jetbrains/jewel/markdown/InlineMarkdown$CustomDelimitedNode;Lorg/jetbrains/jewel/markdown/rendering/InlineMarkdownRenderer;Lorg/jetbrains/jewel/markdown/rendering/InlinesStyling;ZLkotlin/jvm/functions/Function1;)Landroidx/compose/ui/text/AnnotatedString;
}
public final class org/jetbrains/jewel/markdown/extensions/MarkdownKt {
@@ -287,26 +288,26 @@ public final class org/jetbrains/jewel/markdown/extensions/MarkdownKt {
public abstract interface class org/jetbrains/jewel/markdown/extensions/MarkdownProcessorExtension {
public abstract fun getBlockProcessorExtension ()Lorg/jetbrains/jewel/markdown/extensions/MarkdownBlockProcessorExtension;
public abstract fun getInlineProcessorExtension ()Lorg/jetbrains/jewel/markdown/extensions/MarkdownInlineProcessorExtension;
public abstract fun getDelimitedInlineProcessorExtension ()Lorg/jetbrains/jewel/markdown/extensions/MarkdownDelimitedInlineProcessorExtension;
public abstract fun getParserExtension ()Lorg/commonmark/parser/Parser$ParserExtension;
public abstract fun getTextRendererExtension ()Lorg/commonmark/renderer/text/TextContentRenderer$TextContentRendererExtension;
}
public final class org/jetbrains/jewel/markdown/extensions/MarkdownProcessorExtension$DefaultImpls {
public static fun getBlockProcessorExtension (Lorg/jetbrains/jewel/markdown/extensions/MarkdownProcessorExtension;)Lorg/jetbrains/jewel/markdown/extensions/MarkdownBlockProcessorExtension;
public static fun getInlineProcessorExtension (Lorg/jetbrains/jewel/markdown/extensions/MarkdownProcessorExtension;)Lorg/jetbrains/jewel/markdown/extensions/MarkdownInlineProcessorExtension;
public static fun getDelimitedInlineProcessorExtension (Lorg/jetbrains/jewel/markdown/extensions/MarkdownProcessorExtension;)Lorg/jetbrains/jewel/markdown/extensions/MarkdownDelimitedInlineProcessorExtension;
public static fun getParserExtension (Lorg/jetbrains/jewel/markdown/extensions/MarkdownProcessorExtension;)Lorg/commonmark/parser/Parser$ParserExtension;
public static fun getTextRendererExtension (Lorg/jetbrains/jewel/markdown/extensions/MarkdownProcessorExtension;)Lorg/commonmark/renderer/text/TextContentRenderer$TextContentRendererExtension;
}
public abstract interface class org/jetbrains/jewel/markdown/extensions/MarkdownRendererExtension {
public abstract fun getBlockRenderer ()Lorg/jetbrains/jewel/markdown/extensions/MarkdownBlockRendererExtension;
public abstract fun getInlineRenderer ()Lorg/jetbrains/jewel/markdown/extensions/MarkdownInlineRendererExtension;
public abstract fun getDelimitedInlineRenderer ()Lorg/jetbrains/jewel/markdown/extensions/MarkdownDelimitedInlineRendererExtension;
}
public final class org/jetbrains/jewel/markdown/extensions/MarkdownRendererExtension$DefaultImpls {
public static fun getBlockRenderer (Lorg/jetbrains/jewel/markdown/extensions/MarkdownRendererExtension;)Lorg/jetbrains/jewel/markdown/extensions/MarkdownBlockRendererExtension;
public static fun getInlineRenderer (Lorg/jetbrains/jewel/markdown/extensions/MarkdownRendererExtension;)Lorg/jetbrains/jewel/markdown/extensions/MarkdownInlineRendererExtension;
public static fun getDelimitedInlineRenderer (Lorg/jetbrains/jewel/markdown/extensions/MarkdownRendererExtension;)Lorg/jetbrains/jewel/markdown/extensions/MarkdownDelimitedInlineRendererExtension;
}
public final class org/jetbrains/jewel/markdown/processing/MarkdownParserFactory {
@@ -321,26 +322,27 @@ public final class org/jetbrains/jewel/markdown/processing/MarkdownProcessor {
public fun <init> ()V
public fun <init> (Ljava/util/List;Lorg/jetbrains/jewel/markdown/MarkdownMode;Lorg/commonmark/parser/Parser;)V
public synthetic fun <init> (Ljava/util/List;Lorg/jetbrains/jewel/markdown/MarkdownMode;Lorg/commonmark/parser/Parser;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun getBlockExtensions ()Ljava/util/List;
public final fun getDelimitedInlineExtensions ()Ljava/util/List;
public final fun getExtensions ()Ljava/util/List;
public final fun plus (Lorg/jetbrains/jewel/markdown/extensions/MarkdownProcessorExtension;)Lorg/jetbrains/jewel/markdown/processing/MarkdownProcessor;
public final fun processChildren (Lorg/commonmark/node/Node;)Ljava/util/List;
public final fun processMarkdownDocument (Ljava/lang/String;)Ljava/util/List;
public final fun withExtension (Lorg/jetbrains/jewel/markdown/extensions/MarkdownProcessorExtension;)Lorg/jetbrains/jewel/markdown/processing/MarkdownProcessor;
}
public final class org/jetbrains/jewel/markdown/processing/ProcessingUtilKt {
public static final fun readInlineContent (Lorg/commonmark/node/Node;Lorg/jetbrains/jewel/markdown/processing/MarkdownProcessor;)Ljava/util/List;
public static final fun readInlineMarkdown (Lorg/commonmark/node/Node;Lorg/jetbrains/jewel/markdown/processing/MarkdownProcessor;)Ljava/util/List;
public static final fun toInlineMarkdownOrNull (Lorg/commonmark/node/Node;Lorg/jetbrains/jewel/markdown/processing/MarkdownProcessor;)Lorg/jetbrains/jewel/markdown/InlineMarkdown;
}
public class org/jetbrains/jewel/markdown/rendering/DefaultInlineMarkdownRenderer : org/jetbrains/jewel/markdown/rendering/InlineMarkdownRenderer {
public static final field $stable I
public static final field Companion Lorg/jetbrains/jewel/markdown/rendering/DefaultInlineMarkdownRenderer$Companion;
public fun <init> (Ljava/util/List;)V
protected final fun getDelimitedNodeRendererExtensions ()Ljava/util/List;
public fun renderAsAnnotatedString (Ljava/lang/Iterable;Lorg/jetbrains/jewel/markdown/rendering/InlinesStyling;ZLkotlin/jvm/functions/Function1;)Landroidx/compose/ui/text/AnnotatedString;
}
public final class org/jetbrains/jewel/markdown/rendering/DefaultInlineMarkdownRenderer$Companion {
}
public class org/jetbrains/jewel/markdown/rendering/DefaultMarkdownBlockRenderer : org/jetbrains/jewel/markdown/rendering/MarkdownBlockRenderer {
public static final field $stable I
public fun <init> (Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling;Ljava/util/List;Lorg/jetbrains/jewel/markdown/rendering/InlineMarkdownRenderer;)V
@@ -438,6 +440,7 @@ public final class org/jetbrains/jewel/markdown/rendering/MarkdownStyling {
public static final field Companion Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Companion;
public synthetic fun <init> (FLorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Paragraph;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Heading;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$BlockQuote;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Code;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$List;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Image;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$ThematicBreak;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$HtmlBlock;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
public fun equals (Ljava/lang/Object;)Z
public final fun getBaseInlinesStyling ()Lorg/jetbrains/jewel/markdown/rendering/InlinesStyling;
public final fun getBlockQuote ()Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$BlockQuote;
public final fun getBlockVerticalSpacing-D9Ej5fM ()F
public final fun getCode ()Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Code;

View File

@@ -2,7 +2,10 @@ package org.jetbrains.jewel.markdown
import org.jetbrains.jewel.foundation.GenerateDataFunctions
/** A run of inline Markdown used as content for [block-level elements][MarkdownBlock]. */
/**
* An inline Markdown node, usually found as content for [block-level elements][MarkdownBlock] or other inline nodes
* annotated with the [WithInlineMarkdown] interface.
*/
public sealed interface InlineMarkdown {
@GenerateDataFunctions
public class Code(override val content: String) : InlineMarkdown, WithTextContent {
@@ -20,12 +23,26 @@ public sealed interface InlineMarkdown {
override fun toString(): String = "Code(content='$content')"
}
public interface CustomNode : InlineMarkdown {
/**
* An inline node that is delimited by a fixed delimiter, and can be rendered directly into an
* [androidx.compose.ui.text.AnnotatedString].
*
* This type of node can be parsed by a
* [org.jetbrains.jewel.markdown.extensions.MarkdownDelimitedInlineProcessorExtension] and rendered by a
* [org.jetbrains.jewel.markdown.extensions.MarkdownDelimitedInlineRendererExtension].
*/
public interface CustomDelimitedNode : InlineMarkdown, WithInlineMarkdown {
/**
* If this custom node has a text-based representation, this function should return it. Otherwise, it should
* return null.
* The string used to indicate the beginning of this type of inline node. Can be identical to the
* [closingDelimiter].
*/
public fun contentOrNull(): String? = null
public val openingDelimiter: String
/**
* The string used to indicate the end of this type of inline node. Can be identical to the [openingDelimiter].
*/
public val closingDelimiter: String
get() = openingDelimiter
}
@GenerateDataFunctions

View File

@@ -1,5 +1,7 @@
package org.jetbrains.jewel.markdown
/** An inline Markdown node that contains other [InlineMarkdown] nodes. */
public interface WithInlineMarkdown {
/** Child inline Markdown nodes. */
public val inlineContent: List<InlineMarkdown>
}

View File

@@ -1,5 +1,7 @@
package org.jetbrains.jewel.markdown
/** An inline Markdown node that has a plain text content, or can be rendered as plain text. */
public interface WithTextContent {
/** The plain text content or representation of this node. */
public val content: String
}

View File

@@ -4,11 +4,13 @@ import org.commonmark.node.CustomBlock
import org.jetbrains.jewel.markdown.MarkdownBlock
import org.jetbrains.jewel.markdown.processing.MarkdownProcessor
/** Extension that can process a custom block-level [CustomBlock]. */
public interface MarkdownBlockProcessorExtension {
/**
* Returns true if the [block] can be processed by this extension instance.
*
* @param block The [CustomBlock] to parse
* @return True if this extension can process the provided [CustomBlock], false otherwise.
*/
public fun canProcess(block: CustomBlock): Boolean
@@ -16,6 +18,10 @@ public interface MarkdownBlockProcessorExtension {
* Processes the [block] as a [MarkdownBlock.CustomBlock], if possible. Note that you should always check that
* [canProcess] returns true for the same [block], as implementations might throw an exception for unsupported block
* types.
*
* @param block The [CustomBlock] to process, for which this extension's [canProcess] returned true.
* @param processor The [MarkdownProcessor] to use for processing.
* @return null if the processing fails, otherwise the processed [MarkdownBlock.CustomBlock].
*/
public fun processMarkdownBlock(block: CustomBlock, processor: MarkdownProcessor): MarkdownBlock.CustomBlock?
}

View File

@@ -0,0 +1,23 @@
package org.jetbrains.jewel.markdown.extensions
import org.commonmark.node.Delimited
import org.jetbrains.jewel.markdown.InlineMarkdown
import org.jetbrains.jewel.markdown.processing.MarkdownProcessor
/** An extension for parsing [org.commonmark.node.Delimited] inline nodes. */
public interface MarkdownDelimitedInlineProcessorExtension {
/** Checks whether the [delimited] can be processed by this instance. */
public fun canProcess(delimited: Delimited): Boolean
/**
* Processes a [delimited] for which [canProcess] returned `true` into a [InlineMarkdown.CustomDelimitedNode].
*
* @param delimited A [Delimited] produced by a [MarkdownProcessor].
* @param markdownProcessor The [MarkdownProcessor] to use to parse this [Delimited].
* @return The [InlineMarkdown.CustomDelimitedNode] obtained from [delimited].
*/
public fun processDelimitedInline(
delimited: Delimited,
markdownProcessor: MarkdownProcessor,
): InlineMarkdown.CustomDelimitedNode
}

View File

@@ -0,0 +1,41 @@
package org.jetbrains.jewel.markdown.extensions
import androidx.compose.ui.text.AnnotatedString
import org.jetbrains.jewel.markdown.InlineMarkdown
import org.jetbrains.jewel.markdown.InlineMarkdown.CustomDelimitedNode
import org.jetbrains.jewel.markdown.rendering.InlineMarkdownRenderer
import org.jetbrains.jewel.markdown.rendering.InlinesStyling
/**
* An extension for [InlineMarkdownRenderer] that can render [InlineMarkdown.CustomDelimitedNode]s backed by a
* [org.commonmark.node.Delimited] node.
*
* Only `Delimited` nodes that can be rendered as an [AnnotatedString] are supported; other kinds of inline node aren't.
*/
public interface MarkdownDelimitedInlineRendererExtension {
/**
* Check whether the provided [node] node can be rendered by this extension.
*
* @param node The [CustomDelimitedNode] to check.
* @return True if this instance can render [node], false otherwise.
*/
public fun canRender(node: CustomDelimitedNode): Boolean
/**
* Render a [CustomDelimitedNode] into an [AnnotatedString.Builder]. Note that if [canRender] returns `false` for
* [node], the implementation might throw.
*
* @param node The [CustomDelimitedNode] to render.
* @param inlineRenderer The [InlineMarkdownRenderer] to use to render the node and its content.
* @param inlinesStyling The styling to use to render the node and its content.
* @param enabled When false, the node will be rendered with a disabled appearance (e.g., grayed out).
* @param onUrlClicked Lambda that will be invoked when URLs inside this node are clicked.
*/
public fun render(
node: CustomDelimitedNode,
inlineRenderer: InlineMarkdownRenderer,
inlinesStyling: InlinesStyling,
enabled: Boolean,
onUrlClicked: ((String) -> Unit)?,
): AnnotatedString
}

View File

@@ -1,21 +0,0 @@
package org.jetbrains.jewel.markdown.extensions
import org.commonmark.node.CustomNode
import org.jetbrains.jewel.markdown.InlineMarkdown
import org.jetbrains.jewel.markdown.processing.MarkdownProcessor
public interface MarkdownInlineProcessorExtension {
/**
* Returns true if the [node] can be processed by this extension instance.
*
* @param node The [CustomNode] to parse
*/
public fun canProcess(node: CustomNode): Boolean
/**
* Processes the [node] as a [InlineMarkdown.CustomNode], if possible. Note that you should always check that
* [canProcess] returns true for the same [node], as implementations might throw an exception for unsupported node
* types.
*/
public fun processInlineMarkdown(node: CustomNode, processor: MarkdownProcessor): InlineMarkdown.CustomNode?
}

View File

@@ -1,17 +0,0 @@
package org.jetbrains.jewel.markdown.extensions
import org.jetbrains.jewel.markdown.InlineMarkdown
import org.jetbrains.jewel.markdown.InlineMarkdown.CustomNode
import org.jetbrains.jewel.markdown.rendering.InlineMarkdownRenderer
/** An extension for [InlineMarkdownRenderer] that can render one or more [InlineMarkdown.CustomNode]s. */
public interface MarkdownInlineRendererExtension {
/** Check whether the provided [inline] can be rendered by this extension. */
public fun canRender(inline: CustomNode): Boolean
/**
* Render a [CustomNode] as an annotated string. Note that if [canRender] returns `false` for [inline], the
* implementation might throw.
*/
public fun render(inline: CustomNode, inlineRenderer: InlineMarkdownRenderer, enabled: Boolean)
}

View File

@@ -11,7 +11,7 @@ public interface MarkdownProcessorExtension {
* A CommonMark [ParserExtension] that will be used to parse the extended syntax represented by this extension
* instance.
*
* Can be null if all required processing is already handled by an existing [org.commonmark.parser.Parser].
* Can be null if all required parsing is already handled by an existing [org.commonmark.parser.Parser].
*/
public val parserExtension: ParserExtension?
get() = null
@@ -38,14 +38,11 @@ public interface MarkdownProcessorExtension {
get() = null
/**
* An extension for [`MarkdownProcessor`][org.jetbrains.jewel.markdown.processing.MarkdownProcessor] that will
* transform a supported [org.commonmark.node.CustomNode] into the corresponding
* [org.jetbrains.jewel.markdown.InlineMarkdown.CustomNode].
* A [MarkdownDelimitedInlineProcessorExtension] that will transform a supported [org.commonmark.node.Delimited]
* inline node into the corresponding [org.jetbrains.jewel.markdown.InlineMarkdown.CustomDelimitedNode].
*
* Can be null if all required processing is already handled by
* [org.jetbrains.jewel.markdown.processing.MarkdownProcessor] or another
* [org.jetbrains.jewel.markdown.extensions.MarkdownProcessorExtension].
* Can be null if this extension does not handle custom delimited inline nodes.
*/
public val inlineProcessorExtension: MarkdownInlineProcessorExtension?
public val delimitedInlineProcessorExtension: MarkdownDelimitedInlineProcessorExtension?
get() = null
}

View File

@@ -17,11 +17,11 @@ public interface MarkdownRendererExtension {
/**
* An extension for [`InlineMarkdownRenderer`][org.jetbrains.jewel.markdown.rendering.InlineMarkdownRenderer] that
* will render a supported [`CustomNode`][org.jetbrains.jewel.markdown.InlineMarkdown.CustomNode] into an annotated
* will render supported [org.jetbrains.jewel.markdown.InlineMarkdown.CustomDelimitedNode]s into an annotated
* string.
*
* Can be null if this extension doesn't support rendering inline nodes.
* Can be null if this extension doesn't support rendering delimited inline nodes.
*/
public val inlineRenderer: MarkdownInlineRendererExtension?
public val delimitedInlineRenderer: MarkdownDelimitedInlineRendererExtension?
get() = null
}

View File

@@ -28,6 +28,8 @@ import org.jetbrains.jewel.markdown.MarkdownBlock
import org.jetbrains.jewel.markdown.MarkdownBlock.CodeBlock
import org.jetbrains.jewel.markdown.MarkdownBlock.ListBlock
import org.jetbrains.jewel.markdown.MarkdownMode
import org.jetbrains.jewel.markdown.extensions.MarkdownBlockProcessorExtension
import org.jetbrains.jewel.markdown.extensions.MarkdownDelimitedInlineProcessorExtension
import org.jetbrains.jewel.markdown.extensions.MarkdownProcessorExtension
import org.jetbrains.jewel.markdown.rendering.DefaultInlineMarkdownRenderer
import org.jetbrains.jewel.markdown.scrolling.ScrollingSynchronizer
@@ -59,8 +61,19 @@ public class MarkdownProcessor(
public val extensions: List<MarkdownProcessorExtension> = emptyList(),
private val markdownMode: MarkdownMode = MarkdownMode.Standalone,
private val commonMarkParser: Parser =
MarkdownParserFactory.create(markdownMode is MarkdownMode.EditorPreview, extensions),
MarkdownParserFactory.create(optimizeEdits = markdownMode is MarkdownMode.EditorPreview, extensions),
) {
/** The [block-level processor extensions][MarkdownBlockProcessorExtension]s used by this processor. */
public val blockExtensions: List<MarkdownBlockProcessorExtension> =
extensions.mapNotNull { it.blockProcessorExtension }
/**
* The [delimited inline node processor extensions][MarkdownDelimitedInlineProcessorExtension]s used by this
* processor.
*/
public val delimitedInlineExtensions: List<MarkdownDelimitedInlineProcessorExtension> =
extensions.mapNotNull { it.delimitedInlineProcessorExtension }
private var currentState = State(emptyList(), emptyList(), emptyList())
@TestOnly internal fun getCurrentIndexesInTest() = currentState.indexes
@@ -248,10 +261,7 @@ public class MarkdownProcessor(
is ThematicBreak -> MarkdownBlock.ThematicBreak
is HtmlBlock -> toMarkdownHtmlBlockOrNull()
is CustomBlock -> {
extensions
.find { it.blockProcessorExtension?.canProcess(this) == true }
?.blockProcessorExtension
?.processMarkdownBlock(this, this@MarkdownProcessor)
blockExtensions.find { it.canProcess(this) }?.processMarkdownBlock(this, this@MarkdownProcessor)
}
else -> null
@@ -267,14 +277,14 @@ public class MarkdownProcessor(
}
private fun Paragraph.toMarkdownParagraph(): MarkdownBlock.Paragraph =
MarkdownBlock.Paragraph(readInlineContent(this@MarkdownProcessor).toList())
MarkdownBlock.Paragraph(readInlineMarkdown(this@MarkdownProcessor))
private fun BlockQuote.toMarkdownBlockQuote(): MarkdownBlock.BlockQuote =
MarkdownBlock.BlockQuote(processChildren(this))
private fun Heading.toMarkdownHeadingOrNull(): MarkdownBlock.Heading? {
if (level < 1 || level > 6) return null
return MarkdownBlock.Heading(inlineContent = readInlineContent(this@MarkdownProcessor).toList(), level = level)
return MarkdownBlock.Heading(inlineContent = readInlineMarkdown(this@MarkdownProcessor), level = level)
}
private fun FencedCodeBlock.toMarkdownCodeBlockOrNull(): CodeBlock.FencedCodeBlock =
@@ -345,5 +355,13 @@ public class MarkdownProcessor(
return MarkdownBlock.HtmlBlock(literal.trimEnd('\n'))
}
/** Creates a copy of this [MarkdownProcessor] with the same properties, plus the provided [extension]. */
@ExperimentalJewelApi
public operator fun plus(extension: MarkdownProcessorExtension): MarkdownProcessor = withExtension(extension)
/** Creates a copy of this [MarkdownProcessor] with the same properties, plus the provided [extension]. */
public fun withExtension(extension: MarkdownProcessorExtension): MarkdownProcessor =
MarkdownProcessor(extensions + extension, markdownMode, commonMarkParser)
private data class State(val lines: List<String>, val blocks: List<Block>, val indexes: List<Pair<Int, Int>>)
}

View File

@@ -1,7 +1,7 @@
package org.jetbrains.jewel.markdown.processing
import org.commonmark.node.Code as CMCode
import org.commonmark.node.CustomNode as CMCustomNode
import org.commonmark.node.Delimited
import org.commonmark.node.Emphasis as CMEmphasis
import org.commonmark.node.HardLineBreak as CMHardLineBreak
import org.commonmark.node.HtmlInline as CMHtmlInline
@@ -11,21 +11,24 @@ import org.commonmark.node.Node
import org.commonmark.node.SoftLineBreak as CMSoftLineBreak
import org.commonmark.node.StrongEmphasis as CMStrongEmphasis
import org.commonmark.node.Text as CMText
import org.commonmark.parser.beta.ParsedInline
import org.jetbrains.jewel.foundation.ExperimentalJewelApi
import org.jetbrains.jewel.foundation.util.JewelLogger
import org.jetbrains.jewel.markdown.InlineMarkdown
import org.jetbrains.jewel.markdown.WithInlineMarkdown
import org.jetbrains.jewel.markdown.WithTextContent
/**
* Reads the contents of this [Node] as a list of [InlineMarkdown] nodes.
* Reads all supported child inline nodes into a list of [InlineMarkdown] nodes, using the provided [markdownProcessor]
* (and its registered extensions).
*
* @param markdownProcessor Used to parse the inline contents as needed.
* @return A list of the contents as parsed [InlineMarkdown].
* @see toInlineMarkdownOrNull
*/
@ExperimentalJewelApi
public fun Node.readInlineContent(markdownProcessor: MarkdownProcessor): List<InlineMarkdown> = buildList {
var current = this@readInlineContent.firstChild
public fun Node.readInlineMarkdown(markdownProcessor: MarkdownProcessor): List<InlineMarkdown> = buildList {
var current = this@readInlineMarkdown.firstChild
while (current != null) {
val inline = current.toInlineMarkdownOrNull(markdownProcessor)
if (inline != null) add(inline)
@@ -35,14 +38,13 @@ public fun Node.readInlineContent(markdownProcessor: MarkdownProcessor): List<In
}
/**
* Tries parsing a CommonMark [Node] to an [InlineMarkdown] node.
* Converts this node to an [InlineMarkdown] node if possible, using the provided [markdownProcessor] (and its
* registered extensions).
*
* @param markdownProcessor Used to parse the contents of this node, as needed.
* @return The parsed [InlineMarkdown], or null if it is a custom node that can't be parsed by any of the
* [`MarkdownInlineProcessorExtension`][org.jetbrains.jewel.markdown.extensions.MarkdownInlineProcessorExtension]s
* @return The parsed [InlineMarkdown], or null if it is a custom node that can't be parsed by any of the extensions
* registered to [markdownProcessor].
* @see org.jetbrains.jewel.markdown.extensions.MarkdownInlineProcessorExtension
* @see readInlineContent
* @see readInlineMarkdown
*/
public fun Node.toInlineMarkdownOrNull(markdownProcessor: MarkdownProcessor): InlineMarkdown? =
when (this) {
@@ -51,18 +53,18 @@ public fun Node.toInlineMarkdownOrNull(markdownProcessor: MarkdownProcessor): In
InlineMarkdown.Link(
destination = destination,
title = title,
inlineContent = readInlineContent(markdownProcessor),
inlineContent = readInlineMarkdown(markdownProcessor),
)
is CMEmphasis ->
InlineMarkdown.Emphasis(delimiter = openingDelimiter, inlineContent = readInlineContent(markdownProcessor))
InlineMarkdown.Emphasis(delimiter = openingDelimiter, inlineContent = readInlineMarkdown(markdownProcessor))
is CMStrongEmphasis -> InlineMarkdown.StrongEmphasis(openingDelimiter, readInlineContent(markdownProcessor))
is CMStrongEmphasis -> InlineMarkdown.StrongEmphasis(openingDelimiter, readInlineMarkdown(markdownProcessor))
is CMCode -> InlineMarkdown.Code(literal)
is CMHtmlInline -> InlineMarkdown.HtmlInline(literal)
is CMImage -> {
val inlineContent = readInlineContent(markdownProcessor)
val inlineContent = readInlineMarkdown(markdownProcessor)
InlineMarkdown.Image(
source = destination,
alt = inlineContent.renderAsSimpleText().trim(),
@@ -73,11 +75,11 @@ public fun Node.toInlineMarkdownOrNull(markdownProcessor: MarkdownProcessor): In
is CMHardLineBreak -> InlineMarkdown.HardLineBreak
is CMSoftLineBreak -> InlineMarkdown.SoftLineBreak
is CMCustomNode ->
markdownProcessor.extensions
.find { it.inlineProcessorExtension?.canProcess(this) == true }
?.inlineProcessorExtension
?.processInlineMarkdown(this, markdownProcessor)
is Delimited ->
markdownProcessor.delimitedInlineExtensions
.find { it.canProcess(this) }
?.processDelimitedInline(this, markdownProcessor)
is ParsedInline -> null // Unsupported — see JEWEL-747
else -> error("Unexpected block $this")
}
@@ -88,19 +90,11 @@ internal fun List<InlineMarkdown>.renderAsSimpleText(): String = buildString {
when (node) {
is WithInlineMarkdown -> append(node.inlineContent.renderAsSimpleText())
is WithTextContent -> append(node.content)
is InlineMarkdown.CustomNode -> {
val textContent = node.contentOrNull()
if (textContent != null) {
append(' ')
append(textContent)
}
}
is InlineMarkdown.HardLineBreak -> append('\n')
is InlineMarkdown.SoftLineBreak -> append(' ')
else -> {
// Ignore other nodes
JewelLogger.getInstance("MarkdownProcessingUtil")
.debug("Ignoring node ${node.javaClass.simpleName} for text rendering")
}
}
}

View File

@@ -1,6 +1,5 @@
package org.jetbrains.jewel.markdown.rendering
import androidx.compose.foundation.text.appendInlineContent
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.AnnotatedString.Builder
@@ -9,11 +8,15 @@ import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.buildAnnotatedString
import org.jetbrains.jewel.foundation.ExperimentalJewelApi
import org.jetbrains.jewel.markdown.InlineMarkdown
import org.jetbrains.jewel.markdown.extensions.MarkdownDelimitedInlineRendererExtension
import org.jetbrains.jewel.markdown.extensions.MarkdownRendererExtension
@ExperimentalJewelApi
public open class DefaultInlineMarkdownRenderer(private val rendererExtensions: List<MarkdownRendererExtension>) :
public open class DefaultInlineMarkdownRenderer(rendererExtensions: List<MarkdownRendererExtension>) :
InlineMarkdownRenderer {
protected val delimitedNodeRendererExtensions: List<MarkdownDelimitedInlineRendererExtension> =
rendererExtensions.mapNotNull { it.delimitedInlineRenderer }
public override fun renderAsAnnotatedString(
inlineMarkdown: Iterable<InlineMarkdown>,
styling: InlinesStyling,
@@ -77,24 +80,23 @@ public open class DefaultInlineMarkdownRenderer(private val rendererExtensions:
}
is InlineMarkdown.Image -> {
appendInlineContent(
INLINE_IMAGE,
buildString {
appendLine(child.source)
append(child.alt)
if (!child.title.isNullOrBlank()) {
appendLine()
append(child.title)
}
},
)
// TODO not supported yet — see JEWEL-746
}
is InlineMarkdown.CustomNode ->
rendererExtensions
.find { it.inlineRenderer?.canRender(child) == true }
?.inlineRenderer
?.render(child, inlineRenderer = this@DefaultInlineMarkdownRenderer, enabled)
is InlineMarkdown.CustomDelimitedNode -> {
val delimitedNodeRendererExtension =
delimitedNodeRendererExtensions.find { it.canRender(child) } ?: continue
append(
delimitedNodeRendererExtension.render(
node = child,
inlineRenderer = this@DefaultInlineMarkdownRenderer,
inlinesStyling = styling,
enabled = enabled,
onUrlClicked = onUrlClicked,
)
)
}
}
}
}
@@ -119,8 +121,4 @@ public open class DefaultInlineMarkdownRenderer(private val rendererExtensions:
pop(popTo)
}
public companion object {
internal const val INLINE_IMAGE = "inline_image"
}
}

View File

@@ -1,3 +1,5 @@
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the
// Apache 2.0 license.
package org.jetbrains.jewel.markdown.rendering
import androidx.compose.foundation.layout.PaddingValues
@@ -12,6 +14,7 @@ import androidx.compose.ui.text.TextLinkStyles
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.Dp
import org.jetbrains.jewel.foundation.ExperimentalJewelApi
import org.jetbrains.jewel.foundation.GenerateDataFunctions
import org.jetbrains.jewel.markdown.rendering.MarkdownStyling.Code.Fenced.InfoPosition
import org.jetbrains.jewel.markdown.rendering.MarkdownStyling.Code.Fenced.InfoPosition.BottomCenter
@@ -34,6 +37,8 @@ public class MarkdownStyling(
public val thematicBreak: ThematicBreak,
public val htmlBlock: HtmlBlock,
) {
@ExperimentalJewelApi public val baseInlinesStyling: InlinesStyling = paragraph.inlinesStyling
@GenerateDataFunctions
public class Paragraph(override val inlinesStyling: InlinesStyling) : WithInlinesStyling {
override fun equals(other: Any?): Boolean {

View File

@@ -84,7 +84,7 @@ public open class ScrollSyncMarkdownBlockRenderer(
val content = block.content
val highlightedCode by
LocalCodeHighlighter.current.highlight(content, mimeType).collectAsState(AnnotatedString(content))
LocalCodeHighlighter.current.highlight(content, block.mimeType).collectAsState(AnnotatedString(content))
val actualBlock by rememberUpdatedState(block)
AutoScrollableBlock(actualBlock, synchronizer) {

View File

@@ -68,10 +68,10 @@ public class ScrollingSynchronizerTest {
public fun headings() {
val markdown =
"""
# Heading 1
## Heading 2
### Heading 3
"""
# Heading 1
## Heading 2
### Heading 3
"""
.trimIndent()
doTest(markdown) { scrollState, synchronizer ->
synchronizer.scrollToLine(0)
@@ -99,12 +99,12 @@ public class ScrollingSynchronizerTest {
public fun paragraphs() {
val markdown =
"""
p1
p1
p2
p2
p3
"""
p3
"""
.trimIndent()
doTest(markdown) { scrollState, synchronizer ->
synchronizer.scrollToLine(1)
@@ -131,17 +131,17 @@ public class ScrollingSynchronizerTest {
public fun `empty spaces`() {
val markdown =
"""
# Heading 1
# Heading 2
## Heading 3
"""
.trimIndent()
|# Heading 1
|
|
|# Heading 2
|
|
|## Heading 3
|
|
"""
.trimMargin()
doTest(markdown) { scrollState, synchronizer ->
synchronizer.scrollToLine(1)
val h2Top = scrollState.value
@@ -179,12 +179,12 @@ public class ScrollingSynchronizerTest {
public fun `unordered list`() {
val markdown =
"""
Items:
- item 1
- subitem A
- item 2
- item 3
"""
Items:
- item 1
- subitem A
- item 2
- item 3
"""
.trimIndent()
doTest(markdown) { scrollState, synchronizer ->
synchronizer.scrollToLine(1)
@@ -213,12 +213,12 @@ public class ScrollingSynchronizerTest {
public fun `ordered list`() {
val markdown =
"""
Items:
1. item 1
1. subitem A
2. item 2
3. item 3
"""
Items:
1. item 1
1. subitem A
2. item 2
3. item 3
"""
.trimIndent()
doTest(markdown) { scrollState, synchronizer ->
synchronizer.scrollToLine(1)
@@ -247,14 +247,14 @@ public class ScrollingSynchronizerTest {
public fun `fenced code block`() {
val markdown =
"""
```kotlin
package my.awesome.pkg
```kotlin
package my.awesome.pkg
fun main() {
println("Hello world")
}
```
"""
fun main() {
println("Hello world")
}
```
"""
.trimIndent()
doTest(markdown) { scrollState, synchronizer ->
synchronizer.scrollToLine(1)
@@ -296,14 +296,14 @@ public class ScrollingSynchronizerTest {
public fun `indented code block`() {
val markdown =
"""
Here starts the indented code block.
Here starts the indented code block.
package my.awesome.pkg
package my.awesome.pkg
fun main() {
println("Hello world")
}
"""
fun main() {
println("Hello world")
}
"""
.trimIndent()
doTest(markdown) { scrollState, synchronizer ->
synchronizer.scrollToLine(2)
@@ -345,28 +345,28 @@ public class ScrollingSynchronizerTest {
public fun `add a block`() {
val firstRun =
"""
```kotlin
package my.awesome.pkg
```kotlin
package my.awesome.pkg
fun main() {
println("Hello world")
}
```
"""
fun main() {
println("Hello world")
}
```
"""
.trimIndent()
val secondRun =
"""
**CHANGE**
**CHANGE**
```kotlin
package my.awesome.pkg
```kotlin
package my.awesome.pkg
fun main() {
println("Hello world")
}
```
"""
fun main() {
println("Hello world")
}
```
"""
.trimIndent()
doTest(firstRun, secondRun) { scrollState, synchronizer ->
@@ -409,28 +409,28 @@ public class ScrollingSynchronizerTest {
public fun `remove a block`() {
val firstRun =
"""
**CHANGE**
**CHANGE**
```kotlin
package my.awesome.pkg
```kotlin
package my.awesome.pkg
fun main() {
println("Hello world")
}
```
"""
fun main() {
println("Hello world")
}
```
"""
.trimIndent()
val secondRun =
"""
```kotlin
package my.awesome.pkg
```kotlin
package my.awesome.pkg
fun main() {
println("Hello world")
}
```
"""
fun main() {
println("Hello world")
}
```
"""
.trimIndent()
doTest(firstRun, secondRun) { scrollState, synchronizer ->
@@ -473,27 +473,27 @@ public class ScrollingSynchronizerTest {
public fun `change a block`() {
val firstRun =
"""
```kotlin
package my.awesome.pkg
```kotlin
package my.awesome.pkg
fun main() {
println("Hello world")
}
```
"""
fun main() {
println("Hello world")
}
```
"""
.trimIndent()
val secondRun =
"""
```kotlin
package my.awesome.pkg
```kotlin
package my.awesome.pkg
fun main() {
val name = "Steve"
println("Hello " + name)
}
```
"""
fun main() {
val name = "Steve"
println("Hello " + name)
}
```
"""
.trimIndent()
doTest(firstRun, secondRun) { scrollState, synchronizer ->
@@ -541,36 +541,36 @@ public class ScrollingSynchronizerTest {
public fun `merge code blocks`() {
val firstRun =
"""
```kotlin
package my.awesome.pkg
```kotlin
package my.awesome.pkg
fun main() {
println("Hello world")
}
```
fun main() {
println("Hello world")
}
```
```kotlin
fun foo() {
println("Foo")
}
```
"""
```kotlin
fun foo() {
println("Foo")
}
```
"""
.trimIndent()
val secondRun =
"""
```kotlin
package my.awesome.pkg
```kotlin
package my.awesome.pkg
fun main() {
println("Hello world")
}
fun main() {
println("Hello world")
}
fun foo() {
println("Foo")
}
```
"""
fun foo() {
println("Foo")
}
```
"""
.trimIndent()
doTest(firstRun, secondRun) { scrollState, synchronizer ->

View File

@@ -2,7 +2,7 @@ public final class org/jetbrains/jewel/markdown/extension/autolink/AutolinkProce
public static final field $stable I
public static final field INSTANCE Lorg/jetbrains/jewel/markdown/extension/autolink/AutolinkProcessorExtension;
public fun getBlockProcessorExtension ()Lorg/jetbrains/jewel/markdown/extensions/MarkdownBlockProcessorExtension;
public fun getInlineProcessorExtension ()Lorg/jetbrains/jewel/markdown/extensions/MarkdownInlineProcessorExtension;
public fun getDelimitedInlineProcessorExtension ()Lorg/jetbrains/jewel/markdown/extensions/MarkdownDelimitedInlineProcessorExtension;
public fun getParserExtension ()Lorg/commonmark/parser/Parser$ParserExtension;
public fun getTextRendererExtension ()Lorg/commonmark/renderer/text/TextContentRenderer$TextContentRendererExtension;
}

View File

@@ -133,7 +133,7 @@ public final class org/jetbrains/jewel/markdown/extensions/github/alerts/GitHubA
public static final field $stable I
public static final field INSTANCE Lorg/jetbrains/jewel/markdown/extensions/github/alerts/GitHubAlertProcessorExtension;
public fun getBlockProcessorExtension ()Lorg/jetbrains/jewel/markdown/extensions/MarkdownBlockProcessorExtension;
public fun getInlineProcessorExtension ()Lorg/jetbrains/jewel/markdown/extensions/MarkdownInlineProcessorExtension;
public fun getDelimitedInlineProcessorExtension ()Lorg/jetbrains/jewel/markdown/extensions/MarkdownDelimitedInlineProcessorExtension;
public fun getParserExtension ()Lorg/commonmark/parser/Parser$ParserExtension;
public fun getTextRendererExtension ()Lorg/commonmark/renderer/text/TextContentRenderer$TextContentRendererExtension;
}
@@ -142,7 +142,7 @@ public final class org/jetbrains/jewel/markdown/extensions/github/alerts/GitHubA
public static final field $stable I
public fun <init> (Lorg/jetbrains/jewel/markdown/extensions/github/alerts/AlertStyling;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling;)V
public fun getBlockRenderer ()Lorg/jetbrains/jewel/markdown/extensions/MarkdownBlockRendererExtension;
public fun getInlineRenderer ()Lorg/jetbrains/jewel/markdown/extensions/MarkdownInlineRendererExtension;
public fun getDelimitedInlineRenderer ()Lorg/jetbrains/jewel/markdown/extensions/MarkdownDelimitedInlineRendererExtension;
}
public final class org/jetbrains/jewel/markdown/extensions/github/alerts/ImportantAlertStyling : org/jetbrains/jewel/markdown/extensions/github/alerts/BaseAlertStyling {

View File

@@ -0,0 +1,41 @@
# GitHub Flavored Markdown — strikethrough extension
This extension adds support for strikethrough,
a [GFM extension](https://github.github.com/gfm/#strikethrough-extension-) over
CommonMark. Strikethrough nodes are parsed by the `commonmark-ext-gfm-strikethrough` library, and rendered simply by
wrapping their content in a `SpanStyle` that applies the `LineThrough` decoration.
![Screenshot of a strikethrough](../../../art/docs/gfm-strikethrough.png)
## Usage
To use the strikethrough extension, you need to add the `GitHubStrikethroughProcessorExtension` to your
`MarkdownProcessor`, and the
`GitHubStrikethroughRendererExtension` to the `MarkdownBlockRenderer`. For example, in standalone mode:
```kotlin
val isDark = JewelTheme.isDark
val markdownStyling = remember(isDark) { if (isDark) MarkdownStyling.dark() else MarkdownStyling.light() }
val processor = remember { MarkdownProcessor(listOf(GitHubStrikethroughProcessorExtension)) }
val blockRenderer =
remember(markdownStyling) {
if (isDark) {
MarkdownBlockRenderer.dark(
styling = markdownStyling,
rendererExtensions = listOf(GitHubStrikethroughRendererExtension),
)
} else {
MarkdownBlockRenderer.light(
styling = markdownStyling,
rendererExtensions = listOf(GitHubStrikethroughRendererExtension),
)
}
}
ProvideMarkdownStyling(markdownStyling, blockRenderer, NoOpCodeHighlighter) {
// Your UI that renders Markdown goes here
}
```

View File

@@ -0,0 +1,48 @@
public final class org/jetbrains/jewel/markdown/extensions/github/strikethrough/GitHubStrikethroughInlineProcessorExtension : org/jetbrains/jewel/markdown/extensions/MarkdownDelimitedInlineProcessorExtension {
public static final field $stable I
public static final field INSTANCE Lorg/jetbrains/jewel/markdown/extensions/github/strikethrough/GitHubStrikethroughInlineProcessorExtension;
public fun canProcess (Lorg/commonmark/node/Delimited;)Z
public fun processDelimitedInline (Lorg/commonmark/node/Delimited;Lorg/jetbrains/jewel/markdown/processing/MarkdownProcessor;)Lorg/jetbrains/jewel/markdown/InlineMarkdown$CustomDelimitedNode;
}
public final class org/jetbrains/jewel/markdown/extensions/github/strikethrough/GitHubStrikethroughInlineRendererExtension : org/jetbrains/jewel/markdown/extensions/MarkdownDelimitedInlineRendererExtension {
public static final field $stable I
public static final field INSTANCE Lorg/jetbrains/jewel/markdown/extensions/github/strikethrough/GitHubStrikethroughInlineRendererExtension;
public fun canRender (Lorg/jetbrains/jewel/markdown/InlineMarkdown$CustomDelimitedNode;)Z
public fun render (Lorg/jetbrains/jewel/markdown/InlineMarkdown$CustomDelimitedNode;Lorg/jetbrains/jewel/markdown/rendering/InlineMarkdownRenderer;Lorg/jetbrains/jewel/markdown/rendering/InlinesStyling;ZLkotlin/jvm/functions/Function1;)Landroidx/compose/ui/text/AnnotatedString;
}
public final class org/jetbrains/jewel/markdown/extensions/github/strikethrough/GitHubStrikethroughNode : org/jetbrains/jewel/markdown/InlineMarkdown$CustomDelimitedNode, org/jetbrains/jewel/markdown/WithInlineMarkdown {
public static final field $stable I
public fun <init> (Ljava/lang/String;Ljava/util/List;)V
public final fun component1 ()Ljava/lang/String;
public final fun component2 ()Ljava/util/List;
public final fun copy (Ljava/lang/String;Ljava/util/List;)Lorg/jetbrains/jewel/markdown/extensions/github/strikethrough/GitHubStrikethroughNode;
public static synthetic fun copy$default (Lorg/jetbrains/jewel/markdown/extensions/github/strikethrough/GitHubStrikethroughNode;Ljava/lang/String;Ljava/util/List;ILjava/lang/Object;)Lorg/jetbrains/jewel/markdown/extensions/github/strikethrough/GitHubStrikethroughNode;
public fun equals (Ljava/lang/Object;)Z
public fun getClosingDelimiter ()Ljava/lang/String;
public final fun getDelimiter ()Ljava/lang/String;
public fun getInlineContent ()Ljava/util/List;
public fun getOpeningDelimiter ()Ljava/lang/String;
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}
public final class org/jetbrains/jewel/markdown/extensions/github/strikethrough/GitHubStrikethroughProcessorExtension : org/jetbrains/jewel/markdown/extensions/MarkdownProcessorExtension {
public static final field $stable I
public fun <init> ()V
public fun <init> (Z)V
public synthetic fun <init> (ZILkotlin/jvm/internal/DefaultConstructorMarker;)V
public fun getBlockProcessorExtension ()Lorg/jetbrains/jewel/markdown/extensions/MarkdownBlockProcessorExtension;
public fun getDelimitedInlineProcessorExtension ()Lorg/jetbrains/jewel/markdown/extensions/MarkdownDelimitedInlineProcessorExtension;
public fun getParserExtension ()Lorg/commonmark/parser/Parser$ParserExtension;
public fun getTextRendererExtension ()Lorg/commonmark/renderer/text/TextContentRenderer$TextContentRendererExtension;
}
public final class org/jetbrains/jewel/markdown/extensions/github/strikethrough/GitHubStrikethroughRendererExtension : org/jetbrains/jewel/markdown/extensions/MarkdownRendererExtension {
public static final field $stable I
public static final field INSTANCE Lorg/jetbrains/jewel/markdown/extensions/github/strikethrough/GitHubStrikethroughRendererExtension;
public fun getBlockRenderer ()Lorg/jetbrains/jewel/markdown/extensions/MarkdownBlockRendererExtension;
public fun getDelimitedInlineRenderer ()Lorg/jetbrains/jewel/markdown/extensions/MarkdownDelimitedInlineRendererExtension;
}

View File

@@ -0,0 +1,22 @@
plugins {
jewel
`jewel-publish`
`jewel-check-public-api`
alias(libs.plugins.composeDesktop)
alias(libs.plugins.compose.compiler)
}
dependencies {
implementation(projects.markdown.core)
implementation(libs.commonmark.ext.gfm.strikethrough)
testImplementation(compose.desktop.uiTestJUnit4)
}
publishing.publications.named<MavenPublication>("main") {
val ijpTarget = project.property("ijp.target") as String
artifactId = "jewel-markdown-extension-${project.name}-$ijpTarget"
}
publicApiValidation {
excludedClassRegexes = setOf("org.jetbrains.jewel.markdown.extensions.github.strikethrough.*")
}

View File

@@ -0,0 +1,375 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="kotlin-language" name="Kotlin">
<configuration version="5" platform="JVM 17" allPlatforms="JVM [17]" useProjectSettings="false">
<compilerSettings>
<option name="additionalArguments" value="-Xjvm-default=all -opt-in=androidx.compose.ui.ExperimentalComposeUiApi -Xcontext-receivers -opt-in=androidx.compose.foundation.ExperimentalFoundationApi -opt-in=org.jetbrains.jewel.foundation.ExperimentalJewelApi -opt-in=org.jetbrains.jewel.foundation.InternalJewelApi -P plugin:poko-compiler-plugin:pokoAnnotation=org/jetbrains/jewel/foundation/GenerateDataFunctions plugin:poko:pokoAnnotation=org/jetbrains/jewel/foundation/GenerateDataFunctions" />
</compilerSettings>
<compilerArguments>
<stringArguments>
<stringArg name="jvmTarget" arg="17" />
<stringArg name="apiVersion" arg="2.0" />
<stringArg name="languageVersion" arg="2.0" />
</stringArguments>
<arrayArguments>
<arrayArg name="pluginClasspaths">
<args>
<arg>$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-compose-compiler-plugin/2.1.0/kotlin-compose-compiler-plugin-2.1.0.jar</arg>
<arg>$MAVEN_REPOSITORY$/dev/drewhamilton/poko/poko-compiler-plugin/0.18.2/poko-compiler-plugin-0.18.2.jar</arg>
</args>
</arrayArg>
</arrayArguments>
</compilerArguments>
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/kotlin" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/kotlin" isTestSource="true" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="library" name="kotlin-stdlib" level="project" />
<orderEntry type="library" name="kotlinx-coroutines-core" level="project" />
<orderEntry type="library" name="jetbrains-annotations" level="project" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="intellij.platform.jewel.markdown.core" />
<orderEntry type="module" module-name="intellij.platform.jewel.ui" />
<orderEntry type="module" module-name="intellij.platform.jewel.foundation" />
<orderEntry type="module-library" scope="TEST">
<library name="org.jetbrains.compose.ui.ui.test.junit4" type="repository">
<properties include-transitive-deps="false" maven-id="org.jetbrains.compose.ui:ui-test-junit4:1.7.1">
<verification>
<artifact url="file://$MAVEN_REPOSITORY$/org/jetbrains/compose/ui/ui-test-junit4/1.7.1/ui-test-junit4-1.7.1.jar">
<sha256sum>c53f675b2af4696e6022598145a44a9e9feb35216a188163ae5bf99a18e76bdb</sha256sum>
</artifact>
</verification>
</properties>
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/compose/ui/ui-test-junit4/1.7.1/ui-test-junit4-1.7.1.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/compose/ui/ui-test-junit4/1.7.1/ui-test-junit4-1.7.1-sources.jar!/" />
</SOURCES>
</library>
</orderEntry>
<orderEntry type="module-library" scope="TEST">
<library name="org.jetbrains.compose.ui.ui.test.junit4.desktop" type="repository">
<properties include-transitive-deps="false" maven-id="org.jetbrains.compose.ui:ui-test-junit4-desktop:1.7.1">
<verification>
<artifact url="file://$MAVEN_REPOSITORY$/org/jetbrains/compose/ui/ui-test-junit4-desktop/1.7.1/ui-test-junit4-desktop-1.7.1.jar">
<sha256sum>f1e334b73d49ceab00afe776a4c393de77b4fc805e9ff488dac596a2663b1dc1</sha256sum>
</artifact>
</verification>
</properties>
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/compose/ui/ui-test-junit4-desktop/1.7.1/ui-test-junit4-desktop-1.7.1.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/compose/ui/ui-test-junit4-desktop/1.7.1/ui-test-junit4-desktop-1.7.1-sources.jar!/" />
</SOURCES>
</library>
</orderEntry>
<orderEntry type="module-library" scope="TEST">
<library name="org.hamcrest.hamcrest.core" type="repository">
<properties include-transitive-deps="false" maven-id="org.hamcrest:hamcrest-core:1.3">
<verification>
<artifact url="file://$MAVEN_REPOSITORY$/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar">
<sha256sum>66fdef91e9739348df7a096aa384a5685f4e875584cce89386a7a47251c4d8e9</sha256sum>
</artifact>
</verification>
</properties>
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3-sources.jar!/" />
</SOURCES>
</library>
</orderEntry>
<orderEntry type="module-library" scope="TEST">
<library name="org.jetbrains.compose.ui.ui.test" type="repository">
<properties include-transitive-deps="false" maven-id="org.jetbrains.compose.ui:ui-test:1.7.1">
<verification>
<artifact url="file://$MAVEN_REPOSITORY$/org/jetbrains/compose/ui/ui-test/1.7.1/ui-test-1.7.1.jar">
<sha256sum>a7dfdfd2b9d6668c646275948eba357aab6407f635f2dc09fe90258a2f202337</sha256sum>
</artifact>
</verification>
</properties>
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/compose/ui/ui-test/1.7.1/ui-test-1.7.1.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/compose/ui/ui-test/1.7.1/ui-test-1.7.1-sources.jar!/" />
</SOURCES>
</library>
</orderEntry>
<orderEntry type="module-library" scope="TEST">
<library name="org.jetbrains.compose.ui.ui.test.desktop" type="repository">
<properties include-transitive-deps="false" maven-id="org.jetbrains.compose.ui:ui-test-desktop:1.7.1">
<verification>
<artifact url="file://$MAVEN_REPOSITORY$/org/jetbrains/compose/ui/ui-test-desktop/1.7.1/ui-test-desktop-1.7.1.jar">
<sha256sum>34dfab5b4fa8b2913f00facdddc049e2fef4b176f8e7cde0ad306485674c3b5c</sha256sum>
</artifact>
</verification>
</properties>
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/compose/ui/ui-test-desktop/1.7.1/ui-test-desktop-1.7.1.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/compose/ui/ui-test-desktop/1.7.1/ui-test-desktop-1.7.1-sources.jar!/" />
</SOURCES>
</library>
</orderEntry>
<orderEntry type="module-library" scope="TEST">
<library name="org.jetbrains.compose.runtime.runtime" type="repository">
<properties include-transitive-deps="false" maven-id="org.jetbrains.compose.runtime:runtime:1.7.1">
<verification>
<artifact url="file://$MAVEN_REPOSITORY$/org/jetbrains/compose/runtime/runtime/1.7.1/runtime-1.7.1.jar">
<sha256sum>5c84c3bb1c1b636ae36030a0f98d4629afa29e192a9c78f57f22ce2c8ff6bc96</sha256sum>
</artifact>
</verification>
</properties>
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/compose/runtime/runtime/1.7.1/runtime-1.7.1.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/compose/runtime/runtime/1.7.1/runtime-1.7.1-sources.jar!/" />
</SOURCES>
</library>
</orderEntry>
<orderEntry type="module-library" scope="TEST">
<library name="org.jetbrains.compose.ui.ui" type="repository">
<properties include-transitive-deps="false" maven-id="org.jetbrains.compose.ui:ui:1.7.1">
<verification>
<artifact url="file://$MAVEN_REPOSITORY$/org/jetbrains/compose/ui/ui/1.7.1/ui-1.7.1.jar">
<sha256sum>c106c0f705717889663555fe4cb7742612bd47b56a128bf7a9f589f24c64cb08</sha256sum>
</artifact>
</verification>
</properties>
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/compose/ui/ui/1.7.1/ui-1.7.1.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/compose/ui/ui/1.7.1/ui-1.7.1-sources.jar!/" />
</SOURCES>
</library>
</orderEntry>
<orderEntry type="module-library" scope="TEST">
<library name="org.jetbrains.compose.ui.ui.text" type="repository">
<properties include-transitive-deps="false" maven-id="org.jetbrains.compose.ui:ui-text:1.7.1">
<verification>
<artifact url="file://$MAVEN_REPOSITORY$/org/jetbrains/compose/ui/ui-text/1.7.1/ui-text-1.7.1.jar">
<sha256sum>8ff9a2b8c93b0287d8fa837d5b0917923168cb97dea1ada1a8d4aa7bb17c9f15</sha256sum>
</artifact>
</verification>
</properties>
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/compose/ui/ui-text/1.7.1/ui-text-1.7.1.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/compose/ui/ui-text/1.7.1/ui-text-1.7.1-sources.jar!/" />
</SOURCES>
</library>
</orderEntry>
<orderEntry type="module-library" scope="TEST">
<library name="org.jetbrains.compose.ui.ui.unit" type="repository">
<properties include-transitive-deps="false" maven-id="org.jetbrains.compose.ui:ui-unit:1.7.1">
<verification>
<artifact url="file://$MAVEN_REPOSITORY$/org/jetbrains/compose/ui/ui-unit/1.7.1/ui-unit-1.7.1.jar">
<sha256sum>41da5d61c56877b5b5d01e2a2bcb967cbfaf4d45c1a1aa124c0601c7a3de74e7</sha256sum>
</artifact>
</verification>
</properties>
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/compose/ui/ui-unit/1.7.1/ui-unit-1.7.1.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/compose/ui/ui-unit/1.7.1/ui-unit-1.7.1-sources.jar!/" />
</SOURCES>
</library>
</orderEntry>
<orderEntry type="module-library" scope="TEST">
<library name="org.jetbrains.annotations" type="repository">
<properties include-transitive-deps="false" maven-id="org.jetbrains:annotations:23.0.0">
<verification>
<artifact url="file://$MAVEN_REPOSITORY$/org/jetbrains/annotations/23.0.0/annotations-23.0.0.jar">
<sha256sum>7b0f19724082cbfcbc66e5abea2b9bc92cf08a1ea11e191933ed43801eb3cd05</sha256sum>
</artifact>
</verification>
</properties>
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/annotations/23.0.0/annotations-23.0.0.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/annotations/23.0.0/annotations-23.0.0-sources.jar!/" />
</SOURCES>
</library>
</orderEntry>
<orderEntry type="module-library" scope="TEST">
<library name="org.jetbrains.compose.desktop.desktop" type="repository">
<properties include-transitive-deps="false" maven-id="org.jetbrains.compose.desktop:desktop:1.7.1">
<verification>
<artifact url="file://$MAVEN_REPOSITORY$/org/jetbrains/compose/desktop/desktop/1.7.1/desktop-1.7.1.jar">
<sha256sum>bff3d1e895fd5abd54ee725dab59214acabf900e1a0784544d20cf20521bf9f3</sha256sum>
</artifact>
</verification>
</properties>
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/compose/desktop/desktop/1.7.1/desktop-1.7.1.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/compose/desktop/desktop/1.7.1/desktop-1.7.1-sources.jar!/" />
</SOURCES>
</library>
</orderEntry>
<orderEntry type="module-library" scope="TEST">
<library name="org.jetbrains.compose.desktop.desktop.jvm" type="repository">
<properties include-transitive-deps="false" maven-id="org.jetbrains.compose.desktop:desktop-jvm:1.7.1">
<verification>
<artifact url="file://$MAVEN_REPOSITORY$/org/jetbrains/compose/desktop/desktop-jvm/1.7.1/desktop-jvm-1.7.1.jar">
<sha256sum>62c816073195cc0119dc1d66b178544bdb772ef8bee4879954528c6798b17ebe</sha256sum>
</artifact>
</verification>
</properties>
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/compose/desktop/desktop-jvm/1.7.1/desktop-jvm-1.7.1.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/compose/desktop/desktop-jvm/1.7.1/desktop-jvm-1.7.1-sources.jar!/" />
</SOURCES>
</library>
</orderEntry>
<orderEntry type="module-library" scope="TEST">
<library name="org.jetbrains.compose.runtime.runtime" type="repository">
<properties include-transitive-deps="false" maven-id="org.jetbrains.compose.runtime:runtime:1.7.1">
<verification>
<artifact url="file://$MAVEN_REPOSITORY$/org/jetbrains/compose/runtime/runtime/1.7.1/runtime-1.7.1.jar">
<sha256sum>5c84c3bb1c1b636ae36030a0f98d4629afa29e192a9c78f57f22ce2c8ff6bc96</sha256sum>
</artifact>
</verification>
</properties>
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/compose/runtime/runtime/1.7.1/runtime-1.7.1.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/compose/runtime/runtime/1.7.1/runtime-1.7.1-sources.jar!/" />
</SOURCES>
</library>
</orderEntry>
<orderEntry type="module-library" scope="TEST">
<library name="org.jetbrains.compose.ui.ui" type="repository">
<properties include-transitive-deps="false" maven-id="org.jetbrains.compose.ui:ui:1.7.1">
<verification>
<artifact url="file://$MAVEN_REPOSITORY$/org/jetbrains/compose/ui/ui/1.7.1/ui-1.7.1.jar">
<sha256sum>c106c0f705717889663555fe4cb7742612bd47b56a128bf7a9f589f24c64cb08</sha256sum>
</artifact>
</verification>
</properties>
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/compose/ui/ui/1.7.1/ui-1.7.1.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/compose/ui/ui/1.7.1/ui-1.7.1-sources.jar!/" />
</SOURCES>
</library>
</orderEntry>
<orderEntry type="module-library" scope="TEST">
<library name="org.jetbrains.compose.ui.ui.tooling.preview" type="repository">
<properties include-transitive-deps="false" maven-id="org.jetbrains.compose.ui:ui-tooling-preview:1.7.1">
<verification>
<artifact url="file://$MAVEN_REPOSITORY$/org/jetbrains/compose/ui/ui-tooling-preview/1.7.1/ui-tooling-preview-1.7.1.jar">
<sha256sum>1b409141a9ee6ed38e76a8fb8f9cf280030bf45375ba7e07e60b2742039b573e</sha256sum>
</artifact>
</verification>
</properties>
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/compose/ui/ui-tooling-preview/1.7.1/ui-tooling-preview-1.7.1.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/compose/ui/ui-tooling-preview/1.7.1/ui-tooling-preview-1.7.1-sources.jar!/" />
</SOURCES>
</library>
</orderEntry>
<orderEntry type="module-library" scope="TEST">
<library name="org.jetbrains.compose.ui.ui.tooling.preview.desktop" type="repository">
<properties include-transitive-deps="false" maven-id="org.jetbrains.compose.ui:ui-tooling-preview-desktop:1.7.1">
<verification>
<artifact url="file://$MAVEN_REPOSITORY$/org/jetbrains/compose/ui/ui-tooling-preview-desktop/1.7.1/ui-tooling-preview-desktop-1.7.1.jar">
<sha256sum>c5cfad0b125e978d915f8b4c38630bc5d548e59fe8a0e838c0cc84283c605943</sha256sum>
</artifact>
</verification>
</properties>
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/compose/ui/ui-tooling-preview-desktop/1.7.1/ui-tooling-preview-desktop-1.7.1.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/compose/ui/ui-tooling-preview-desktop/1.7.1/ui-tooling-preview-desktop-1.7.1-sources.jar!/" />
</SOURCES>
</library>
</orderEntry>
<orderEntry type="module-library" scope="TEST">
<library name="org.jetbrains.compose.runtime.runtime" type="repository">
<properties include-transitive-deps="false" maven-id="org.jetbrains.compose.runtime:runtime:1.7.1">
<verification>
<artifact url="file://$MAVEN_REPOSITORY$/org/jetbrains/compose/runtime/runtime/1.7.1/runtime-1.7.1.jar">
<sha256sum>5c84c3bb1c1b636ae36030a0f98d4629afa29e192a9c78f57f22ce2c8ff6bc96</sha256sum>
</artifact>
</verification>
</properties>
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/compose/runtime/runtime/1.7.1/runtime-1.7.1.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/compose/runtime/runtime/1.7.1/runtime-1.7.1-sources.jar!/" />
</SOURCES>
</library>
</orderEntry>
<orderEntry type="module" module-name="intellij.libraries.junit4" scope="TEST" />
<orderEntry type="module" module-name="intellij.libraries.compose.foundation.desktop" />
<orderEntry type="library" scope="TEST" name="kotlinx-coroutines-test" level="project" />
<orderEntry type="module-library">
<library name="commonmark.ext.gfm.strikethrough" type="repository">
<properties maven-id="org.commonmark:commonmark-ext-gfm-strikethrough:0.24.0">
<verification>
<artifact url="file://$MAVEN_REPOSITORY$/org/commonmark/commonmark-ext-gfm-strikethrough/0.24.0/commonmark-ext-gfm-strikethrough-0.24.0.jar">
<sha256sum>7385cb637f04dc4cbda4ddca9c2fcd2af7ac536a50e4c8d2c77f4748bb14bf41</sha256sum>
</artifact>
<artifact url="file://$MAVEN_REPOSITORY$/org/commonmark/commonmark/0.24.0/commonmark-0.24.0.jar">
<sha256sum>679338e0b7fc15c02d275d598654b01a149893bc28a87992e90123c8d06af25b</sha256sum>
</artifact>
</verification>
</properties>
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/commonmark/commonmark-ext-gfm-strikethrough/0.24.0/commonmark-ext-gfm-strikethrough-0.24.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/commonmark/commonmark/0.24.0/commonmark-0.24.0.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/commonmark/commonmark-ext-gfm-strikethrough/0.24.0/commonmark-ext-gfm-strikethrough-0.24.0-sources.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/commonmark/commonmark/0.24.0/commonmark-0.24.0-sources.jar!/" />
</SOURCES>
</library>
</orderEntry>
</component>
</module>

View File

@@ -0,0 +1,33 @@
package org.jetbrains.jewel.markdown.extensions.github.strikethrough
import org.commonmark.ext.gfm.strikethrough.Strikethrough
import org.commonmark.node.Delimited
import org.commonmark.node.Node
import org.jetbrains.jewel.markdown.InlineMarkdown
import org.jetbrains.jewel.markdown.extensions.MarkdownDelimitedInlineProcessorExtension
import org.jetbrains.jewel.markdown.processing.MarkdownProcessor
import org.jetbrains.jewel.markdown.processing.readInlineMarkdown
/**
* A [MarkdownDelimitedInlineProcessorExtension] that turns [Strikethrough] nodes into [GitHubStrikethroughNode]s.
*
* Strikethrough is a GitHub Flavored Markdown extension, defined
* [in the GFM specs](https://github.github.com/gfm/#strikethrough-extension-).
*
* @see GitHubStrikethroughProcessorExtension
* @see GitHubStrikethroughNode
* @see GitHubStrikethroughRendererExtension
*/
public object GitHubStrikethroughInlineProcessorExtension : MarkdownDelimitedInlineProcessorExtension {
override fun canProcess(delimited: Delimited): Boolean = delimited is Strikethrough
override fun processDelimitedInline(
delimited: Delimited,
markdownProcessor: MarkdownProcessor,
): InlineMarkdown.CustomDelimitedNode =
GitHubStrikethroughNode(
delimited.openingDelimiter,
// Alas, CommonMark APIs kinda suck, so we need to hard-cast to Node...
(delimited as Node).readInlineMarkdown(markdownProcessor),
)
}

View File

@@ -0,0 +1,43 @@
package org.jetbrains.jewel.markdown.extensions.github.strikethrough
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.buildAnnotatedString
import androidx.compose.ui.text.style.TextDecoration
import androidx.compose.ui.text.withStyle
import org.jetbrains.jewel.markdown.InlineMarkdown
import org.jetbrains.jewel.markdown.extensions.MarkdownDelimitedInlineRendererExtension
import org.jetbrains.jewel.markdown.rendering.InlineMarkdownRenderer
import org.jetbrains.jewel.markdown.rendering.InlinesStyling
/**
* An extension for [`MarkdownInlineRenderer`][org.jetbrains.jewel.markdown.rendering.InlineMarkdownRenderer] that
* renders [GitHubStrikethroughNode]s into annotated strings.
*/
public object GitHubStrikethroughInlineRendererExtension : MarkdownDelimitedInlineRendererExtension {
private val strikethroughSpanStyle = SpanStyle(textDecoration = TextDecoration.Companion.LineThrough)
override fun canRender(node: InlineMarkdown.CustomDelimitedNode): Boolean = node is GitHubStrikethroughNode
override fun render(
node: InlineMarkdown.CustomDelimitedNode,
inlineRenderer: InlineMarkdownRenderer,
inlinesStyling: InlinesStyling,
enabled: Boolean,
onUrlClicked: ((String) -> Unit)?,
): AnnotatedString {
val strikethroughNode = node as GitHubStrikethroughNode
return buildAnnotatedString {
withStyle(strikethroughSpanStyle) {
append(
inlineRenderer.renderAsAnnotatedString(
inlineMarkdown = strikethroughNode.inlineContent,
styling = inlinesStyling,
enabled = enabled,
onUrlClicked = onUrlClicked,
)
)
}
}
}
}

View File

@@ -0,0 +1,19 @@
package org.jetbrains.jewel.markdown.extensions.github.strikethrough
import org.jetbrains.jewel.markdown.InlineMarkdown
import org.jetbrains.jewel.markdown.WithInlineMarkdown
/**
* A Markdown inline node representing a strike-through. It contains other inline nodes.
*
* Strikethrough is a GitHub Flavored Markdown extension, defined
* [in the GFM specs](https://github.github.com/gfm/#strikethrough-extension-).
*
* @see org.commonmark.ext.gfm.strikethrough.Strikethrough
* @see GitHubStrikethroughProcessorExtension
* @see GitHubStrikethroughRendererExtension
*/
public data class GitHubStrikethroughNode(val delimiter: String, override val inlineContent: List<InlineMarkdown>) :
InlineMarkdown.CustomDelimitedNode, WithInlineMarkdown {
override val openingDelimiter: String = delimiter
}

View File

@@ -0,0 +1,29 @@
package org.jetbrains.jewel.markdown.extensions.github.strikethrough
import org.commonmark.ext.gfm.strikethrough.StrikethroughExtension
import org.commonmark.parser.Parser.ParserExtension
import org.commonmark.renderer.text.TextContentRenderer
import org.jetbrains.jewel.markdown.extensions.MarkdownDelimitedInlineProcessorExtension
import org.jetbrains.jewel.markdown.extensions.MarkdownProcessorExtension
/**
* Adds support for inline strikethrough to a [org.jetbrains.jewel.markdown.processing.MarkdownProcessor].
*
* Strikethrough is a GitHub Flavored Markdown extension, defined
* [in the GFM specs](https://github.github.com/gfm/#strikethrough-extension-).
*
* @see StrikethroughExtension
* @see GitHubStrikethroughNode
* @see GitHubStrikethroughRendererExtension
*/
public class GitHubStrikethroughProcessorExtension(requireTwoTildes: Boolean = false) : MarkdownProcessorExtension {
private val commonMarkExtension = StrikethroughExtension.builder().requireTwoTildes(requireTwoTildes).build()
override val parserExtension: ParserExtension = commonMarkExtension as ParserExtension
override val textRendererExtension: TextContentRenderer.TextContentRendererExtension =
commonMarkExtension as TextContentRenderer.TextContentRendererExtension
override val delimitedInlineProcessorExtension: MarkdownDelimitedInlineProcessorExtension =
GitHubStrikethroughInlineProcessorExtension
}

View File

@@ -0,0 +1,13 @@
package org.jetbrains.jewel.markdown.extensions.github.strikethrough
import org.jetbrains.jewel.markdown.extensions.MarkdownDelimitedInlineRendererExtension
import org.jetbrains.jewel.markdown.extensions.MarkdownRendererExtension
/**
* A [MarkdownRendererExtension] that supports rendering
* [org.jetbrains.jewel.markdown.InlineMarkdown.CustomDelimitedNode]s into [androidx.compose.ui.text.AnnotatedString]s.
*/
public object GitHubStrikethroughRendererExtension : MarkdownRendererExtension {
public override val delimitedInlineRenderer: MarkdownDelimitedInlineRendererExtension =
GitHubStrikethroughInlineRendererExtension
}

View File

@@ -57,7 +57,7 @@ public final class org/jetbrains/jewel/markdown/extensions/github/tables/GitHubT
public static final field $stable I
public static final field INSTANCE Lorg/jetbrains/jewel/markdown/extensions/github/tables/GitHubTableProcessorExtension;
public fun getBlockProcessorExtension ()Lorg/jetbrains/jewel/markdown/extensions/MarkdownBlockProcessorExtension;
public fun getInlineProcessorExtension ()Lorg/jetbrains/jewel/markdown/extensions/MarkdownInlineProcessorExtension;
public fun getDelimitedInlineProcessorExtension ()Lorg/jetbrains/jewel/markdown/extensions/MarkdownDelimitedInlineProcessorExtension;
public fun getParserExtension ()Lorg/commonmark/parser/Parser$ParserExtension;
public fun getTextRendererExtension ()Lorg/commonmark/renderer/text/TextContentRenderer$TextContentRendererExtension;
}
@@ -66,7 +66,7 @@ public final class org/jetbrains/jewel/markdown/extensions/github/tables/GitHubT
public static final field $stable I
public fun <init> (Lorg/jetbrains/jewel/markdown/extensions/github/tables/GfmTableStyling;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling;)V
public fun getBlockRenderer ()Lorg/jetbrains/jewel/markdown/extensions/MarkdownBlockRendererExtension;
public fun getInlineRenderer ()Lorg/jetbrains/jewel/markdown/extensions/MarkdownInlineRendererExtension;
public fun getDelimitedInlineRenderer ()Lorg/jetbrains/jewel/markdown/extensions/MarkdownDelimitedInlineRendererExtension;
}
public final class org/jetbrains/jewel/markdown/extensions/github/tables/RowBackgroundStyle : java/lang/Enum {

View File

@@ -24,9 +24,15 @@ import org.jetbrains.jewel.markdown.extensions.MarkdownBlockRendererExtension
import org.jetbrains.jewel.markdown.extensions.MarkdownProcessorExtension
import org.jetbrains.jewel.markdown.extensions.MarkdownRendererExtension
import org.jetbrains.jewel.markdown.processing.MarkdownProcessor
import org.jetbrains.jewel.markdown.processing.readInlineContent
import org.jetbrains.jewel.markdown.processing.readInlineMarkdown
import org.jetbrains.jewel.markdown.rendering.MarkdownStyling
/**
* Adds support for table parsing. Tables are a GitHub Flavored Markdown extension, defined
* [in the GFM specs](https://github.github.com/gfm/#tables-extension-).
*
* @see TablesExtension
*/
@OptIn(ExperimentalJewelApi::class)
public object GitHubTableProcessorExtension : MarkdownProcessorExtension {
override val parserExtension: ParserExtension = GitHubTablesCommonMarkExtension
@@ -54,7 +60,7 @@ public object GitHubTableProcessorExtension : MarkdownProcessorExtension {
TableCell(
rowIndex = 0,
columnIndex = columnIndex,
content = cell.readInlineContent(processor),
content = cell.readInlineMarkdown(processor),
alignment = getAlignment(cell),
)
}
@@ -67,7 +73,7 @@ public object GitHubTableProcessorExtension : MarkdownProcessorExtension {
TableCell(
rowIndex = rowIndex + 1, // The header is row zero
columnIndex = columnIndex,
content = cell.readInlineContent(processor),
content = cell.readInlineMarkdown(processor),
alignment = getAlignment(cell),
)
},

View File

@@ -54,13 +54,12 @@ public class GfmTableStyling(
return result
}
override fun toString(): String {
return "GfmTableStyling(" +
override fun toString(): String =
"GfmTableStyling(" +
"colors=$colors, " +
"metrics=$metrics, " +
"headerBaseFontWeight=$headerBaseFontWeight" +
")"
}
public companion object
}
@@ -94,14 +93,13 @@ public class GfmTableColors(
return result
}
override fun toString(): String {
return "GfmTableColors(" +
override fun toString(): String =
"GfmTableColors(" +
"borderColor=$borderColor, " +
"rowBackgroundColor=$rowBackgroundColor, " +
"alternateRowBackgroundColor=$alternateRowBackgroundColor, " +
"rowBackgroundStyle=$rowBackgroundStyle" +
")"
}
public companion object
}

View File

@@ -1,3 +1,5 @@
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the
// Apache 2.0 license.
package org.jetbrains.jewel.intui.markdown.bridge
import androidx.compose.runtime.Composable
@@ -14,7 +16,6 @@ import org.jetbrains.jewel.foundation.theme.JewelTheme
import org.jetbrains.jewel.intui.markdown.bridge.styling.create
import org.jetbrains.jewel.markdown.MarkdownMode
import org.jetbrains.jewel.markdown.extensions.LocalMarkdownBlockRenderer
import org.jetbrains.jewel.markdown.extensions.LocalMarkdownMode
import org.jetbrains.jewel.markdown.extensions.LocalMarkdownProcessor
import org.jetbrains.jewel.markdown.extensions.LocalMarkdownStyling
import org.jetbrains.jewel.markdown.processing.MarkdownProcessor
@@ -35,7 +36,6 @@ public fun ProvideMarkdownStyling(
) {
CompositionLocalProvider(
LocalMarkdownStyling provides markdownStyling,
LocalMarkdownMode provides markdownMode,
LocalMarkdownProcessor provides markdownProcessor,
LocalMarkdownBlockRenderer provides markdownBlockRenderer,
LocalCodeHighlighter provides codeHighlighter,
@@ -50,7 +50,7 @@ public fun ProvideMarkdownStyling(
project: Project,
themeName: String = JewelTheme.name,
markdownStyling: MarkdownStyling = remember(themeName) { MarkdownStyling.create() },
markdownMode: MarkdownMode = remember { MarkdownMode.Standalone },
markdownMode: MarkdownMode = MarkdownMode.Standalone,
markdownProcessor: MarkdownProcessor = remember { MarkdownProcessor(markdownMode = markdownMode) },
markdownBlockRenderer: MarkdownBlockRenderer =
remember(markdownStyling) { MarkdownBlockRenderer.create(markdownStyling) },
@@ -61,7 +61,6 @@ public fun ProvideMarkdownStyling(
ProvideMarkdownStyling(
themeName = themeName,
markdownStyling = markdownStyling,
markdownMode = markdownMode,
markdownProcessor = markdownProcessor,
markdownBlockRenderer = markdownBlockRenderer,
codeHighlighter = codeHighlighter,

View File

@@ -1,3 +1,5 @@
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the
// Apache 2.0 license.
package org.jetbrains.jewel.intui.markdown.bridge.styling.extensions.github.alerts
import androidx.compose.foundation.layout.PaddingValues

View File

@@ -1,3 +1,5 @@
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the
// Apache 2.0 license.
package org.jetbrains.jewel.intui.markdown.standalone
import androidx.compose.runtime.Composable
@@ -12,7 +14,6 @@ import org.jetbrains.jewel.intui.markdown.standalone.styling.dark
import org.jetbrains.jewel.intui.markdown.standalone.styling.light
import org.jetbrains.jewel.markdown.MarkdownMode
import org.jetbrains.jewel.markdown.extensions.LocalMarkdownBlockRenderer
import org.jetbrains.jewel.markdown.extensions.LocalMarkdownMode
import org.jetbrains.jewel.markdown.extensions.LocalMarkdownProcessor
import org.jetbrains.jewel.markdown.extensions.LocalMarkdownStyling
import org.jetbrains.jewel.markdown.processing.MarkdownProcessor
@@ -31,8 +32,8 @@ public fun ProvideMarkdownStyling(
MarkdownStyling.light()
}
},
markdownMode: MarkdownMode = remember { MarkdownMode.Standalone },
markdownProcessor: MarkdownProcessor = remember { MarkdownProcessor() },
markdownMode: MarkdownMode = MarkdownMode.Standalone,
markdownProcessor: MarkdownProcessor = remember { MarkdownProcessor(markdownMode = markdownMode) },
markdownBlockRenderer: MarkdownBlockRenderer =
remember(markdownStyling) {
if (isDark) {
@@ -46,7 +47,6 @@ public fun ProvideMarkdownStyling(
) {
CompositionLocalProvider(
LocalMarkdownStyling provides markdownStyling,
LocalMarkdownMode provides markdownMode,
LocalMarkdownProcessor provides markdownProcessor,
LocalMarkdownBlockRenderer provides markdownBlockRenderer,
LocalCodeHighlighter provides codeHighlighter,
@@ -67,7 +67,6 @@ public fun ProvideMarkdownStyling(
) {
CompositionLocalProvider(
LocalMarkdownStyling provides markdownStyling,
LocalMarkdownMode provides markdownMode,
LocalMarkdownProcessor provides markdownProcessor,
LocalMarkdownBlockRenderer provides markdownBlockRenderer,
LocalCodeHighlighter provides codeHighlighter,

View File

@@ -6,6 +6,8 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import org.jetbrains.jewel.intui.standalone.theme.dark
import org.jetbrains.jewel.intui.standalone.theme.light
import org.jetbrains.jewel.markdown.extensions.github.tables.GfmTableColors
import org.jetbrains.jewel.markdown.extensions.github.tables.GfmTableMetrics
import org.jetbrains.jewel.markdown.extensions.github.tables.GfmTableStyling

View File

@@ -14,8 +14,9 @@ dependencies {
implementation(projects.intUi.intUiDecoratedWindow)
implementation(projects.markdown.intUiStandaloneStyling)
implementation(projects.markdown.extension.gfmAlerts)
implementation(projects.markdown.extension.autolink)
implementation(projects.markdown.extension.gfmStrikethrough)
implementation(projects.markdown.extension.gfmTables)
implementation(projects.markdown.extension.autolink)
implementation(compose.desktop.currentOs) { exclude(group = "org.jetbrains.compose.material") }
implementation(compose.components.resources)
implementation(project(":samples:showcase"))

View File

@@ -70,15 +70,20 @@
</SOURCES>
</library>
</orderEntry>
<orderEntry type="module" module-name="intellij.platform.jewel.markdown.extension.autolink" />
<orderEntry type="module" module-name="intellij.libraries.compose.foundation.desktop" />
<orderEntry type="module" module-name="intellij.libraries.skiko" />
<orderEntry type="module" module-name="intellij.platform.jewel.ui" />
<orderEntry type="module" module-name="intellij.platform.jewel.foundation" />
<orderEntry type="module" module-name="intellij.platform.jewel.intUi.decoratedWindow" />
<orderEntry type="module" module-name="intellij.libraries.skiko" />
<orderEntry type="module" module-name="intellij.platform.jewel.decoratedWindow" />
<orderEntry type="module" module-name="intellij.platform.jewel.markdown.intUiStandaloneStyling" />
<orderEntry type="module" module-name="intellij.platform.jewel.intUi.decoratedWindow" />
<orderEntry type="module" module-name="intellij.platform.jewel.intUi.standalone" />
<orderEntry type="module" module-name="intellij.platform.jewel.markdown.core" />
<orderEntry type="module" module-name="intellij.platform.jewel.markdown.extension.autolink" />
<orderEntry type="module" module-name="intellij.platform.jewel.markdown.extension.gfmAlerts" />
<orderEntry type="module" module-name="intellij.platform.jewel.markdown.extension.gfmStrikethrough" />
<orderEntry type="module" module-name="intellij.platform.jewel.markdown.extension.gfmTables" />
<orderEntry type="module" module-name="intellij.platform.jewel.markdown.intUiStandaloneStyling" />
<orderEntry type="module" module-name="intellij.platform.jewel.samples.showcase" />
<orderEntry type="library" scope="RUNTIME" name="jna" level="project" />
<orderEntry type="module-library" scope="RUNTIME">
<library name="org.lwjgl.lwjgl" type="repository">
@@ -134,9 +139,5 @@
</SOURCES>
</library>
</orderEntry>
<orderEntry type="module" module-name="intellij.platform.jewel.intUi.standalone" />
<orderEntry type="module" module-name="intellij.libraries.compose.foundation.desktop" />
<orderEntry type="module" module-name="intellij.platform.jewel.samples.showcase" />
<orderEntry type="module" module-name="intellij.platform.jewel.markdown.extension.gfmTables" />
</component>
</module>

View File

@@ -33,6 +33,8 @@ 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.github.strikethrough.GitHubStrikethroughProcessorExtension
import org.jetbrains.jewel.markdown.extensions.github.strikethrough.GitHubStrikethroughRendererExtension
import org.jetbrains.jewel.markdown.extensions.github.tables.GfmTableStyling
import org.jetbrains.jewel.markdown.extensions.github.tables.GitHubTableProcessorExtension
import org.jetbrains.jewel.markdown.extensions.github.tables.GitHubTableRendererExtension
@@ -55,7 +57,12 @@ public fun MarkdownPreview(modifier: Modifier = Modifier, rawMarkdown: CharSeque
// potentially involving ViewModels, dependency injection, etc.
val processor = remember {
MarkdownProcessor(
listOf(GitHubAlertProcessorExtension, AutolinkProcessorExtension, GitHubTableProcessorExtension)
listOf(
AutolinkProcessorExtension,
GitHubAlertProcessorExtension,
GitHubStrikethroughProcessorExtension(),
GitHubTableProcessorExtension,
)
)
}
@@ -71,19 +78,21 @@ public fun MarkdownPreview(modifier: Modifier = Modifier, rawMarkdown: CharSeque
remember(markdownStyling) {
if (isDark) {
MarkdownBlockRenderer.dark(
styling = MarkdownStyling.dark(),
styling = markdownStyling,
rendererExtensions =
listOf(
GitHubAlertRendererExtension(AlertStyling.dark(), MarkdownStyling.dark()),
GitHubAlertRendererExtension(AlertStyling.dark(), markdownStyling),
GitHubStrikethroughRendererExtension,
GitHubTableRendererExtension(GfmTableStyling.dark(), markdownStyling),
),
)
} else {
MarkdownBlockRenderer.light(
styling = MarkdownStyling.light(),
styling = markdownStyling,
rendererExtensions =
listOf(
GitHubAlertRendererExtension(AlertStyling.light(), MarkdownStyling.light()),
GitHubAlertRendererExtension(AlertStyling.light(), markdownStyling),
GitHubStrikethroughRendererExtension,
GitHubTableRendererExtension(GfmTableStyling.light(), markdownStyling),
),
)
@@ -103,8 +112,10 @@ public fun MarkdownPreview(modifier: Modifier = Modifier, rawMarkdown: CharSeque
PaddingValues(start = 8.dp, top = 8.dp, end = 8.dp + scrollbarContentSafePadding(), bottom = 8.dp),
state = lazyListState,
selectable = true,
onUrlClick = { url -> Desktop.getDesktop().browse(URI.create(url)) },
onUrlClick = onUrlClick(),
)
}
}
}
private fun onUrlClick(): (String) -> Unit = { url -> Desktop.getDesktop().browse(URI.create(url)) }

View File

@@ -12,9 +12,7 @@ pluginManagement {
gradlePluginPortal()
mavenCentral()
}
plugins {
kotlin("jvm") version "2.1.0"
}
plugins { kotlin("jvm") version "2.1.0" }
}
dependencyResolutionManagement {
@@ -45,6 +43,7 @@ include(
":markdown:core",
":markdown:extension:autolink",
":markdown:extension:gfm-alerts",
":markdown:extension:gfm-strikethrough",
":markdown:extension:gfm-tables",
":markdown:int-ui-standalone-styling",
":markdown:ide-laf-bridge-styling",
@@ -52,7 +51,7 @@ include(
":samples:showcase",
":samples:standalone",
":ui",
":ui-test",
":ui-tests",
)
gradleEnterprise {
@@ -67,22 +66,22 @@ val isWindows
get() = System.getProperty("os.name").contains("win", true)
val gradleCommand: String by
lazy(LazyThreadSafetyMode.NONE) {
val gradlewFilename =
if (isWindows) {
"gradlew.bat"
} else {
"gradlew"
}
lazy(LazyThreadSafetyMode.NONE) {
val gradlewFilename =
if (isWindows) {
"gradlew.bat"
} else {
"gradlew"
}
val gradlew = File(rootProject.projectDir, gradlewFilename)
if (gradlew.exists() && gradlew.isFile && gradlew.canExecute()) {
logger.info("Using gradlew wrapper at ${gradlew.invariantSeparatorsPath}")
gradlew.invariantSeparatorsPath
} else {
"gradle"
val gradlew = File(rootProject.projectDir, gradlewFilename)
if (gradlew.exists() && gradlew.isFile && gradlew.canExecute()) {
logger.info("Using gradlew wrapper at ${gradlew.invariantSeparatorsPath}")
gradlew.invariantSeparatorsPath
} else {
"gradle"
}
}
}
val shebang = if (isWindows) "" else "#!/bin/sh"
@@ -94,13 +93,18 @@ gitHooks {
// language=Shell Script
"""
|#### Note: this hook was autogenerated. You can edit it in settings.gradle.kts
|GRADLEW=$gradleCommand
|OLD_DIR=$(pwd)
|cd ${rootDir.absolutePath}
|GRADLEW=./gradlew
|if ! ${'$'}GRADLEW ktfmtCheck ; then
| ${'$'}GRADLEW ktfmtFormat
| echo 1>&2 "\nktfmt found problems; commit the result and re-push"
| cd ${'$'}OLD_DIR
| exit 1
|fi
|
|cd ${'$'}OLD_DIR
|
"""
.trimMargin()
}

View File

@@ -8,7 +8,7 @@ import org.jetbrains.annotations.ApiStatus
* otherwise.
*/
@Deprecated(
message = "This modifier has been moved to org.jetbrains.jewel.foundation.util. Please update your imports.",
message = "This modifier has been moved to org.jetbrains.jewel.foundation.modifier. Please update your imports.",
ReplaceWith("thenIf(precondition, action)", "org.jetbrains.jewel.foundation.modifier.thenIf"),
)
@ApiStatus.ScheduledForRemoval(inVersion = "2025.2")