Bug 457548 - [PATCH] CartoCSS has wrong syntax highlighting when the last statement in curly braces does not terminate with a semicolon
Summary: [PATCH] CartoCSS has wrong syntax highlighting when the last statement in cur...
Status: RESOLVED FIXED
Alias: None
Product: frameworks-syntax-highlighting
Classification: Frameworks and Libraries
Component: syntax (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-08-06 11:24 UTC by Lukas Sommer
Modified: 2022-08-14 23:16 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
carto-css.xml (13.05 KB, text/xml)
2022-08-06 11:24 UTC, Lukas Sommer
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Lukas Sommer 2022-08-06 11:24:48 UTC
Created attachment 151145 [details]
carto-css.xml

SUMMARY

[PATCH] CartoCSS has wrong syntax highlighting when the last statement in curly braces does not terminate with a semicolon


STEPS TO REPRODUCE
Use the following example.mss with carto-css.xml syntax highlighting:

[zoom >= 17] {
  text-size: 9;
  text-repeat-distance: 10
}
[zoom >= 19] { text-size: 11; }

OBSERVED RESULT

The second “zoom” is not highlighted correctly.

EXPECTED RESULT

The second “zoom” is not highlighted correctly.

ADDITIONAL INFORMATION

The reason is the “missing” semicolon after “10”. The current carto-css.xml assumes that each statement within curly braces has to be terminated with a semicolon. However, the CartoCSS parser accepts (and without warnings!) that the last statement before curly braces is NOT terminated with a semicolon. So currently, we get wrong highlighting for syntactically correct CartoCSS files.

The attached patch 
- fixes this issue by adding the necessary context switches to get correct highlighting
- fixes the spell checking configuration (data field names and variable names should not be spell-checked because often they use abbreviations and the name of data fields is usually outside the influence of the CartoCSS user
- use entities instead of repeating the same string (does not change the highlighting, but makes the XML code more structured)
Comment 1 Jonathan Poelen 2022-08-14 23:15:48 UTC
Commit: https://invent.kde.org/frameworks/syntax-highlighting/-/commit/ce3eed7d886d57813116261592cc6b2cc81224dc

The link is not made automatically because I did not write BUG correctly