textoutpc.tags – Tag definitions#
- class textoutpc.tags.RawTag(*, name: str, value: str | None, parser: Parser)#
- Bases: - Tag- A tag for textoutpc’s BBCode, except always raw. - This means that the content for such tags must systematically be not interpreted, whatever the name and values are. 
- class textoutpc.tags.Tag(*, name: str, value: str | None, parser: Parser)#
- Bases: - ABC- A tag for textoutpc’s BBCode. - Note that the provided name may be surrounded by brackets if the tag is a normal tag, or not if it is a special tag such as “`”. - Parameters:
- name – The name of the tag. 
- value – The value of the content. 
- parser – Parser with which to parse subcontent, if relevant. 
 
 - CLOSE_IF_OPENED_WITHIN_ITSELF: ClassVar[bool] = False#
- Whether to close and re-open the tag, if opened within itself. - This is for tags such as - [li]not to have to be closed if placed within themselves, e.g.:- [list] [li]Bullet 1 [li]Bullet 2 [/list] 
 - classmethod get_text_from_children(children: Iterable[Node], /) → str#
- Get text from children. - This is mostly used in case the tag is raw, to obtain the contents. - Parameters:
- children – Children to extract text from. 
- Returns:
- Extracted text. 
 
 - name: str#
- Name of the tag. - This is surrounded by brackets in case of a normal tag, or the character directly if a special character has been used, e.g. backquotes. 
 - value: str | None#
- Value passed to the tag, e.g. - [tag=my_value].- Set to - Noneif no value has been passed, e.g.- [tag].
 - parser: Parser#
- Parser for which the tag has been instanciated. - This can be used to parse the value or any subcontent as BBCode as well. 
 - validate() → None#
- Validate the name and value for this tag. - Raises:
- TagValidationError – The name and value combination is invalid. 
 
 - is_raw() → bool#
- Return whether the content of this tag should be read as raw or not. - This will be called after the tag is initialized, but before the tag is used to populate a node, in order to read if what follows the tag is interpreted or not and whether we should look for an end tag or not. - This may take into account both the name and the value of the tag.