Repository navigation
New: Markdown (.md) to Pdf and Docx conversion - #802
Open
Pratham-Solanki911 wants to merge 2 commits into
Open
Pratham-Solanki911 wants to merge 2 commits into
Pratham-Solanki911 wants to merge 2 commits into
Conversation
Markdown files are rendered to html with Markdig, then opened in Microsoft Word, which exports them like any other Word document. This gives Pdf, image (via the existing pdf pipeline) and the new Docx output type. - Add Docx output type, handled by the Word conversion job (also enables doc/odt to docx). - Embed linked pictures so generated docx files are self-contained. - Resolve relative image paths against the markdown file's folder. - Add md to the default "To Pdf" preset and a new default "To Docx" preset.
…ns work on install
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds Markdown (
.md) input with Pdf and Docx output, plus image output through the existing pdf → image pipeline.How it works
Markdown is rendered to HTML with Markdig (advanced extensions: tables, task lists, footnotes, etc.). The HTML goes to a temp file, and the existing
ConversionJob_Wordopens it in Microsoft Word, the same way it opens doc/docx/odt today. From there Word either:ExportAsFixedFormat(unchanged code path), orSaveAs2(wdFormatXMLDocument)(new).Reusing Word keeps output consistent with the existing document conversions, gives proper pagination and fonts, and makes the Docx output an editable Word document rather than a flattened one.
Changes
Docxoutput type, handled by the Word job. This also enables doc/odt → docx for free..mdis registered as a Document input and routed to the Word job.<base href>in the generated HTML.Settings.default.xml:mdadded to "To Pdf", plus a new default "To Docx" preset (md, doc, odt).Markdig.dlladded. Its only dependency,System.Memory, is already shipped.Installer fix (separate commit)
Product.wxsdidn't ship the NetOffice assemblies (NetOffice.dll,OfficeApi.dll,WordApi.dll,ExcelApi.dll,PowerPointApi.dll,VBIDEApi.dll), so every Office-based conversion fails on an installed v2.2. This feature depends on the Word job, so the missing files are added here. It overlaps with the installer part of #779, and whichever PR merges first will make this commit redundant.Relation to #776
#776 also adds md → pdf, but renders through QuestPDF without Office. This PR takes the Word route, which adds Docx output and matches how the app already handles documents. The trade-off is that it needs Microsoft Word installed, like the other Office conversions.
Testing
I converted one markdown file containing headings, bold/italic/inline code, a link, a table with alignment, a fenced code block, nested and ordered lists, a blockquote, unicode text and a relative image:
r:embed, nor:link).