Skip to content

API Reference

utils

Functions:

  • find_next_letter

    Find the next letter after a placeholder in a string.

  • format_str

    Format a string by removing HTML tags, sprite presets, and ruby tags, and replacing pronouns.

  • remove_ruby_tags

    Remove ruby tags ({RUBY_B...} and {RUBY_E#}) from a string.

  • replace_placeholders

    Replace placeholders in a string with values from parameters.

  • replace_pronouns

    Replace gendered pronouns in the format {F#female}/{M#male} with a combined format.

find_next_letter

find_next_letter(text: str, placeholder: str) -> str

Find the next letter after a placeholder in a string.

Parameters:

  • text

    (str) –

    The string to search within.

  • placeholder

    (str) –

    The placeholder string to find.

Returns:

  • str

    The character immediately following the placeholder.

format_str

format_str(text: str) -> str

Format a string by removing HTML tags, sprite presets, and ruby tags, and replacing pronouns.

Parameters:

  • text

    (str) –

    The input string to format.

Returns:

  • str

    The formatted string.

remove_ruby_tags

remove_ruby_tags(text: str) -> str

Remove ruby tags ({RUBY_B...} and {RUBY_E#}) from a string.

Parameters:

  • text

    (str) –

    The input string containing ruby tags.

Returns:

  • str

    The string with ruby tags removed.

replace_placeholders

replace_placeholders(string: str, params: dict[str, list[float | int]] | list[int] | None) -> str

Replace placeholders in a string with values from parameters.

Handle both list-based and dictionary-based parameters. Multiply values by 100 if the character following the placeholder is '%'.

Parameters:

  • string

    (str) –

    The string containing placeholders.

  • params

    (dict[str, list[float | int]] | list[int] | None) –

    A dictionary or list of parameters to substitute.

Returns:

  • str

    The string with placeholders replaced by values.

replace_pronouns

replace_pronouns(text: str) -> str

Replace gendered pronouns in the format {F#female}/{M#male} with a combined format.

Example

"{F#She}/{M#He} is here." -> "She/He is here."

Parameters:

  • text

    (str) –

    The input string containing pronouns.

Returns:

  • str

    The string with pronouns replaced.