Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/jupyterlab_pygments/style.py: 100%

7 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2023-07-01 06:54 +0000

1# Copyright (c) Jupyter Development Team. 

2# Distributed under the terms of the Modified BSD License. 

3 

4from pygments.style import Style 

5from pygments.token import ( 

6 Comment, Error, Generic, Keyword, Literal, Name, Number, Operator, Other, 

7 Punctuation, String, Text, Whitespace) 

8 

9 

10class JupyterStyle(Style): 

11 """ 

12 A pygments style using JupyterLab CSS variables. 

13 

14 The goal is to mimick JupyterLab's codemirror theme. 

15 

16 Known impossibilities: 

17 

18 - With pygments, the dot in `foo.bar` is considered an Operator (class: 'o'), 

19 while in codemirror, it is bare text. 

20 - With pygments, in both `from foo import bar`, and `foo.bar`, "bar" is 

21 considered a Name (class: 'n'), while in coremirror, the latter is a property. 

22 

23Available CSS variables are 

24 

25 --jp-mirror-editor-keyword-color 

26 --jp-mirror-editor-atom-color 

27 --jp-mirror-editor-number-color 

28 --jp-mirror-editor-def-color 

29 --jp-mirror-editor-variable-color 

30 --jp-mirror-editor-variable-2-color 

31 --jp-mirror-editor-variable-3-color 

32 --jp-mirror-editor-punctuation-color 

33 --jp-mirror-editor-property-color 

34 --jp-mirror-editor-operator-color 

35 --jp-mirror-editor-comment-color 

36 --jp-mirror-editor-string-color 

37 --jp-mirror-editor-string-2-color 

38 --jp-mirror-editor-meta-color 

39 --jp-mirror-editor-qualifier-color 

40 --jp-mirror-editor-builtin-color 

41 --jp-mirror-editor-bracket-color 

42 --jp-mirror-editor-tag-color 

43 --jp-mirror-editor-attribute-color 

44 --jp-mirror-editor-header-color 

45 --jp-mirror-editor-quote-color 

46 --jp-mirror-editor-link-color 

47 --jp-mirror-editor-error-color 

48 """ 

49 

50 default_style = '' 

51 background_color = 'var(--jp-cell-editor-background)' 

52 highlight_color = 'var(--jp-cell-editor-active-background)' 

53 

54 styles = { 

55 Text: 'var(--jp-mirror-editor-variable-color)', # no class 

56 Whitespace: '', # class: 'w' 

57 Error: 'var(--jp-mirror-editor-error-color)', # class: 'err' 

58 Other: '', # class: 'x' 

59 

60 Comment: 'italic var(--jp-mirror-editor-comment-color)', # class: 'c' 

61 #Comment.Multiline: '', # class: 'cm' 

62 #Comment.Preproc: '', # class: 'cp' 

63 #Comment.Single: '', # class: 'c1' 

64 #Comment.Special: '', # class: 'cs' 

65 

66 Keyword: 'bold var(--jp-mirror-editor-keyword-color)', # class: 'k' 

67 #Keyword.Constant: '', # class: 'kc' 

68 #Keyword.Declaration: '', # class: 'kd' 

69 #Keyword.Namespace: '', # class: 'kn' 

70 #Keyword.Pseudo: '', # class: 'kp' 

71 #Keyword.Reserved: '', # class: 'kr' 

72 #Keyword.Type: '', # class: 'kt' 

73 

74 Operator: 'bold var(--jp-mirror-editor-operator-color)', # class: 'o' 

75 Operator.Word: '', # class: 'ow' 

76 

77 Literal: '', # class: 'l' 

78 Literal.Date: '', # class: 'ld' 

79 

80 String: 'var(--jp-mirror-editor-string-color)', 

81 #String.Backtick: '', # class: 'sb' 

82 #String.Char: '', # class: 'sc' 

83 #String.Doc: '', # class: 'sd' 

84 #String.Double: '', # class: 's2' 

85 #String.Escape: '', # class: 'se' 

86 #String.Heredoc: '', # class: 'sh' 

87 #String.Interpol: '', # class: 'si' 

88 #String.Other: '', # class: 'sx' 

89 #String.Regex: '', # class: 'sr' 

90 #String.Single: '', # class: 's1' 

91 #String.Symbol: '', # class: 'ss' 

92 

93 Number: 'var(--jp-mirror-editor-number-color)', # class: 'm' 

94 #Number.Float: '', # class: 'mf' 

95 #Number.Hex: '', # class: 'mh' 

96 #Number.Integer: '', # class: 'mi' 

97 #Number.Integer.Long: '', # class: 'il' 

98 #Number.Oct: '', # class: 'mo' 

99 

100 Name: '', # class: 'n' 

101 #Name.Attribute: '', # class: 'na' 

102 #Name.Builtin: '', # class: 'nb' 

103 #Name.Builtin.Pseudo: '', # class: 'bp' 

104 #Name.Class: '', # class: 'nc' 

105 #Name.Constant: '', # class: 'no' 

106 #Name.Decorator: '', # class: 'nd' 

107 #Name.Entity: '', # class: 'ni' 

108 #Name.Exception: '', # class: 'ne' 

109 #Name.Function: '', # class: 'nf' 

110 #Name.Property: '', # class 'py' 

111 #Name.Label: '', # class: 'nl' 

112 #Name.Namespace: '', # class: 'nn' 

113 #Name.Other: '', # class: 'nx' 

114 #Name.Tag: '', # class: 'nt' 

115 #Name.Variable: '', # class: 'nv' 

116 #Name.Variable.Class: '', # class: 'vc' 

117 #Name.Variable.Global: '', # class: 'vg' 

118 #Name.Variable.Instance: '', # class: 'vi' 

119 

120 Generic: '', # class: 'g' 

121 #Generic.Deleted: '', # class: 'gd', 

122 #Generic.Emph: 'italic', # class: 'ge' 

123 #Generic.Error: '', # class: 'gr' 

124 #Generic.Heading: '', # class: 'gh' 

125 #Generic.Inserted: '', # class: 'gi' 

126 #Generic.Output: '', # class: 'go' 

127 #Generic.Prompt: '', # class: 'gp' 

128 #Generic.Strong: '', # class: 'gs' 

129 #Generic.Subheading: '', # class: 'gu' 

130 #Generic.Traceback: '', # class: 'gt' 

131 

132 Punctuation: 'var(--jp-mirror-editor-punctuation-color)' # class: 'p' 

133 }