### Install Application using Bash Source: https://github.com/feiyin0719/composemarkdown/blob/master/app/src/main/assets/large_document.md Follow these bash commands to clone the repository, install dependencies, set up environment variables, and start the development server. ```bash git clone https://github.com/yourproject/app.git cd app ``` ```bash npm install # or yarn install ``` ```bash cp .env.example .env # Edit .env with your configuration ``` ```bash npm run dev ``` -------------------------------- ### Bash Project Setup and Database Commands Source: https://github.com/feiyin0719/composemarkdown/blob/master/app/src/main/assets/large_document.md A set of bash commands for cloning a project, installing dependencies, starting the server, and performing basic database operations. ```bash # [BASH SCRIPT BLOCK] Project Setup Commands git clone https://github.com/example/project.git cd project npm install npm start # Database operations createdb myproject_dev psql -d myproject_dev -f schema.sql ``` -------------------------------- ### Inline Code Example Source: https://github.com/feiyin0719/composemarkdown/blob/master/app/src/main/assets/large_document.md Demonstrates the use of inline code formatting for commands like `npm start`, `yarn dev`, and `npm run build`. ```text `npm start` or `yarn dev` ``` ```text `npm run build` ``` -------------------------------- ### Install Application with Git Source: https://github.com/feiyin0719/composemarkdown/blob/master/app/src/main/assets/large_document.md Use these commands to clone the repository and install dependencies for the application. Ensure Node.js 16+ is installed. ```bash git clone https://github.com/yourproject/app.git cd app npm install ``` ```bash yarn install ``` ```bash cp .env.example .env # Edit .env with your configuration ``` ```bash npm run dev ``` -------------------------------- ### Start Development Server Source: https://github.com/feiyin0719/composemarkdown/blob/master/app/src/main/assets/large_document.md Starts the development server using npm. ```bash npm run dev ``` -------------------------------- ### Set Up Environment Variables Source: https://github.com/feiyin0719/composemarkdown/blob/master/app/src/main/assets/large_document.md Copies the environment variable example file and prompts to edit it with your configuration. ```bash cp .env.example .env # Edit .env with your configuration ``` -------------------------------- ### Install Application Dependencies Source: https://github.com/feiyin0719/composemarkdown/blob/master/app/src/main/assets/large_document.md Use these commands to clone the repository and install project dependencies. Ensure Node.js 16+ is installed. ```bash git clone https://github.com/yourproject/app.git cd app ``` ```bash npm install # or yarn install ``` ```bash cp .env.example .env # Edit .env with your configuration ``` ```bash npm run dev ``` -------------------------------- ### Clone and Setup Application Source: https://github.com/feiyin0719/composemarkdown/blob/master/app/src/main/assets/large_document.md Clones the application repository and sets up the environment variables. Requires Git and Node.js. ```bash git clone https://github.com/yourproject/app.git cd app cp .env.example .env # Edit .env with your configuration ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/feiyin0719/composemarkdown/blob/master/app/src/main/assets/large_document.md Installs project dependencies using npm or yarn. Ensure Node.js 16+ is installed. ```bash npm install ``` ```bash yarn install ``` -------------------------------- ### Install Application Dependencies Source: https://github.com/feiyin0719/composemarkdown/blob/master/app/src/main/assets/large_document.md Installs project dependencies using npm or yarn. Ensure Node.js 16+ is installed and the repository is cloned before running. ```bash git clone https://github.com/yourproject/app.git cd app npm install # or yarn install ``` -------------------------------- ### Install Application Dependencies Source: https://github.com/feiyin0719/composemarkdown/blob/master/app/src/main/assets/large_document.md Installs project dependencies using npm or yarn. Ensure Node.js 16+ is installed and the repository is cloned before running. ```bash npm install # or yarn install ``` -------------------------------- ### Clone Repository and Install Dependencies Source: https://github.com/feiyin0719/composemarkdown/blob/master/app/src/main/assets/large_document.md Use these bash commands to clone the project repository and install necessary dependencies for development. ```bash git clone https://github.com/yourproject/app.git cd app ``` ```bash npm install # or yarn install ``` -------------------------------- ### MarkdownRenderConfig Builder Example Source: https://github.com/feiyin0719/composemarkdown/blob/master/docs/API.md Demonstrates creating a `MarkdownRenderConfig` instance using its builder. Configure theme, plugins, and renderers as needed. ```kotlin val config = MarkdownRenderConfig.Builder() // configure theme, plugins, renderers... .build() ``` -------------------------------- ### MarkdownText Example Usage Source: https://github.com/feiyin0719/composemarkdown/blob/master/docs/API.md An example demonstrating how to use the MarkdownText composable to render Markdown content with specific styling and overflow handling. ```kotlin ```kotlin SelectionContainer { MarkdownText( content = markdownContent, markdownRenderConfig = config, modifier = Modifier.padding(16.dp), maxLines = 10, overflow = TextOverflow.Ellipsis, ) } ``` ``` -------------------------------- ### Basic Markdown Rendering Example Source: https://github.com/feiyin0719/composemarkdown/blob/master/README.md Demonstrates the simplest way to use MarkdownView to render Markdown content. Ensure necessary imports are included. ```kotlin import com.iffly.compose.markdown.MarkdownView import com.iffly.compose.markdown.config.MarkdownRenderConfig @Composable fun SimpleMarkdownExample() { val markdownContent = """ # Welcome to Compose Markdown This is a powerful Markdown rendering library. ## Supported Features - **Bold text** - *Italic text* - `Inline code` - [Link](https://github.com) ### Code Block Example ```kotlin @Composable fun HelloWorld() { Text("Hello, Compose Markdown!") } ``` """.trimIndent() val config = remember { MarkdownRenderConfig.Builder().build() } MarkdownView( content = markdownContent, markdownRenderConfig = config, modifier = Modifier.fillMaxSize(), ) } ``` -------------------------------- ### JSON Package Configuration Source: https://github.com/feiyin0719/composemarkdown/blob/master/app/src/main/assets/large_document.md Example of a package.json file configuration, including name, version, description, scripts for common tasks, and dependencies. ```json { "name": "markdown-showcase", "version": "1.0.0", "description": "A comprehensive markdown elements demonstration", "scripts": { "start": "node server.js", "test": "jest", "build": "webpack --mode production" }, "dependencies": { "express": "^4.18.0", "lodash": "^4.17.21" } } ``` -------------------------------- ### Check Node.js Module Resolution Source: https://github.com/feiyin0719/composemarkdown/blob/master/app/src/main/assets/large_document.md Commands to list installed Node.js packages and audit for security vulnerabilities. ```bash npm ls package-name npm audit fix ``` -------------------------------- ### Configured Markdown Rendering with MarkdownTheme Source: https://github.com/feiyin0719/composemarkdown/blob/master/README.md Shows how to customize the appearance of Markdown content using a MarkdownTheme. This example applies custom text styles and head styles. ```kotlin import com.iffly.compose.markdown.style.MarkdownTheme @Composable fun ConfiguredMarkdownExample() { val markdownTheme = MarkdownTheme( textStyle = TextStyle( fontSize = 16.sp, lineHeight = 24.sp, ), headStyle = mapOf( 1 to TextStyle(fontSize = 28.sp, fontWeight = FontWeight.Bold), 2 to TextStyle(fontSize = 24.sp, fontWeight = FontWeight.Bold), ), ) val config = remember { MarkdownRenderConfig.Builder() .markdownTheme(markdownTheme) .build() } MarkdownView( content = "# Custom Style Title\n\nThis is Markdown content with custom styling.", markdownRenderConfig = config, modifier = Modifier.fillMaxSize(), showNotSupportedText = true, actionHandler = ActionHandler { action -> // Handle actions (links, images, etc.) }, onError = { error -> Text( text = "Content parsing failed: ${error.message}", color = MaterialTheme.colorScheme.error, ) }, ) } ``` -------------------------------- ### Basic LazyMarkdownView Usage Source: https://github.com/feiyin0719/composemarkdown/blob/master/README.md Example of how to use LazyMarkdownView to render a large markdown document from a file. It shows basic configuration for the file and render config. ```kotlin @Composable fun LargeMarkdownDocument() { val markdownFile = File("/path/to/large-document.md") val config = remember { MarkdownRenderConfig.Builder().build() } LazyMarkdownView( file = markdownFile, markdownRenderConfig = config, modifier = Modifier.fillMaxSize(), chunkLoaderConfig = ChunkLoaderConfig( /* initialLines = 1000, incrementalLines = 500, chunkSize = 5, */ parserDispatcher = MarkdownThreadPool.dispatcher, ), ) } ``` -------------------------------- ### Custom AlertBlockRenderer Implementation Source: https://github.com/feiyin0719/composemarkdown/blob/master/README.md Example of implementing a custom IBlockRenderer for an AlertBlock. This allows for custom composable rendering of specific markdown block types. ```kotlin class AlertBlockRenderer : IBlockRenderer { @Composable override fun Invoke( node: AlertBlock, modifier: Modifier, ) { Card(modifier = modifier) { Text(text = node.title) } } } val config = MarkdownRenderConfig .Builder() .addBlockRenderer(AlertBlock::class.java, AlertBlockRenderer()) .build() ``` -------------------------------- ### Synchronous MarkdownView Example Source: https://github.com/feiyin0719/composemarkdown/blob/master/README.md Render short Markdown content synchronously using `MarkdownView`. This is suitable for small documents that can be parsed instantly without blocking the UI thread. Includes error handling and action handling. ```kotlin @Composable fun SyncMarkdownExample() { val shortContent = """ # Quick Notes This is short markdown content that can be parsed instantly. - Item 1 - Item 2 **Bold text** and *italic text* """.trimIndent() val config = remember { MarkdownRenderConfig.Builder().build() } MarkdownView( content = shortContent, markdownRenderConfig = config, modifier = Modifier.padding(16.dp), showNotSupportedText = true, actionHandler = ActionHandler { action -> // Handle actions }, onError = { error -> Text( text = "Parsing failed: ${error.message}", color = MaterialTheme.colorScheme.error, ) }, ) } ``` -------------------------------- ### Custom Loading Composable Source: https://github.com/feiyin0719/composemarkdown/blob/master/docs/API.md Example of a custom composable to display a loading indicator for images. This can be passed to the MarkdownImage's loadingView parameter. ```kotlin @Composable fun CustomLoading(image: Image, modifier: Modifier) { Box(modifier, contentAlignment = Alignment.Center) { CircularProgressIndicator(strokeWidth = 2.dp) } } ``` -------------------------------- ### Enabling Multiple Plugins Simultaneously Source: https://github.com/feiyin0719/composemarkdown/blob/master/README.md Combine multiple ComposeMarkdown plugins within a single MarkdownRenderConfig. This example shows enabling both Task and MarkdownMath plugins. ```kotlin val fullConfig = MarkdownRenderConfig.Builder() .addPlugin(TaskMarkdownRenderPlugin()) .addPlugin( MarkdownMathPlugin( mathStyle = SpanStyle(fontStyle = FontStyle.Italic), width = 180.sp, height = 72.sp, align = TextAlign.Center ) ) .build() ``` -------------------------------- ### Troubleshoot 'Module Not Found' Error Source: https://github.com/feiyin0719/composemarkdown/blob/master/app/src/main/assets/large_document.md Commands and code examples for resolving 'Module Not Found' errors in Node.js applications. Includes steps for clearing cache, reinstalling dependencies, and verifying import paths. ```bash rm -rf node_modules package-lock.json npm install ``` ```bash npm ls package-name npm audit fix ``` ```javascript // ❌ Incorrect import { Component } from './Components/MyComponent' // ✅ Correct import { Component } from './components/MyComponent' ``` -------------------------------- ### Customizing Table Cell Rendering Source: https://github.com/feiyin0719/composemarkdown/blob/master/docs/API.md Demonstrates how to implement a custom table cell renderer to alter the display of individual cells. This example forces text alignment to center for all cells. ```kotlin class CustomTableCellRenderer : TableWidgetRenderer { @Composable override fun invoke(node: TableCell, modifier: Modifier) { val theme = currentTheme() val isHeader = node.parent is TableRow && node.parent?.parent is TableHead SelectionContainer { MarkdownText( parent = node, modifier = Modifier, textAlign = TextAlign.Center, // force center for all cells textStyle = if (isHeader) theme.tableTheme.headerTextStyle else theme.tableTheme.cellTextStyle, ) } } } val config = MarkdownRenderConfig.Builder() .addBlockRenderer( TableBlock::class.java, TableRenderer(tableCellRenderer = CustomTableCellRenderer()), ) .build() ``` -------------------------------- ### Basic LazyMarkdownColumn Usage Source: https://github.com/feiyin0719/composemarkdown/blob/master/README.md Example of using LazyMarkdownColumn to render a string of markdown content efficiently within a LazyColumn. It requires the markdown content and a render config. ```kotlin @Composable fun LazyMarkdownExample() { val config = remember { MarkdownRenderConfig.Builder().build() } LazyMarkdownColumn( content = longMarkdownContent, markdownRenderConfig = config, modifier = Modifier.fillMaxSize(), ) } ``` -------------------------------- ### Custom Icon Inline Builder Example Source: https://github.com/feiyin0719/composemarkdown/blob/master/docs/API.md Demonstrates how to implement IInlineNodeStringBuilder to register and append custom inline content, such as an icon, within the text. This involves registering the content with a unique key and then appending a placeholder annotated with that key. ```kotlin class IconInlineNodeStringBuilder : IInlineNodeStringBuilder { override fun AnnotatedString.Builder.buildInlineNodeString( node: IconNode, inlineContentMap: MutableMap, markdownTheme: MarkdownTheme, actionHandler: ActionHandler?, indentLevel: Int, isShowNotSupported: Boolean, renderRegistry: RenderRegistry, nodeStringBuilderContext: NodeStringBuilderContext, ) { // 1. Register rich inline content under a unique key val key = "icon-${node.id}" inlineContentMap[key] = MarkdownInlineView.MarkdownRichTextInlineContent( inlineContent = /* build RichTextInlineContent for this icon */ buildIconInlineContent(node), ) // 2. Append a placeholder character with that key as an annotation appendInlineContent(key, " ") } } ``` -------------------------------- ### Override Heading Styles Source: https://github.com/feiyin0719/composemarkdown/blob/master/docs/API.md Example of how to override the default text styles for H1 and H2 headings within a MarkdownTheme. ```kotlin import androidx.compose.ui.graphics.Color import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import androidx.compose.foundation.text.selection.TextSelectionColors import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Stable val theme = MarkdownTheme( headStyle = mapOf( MarkdownTheme.HEAD1 to TextStyle( fontSize = 32.sp, fontWeight = FontWeight.Bold, color = MaterialTheme.colorScheme.primary, ), MarkdownTheme.HEAD2 to TextStyle( fontSize = 28.sp, fontWeight = FontWeight.Bold, color = MaterialTheme.colorScheme.onSurface, ), ), ) ``` -------------------------------- ### Flowchart for Decision Process Source: https://github.com/feiyin0719/composemarkdown/blob/master/app/src/main/assets/large_document.md A visual representation of a decision process, starting from user input and proceeding through validation, processing, and response. ```text Start │ ▼ ┌─────────────┐ │ User Input │ └──────┬──────┘ │ ▼ ┌─────────────┐ No ┌──────────────┐ │ Valid Data? │────────▶│ Show Error │ └──────┬──────┘ └──────┬───────┘ │ Yes │ ▼ │ ┌─────────────┐ │ │ Process │ │ │ Request │ │ └──────┬──────┘ │ │ │ ▼ │ ┌─────────────┐ │ │ Return │ │ │ Response │ │ └──────┬──────┘ │ │ │ ▼ ▼ End ◀────────────────────── ``` -------------------------------- ### JavaScript for Verifying Import Paths Source: https://github.com/feiyin0719/composemarkdown/blob/master/app/src/main/assets/large_document.md Illustrates correct and incorrect import path syntax in JavaScript, highlighting the importance of case sensitivity and relative path accuracy. ```javascript // ❌ Incorrect import { Component } from './Components/MyComponent' // ✅ Correct import { Component } from './components/MyComponent' ``` -------------------------------- ### Custom Error Composable Source: https://github.com/feiyin0719/composemarkdown/blob/master/docs/API.md Example of a custom composable to display an error message for images. This can be passed to the MarkdownImage's errorView parameter. ```kotlin @Composable fun CustomError(image: Image, modifier: Modifier) { Column( modifier = modifier, horizontalAlignment = Alignment.CenterHorizontally, ) { Icon(Icons.Default.BrokenImage, contentDescription = null) Text(text = image.text?.toString().orEmpty()) } } ``` -------------------------------- ### Integrate Third-Party Syntax Highlighter Source: https://github.com/feiyin0719/composemarkdown/blob/master/docs/API.md Demonstrates how to integrate a custom third-party syntax highlighter by implementing the CodeAnnotator interface. ```kotlin val config = MarkdownRenderConfig.Builder() .addBlockRenderer( FencedCodeBlock::class.java, FencedCodeBlockRenderer( codeAnnotator = CodeAnnotator { code, language, _ -> myHighlighter.highlight(code, language) }, ), ) .build() ``` -------------------------------- ### MarkdownRenderConfig Builder Methods Source: https://github.com/feiyin0719/composemarkdown/blob/master/docs/API.md Illustrates key methods available on the `MarkdownRenderConfig.Builder` for customization. These include setting themes, adding plugins, and registering custom renderers. ```kotlin class MarkdownRenderConfig { class Builder { fun markdownTheme(markdownTheme: MarkdownTheme): Builder fun addPlugin(plugin: IMarkdownRenderPlugin): Builder fun addInlineNodeStringBuilder( nodeClass: Class, builder: IInlineNodeStringBuilder<*>, ): Builder fun addBlockRenderer( blockClass: Class, renderer: IBlockRenderer<*>, ): Builder fun markdownTextRenderer(renderer: MarkdownTextRenderer): Builder fun markdownContentRenderer(renderer: MarkdownContentRenderer): Builder fun addBlockParserFactory(factory: CustomBlockParserFactory): Builder fun addInlineContentParserFactory(factory: InlineParserExtensionFactory): Builder fun addDelimiterProcessor(processor: DelimiterProcessor): Builder fun addExtension(extension: Extension): Builder fun build(): MarkdownRenderConfig } } ``` -------------------------------- ### Verify Import Paths in JavaScript Source: https://github.com/feiyin0719/composemarkdown/blob/master/app/src/main/assets/large_document.md Illustrates correct and incorrect import path syntax in JavaScript for resolving 'Module Not Found' errors. ```javascript // ❌ Incorrect import { Component } from './Components/MyComponent' // ✅ Correct import { Component } from './components/MyComponent' ``` -------------------------------- ### Minimal LazyMarkdownView Usage Source: https://github.com/feiyin0719/composemarkdown/blob/master/README.md Demonstrates the minimal configuration required to use LazyMarkdownView, relying on default settings for most parameters. ```kotlin LazyMarkdownView( file = File(path), markdownRenderConfig = MarkdownRenderConfig.Builder().build(), ) ``` -------------------------------- ### Dockerfile for Multi-stage Production Build Source: https://github.com/feiyin0719/composemarkdown/blob/master/app/src/main/assets/large_document.md Sets up a multi-stage Docker build for a Node.js application, optimizing for production. ```dockerfile # [DOCKERFILE BLOCK] Multi-stage Production Build FROM node:18-alpine AS builder WORKDIR /app COPY package*.json ./ RUN npm ci --only=production COPY . . RUN npm run build # Production stage FROM node:18-alpine AS production RUN addgroup -g 1001 -S nodejs RUN adduser -S nextjs -u 1001 WORKDIR /app COPY --from=builder /app/public ./public COPY --from=builder /app/.next/standalone ./ COPY --from=builder /app/.next/static ./.next/static USER nextjs EXPOSE 3000 ENV PORT 3000 ENV NODE_ENV production CMD ["node", "server.js"] ``` -------------------------------- ### Custom Code Header Renderer Source: https://github.com/feiyin0719/composemarkdown/blob/master/docs/API.md Example of a custom renderer for the header of a fenced code block. This allows for custom UI elements or information to be displayed above the code. ```kotlin val config = MarkdownRenderConfig.Builder() .addBlockRenderer( FencedCodeBlock::class.java, FencedCodeBlockRenderer( renderHeaderOverride = CustomCodeHeaderRenderer(), ), ) .build() ``` -------------------------------- ### MarkdownRenderConfig Builder Overview Source: https://github.com/feiyin0719/composemarkdown/blob/master/README.md Illustrates the high-level configuration options available for Markdown rendering using the MarkdownRenderConfig builder. This includes setting themes and adding plugins. ```kotlin val config = MarkdownRenderConfig.Builder() .markdownTheme(MarkdownTheme()) // .addPlugin(...) // .addBlockRenderer(...) // .addInlineNodeStringBuilder(...) .build() ``` -------------------------------- ### Custom MentionNode Inline Builder Source: https://github.com/feiyin0719/composemarkdown/blob/master/README.md Example of implementing IInlineNodeStringBuilder for a custom MentionNode. This customizes how inline nodes are converted to styled text within the markdown rendering. ```kotlin class MentionInlineBuilder : IInlineNodeStringBuilder { override fun AnnotatedString.Builder.buildInlineNodeString( node: MentionNode, inlineContentMap: MutableMap, markdownTheme: MarkdownTheme, actionHandler: ActionHandler?, indentLevel: Int, isShowNotSupported: Boolean, renderRegistry: RenderRegistry, nodeStringBuilderContext: NodeStringBuilderContext, ) { pushStyle(markdownTheme.linkTextStyle) append("@" + node.username) pop() } } val config = MarkdownRenderConfig .Builder() .addInlineNodeStringBuilder(MentionNode::class.java, MentionInlineBuilder()) .build() ``` -------------------------------- ### Clone Project Repository Source: https://github.com/feiyin0719/composemarkdown/blob/master/app/src/main/assets/large_document.md Clones the project repository from GitHub and navigates into the project directory. ```bash git clone https://github.com/yourproject/app.git cd app ``` -------------------------------- ### LaTeX Math Plugin Configuration Source: https://github.com/feiyin0719/composemarkdown/blob/master/README.md Configure the MarkdownMathPlugin for rendering LaTeX math formulas. Options include customizing math style, dimensions, alignment, and enabling/disabling GitLab extensions. ```kotlin val mathConfig = MarkdownRenderConfig.Builder() .addPlugin( MarkdownMathPlugin( mathStyle = SpanStyle(fontStyle = FontStyle.Italic), width = 200.sp, height = 80.sp, align = TextAlign.Center, enableGitLabExtension = false ) ) .build() ``` -------------------------------- ### LazyMarkdownView with ChunkLoaderConfig Source: https://github.com/feiyin0719/composemarkdown/blob/master/docs/API.md Configures ChunkLoaderConfig for LazyMarkdownView to manage parsing of large markdown files. This example shows setting a custom parser dispatcher and conceptual values for loading parameters. ```kotlin val chunkConfig = ChunkLoaderConfig( // initialLines = 800, // incrementalLines = 400, // maxCachedChunks = 8, parserDispatcher = MarkdownThreadPool.dispatcher, ) LazyMarkdownView( file = largeFile, markdownRenderConfig = config, chunkLoaderConfig = chunkConfig, ) ``` -------------------------------- ### Adding Render Plugins for Extended Functionality Source: https://github.com/feiyin0719/composemarkdown/blob/master/_posts/2025-09-23-compose-markdown.md Extend Markdown rendering capabilities by adding custom render plugins to the MarkdownRenderConfig. This example shows how to add support for task lists. ```kotlin // Need task list functionality? Easy extension! val configWithTasks = MarkdownRenderConfig.Builder() .addRenderPlugin(TaskMarkdownRenderPlugin()) // Support for - [ ] task lists .build() ``` -------------------------------- ### Configure Fenced Code Block Renderer with Basic Syntax Highlighter Source: https://github.com/feiyin0719/composemarkdown/blob/master/README.md This snippet shows how to configure the FencedCodeBlockRenderer to use the built-in BasicSyntaxHighlighter for syntax highlighting. You can also implement your own CodeAnnotator for third-party library integration. ```kotlin val config = MarkdownRenderConfig.Builder() .addBlockRenderer( FencedCodeBlock::class.java, FencedCodeBlockRenderer(codeAnnotator = BasicSyntaxHighlighter()), ) .build() ```