lookatme.render.pygments module¶
Pygments related rendering
-
class
lookatme.render.pygments.
UrwidFormatter
(**options)¶ Bases:
pygments.formatter.Formatter
Formatter that returns [(text,attrspec), …], where text is a piece of text, and attrspec is an urwid.AttrSpec
-
classmethod
findclosest
(colstr, colors=256)¶ Takes a hex string and finds the nearest color to it.
Returns a string urwid will recognize.
-
findclosestattr
(fgcolstr=None, bgcolstr=None, othersettings='', colors=256)¶ Takes two hex colstring (e.g. ‘ff00dd’) and returns the nearest urwid style.
-
format
(tokensource, outfile)¶ Format
tokensource
, an iterable of(tokentype, tokenstring)
tuples and write it intooutfile
.
-
formatgenerator
(tokensource)¶ Takes a token source, and generates (tokenstring, urwid.AttrSpec) pairs
-
style
¶
-
classmethod
-
lookatme.render.pygments.
get_formatter
(style_name)¶
-
lookatme.render.pygments.
get_lexer
(lang, default='text')¶
-
lookatme.render.pygments.
get_style
(style_name)¶
-
lookatme.render.pygments.
render_text
(text, lang='text', style_name=None, plain=False)¶ Render the provided text with the pygments renderer