textoutpc.builtin.nodes – Built-in node definitions#

textoutpc.builtin.nodes.Anchor#

Anchor.

alias of typing.Annotated[str, StringConstraints(strip_whitespace=None, to_upper=None, to_lower=None, strict=None, min_length=None, max_length=None, pattern=’^[A-Za-z0-9_]+$’)]

textoutpc.builtin.nodes.FontName#

Name of a font.

alias of typing.Annotated[str, StringConstraints(strip_whitespace=None, to_upper=None, to_lower=None, strict=None, min_length=None, max_length=None, pattern=’^[a-z0-9 ]+$’)]

textoutpc.builtin.nodes.Username#

Username of a Planète Casio user.

alias of typing.Annotated[str, StringConstraints(strip_whitespace=None, to_upper=None, to_lower=None, strict=None, min_length=None, max_length=None, pattern=’^[A-Za-z0-9_ .-]+$’)]

textoutpc.builtin.nodes.CodeLanguage#

Name of a code language.

alias of typing.Annotated[str, StringConstraints(strip_whitespace=None, to_upper=None, to_lower=None, strict=None, min_length=None, max_length=None, pattern=’^[^\s](?:.*[^\s])?$’)]

class textoutpc.builtin.nodes.TitleNode(children: Iterable[Node] | None = None)#

Bases: BlockInlineContainerNode

Document title node.

render_html(env: NodeHTMLRenderEnvironment, /) str#

Render the node as HTML.

Parameters:

env – Environment with all of the options.

Returns:

Rendered HTML version of the node.

children: tuple[Node, ...]#

Children.

class textoutpc.builtin.nodes.SubtitleNode(children: Iterable[Node] | None = None)#

Bases: BlockInlineContainerNode

Document subtitle node.

render_html(env: NodeHTMLRenderEnvironment, /) str#

Render the node as HTML.

Parameters:

env – Environment with all of the options.

Returns:

Rendered HTML version of the node.

children: tuple[Node, ...]#

Children.

class textoutpc.builtin.nodes.QuoteAuthorNode(children: Iterable[Node] | None = None)#

Bases: BlockInlineContainerNode

Quote author node.

render_html(env: NodeHTMLRenderEnvironment, /) str#

Render the node as HTML.

Parameters:

env – Environment with all of the options.

Returns:

Rendered HTML version of the node.

children: tuple[Node, ...]#

Children.

class textoutpc.builtin.nodes.QuoteContentNode(children: Iterable[Node] | None = None)#

Bases: BlockContainerNode

Quote content node.

render_html(env: NodeHTMLRenderEnvironment, /) str#

Render the node as HTML.

Parameters:

env – Environment with all of the options.

Returns:

Rendered HTML version of the node.

children: tuple[Node, ...]#

Children.

class textoutpc.builtin.nodes.QuoteNode(children: Iterable[Node] | None = None)#

Bases: BlockContainerNode

Quote node.

AUTHORIZED_CHILDREN_TYPES: ClassVar[Sequence[type[Node] | tuple[type[Node], int | range]] | None] = ((<class 'textoutpc.builtin.nodes.QuoteAuthorNode'>, range(0, 2)), (<class 'textoutpc.builtin.nodes.QuoteContentNode'>, 1))#

Authorized children types.

This is a sequence of either the type to check, or the authorized count of this type of node. Here’s an example use of this property:

class MyContainerNode(ContainerNode):
    AUTHORIZED_CHILDREN_TYPES = (
        MyFirstNode,
        (MySecondNode, 4),
        (MyThirdNode, range(1, 3)),
    )

This example presents the following constraints:

  • Children are either instances of MyFirstNode, MySecondNode or MyThirdNode;

  • There must be exactly 4 MySecondNode instances;

  • There must be 1 or 2 MyThirdNode instances.

render_html(env: NodeHTMLRenderEnvironment, /) str#

Render the node as HTML.

Parameters:

env – Environment with all of the options.

Returns:

Rendered HTML version of the node.

children: tuple[Node, ...]#

Children.

class textoutpc.builtin.nodes.IndentNode(children: Iterable[Node] | None = None)#

Bases: BlockInlineContainerNode

Indentation node.

render_html(env: NodeHTMLRenderEnvironment, /) str#

Render the node as HTML.

Parameters:

env – Environment with all of the options.

Returns:

Rendered HTML version of the node.

children: tuple[Node, ...]#

Children.

class textoutpc.builtin.nodes.SpoilerOpenLabelNode(children: Iterable[Node] | None = None)#

Bases: BlockInlineContainerNode

Node to display to prompt the user to open the spoiler.

render_html(env: NodeHTMLRenderEnvironment, /) str#

Render the node as HTML.

Parameters:

env – Environment with all of the options.

Returns:

Rendered HTML version of the node.

children: tuple[Node, ...]#

Children.

class textoutpc.builtin.nodes.SpoilerCloseLabelNode(children: Iterable[Node] | None = None)#

Bases: BlockInlineContainerNode

Node to display to prompt the user to close the spoiler.

render_html(env: NodeHTMLRenderEnvironment, /) str#

Render the node as HTML.

Parameters:

env – Environment with all of the options.

Returns:

Rendered HTML version of the node.

children: tuple[Node, ...]#

Children.

class textoutpc.builtin.nodes.SpoilerContentNode(children: Iterable[Node] | None = None)#

Bases: BlockContainerNode

Spoiler content node.

render_html(env: NodeHTMLRenderEnvironment, /) str#

Render the node as HTML.

Parameters:

env – Environment with all of the options.

Returns:

Rendered HTML version of the node.

children: tuple[Node, ...]#

Children.

class textoutpc.builtin.nodes.SpoilerNode(children: Iterable[Node] | None = None)#

Bases: BlockContainerNode

Spoiler node.

AUTHORIZED_CHILDREN_TYPES: ClassVar[Sequence[type[Node] | tuple[type[Node], int | range]] | None] = ((<class 'textoutpc.builtin.nodes.SpoilerOpenLabelNode'>, 1), (<class 'textoutpc.builtin.nodes.SpoilerCloseLabelNode'>, 1), (<class 'textoutpc.builtin.nodes.SpoilerContentNode'>, 1))#

Authorized children types.

This is a sequence of either the type to check, or the authorized count of this type of node. Here’s an example use of this property:

class MyContainerNode(ContainerNode):
    AUTHORIZED_CHILDREN_TYPES = (
        MyFirstNode,
        (MySecondNode, 4),
        (MyThirdNode, range(1, 3)),
    )

This example presents the following constraints:

  • Children are either instances of MyFirstNode, MySecondNode or MyThirdNode;

  • There must be exactly 4 MySecondNode instances;

  • There must be 1 or 2 MyThirdNode instances.

render_html(env: NodeHTMLRenderEnvironment, /) str#

Render the node as HTML.

Parameters:

env – Environment with all of the options.

Returns:

Rendered HTML version of the node.

children: tuple[Node, ...]#

Children.

class textoutpc.builtin.nodes.CodeNode(content: str, *, language: str | None = None)#

Bases: BlockNode

Code node.

content: str#

Content.

language: CodeLanguage | None#

Language of the code.

render_html(env: NodeHTMLRenderEnvironment, /) str#

Render the node as HTML.

Parameters:

env – Environment with all of the options.

Returns:

Rendered HTML version of the node.

class textoutpc.builtin.nodes.BaseImageNode(*, align: Literal['center', 'left', 'right'] | None = None, width: int | None = None, height: int | None = None, float: bool = False)#

Bases: Node

Image node.

align: Literal['center', 'left', 'right'] | None#

Optional alignment to apply to the image.

width: int | None#

Optional width to display the image as, in pixels.

height: int | None#

Optional height to display the image as, in pixels.

float: bool#

Whether the image should be displayed as floating or not.

abstract get_url_for_html_output(env: NodeHTMLRenderEnvironment, /) str#

Get the URL to the image for HTML output.

Returns:

Obtained URL.

render_html(env: NodeHTMLRenderEnvironment, /) str#

Render the node as HTML.

Parameters:

env – Environment with all of the options.

Returns:

Rendered HTML version of the node.

class textoutpc.builtin.nodes.ImageNode(*, align: Literal['center', 'left', 'right'] | None = None, width: int | None = None, height: int | None = None, float: bool = False, url: HttpUrl)#

Bases: BaseImageNode

Image node.

url: HttpUrl#

URL of the image to display.

get_url_for_html_output(env: NodeHTMLRenderEnvironment, /) str#

Get the URL to the image for HTML output.

Returns:

Obtained URL.

class textoutpc.builtin.nodes.AdminImageNode(*, align: Literal['center', 'left', 'right'] | None = None, width: int | None = None, height: int | None = None, float: bool = False, path: str)#

Bases: BaseImageNode

Admin image node.

path: str#

Path to the image to display.

get_url_for_html_output(env: NodeHTMLRenderEnvironment, /) str#

Get the URL to the image for HTML output.

Returns:

Obtained URL.

class textoutpc.builtin.nodes.ProgressBarNode(children: Iterable[Node] | None = None, *, value: Decimal)#

Bases: BlockContainerNode

Progress bar node.

value: Annotated[Decimal, Ge(0), Le(1)]#

Value of the progress bar, between 0 and 1 included.

render_html(env: NodeHTMLRenderEnvironment, /) str#

Render the node as HTML.

Parameters:

env – Environment with all of the options.

Returns:

Rendered HTML version of the node.

class textoutpc.builtin.nodes.CalcIconNode(*, name: str)#

Bases: InlineNode

Calculator icon node.

name: str#

Smiley name.

render_html(env: NodeHTMLRenderEnvironment, /) str#

Render the node as HTML.

Parameters:

env – Environment with all of the options.

Returns:

Rendered HTML version of the node.

class textoutpc.builtin.nodes.ListItemNode(children: Iterable[Node] | None = None)#

Bases: BlockContainerNode

List item node.

render_html(env: NodeHTMLRenderEnvironment, /) str#

Render the node as HTML.

Parameters:

env – Environment with all of the options.

Returns:

Rendered HTML version of the node.

children: tuple[Node, ...]#

Children.

class textoutpc.builtin.nodes.ListType(value)#

Bases: str, Enum

List type.

UL = 'ul'#

Unordered list.

OL = 'ol'#

Ordered list.

ARROW = 'arrow'#

Arrow-based list.

class textoutpc.builtin.nodes.ListNode(children: Iterable[Node] | None = None, *, type: ListType = ListType.UL)#

Bases: BlockContainerNode

List node.

AUTHORIZED_CHILDREN_TYPES: ClassVar[Sequence[type[Node] | tuple[type[Node], int | range]] | None] = (<class 'textoutpc.builtin.nodes.ListItemNode'>,)#

Authorized children types.

This is a sequence of either the type to check, or the authorized count of this type of node. Here’s an example use of this property:

class MyContainerNode(ContainerNode):
    AUTHORIZED_CHILDREN_TYPES = (
        MyFirstNode,
        (MySecondNode, 4),
        (MyThirdNode, range(1, 3)),
    )

This example presents the following constraints:

  • Children are either instances of MyFirstNode, MySecondNode or MyThirdNode;

  • There must be exactly 4 MySecondNode instances;

  • There must be 1 or 2 MyThirdNode instances.

type: ListType#

List type.

render_html(env: NodeHTMLRenderEnvironment, /) str#

Render the node as HTML.

Parameters:

env – Environment with all of the options.

Returns:

Rendered HTML version of the node.

class textoutpc.builtin.nodes.TableHeaderNode(children: Iterable[Node] | None = None)#

Bases: BlockInlineContainerNode

Table header node.

render_html(env: NodeHTMLRenderEnvironment, /) str#

Render the node as HTML.

Parameters:

env – Environment with all of the options.

Returns:

Rendered HTML version of the node.

children: tuple[Node, ...]#

Children.

class textoutpc.builtin.nodes.TableCellNode(children: Iterable[Node] | None = None)#

Bases: BlockInlineContainerNode

Table cell node.

render_html(env: NodeHTMLRenderEnvironment, /) str#

Render the node as HTML.

Parameters:

env – Environment with all of the options.

Returns:

Rendered HTML version of the node.

children: tuple[Node, ...]#

Children.

class textoutpc.builtin.nodes.TableRowNode(children: Iterable[Node] | None = None)#

Bases: BlockContainerNode

Table row node.

AUTHORIZED_CHILDREN_TYPES: ClassVar[Sequence[type[Node] | tuple[type[Node], int | range]] | None] = (<class 'textoutpc.builtin.nodes.TableHeaderNode'>, <class 'textoutpc.builtin.nodes.TableCellNode'>)#

Authorized children types.

This is a sequence of either the type to check, or the authorized count of this type of node. Here’s an example use of this property:

class MyContainerNode(ContainerNode):
    AUTHORIZED_CHILDREN_TYPES = (
        MyFirstNode,
        (MySecondNode, 4),
        (MyThirdNode, range(1, 3)),
    )

This example presents the following constraints:

  • Children are either instances of MyFirstNode, MySecondNode or MyThirdNode;

  • There must be exactly 4 MySecondNode instances;

  • There must be 1 or 2 MyThirdNode instances.

render_html(env: NodeHTMLRenderEnvironment, /) str#

Render the node as HTML.

Parameters:

env – Environment with all of the options.

Returns:

Rendered HTML version of the node.

children: tuple[Node, ...]#

Children.

class textoutpc.builtin.nodes.TableNode(children: Iterable[Node] | None = None)#

Bases: BlockContainerNode

Table node.

AUTHORIZED_CHILDREN_TYPES: ClassVar[Sequence[type[Node] | tuple[type[Node], int | range]] | None] = (<class 'textoutpc.builtin.nodes.TableRowNode'>,)#

Authorized children types.

This is a sequence of either the type to check, or the authorized count of this type of node. Here’s an example use of this property:

class MyContainerNode(ContainerNode):
    AUTHORIZED_CHILDREN_TYPES = (
        MyFirstNode,
        (MySecondNode, 4),
        (MyThirdNode, range(1, 3)),
    )

This example presents the following constraints:

  • Children are either instances of MyFirstNode, MySecondNode or MyThirdNode;

  • There must be exactly 4 MySecondNode instances;

  • There must be 1 or 2 MyThirdNode instances.

render_html(env: NodeHTMLRenderEnvironment, /) str#

Render the node as HTML.

Parameters:

env – Environment with all of the options.

Returns:

Rendered HTML version of the node.

children: tuple[Node, ...]#

Children.

class textoutpc.builtin.nodes.StrongNode(children: Iterable[Node] | None = None)#

Bases: InlineContainerNode

Node to place text in strong.

render_html(env: NodeHTMLRenderEnvironment, /) str#

Render the node as HTML.

Parameters:

env – Environment with all of the options.

Returns:

Rendered HTML version of the node.

children: tuple[Node, ...]#

Children.

class textoutpc.builtin.nodes.EmphasisNode(children: Iterable[Node] | None = None)#

Bases: InlineContainerNode

Node to place text in emphasis (italic).

render_html(env: NodeHTMLRenderEnvironment, /) str#

Render the node as HTML.

Parameters:

env – Environment with all of the options.

Returns:

Rendered HTML version of the node.

children: tuple[Node, ...]#

Children.

class textoutpc.builtin.nodes.UnderlineNode(children: Iterable[Node] | None = None)#

Bases: InlineContainerNode

Node to place text with an underline.

render_html(env: NodeHTMLRenderEnvironment, /) str#

Render the node as HTML.

Parameters:

env – Environment with all of the options.

Returns:

Rendered HTML version of the node.

children: tuple[Node, ...]#

Children.

class textoutpc.builtin.nodes.OverlineNode(children: Iterable[Node] | None = None)#

Bases: InlineContainerNode

Node to place text with an overline.

render_html(env: NodeHTMLRenderEnvironment, /) str#

Render the node as HTML.

Parameters:

env – Environment with all of the options.

Returns:

Rendered HTML version of the node.

children: tuple[Node, ...]#

Children.

class textoutpc.builtin.nodes.StrikeThroughNode(children: Iterable[Node] | None = None)#

Bases: InlineContainerNode

Node to place text with a strike-through.

render_html(env: NodeHTMLRenderEnvironment, /) str#

Render the node as HTML.

Parameters:

env – Environment with all of the options.

Returns:

Rendered HTML version of the node.

children: tuple[Node, ...]#

Children.

class textoutpc.builtin.nodes.FontFamilyNode(children: Iterable[Node] | None = None, *, name: str)#

Bases: InlineContainerNode

Node to set the font manually on a given text.

name: FontName#

Name of the font to set.

render_html(env: NodeHTMLRenderEnvironment, /) str#

Render the node as HTML.

Parameters:

env – Environment with all of the options.

Returns:

Rendered HTML version of the node.

class textoutpc.builtin.nodes.FontSizeNode(children: Iterable[Node] | None = None, *, size: Decimal, unit: Literal['pt', 'em'])#

Bases: InlineContainerNode

Node to set the font size manually on a given text.

size: Annotated[Decimal, Gt(0)]#

Font size, in the provided unit.

unit: Literal['pt', 'em']#

Unit of the font size to set.

render_html(env: NodeHTMLRenderEnvironment, /) str#

Render the node as HTML.

Parameters:

env – Environment with all of the options.

Returns:

Rendered HTML version of the node.

class textoutpc.builtin.nodes.FontColorNode(children: Iterable[Node] | None = None, *, color: Color)#

Bases: InlineContainerNode

Node to set the font color manually.

color: Color#

Color to set to the font.

render_html(env: NodeHTMLRenderEnvironment, /) str#

Render the node as HTML.

Parameters:

env – Environment with all of the options.

Returns:

Rendered HTML version of the node.

class textoutpc.builtin.nodes.BackColorNode(children: Iterable[Node] | None = None, *, color: Color)#

Bases: InlineContainerNode

Node to set the background color manually on text.

color: Color#

Color to set to the background color manually.

render_html(env: NodeHTMLRenderEnvironment, /) str#

Render the node as HTML.

Parameters:

env – Environment with all of the options.

Returns:

Rendered HTML version of the node.

class textoutpc.builtin.nodes.InlineCodeNode(content: str, *, language: str | None = None)#

Bases: InlineNode

Inline code node.

content: str#

Content.

language: CodeLanguage | None#

Language of the code.

render_html(env: NodeHTMLRenderEnvironment, /) str#

Render the node as HTML.

Parameters:

env – Environment with all of the options.

Returns:

Rendered HTML version of the node.

class textoutpc.builtin.nodes.AnchorNode(children: Iterable[Node] | None = None, *, anchor: str)#

Bases: InlineContainerNode

Anchor node.

anchor: Anchor#

Anchor to place.

render_html(env: NodeHTMLRenderEnvironment, /) str#

Render the node as HTML.

Parameters:

env – Environment with all of the options.

Returns:

Rendered HTML version of the node.

class textoutpc.builtin.nodes.TargetNode(children: Iterable[Node] | None = None, *, anchor: str)#

Bases: InlineContainerNode

Target node.

anchor: Anchor#

Anchor to reference.

render_html(env: NodeHTMLRenderEnvironment, /) str#

Render the node as HTML.

Parameters:

env – Environment with all of the options.

Returns:

Rendered HTML version of the node.

class textoutpc.builtin.nodes.ExternalReferenceNode#

Bases: InlineNode

Reference to an external resource.

abstract build_data(env: NodeHTMLRenderEnvironment, /) tuple[str, str]#

Build external reference data.

Parameters:

env – Environment with all of the options.

Returns:

Obtained title and URL.

render_html(env: NodeHTMLRenderEnvironment, /) str#

Render the node as HTML.

Parameters:

env – Environment with all of the options.

Returns:

Rendered HTML version of the node.

class textoutpc.builtin.nodes.ProfileReferenceNode(*, username: str)#

Bases: ExternalReferenceNode

Reference to a Planète Casio user profile.

username: Username#

Username to reference.

build_data(env: NodeHTMLRenderEnvironment, /) tuple[str, str]#

Build external reference data.

Parameters:

env – Environment with all of the options.

Returns:

Obtained title and URL.

class textoutpc.builtin.nodes.TopicReferenceNode(*, id: int)#

Bases: ExternalReferenceNode

Reference to a Planète Casio forum topic.

id: Annotated[int, Ge(1)]#

Topic to reference.

build_data(env: NodeHTMLRenderEnvironment, /) tuple[str, str]#

Build external reference data.

Parameters:

env – Environment with all of the options.

Returns:

Obtained title and URL.

class textoutpc.builtin.nodes.TutorialReferenceNode(*, id: int)#

Bases: ExternalReferenceNode

Reference to a Planète Casio tutorial.

id: Annotated[int, Ge(1)]#

Tutorial to reference.

build_data(env: NodeHTMLRenderEnvironment, /) tuple[str, str]#

Build external reference data.

Parameters:

env – Environment with all of the options.

Returns:

Obtained title and URL.

class textoutpc.builtin.nodes.ProgramReferenceNode(*, id: int)#

Bases: ExternalReferenceNode

Reference to a Planète Casio program.

id: Annotated[int, Ge(1)]#

Program to reference.

build_data(env: NodeHTMLRenderEnvironment, /) tuple[str, str]#

Build external reference data.

Parameters:

env – Environment with all of the options.

Returns:

Obtained title and URL.

class textoutpc.builtin.nodes.VideoNode(*, url: HttpUrl, format: Literal['normal', 'tiny'] = 'normal', width: int | None = None)#

Bases: BlockNode

Video node.

YOUTUBE_VIDEO_PATTERN: ClassVar[re.Pattern] = re.compile('^/?([a-zA-Z0-9_-]+)$')#

Pattern for matching youtu.be paths and extracting the video.

GFYCAT_PATH_PATTERN: ClassVar[re.Pattern] = re.compile('^(.*)-mobile(\\.(?:mp4|webm))$')#

Pattern for matching thumbs.gfycat.com paths.

url: HttpUrl#

URL to the video.

format: Literal['normal', 'tiny']#

Format, that determines the dimensions of the final player.

width: int | None#

Explicit width, if defined.

render_html(env: NodeHTMLRenderEnvironment, /) str#

Render the node as HTML.

Parameters:

env – Environment with all of the options.

Returns:

Rendered HTML version of the node.