https://github.com/ralphpina/markdownparser
Kotlin Multiplatform Markdown parser with support for bold, underline, italics, and hyperlinks.
https://github.com/ralphpina/markdownparser
android ios kotlin multiplatform multiplatform-kotlin-library
Last synced: 3 months ago
JSON representation
Kotlin Multiplatform Markdown parser with support for bold, underline, italics, and hyperlinks.
- Host: GitHub
- URL: https://github.com/ralphpina/markdownparser
- Owner: ralphpina
- License: mit
- Created: 2021-03-26T03:17:16.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-03-26T17:11:27.000Z (about 4 years ago)
- Last Synced: 2025-02-05T21:02:19.041Z (5 months ago)
- Topics: android, ios, kotlin, multiplatform, multiplatform-kotlin-library
- Language: Kotlin
- Homepage:
- Size: 283 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
MarkdownParser
---This is a simple POC to parse a subset of markdown and render it in Android and iOS.
### Supported Markdown Styles
This POC tries to handle the following markdown styles:
- bold: `**bold**`
- underline: `__underline__`
- italic: `_italic_`
- hyperlink: `[link text](http://google.com)`### Shared
- [MarkdownParser.kt](/shared/src/commonMain/kotlin/net/ralphpina/markdownparser/shared/MarkdownParser.kt): exposes a parse() method that returns the copy and a list of entities.### Android
- [AndroidMarkdownRenderer.kt](/androidApp/src/main/java/net/ralphpina/markdownparser/androidApp/AndroidMarkdownRenderer.kt): exposes a couple of extension methods to add markdown to a `TextView` and `Button`.### iOS
- TODO: we need to implement this, probably using [NSAttributedString or UIFont](https://stackoverflow.com/questions/25025779/setting-uilabel-text-to-bold). I need to explore this.- We welcome contributions :)
### Example
Thus, the following copy:
```kotlin
val markdown = "Some text is **bold**. While some text is _italic_. Other is __underlined__. Lastly we have [link](http://google.com)."
```Used like so in **Android**:
```kotlin
val textView = findViewById(R.id.text_view)
val button = findViewById(R.id.button)
textView.renderMarkdown(markdown)
button.renderMarkdown(markdown)
```Is rendered like so:
