MarkdownText - Jetpack Compose

- Markdown - HTML - Image - Highlight - Linkfy - Table ## Setup Configure root `build.gradle`: ``` allprojects { repositories { ... maven { url 'https://jitpack.io' } } } ``` Add dependency into `build.gradle`: ```groovy dependencies { implementation 'com.github.jeziellago:compose-markdown:TAG' } ```

Supported attributes

Most of the attributes of that a default Text composable has are also supported by MarkdownText.

  • color
  • fontSize
  • textAlign
  • maxLines
  • style (only styling for supported attributes is applied)

The font can be changed by passing a font xml resource as fontResource parameter.

How to use

val markdown = """  
	# Sample  
	* Markdown  
	* [Link](https://example.com)  
	![Image](https://example.com/img.png)  
	<a href="https://www.google.com/">Google</a>  
"""

//Minimal example
@Composable  
fun MinimalExampleContent() {  
    MarkdownText(markdown = markdownContent)  
} 

//Complex example
@Composable  
fun ComplexExampleContent() {  
     MarkdownText(
                modifier = Modifier.padding(8.dp),
                markdown = markdown,
                textAlign = TextAlign.Center,
                fontSize = 12.sp,
                color = LocalContentColor.current,
                maxLines = 3,
                fontResource = R.font.montserrat_medium,
                style = MaterialTheme.typography.overline,
              
     )  
}  

GitHub

https://github.com/jeziellago/compose-markdown