[PR #387] [MERGED] Add missing Descendants<T> api #977

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

📋 Pull Request Information

Original PR: https://github.com/xoofx/markdig/pull/387
Author: @MihaZupan
Created: 1/21/2020
Status: Merged
Merged: 1/21/2020
Merged by: @xoofx

Base: masterHead: descendants-api


📝 Commits (2)

  • e4e6406 Add missing Descendants overload
  • fa2b157 Improve some CharHelper methods

📊 Changes

9 files changed (+220 additions, -56 deletions)

View changed files

📝 src/Markdig.Tests/TestDescendantsOrder.cs (+78 -10)
📝 src/Markdig.Tests/TestParser.cs (+13 -1)
📝 src/Markdig.Tests/TestPlayParser.cs (+1 -1)
📝 src/Markdig.Tests/TestSourcePosition.cs (+8 -9)
📝 src/Markdig/Extensions/Bootstrap/BootstrapExtension.cs (+2 -3)
📝 src/Markdig/Extensions/Globalization/GlobalizationExtension.cs (+8 -11)
📝 src/Markdig/Helpers/CharHelper.cs (+16 -11)
📝 src/Markdig/Syntax/Inlines/ContainerInline.cs (+16 -2)
📝 src/Markdig/Syntax/MarkdownObjectExtensions.cs (+78 -8)

📄 Description

We were missing a few conveniance overloads (#63)

IEnumerable<T> Descendants<T>(this MarkdownObject) where T : Inline
IEnumerable<T> Descendants<T>(this MarkdownObject) where T : Block

Since these can't coexist in C#, I added one where T : MarkdownObject that then calls the appropriate internal overload for optimal traversal (has the added bonus of not allocating when it's obvious there can't be any descendants).

Added tests for all the different overloads to make sure the traversal logic is correct.


🔄 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/387 **Author:** [@MihaZupan](https://github.com/MihaZupan) **Created:** 1/21/2020 **Status:** ✅ Merged **Merged:** 1/21/2020 **Merged by:** [@xoofx](https://github.com/xoofx) **Base:** `master` ← **Head:** `descendants-api` --- ### 📝 Commits (2) - [`e4e6406`](https://github.com/xoofx/markdig/commit/e4e6406546ce38ec8512389a8d11e7559dd338be) Add missing Descendants<T> overload - [`fa2b157`](https://github.com/xoofx/markdig/commit/fa2b157c1a11068471965f5536701f478e9b6020) Improve some CharHelper methods ### 📊 Changes **9 files changed** (+220 additions, -56 deletions) <details> <summary>View changed files</summary> 📝 `src/Markdig.Tests/TestDescendantsOrder.cs` (+78 -10) 📝 `src/Markdig.Tests/TestParser.cs` (+13 -1) 📝 `src/Markdig.Tests/TestPlayParser.cs` (+1 -1) 📝 `src/Markdig.Tests/TestSourcePosition.cs` (+8 -9) 📝 `src/Markdig/Extensions/Bootstrap/BootstrapExtension.cs` (+2 -3) 📝 `src/Markdig/Extensions/Globalization/GlobalizationExtension.cs` (+8 -11) 📝 `src/Markdig/Helpers/CharHelper.cs` (+16 -11) 📝 `src/Markdig/Syntax/Inlines/ContainerInline.cs` (+16 -2) 📝 `src/Markdig/Syntax/MarkdownObjectExtensions.cs` (+78 -8) </details> ### 📄 Description We were missing a few conveniance overloads (#63) ```c# IEnumerable<T> Descendants<T>(this MarkdownObject) where T : Inline IEnumerable<T> Descendants<T>(this MarkdownObject) where T : Block ``` Since these can't coexist in C#, I added one `where T : MarkdownObject` that then calls the appropriate internal overload for optimal traversal (has the added bonus of not allocating when it's obvious there can't be any descendants). Added tests for all the different overloads to make sure the traversal logic is correct. --- <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:48:05 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#977