Gettext Message Catalogs Lexer

Issue #266 resolved
Former user created an issue

Here's a custom Gettext Message Catalogs Lexer.

I'm sure that there might be some bad usage, but it was a trial and error work, just hope it helps others. {{{

!python

import re from pygments.lexer import RegexLexer, bygroups from pygments.token import *

class GettextLexer(RegexLexer): name = 'Gettext Catalog' aliases = ['pot', 'po'] filenames = ['.pot', '.po'] mimetypes = ['application/x-gettext', 'text/x-gettext', 'text/gettext']

tokens = {
    'root': [
        (r'^#,\\s.*?$', Keyword.Type),
        (r'^#:\\s.*?$', Keyword.Declaration),
        #(r'^#$', Comment),
        (r'^(#|#\\.\\s|#\\|\\s|#~\\s|#\\s).*$', Comment.Single),
        (r'^(")([\\w-]*:)(.*")$',
         bygroups(String, Name.Property, String)),
        (r'^".*"$', String),
        (r'^(msgid|msgid_plural|msgstr)(\\s+)(".*")$',
         bygroups(Name.Variable, Text, String)),
        (r'^(msgstr\\[)(\\d)(\\])(\\s+)(".*")$',
         bygroups(Name.Variable, Number.Integer, Name.Variable, Text, String)),
    ]
}

}}}

Reported by guest

Comments (4)

  1. Log in to comment