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.

5
  • Less can't have any idea of what HTML page the compiled CSS is applied to. See stackoverflow.com/questions/27529374 for more details. Commented Oct 24, 2019 at 12:45
  • There is no chance to automatically darken the text for the light theme of the site? Commented Oct 24, 2019 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 <span style="color: rgb(r,g,b);"> smells very bad at worst or at least it's highly-likely an XY-problem). Commented Oct 25, 2019 at 1: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! Commented Oct 25, 2019 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). Commented Oct 25, 2019 at 10:28

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.