Clean up code

This commit is contained in:
YishiMichael
2022-03-21 23:06:47 +08:00
parent c51811d2f1
commit cabc1322d6
2 changed files with 2 additions and 6 deletions

View File

@ -557,10 +557,7 @@ class MTex(_TexSVG):
def get_part_by_tex(self, tex, index=0):
all_parts = self.get_parts_by_tex(tex)
try:
return all_parts[index]
except IndexError:
return None
return all_parts[index]
def set_color_by_tex(self, tex, color):
self.get_parts_by_tex(tex).set_color(color)

View File

@ -449,8 +449,7 @@ class Code(MarkupText):
lexer = pygments.lexers.get_lexer_by_name(self.language)
formatter = pygments.formatters.PangoMarkupFormatter(style=self.code_style)
markup = pygments.highlight(code, lexer, formatter)
markup = markup.replace("<tt>", f"<span font_family='{self.font}'>")
markup = markup.replace("</tt>", "</span>")
markup = markup.replace("<tt>", "<span>").replace("</tt>", "</span>")
super().__init__(markup, **kwargs)