Skip to content

Commit 7f42df4

Browse files
Merge pull request #81 from adamtheturtle/fix-bullet
Fix bullets within admonitions
2 parents 90453d1 + 2a1759c commit 7f42df4

File tree

2 files changed

+46
-30
lines changed

2 files changed

+46
-30
lines changed

src/sphinx_notion/__init__.py

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -187,15 +187,6 @@ def _(
187187
return [code_block]
188188

189189

190-
@_process_node_to_blocks.register
191-
def _(node: nodes.list_item, *, section_level: int) -> list[NotionObject[Any]]:
192-
"""
193-
Process list item nodes by creating BulletedItem blocks.
194-
"""
195-
del section_level
196-
return [_process_list_item_recursively(node=node, depth=0)]
197-
198-
199190
@_process_node_to_blocks.register
200191
def _(
201192
node: nodes.bullet_list,
@@ -206,10 +197,11 @@ def _(
206197
Process bullet list nodes by creating Notion BulletedItem blocks.
207198
"""
208199
del section_level
209-
del node
210-
# We don't create a block for the list itself,
211-
# just process the children (list items)
212-
return []
200+
return [
201+
_process_list_item_recursively(node=list_item, depth=0)
202+
for list_item in node.children
203+
if isinstance(list_item, nodes.list_item)
204+
]
213205

214206

215207
@_process_node_to_blocks.register
@@ -499,23 +491,6 @@ def visit_bullet_list(self, node: nodes.Element) -> None:
499491
section_level=self._section_level,
500492
)
501493
self._blocks.extend(blocks)
502-
503-
def depart_bullet_list(self, node: nodes.Element) -> None:
504-
"""
505-
Handle leaving bullet list nodes.
506-
"""
507-
assert self
508-
del node
509-
510-
def visit_list_item(self, node: nodes.Element) -> None:
511-
"""
512-
Handle list item nodes by creating Notion BulletedItem blocks.
513-
"""
514-
blocks = _process_node_to_blocks(
515-
node,
516-
section_level=self._section_level,
517-
)
518-
self._blocks.extend(blocks)
519494
raise nodes.SkipNode
520495

521496
def visit_topic(self, node: nodes.Element) -> None:

tests/test_integration.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -889,6 +889,47 @@ def hello():
889889
)
890890

891891

892+
def test_admonition_with_bullet_points(
893+
make_app: Callable[..., SphinxTestApp],
894+
tmp_path: Path,
895+
) -> None:
896+
"""
897+
Test that bullet points show up within admonitions (issue #78).
898+
"""
899+
rst_content = """
900+
.. note::
901+
902+
This is an important note that demonstrates the note admonition
903+
support.
904+
905+
* A
906+
* B
907+
"""
908+
909+
callout = UnoCallout(text="", icon=Emoji(emoji="📝"), color=Color.BLUE)
910+
callout.rich_text = text(
911+
text="This is an important note that demonstrates the note "
912+
"admonition\nsupport."
913+
)
914+
915+
bullet_a = UnoBulletedItem(text="A")
916+
bullet_b = UnoBulletedItem(text="B")
917+
918+
callout.obj_ref.value.children.append(bullet_a.obj_ref) # pyright: ignore[reportUnknownMemberType]
919+
callout.obj_ref.value.children.append(bullet_b.obj_ref) # pyright: ignore[reportUnknownMemberType]
920+
921+
expected_objects: list[NotionObject[Any]] = [
922+
callout,
923+
]
924+
925+
_assert_rst_converts_to_notion_objects(
926+
rst_content=rst_content,
927+
expected_objects=expected_objects,
928+
make_app=make_app,
929+
tmp_path=tmp_path,
930+
)
931+
932+
892933
def test_nested_bullet_list(
893934
make_app: Callable[..., SphinxTestApp],
894935
tmp_path: Path,

0 commit comments

Comments
 (0)