Skip to content

Commit

Permalink
bugfix: fix a bug where custom serializer blocks can fail if after a …
Browse files Browse the repository at this point in the history
…list

This commit fixes a bug where the rendering of a node can fail
if it has fields not supported by Block and follows directly after
a list item.

The list item logic would pass in the first node after the list as context
and cast it to a Block. This fails if the node has fields not supported
by Block. Which is the case for custom serializer blocks.

The context is actually not used, and removing it solves the bug.
  • Loading branch information
Kakebake committed Jun 20, 2022
1 parent 69fa475 commit bf018e4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion portabletext_html/renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def render(self) -> str:

if list_nodes and not is_list(node):
tree = self._normalize_list_tree(list_nodes)
result += ''.join([self._render_node(n, Block(**node), list_item=True) for n in tree])
result += ''.join([self._render_node(n, list_item=True) for n in tree])
list_nodes = [] # reset list_nodes

if is_list(node):
Expand Down

0 comments on commit bf018e4

Please sign in to comment.