Debian Codegraph @

src/parser/shortcodes.rs

raw
1 /// The details of an inline "shortcode" emoji/gemoji.
2 ///
3 /// ("gemoji" name context: <https://github.com/github/gemoji>)
4 #[derive(Debug, Clone, PartialEq, Eq)]
5 pub struct NodeShortCode {
6 /// The shortcode that was resolved, e.g. "rabbit".
7 pub code: String,
8
9 /// The emoji `code` resolved to, e.g. "🐰".
10 pub emoji: String,
11 }
12
13 impl NodeShortCode {
14 /// Checks whether the input is a valid short code.
15 pub fn resolve(code: &str) -> Option<Self> {
16 let emoji = emojis::get_by_shortcode(code)?;
17 Some(NodeShortCode {
18 code: code.to_string(),
19 emoji: emoji.to_string(),
20 })
21 }
22 }