Skip to content

Commit

Permalink
Add readme for strikethrough extension
Browse files Browse the repository at this point in the history
  • Loading branch information
rock3r committed Jan 15, 2025
1 parent f798fc7 commit c94c946
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
Binary file added art/docs/gfm-strikethrough.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 41 additions & 0 deletions markdown/extension/gfm-strikethrough/README.md
Original file line number Diff line number Diff line change
@@ -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
}
```
4 changes: 4 additions & 0 deletions markdown/extension/gfm-strikethrough/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,7 @@ 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.*")
}

0 comments on commit c94c946

Please sign in to comment.