rtf-to-html

Crates.iortf-to-html
lib.rsrtf-to-html
version0.1.0
created_at2025-12-17 16:54:36.390097+00
updated_at2025-12-17 16:54:36.390097+00
descriptionConvert RTF documents to HTML with semantic markup
homepage
repositoryhttps://github.com/TwelveTake-Studios/rtf-to-html
max_upload_size
id1990703
size25,732
(david-cilluffo)

documentation

https://docs.rs/rtf-to-html

README

rtf-to-html

Convert RTF documents to clean, semantic HTML.

Crates.io Documentation License

Support

If you find this crate useful, consider supporting development:

Features

  • Converts RTF to semantic HTML (<strong>, <em>, <u>)
  • Paragraph structure preserved with <p> tags
  • XSS-safe output (HTML entities escaped)
  • Plain text extraction (strips all formatting)
  • Zero unsafe code

Installation

[dependencies]
rtf-to-html = "0.1"

Usage

Convert RTF to HTML

use rtf_to_html::rtf_to_html;

let rtf = br#"{\rtf1\ansi\deff0 {\b Bold} and {\i italic} text}"#;
let html = rtf_to_html(rtf).unwrap();
// Output: <p><strong>Bold</strong> and <em>italic</em> text</p>

Extract Plain Text

use rtf_to_html::rtf_to_plain_text;

let rtf = br#"{\rtf1\ansi\deff0 Hello World}"#;
let text = rtf_to_plain_text(rtf).unwrap();
// Output: Hello World

Supported Formatting

RTF HTML Output
\b (bold) <strong>
\i (italic) <em>
\ul (underline) <u>
\par (paragraph) <p>

Limitations

This crate focuses on basic text formatting. The following are not currently supported:

  • Hyperlinks (\field with HYPERLINK)
  • Embedded images or objects
  • Tables
  • Font sizes and colors
  • Lists (numbered/bulleted)

Contributions welcome!

License

Licensed under either of:

at your option.

Credits

Built by TwelveTake Studios. Uses the rtf-parser crate for RTF parsing.

Commit count: 0

cargo fmt