Skip to content

feat(md-to-docx): accept pasted Markdown text as input - #618

Merged
Durgeshwar-AI merged 2 commits into
Durgeshwar-AI:mainfrom
Anijesh:feat/566-md-to-docx-text-input
Aug 7, 2026
Merged

feat(md-to-docx): accept pasted Markdown text as input#618
Durgeshwar-AI merged 2 commits into
Durgeshwar-AI:mainfrom
Anijesh:feat/566-md-to-docx-text-input

Conversation

@Anijesh

@Anijesh Anijesh commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

🔀 Pull Request

📌 Issue Reference

Closes #566


📝 Summary

  • What issue does this fix?
    The Markdown → DOCX tool only accepted a .md file upload. Since the Markdown is usually already on the clipboard (or being tweaked right before conversion), users had to save it to a file first just to convert it. This adds a plain text input as an alternative source.

  • What major changes were made?

    Backend

    • /convertMdToDocx (backend/blueprints/markdown_docx.py) now resolves its input through the shared resolve_markdown_input() validator, so it accepts either the uploaded file or a new text form field. Pasted Markdown downloads as document.docx; the existing upload flow, the .md extension check and the UTF-8 decode error are unchanged, and blank / whitespace-only text is rejected with 400.
    • Conversion stays fully in memory and uses only local libraries — no disk writes, no external API.

    Frontend

    • MdToDocx.tsx now shows an "Upload .md file" / "Paste Markdown" switch. In text mode the drop area is replaced by a Markdown textarea, and the Convert button stays disabled until something is typed. Switching modes clears the input from the mode you left, so only one source is ever active.

📸 Screenshots (if applicable)

Verified against the running endpoint rather than screenshots:

text input     -> 200 attachment; filename=document.docx
file upload    -> 200 attachment; filename=readme.docx   (unchanged)
blank text     -> 400 No Markdown provided. Please upload a .md file or enter Markdown text.
empty request  -> 400 No Markdown provided. Please upload a .md file or enter Markdown text.

The generated .docx is a real Word document — unzipping it shows the converted headings and body text in word/document.xml.


✅ Checklist

  • My code follows the project's coding conventions
  • I have tested all impacted features
  • I have updated or added necessary documentation

🔗 Related Issues / PRs

Issue #566

Depends on #617 (issue #565), which introduces the shared resolve_markdown_input() validator and the optional ToolPageTemplate props this PR builds on. This branch is stacked on top of it, so the diff here shows both commits until #617 is merged — after that it reduces to the DOCX-only changes automatically. Please merge #617 first.


🏅 Open Source Program Participation

Program Name: GSSoC '26


💬 Additional Notes

  • Tests: added 3 backend tests to backend/test_blueprints.py (text input success, blank text rejected, empty request rejected) and a new frontend/src/tests/mdToDocxTextInput.test.tsx with 4 tests covering the mode switch. pytest is at 86 passing with no new failures (the 2 pre-existing add_watermark failures are untouched) and vitest at 17 passing. npm run lint, npm run typecheck and npm run build are all clean.
  • The Readme.md feature list previously had no entry for Markdown → DOCX at all; this PR adds one.

/convertMdToDocx only accepted a .md upload, so anyone who already had the
Markdown on their clipboard had to save it to a file just to convert it.

- Resolve the Markdown in the markdown_docx blueprint through the shared
  resolve_markdown_input() validator, so the endpoint accepts either an
  uploaded .md file or a `text` form field; pasted text downloads as
  document.docx and the existing upload flow is unchanged
- Add an "Upload .md file" / "Paste Markdown" switch to the tool page, with
  the Convert button disabled until Markdown text is entered
- Cover the new input path with backend and frontend tests, and document it
  in the Readme

Closes Durgeshwar-AI#566
@vercel

vercel Bot commented Aug 3, 2026

Copy link
Copy Markdown

@Anijesh is attempting to deploy a commit to the Durgeshwar's projects Team on Vercel.

A member of the Team first needs to authorize it.

@Durgeshwar-AI
Durgeshwar-AI merged commit 4f27091 into Durgeshwar-AI:main Aug 7, 2026
1 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Text input for the Markdown to Docx

2 participants