GNOME Bugzilla – Bug 605071
Bibtex syntax highlighting
Last modified: 2009-12-23 13:44:33 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
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.
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.
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.
Created attachment 150247 [details] [review] Updated lang file Nice! I've mapped 'Field' to 'identifier' which seemed vague enough cover this case.
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.
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
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"/>
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.
Pushed your lang file with minor changes. Thanks a lot for it.