Fortress was a language being developed by the Sun Programming Language Research Group (R.I.P. Fortress) that had a unique property to it, it was possible to render ("Fortify") programs in different font-styles (i.e. blackboard bold, bold, italics, roman, etc. ). The goal is to represent a one-char Fortress variable in HTML markup.
Here's how the fortification of one-char variables worked (simplified/modified from documentation for code-golfing purposes):
- If the variable is a repeated capital (i.e.
ZZ
), it becomes formatted in blackboard bold (πΈπΉβπ»πΌπ½πΎβπππππβπβββπππππππβ€
) - If the variable is preceded by an underscore, the variable is rendered in roman font (left alone)
- If the variable is followed by an underscore, the variable is rendered in bold font (
<b>
v</b>
) - If the variable is neither preceded nor followed by an underscore, the variable is rendered in italic font (
<i>
v</i>
) - The codepoints of the blackboard bolds are:
πΈ
:1D538,πΉ
:1D539,β
:2102,π»
:1D53B,πΌ
:1D53C,π½
:1D53D,πΎ
:1D53E,β
:210D,π
:1D540,π
:1D541,π
:1D542,π
:1D543,π
:1D544,β
:2115,π
:1D546,β
:2119,β
:211A,β
:211D,π
:1D54A,π
:1D54B,π
:1D54C,π
:1D54D,π
:1D54E,π
:1D54F,π
:1D550,β€
:2124. These count as one byte each in your program (if your language of choice can handle these characters at all)
Input will be either a repeated ASCII capital, or a single ASCII letter with either no underscore, a leading underscore, or a trailing underscore (AKA _a_
will not be an input). This is code-golf so lowest byte count wins!
Test cases:
a => <i>a</i>
BB => πΉ
c_ => <b>c</b>
_d => d
E => <i>E</i>
G_ => <b>G</b>
_H => H
ZZ => β€
Links: Specification, Direct download of version 0.1 alpha.
Reference implementation (This would be in Fortress, but Fortress doesn't like most of the doublestruck characters, so this implementation is in D):
dstring fortify(string arg) {
import std.string, std.conv;
alias D = to!dstring; //Convert to a string that accepts the unicode needed
dstring BB = "πΈπΉβπ»πΌπ½πΎβπππππβπβββπππππππβ€"d; //blackboard bold capitals
string UC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; //normal ASCII capitals
if(arg.length == 1)
return D("<i>" ~ arg ~ "</i>");
if(arg[0] == a[1])
return D(BB[UC.indexOf(arg[0])]);
if(arg[0] == '_')
return D(arg[1]);
return D("<b>" ~ arg[0] ~ "</b>");
}
_____
won't be input. \$\endgroup\$