Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/tutosrive/mcbfc/llms.txt

Use this file to discover all available pages before exploring further.

In this guide you will clone the MCBFC repository, confirm that your local toolchain meets the prerequisites, and run the sample app on a real device or emulator — all so you can see copy buttons appearing on every fenced code block in action. Once the demo is running, the integration section walks you through transplanting the same pattern into your own Android project.

Prerequisites

Before you begin, make sure you have the following installed and configured:
  • Android Studio (latest stable recommended) — the easiest way to build and run the project.
  • JDK 21 with Kotlin support — required by the Gradle toolchain. Confirm with java -version.
  • Gradle 9.4.1 — the repository ships with a Gradle wrapper (gradlew / gradlew.bat) that downloads the correct version automatically, so a local Gradle installation is optional.
  • Android device or emulator running API level 24 or higher (Android 7.0 Nougat+).

Clone and set up

1

Clone the repository

git clone https://github.com/tutosrive/mcbfc.git
2

Enter the project directory

cd mcbfc
3

(Optional) verify the Gradle wrapper version

The repository includes a pre-configured wrapper targeting Gradle 9.4.1. You can confirm it before building:
./gradlew --version
The output should show Gradle 9.4.1. On Windows, use gradlew.bat --version.
4

Open in Android Studio or build from the CLI

Choose whichever method suits your workflow — see Build options below.

Build options

  1. In Android Studio, choose File → Open and select the mcbfc directory.
  2. Wait for the Gradle sync to complete (the IDE will download dependencies automatically).
  3. Select your target device or emulator from the device dropdown.
  4. Click the Run ▶ button (or use Build → Make Project) to assemble and deploy the debug build.
To produce an optimised release APK, open the Build menu and choose Generate Signed App Bundle / APK, or run Build → Build APK(s) for an unsigned release via:
Build → Build Bundle(s) / APK(s) → Build APK(s)

Integrate into your own project

MCBFC is a reference implementation — there is no library artifact to add as a dependency. Follow these steps to bring the pattern into an existing Android project.
1

Add the Markwon dependencies

Open your module’s build.gradle.kts and add the two Markwon artifacts inside the dependencies block:
dependencies {
    // Markwon core parser and renderer
    implementation("io.noties.markwon:core:4.6.2")
    // RecyclerView adapter for Markwon
    implementation("io.noties.markwon:recycler:4.6.2")
}
Sync your project after saving the file.
2

Copy BlockCodeEntry.kt and the fenced code layout

Copy app/src/main/java/com/srm/markdown_render/BlockCodeEntry.kt into your own package and update the package declaration at the top of the file.Then copy app/src/main/res/layout/fenced_code_view.xml into your project’s res/layout/ directory. This layout contains the HorizontalScrollView-wrapped TextView (R.id.command) and the overlay ImageButton (R.id.copyCommand) that BlockCodeEntry.Holder references. Adjust the styling — fonts, colours, padding — to match your app’s design system.
3

Copy markdown.kt and the default entry layout

Copy app/src/main/java/com/srm/markdown_render/markdown.kt into your package (update the package declaration). This class owns the Markwon instance and MarkwonAdapter, registers BlockCodeEntry for all FencedCodeBlock nodes, and configures the RecyclerView.Also copy app/src/main/res/layout/adapter_default_entry.xml — this is the fallback layout passed to MarkwonAdapter.builderTextViewIsRoot(...) for every non-code node.
4

Wire up in your Activity or Fragment

In your Activity (or Fragment’s onViewCreated), instantiate the markdown wrapper and call sett() with your markdown string:
// R.id.recyclerMark is your RecyclerView in the layout
val mark = markdown(this, findViewById(R.id.recyclerMark))
mark.sett(yourMarkdownString)
sett() calls adapter.setMarkdown() followed by notifyDataSetChanged() internally, so a single call is all that is needed to render or refresh the content.
Ready to go deeper? Head to the Core Concepts section for a detailed walkthrough of how BlockCodeEntry, the markdown wrapper class, and the two XML layouts interact — including how MarkwonAdapter.Entry dispatch works and where to hook in additional customisation.

Build docs developers (and LLMs) love