How ashok19rd91/md2ml works
Purpose and Entry Point
MD2ML is a .NET library for generating Word documents as WordProcessingML/OpenXML, with Markdown-to-document conversion plus direct document-construction APIs. Consumers instantiate Md2MlEngine, clone/create a DOCX from a template, write content, and save it. Core entry points are in Md2Ml/Md2Ml/Md2MlCore.cs and the project is built through Md2Ml/Md2Ml/Md2Ml.csproj.
Document Lifecycle
Md2MlEngine owns the document-generation lifecycle: create a destination document from a source/template DOCX, attach content to the document body, perform cleanup, and persist the finished package. It is the boundary between caller-provided paths/content and OpenXML document state.
• Md2Ml/Md2Ml/Md2MlCore.cs
• Md2Ml/Md2Ml/Md2Ml.csproj
Markdown Parsing Stage
Markdown text is accepted by the engine’s Markdown-writing APIs and passed through a parser that identifies document-level constructs and inline formatting. The parser separates Markdown interpretation from OpenXML emission, enabling Markdown text to be used within paragraphs, lists, and other generated structures.
• Md2Ml/Md2Ml/MarkdownStingParser.cs
• Md2Ml/Md2Ml/Md2MlCore.cs
Pattern-Based Formatting Model
The conversion design uses pattern objects and a matcher to recognize Markdown syntax and map it to formatting behavior. Paragraph patterns represent block-level constructs; run patterns represent inline spans such as emphasis, bold text, code, or hyperlinks. This is the main extensibility boundary for additional Markdown syntax.
• Md2Ml/Md2Ml/PatternMatcher.cs
• Md2Ml/Md2Ml/ParaPattern.cs
• Md2Ml/Md2Ml/RunPattern.cs
Paragraph and Run Property Translation
Recognized patterns are represented with separate property models for paragraph and run formatting. These models isolate semantic Markdown results from the eventual WordProcessingML paragraph/run properties, supporting composition of text styling with block layout.
• Md2Ml/Md2Ml/ParaProperties.cs
• Md2Ml/Md2Ml/RunProperties.cs
• Md2Ml/Md2Ml/MarkdownStingParser.cs
Direct OpenXML Authoring
Beyond Markdown conversion, the engine exposes imperative operations for paragraphs, plain/formatted text, hyperlinks, ordered and bulleted lists, page breaks, bookmarks, tables, and images. These operations likely share the same active document/body managed by the engine, while tables and non-body paragraphs permit composing content before attachment.
• Md2Ml/Md2Ml/Md2MlCore.cs
Runtime and External Boundaries
The library targets the .NET runtime and uses OpenXML specifications/packages to create and modify DOCX WordProcessingML packages. Input boundaries include local DOCX template/output paths, Markdown strings, image URLs or file paths, and hyperlink URLs. Image retrieval may require network access when callers provide URLs.
• Md2Ml/Md2Ml/Md2Ml.csproj
• Md2Ml/Md2Ml/Md2MlCore.cs
Main entry points: Md2MlCore.cs Md2MlEngine · MarkdownStingParser.cs Markdown parser · PatternMatcher.cs Pattern matcher · Md2Ml.csproj Md2Ml project
Components 14
Library API
- Md2MlEngine · Owns the active document, body attachment, cleanup, and save lifecycle.
Md2Ml/Md2Ml/Md2MlCore.cs - Markdown writing APIs
Md2Ml/Md2Ml/Md2MlCore.cs - Direct authoring APIs · Creates paragraphs, text, links, lists, breaks, bookmarks, tables, and images.
Md2Ml/Md2Ml/Md2MlCore.cs
Markdown Conversion
- Markdown parser · Separates Markdown interpretation from OpenXML emission.
Md2Ml/Md2Ml/MarkdownStingParser.cs - Pattern matcher · Recognizes Markdown syntax using block and inline patterns.
Md2Ml/Md2Ml/PatternMatcher.cs - Paragraph patterns
Md2Ml/Md2Ml/ParaPattern.cs - Run patterns
Md2Ml/Md2Ml/RunPattern.cs - Paragraph properties · Carries paragraph layout semantics before WordProcessingML translation.
Md2Ml/Md2Ml/ParaProperties.cs - Run properties · Carries text styling semantics before WordProcessingML translation.
Md2Ml/Md2Ml/RunProperties.cs
Document Authoring
- DOCX / WordProcessingML · Template-derived destination package and generated document body.
Runtime Boundaries
- Library consumer · Supplies templates, Markdown, and direct authoring commands.
- Md2Ml project · Builds the MD2ML library against its runtime dependencies.
Md2Ml/Md2Ml/Md2Ml.csproj - OpenXML packages
Md2Ml/Md2Ml/Md2Ml.csproj - Templates and resources · Includes DOCX paths, Markdown strings, image sources, and hyperlink URLs.
Md2Ml/Md2Ml/Md2MlCore.cs
Connections 16
- Md2Ml project → Md2MlEngine: builds
- Md2Ml project → OpenXML packages: references
- Library consumer → Md2MlEngine: uses
- Templates and resources → Md2MlEngine: provides inputs
- Md2MlEngine → Markdown writing APIs: accepts Markdown through
- Md2MlEngine → Direct authoring APIs: exposes
- Markdown writing APIs → Markdown parser: parses
- Markdown parser → Pattern matcher: matches syntax with
- Pattern matcher → Paragraph patterns: uses block rules
- Pattern matcher → Run patterns: uses inline rules
- Markdown parser → Paragraph properties: produces
- Markdown parser → Run properties: produces
- Markdown parser → DOCX / WordProcessingML: emits formatted content
- Direct authoring APIs → DOCX / WordProcessingML: authors content
- Md2MlEngine → DOCX / WordProcessingML: creates, cleans, and saves
- OpenXML packages → DOCX / WordProcessingML: manipulates