I'm writing a simple Facebook status update web app that uses Graph API. It works well except for when I'd like to include a line break in the status message. I've tried adding a simple HTML tag, but this is just rendered as text.
Anyone know if this is possible, and if so, how?
It sounds silly, but this works:
Insert <center></center> where you would normally put <br>.
\r\n seems to work just fine to get line breaks in facebook
If you're using PHP or any language just add chr(10) and this will add a break :)
ASCII Solution :P
Please observe the new line that is used in the below code (an enter is hit inside the editor), that serves the purpose of adding new line to a post at a specific location:
$fb_status_with_new_line = "Text before new line" . "
" . "Text after new line";
If you replace return characters (\r) with new line characters (\n) you can achieve the desired result.
Enjoy...
%0A might work, i think i used that on one of my apps before.
HTML Decimal:
HTML Hexadecimal:
Java Hexadecimal: \u000A (Common To Javascript)
URL Hexadecimal: %0A
Escape Sequence: \n
HTML tag : <br>
Hope these come in handy :)
As of Dec 2013, this works (break lines in code):
$facebook->api('/me/feed', 'post', array('message'=> 'Line 1
Line 2
Line 3
Line 4',
'cb' => ''));
I've tried <center></center> it didn't work.
I've tried <br> it didn't work.
I've tried with invisible html characters, it didn't work.
I've tried with '\n' it didn't work.
However when I used "\n" instead of '\n' it worked. But this was recognized directly by the php before it was uploaded to facebook. So my suggestion is using double quotes with string messages in facebook posts.
If you are using PHP, you can do like this:
$message = str_replace('\r\n', "\n", $message); // input is from textarea
$ret_obj = $facebook->api('/me/photos', 'POST', array(
'source' => '#' . $photo['file_source'],
'message' => $message)
);
Please use double quote "\n" instead '\n'
\n Worked Its smallest an easiest way to add line breaks
You need to add carriage return i.e \n\r because facebook accept only enter for new line.
\n works. You just need to add it to the message param
\n working I checked now on twitter.
$post = $connection->post('statuses/update', array('status' => "first line \n second line"));
Just do it like so, It will work for other social media also
I use the messenger API with PHP.
For me, the string '\n' is working.
Beware that this is not the newline character (aka "\n").
No, it's '\' followed by 'n', aka "plain antislash-N".
if You are using iOS mobile platform the \n will supports fine.. message = encodeURIComponent(message) .. bur for android nothing is working for me searching for me..
None of the solutions offered worked for me when trying to post a comment on Facebook using Chrome. The only solution I have found is to highlight text that has a linefeed, then paste in that text, then erase all of the paste except the linefeed.
In my case (in bash) newline works only with newline character $'\n', e.g.
echo "Message text"$'\n'"#kw"
Related
I expected to find answers to this on the web but have been unlucky so far.
I am producing an Access macro to send a query as an excel file by email. I am using emailDatabaseObject.
This offers me several fields all of which I have completed but the Message Text Field doesn't allow me a new line. I have tried enter, "..." & vbCrLf & "...", \vbCrLf, alt+10 alt+13, and other things none of which work.
At the moment I have:
Shane. \n \r Please find the latest list attached. Regards ...
Would like to have:
Shane.
Please find the latest list attached.
Regards ...
Does anyone know how to get a newline in a field like this? Please let me know if you can, thanks.
Scriptham
Have you tried using Chr(10)?
"Shane." & Chr(10) & Chr(10) & _
"Please find the latest list attached." & Chr(10) & Chr(10) & _
"Regards ..."
If Zaider's trick char(13) or char(10) doesn't work, I guess your output format is HTML, then you should use <br> :
Shane. <br> <br> Please find the latest list attached. <br><br>Regards ..
Which renders :
Shane. Please find the latest list attached.
Regards ..
The title of my column-chart contain a single quote. It's displayed like this: ' .
I have other specific characters, such as 'é', but they work perfectly.
I tried to URL-encode the text, without result.
Is there something I need to know about Google Visualization and single quotes?
Turns out I was wrong about the problem. I'm working in a Rails app, and I'm rendering my charts via Erb templates, with the title as a parameter.
Solution was to pass that parameter like this raw(title_string), so the single quote character is escaped. Issue was about Erb, not Google Chart.
WhiteHat comment helped me realise that, thanks :)
Appreciate this is an old question, but as I too have had this issue, with title and column values I pop in my solution.
If your title is
title: 'my title's great'
then you need to escape the ' in the title with a backslash \ . It becomes
title: 'my title\'s great'
If your title is
title: "my title's "great""
then you need to escape the " in the title with a backslash \ . It becomes
title: "my title's \"great\"".
What I have started to do is put \ before all specials. Some systems may need to you to use double backslash in your code for the single backslash to make it to the google chart.
I want to print a horizontal line to the console. At the moment, I use -----, but there are small spaces between the single characters.
Is there a better character I might use?
_ is not a viable option, as it is not vertically centered. Is there something like a middlescore, strikethrough (or whatever it's name is) character?
Hyphen ---------------------
Underscore _____________________
EM Dash —————————————————————
Horizontal Bar ―――――――――――――――――――――
Horizontal Box ─────────────────────
There is a big list of characters to try over at wikipedia.
The horizontal box drawing character is my recommendation. It is designed for this purpose
With bash, to display a horizontal rule the size of your window you can use:
printf %"$COLUMNS"s | tr " " "-"
With zsh, you could avoid the tr:
printf '—%.0s' {1..$COLUMNS}
NOTE: I know this is not what OP wants, but it is what I think someone from Google could be seeking.
Unicode character \u2500 solved it for me. According to Wikipedia it is for box drawings light horizontal, which is exactly what I need :-)
Thanks #Gusdor for pointing me to the correct Wikipedia article!
I believe that extended ASCII character #196 can serve your purpose:
See http://www.asciitable.com/
It seems like a vertically-centered non-gap line.
―/― is a horizontal bar character ―
Works for me in terminal.
If you're using Windows, open RUN, type charmap and hit enter.
There are a plenty of characters listed there with previews and names. I'm sure you'll find what you're looking for in charmap.
Update
If you're using a Linux Distribution, check this out.
if working on node js
const line = '#'.repeat(process.stdout.columns || 100);
console.log(line)
function and in Typescript
function consoleLine(mainChar:string, fallbackNum:number):string {
const line = (toRepeat:string) => toRepeat?.repeat(process.stdout?.columns || fallbackNum)
const mainLine = line(mainChar);
const emptyLine = line(' ');
return `${mainLine}\n${emptyLine}\n${mainLine}`;
};
console.log(consoleLine('#', 100));
print a dotted line the width of the console
print('-'*80)
I'm using tinymce on this page:
http://coachbrian.ca/CoachBrian4/admin/index.php?public=7&page=1
On that page the user can edit whatever text they want, which later gets viewed and displayed on this page:
http://coachbrian.ca/CoachBrian4/index.php?public=1
What's happening right now is that every time the user edits and saves whatever text they want, the next time they go in, there's a bunch of "rn"'s in the text.
I've used this in my PHP to try and clean them out:
$order = array("\r\n", "\n", "\r", "rn", "rnrn", "<p> </p>");
$replace = '';
// Processes \r\n's first so they aren't converted twice.
$formatOne = str_replace($order, $replace, $unformattedText);
And then I save the entry in the database. I also use the same code on the the 'display' page that the public would see, and for some reason the "rn"'s don't show, but there's extra carriage returns.
I've been banging my head for 2 days now looking for what is probably an obvious issue but I can't seem to find it.
Thanks in advance.
I recognize this is an old issue but I had the same problem but discovered I was using mysql_real_escape_string on the contents of tinymce twice. I removed the second occurrence of the escape and it is fixed.
In tinyMCE, Is there any way to get the plain text instead of HTML text?
Try this:
var myText = tinyMCE.activeEditor.selection.getContent({ format: 'text' });
var rawtext = tinyMCE.activeEditor.getBody().textContent;
I just tried this approach:
editor.getContent()
.replace(/<[^>]*>/ig, ' ')
.replace(/<\/[^>]*>/ig, ' ')
.replace(/ | /gi, ' ')
.replace(/\s+/ig, ' ')
.trim();
Replaces both opening and closing html tags with space
Replaces various known special characters with space (add yours as well)
Replaces multiple spaces with a single space
Worked reasonably well, but it is obviously not perfect. I need only an approximation of plain text for purposes of word counting, so I am willing to ignore corner cases such as having part of the word bold or italic (replacement above for <b>a</b><i>x</i> will produce two separate words a b instead of ab).
It is an extension of Regular expression to remove HTML tags from a string
Hope that helps.