Skip to content

Commit ed98245

Browse files
committed
fix export docx issue
1 parent fa54d1e commit ed98245

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

backend/routers/export.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ def export_docx(payload: ExportPayload):
8585
# We use a minimal stub that shells out to the existing logic. The legacy
8686
# export_to_docx() function requires a MarkdownReader 'app' object, so we
8787
# create a lightweight adapter.
88-
from markdown_reader.logic import export_to_docx
88+
import markdown_reader.logic as legacy_logic
89+
90+
export_to_docx = legacy_logic.export_to_docx
8991

9092
out_path = _make_output_path(payload.output_path, ".docx")
9193
parent = os.path.dirname(out_path)
@@ -113,8 +115,18 @@ def get(self, *_):
113115

114116
adapter.editors = [_FakeTextArea()]
115117

118+
# Disable any legacy GUI message boxes from the backend export path.
119+
def _noop(*args, **kwargs):
120+
return None
121+
122+
if hasattr(legacy_logic, "messagebox"):
123+
legacy_logic.messagebox.showinfo = _noop
124+
legacy_logic.messagebox.showerror = _noop
125+
116126
try:
117-
export_to_docx(adapter, out_path)
127+
success = export_to_docx(adapter, out_path)
128+
if not success:
129+
raise RuntimeError("DOCX export failed")
118130
except Exception as exc:
119131
raise HTTPException(status_code=500, detail=str(exc))
120132
return {"path": out_path}

0 commit comments

Comments
 (0)