CORE/docs/references/Preprocessor.md

97 lines
2.6 KiB
Markdown
Raw Normal View History

---
hide:
- navigation
---
# Preprocessor (/root/CORE/Preprocessor)
The **Preprocessor** parses tags and is responsible for formatting text.
## Tags *(these can be used in log messages too!)*
All tags can be escaped by adding `esc_` before the tag name, if you want to do that. Example:
```text
Raw: <esc_up><esc_np></esc_lo>
Output: <up><np></lo>
```
### No process `<np>`
- end tag `no`
- description `Disables preprocessing completely. Doesn't even display the prefix.`
- example:
``` text
Raw: <up>This is a</up><pa>test</pa><np> MESS<lo>age</lo>.
Output: <up>This is a</up><pa>test</pa> MESS<lo>age</lo>.
```
### Newline `<nl>`
- 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!<nl>Here's another message :)
Output:
prefix_Very nice message!
Here's another message :)
```
### Lowercase `<lo></lo>`
- end tag `yes`
- description `Makes your text lowercase.`
- example:
``` text
Raw: Did <lo>you FiNd THA</lo>T funny?
Output: Did you find thaT funny?
```
### Uppercase `<up></up>`
- end tag `yes`
- description `Makes your text uppercase.`
- example:
``` text
Raw: ThiS Te<up>XT should be UPPer</up>caSED
Output: ThiS TeXT SHOULD BE UPPERcaSED
```
### Camelcase `<ca></ca>`
- end tag `yes`
- description `Makes your text camelcase.`
- example:
``` text
Raw: This <ca>text should be CamelCa</ca>sed.
Output: This textShouldBeCamelCased.
```
### Pascalcase `<pa></pa>`
- end tag `yes`
- description `Makes your text pascalcase.`
- example:
``` text
Raw: This <pa>text should be PascelCa</pa>sed.
Output: This TextShouldBePascelCased.
```
### Snakecase `<sn></sn>`
- end tag `yes`
- description `Makes your text snakecase.`
- example:
``` text
Raw: This <sn>text should be SnakeCa</sn>sed.
Output: This text_should_be_snake_cased.
```
## Methods
### 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 when using <nl>)`