diff --git a/espanso-engine/src/process/middleware/markdown.rs b/espanso-engine/src/process/middleware/markdown.rs
index abebc54..7deec85 100644
--- a/espanso-engine/src/process/middleware/markdown.rs
+++ b/espanso-engine/src/process/middleware/markdown.rs
@@ -17,6 +17,8 @@
* along with espanso. If not, see
") { - html = html.trim_start_matches("
"); - } - if html.ends_with("
") { - html = html.trim_end_matches(""); - } + // Remove the surrounding paragraph + if html.starts_with("") { + html = html.trim_start_matches("
"); + } + if html.ends_with("
") { + html = html.trim_end_matches(""); + } - return Event::caused_by( - event.source_id, - EventType::HtmlInject(HtmlInjectRequest { - html: html.to_owned(), - }), - ); + return Event::caused_by( + event.source_id, + EventType::HtmlInject(HtmlInjectRequest { + html: html.to_owned(), + }), + ); + } else { + error!("unable to convert markdown to HTML, is it malformed?"); + + return Event::caused_by(event.source_id, EventType::NOOP); + } } event