Properly highlight LESS and SCSS files

#1

Pygments already has LESS and SCSS lexers :http://pygments.org/docs/lexers/

But Phabricator still highlights this files just like plain CSS:

https://secure.phabricator.com/source/libphutil/browse/master/src/markup/syntax/highlighter/PhutilPygmentsSyntaxHighlighter.php;32746e8b0793995ab90ce8acde138e99e75a58ed$123
https://secure.phabricator.com/source/libphutil/browse/master/src/markup/syntax/highlighter/PhutilPygmentsSyntaxHighlighter.php;32746e8b0793995ab90ce8acde138e99e75a58ed$183

0 Likes

#2

See https://secure.phabricator.com/T3626.

As a workaround, you can configure syntax.filemap to the correct values.

0 Likes

#3

Seems it doesn’t work for these filetypes.

Not shure how it works exactly, but it looks like even I set syntax.filemap to

{
"@\.scss$@": “scss”
}

It will get value for scss key from getPygmentsLexerNameFromLanguageName method:

'scss' => 'css'

and highlights the file with css lexer.

0 Likes

#4

Try clearing the caches; file highlighting is expensive, so it’s cached. use ./bin/cache purge changeset, I think.

0 Likes

#5

Yes, I have purged the cache with command

./bin/cache purge --all

Also I have purged cache in web interace.

But nothing happened with scss file highlighting.

It was worked only when I changed value directly in PhutilPygmentsSyntaxHighlighter class.

Other syntax.filemap entries works as expected ( "@\\.arclint$@": "json" for example)

Also I noticed that scss highlighting looks worsed than “default” css highlighting for Sass files :slightly_smiling_face:.

https://tppr.me/zK0Uc - css
https://tppr.me/mhntW - scss

0 Likes