Skip to content

Commit 912f976

Browse files
authored
Merge pull request #46 from mikepenz/develop
dev -> main
2 parents fb5e889 + 07d60f4 commit 912f976

File tree

8 files changed

+79
-23
lines changed

8 files changed

+79
-23
lines changed

.github/workflows/ci.yml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,18 @@ jobs:
2020

2121
steps:
2222
- name: Checkout the repo
23-
uses: actions/checkout@v2
23+
uses: actions/checkout@v3
2424

25-
- uses: actions/setup-java@v2
25+
- uses: actions/setup-java@v3
2626
with:
27-
distribution: 'adopt'
28-
java-version: '15'
27+
distribution: 'temurin'
28+
java-version: '17'
2929

3030
- name: Copy CI gradle.properties
3131
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties
3232

3333
- name: Checkout Gradle Build Cache
34-
uses: actions/cache@v2
34+
uses: actions/cache@v3
3535
with:
3636
path: |
3737
~/.gradle/caches
@@ -74,14 +74,14 @@ jobs:
7474
runs-on: macos-latest
7575
steps:
7676
- name: Checkout
77-
uses: actions/checkout@v2
77+
uses: actions/checkout@v3
7878
with:
7979
fetch-depth: 100
8080

81-
- uses: actions/setup-java@v2
81+
- uses: actions/setup-java@v3
8282
with:
83-
distribution: 'adopt'
84-
java-version: '15'
83+
distribution: 'temurin'
84+
java-version: '17'
8585

8686
- name: Validate gradle wrapper
8787
uses: gradle/wrapper-validation-action@v1
@@ -90,7 +90,7 @@ jobs:
9090
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties
9191

9292
- name: Checkout Gradle Build Cache
93-
uses: actions/cache@v2
93+
uses: actions/cache@v3
9494
with:
9595
path: |
9696
~/.gradle/caches
@@ -149,14 +149,14 @@ jobs:
149149
find . -name "*release.aab" -type f -exec cp {} "artifacts" \;
150150
151151
- name: Archive Artifacts
152-
uses: actions/upload-artifact@v2
152+
uses: actions/upload-artifact@v3
153153
with:
154154
name: "App-Artifacts"
155155
path: artifacts/*
156156

157157
- name: Build Changelog
158158
id: github_release
159-
uses: mikepenz/release-changelog-builder-action@v2
159+
uses: mikepenz/release-changelog-builder-action@v3
160160
if: startsWith(github.ref, 'refs/tags/')
161161
with:
162162
configuration: ".github/config/configuration.json"

README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,38 @@ val markdown = """
9292
Markdown(markdown)
9393
```
9494

95+
<details><summary><b>Advanced Usage</b></summary>
96+
<p>
97+
98+
The library offers the ability to modify different behaviour when rendering the markdown.
99+
100+
### Provided custom style
101+
102+
```kotlin
103+
Markdown(
104+
content,
105+
colors = MarkdownDefaults.markdownColors(textColor = Color.Red),
106+
typography = MarkdownDefaults.markdownTypography(h1 = MaterialTheme.typography.body1)
107+
)
108+
```
109+
110+
### Adjust List Ordering
111+
112+
```kotlin
113+
// Use the bullet list symbol from the original markdown
114+
CompositionLocalProvider(LocalBulletListHandler provides { "$it " }) {
115+
Markdown(content)
116+
}
117+
118+
// Replace the ordered list symbol with `A.)` instead.
119+
CompositionLocalProvider(LocalOrderedListHandler provides { "A.) " }) {
120+
Markdown(content, Modifier.fillMaxSize().padding(16.dp).verticalScroll(scrollState))
121+
}
122+
```
123+
124+
</p>
125+
</details>
126+
95127
## Dependency
96128

97129
This project uses JetBrains [markdown](https://github.com/JetBrains/markdown/) Multiplatform Markdown processor as dependency to parse the markdown content.

build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ buildscript {
1313
classpath("com.vanniktech:gradle-maven-publish-plugin:0.18.0")
1414
classpath("io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.19.0")
1515
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10")
16-
classpath("org.jetbrains.dokka:dokka-gradle-plugin:1.6.10")
17-
classpath("com.mikepenz.aboutlibraries.plugin:aboutlibraries-plugin:10.1.0")
16+
classpath("org.jetbrains.dokka:dokka-gradle-plugin:1.6.21")
17+
classpath("com.mikepenz.aboutlibraries.plugin:aboutlibraries-plugin:10.2.0")
1818
classpath("org.jetbrains.compose:compose-gradle-plugin:1.1.1")
1919
}
2020
}

buildSrc/src/main/java/Dependencies.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ object Versions {
77

88
const val markdown = "0.3.1"
99

10-
const val coil = "2.0.0"
10+
const val coil = "2.1.0"
1111
const val compose = "1.1.1"
1212
const val composeCompiler = "1.1.1"
1313

14-
const val material = "1.5.0"
14+
const val material = "1.6.0"
1515
const val activityCompose = "1.4.0"
1616
const val lifecycleKtx = "2.3.1"
1717
}

gradle.properties

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Maven stuff
22
GROUP=com.mikepenz
3-
VERSION_NAME=0.5.0
4-
VERSION_CODE=500
3+
VERSION_NAME=0.6.0
4+
VERSION_CODE=600
55

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

@@ -14,7 +14,7 @@ POM_GITHUB_REPO=mikepenz/multiplatform-markdown-renderer
1414
POM_GITHUB_README=README.md
1515

1616
POM_LICENCE_NAME=Apache-2.0
17-
POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt
17+
POM_LICENCE_URL=https://www.apache.org/licenses/LICENSE-2.0.txt
1818
POM_LICENCE_DIST=repo
1919

2020
SONATYPE_HOST=S01

multiplatform-markdown-renderer/src/commonMain/kotlin/com/mikepenz/markdown/Markdown.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,9 +352,10 @@ private fun MarkdownBulletList(
352352
style: TextStyle = LocalTextStyle.current,
353353
level: Int = 0
354354
) {
355+
val bulletHandler = LocalBulletListHandler.current
355356
MarkdownListItems(content, node, modifier, colors, style, level) { child ->
356357
Row(Modifier.fillMaxWidth()) {
357-
Text("${child.findChildOfType(MarkdownTokenTypes.LIST_BULLET)?.getTextInNode(content)} ")
358+
Text(bulletHandler.transform(child.findChildOfType(MarkdownTokenTypes.LIST_BULLET)?.getTextInNode(content)), style = style, color = colors.textColorByType(MarkdownTokenTypes.LIST_BULLET))
358359
val text = buildAnnotatedString {
359360
pushStyle(style.toSpanStyle())
360361
buildMarkdownAnnotatedString(content, child.children.filterNonListTypes(), colors)
@@ -374,9 +375,10 @@ private fun MarkdownOrderedList(
374375
style: TextStyle = LocalTextStyle.current,
375376
level: Int = 0,
376377
) {
378+
val orderedListHandler = LocalOrderedListHandler.current
377379
MarkdownListItems(content, node, modifier, colors, style, level) { child ->
378380
Row(Modifier.fillMaxWidth()) {
379-
Text("${child.findChildOfType(MarkdownTokenTypes.LIST_NUMBER)?.getTextInNode(content)} ")
381+
Text(orderedListHandler.transform(child.findChildOfType(MarkdownTokenTypes.LIST_NUMBER)?.getTextInNode(content)), style = style, color = colors.textColorByType(MarkdownTokenTypes.LIST_NUMBER))
380382
val text = buildAnnotatedString {
381383
pushStyle(style.toSpanStyle())
382384
buildMarkdownAnnotatedString(content, child.children.filterNonListTypes(), colors)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.mikepenz.markdown
2+
3+
import androidx.compose.runtime.staticCompositionLocalOf
4+
5+
/**
6+
* The CompositionLocal to provide functionality related to transforming the bullet of an ordered list
7+
*/
8+
val LocalBulletListHandler = staticCompositionLocalOf {
9+
return@staticCompositionLocalOf BulletHandler { "" }
10+
}
11+
12+
/**
13+
* The CompositionLocal to provide functionality related to transforming the bullet of an ordered list
14+
*/
15+
val LocalOrderedListHandler = staticCompositionLocalOf {
16+
return@staticCompositionLocalOf BulletHandler { "$it " }
17+
}
18+
19+
20+
/** An interface of providing use case specific un/ordered list handling.*/
21+
fun interface BulletHandler {
22+
/** Transforms the bullet icon */
23+
fun transform(bullet: CharSequence?): String
24+
}

multiplatform-markdown-renderer/src/commonMain/kotlin/com/mikepenz/markdown/MarkdownDefaults.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ private class DefaultMarkdownColors(
8080
}
8181
}
8282

83-
8483
/**
8584
* Represents the type scale for the [Markdown].
8685
*
@@ -98,7 +97,6 @@ interface MarkdownTypography {
9897
val body2: TextStyle
9998
}
10099

101-
102100
@Immutable
103101
private class DefaultMarkdownTypography(
104102
override val h1: TextStyle,

0 commit comments

Comments
 (0)