mirror of
https://github.com/sbrow/thor.git
synced 2026-08-26 19:33:32 -04:00
438 lines
16 KiB
Odin
438 lines
16 KiB
Odin
#+feature dynamic-literals
|
||
package markdown
|
||
|
||
import "core:strings"
|
||
|
||
EMOJIS: map[string]string = {
|
||
// People
|
||
"smile" = "😄",
|
||
"laughing" = "😆",
|
||
"blush" = "😊",
|
||
"smiley" = "😃",
|
||
"wink" = "😉",
|
||
"joy" = "😂",
|
||
"rofl" = "🤣",
|
||
"relaxed" = "☺️",
|
||
"thinking" = "🤔",
|
||
"neutral_face" = "😐",
|
||
"expressionless" = "😑",
|
||
"no_mouth" = "😶",
|
||
"rolling_eyes" = "🙄",
|
||
"smirk" = "😏",
|
||
"persevere" = "😣",
|
||
"disappointed_relieved" = "😥",
|
||
"open_mouth" = "😮",
|
||
"zipper_mouth_face" = "🤐",
|
||
"hushed" = "😯",
|
||
"sleepy" = "😪",
|
||
"tired_face" = "😫",
|
||
"sleeping" = "😴",
|
||
"relieved" = "😌",
|
||
"stuck_out_tongue" = "😛",
|
||
"stuck_out_tongue_winking_eye" = "😜",
|
||
"stuck_out_tongue_closed_eyes" = "😝",
|
||
"drooling_face" = "🤤",
|
||
"unamused" = "😒",
|
||
"sweat" = "😅",
|
||
"pensive" = "😔",
|
||
"confused" = "😕",
|
||
"upside_down_face" = "🙃",
|
||
"money_mouth_face" = "🤑",
|
||
"astonished" = "😲",
|
||
"white_frowning_face" = "☹️",
|
||
"slightly_sad_face" = "☹️",
|
||
"confounded" = "😖",
|
||
"disappointed" = "😞",
|
||
"worried" = "😟",
|
||
"triumph" = "😤",
|
||
"cry" = "😢",
|
||
"sob" = "😭",
|
||
"frowning" = "😦",
|
||
"frowning_face" = "🙁",
|
||
"anguished" = "😧",
|
||
"fearful" = "😨",
|
||
"weary" = "😩",
|
||
"grimacing" = "😬",
|
||
"cold_sweat" = "😰",
|
||
"scream" = "😱",
|
||
"flushed" = "😳",
|
||
"dizzy_face" = "😵",
|
||
"rage" = "😡",
|
||
"angry" = "😠",
|
||
"innocent" = "😇",
|
||
"cowboy_hat_face" = "🤠",
|
||
"clown_face" = "🤡",
|
||
"mask" = "😷",
|
||
"thermometer_face" = "🤒",
|
||
"head_bandage" = "🤕",
|
||
"nauseated_face" = "🤢",
|
||
"sneezing_face" = "🤧",
|
||
"smiling_imp" = "😈",
|
||
"imp" = "👿",
|
||
"shrug" = "¯\\_(ツ)_/¯",
|
||
"facepalm" = "🤦",
|
||
"facepunch" = "👊",
|
||
"wave" = "👋",
|
||
"ok_hand" = "👌",
|
||
"thumbsup" = "👍",
|
||
"thumbsdown" = "👎",
|
||
"clap" = "👏",
|
||
"pray" = "🙏",
|
||
"point_up" = "☝️",
|
||
"point_down" = "👇",
|
||
"point_left" = "👈",
|
||
"point_right" = "👉",
|
||
"v" = "✌️",
|
||
"raised_hands" = "🙌",
|
||
"muscle" = "💪",
|
||
"fist" = "✊",
|
||
"hand" = "✋",
|
||
|
||
// Hearts & symbols
|
||
"heart" = "❤️",
|
||
"orange_heart" = "🧡",
|
||
"yellow_heart" = "💛",
|
||
"green_heart" = "💚",
|
||
"blue_heart" = "💙",
|
||
"purple_heart" = "💜",
|
||
"broken_heart" = "💔",
|
||
"sparkling_heart" = "💖",
|
||
"100" = "💯",
|
||
"anger" = "💢",
|
||
"checkered_flag" = "🏁",
|
||
"crossed_flags" = "🚩",
|
||
"rocket" = "🚀",
|
||
"star" = "⭐",
|
||
"star2" = "🌟",
|
||
"sparkles" = "✨",
|
||
"boom" = "💥",
|
||
"exclamation" = "❗",
|
||
"question" = "❓",
|
||
"grey_exclamation" = "❕",
|
||
"grey_question" = "❔",
|
||
"zzz" = "💤",
|
||
"warning" = "⚠️",
|
||
"no_entry_sign" = "🚫",
|
||
"no_entry" = "⛔",
|
||
"white_check_mark" = "✅",
|
||
"negative_squared_cross_mark" = "❎",
|
||
"x" = "❌",
|
||
"o" = "⭕",
|
||
"heavy_plus_sign" = "➕",
|
||
"heavy_minus_sign" = "➖",
|
||
"heavy_division_sign" = "➗",
|
||
"copyright" = "©️",
|
||
"registered" = "®️",
|
||
"tm" = "™️",
|
||
|
||
// Nature & weather
|
||
"fire" = "🔥",
|
||
"zap" = "⚡",
|
||
"sunny" = "☀️",
|
||
"cloud" = "☁️",
|
||
"rainbow" = "🌈",
|
||
"snowflake" = "❄️",
|
||
"dash" = "💨",
|
||
"tornado" = "🌪️",
|
||
"deciduous_tree" = "🌳",
|
||
"evergreen_tree" = "🌲",
|
||
"palm_tree" = "🌴",
|
||
"cactus" = "🌵",
|
||
"tulip" = "🌷",
|
||
"rose" = "🌹",
|
||
"sunflower" = "🌻",
|
||
"hibiscus" = "🌺",
|
||
"earth_africa" = "🌍",
|
||
"earth_americas" = "🌎",
|
||
"earth_asia" = "🌏",
|
||
"new_moon" = "🌑",
|
||
"full_moon" = "🌕",
|
||
|
||
// Food & drink
|
||
"coffee" = "☕",
|
||
"tea" = "🍵",
|
||
"beer" = "🍺",
|
||
"beers" = "🍻",
|
||
"wine_glass" = "🍷",
|
||
"tropical_drink" = "🍹",
|
||
"apple" = "🍎",
|
||
"green_apple" = "🍏",
|
||
"orange" = "🍊",
|
||
"lemon" = "🍋",
|
||
"banana" = "🍌",
|
||
"watermelon" = "🍉",
|
||
"grapes" = "🍇",
|
||
"strawberry" = "🍓",
|
||
"melon" = "🍈",
|
||
"cherries" = "🍒",
|
||
"peach" = "🍑",
|
||
"pineapple" = "🍍",
|
||
"pizza" = "🍕",
|
||
"hamburger" = "🍔",
|
||
"hotdog" = "🌭",
|
||
"taco" = "🌮",
|
||
"burrito" = "🌯",
|
||
"cake" = "🍰",
|
||
"cookie" = "🍪",
|
||
"chocolate_bar" = "🍫",
|
||
"candy" = "🍬",
|
||
"popcorn" = "🍿",
|
||
|
||
// Animals
|
||
"dog" = "🐶",
|
||
"cat" = "🐱",
|
||
"mouse" = "🐭",
|
||
"hamster" = "🐹",
|
||
"rabbit" = "🐰",
|
||
"bear" = "🐻",
|
||
"panda_face" = "🐼",
|
||
"koala" = "🐨",
|
||
"tiger" = "🐯",
|
||
"lion_face" = "🦁",
|
||
"cow" = "🐮",
|
||
"pig" = "🐷",
|
||
"frog" = "🐸",
|
||
"monkey_face" = "🐵",
|
||
"see_no_evil" = "🙈",
|
||
"hear_no_evil" = "🙉",
|
||
"speak_no_evil" = "🙊",
|
||
"owl" = "🦉",
|
||
"bat" = "🦇",
|
||
"wolf" = "🐺",
|
||
"boar" = "🐗",
|
||
"horse" = "🐴",
|
||
"unicorn" = "🦄",
|
||
"honeybee" = "🐝",
|
||
"bug" = "🐛",
|
||
"snail" = "🐌",
|
||
"beetle" = "🐞",
|
||
"ant" = "🐜",
|
||
"spider" = "🕷",
|
||
"scorpion" = "🦂",
|
||
"turtle" = "🐢",
|
||
"snake" = "🐍",
|
||
"octopus" = "🐙",
|
||
"shell" = "🐚",
|
||
"whale" = "🐳",
|
||
"dolphin" = "🐬",
|
||
"fish" = "🐟",
|
||
"tropical_fish" = "🐠",
|
||
"blowfish" = "🐡",
|
||
"penguin" = "🐧",
|
||
"chicken" = "🐔",
|
||
"bird" = "🐦",
|
||
"eagle" = "🦅",
|
||
|
||
// Objects
|
||
"computer" = "💻",
|
||
"iphone" = "📱",
|
||
"keyboard" = "⌨️",
|
||
"desktop_computer" = "🖥",
|
||
"printer" = "🖨",
|
||
"mouse_three_button" = "🖱",
|
||
"joystick" = "🕹",
|
||
"stash" = "💾",
|
||
"floppy_disk" = "💾",
|
||
"cd" = "💿",
|
||
"dvd" = "📀",
|
||
"vhs" = "📼",
|
||
"camera" = "📷",
|
||
"video_camera" = "📹",
|
||
"tv" = "📺",
|
||
"radio" = "📻",
|
||
"pager" = "📟",
|
||
"telephone" = "☎️",
|
||
"fax" = "📠",
|
||
"bulb" = "💡",
|
||
"candle" = "🕯",
|
||
"bathtub" = "🛁",
|
||
"shower" = "🚿",
|
||
"toilet" = "🚽",
|
||
"wrench" = "🔧",
|
||
"hammer" = "🔨",
|
||
"nut_and_bolt" = "🔩",
|
||
"gear" = "⚙️",
|
||
"link" = "🔗",
|
||
"lock" = "🔒",
|
||
"unlock" = "🔓",
|
||
"key" = "🔑",
|
||
"bell" = "🔔",
|
||
"bookmark" = "🔖",
|
||
"pushpin" = "📌",
|
||
"paperclip" = "📎",
|
||
"memo" = "📝",
|
||
"pencil2" = "✏️",
|
||
"black_nib" = "✒️",
|
||
"pen" = "🖊",
|
||
"paintbrush" = "🖌",
|
||
"crayon" = "🖍",
|
||
"book" = "📖",
|
||
"books" = "📚",
|
||
"ledger" = "📒",
|
||
"notebook" = "📓",
|
||
"scroll" = "📜",
|
||
"page_with_curl" = "📄",
|
||
"newspaper" = "📰",
|
||
"chart_with_upwards_trend" = "📈",
|
||
"chart_with_downwards_trend" = "📉",
|
||
"bar_chart" = "📊",
|
||
"calendar" = "📅",
|
||
"date" = "📅",
|
||
"hourglass" = "⌛",
|
||
"hourglass_flowing_sand" = "⏳",
|
||
"clock" = "🕐",
|
||
"alarm_clock" = "⏰",
|
||
"stopwatch" = "⏱",
|
||
"watch" = "⌚",
|
||
"moneybag" = "💰",
|
||
"yen" = "💴",
|
||
"dollar" = "💵",
|
||
"euro" = "💶",
|
||
"pound" = "💷",
|
||
"money_with_wings" = "💸",
|
||
"credit_card" = "💳",
|
||
"gem" = "💎",
|
||
"bomb" = "💣",
|
||
"gift" = "🎁",
|
||
"balloon" = "🎈",
|
||
"tada" = "🎉",
|
||
"confetti_ball" = "🎊",
|
||
"package" = "📦",
|
||
"mailbox" = "📫",
|
||
"inbox_tray" = "📥",
|
||
"outbox_tray" = "📤",
|
||
"email" = "✉️",
|
||
"envelope" = "✉️",
|
||
"incoming_envelope" = "📨",
|
||
|
||
// Activities
|
||
"soccer" = "⚽",
|
||
"basketball" = "🏀",
|
||
"football" = "🏈",
|
||
"baseball" = "⚾",
|
||
"tennis" = "🎾",
|
||
"8ball" = "🎱",
|
||
"bowling" = "🎳",
|
||
"video_game" = "🎮",
|
||
"dart" = "🎯",
|
||
"game_die" = "🎲",
|
||
"slot_machine" = "🎰",
|
||
"cards" = "🃏",
|
||
"black_joker" = "🃟",
|
||
"mahjong" = "🀄",
|
||
"musical_note" = "🎵",
|
||
"notes" = "🎶",
|
||
"saxophone" = "🎷",
|
||
"guitar" = "🎸",
|
||
"musical_keyboard" = "🎹",
|
||
"trumpet" = "🎺",
|
||
"violin" = "🎻",
|
||
"drum" = "🥁",
|
||
"headphones" = "🎧",
|
||
"microphone" = "🎤",
|
||
"level_slider" = "🎚",
|
||
"control_knobs" = "🎛",
|
||
"ticket" = "🎫",
|
||
"art" = "🎨",
|
||
"circus_tent" = "🎪",
|
||
"theater_masks" = "🎭",
|
||
"clapper" = "🎬",
|
||
|
||
// Travel
|
||
"car" = "🚗",
|
||
"taxi" = "🚕",
|
||
"bus" = "🚍",
|
||
"train" = "🚆",
|
||
"metro" = "🚇",
|
||
"light_rail" = "🚈",
|
||
"tram" = "🚊",
|
||
"bike" = "🚲",
|
||
"motorcycle" = "🏍",
|
||
"airplane" = "✈️",
|
||
"helicopter" = "🚁",
|
||
"boat" = "⛵",
|
||
"sailboat" = "⛵",
|
||
"ship" = "🚢",
|
||
"fuelpump" = "⛽",
|
||
"construction" = "🚧",
|
||
"house" = "🏠",
|
||
"house_with_garden" = "🏡",
|
||
"office" = "🏢",
|
||
"post_office" = "🏣",
|
||
"hospital" = "🏥",
|
||
"bank" = "🏦",
|
||
"hotel" = "🏨",
|
||
"school" = "🏫",
|
||
"department_store" = "🏬",
|
||
"church" = "⛪",
|
||
"castle" = "🏰",
|
||
"factory" = "🏭",
|
||
"tokyo_tower" = "🗼",
|
||
"statue_of_liberty" = "🗽",
|
||
"fountain" = "⛲",
|
||
"tent" = "⛺",
|
||
"mountain" = "⛰️",
|
||
"snow_capped_mountain" = "🏔",
|
||
"beach" = "🏖",
|
||
"camping" = "🏕",
|
||
"world_map" = "🗺",
|
||
"japan" = "🗾",
|
||
}
|
||
|
||
expand_emoji :: proc(text: string) -> string {
|
||
assert(len(EMOJIS) > 0)
|
||
|
||
sb := strings.builder_make()
|
||
defer strings.builder_destroy(&sb)
|
||
|
||
remaining := text
|
||
|
||
for {
|
||
colon := strings.index(remaining, ":")
|
||
if colon < 0 {
|
||
strings.write_string(&sb, remaining)
|
||
break
|
||
}
|
||
|
||
after := remaining[colon + 1:]
|
||
end := strings.index(after, ":")
|
||
if end < 0 {
|
||
strings.write_string(&sb, remaining)
|
||
break
|
||
}
|
||
|
||
shortcode := remaining[colon + 1:colon + 1 + end]
|
||
|
||
valid := true
|
||
for c in shortcode {
|
||
if !(c >= 'a' && c <= 'z') &&
|
||
!(c >= '0' && c <= '9') &&
|
||
c != '_' &&
|
||
c != '+' &&
|
||
c != '-' {
|
||
valid = false
|
||
break
|
||
}
|
||
}
|
||
if !valid || len(shortcode) == 0 {
|
||
strings.write_string(&sb, remaining[:colon + 1])
|
||
remaining = remaining[colon + 1:]
|
||
continue
|
||
}
|
||
|
||
emoji, found := EMOJIS[shortcode]
|
||
if !found {
|
||
strings.write_string(&sb, remaining[:colon + 1])
|
||
remaining = remaining[colon + 1:]
|
||
continue
|
||
}
|
||
|
||
strings.write_string(&sb, remaining[:colon])
|
||
strings.write_string(&sb, emoji)
|
||
remaining = remaining[colon + 1 + end + 1:]
|
||
}
|
||
|
||
return strings.to_string(sb)
|
||
}
|
||
|