@@ -731,8 +731,7 @@ def test_admonition_single_line(
731731 rst_content = f"""
732732 Regular paragraph.
733733
734- .. { admonition_type } ::
735- { message }
734+ .. { admonition_type } :: { message }
736735
737736 Another paragraph.
738737 """
@@ -773,19 +772,69 @@ def test_admonition_multiline(
773772) -> None :
774773 """Test that admonitions with multiple paragraphs work.
775774
776- For now, we ignore children and just combine all text content.
775+ The first paragraph becomes the callout text, and subsequent
776+ paragraphs become nested blocks within the callout.
777777 """
778778 rst_content = f"""
779779 .. { admonition_type } ::
780780 This is the first paragraph of the { admonition_type } .
781781
782- This is the second paragraph that should be combined .
782+ This is the second paragraph that should be nested .
783783 """
784- # Create the callout with expected rich text structure
785784 callout = UnoCallout (text = "" , icon = Emoji (emoji = emoji ), color = color )
786785 callout .rich_text = text (
787786 text = f"This is the first paragraph of the { admonition_type } ."
788- ) + text (text = "This is the second paragraph that should be combined." )
787+ )
788+
789+ nested_paragraph = UnoParagraph (
790+ text = "This is the second paragraph that should be nested."
791+ )
792+
793+ callout .obj_ref .value .children .append (nested_paragraph .obj_ref ) # pyright: ignore[reportUnknownMemberType]
794+
795+ expected_objects : list [NotionObject [Any ]] = [
796+ callout ,
797+ ]
798+ _assert_rst_converts_to_notion_objects (
799+ rst_content = rst_content ,
800+ expected_objects = expected_objects ,
801+ make_app = make_app ,
802+ tmp_path = tmp_path ,
803+ )
804+
805+
806+ def test_admonition_with_code_block (
807+ make_app : Callable [..., SphinxTestApp ],
808+ tmp_path : Path ,
809+ ) -> None :
810+ """
811+ Test that admonitions can contain code blocks as nested children.
812+ """
813+ rst_content = """
814+ .. note::
815+ This note contains a code example.
816+
817+ .. code-block:: python
818+
819+ def hello():
820+ print("Hello, world!")
821+
822+ The code above demonstrates a simple function.
823+ """
824+
825+ callout = UnoCallout (text = "" , icon = Emoji (emoji = "📝" ), color = Color .BLUE )
826+ callout .rich_text = text (text = "This note contains a code example." )
827+
828+ nested_code_block = _create_code_block_without_annotations (
829+ content = 'def hello():\n print("Hello, world!")' ,
830+ language = CodeLang .PYTHON ,
831+ )
832+ nested_paragraph = UnoParagraph (
833+ text = "The code above demonstrates a simple function."
834+ )
835+
836+ callout .obj_ref .value .children .append (nested_code_block .obj_ref ) # pyright: ignore[reportUnknownMemberType]
837+ callout .obj_ref .value .children .append (nested_paragraph .obj_ref ) # pyright: ignore[reportUnknownMemberType]
789838
790839 expected_objects : list [NotionObject [Any ]] = [
791840 callout ,
@@ -798,6 +847,48 @@ def test_admonition_multiline(
798847 )
799848
800849
850+ def test_admonition_with_code_block_first (
851+ make_app : Callable [..., SphinxTestApp ],
852+ tmp_path : Path ,
853+ ) -> None :
854+ """Test admonition with code block as first child (not paragraph).
855+
856+ This tests the else clause when first child is not a paragraph.
857+ """
858+ rst_content = """
859+ .. note::
860+
861+ .. code-block:: python
862+
863+ def hello():
864+ print("Hello, world!")
865+
866+ This paragraph comes after the code block.
867+ """
868+
869+ callout = UnoCallout (text = "" , icon = Emoji (emoji = "📝" ), color = Color .BLUE )
870+ callout .rich_text = text (text = "" )
871+
872+ nested_code_block = _create_code_block_without_annotations (
873+ content = 'def hello():\n print("Hello, world!")' ,
874+ language = CodeLang .PYTHON ,
875+ )
876+ nested_paragraph = UnoParagraph (
877+ text = "This paragraph comes after the code block."
878+ )
879+
880+ callout .obj_ref .value .children .append (nested_code_block .obj_ref ) # pyright: ignore[reportUnknownMemberType]
881+ callout .obj_ref .value .children .append (nested_paragraph .obj_ref ) # pyright: ignore[reportUnknownMemberType]
882+
883+ expected_objects : list [NotionObject [Any ]] = [callout ]
884+ _assert_rst_converts_to_notion_objects (
885+ rst_content = rst_content ,
886+ expected_objects = expected_objects ,
887+ make_app = make_app ,
888+ tmp_path = tmp_path ,
889+ )
890+
891+
801892def test_nested_bullet_list (
802893 make_app : Callable [..., SphinxTestApp ],
803894 tmp_path : Path ,
0 commit comments