Back to index

moin  1.9.0~rc2
Public Member Functions
MoinMoin.support.pygments.style.StyleMeta Class Reference

List of all members.

Public Member Functions

def __new__
def style_for_token
def list_styles
def styles_token
def __iter__
def __len__

Detailed Description

Definition at line 15 of file style.py.


Member Function Documentation

Definition at line 99 of file style.py.

00099 
00100     def __iter__(cls):
00101         for token in cls._styles:
00102             yield token, cls.style_for_token(token)

Definition at line 103 of file style.py.

00103 
00104     def __len__(cls):
00105         return len(cls._styles)
00106 

def MoinMoin.support.pygments.style.StyleMeta.__new__ (   mcs,
  name,
  bases,
  dct 
)

Definition at line 17 of file style.py.

00017 
00018     def __new__(mcs, name, bases, dct):
00019         obj = type.__new__(mcs, name, bases, dct)
00020         for token in STANDARD_TYPES:
00021             if token not in obj.styles:
00022                 obj.styles[token] = ''
00023 
00024         def colorformat(text):
00025             if text[0:1] == '#':
00026                 col = text[1:]
00027                 if len(col) == 6:
00028                     return col
00029                 elif len(col) == 3:
00030                     return col[0]+'0'+col[1]+'0'+col[2]+'0'
00031             elif text == '':
00032                 return ''
00033             assert False, "wrong color format %r" % text
00034 
00035         _styles = obj._styles = {}
00036 
00037         for ttype in obj.styles:
00038             for token in ttype.split():
00039                 if token in _styles:
00040                     continue
00041                 ndef = _styles.get(token.parent, None)
00042                 styledefs = obj.styles.get(token, '').split()
00043                 if  not ndef or token is None:
00044                     ndef = ['', 0, 0, 0, '', '', 0, 0, 0]
00045                 elif 'noinherit' in styledefs and token is not Token:
00046                     ndef = _styles[Token][:]
00047                 else:
00048                     ndef = ndef[:]
00049                 _styles[token] = ndef
00050                 for styledef in obj.styles.get(token, '').split():
00051                     if styledef == 'noinherit':
00052                         pass
00053                     elif styledef == 'bold':
00054                         ndef[1] = 1
00055                     elif styledef == 'nobold':
00056                         ndef[1] = 0
00057                     elif styledef == 'italic':
00058                         ndef[2] = 1
00059                     elif styledef == 'noitalic':
00060                         ndef[2] = 0
00061                     elif styledef == 'underline':
00062                         ndef[3] = 1
00063                     elif styledef == 'nounderline':
00064                         ndef[3] = 0
00065                     elif styledef[:3] == 'bg:':
00066                         ndef[4] = colorformat(styledef[3:])
00067                     elif styledef[:7] == 'border:':
00068                         ndef[5] = colorformat(styledef[7:])
00069                     elif styledef == 'roman':
00070                         ndef[6] = 1
00071                     elif styledef == 'sans':
00072                         ndef[7] = 1
00073                     elif styledef == 'mono':
00074                         ndef[8] = 1
00075                     else:
00076                         ndef[0] = colorformat(styledef)
00077 
00078         return obj

Definition at line 93 of file style.py.

00093 
00094     def list_styles(cls):
00095         return list(cls)

Definition at line 79 of file style.py.

00079 
00080     def style_for_token(cls, token):
00081         t = cls._styles[token]
00082         return {
00083             'color':        t[0] or None,
00084             'bold':         bool(t[1]),
00085             'italic':       bool(t[2]),
00086             'underline':    bool(t[3]),
00087             'bgcolor':      t[4] or None,
00088             'border':       t[5] or None,
00089             'roman':        bool(t[6]) or None,
00090             'sans':         bool(t[7]) or None,
00091             'mono':         bool(t[8]) or None,
00092         }

Definition at line 96 of file style.py.

00096 
00097     def styles_token(cls, ttype):
00098         return ttype in cls._styles


The documentation for this class was generated from the following file: