2.8 KiB
2.8 KiB
ADDED Requirements
Requirement: Markdown Input Acceptance
The system SHALL accept markdown content via POST /api/v1/convert/docx endpoint.
The request body SHALL contain:
markdown: string containing the markdown content to convert
Scenario: Valid markdown provided
- WHEN valid markdown content is provided in the request body
- THEN the system SHALL process and convert it to DOCX format
Scenario: Empty markdown
- WHEN an empty
markdownstring is provided - THEN the system SHALL return HTTP 422 with validation error
Requirement: DOCX Conversion
The system SHALL convert markdown content to DOCX format using the markdown_2_docx library.
The conversion SHALL preserve:
- Headings (H1-H6)
- Paragraphs
- Bold and italic formatting
- Lists (ordered and unordered)
- Code blocks
- Tables
- Images (if embedded as base64 or accessible URLs)
Scenario: Basic markdown conversion
- WHEN markdown with headings, paragraphs, and formatting is provided
- THEN the system SHALL generate a valid DOCX file
- AND the DOCX SHALL preserve the document structure
Scenario: Complex markdown with tables
- WHEN markdown containing tables is provided
- THEN the system SHALL convert tables to Word table format
- AND preserve table structure and content
Scenario: Markdown with math formulas
- WHEN markdown containing LaTeX math expressions is provided
- THEN the system SHALL convert math to OMML (Office Math Markup Language) format
- AND render correctly in Microsoft Word
Requirement: DOCX File Response
The system SHALL return the generated DOCX file as a binary download.
The response SHALL include:
- Content-Type:
application/vnd.openxmlformats-officedocument.wordprocessingml.document - Content-Disposition:
attachment; filename="output.docx"
Scenario: Successful conversion response
- WHEN markdown conversion completes successfully
- THEN the response SHALL be the DOCX file binary
- AND HTTP status code SHALL be 200
- AND appropriate headers for file download SHALL be set
Scenario: Custom filename
- WHEN an optional
filenameparameter is provided in the request - THEN the Content-Disposition header SHALL use the provided filename
- AND append
.docxextension if not present
Requirement: Error Handling
The system SHALL provide clear error responses for conversion failures.
Scenario: Conversion failure
- WHEN markdown_2_docx fails to convert the content
- THEN the system SHALL return HTTP 500 with error details
- AND the error message SHALL describe the failure reason
Scenario: Malformed markdown
- WHEN severely malformed markdown is provided
- THEN the system SHALL attempt best-effort conversion
- AND log a warning about potential formatting issues