diff --git a/server/app/dicts/mdict/html_cleaner.py b/server/app/dicts/mdict/html_cleaner.py
index 6b0a9a3..8ffbc65 100644
--- a/server/app/dicts/mdict/html_cleaner.py
+++ b/server/app/dicts/mdict/html_cleaner.py
@@ -36,8 +36,11 @@ def _expand_compact_html(self, compact_html: str) -> str:
buf.append(self._compact_html_rules[m.group(1)][0])
last_end_tag = self._compact_html_rules[m.group(1)][1]
pos = m.end()
- buf.append(last_end_tag)
- return ''.join(buf)
+ if len(buf) > 0:
+ buf.append(last_end_tag)
+ return ''.join(buf)
+ else:
+ return compact_html
def _fix_file_path(self, definition_html: str, file_extension: str) -> str:
extension_position = 0