I have some markdown text.

I use MarkDig to parse the markdown text and obtain a markdown-document-object-model. (markdown-DOM.)

From that, I want to obtain an HTML-DOM.

As far as I can tell, the only thing MarkDig can easily do in that direction is to convert the markdown-DOM into HTML text.

This means that I would then have to use some other HTML library (e.g. HtmlAgilityPack (site, GitHub) or AngleSharp) to parse that HTML text into an HTML-DOM.

That would be a bit too roundabout for my taste.

So, how can I produce an HTML-DOM from the markdown-DOM generated by MarkDig?

Note: I do not have to use MarkDig, so if there is some other library that produces a markdown-DOM which is easier to convert to an HTML DOM, I am open to it.

2 Replies 2

If you look at

https://dotnetfiddle.net/GoZXyI

you can see it does HTML

If you want that in a DOM then you need a DOMParser and create a document

I found this for .NET https://learn.microsoft.com/en-us/dotnet/desktop/winforms/controls/using-the-managed-html-document-object-model

and this for node https://www.npmjs.com/package/node-html-parser (there are several)

browser https://developer.mozilla.org/en-US/docs/Web/API/DOMParser

If the problem is simply being able to read your Markdown files in an HTML browser, the easiest solution is to use an extension like MD Reader.

Otherwise, I understand that LibreOffice is working on full integration of this format. The preview (2026?) will allow direct reading of MD files; then you'll be able to export them in all LibreOffice formats: .odf, .pdf, .html, .docx, etc.

Your Reply

By clicking “Post Your Reply”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.