Skip to content

Commit

Permalink
Merge pull request #139 from mikepenz/develop
Browse files Browse the repository at this point in the history
dev -> main
  • Loading branch information
mikepenz authored Apr 25, 2024
2 parents f0ad478 + bff40b1 commit 805ca85
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion compose-desktop/src/main/kotlin/main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fun main() = application {
}
```
You can find more information on [GitHub](https://github.com/mikepenz/multiplatform-markdown-renderer).
You can find more information on [GitHub](https://github.com/mikepenz/multiplatform-markdown-renderer). More Text after this.
![Image](https://avatars.githubusercontent.com/u/1476232?v=4)
Expand Down
4 changes: 2 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.14.0
VERSION_CODE=1400
VERSION_NAME=0.15.0
VERSION_CODE=1500

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ import com.mikepenz.markdown.model.MarkdownColors
fun markdownColor(
text: Color = MaterialTheme.colors.onBackground,
codeText: Color = MaterialTheme.colors.onBackground,
inlineCodeText: Color = codeText,
linkText: Color = text,
codeBackground: Color = MaterialTheme.colors.onBackground.copy(alpha = 0.1f),
inlineCodeBackground: Color = codeBackground,
dividerColor: Color = MaterialTheme.colors.onSurface.copy(alpha = 0.12f),
): MarkdownColors = DefaultMarkdownColors(
text = text,
codeText = codeText,
inlineCodeText = inlineCodeText,
linkText = linkText,
codeBackground = codeBackground,
inlineCodeBackground = inlineCodeBackground,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ import com.mikepenz.markdown.model.MarkdownColors
fun markdownColor(
text: Color = MaterialTheme.colorScheme.onBackground,
codeText: Color = MaterialTheme.colorScheme.onBackground,
inlineCodeText: Color = codeText,
linkText: Color = text,
codeBackground: Color = MaterialTheme.colorScheme.onBackground.copy(alpha = 0.1f),
inlineCodeBackground: Color = codeBackground,
dividerColor: Color = MaterialTheme.colorScheme.outlineVariant,
): MarkdownColors = DefaultMarkdownColors(
text = text,
codeText = codeText,
inlineCodeText = inlineCodeText,
linkText = linkText,
codeBackground = codeBackground,
inlineCodeBackground = inlineCodeBackground,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import com.mikepenz.markdown.compose.LocalMarkdownDimens
@Composable
fun MarkdownDivider(
modifier: Modifier = Modifier,
color: Color = LocalMarkdownColors.current.codeBackground,
color: Color = LocalMarkdownColors.current.dividerColor,
thickness: Dp = LocalMarkdownDimens.current.dividerThickness,
) {
val targetThickness = if (thickness == Dp.Hairline) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ interface MarkdownColors {
/** Represents the color used for the text of code. */
val codeText: Color

/** Represents the color used for the text of code. */
val inlineCodeText: Color

/** Represents the color used for the text of links. */
val linkText: Color

Expand All @@ -29,6 +32,7 @@ interface MarkdownColors {
class DefaultMarkdownColors(
override val text: Color,
override val codeText: Color,
override val inlineCodeText: Color,
override val linkText: Color,
override val codeBackground: Color,
override val inlineCodeBackground: Color,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import org.intellij.markdown.MarkdownTokenTypes.Companion.TEXT
import org.intellij.markdown.ast.ASTNode
import org.intellij.markdown.ast.findChildOfType
import org.intellij.markdown.ast.getTextInNode
import org.intellij.markdown.flavours.gfm.GFMElementTypes
import org.intellij.markdown.flavours.gfm.GFMTokenTypes

@Composable
Expand All @@ -30,6 +31,7 @@ internal fun AnnotatedString.Builder.appendMarkdownLink(content: String, node: A
pushStyle(SpanStyle(color = LocalMarkdownColors.current.linkText, textDecoration = TextDecoration.Underline, fontWeight = FontWeight.Bold))
buildMarkdownAnnotatedString(content, linkText)
pop()
pop()
}

internal fun AnnotatedString.Builder.appendAutoLink(content: String, node: ASTNode) {
Expand Down Expand Up @@ -84,8 +86,14 @@ fun AnnotatedString.Builder.buildMarkdownAnnotatedString(content: String, childr
pop()
}

GFMElementTypes.STRIKETHROUGH -> {
pushStyle(SpanStyle(textDecoration = TextDecoration.LineThrough))
buildMarkdownAnnotatedString(content, child)
pop()
}

MarkdownElementTypes.CODE_SPAN -> {
pushStyle(SpanStyle(fontFamily = FontFamily.Monospace, background = LocalMarkdownColors.current.inlineCodeBackground))
pushStyle(SpanStyle(fontFamily = FontFamily.Monospace, color = LocalMarkdownColors.current.inlineCodeText, background = LocalMarkdownColors.current.inlineCodeBackground))
append(' ')
buildMarkdownAnnotatedString(content, child.children.innerList())
append(' ')
Expand Down

0 comments on commit 805ca85

Please sign in to comment.