You are here: PSPad forum > Bug report / Hlášení chyb > An error in syntax highlighter for CSS

An error in syntax highlighter for CSS

#1 An error in syntax highlighter for CSS

Posted by: Andreas | Date: 2016-08-19 22:06 | IP: IP Logged

Hello Jan,

I actually wanted to report this years ago. Finaly it's comming up now winking smiley

As you can see in this screenshot the highlighter seems not to respect nested curly brackets. The selector "body" should get the color for selectors every time. A selector at this position seems not to get recognized as a selector.

image

Options: Reply | Quote | Up ^


#2 Re: An error in syntax highlighter for CSS

Posted by: Andreas | Date: 2017-01-19 17:35 | IP: IP Logged

Hello Jan,

I like to push this one as you are working a lot on different highlighters recently. Is it possible for you to fix this one?

Regards Andreas

Options: Reply | Quote | Up ^


#3 Re: An error in syntax highlighter for CSS

Posted by: pspad | Date: 2017-01-20 08:45 | IP: IP Logged

Hello

I commited some changes made in CSS from Github. I hope it will make CSS highlighter better + it fixed your problem.

I am not sure about default colors. Can you please set some "nice" (or standard) default colors for CSS attributes and send me [Cascading Syle Sheets] section from your PSPad.ini? I will set it as default.

Options: Reply | Quote | Up ^


#4 Re: An error in syntax highlighter for CSS

Posted by: Andreas | Date: 2017-01-21 00:43 | IP: IP Logged

The colors are not important. Meanwhile I use a modified Monokai theme.
image

Unfortunately I can not reset the theme to "Standard" as in my highlighter settings the CSS with "Standard" theme has the same background color as my modded Monokai. But I never saved the Standard theme with those backgrounds.
image

The thing is, that every selector should have the same color. In the example above these are the selectors
- @media print
- body
- body
Every selector should have this pink color, but the first selector in nested rules gets not recognized as selector. The first one here always is white as you can see with the first "body". This is white and this is wrong.


/* nested rules */
selector {
selector {
property: value;
}
selector {
property: value;
}
}

Looks like the first nested selector (here the first body) gets treated as property and as body is not a valid property it gets the color of unknown properties.

I think you have to do a look behind.

A property is always followed by a colon ":". Curly brackets never are part of a property.

There can be whitespaces between property and colon "color:", "color :". Default is no whitespace.

So here "body {" can never be a property, as there is a curly bracket before a colon exists.

Proterties only exist of [a-zA-Z-] (regex syntax). Lower case is default.

Edited 1 time(s). Last edit at 2017-01-21 00:47 by Andreas.

Options: Reply | Quote | Up ^






Editor PSPad - freeware editor, © 2001 - 2024 Jan Fiala, Hosted by Webhosting TOJEONO.CZ, design by WebDesign PAY & SOFT, code Petr Dvořák, Privacy policy and GDPR