HtmlRender.Render() not equivalent to Markdown.ToHtml() #500

Open
opened 2026-01-29 14:38:13 +00:00 by claunia · 0 comments
Owner

Originally created by @jo3w4rd on GitHub (Feb 8, 2022).

Are these expected to produce the same results? When using the PipeTables extension, Render() simply wraps the table cells in p tags (without and table, tbody, etc.). ToHtml() produces the full HTML table, as expected.

HtmlRender.Render() never hits a breakpoint in the HtmlTableRender.Write() method, whereas ToHtml() does. Am I missing a step for setting up the renderer object?

        public static void ParseMarkdown(string markdown)
        {
            var pipeline = new MarkdownPipelineBuilder().UsePipeTables().Build();
            MarkdownDocument md = Markdown.Parse(markdown, pipeline);
            var testStringA = md.ToHtml(pipeline);
            
            var stWriter = new StringWriter();
            var renderer = new HtmlRenderer(stWriter);
            renderer.Render(md);
            var testStringB = stWriter.ToString();
            
            Console.WriteLine(testStringA);
            Console.WriteLine(testStringB);
        }

(For context, I am exploring writing a different renderer.)

ToHTML() output (testStringA)

<h1>Table</h1>
<table>
<thead>
<tr>
<th><strong>Property</strong></th>
<th><strong>Description</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td><strong>Interaction Manager</strong></td>
<td>The <a href="xr-interaction-manager.md">XRInteractionManager</a> that this Interactable will communicate with (will find one if <strong>None</strong>).</td>
</tr>
<tr>
<td><strong>Interaction Layer Mask</strong></td>
<td>Allows interaction with Interactors whose <a href="interaction-layers.md">Interaction Layer Mask</a> overlaps with any Layer in this Interaction Layer Mask.</td>
</tr>
<tr>
<td><strong>Colliders</strong></td>
<td>Colliders to use for interaction with this Interactable (if empty, will use any child Colliders).</td>
</tr>
</tbody>
</table>

Render() (testStringB):

<h1>Table</h1>
<p><strong>Property</strong></p>
<p><strong>Description</strong></p>
<p><strong>Interaction Manager</strong></p>
<p>The <a href="xr-interaction-manager.md">XRInteractionManager</a> that this Interactable will communicate with (will find one if <strong>None</strong>).</p>
<p><strong>Interaction Layer Mask</strong></p>
<p>Allows interaction with Interactors whose <a href="interaction-layers.md">Interaction Layer Mask</a> overlaps with any Layer in this Interaction Layer Mask.</p>
<p><strong>Colliders</strong></p>
<p>Colliders to use for interaction with this Interactable (if empty, will use any child Colliders).</p>

Input markdown:

# Table

| **Property**               | **Description**                                                                                                                                   |
| -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Interaction Manager**    | The [XRInteractionManager](xr-interaction-manager.md) that this Interactable will communicate with (will find one if **None**).                   |
| **Interaction Layer Mask** | Allows interaction with Interactors whose [Interaction Layer Mask](interaction-layers.md) overlaps with any Layer in this Interaction Layer Mask. |
| **Colliders**              | Colliders to use for interaction with this Interactable (if empty, will use any child Colliders).                                                 |
Originally created by @jo3w4rd on GitHub (Feb 8, 2022). Are these expected to produce the same results? When using the PipeTables extension, `Render()` simply wraps the table cells in `p` tags (without and `table`, `tbody`, etc.). `ToHtml()` produces the full HTML table, as expected. `HtmlRender.Render()` never hits a breakpoint in the `HtmlTableRender.Write()` method, whereas `ToHtml()` does. Am I missing a step for setting up the renderer object? ``` public static void ParseMarkdown(string markdown) { var pipeline = new MarkdownPipelineBuilder().UsePipeTables().Build(); MarkdownDocument md = Markdown.Parse(markdown, pipeline); var testStringA = md.ToHtml(pipeline); var stWriter = new StringWriter(); var renderer = new HtmlRenderer(stWriter); renderer.Render(md); var testStringB = stWriter.ToString(); Console.WriteLine(testStringA); Console.WriteLine(testStringB); } ``` (For context, I am exploring writing a different renderer.) `ToHTML()` output (testStringA) ``` <h1>Table</h1> <table> <thead> <tr> <th><strong>Property</strong></th> <th><strong>Description</strong></th> </tr> </thead> <tbody> <tr> <td><strong>Interaction Manager</strong></td> <td>The <a href="xr-interaction-manager.md">XRInteractionManager</a> that this Interactable will communicate with (will find one if <strong>None</strong>).</td> </tr> <tr> <td><strong>Interaction Layer Mask</strong></td> <td>Allows interaction with Interactors whose <a href="interaction-layers.md">Interaction Layer Mask</a> overlaps with any Layer in this Interaction Layer Mask.</td> </tr> <tr> <td><strong>Colliders</strong></td> <td>Colliders to use for interaction with this Interactable (if empty, will use any child Colliders).</td> </tr> </tbody> </table> ``` `Render()` (testStringB): ``` <h1>Table</h1> <p><strong>Property</strong></p> <p><strong>Description</strong></p> <p><strong>Interaction Manager</strong></p> <p>The <a href="xr-interaction-manager.md">XRInteractionManager</a> that this Interactable will communicate with (will find one if <strong>None</strong>).</p> <p><strong>Interaction Layer Mask</strong></p> <p>Allows interaction with Interactors whose <a href="interaction-layers.md">Interaction Layer Mask</a> overlaps with any Layer in this Interaction Layer Mask.</p> <p><strong>Colliders</strong></p> <p>Colliders to use for interaction with this Interactable (if empty, will use any child Colliders).</p> ``` Input markdown: ``` # Table | **Property** | **Description** | | -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | | **Interaction Manager** | The [XRInteractionManager](xr-interaction-manager.md) that this Interactable will communicate with (will find one if **None**). | | **Interaction Layer Mask** | Allows interaction with Interactors whose [Interaction Layer Mask](interaction-layers.md) overlaps with any Layer in this Interaction Layer Mask. | | **Colliders** | Colliders to use for interaction with this Interactable (if empty, will use any child Colliders). | ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#500