1

There are some span tags with code like this:

<span style="color: rgb(r,g,b);">Text</span>

Need to convert HTML attribute to LESS variable.

.block(@rgb){
    @ccolor: ~'style="color: @{rgb}';
    span[@{ccolor}]{color:darken(@rgb, 30%);}
}

I can’t designate an HTML object.

Koxae Sun
  • 11
  • 1
  • Less can't have any idea of what HTML page the compiled CSS is applied to. See https://stackoverflow.com/questions/27529374 for more details. – seven-phases-max Oct 24 '19 at 12:45
  • There is no chance to automatically darken the text for the light theme of the site? – Koxae Sun Oct 24 '19 at 14:13
  • *There is no chance to automatically darken...* If you need to darken (or apply whatever modification to) a color hardcoded within HTML the thing you need is just some color manipulation JS lib. (There're probably other options but then you'll need to provide more details for your use-case. That `` smells very bad at worst or at least it's highly-likely an XY-problem). – seven-phases-max Oct 25 '19 at 01:43
  • Thanks for the answer. This situation is made from custom colors in forum posts. People paint their text in different colors. And this is the problem. I will limit the choice of color, unless otherwise fixed. Thank! – Koxae Sun Oct 25 '19 at 10:13
  • Then just as I said above a JS lib is the proper way. After all these Less color manipulation functions are nothing but 5-10 lines of code functions written in JS (there's no reason to bother with HTML -> Less -> JS -> Less -> CSS -> HTML execution chain (even if it would be possible) where you can have just HTML -> JS -> HTML one). – seven-phases-max Oct 25 '19 at 10:28

0 Answers0