-
Notifications
You must be signed in to change notification settings - Fork 337
Open
Labels
Milestone
Description
Defined as something like
class FormattedText(pydantic.BaseModel, extra='forbid'):
text: str
text_format: typing.Literal['bold', 'italic', 'underline', 'strikethrough'] | None = pydantic.Field(None, serialization_alias='textFormat')
# TODO, use pydantic-extra-types Color?
text_color: str | None = pydantic.Field(None, serialization_alias='textColor')
background_color: str | None = pydantic.Field(None, serialization_alias='backgroundColor')
type: typing.Literal['FormattedText'] = 'FormattedText'
The items in components like Button
and Link
become list[str | FormattedText | Link]
. We might want too provide a few more components specifically for typography, like Bullets
and Numbers
Two reasons to do this over relying on Markdown
:
- Markdown is a relatively heave lazy module, that it would be nice not to have to load
- Markdown by it's definition is terrible for templating or user defined values - it's virtually impossible to escape. Providing these types would allow text to be defined which included uses values safely