After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 747129 - Syntax file for CSV files
Syntax file for CSV files
Status: RESOLVED FIXED
Product: gtksourceview
Classification: Platform
Component: Syntax files
git master
Other All
: Normal enhancement
: ---
Assigned To: GTK Sourceview maintainers
GTK Sourceview maintainers
Depends on:
Blocks:
 
 
Reported: 2015-03-31 18:01 UTC by Martin Blanchard
Modified: 2015-04-17 18:30 UTC
See Also:
GNOME target: ---
GNOME version: Unversioned Enhancement


Attachments
Add lang file for (basic) CSV (2.85 KB, patch)
2015-03-31 18:04 UTC, Martin Blanchard
none Details | Review
Basic .lang file for CSV + decimal numbers (3.19 KB, patch)
2015-04-01 20:12 UTC, Martin Blanchard
none Details | Review
Basic .lang file for CSV + interger and floating-point numbers (3.65 KB, patch)
2015-04-14 21:05 UTC, Martin Blanchard
none Details | Review
Basic .lang file for CSV + interger and floating-point numbers + test file (4.19 KB, patch)
2015-04-15 18:51 UTC, Martin Blanchard
committed Details | Review

Description Martin Blanchard 2015-03-31 18:01:24 UTC
Even if often considered as an 'evil' file format, CSV is widly use especally in  public open-data initiatives. Could be interesting to support it, at least for the buffer.get_language().get_id() == 'csv'.
Comment 1 Martin Blanchard 2015-03-31 18:04:17 UTC
Created attachment 300694 [details] [review]
Add lang file for (basic) CSV

Basic .lang file for CSV
Comment 2 Paolo Borelli 2015-04-01 06:23:15 UTC
This sounds like a good idea, but it should be probably be fleshed out a bit more, for instance I think we should match numeric fields

This also will have to wait for the string freeze to be lifted
Comment 3 Martin Blanchard 2015-04-01 20:12:41 UTC
Created attachment 300777 [details] [review]
Basic .lang file for CSV + decimal numbers

Agreed. Anyway, not sure what is the right thing to do here: rfc doesn't mention anything about numbers and everyday-life files often have unpredictable numeric formats. New version matches decimal numbers (including integers).
Comment 4 Sébastien Wilmet 2015-04-13 13:41:52 UTC
Review of attachment 300777 [details] [review]:

::: data/language-specs/csv.lang
@@ +34,3 @@
+
+  <definitions>
+    <context id="decimal" style-ref="decimal">

It's probably better to reference the contexts defined in def.lang: decimal, octal, hexadecimal and float.

@@ +42,3 @@
+    </context>
+
+    <context id="string" style-ref="string" class="string" class-disabled="no-spell-check">

Same for matching strings, I think we can use the 'string' and 'single-quoted-string' contexts.

@@ +48,3 @@
+        <context id="escaped-character" style-ref="escaped-character">
+          <match>
+            \"\"

Btw, why _two_ escaped "?
Comment 5 Martin Blanchard 2015-04-14 21:05:35 UTC
Created attachment 301575 [details] [review]
Basic .lang file for CSV + interger and floating-point numbers

rfc4180 describes CSV format like this: fieds "may or may not be enclosed in double quotes" and if they are, double quotes "must be escaped by preceding it with another double quote".

Regarding numbers, the problem with def:decimal is that it does not match '01' or '001' which are often use as index (because of their fix character length).
def:float has the advantage of supporting scientific notation but not '.001' format.

Again, rfc defines no standard for numbers. Not sure about octal and hexadecimal, but making a difference between integers and floating-points is interesting I guess. New version attached.
Comment 6 Sébastien Wilmet 2015-04-15 08:39:30 UTC
Review of attachment 301575 [details] [review]:

Ok, the csv.lang looks good. Can you provide an example file in tests/syntax-highlighting/?
Comment 7 Martin Blanchard 2015-04-15 18:51:51 UTC
Created attachment 301670 [details] [review]
Basic .lang file for CSV + interger and floating-point numbers + test file

Sure.