Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1# -*- coding: utf-8 -*- 

2""" 

3 pygments.styles 

4 ~~~~~~~~~~~~~~~ 

5 

6 Contains built-in styles. 

7 

8 :copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS. 

9 :license: BSD, see LICENSE for details. 

10""" 

11 

12from pygments.plugin import find_plugin_styles 

13from pygments.util import ClassNotFound 

14 

15 

16#: Maps style names to 'submodule::classname'. 

17STYLE_MAP = { 

18 'default': 'default::DefaultStyle', 

19 'emacs': 'emacs::EmacsStyle', 

20 'friendly': 'friendly::FriendlyStyle', 

21 'colorful': 'colorful::ColorfulStyle', 

22 'autumn': 'autumn::AutumnStyle', 

23 'murphy': 'murphy::MurphyStyle', 

24 'manni': 'manni::ManniStyle', 

25 'monokai': 'monokai::MonokaiStyle', 

26 'perldoc': 'perldoc::PerldocStyle', 

27 'pastie': 'pastie::PastieStyle', 

28 'borland': 'borland::BorlandStyle', 

29 'trac': 'trac::TracStyle', 

30 'native': 'native::NativeStyle', 

31 'fruity': 'fruity::FruityStyle', 

32 'bw': 'bw::BlackWhiteStyle', 

33 'vim': 'vim::VimStyle', 

34 'vs': 'vs::VisualStudioStyle', 

35 'tango': 'tango::TangoStyle', 

36 'rrt': 'rrt::RrtStyle', 

37 'xcode': 'xcode::XcodeStyle', 

38 'igor': 'igor::IgorStyle', 

39 'paraiso-light': 'paraiso_light::ParaisoLightStyle', 

40 'paraiso-dark': 'paraiso_dark::ParaisoDarkStyle', 

41 'lovelace': 'lovelace::LovelaceStyle', 

42 'algol': 'algol::AlgolStyle', 

43 'algol_nu': 'algol_nu::Algol_NuStyle', 

44 'arduino': 'arduino::ArduinoStyle', 

45 'rainbow_dash': 'rainbow_dash::RainbowDashStyle', 

46 'abap': 'abap::AbapStyle', 

47 'solarized-dark': 'solarized::SolarizedDarkStyle', 

48 'solarized-light': 'solarized::SolarizedLightStyle', 

49 'sas': 'sas::SasStyle', 

50 'stata': 'stata_light::StataLightStyle', 

51 'stata-light': 'stata_light::StataLightStyle', 

52 'stata-dark': 'stata_dark::StataDarkStyle', 

53 'inkpot': 'inkpot::InkPotStyle', 

54} 

55 

56 

57def get_style_by_name(name): 

58 if name in STYLE_MAP: 

59 mod, cls = STYLE_MAP[name].split('::') 

60 builtin = "yes" 

61 else: 

62 for found_name, style in find_plugin_styles(): 

63 if name == found_name: 

64 return style 

65 # perhaps it got dropped into our styles package 

66 builtin = "" 

67 mod = name 

68 cls = name.title() + "Style" 

69 

70 try: 

71 mod = __import__('pygments.styles.' + mod, None, None, [cls]) 

72 except ImportError: 

73 raise ClassNotFound("Could not find style module %r" % mod + 

74 (builtin and ", though it should be builtin") + ".") 

75 try: 

76 return getattr(mod, cls) 

77 except AttributeError: 

78 raise ClassNotFound("Could not find style class %r in style module." % cls) 

79 

80 

81def get_all_styles(): 

82 """Return a generator for all styles by name, 

83 both builtin and plugin.""" 

84 yield from STYLE_MAP 

85 for name, _ in find_plugin_styles(): 

86 yield name