Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

bugfix: fix a bug where custom serializer blocks can fail if after a … (Sourcery refactored) #45

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
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
12 changes: 7 additions & 5 deletions 12 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 Expand Up @@ -208,8 +208,11 @@ def _normalize_list_tree(self, nodes: list) -> list[dict]:
continue

if node.get('level') < current_list['level']:
parent = self._find_list(tree[-1], level=node.get('level'), list_item=node.get('listItem'))
if parent:
if parent := self._find_list(
tree[-1],
level=node.get('level'),
list_item=node.get('listItem'),
):
Comment on lines -211 to +215
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function PortableTextRenderer._normalize_list_tree refactored with the following changes:

current_list = parent
current_list['children'].append(node)
continue
Expand Down Expand Up @@ -240,8 +243,7 @@ def _find_list(self, root_node: dict, level: int, list_item: Optional[str] = Non
):
return root_node

children = root_node.get('children')
if children:
if children := root_node.get('children'):
Comment on lines -243 to +246
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function PortableTextRenderer._find_list refactored with the following changes:

return self._find_list(children[-1], level, list_item)

return None
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.