Facebook bot messages not showing blank lines - facebook

I have created a chat bot using Microsoft bot framework and deployed it on Azure and linked it with my Facebook page. Everything is working fine but has a minor issue that, One of the messages send by the bot has a combination of 2-3 different lines, I want to show those 3 lines separated by blank lines so I have added escape sequence "\n\n" between the lines.
"Line1\n\nLine2\n\nLine3"
This works fine when I testes it in Azure web chat but Facebook chat window don't display the blank lines, Can any one help me with this?Thanks in Advance.
Currently face Display message like
Line1
Line2
Line3
I want to show it as
Line 1
Line 2
Line 3

Your message text is being run through a rather aggressive Markdown parser that's stripping away extra line breaks. You have a few options for how to deal with this.
Option 1
If you set the text as channel data instead of the actual activity text, it won't be run through the Markdown parser:
var text = "Line1\n\nLine2\n\nLine3";
var activity = turnContext.Activity.CreateReply();
activity.ChannelData = new { text };
await turnContext.SendActivityAsync(activity);
Option 2
If you set the text format to plain, the text won't be run through the Markdown parser:
var text = "Line1\n\nLine2\n\nLine3";
var activity = turnContext.Activity.CreateReply(text);
activity.TextFormat = TextFormatTypes.Plain;
await turnContext.SendActivityAsync(activity);
Option 3
If you're using channel data for something else and you don't want to set the text format to plain, you can always use <br/> instead of \n:
var text = "Line1<br/><br/>Line2<br/><br/>Line3";

Related

TextEditor multi-line display on website losing newlines

When i save data entered from a TextEditor on my IOS app and then preview that text on website version it doesn't display the newline and consider the whole description as a single line text.
my qustion is : how to display the same description with multiline on the website exactly as shown on the the iphone app using TextEditor ?
after some Research i've found this solution :
let descriptionInputHtmlForm = descriptionInput(of: "\n", with: "<br>", options: .literal, range: nil)
Before sending the entered input to the Database we do some modifications by replacing the \n with br inside <> in this way the html will detect new line break

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>";

String output to MS-WORD has too many new lines

This is my program window... The box in questions is the one labeled "INVESTIGATION" and "DISPOSITION".
When text is entered into the multiline textbox it is output in the DOCX file and it adds extra new lines... If a line is entered right below the original line it is a single extra new line. If it is spaced by one line it adds in two new lines. I figure it is something with the textbox properties or the output argument not playing well with the string. I have included pictures of the Form as it looks to the user. The builder code. The word document which shows the problem and the textbox properties. I want new lines in the investigation and disposition textbox to display how they are in the GUI and not have the extra new line. Any pointers?
I cant post images yet but you can view the images at the DOCX discussion board here https://docx.codeplex.com/discussions/658603
I hope its clear that I want it to display just as it is in the GUI:
A
A
A
should not look like it does in the last image where it is:
A
A
A
Thanks for all the help!

tinymce removes line breaks so all text is in a continuous chunk with no paragraphs

I'm using TinyMce textarea editor and have a problem. As you probably know Tinymce transforms a standard html textarea into a rich text editor.
On our 'edit listing' page we call up some text from our db for the user to edit (previously in a standard textarea, now in the tinymce textarea.
Previously the standard textarea would preserve linebreaks and the user would get several paragraphs of text in the text area, now with tinyMCE they get a huge chunk of text with no linebreaks. (I have pasted an example of an entry in our db below - as you can see it has line breaks in it by tinymce seems to be ignoring them when it displays them in the editor).
Just to clarify my issue is now that tinymce is stripping something when I submit the form, it's that when I pull text (that contains line breaks) from the db and populate the tinymce textarea with that data (for the user to edit) in the tinymce textarea - the text appears (in the tinymce textarea) as one massive chunk of text with my paragraphs (whereas in a standard textarea it is nicely formatted with linebreaks)
Any help on how to resolve this would be greatly appreciated - do I need to use some sort of populate() type function to put the text in, or maybe I need to replace all the linebreaks with a different special character that tinyMCE will recognise as a line break and preserve?..
Thanks in advance.
Nick
example from db:
Here is line one
Here is line two
And here is line three
Which appears in tinymce as:
Here is line one Here is line two And here is line three
I faced a similar a problem, a while back and had questions just like yours. Also I finally ended up on SE just like you.
Anyway, I think I have the solution to your problem. If you are using PHP as your server side language, then you should use nl2br() PHP function.
Suppose you have stored your content fetched from the database in a php variable. Something like this:
$content = $row['content'];
Now when displaying it on to your screen, use the nl2br() function.
echo nl2br("<p>".$content."<p>");
Now, this part inside () depends on how you want to output the data. And I will leave it to you to figure that part out.
Hope this helps.

UITextView Ignores Line Breaks When The Text Comes From Web Service

I'm using a SOAP service in my iPhone application and getting some text values from my remote database. In this text values, I intend to use \n for line breaks. But when I set the text of my UITextView to this value, it simply ignores the line breaks and shows them in single line.
If I declare its text in my code like myTextView.text = #"Break\me"; it works great. But when I call the text from service, it doesn't work.
How can I solve this?