Browse Source

Default pro highlight

jk-bakalarka
Jiří Kalvoda 9 months ago
parent
commit
41f51bf6fe
  1. 4
      src/formatitko/html_generator.py

4
src/formatitko/html_generator.py

@ -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…
Cancel
Save