[PR #802] [CLOSED] Add ConfigureHtmlRenderer to MarkdownPipelineBuilder #1228

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

📋 Pull Request Information

Original PR: https://github.com/xoofx/markdig/pull/802
Author: @yngvedh
Created: 6/9/2024
Status: Closed

Base: masterHead: configure-renderer


📝 Commits (10+)

  • 011f4eb Add configuration of HtmlRenderer in pipeline builder
  • 26064f6 Add support for relative base uri
  • de4a49c Redo combining of relative uris
  • c68e734 Rename ConfigureHtmlRenderer field to resolve name conflict
  • e8aa193 Add POC of renderer builders
  • 27c64af Flesh out HtmlRendererBuilder
  • 1211b73 Add NormalizeRendererBuilder
  • 1c3afba Add RoundtripRendererBuilder
  • ef56e52 Add missing licensing headers
  • c6521f6 Refactor Configure*Renderer pipeline extension methods

📊 Changes

14 files changed (+310 additions, -58 deletions)

View changed files

📝 src/Markdig.Tests/RoundtripSpecs/Inlines/TestNullCharacterInline.cs (+7 -8)
📝 src/Markdig.Tests/TestLinkRewriter.cs (+5 -9)
📝 src/Markdig.Tests/TestRelativeUrlReplacement.cs (+5 -10)
📝 src/Markdig.Tests/TestRoundtrip.cs (+6 -10)
📝 src/Markdig/Markdown.cs (+3 -3)
📝 src/Markdig/MarkdownExtensions.cs (+43 -1)
📝 src/Markdig/MarkdownPipeline.cs (+19 -11)
📝 src/Markdig/MarkdownPipelineBuilder.cs (+7 -3)
📝 src/Markdig/Renderers/HtmlRenderer.cs (+11 -2)
src/Markdig/Renderers/HtmlRendererBuilder.cs (+86 -0)
src/Markdig/Renderers/IMarkdownRendererBuilder.cs (+22 -0)
src/Markdig/Renderers/Normalize/NormalizeRendererBuilder.cs (+66 -0)
src/Markdig/Renderers/Roundtrip/RoundtripRendererBuilder.cs (+23 -0)
📝 src/Markdig/Renderers/TextRendererBase.cs (+7 -1)

📄 Description

I needed to set up image url rewriting in a project of mine and found it a bit tedious not having a way to set it up in the pipeline. So I added the ability to configure the HtmlRenderer from the pipeline builder. As an added bonus, this works with the renderer cache as well.

I did not add any tests but updated the BaseUrl test to configure the html renderer using the pipeline builder.
I did not update changelog.md since it already has been neglected for some time.
I have not spent any time figuring out whether any of the documentation should be updated, please advise.
I could not find any existing PR or issue on this exact issue so I took the liberty to raise this draft PR.

UPDATE:
I added a bare bones builder for HtmlRenderer letting me set the one field I need as a POC. It is basically a factory for TextRendererBase which I also refactored the cache mechanism to use so that too should work for any text renderer. This goes for the ToHtml method since it uses the caching mechanism to get hold of its renderer.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/xoofx/markdig/pull/802 **Author:** [@yngvedh](https://github.com/yngvedh) **Created:** 6/9/2024 **Status:** ❌ Closed **Base:** `master` ← **Head:** `configure-renderer` --- ### 📝 Commits (10+) - [`011f4eb`](https://github.com/xoofx/markdig/commit/011f4eb9ee22795afb5042fb0a67c41ee3d825f8) Add configuration of HtmlRenderer in pipeline builder - [`26064f6`](https://github.com/xoofx/markdig/commit/26064f66046d387613e8658621b53224a8640dd1) Add support for relative base uri - [`de4a49c`](https://github.com/xoofx/markdig/commit/de4a49c8cb95766c125bec6530b3efb2ca847551) Redo combining of relative uris - [`c68e734`](https://github.com/xoofx/markdig/commit/c68e734f544a2abc02d5bad85a067c8e395478bf) Rename ConfigureHtmlRenderer field to resolve name conflict - [`e8aa193`](https://github.com/xoofx/markdig/commit/e8aa193a791f1f85bcabb25c443245d20df649de) Add POC of renderer builders - [`27c64af`](https://github.com/xoofx/markdig/commit/27c64af0feaec1303e0e297a9d800db3272bdf83) Flesh out HtmlRendererBuilder - [`1211b73`](https://github.com/xoofx/markdig/commit/1211b731723835aede73ec10d4944a5286c2baad) Add NormalizeRendererBuilder - [`1c3afba`](https://github.com/xoofx/markdig/commit/1c3afba6343dc06fff53c8e679ebdb871d7671be) Add RoundtripRendererBuilder - [`ef56e52`](https://github.com/xoofx/markdig/commit/ef56e528e284c118d5e16fbbe6d50774b8c0ab96) Add missing licensing headers - [`c6521f6`](https://github.com/xoofx/markdig/commit/c6521f6f036d62e9e68ccb2b2a7ff9ca805d71d7) Refactor Configure*Renderer pipeline extension methods ### 📊 Changes **14 files changed** (+310 additions, -58 deletions) <details> <summary>View changed files</summary> 📝 `src/Markdig.Tests/RoundtripSpecs/Inlines/TestNullCharacterInline.cs` (+7 -8) 📝 `src/Markdig.Tests/TestLinkRewriter.cs` (+5 -9) 📝 `src/Markdig.Tests/TestRelativeUrlReplacement.cs` (+5 -10) 📝 `src/Markdig.Tests/TestRoundtrip.cs` (+6 -10) 📝 `src/Markdig/Markdown.cs` (+3 -3) 📝 `src/Markdig/MarkdownExtensions.cs` (+43 -1) 📝 `src/Markdig/MarkdownPipeline.cs` (+19 -11) 📝 `src/Markdig/MarkdownPipelineBuilder.cs` (+7 -3) 📝 `src/Markdig/Renderers/HtmlRenderer.cs` (+11 -2) ➕ `src/Markdig/Renderers/HtmlRendererBuilder.cs` (+86 -0) ➕ `src/Markdig/Renderers/IMarkdownRendererBuilder.cs` (+22 -0) ➕ `src/Markdig/Renderers/Normalize/NormalizeRendererBuilder.cs` (+66 -0) ➕ `src/Markdig/Renderers/Roundtrip/RoundtripRendererBuilder.cs` (+23 -0) 📝 `src/Markdig/Renderers/TextRendererBase.cs` (+7 -1) </details> ### 📄 Description I needed to set up image url rewriting in a project of mine and found it a bit tedious not having a way to set it up in the pipeline. So I added the ability to configure the `HtmlRenderer` from the pipeline builder. As an added bonus, this works with the renderer cache as well. I did not add any tests but updated the BaseUrl test to configure the html renderer using the pipeline builder. I did not update changelog.md since it already has been neglected for some time. I have not spent any time figuring out whether any of the documentation should be updated, please advise. I could not find any existing PR or issue on this exact issue so I took the liberty to raise this draft PR. UPDATE: I added a bare bones builder for HtmlRenderer letting me set the one field I need as a POC. It is basically a factory for `TextRendererBase` which I also refactored the cache mechanism to use so that too should work for any text renderer. This goes for the `ToHtml` method since it uses the caching mechanism to get hold of its renderer. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-29 14:51:46 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#1228