TYPOSCRIPT stdWrap.replacement I Want to replace space with underscore _ - typo3

My typo3 version is 10.4.22
lib.spaces = TEXT
lib.spaces {
current = 1
stdWrap.replacement {
10 {
search =
replace = _
wrap = |
}
}
}
I have a following typoscript. And now my question is, what i have to write in search = ?
so that space is being searched and replace with underscore.
SORRY For my bad english!

replacement.search has stdWrap, so you can use char. The ascii code for space is 32, so that will make it:
lib.spaces = TEXT
lib.spaces {
current = 1
stdWrap.replacement {
10 {
search.char = 32
replace = _
wrap = |
}
}
}

Related

Getting substring of a string in flutter that contain and emoji can cause a render failure

As part of the app I am shortening a user-given string to 40 characters and appending ellipses at the end if the string is longer than 40 characters. The users are allowed/able to use emoji in their strings.
If a string that is cut off has an emoji at the 40-character mark it causes it to fail to render and renders as a "�".
Is there a way to reliably get a sub-string of a text but without running into this issue?
Current code:
if (useStr.length > 40) {
useStr = useStr.substring(0, 40) + "...";
}
You should use package:characters and truncate strings based on graphemes (human-perceived characters) and not on (UTF-16) code units.
import 'package:characters/characters.dart';
void main() {
final originalString = '\u{1F336}\uFE0F' * 3; // 🌶️🌶️🌶️
const ellipsis = '\u2026';
for (var i = 1; i < 4; i += 1) {
var s = originalString;
var characters = s.chararacters;
if (characters.length > i) {
s = '${characters.take(i)}$ellipsis';
}
print(s);
}
}
which prints:
🌶️…
🌶️🌶️…
🌶️🌶️🌶️

Limit Text to number of lines 3

I have to show some text in UILabel and append read more if the text goes beyond 3 number of lines. It works fine if I set number of lines = 3 and trim the text to 120 characters or so. But if the text contains newline character then this fails.
How to handle this.
func formatText() -> String {
var formatString = self.review_description
var maxLimit = 140
if self.review_link != nil {
maxLimit = 120
}
if formatString.count > maxLimit {
let substring = formatString.dropLast(formatString.count - maxLimit)
formatString = String(substring) + "... " + AppConstants.readMoreText
}
if self.review_link != nil {
formatString = formatString + " \(AppConstants.reviewSourceText)"
}
return formatString
}
try this
make your number of lines for label as 0. because new line won't increase your char count at all

Javascript First letter uppercase restlower of two lines "."

I want to first letter to be in upper case other in lower. But after ".", it must be upper again..
function firstToUpperCase( str ) {
return str.substr(0, 1).toUpperCase() + str.substr(1);
}
var str = 'prompt("Enter text to convert: ")
var Upcase = firstToUpperCase( str );
document.write(Upcase);
Here's a simplistic answer based on what you provided. It does not take whitespace into account following the period since you didn't mention that in the specs.
function firstToUpperCase(str) {
var parts = str.split(".");
for (i = 0; i < parts.length; i++) {
parts[i] = parts[i].substring(0, 1).toUpperCase() + parts[i].substring(1).toLowerCase();
}
return parts.join(".");
}
If you're trying to deal with sentences, something like this might be a little better, though it does not preserve exact whitespace:
function firstToUpperCase(str) {
var parts = str.split(".");
for (i = 0; i < parts.length; i++) {
sentence = parts[i].trim();
parts[i] = sentence.substring(0, 1).toUpperCase() + sentence.substring(1).toLowerCase();
}
return parts.join(". ");

CTRL+V unformatted on Tinymce

I am trying to copy html text and paste it into an unformatted way in TinyMCE by simply using CTRL + C, CTRL + V.
I have had a hard time to do this as TinyMCE constantly tries to keep the initial formatting. I am using Rails.
Would you know any work around this?
You may configure tinymce to strip all unwanted tags when pasting.
To do this use the tinymce config param paste_preprocess:
paste_preprocess : function(pl, o) {
o.content = window.strip_tags( o.content,'<p><div><ul><ol><li><br>' );
},
with the function strip_tags as follows:
// Strips HTML and PHP tags from a string
// returns 1: 'Kevin <b>van</b> <i>Zonneveld</i>'
// example 2: strip_tags('<p>Kevin <img src="someimage.png" onmouseover="someFunction()">van <i>Zonneveld</i></p>', '<p>');
// returns 2: '<p>Kevin van Zonneveld</p>'
// example 3: strip_tags("<a href='http://kevin.vanzonneveld.net'>Kevin van Zonneveld</a>", "<a>");
// returns 3: '<a href='http://kevin.vanzonneveld.net'>Kevin van Zonneveld</a>'
// example 4: strip_tags('1 < 5 5 > 1');
// returns 4: '1 < 5 5 > 1'
function strip_tags (str, allowed_tags)
{
var key = '', allowed = false;
var matches = []; var allowed_array = [];
var allowed_tag = '';
var i = 0;
var k = '';
var html = '';
var replacer = function (search, replace, str) {
return str.split(search).join(replace);
};
// Build allowes tags associative array
if (allowed_tags) {
allowed_array = allowed_tags.match(/([a-zA-Z0-9]+)/gi);
}
str += '';
// Match tags
matches = str.match(/(<\/?[\S][^>]*>)/gi);
// Go through all HTML tags
for (key in matches) {
if (isNaN(key)) {
// IE7 Hack
continue;
}
// Save HTML tag
html = matches[key].toString();
// Is tag not in allowed list? Remove from str!
allowed = false;
// Go through all allowed tags
for (k in allowed_array) { // Init
allowed_tag = allowed_array[k];
i = -1;
if (i != 0) { i = html.toLowerCase().indexOf('<'+allowed_tag+'>');}
if (i != 0) { i = html.toLowerCase().indexOf('<'+allowed_tag+' ');}
if (i != 0) { i = html.toLowerCase().indexOf('</'+allowed_tag) ;}
// Determine
if (i == 0) { allowed = true;
break;
}
}
if (!allowed) {
str = replacer(html, "", str); // Custom replace. No regexing
}
}
return str;
}
You may want to have a closer look at this SO-Thread too: TinyMCE Paste As Plain Text

wrap a string in Typo3 only if not empty, and replace with message if empty

this is my typoscript:
nota = TEXT
nota.value = ###WFQBE_FIELD_nota###
nota.stdWrap {
required = 1
wrap = (|)
}
nota.ifEmpty = not available
I want to wrap the field nota in () only if not empty, if empty I want the message "not available" to appear.
This works, but the only problem is that the message gets wrapped in () too!!
Any idea? I'm a total newbe in Typoscript..
You can turn your condition around:
nota = TEXT
nota {
value = not available
override {
cObject = TEXT
cObject {
required = 1
value = ###WFQBE_FIELD_nota###
wrap = (|)
}
}
}
If I understood correctly, Your current problem is the "wrap".
As ifEmpty could be stdWrap too, try to override the wrap in ifEmpty condition.
nota = TEXT
nota.value = ###WFQBE_FIELD_nota###
nota.stdWrap {
required = 1
wrap = (|)
}
nota.ifEmpty.wrap = not available|