Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ See the [Contributing Guide](contributing.md) for details.
## [Unreleased]

* Update serializer to be non-recursive (#1644).
* Improve ancestor handling in the inline `Treeprocessor` (#1646).

## [3.11.0] - 2026-09-25

Expand Down
4 changes: 3 additions & 1 deletion markdown/treeprocessors.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,12 +371,14 @@ def run(self, tree: etree.Element, ancestors: list[str] | None = None) -> etree.

self.parent_map = {c: p for p in tree.iter() for c in p}
stack = [(tree, tree_parents)]
self.__build_ancestors(tree, tree_parents)

while stack:
currElement, parents = stack.pop(0)

self.ancestors = parents
self.__build_ancestors(currElement, self.ancestors)
if currElement is not tree:
self.ancestors.append(currElement.tag.lower())

insertQueue = []
for child in currElement:
Expand Down
Loading