discord-markdown
Parse discord-flavored markdown
This parser was written for use with cheesecake, so the convertor function provided is designed for that. If this function doesn't suit your use-case, you can write your own convertor function to generate HTML from the parsed AST. The text in the generated HTML will be HTML-escaped, so you can safely insert the output into the DOM.
Documentation
Read the API documentation on docs.rs.
Usage
Call parser::parse
on the input string, and it will return a vector of Expression
s. Supply
this vector to convertor::to_html
to get an HTML string. If your input text will also have
custom emoji, user mentions, role mentions, or channel mentions, then use
convertor::to_html_with_callbacks
instead.
Call parser::parse_with_md_hyperlinks
instead if you want to also parse links with alt text,
which is supported in discord embeds (Like [example](https://example.com)
)
Note:
Newlines are not converted to Expression::Newline
inside code blocks, so that must be handled
in the covertor.
Examples
If all you want is to generate the AST, it's really simple:
use ;
If you want to generate an HTML string, it's like this:
use ;
You can then add styling for .role
and .role span
in your stylesheet. Here's some example
CSS:
}
}