Skip to main content

Crate rushdown_emoji

Crate rushdown_emoji 

Source
Expand description

§rushdown-emoji

rushdown-emoji is an extension for the rushdown that parses :joy: style emojis.

§Installation

Add dependency to your Cargo.toml:

[dependencies]
rushdown-emoji = "x.y.z"

rushdown-emoji can also be used in no_std environments. To enable this feature, add the following line to your Cargo.toml:

rushdown-emoji = { version = "x.y.z", default-features = false, features = ["no-std"] }

§Syntax

I am :joy: emoji.

§Usage

§Example

use core::fmt::Write;
use rushdown::{
    new_markdown_to_html,
    parser::{self, ParserExtension},
    renderer::html::{self, RendererExtension},
    Result,
};
use rushdown_emoji::{
    emoji_html_renderer_extension, emoji_parser_extension, 
    EmojiParserOptions,
    EmojiHtmlRendererOptions,
};

let markdown_to_html = new_markdown_to_html(
    parser::Options::default(),
    html::Options::default(),
    emoji_parser_extension(EmojiParserOptions::default()),
    emoji_html_renderer_extension(EmojiHtmlRendererOptions::default()),
);
let mut output = String::new();
let input = r#"
I am :joy: emoji.
"#;
match markdown_to_html(&mut output, input) {
    Ok(_) => {
        println!("HTML output:\n{}", output);
    }
    Err(e) => {
        println!("Error: {:?}", e);
    }
}

§Options

§Parser options
OptionTypeDefaultDescription
blacklistOption<Rc<AsciiWordSet>>NoneA set of emoji shortcodes that should not be parsed as emojis.
§HTML renderer options
OptionTypeDefaultDescription
templateOption<String>NoneA template string for rendering emojis. The template can include {emoji}, {shortcode} and {name} which will be replaced with the actual data. If None, the default template is used, which simply outputs the emoji character.

§Donation

BTC: 1NEDSyUmo4SMTDP83JJQSWi1MvQUGGNMZB

Github sponsors also welcome.

§License

MIT

§Author

Yusuke Inuzuka

Structs§

Emoji
Represents an emoji in the AST.
EmojiHtmlRendererOptions
Options for the emoji HTML renderer.
EmojiParserOptions
Options for the emoji parser.

Functions§

emoji_html_renderer_extension
Returns a renderer extension that renders emojis as HTML.
emoji_parser_extension
Returns a parser extension that parses emojis.