Skip to content

Commit 29fa7be

Browse files
committed
Define pandoc InlineContent type to be recursive
InlineContent is already processed recursively, this change makes the type definition recursive too. And it also defines a clearer relationship between InlineContent and BlockContent.
1 parent 6781777 commit 29fa7be

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

quartodoc/pandoc/blocks.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from quartodoc.pandoc.inlines import (
2121
Inline,
2222
InlineContent,
23+
InlineContentItem,
2324
inlinecontent_to_str,
2425
str_as_list_item,
2526
)
@@ -79,8 +80,8 @@ def as_list_item(self):
7980

8081
# TypeAlias declared here to avoid forward-references which
8182
# break beartype
82-
ContentItem: TypeAlias = Union[str, Inline, Block]
83-
BlockContent: TypeAlias = Union[ContentItem, Sequence[ContentItem]]
83+
BlockContentItem: TypeAlias = Union[InlineContentItem, Block]
84+
BlockContent: TypeAlias = Union[BlockContentItem, Sequence[BlockContentItem]]
8485
DefinitionItem: TypeAlias = tuple[InlineContent, BlockContent]
8586

8687

quartodoc/pandoc/inlines.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ def as_list_item(self):
6565

6666
# TypeAlias declared here to avoid forward-references which
6767
# break beartype
68-
InlineContent: TypeAlias = Union[str, Inline, Union[Sequence[str], Inline]]
68+
InlineContentItem = Union[str, Inline]
69+
InlineContent: TypeAlias = Union[InlineContentItem, Sequence[InlineContentItem]]
6970

7071

7172
@dataclass

quartodoc/tests/pandoc/test_inlines.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ def test_span():
8787
s = Span("a", Attr("span-id", classes=["c1", "c2"], attributes={"data-value": "1"}))
8888
assert str(s) == '[a]{#span-id .c1 .c2 data-value="1"}'
8989

90+
s = Span([Span("a"), Span("b"), "c"])
91+
assert str(s) == "[[a]{} [b]{} c]{}"
92+
9093

9194
def test_str():
9295
s = Str("a")

0 commit comments

Comments
 (0)