Skip to main content

rich_markdown 1.0.0 copy "rich_markdown: ^1.0.0" to clipboard
rich_markdown: ^1.0.0 copied to clipboard

A Flutter package for rendering Markdown, LaTeX, and HTML content.

Rich Markdown #

A Flutter package for rendering Markdown, LaTeX equations, and HTML content in a single reusable widget. Designed for AI chat applications, streaming responses, educational apps, documentation viewers, and content-rich mobile applications.

โœจ Features #

  • ๐Ÿ“ Markdown Rendering โ€” Headings, paragraphs, bold, italic, strikethrough, lists, blockquotes, links, and GitHub Flavored Markdown.
  • ๐Ÿงฎ LaTeX Support โ€” Render inline and block mathematical expressions using flutter_math_fork.
  • ๐ŸŒ HTML Rendering โ€” Display HTML content with custom LaTeX tags.
  • ๐Ÿ’ฌ AI Chat Ready โ€” Designed to support Markdown and math in AI-generated responses.
  • โšก Streaming-Friendly โ€” Supports progressively updated content as responses arrive.
  • ๐Ÿ”— Link Callbacks โ€” Handle link taps with your own navigation logic.
  • ๐ŸŽจ Custom Styling โ€” Customize text size, color, font family, and layout.
  • ๐Ÿงฉ Simple API โ€” One widget for multiple content formats.

๐Ÿ“ฆ Installation #

Add the package to your pubspec.yaml:

dependencies:
  rich_markdown: ^1.0.0

Then run:

flutter pub get

๐Ÿš€ Quick Start #

Import the package:

import 'package:flutter/material.dart';
import 'package:rich_markdown/rich_markdown.dart';

Render Markdown content:

const content = r'''
# Hello, Rich Markdown!

This is **bold text** and *italic text*.

Inline equation: \(E = mc^2\)

Block equation:

$$
\int_0^1 x^2\,dx = \frac{1}{3}
$$
''';

RichMarkdownView(
  data: content,
  type: ContentType.markdown,
  textStyle: const TextStyle(
    fontSize: 16,
    height: 1.5,
  ),
)

๐Ÿ“ธ Screenshots #

1. Markdown Rendering #

Markdown rendering screenshot

Displays Markdown formatting, headings, lists, links, and blockquotes.

2. Inline LaTeX #

Inline LaTeX screenshot

Render mathematical expressions directly within paragraphs.

3. Block LaTeX #

Block LaTeX screenshot

Display equations such as integrals, fractions, summations, and quadratic formulas.

4. HTML Rendering #

HTML rendering screenshot

Render HTML elements, including paragraphs, lists, emphasis, links, and supported custom math tags.

5. Code and LaTeX Handling #

Code protection screenshot

Test code blocks and inline code containing LaTeX-like expressions.

6. Currency and Symbols #

Currency and symbols screenshot

Test currency values, escaped dollar signs, and inline mathematical expressions.

7. Incomplete Equations #

Incomplete equation screenshot

Test how unfinished equations are handled while content is being generated.

๐ŸŽฌ AI Streaming Demo #

Watch Rich Markdown render progressively updated AI-style responses containing Markdown and LaTeX.

Rich Markdown streaming demo

The animation demonstrates simulated streaming in the example application. Actual streaming behavior depends on how your application supplies updated content and how incomplete Markdown and LaTeX expressions are handled.

๐Ÿ› ๏ธ Usage #

Markdown #

RichMarkdownView(
  data: '# Welcome\n\nThis is **Markdown**.',
  type: ContentType.markdown,
)

LaTeX #

Use raw strings to preserve LaTeX backslashes:

RichMarkdownView(
  data: r'\int_0^\infty e^{-x}\,dx = 1',
  type: ContentType.latex,
)

The latex content type renders the supplied expression in display math mode.

HTML #

RichMarkdownView(
  data: '''
    <h2>Hello</h2>
    <p>This is <strong>HTML</strong>.</p>
  ''',
  type: ContentType.html,
)

HTML with LaTeX #

The package supports custom tex and texblock tags containing Base64-encoded LaTeX.

RichMarkdownView(
  data: '''
    <p>Inline math: <tex>Uj1hXjI=</tex></p>
  ''',
  type: ContentType.html,
)

The encoded example represents R=a^2.

Custom Styling #

RichMarkdownView(
  data: '# Custom Content\n\nStyled text.',
  type: ContentType.markdown,
  textStyle: const TextStyle(
    fontSize: 18,
    height: 1.6,
    color: Colors.black87,
  ),
  shrinkWrap: true,
)
RichMarkdownView(
  data: '[Visit Flutter](https://flutter.dev)',
  onLinkTap: (url) {
    debugPrint('Tapped link: $url');
    // Add your navigation or URL-launching logic here.
  },
)

๐Ÿ“š API Reference #

RichMarkdownView #

Parameter Type Default Description
data String Required Content to render
type ContentType ContentType.markdown Content format
textStyle TextStyle? null Text styling
onLinkTap void Function(String? url)? null Link tap callback
shrinkWrap bool true Controls HTML content shrink wrapping

ContentType #

Value Description
ContentType.markdown Renders Markdown and supported LaTeX expressions
ContentType.latex Renders the input as a block LaTeX expression
ContentType.html Renders HTML with supported custom math tags

๐Ÿงช Example App #

Explore the example application to try different content types and test mathematical expressions.

git clone https://github.com/rohit-bon/rich_markdown.git
cd rich_markdown/example
flutter pub get
flutter run

Replace YOUR_USERNAME with your GitHub username.

๐Ÿงฐ Built With #

๐Ÿ—บ๏ธ Roadmap #

  • โŒ More comprehensive Markdown and LaTeX parsing tests
  • โŒ Improved handling of incomplete equations during streaming
  • โŒ Additional HTML and Markdown customization
  • โŒ Performance improvements for frequently updated AI responses
  • โŒ More examples and documentation

๐Ÿค Contributing #

Contributions, bug reports, and feature requests are welcome.

  1. Fork the repository.
  2. Create a feature branch.
  3. Implement your changes and add tests.
  4. Submit a pull request.

๐Ÿ“„ License #

This project is distributed under the MIT License. See the LICENSE file for details.

โญ Support #

If you find Rich Markdown useful, consider giving the project a star on GitHub and sharing feedback through issues or pull requests.

8
likes
130
points
450
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A Flutter package for rendering Markdown, LaTeX, and HTML content.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter, flutter_html, flutter_math_fork, html, markdown

More

Packages that depend on rich_markdown