--- hide: - navigation --- # Preprocessor (Preprocessor) The **Preprocessor** can format text. ## Tags *(these can be used in log messages too!)* All tags can be escaped by adding `esc_` before the tag name. Example: ```text Raw: Output: ``` ### No process `` - end tag `no` - description `Disables preprocessing completely. Doesn't even display the prefix.` - example: ``` text Raw: This is atest MESSage. Output: This is atest MESSage. ``` ### Newline `` - end tag `no` - description `Makes a newline while respecting the prefix. Is much recommended over "\n".` - example (with prefix `prefix_`): ``` text Raw: Very nice message!Here's another message :) Output: prefix_Very nice message! Here's another message :) ``` ### Lowercase `` - end tag `yes` - description `Makes your text lowercase.` - example: ``` text Raw: Did you FiNd THAT funny? Output: Did you find thaT funny? ``` ### Uppercase `` - end tag `yes` - description `Makes your text uppercase.` - example: ``` text Raw: ThiS TeXT should be UPPercaSED Output: ThiS TeXT SHOULD BE UPPERcaSED ``` ### Camelcase `` - end tag `yes` - description `Makes your text camelcase.` - example: ``` text Raw: This text should be CamelCased. Output: This textShouldBeCamelCased. ``` ### Pascalcase `` - end tag `yes` - description `Makes your text pascalcase.` - example: ``` text Raw: This text should be PascelCased. Output: This TextShouldBePascelCased. ``` ### Snakecase `` - end tag `yes` - description `Makes your text snakecase.` - example: ``` text Raw: This text should be SnakeCased. Output: This text_should_be_snake_cased. ``` ## Variables ### enabled - type `bool` - default value `true` - description `Enables or disables the preprocessor.` ### verbose_logging - type `bool` - default value `false` - description `Makes the log unreadable. Adds about twenty lines to every process() call.` ### tests_enabled - type `bool` - default value `true` - description `Enables or disables preprocessor testing. Recommended to leave enabled as it disables the preprocessor if it's malfunctioning (somehow). Better to have unformatted text than broken text.` ### tests_level - type `int` - default value `1` - description `Controls when test results are displayed. 0 = Never, 1 = On failure, 2 = Always` ## Methods ### do_tests() - returns `void` - description `Performs tests on all preprocessor functions. Very useful for catching bugs while debugging and/or modifying the preprocessor.` - argument `ignore_flag` - type `bool` - mandatory `no, default value is false` - description `ignores the "tests_enabled" variable if set to true` ### process() - returns `String` - description `Formats a message` - argument `msg` - type `String` - mandatory `yes` - description `The message used for processing` - argument `prefix` - type `String` - mandatory `yes` - description `The prefix used for newlines` - argument `pre_msg` - type `String` - mandatory `no, default value is ""` - description `Inserted before the message` - argument `post_msg` - type `String` - mandatory `no, default value is ""` - description `Inserted after the message` - argument `exclusion_filter` - type `Array` - mandatory `no, default value is []` - description `Removes specific Strings from the prefix (used in calculating spaces in _newline())` ## Internal variables Do not touch these or you will cause breakage. ### tests_executed - type `bool` - default value `false` - description `If tests have been executed already or not.` ### tests_log - type `String` - default value `""` - description `The latest preprocessor testing log.` ### tests_success - type `int` - default value `0` - description `The testing success count. If the value is 12, testing succeeded. If not, something is broken.` ## Internal Methods Do not execute these or you will cause breakage. ### _ready() - returns `void` - description `Executes do_tests() and imports logger.` ### _newline() - returns `String` - description `Processes the tag` - argument `msg` - type `String` - mandatory `yes` - description `The message used for processing the tag` - argument `prefix` - type `String` - mandatory `yes` - description `The prefix used for newlines` - argument `pre_msg` - type `String` - mandatory `yes` - description `Inserted before the message` - argument `post_msg` - type `String` - mandatory `yes` - description `Inserted after the message` - argument `exclusion_filter` - type `Array` - mandatory `yes` - description `Removes specific Strings from the prefix (used in calculating spaces)` ### _case_lower() - returns `String` - description `Processes the tags` - argument `msg` - type `String` - mandatory `yes` - description `The message used for processing the tags` ### _case_upper() - returns `String` - description `Processes the tags` - argument `msg` - type `String` - mandatory `yes` - description `The message used for processing the tags` ### _case_camelcase() - returns `String` - description `Processes the tags` - argument `msg` - type `String` - mandatory `yes` - description `The message used for processing the tags` ### _case_pascalcase() - returns `String` - description `Processes the tags` - argument `msg` - type `String` - mandatory `yes` - description `The message used for processing the tags` ### _case_snakecase() - returns `String` - description `Processes the tags` - argument `msg` - type `String` - mandatory `yes` - description `The message used for processing the tags` ### _case() - returns `String` - description `Executes all _case_* functions` - argument `msg` - type `String` - mandatory `yes` - description `The messages passed to all other _case_* functions` ### _escapes() - returns `String` - description `It escapes tags` - argument `msg` - type `String` - mandatory `yes` - description `The message used for processing the tags` ### _noprocess() - returns `bool` - description `Checks if the "msg" variable contains ""` - argument `msg` - type `String` - mandatory `yes` - description `The message used for searching ""`