Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add LESS language support #101

Closed
calvinjuarez opened this issue Dec 19, 2013 · 3 comments
Closed

Add LESS language support #101

calvinjuarez opened this issue Dec 19, 2013 · 3 comments
Milestone

Comments

@calvinjuarez
Copy link

What would I have to do to get this to happen?

@ucarion
Copy link

ucarion commented Dec 28, 2013

@calvinjuarez Perhaps you're looking for Pygments.css? This returns a string that is CSS, but is valid LESS code as well.

@calvinjuarez
Copy link
Author

@ulyssecarion Pardon? Would that make it possible for GitHub to highlight blocks of code labeled 'less'? Because that's what I'm looking to do.

@ucarion
Copy link

ucarion commented Dec 30, 2013

@calvinjuarez Oh, I misunderstood you.

I haven't found any less parsers, but there is a SCSS parser. Would that do it for you? It's definitely not perfect, though. Here is what the Scss parser produces when faced with some LESS (which I got from lesscss.org):

@base: #f938ab;

.box-shadow(@style, @c) when (iscolor(@c)) {
  -webkit-box-shadow: @style @c;
  -moz-box-shadow:    @style @c;
  box-shadow:         @style @c;
}
.box-shadow(@style, @alpha: 50%) when (isnumber(@alpha)) {
  .box-shadow(@style, rgba(0, 0, 0, @alpha));
}
.box { 
  color: saturate(@base, 5%);
  border-color: lighten(@base, 30%);
  div { .box-shadow(0 0 5px, 30%) }
}

If you're limited to strictly GitHub, I think that's the best you can do (though you might want to try both sass and scss, since sometimes one seems to work better than the other for less). Adding direct support for Less would require adding a Less lexer to Pygments itself, which you can learn about here, though that might be tricky to do if you've never made a lexer or used Python before.

Perhaps you may want to voice your interest for a Less lexer in this Pygments issue on Bitbucket.

Hope this helps.

slonopotamus added a commit to slonopotamus/pygments.rb that referenced this issue Jan 5, 2021
@slonopotamus slonopotamus added this to the 2.0 milestone Jan 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants