transform function from @accordproject/markdown-transform converts CiceroMark documents to different output formats including HTML, PDF, DOCX, and more.
Installation
Function Signature
Parameters
The source document to transform (typically CiceroMark JSON)
The format of the source document. Common values:
"ciceromark_parsed"- Parsed CiceroMark JSON"markdown"- Markdown text"html"- HTML string
Array of target format(s) to generate. Supported formats:
"html"- HTML output"pdf"- PDF document"docx"- Microsoft Word document"markdown"- Markdown text"plaintext"- Plain text
Optional transformation parameters (format-specific options)
Transformation options
Enable verbose logging during transformation
Return Value
Returns aPromise that resolves to:
stringwhen transforming to a single text format (HTML, markdown, plaintext)objectwhen transforming to binary formats or multiple formats
Example Usage
Here’s the complete example from the Template Playground showing the transformation pipeline:Transform to Multiple Formats
You can generate multiple output formats in a single transform call:Common Use Cases
CiceroMark to HTML
CiceroMark to PDF
Markdown to HTML
Supported Formats
Source Formats
ciceromark_parsed- CiceroMark JSON from template enginemarkdown- Standard markdown texthtml- HTML stringcommonmark- CommonMark format
Target Formats
html- HTML5 outputpdf- PDF documentdocx- Microsoft Word documentmarkdown- Markdown textplaintext- Plain text without formattingciceromark- CiceroMark JSON
Error Handling
Related APIs
- TemplateMarkInterpreter - Generates CiceroMark for transformation
- ModelManager - Validates data structure before transformation
Source Reference
See the implementation in the Template Playground:src/store/store.ts:100-107