GNOME Bugzilla – Bug 747129
Syntax file for CSV files
Last modified: 2015-04-17 18:30:33 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'.
Created attachment 300694 [details] [review] Add lang file for (basic) CSV Basic .lang file for CSV
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
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).
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 "?
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.
Review of attachment 301575 [details] [review]: Ok, the csv.lang looks good. Can you provide an example file in tests/syntax-highlighting/?
Created attachment 301670 [details] [review] Basic .lang file for CSV + interger and floating-point numbers + test file Sure.
Review of attachment 301670 [details] [review]: Commit pushed: https://git.gnome.org/browse/gtksourceview/commit/?id=9a31304764239d37e1cbfc6b6eba52ff62a29587 Thanks!