How to get style variables in coffee?


I have to give a foreground color into ‘ansi-to-html’, which should be @text-color. However I didn’t find a way to work.


It’s not possible to get style variables in CoffeeScript, unless you find the path to the variables file and parse it yourself or something. The recommended way is to do it using LESS:

@import "syntax-variables";

my-element {
  color: @text-color;


Well, I’d like to use the variables always in LESS myself. But, the ‘ansi-to-html’ package will set the color of non-colored words to #FFF if I don’t assign a foreground color, which means I must get the @text-color in the CoffeeSscript.

I’m now think to rewrite the ‘ansi-to-html’ package myself.


You can make some dummy elements which you apply the wanted style to and then read the values with JS. Saves you rewriting ansi-to-html :slight_smile: