$ show JoaoPauloCMarra/react-native-nitro-markdown
react-native-nitro-markdown is a high-performance native Markdown parser and renderer for React Native, built on a vendored md4c C library (forked as nitromd) and the Nitro Modules framework for direct JSI bridging. It provides full CommonMark and GitHub Flavored Markdown support, plus extensions for LaTeX inline/block math, task lists, and strikethrough. The library offers three primary consumption modes: a full `<Markdown>` React component with customizable renderers, a `<MarkdownStream>` component designed for progressive rendering of streaming text (e.g., from LLM output), and a headless API (`parseMarkdown`, `extractPlainText`, `createMarkdownSession`) for server-side or non-React usage. Architecture is layered: native C++ parser produces a typed JSON AST, which is consumed by a React rendering pipeline with caching, incremental updates, and a plugin system. The repository includes a comprehensive test suite (unit, conformance, snapshot, C++ unit, E2E Maestro), performance benchmarks, fuzz testing, and a CI/CD pipeline for automated releases. It is a mature, well-engineered library with strong focus on correctness, performance, and developer experience, though it is tightly coupled to the iOS/Android native runtime and Nitro Modules ecosystem.
The LLM identified 5 files worth highlighting for reuse:
Provides a configurable URL security policy for external links and images. Exports `getAllowedExternalHref` and `getAllowedImageHref` functions that validate protocols, hostnames, and remote image sources against a allowlist/blocklist. Self-contained, no internal imports, easily extracted into any React Native or TypeScript project needing safe URL handling.
Implements a deep-freeze and validation function for the Markdown AST tree. Recursively checks node depth, string byte lengths, array slot counts, numeric finiteness, and property types to prevent corrupted or malicious ASTs from reaching the renderer. Reusable in any system that needs to validate and freeze heterogeneous tree structures.
Wraps language detection and syntax highlighting for code blocks. Maps language identifiers to highlight.js/scipy names and returns a highlighted HTML string or token array. Self-contained utility that can be reused in web or mobile projects for code rendering.
Defines the theming infrastructure with typed style overrides for each Markdown node type. Exports `mergeThemes` for deep partial merging, `darkMarkdownTheme` and `minimalMarkdownTheme` as preset themes, and `NodeStyleOverrides` for fine-grained control. This pattern can be extracted and reused for any component library requiring composable theme objects.
Provides a React-free entry point for Markdown parsing and text extraction. Exports `parseMarkdown`, `parseMarkdownWithOptions`, `extractPlainText`, and `createMarkdownSession` functions that delegate to the native C++ parser via the session interface. The pattern of separating parsing from rendering is reusable in any project needing server-side or lightweight Markdown processing without a UI framework.