XhmikosR / notepad2-mod

LOOKING FOR DEVELOPERS - Notepad2-mod, a Notepad2 fork, a fast and light-weight Notepad-like text editor with syntax highlighting
https://xhmikosr.github.io/notepad2-mod/
Other
1.45k stars 270 forks source link

Missing keywords for HTML and CSS #45

Closed Phanx closed 9 years ago

Phanx commented 11 years ago

Version: Notepad2-mod (64-bit) 4.2.25 r858 (3f0683d) Operating system: Windows 7 Professional (64-bit)

Summary:

The schemes for HTML ("Web Source Code") and CSS ("CSS Style Sheets") are both missing a number of keywords. These keywords are currently highlighted using the "unknown" settings for their respective context. To resolve the issue, they should be added to the appropriate keyword lists in Notepad2-mod.

For example, if you set the scheme to "Web Source Code" and type <main>, that element tag will be displayed using the settings for "HTML Unknown Tag" instead of the settings for "HTML Tag".

Missing HTML elements (Should use: Web Source Code > HTML Tag)

Missing deprecated HTML elements: (Should use: Web Source Code > HTML Tag)

These elements are deprecated and not part of any current standard, and some are ignored entirely by modern browsers. However, since some deprecated elements are included in the HTML highlighting scheme, I'm not sure whether you want to support old stuff or not. Let me know if you want the reverse of this list (deprecated elements that are currently recognized but chould be removed).

Missing HTML attributes: (Should use: Web Source Code > HTML Attribute)

Missing CSS @rules: (Should use: CSS Style Sheets > Directive)

Missing CSS properties: (Should use: CSS Style Sheets > CSS Property)

The above list doesn't include any of the ~75 properties that are defined in CSS3 or CSS4 but are not supported by any browsers and (in some cases) are still under revision. A list of such properties is here if you do want to do anything with them:

https://gist.github.com/phanx/c0c9f9f0ee8d3163bfcd

XhmikosR commented 11 years ago

Like I said in the other ticket, always check what works with Scite.

Apart from that, I will need a patch which then I will try to review. It's impossible to maintain all languages by myself.

Phanx commented 11 years ago

I'm not sure how this issue could be related to SciTE, as all of the keywords for all of the languages Notepad2-mod supports are listed in src/Styles.c which doesn't appear to be part of the SciTE source.

I've never touched C++ but I will do my best to copy and paste the missing keywords without breaking anything...

Phanx commented 11 years ago

Here you go:
https://github.com/XhmikosR/notepad2-mod/pull/47

Phanx commented 11 years ago

It also looks like you could easily support separate highlighting for pseudo-classes and pseudo-elements by splitting line 304 in src\Styles.c:

                 { MULTI_STYLE(SCE_CSS_PSEUDOCLASS,SCE_CSS_EXTENDED_PSEUDOCLASS,SCE_CSS_PSEUDOELEMENT,SCE_CSS_EXTENDED_PSEUDOELEMENT), 63197, L"Pseudo-class/element", L"fore:#B000B0", L"" },

into two:

                 { MULTI_STYLE(SCE_CSS_PSEUDOCLASS,SCE_CSS_EXTENDED_PSEUDOCLASS), 63197, L"Pseudo-class", L"fore:#B000B0", L"" },
                 { MULTI_STYLE(SCE_CSS_PSEUDOELEMENT,SCE_CSS_EXTENDED_PSEUDOELEMENT), 63197, L"Pseudo-element", L"fore:#B000B0", L"" },

However, I did not include this in my pull request, as I have no idea how localization (L"text") is handled or whether anything needs to be added anywhere else to support this change.

QWp6t commented 11 years ago

Scintilla's CSS lexer can actually separately support

In other words, if we really wanted to, we could support different styles for each of these types of keywords.

I think there's just always been a consensus that it's not worth the effort. If anything, I would propose refactoring CSS1 properties as what's part of modern spec and currently supported in most browsers; CSS2 as deprecated properties; and CSS3 as modern or future spec unsupported in most browsers. Since these are all more or less cosmetic changes, it shouldn't be an issue to simply refactor them if anyone ever wants to go through the trouble. Personally I just don't see the point.

Phanx commented 11 years ago

Highlighting CSS1/2/3 properties separately wouldn't be useful; I don't care which spec first included "height", for example. Same goes for highlighting vendor-specific properties separately; ideally those wouldn't exist at all, but since they do, they really aren't any different than standard properties.

However, highlighting pseudo-classes and pseudo-elements separately is useful. For example, if I use CSS to set the content of an element selected with a pseudo-class -- img:first-child { content: "X" } -- the selected img element will be replaced by a single "X" character. But if I set the content of an element selected with a pseudo-element -- img::before { content: "X" } -- a new element is created before the selected img element with a single "X" character as its contents. They serve separate roles.

XhmikosR commented 11 years ago

I'll have a look later today or tomorrow. Thanks for the patches.