How to remove white space in html using Tritium - moovweb

I'm using the Moovweb SDK and I'd like to remove excess white space from the beginning or end of any elements. It sometimes shows up as
or
and I want to remove it since it messes with my spacing. How can I get around doing this?
Thanks.

You can use regex to replace the leading and tailing whitespace with nothing.
Inside a tag, you can open up a text scope and use the replace(...) function to replace leading and trailing whitespace:
text() {
replace(/^\s+|\s+$/, "")
}
Here's a working example in play.tritium.io:
http://play.tritium.io/648c6b2f72266b7b7db308e14dcb85f71707f4ee

text(" I'm an example ")
text() {
trim()
}
can also be used to remove white spaces

Related

New line on UILabel messes with the word wrapping [duplicate]

Under certain circumstances, UILabel seems to bring an extra word to new line even when there is enough space for it, for example,
If one more word is appended,
Even if I force the width of the label to become something like below, it still moves the word consists of "c"s to the next line,
I've tried twisting the configuration of the UILabel, but seems it behaves the same unless I set the line breaking mode to character wrap, below is the configuration for the above cases,
And the constraints (in the first two cases, the trailing ),
Is there any reason for this particular behaviour and can I fix this? It looks weird in this way leaving that space emptied.
this is the default behavior since iOS 11, to fix orphaned words. No way to shut it off
to fix it
use the text as attributed text
or
use UItextview and turn of the scroll, edit option
or
use the custom label here
Get each line of text in a UILabel
You should set the line break to character wrap, because the letters after the space will be recognized as a word.
Hey I know this is late but I just figured out that you can cheat the system by adding a bunch of spaces at the end of the text.
If text of UILable may be changed, then it's still possible to use quick-dirty hack with "\n" - new line symbol.
Text "Aaaaaaaaaaaaaa bbb cccccccccc\ndddddd" will force UILabel to display:
Aaaaaaaaaaaaaa bbb cccccccccc
ddddddd
In Interface Builder new line can be inputted with Ctrl + Enter
If u use wordWrap, it tries to keep words in full form, as a result of this, it goes to next line. If you use character wrap, it will break on characters, and push the chars onto next line.
For Example:-
My name is ABCXXXX and I (have space here)
love myself.
Solution:-
Use NSMutableAttributedText and write love\n. It will make the "love" be in the space myself in the next line.

How to add a small straight line (I mean like this: a̅ b̅ X̅) onto a character inside a string?

I want to add small straight line onto some desired characters/numbers inside a string inside textview. I couldn't find a solution. Maybe using NSMutableAttributedString. Meanwhile, I mean doing this programmatically. There is strikethrough style, but not overstrike style. Or maybe adding the letters "a" and "_" with different .baseline values. But how to add both characters onto each other then?
Is it possible?
EDIT: Due to make a try for the helpful answers below, I think to make the line at a spesific height is needed. "A\u{0305}" makes the up line very close to the character, as if it sticks. Is there a way to make it at specific height? For example, if we assume that all the keyboard-inputted characters are written inside every single boxes, the ceiling side of these boxes could be lined?
So this (note: see edit below) appears to be an "a tilde ogonek" (it's Lithuanian).
You can write it for instance as follows using these two Unicode characters:
let atildeogonek = "\u{0105}\u{0303}"
let title = "How to add a small straight line (I mean like this: \(atildeogonek)) onto a character inside a string?"
The first character is the a with an ogonek, the second one is the tilde.
EDIT: The initial question specifically asked about the character ą̃ ("a tilde ogonek") in the title, and I used this code to demonstrate how to use Unicode characters in a Swift string. After posting this answer, the question was edited to be more general about "a line above a character".
Programmatically, you could use a function like this:
func overline(character: Character) -> Character? {
return "\(character)\u{0305}".first
}
That will take a character as input and return a new character (glyph) that has had the Unicode combining overline character added to it. It will return nil if adding the combining overline character fails.
The code print(overline(character:"A")!), for example, returns "A̅"
Or, if you want to add an overline to every character in a string, you could use a function like this:
func overline(characters: String) -> [Character?] {
return Array(characters).map { return "\($0)\u{0305}".first
}
}
(I'm not sure if there are any characters for which the above will fail, so I'm not sure if force-unwrapping the result is safe. Thus I left the result of both functions to be optional Character/Array of Character.)
You can easily find the unicodes of ā or ą̃ by using the xcode's own Character Viewer. Just follow the following steps :
hit : Control + Command + SpaceBar
If you get a compact one like this, click the upper right corner icon to expand it.
When expanded, Click the settings gear in the corner . Select customize list.
select Enclosed Characters
Go down to the bottom and open Code tables then add Unicode.
Now, just search for your required Character and you can check its unicode value. here i am searching ā
to print unicode's value :
print("\u{0101}")

Hide certain characters in a text field in Flutter

I have a text field which I need to style for example with bold or italics parts.
I tried overridding the TextEditingController's buildTextSpan and formatting the text using annotation ranges with custom styles but the edge cases were too much and I really couldn't get it to work.
So, thought about using a formatter where before every change in format I'll add a custom character, like this:
This text is |bBOLD and this is |iITALICS. Would get me this:
This text is BOLD and this is ITALICS. So I override the buildTextSpan to build the TextSpan from a parse function where I split the text by the special characters and check the initial letter of each text for formatting info.
This works well except for the fact that when I press the right arrow to go the next character after the "This text is ", the cursor will stay fixed as it thinks there are two characters but being only for formatting, they aren't there on the render.
Is there any way I could tell the textfield to ignore certain characters when selecting, moving selection or typing?
I think this would work!
static const kCharToBEIgnored = 0x2C;
// Here 0x2C means ',' comma
// For complete list visit https://api.flutter.dev/flutter/charcode/charcode-library.html
String get text {
return String.fromCharCodes(
_value.text.codeUnits.where((ch) => ch != kCharToBEIgnored),
);
}

How to wrap text in Notepad++, but leave paragraph lines intact?

How can I wrap text in Notepad++, but leave paragraph lines intact?
Example:
The original text looks like this:
This
is
paragraph
one.
This
is
paragraph
two.
I would like the text to look like this:
This is paragraph one.
This is paragraph two.
But currently, when I go to Edit > Blank Operations > Remove Unnecessary Blank and EOL, the text ends up with no paragraph line in between, like this:
This is paragraph one. This is paragraph two.
How can I fix this?
Thank you.
You may try the following find and replace, in regex mode:
Find: ([^.\s])\r?\n
Replace: $1[ ]
Demo
The regex pattern ([^.\s])\r?\n will match and capture any letter which appears before a CR?LF character, so long as that character is not a full stop. It then replaces with that same character, followed by just a single space, thereby removing/replacing the original CR?LF.
This will replace every single linebreak with a space.
Ctrl+H
Find what: [^\r\n]+\K\R(?!\R)
Replace with: # a space
CHECK Wrap around
CHECK Regular expression
Replace all
Explanation:
[^\r\n]+ # 1 or more non linebreak
\K # forget them
\R # any kind of linebreak (i.e. \r, \n, \r\n)
(?!\R) # negative lookahead, make sure we haven't another linebreak after
Screenshot (before):
Screenshot (after):

Scratch equals operator problems

I am using scratch.mit.edu version 2.0 on the internet and writing a program to evaluate a postfix expression. As I iterate through the input string such as: "23+" (postfix) letter by letter using the letter..of...block, it works fine.
I then add a letter.. of.. block to identify a spacebar character so the user can insert blanks in the expression eg "2 3 +"
However, there seems no way to recognize a blank character. I tried
1) Lookahead = ""
2) Lookahead =' '
3) Lookahead =''
None of which pick up that a space has been encountered.
Here is the project: https://scratch.mit.edu/projects/77653712/
In Scratch, the box is the string literal - no quotes, unless you're looking for literal quotes. Just put a space in the box.
Just set it to check <(Lookahead) = [ ]>: (brackets are the symbol for the box)
(That black line is me pressing ctrl+a to highlight and show that it exists.)
OK, I have found the solution. There is no character to represent a blank. You simply press space bar once!
You can see the letter nextChar of blanks is an empty space but, you must add space using the spacebar for it to work!!