Default pro highlight
This commit is contained in:
parent
f1f2f63cb5
commit
41f51bf6fe
1 changed files with 2 additions and 2 deletions
|
@ -110,7 +110,7 @@ class HTMLGenerator(OutputGenerator):
|
|||
|
||||
def generate_CodeBlock(self, e: CodeBlock):
|
||||
lexer = None
|
||||
if e.classes and len(e.classes) > 0 and (e.attributes["highlight"] == True or e.attributes["highlight"] == 'True'):
|
||||
if e.classes and len(e.classes) > 0 and (e.attributes.get("highlight", False) in [True, 'True']):
|
||||
# Syntax highlighting using pygments
|
||||
for cl in e.classes:
|
||||
try:
|
||||
|
@ -122,7 +122,7 @@ class HTMLGenerator(OutputGenerator):
|
|||
warnings.warn(f"Syntax highligher does not have lexer for element with these classes: {e.classes}", UserWarning)
|
||||
|
||||
if lexer:
|
||||
formatter = HtmlFormatter(style=e.attributes["style"], noclasses=True)
|
||||
formatter = HtmlFormatter(style=e.attributes.get("style", self.context.get_metadata("highlight-style")), noclasses=True)
|
||||
result = highlight(e.text, lexer, formatter)
|
||||
self.writeraw(result)
|
||||
else:
|
||||
|
|
Loading…
Reference in a new issue