IPython(Jupyter) 如何更改代码的高亮颜色样式?
How do I change the highlight color style of the code in the IPython(Jupyter)?
我的问题如下图所示。我想更改下图中红色矩形指定的代码区域的高亮颜色样式。但是我不知道我应该改变哪个令牌的样式。
我的pygment样式设置代码如下
from pygments.style import Style
from pygments.token import Keyword, Name, Comment, String, Error, \
Number, Operator, Generic, Whitespace, Token
class EmacsStyle(Style):
"""
The default style (inspired by Emacs 22).
"""
background_color = "#333333"
highlight_color = "#a7a695"
default_style = ""
styles = {
Token: "#ffffff",
Whitespace: "#bbbbbb",
Comment: "italic #008800",
Comment.Preproc: "noitalic",
Comment.Special: "noitalic bold",
Keyword: "bold #B541FF",
Keyword.Pseudo: "nobold",
Keyword.Type: "bold #00BB00",
Operator: "#666666",
Operator.Word: "bold #AA22FF",
Name.Builtin: "#B541FF",
Name.Function: "#00A000",
Name.Class: "#4242FF",
Name.Namespace: "bold #4242FF",
Name.Exception: "bold #D2413A",
Name.Variable: "#B8860B",
Name.Constant: "#880000",
Name.Label: "#A0A000",
Name.Entity: "bold #999999",
Name.Attribute: "#BB4444",
Name.Tag: "bold #008000",
Name.Decorator: "#AA22FF",
String: "#BB4444",
String.Doc: "italic",
String.Interpol: "bold #BB6688",
String.Escape: "bold #BB6622",
String.Regex: "#BB6688",
String.Symbol: "#B8860B",
String.Other: "#008000",
Number: "#666666",
Generic.Heading: "bold #4242FF",
Generic.Subheading: "bold #B541FF",
Generic.Deleted: "#D2413A",
Generic.Inserted: "#00A000",
Generic.Error: "#FF0000",
Generic.Emph: "italic",
Generic.Strong: "bold",
Generic.Prompt: "bold #4242FF",
Generic.Output: "#888",
Generic.Traceback: "#04D",
Error: "border:#FF0000"
}
我找到了一个 IPython 魔术命令来改变颜色(在 Mac 上):
%colors NoColor
或(Linux)
%colors Linux
这不是一个完美的解决方案,但有效。
我的问题如下图所示。我想更改下图中红色矩形指定的代码区域的高亮颜色样式。但是我不知道我应该改变哪个令牌的样式。
我的pygment样式设置代码如下
from pygments.style import Style
from pygments.token import Keyword, Name, Comment, String, Error, \
Number, Operator, Generic, Whitespace, Token
class EmacsStyle(Style):
"""
The default style (inspired by Emacs 22).
"""
background_color = "#333333"
highlight_color = "#a7a695"
default_style = ""
styles = {
Token: "#ffffff",
Whitespace: "#bbbbbb",
Comment: "italic #008800",
Comment.Preproc: "noitalic",
Comment.Special: "noitalic bold",
Keyword: "bold #B541FF",
Keyword.Pseudo: "nobold",
Keyword.Type: "bold #00BB00",
Operator: "#666666",
Operator.Word: "bold #AA22FF",
Name.Builtin: "#B541FF",
Name.Function: "#00A000",
Name.Class: "#4242FF",
Name.Namespace: "bold #4242FF",
Name.Exception: "bold #D2413A",
Name.Variable: "#B8860B",
Name.Constant: "#880000",
Name.Label: "#A0A000",
Name.Entity: "bold #999999",
Name.Attribute: "#BB4444",
Name.Tag: "bold #008000",
Name.Decorator: "#AA22FF",
String: "#BB4444",
String.Doc: "italic",
String.Interpol: "bold #BB6688",
String.Escape: "bold #BB6622",
String.Regex: "#BB6688",
String.Symbol: "#B8860B",
String.Other: "#008000",
Number: "#666666",
Generic.Heading: "bold #4242FF",
Generic.Subheading: "bold #B541FF",
Generic.Deleted: "#D2413A",
Generic.Inserted: "#00A000",
Generic.Error: "#FF0000",
Generic.Emph: "italic",
Generic.Strong: "bold",
Generic.Prompt: "bold #4242FF",
Generic.Output: "#888",
Generic.Traceback: "#04D",
Error: "border:#FF0000"
}
我找到了一个 IPython 魔术命令来改变颜色(在 Mac 上):
%colors NoColor
或(Linux)
%colors Linux
这不是一个完美的解决方案,但有效。