Bug 605071 - Bibtex syntax highlighting
Bibtex syntax highlighting
Status: RESOLVED FIXED
Product: gtksourceview
Classification: Platform
Component: Syntax files
2.8.x
Other Linux
: Normal normal
: ---
Assigned To: GTK Sourceview maintainers
GTK Sourceview maintainers
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2009-12-20 16:24 UTC by søren hauberg
Modified: 2009-12-23 13:44 UTC (History)
1 user (show)

See Also:
GNOME target: ---
GNOME version: ---


Attachments
Bibtex syntax highlighting (3.03 KB, application/octet-stream)
2009-12-20 16:24 UTC, søren hauberg
  Details
Updated lang file (3.03 KB, patch)
2009-12-22 19:25 UTC, søren hauberg
none Details | Diff | Review
New lang file with latex support (2.80 KB, patch)
2009-12-23 13:11 UTC, søren hauberg
none Details | Diff | Review

Description søren hauberg 2009-12-20 16:24:48 UTC
Created attachment 150113 [details]
Bibtex syntax highlighting

Hi

Gedit is currently missing syntax highlighting for bibtex (bibliography for latex). The attached .lang file does this.

However, I get the following warning from gedit when I use the bibtex syntax highlighting:

  ERROR:Editor:create_marker(): end offset out of range (16529 > 16525)

I don't know what this means, so I don't know how to fix it; hopefully, somebody else does.

Søren
Comment 1 Ignacio Casal Quinteiro (nacho) 2009-12-22 18:48:40 UTC
Haven't tested yet the file so not sure about that error yet. Some comments about the file. It looks good but I'd like changed the next:
- <style id="fields" _name="Fields" map-to="def:decimal"/> this doesn't look correct to me, the fields aren't a decimal number. You should choose another map for it.

Also I'd like to know if you checked if text/x-bibtex is the right mime type for the lang file.

Apart from that it looks good to me.
Comment 2 søren hauberg 2009-12-22 19:03:16 UTC
I started out by mapping 'Fields' to 'keyword', but then 'entry-types' (which currently map to 'keyword') both have the same colour. Is there a list of style classes (or whatever you call these) available somewhere such that I can pick something more suitable to map to?

As to the mime type, then 'text/x-bibtex' is what is being reported by 'gedit' when I open a bibtex file, so I think it is correct.
Comment 3 Ignacio Casal Quinteiro (nacho) 2009-12-22 19:15:11 UTC
Well, in the def.lang file you have a list of mappings.
http://git.gnome.org/browse/gtksourceview/tree/gtksourceview/language-specs/def.lang

Also you can use you're own style and then mapping it in the scheme color. But it is not really a good idea.
Comment 4 søren hauberg 2009-12-22 19:25:48 UTC
Created attachment 150247 [details] [review]
Updated lang file

Nice! I've mapped 'Field' to 'identifier' which seemed vague enough cover this case.
Comment 5 Ignacio Casal Quinteiro (nacho) 2009-12-23 12:04:10 UTC
I've been testing the lang file, and I think it should include or the whole latex context or part of it.
http://shelah.logic.at/listb.bib
that's the file with which I tested.
Comment 6 søren hauberg 2009-12-23 12:32:34 UTC
In principle I agree with you that the bibtex highlighting should also be able to highlight TeX code. This, however, goes beyond my capabilities, so I can't help :-(

In general, the .lang file I sent is highly simplistic. For example, it will highlight the word "Journal" when it appears in the name of a journal.

Unless somebody skilled enough is willing to create a proper .lang file (that knows TeX and properly parses the text), then I would recommend that my .lang file is used. It might not be very good, but it's better than the current situation (no highlighting).

Søren
Comment 7 Ignacio Casal Quinteiro (nacho) 2009-12-23 12:40:55 UTC
to get latex highlight it is quite easy you just have to ref latex:latex in your main context. Have a look at xslt.lang for example. <context ref="xml:xml"/>
Comment 8 søren hauberg 2009-12-23 13:11:41 UTC
Created attachment 150287 [details] [review]
New lang file with latex support

Wow, that was easy :-)

The attached .lang file now also has LaTeX support. Since LaTeX supports comments, I removed these from the bibtex lang file (we get them for free from LaTeX).

It still annoys me a bit that, e.g. the word 'Journal' is highlighted when appears in the title of a journal, but I don't know how to deal with that.
Comment 9 Ignacio Casal Quinteiro (nacho) 2009-12-23 13:44:33 UTC
Pushed your lang file with minor changes. Thanks a lot for it.

Note You need to log in before you can comment on or make changes to this bug.