WKInterfaceLabel ignoring \n indicators - swift

I'm getting text from the MediaWiki API, and it includes getting \n text which indicates a new line. When I set the API results as the text of a WKInterfaceLabel, the \n's disappears, but no new line is created.
Any way to fix it?
Example. From this term:
[...] forms.\n\n==Use in writing systems==\n\n===English===\nIn Modern English [[English orthography|spelling]], {{angbr|i}} represents several different sounds, either the diphthong {{IPAc-en|aɪ}} ("long" {{angbr|i}}) as in ''kite'', the short [...]
It's meant to remove the \n's and replace it with new lines. What's added to the label is this text minus the \n's, but no new lines.

Related

Monaco editor: Replace short text with longer text

I want to use the additionalTextEdits of the autocomplete callback to replace some text.
In some cases, I want to replace a short text with a longer text and expect everything after the short text to get pushed further back.
Example:
Original: abde
Text to insert: ABC, startColumn: 1, endColumn: 3
Expected outcome: ABCde
Actual outcome: ABde
My suspicion is that the editor sees that I want to replace two characters and therefore only takes the first two characters of my provided text.
Is there a way to tell it to replace those two characters with the provided three characters and everything afterwards gets pushed one column back?
Here is the link to the documentation of the property that I use:
https://microsoft.github.io/monaco-editor/api/interfaces/monaco.languages.CompletionItem.html#additionalTextEdits

C# Word OpenXml SDK - Adding text to a run trims spaces

I'm trying to add text runs to an existing paragraph in Word using the OpenXml SDK, but every time I do this it ends up "trimming" the text which I add.
For example
Run newRun = newRun();
newRun.AppendChild(new Text("Hello "));
paragraph.AppendChild(newRun);
Run newRun = newRun();
newRun.AppendChild(new Text(" World"));
paragraph.AppendChild(newRun);
// the resulting paragraph contains "HelloWorld" as the text
I've also checked the XML of the resulting Run which gets generated, which clearly includes the "space" character:
<w:t xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\">Hello </w:t>
I've tried injecting '\u0020' unicode values, as well as an "empty" run which just contains a single space, but nothing seems to work.
Does anyone know the trick to this?
Rolling my eyes at how typical that I find the answer 5 minutes after posting (having been trying for hours)
The answer is to add the XML xml:space="preserve" attribute to the Text element, otherwise spaces are trimmed.
newRun.InnerXml = $"<w:t xml:space=\"preserve\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\">{text}</w:t>";

How to set width of text marks in vega-lite / altair (text wrapping and line break) for long text

I am trying to display text over time using altair (vega-lite), which works fine using a layered chart, where one is created using the alt.Chart().mark_text() function to display the text.
The text though is multiple phrases and should be wrapped (with line breaks). How can this be done?
(I do not want to use fixed line breaks, e.g. \n, at distinct positions since the text wrapping should work with zooming too)
Not exactly what you want, but you can specify a character on which to break to a new line. When zooming, the text stays the same size, so it should always fit the view.
For example making a new line for every word:
.mark_text(lineBreak=' ')

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.

To get the content of first two lines from UITextView without using next line object

I need to get the two lines of content from uitextview, but without using nextline.. I entered the text continuously on uitextview without press enter the line goes to second line automatically. when I print those text it is showing single line. But the content is two or more than two lines. How I can get that content from UITextView.
You need to count (roughly) number of characters that can be entered in a single line.
Then using modulo and division you can find number of lines the text consumed.