TailwindCSS is a utility that lets one write CSS code using only HTML classes, which are then converted to CSS code with the Tailwind compiler. Ordinarily, one would write CSS in a separate file from the HTML, and reference named classes:
<!-- without Tailwind -->
<p class="crazy-monologue">Crazy? I was crazy once. They locked me in a room…</p>
.crazy-monologue {
background: black;
color: red;
opacity: 0.5;
}
With Tailwind, the CSS is auto-generated:
<!-- with Tailwind -->
<p class="background-[black] color-[red] opacity-[0.5]">
Crazy? I was crazy once. They locked me in a room…
</p>
/* auto-generated by Tailwind */
.background-\[black\]{background:black;}
.color-\[red\]{color:red;}
.opacity-\[0\.5\]{opacity:0.5;}
This is a simplified version of Tailwind; for the purposes of this challenge, all class names will be in the format property-name-[value]. The property name will be a kebab-case string, and the value will be an string consisting of alphanumeric characters and the period .. Note that the brackets [ and ] must be escaped as \[ and \] in the outputted CSS selector, and the period . must be escaped as \.. You may also backslash-escape any other characters, but doing so is not required.
Task
Given a class name in the above format, output the corresponding CSS. The CSS output is flexible; you may have any amount of whitespace before and after the curly braces and colons, and the semicolon is optional.
This is code-golf, so the shortest answer in each language wins.
Test cases
Note that since the CSS output is flexible, your output does not have to be formatted exactly as these are.
/* in: opacity-[0.5] */
/* out: */
.opacity-\[0\.5\] { opacity: 0.5 }
/* in: background-color-[lightgoldenrodyellow] */
/* out: */
.background-color-\[lightgoldenrodyellow\] {
background-color: lightgoldenrodyellow;
}
(\i)-\[(.+)]/$1-\\\[($2/[.-]/\\$3)]{$1:$2}. May write up an answer after I implement it \$\endgroup\$