THIS ... IS ... FORTRESS!

Python 3.6, 159 131 128 bytes

1 byte saved thanks to @Zacharý

3 bytes saved thanks to @VаlueInk

28 bytes saved thanks to @Rod

lambda s:len(s)<2and f"<i>{s}</i>"or s[0]==s[1]and"ℂℍℕℙℚℝℤ"[ord(s[0])-65]or[f"<b>{s[0]}</b>",s[1]][s[0]=='_']

Try it online!


Ruby, 104 106 105+1 = 105 107 106 "bytes"

Probably works even better in Retina. Uses -p flag.

-1 byte from Zacharý.

gsub /^.$/,'<i>\0</i>'
gsub(/(.)\1/){$1.tr"A-Z","ℂ-ℍ-ℕℙℚℝ-ℤ"}
gsub /(.)_/,'<b>\1</b>'
gsub ?_,''

Try it online!

Tags:

Code Golf