Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev -> main #229

Merged
merged 45 commits into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
022d4c4
- introduce a new module with syntax highlighting support
mikepenz Sep 6, 2024
35587a9
- add new default and functions to define the highlighted code block
mikepenz Sep 6, 2024
68c4a07
- add documentation on syntax highlighting to README
mikepenz Sep 6, 2024
6caf007
- fetch dark theme prior to builder
mikepenz Sep 6, 2024
62da0ff
- update to AGP 8.6.0
mikepenz Sep 6, 2024
134cc80
Merge pull request #206 from mikepenz/feature/124
mikepenz Sep 6, 2024
0f0928f
Merge pull request #207 from mikepenz/feature/upgrade_dependencies_20…
mikepenz Sep 6, 2024
c49ee96
Merge remote-tracking branch 'origin/release/0.26.0' into develop
mikepenz Sep 6, 2024
beb6d21
- [release] v0.27.0-b01
mikepenz Sep 6, 2024
6b71b6c
- upgrade dependencies to latest releases
mikepenz Sep 16, 2024
33f2e2f
- revert gradle
mikepenz Sep 16, 2024
adb27b0
- include `code` module in release
mikepenz Sep 16, 2024
bd6e68c
Merge pull request #209 from mikepenz/feature/upgrade_dependencies_20…
mikepenz Sep 16, 2024
0653327
Merge pull request #210 from mikepenz/fix/ci_for_code_module
mikepenz Sep 16, 2024
6a81040
- [release] v0.27.0-b02
mikepenz Sep 16, 2024
02dac3a
Making use of EntityConverter to unescape text of leaf nodes
sroebert Sep 27, 2024
7141786
make link text spanStyle configurable via the `MarkdownTypography` class
aegis123 Oct 9, 2024
9da4010
resolved comments
aegis123 Oct 9, 2024
42a2521
Update README.md
aegis123 Oct 9, 2024
a763a48
cleaned up unused imports
aegis123 Oct 9, 2024
37906fd
- small fixes
mikepenz Oct 10, 2024
5ae7314
Merge branch 'aegis123-update-readme-custom-components' into develop
mikepenz Oct 10, 2024
16b92fd
Merge pull request #217 from aegis123/feature/custom-link-spanstyle
mikepenz Oct 10, 2024
e16bd4d
Merge branch 'bugfix/unescape-leaf-node-text' of https://github.com/s…
mikepenz Oct 10, 2024
797b74c
- add named arguments
mikepenz Oct 10, 2024
591dfb3
Merge branch 'sroebert-bugfix/unescape-leaf-node-text' into develop
mikepenz Oct 10, 2024
29e09c3
- upgrade dependencies to Compose-MP 1.7.0-rc01
mikepenz Oct 10, 2024
741663c
- apply the defined code TextStyle to spannable strings
mikepenz Oct 10, 2024
a1e8116
- offer new typography input for inline code
mikepenz Oct 10, 2024
e676d74
Merge pull request #219 from mikepenz/fix/use_defined_code_style
mikepenz Oct 10, 2024
c96c366
Merge pull request #220 from mikepenz/feature/dependency_updates_2024…
mikepenz Oct 10, 2024
4c2fedb
- [release] v0.27.0-rc01
mikepenz Oct 10, 2024
2b2b676
fix getUnescapedText error
keta1 Oct 12, 2024
124e9cf
- simplify entity converter further
mikepenz Oct 13, 2024
afe4d2a
Merge branch 'keta1-develop' into develop
mikepenz Oct 13, 2024
42d5564
- [release] v0.27.0-rc02
mikepenz Oct 13, 2024
618b3e3
Bump rexml from 3.2.8 to 3.3.9
dependabot[bot] Oct 28, 2024
f998fa7
- adjust minAPI to 24 for sample app
mikepenz Nov 1, 2024
9c8a500
Merge pull request #225 from mikepenz/dependabot/bundler/rexml-3.3.9
mikepenz Nov 1, 2024
810a90a
- add ability to disable the animation for the placeholder via the Im…
mikepenz Nov 1, 2024
76c72af
Merge pull request #226 from mikepenz/note/223
mikepenz Nov 1, 2024
9fc62f7
Merge pull request #227 from mikepenz/fix/212
mikepenz Nov 1, 2024
859f7bb
- upgrade dependencies to latest major version
mikepenz Nov 1, 2024
cb46194
Merge pull request #228 from mikepenz/feature/upgrade_dependencies_20…
mikepenz Nov 1, 2024
fb4bb52
- [release] v0.27.0
mikepenz Nov 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ jobs:
./gradlew multiplatform-markdown-renderer-m3:publishAllPublicationsToMavenCentralRepository --no-daemon --no-configure-on-demand --no-parallel
./gradlew multiplatform-markdown-renderer-coil2:publishAllPublicationsToMavenCentralRepository --no-daemon --no-configure-on-demand --no-parallel
./gradlew multiplatform-markdown-renderer-coil3:publishAllPublicationsToMavenCentralRepository --no-daemon --no-configure-on-demand --no-parallel
./gradlew multiplatform-markdown-renderer-code:publishAllPublicationsToMavenCentralRepository --no-daemon --no-configure-on-demand --no-parallel

build:
name: Build
Expand Down
4 changes: 1 addition & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,14 @@ GEM
open4 (1.3.4)
public_suffix (5.0.3)
rchardet (1.8.0)
rexml (3.2.8)
strscan (>= 3.0.9)
rexml (3.3.9)
ruby-ll (2.1.3)
ansi
ast
ruby2_keywords (0.0.5)
sawyer (0.9.2)
addressable (>= 2.3.5)
faraday (>= 0.17.3, < 3)
strscan (3.1.0)
terminal-table (3.0.2)
unicode-display_width (>= 1.1.1, < 3)
unicode-display_width (2.4.2)
Expand Down
75 changes: 74 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,42 @@ Markdown(
paragraph = customParagraphComponent
)
)
```

Another example to of a custom component is changing the rendering of an unordered list.

```kotlin
// Define a custom component for rendering unordered list items in Markdown
val customUnorderedListComponent: MarkdownComponent = {
// Use the MarkdownListItems composable to render the list items
MarkdownListItems(it.content, it.node, level = 0) { index, child ->
// Create a row layout for each list item with spacing between elements
Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(8.dp)) {
// Render an icon for the bullet point with a green tint
Icon(
imageVector = icon,
tint = Color.Green,
contentDescription = null,
modifier = Modifier.size(20.dp),
)
// Extract the bullet marker text from the child node
val bulletMarker: String = child.findChildOfType(MarkdownTokenTypes.LIST_BULLET)?.getTextInNode(it.content).toString()
// Extract the item text and remove the bullet marker from it
val itemText = child.getTextInNode(it.content).toString().replace(bulletMarker, "")

// Render the item text using the MarkdownText composable
MarkdownText(content = itemText)
}
}
}

// Define the `Markdown` composable and pass in the custom unorderedList component
Markdown(
content,
components = markdownComponents(
unorderedList = customUnorderedListComponent
)
)
```

</p>
Expand All @@ -251,7 +286,8 @@ Markdown(
```

> [!NOTE]
> 0.21.0 adds JVM support for this dependency via `HTTPUrlConnection` -> however this is expected to be removed in the future.
> 0.21.0 adds JVM support for this dependency via `HTTPUrlConnection` -> however this is expected to be removed in the
> future.

> [!NOTE]
> Please refer to the official coil2 documentation on how to adjust the `ImageLoader`
Expand All @@ -276,6 +312,43 @@ Markdown(
> [!NOTE]
> The `coil3` module does depend on SNAPSHOT builds of coil3

### Syntax Highlighting

The library (introduced with 0.27.0) offers optional support for syntax highlighting via
the [Highlights](https://github.com/SnipMeDev/Highlights) project.
This support is not included in the core, and can be enabled by adding the `multiplatform-markdown-renderer-code`
dependency.

```groovy
implementation("com.mikepenz:multiplatform-markdown-renderer-code:${version}")
```

Once added, the `Markdown` has to be configured to use the alternative code highlighter.

```kotlin
// Use default color scheme
Markdown(
MARKDOWN,
components = markdownComponents(
codeBlock = highlightedCodeBlock,
codeFence = highlightedCodeFence,
)
)

// ADVANCED: Customize Highlights library by defining different theme
val isDarkTheme = isSystemInDarkTheme()
val highlightsBuilder = remember(isDarkTheme) {
Highlights.Builder().theme(SyntaxThemes.atom(darkMode = isDarkTheme))
}
Markdown(
MARKDOWN,
components = markdownComponents(
codeBlock = { MarkdownHighlightedCodeBlock(it.content, it.node, highlightsBuilder) },
codeFence = { MarkdownHighlightedCodeFence(it.content, it.node, highlightsBuilder) },
)
)
```

## Dependency

This project uses JetBrains [markdown](https://github.com/JetBrains/markdown/) Multiplatform
Expand Down
1 change: 1 addition & 0 deletions app-desktop/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ dependencies {
implementation(projects.multiplatformMarkdownRenderer)
implementation(projects.multiplatformMarkdownRendererM2)
implementation(projects.multiplatformMarkdownRendererCoil3)
implementation(projects.multiplatformMarkdownRendererCode)

implementation(compose.desktop.currentOs)
implementation(compose.foundation)
Expand Down
16 changes: 15 additions & 1 deletion app-desktop/src/main/kotlin/main.kt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
Expand All @@ -11,12 +12,17 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Window
import androidx.compose.ui.window.application
import com.mikepenz.markdown.coil3.Coil3ImageTransformerImpl
import com.mikepenz.markdown.compose.components.markdownComponents
import com.mikepenz.markdown.compose.elements.MarkdownHighlightedCodeBlock
import com.mikepenz.markdown.compose.elements.MarkdownHighlightedCodeFence
import com.mikepenz.markdown.compose.extendedspans.ExtendedSpans
import com.mikepenz.markdown.compose.extendedspans.RoundedCornerSpanPainter
import com.mikepenz.markdown.compose.extendedspans.SquigglyUnderlineSpanPainter
import com.mikepenz.markdown.compose.extendedspans.rememberSquigglyUnderlineAnimator
import com.mikepenz.markdown.m2.Markdown
import com.mikepenz.markdown.model.markdownExtendedSpans
import dev.snipme.highlights.Highlights
import dev.snipme.highlights.model.SyntaxThemes

fun main() = application {
Window(onCloseRequest = ::exitApplication, title = "Markdown Sample") {
Expand All @@ -29,9 +35,17 @@ fun main() = application {
}
) {
val scrollState = rememberScrollState()
val isDarkTheme = isSystemInDarkTheme()
val highlightsBuilder = remember(isDarkTheme) {
Highlights.Builder().theme(SyntaxThemes.atom(darkMode = isDarkTheme))
}

Markdown(
MARKDOWN,
components = markdownComponents(
codeBlock = { MarkdownHighlightedCodeBlock(it.content, it.node, highlightsBuilder) },
codeFence = { MarkdownHighlightedCodeFence(it.content, it.node, highlightsBuilder) },
),
imageTransformer = Coil3ImageTransformerImpl,
extendedSpans = markdownExtendedSpans {
val animator = rememberSquigglyUnderlineAnimator()
Expand Down Expand Up @@ -76,7 +90,7 @@ This is a paragraph with a [link](https://www.jetbrains.com/).
This is a code block:
```kotlin
fun main() {
println("Hello, world!")
println("Hello, world!")
}
```

Expand Down
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ android {

defaultConfig {
applicationId = "com.mikepenz.markdown"
minSdk = libs.versions.minSdk.get().toInt()
minSdk = 24 // anything below faces: https://github.com/mikepenz/multiplatform-markdown-renderer/issues/223
targetSdk = libs.versions.targetSdk.get().toInt()

versionCode = property("VERSION_CODE").toString().toInt()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ private val MARKDOWN_DEFAULT = """

###### This is an H6

This is a paragraph with some *italic* and **bold** text.
This is a paragraph with some *italic* and **bold** text\.

This is a paragraph with some `inline code`.
This is a paragraph with some `inline code`\.

This is a paragraph with a [link](https://www.jetbrains.com/).
This is a paragraph with a [link](https://www.jetbrains.com/)\.

This is a code block:
```kotlin
Expand Down
5 changes: 3 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Maven stuff
GROUP=com.mikepenz
VERSION_NAME=0.26.0
VERSION_CODE=2600
VERSION_NAME=0.27.0
VERSION_CODE=2700

POM_URL=https://github.com/mikepenz/multiplatform-markdown-renderer

Expand Down Expand Up @@ -30,6 +30,7 @@ kotlin.js.compiler=both

kotlin.mpp.stability.nowarn=true
kotlin.mpp.androidSourceSetLayoutVersion=2
kotlin.suppressGradlePluginWarnings=IncorrectCompileOnlyDependencyWarning

org.jetbrains.compose.experimental.wasm.enabled=true
org.jetbrains.compose.experimental.uikit.enabled=true
Expand Down
26 changes: 14 additions & 12 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
[versions]
agp = "8.5.2"
agp = "8.7.2"
compileSdk = "34"
minSdk = "21"
targetSdk = "34"
androidx-activityCompose = "1.9.1"
androidx-activityCompose = "1.9.3"
androidx-material = "1.12.0"
compose = "1.6.8"
compose-plugin = "1.6.11"
kotlin = "2.0.20"
coroutines = "1.8.1"
dokka = "1.9.20"
coil = "3.0.0-alpha10"
compose = "1.7.5"
compose-plugin = "1.7.0"
kotlin = "2.0.21"
coroutines = "1.9.0"
dokka = "2.0.0-Beta"
coil = "3.0.0-rc02"
coil2 = "2.7.0"
aboutlib = "11.2.3"
markdown = "0.7.3"
detekt = "1.23.6"
gradleMvnPublish = "0.29.0"
screenshot = "0.0.1-alpha05"
ktor = "3.0.0-beta-2"
detekt = "1.23.7"
gradleMvnPublish = "0.30.0"
screenshot = "0.0.1-alpha07"
ktor = "3.0.1"
highlights = "0.9.3"

[libraries]
androidx-material = { group = "com.google.android.material", name = "material", version.ref = "androidx-material" }
Expand All @@ -39,6 +40,7 @@ markdown = { module = "org.jetbrains:markdown", version.ref = "markdown" }
kotlinx-coroutines-swing = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-swing", version.ref = "coroutines" }
ktor-client-core = { module = "io.ktor:ktor-client-core", version.ref = "ktor" }
ktor-client-java = { module = "io.ktor:ktor-client-java", version.ref = "ktor" }
highlights = { module = "dev.snipme:highlights", version.ref = "highlights" }

[plugins]
androidApplication = { id = "com.android.application", version.ref = "agp" }
Expand Down
1 change: 1 addition & 0 deletions multiplatform-markdown-renderer-code/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
Loading