cast decorations before creating codeblock

This commit is contained in:
Elijah 2024-10-26 09:12:37 +00:00
parent d015da113c
commit 469cbf4068
2 changed files with 8 additions and 7 deletions

View File

@ -394,8 +394,8 @@ LiteralCodeTheme = Literal[
class Position(NoExtrasAllowedProps):
"""Position of the decoration."""
line: str
character: str
line: int
character: int
class ShikiDecorations(NoExtrasAllowedProps):
@ -586,6 +586,10 @@ class ShikiCodeBlock(Component):
value
)
# cast decorations into ShikiDecorations.
decorations = [ShikiDecorations(**decoration) for decoration in decorations]
code_block_props["decorations"] = decorations
code_block_props["code"] = children[0]
code_block = super().create(**code_block_props)
@ -596,9 +600,6 @@ class ShikiCodeBlock(Component):
transformer_styles.update(transformer.style)
transformer_styles.update(code_wrapper_props.pop("style", {}))
decorations = [ShikiDecorations(**decoration) for decoration in decorations]
code_block_props["decorations"] = decorations
return Box.create(
code_block,
*children[1:],

View File

@ -330,8 +330,8 @@ LiteralCodeTheme = Literal[
]
class Position(NoExtrasAllowedProps):
line: str
character: str
line: int
character: int
class ShikiDecorations(NoExtrasAllowedProps):
start: Union[int, Position]