Skip to main content

BBCodeRendererForReview

ClassSource

BBCodeRendererForReview(
configs: BBCodeConfig | None = None,
is_quote_converted: bool = False,
is_codeblock_converted: bool = False,
is_h_converted: bool = True,
)

The BBCode renderer specialized for rendering reviews.

This renderer variant will specialize the format when rendering:

  • tables

and provide optional options for rendering:

  • quote
  • code
  • h2/h3...

These features are particularly optimized for the best format when writing Steam Reviews, with all incorrect features replaced by other available features.

Arguments​

Requires​

NameTypeRequired
Description
configsBBCodeConfig | None

The configurations used for customizing the BBCode tags.

If not specified, will use BBCodeConfig() by default.

is_quote_convertedbool

A flag that enabling the optional feature of converting the format of quote blocks. If enabled, will render the quotes in the following format:

[quote][u]...[/u][/quote]
is_codeblock_convertedbool

A flag that enabling the optional feature of converting the format of code blocks. If enabled, will render the codes as texts like this:

> line 1> line 2> ...
is_h_convertedboolA flag that enabling the optional feature of converting the section heads. If enabled, will make all h tags formatted as the h1 tag.

Methods​

render_code_block​

v_1: str = self.render_code_block(node: CodeBlockNode)

Specific renderring. Render the block code as

> ...
> ...
> ...

Requires​

NameTypeRequired
Description
nodeCodeBlockNodeThe code block to be rendered.

Returns​

NameType
Description
v_1strThe rendered code block.

render_heading​

v_1: str = self.render_heading(node: HeadingNode)

Specific renderring. Render the heading (title).

Requires​

NameTypeRequired
Description
nodeHeadingNodeThe data to be rendered.

Returns​

NameType
Description
v_1strThe formatted heading/title.

render_list​

v_1: str = self.render_list(node: ListNode)

Specific rendering. Render the ordered or unordered list.

Requires​

NameTypeRequired
Description
nodeListNodeThe list to be rendered.

Returns​

NameType
Description
v_1strThe rendered list bbcode.

render_quote​

v_1: str = self.render_quote(node: QuoteNode)

Specific renderring. Render the quote block.

Requires​

NameTypeRequired
Description
nodeQuoteNodeThe data to be rendered.

Returns​

NameType
Description
v_1strThe formatted quote block.

render_table​

v_1: str = self.render_table(node: TableNode)

Specific renderring. Render the table.

This overriden table rendering will convert a table to the following list:

[list]
[*] [b]Header[/b] | [b]Header[/b]

[*] Cell | Cell
[/list]

When the list needs to be replaced by the ordered list, use the following configs:

configs.table = "ordered"

Requires​

NameTypeRequired
Description
nodeTableNodeThe table to be rendered.

Returns​

NameType
Description
v_1strThe rendered table bbcode.