
Render Markdown into native Compose UI with full GFM support, streaming asynchronous parsing, Material 2/3 theming, overridable components, syntax highlighting, image loading, and performance optimizations.
[!CAUTION]
注意:本库是本作者个人私库(不公开分享本库,不建议他人使用),如果想使用本库可以在项目中使用依赖库或克隆分支(可以自己新建一个分支修改本库,不可提交到本库),请不要上传提交,请勿私自外传本项目。
| 🧩 每个平台 | 通过一个 commonMain 调用即可覆盖 Android、iOS、桌面(JVM)、网页(Wasm / JS)和 macOS。 |
| ⚡ 默认异步 |
rememberMarkdownState 会解析组合;retainState = true 会在重新解析时保持内容可见。 |
| 🎨 Material 2 和 3 |
-m2 / -m3 的主题默认值;可通过 markdownColor() 和 markdownTypography() 覆盖。 |
| 🧱 每个元素都可以被重写 |
MarkdownComponents 将每个 AST 节点映射到你控制的 @Composable。 |
| 📊 完整 GFM | 表格、任务列表、删除线、自动链接和 GitHub 提示,开箱即用。 |
| 📡 为流媒体而生 |
rememberStreamingMarkdownState() 会追加数据块并只重新解析不稳定的尾部。 |
1 — 添加依赖。 选择与你的 Material 主题匹配的模块:
// 在项目的 build.gradle.kts 文件中添加依赖项
kotlin {
sourceSets {
// 多平台,
commonMain.dependencies {
// 如果使用多平台 Jetpack Compose Multiplatform 项目,请添加以下依赖项
implementation("io.github.dxycw:markdown-renderer:1.0.0")
}
}
}
2 — 渲染。 从 com.mikepenz.markdown.m3(或 .m2)导入 Markdown:
import com.mikepenz.markdown.m3.Markdown
Markdown(
"""
# Hello Markdown
- Bullet points
- **Bold** and *italic* text
[Check out this link](https://github.com/dxycw/markdown-renderer)
""".trimIndent()
)3 — 对任何复杂的内容都提升解析。 rememberMarkdownState 是异步解析的,并且在重新组合时仍然存在:
val markdownState = rememberMarkdownState(markdown)
Markdown(markdownState)这个库使用了以下主要依赖:
Copyright 2026 Mike Penz
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
[!CAUTION]
注意:本库是本作者个人私库(不公开分享本库,不建议他人使用),如果想使用本库可以在项目中使用依赖库或克隆分支(可以自己新建一个分支修改本库,不可提交到本库),请不要上传提交,请勿私自外传本项目。
| 🧩 每个平台 | 通过一个 commonMain 调用即可覆盖 Android、iOS、桌面(JVM)、网页(Wasm / JS)和 macOS。 |
| ⚡ 默认异步 |
rememberMarkdownState 会解析组合;retainState = true 会在重新解析时保持内容可见。 |
| 🎨 Material 2 和 3 |
-m2 / -m3 的主题默认值;可通过 markdownColor() 和 markdownTypography() 覆盖。 |
| 🧱 每个元素都可以被重写 |
MarkdownComponents 将每个 AST 节点映射到你控制的 @Composable。 |
| 📊 完整 GFM | 表格、任务列表、删除线、自动链接和 GitHub 提示,开箱即用。 |
| 📡 为流媒体而生 |
rememberStreamingMarkdownState() 会追加数据块并只重新解析不稳定的尾部。 |
1 — 添加依赖。 选择与你的 Material 主题匹配的模块:
// 在项目的 build.gradle.kts 文件中添加依赖项
kotlin {
sourceSets {
// 多平台,
commonMain.dependencies {
// 如果使用多平台 Jetpack Compose Multiplatform 项目,请添加以下依赖项
implementation("io.github.dxycw:markdown-renderer:1.0.0")
}
}
}
2 — 渲染。 从 com.mikepenz.markdown.m3(或 .m2)导入 Markdown:
import com.mikepenz.markdown.m3.Markdown
Markdown(
"""
# Hello Markdown
- Bullet points
- **Bold** and *italic* text
[Check out this link](https://github.com/dxycw/markdown-renderer)
""".trimIndent()
)3 — 对任何复杂的内容都提升解析。 rememberMarkdownState 是异步解析的,并且在重新组合时仍然存在:
val markdownState = rememberMarkdownState(markdown)
Markdown(markdownState)这个库使用了以下主要依赖:
Copyright 2026 Mike Penz
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.