Using the cloud version, css not available, is there a way to do it via Formula?
Need color or bold folder names in the Knowledge Base - can we through Formula?
Collapse
X
-
Tags: None
-
Maybe you'll be satisfied with just coding in utf-8. PHP function prototype (grok-3 version):
Here's an explanation in English of the PHP function that converts a string to bold display using UTF-8 character replacement:
```php
function toBold($text) {
// Define two sets of characters:
// 1. Normal ASCII characters (letters and numbers)
$normal = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvw xyz0123456789';
// 2. Corresponding bold Unicode mathematical alphabet characters
$bold = '????????????????????????????????????????????????? ?????????????';
$result = '';
// Iterate through each character in the input string
for ($i = 0; $i < mb_strlen($text); $i++) {
// Get single character from the string
$char = mb_substr($text, $i, 1);
// Find position of character in normal set
$pos = mb_strpos($normal, $char);
if ($pos !== false) {
// If found, replace with corresponding bold character
$result .= mb_substr($bold, $pos, 1);
} else {
// If not found (e.g., spaces, punctuation), keep original character
$result .= $char;
}
}
return $result;
}
```
How it works:
1. **Character Sets**:
- `$normal` contains standard ASCII letters (A-Z, a-z) and numbers (0-9)
- `$bold` contains the corresponding Unicode bold mathematical symbols
2. **Processing**:
- The function loops through each character in the input string
- For each character, it checks if it exists in the `$normal` set
- If found, it replaces it with the matching bold character from `$bold`
- If not found (like spaces or punctuation), it keeps the original character
3. **Multibyte Support**:
- Uses `mb_*` functions to properly handle UTF-8 multi-byte characters
Example Usage:
```php
echo toBold("Hello World 123"); // Outputs: ????? ????? ???
echo toBold("Test 123"); // Outputs: ???? ???
echo toBold("PHP 8.0"); // Outputs: ??? ?.?
```
Key Features:
- Supports Latin alphabet (both uppercase and lowercase) and numerals
- Preserves non-convertible characters (spaces, punctuation, etc.)
- Works with UTF-8 encoding
If you need support for additional character sets (like Cyrillic), the function can be extended by adding the appropriate Unicode bold characters to the `$normal` and `$bold` strings. -
After 4 iterations (grok-3) formula script version:
Code:$normal = list('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'); $bold = list('?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?'); $input = string; // Входная строка, например, поле 'string' $len = string\length($input); $output = ''; // Инициализация результирующей строки $i = 0; while( $i < $len, ( $char = string\substring($input, $i, 1); $index = array\findIndex($normal, $char); $boldChar = ifThenElse( $index > 0, array\at($bold, $index), $char ); $output = string\concatenate($output, $boldChar); $i = $i + 1; ) );
Last edited by dimyy; Yesterday, 08:08 AM.Comment
Comment