xoofx / xoofx/markdig

[Question] Custom renderer outside MarkDig possible?

Open
#871 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

question
Dominant language
C#
Stars
5.3k
Forks
510
Avg merge
8d 5h
Merged PRs (30d)
5

Description

Hi,

due to a lack of documentation I am trying to create a simple PDF exporter and was playing around with deriving from RendererBase because I won't return a text writer, so I cannot use TextRenderBase like the HtmlRenderer does. (This is my assumption)

However, the signature of render base poses some questions for me:

public override object Render(MarkdownObject markdownObject)

I get a MarkdownObject and need to descend down to containers, etc but I am stuck.

Beside the fact that I haven't found a way for a hierarchical traversal yet, I stumbled upon MarkdownObject.IsContainerInline and MarkdownObject.IsContainerBlock, which are internal.

I assume that I misunderstand how to approach the traversal, but does the internal modifier on the method above makes it quite tricky to discern what to do?

I looked at the plain text and html renderers, I also looked at some forked Wpf Renderer but still am unsure on how to handle traversal that way without a text render output (otherwise I could somehow hijack the html renderer I assume.

Or would be actually using the Html renderer to get html be the best way? I could parse the resulting html into a tree and then continue my pdf export from html instead of markdown I assume.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by comparing RendererBase, TextRenderBase, HtmlRenderer, and the plain-text and HTML renderers to understand the supported traversal model. The issue is done when the documentation explains whether a custom non-text renderer can traverse MarkdownObject hierarchies, how the internal container members affect that approach, and whether rendering HTML first is recommended.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, markdown
Domain
devtools
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.