diff --git a/src/formatitko/html_generator.py b/src/formatitko/html_generator.py index 2aabe85..cafa003 100644 --- a/src/formatitko/html_generator.py +++ b/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: