cast decorations before creating codeblock
This commit is contained in:
parent
d015da113c
commit
469cbf4068
@ -394,8 +394,8 @@ LiteralCodeTheme = Literal[
|
|||||||
class Position(NoExtrasAllowedProps):
|
class Position(NoExtrasAllowedProps):
|
||||||
"""Position of the decoration."""
|
"""Position of the decoration."""
|
||||||
|
|
||||||
line: str
|
line: int
|
||||||
character: str
|
character: int
|
||||||
|
|
||||||
|
|
||||||
class ShikiDecorations(NoExtrasAllowedProps):
|
class ShikiDecorations(NoExtrasAllowedProps):
|
||||||
@ -586,6 +586,10 @@ class ShikiCodeBlock(Component):
|
|||||||
value
|
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_props["code"] = children[0]
|
||||||
code_block = super().create(**code_block_props)
|
code_block = super().create(**code_block_props)
|
||||||
|
|
||||||
@ -596,9 +600,6 @@ class ShikiCodeBlock(Component):
|
|||||||
transformer_styles.update(transformer.style)
|
transformer_styles.update(transformer.style)
|
||||||
transformer_styles.update(code_wrapper_props.pop("style", {}))
|
transformer_styles.update(code_wrapper_props.pop("style", {}))
|
||||||
|
|
||||||
decorations = [ShikiDecorations(**decoration) for decoration in decorations]
|
|
||||||
code_block_props["decorations"] = decorations
|
|
||||||
|
|
||||||
return Box.create(
|
return Box.create(
|
||||||
code_block,
|
code_block,
|
||||||
*children[1:],
|
*children[1:],
|
||||||
|
@ -330,8 +330,8 @@ LiteralCodeTheme = Literal[
|
|||||||
]
|
]
|
||||||
|
|
||||||
class Position(NoExtrasAllowedProps):
|
class Position(NoExtrasAllowedProps):
|
||||||
line: str
|
line: int
|
||||||
character: str
|
character: int
|
||||||
|
|
||||||
class ShikiDecorations(NoExtrasAllowedProps):
|
class ShikiDecorations(NoExtrasAllowedProps):
|
||||||
start: Union[int, Position]
|
start: Union[int, Position]
|
||||||
|
Loading…
Reference in New Issue
Block a user