diff --git a/src/formatitko/html_generator.py b/src/formatitko/html_generator.py
index 36c96f9..d7dbc03 100644
--- a/src/formatitko/html_generator.py
+++ b/src/formatitko/html_generator.py
@@ -243,7 +243,11 @@ class HTMLGenerator(OutputGenerator):
"DisplayMath": True,
"InlineMath": False
}
- self.writeraw(self.katexClient.render(e.text, {"displayMode": formats[e.format]}))
+ rawhtml = self.katexClient.render(e.text, {"displayMode": formats[e.format]})
+ if (e.format == "InlineMath"):
+ self.write(rawhtml)
+ else:
+ self.writeraw()
def generate_RawInline(self, e: RawInline):
if e.format == "html":