I am trying to paste a piece of code in my Google+ stream but it removes the white space from the start of the lines making the code less appealing, aesthetically speaking. Basically, the functionality that I'm after is the "Code Sample" button of the WYSIWYG editor that I'm writing on right now.
5 Answers
You could add the code to something like Pastebin;
and then share it as a link.
Hope this helps.
Em space works!
I've finally cracked this indentation issue in Google+. I use em space and Google+ doesn't simply remove/replace it. It stays there.
The only problem is how do you type it out? Its Unicode code is U+2003
but there's not any keyboard shortcut... How I used it is:
- Open Character Map.
- Change options to display By Unicode Block.
- Select General Punctuation Unicode Block.
- Starting characters starts with seemingly empty boxes, because they represent all kinds of different space characters, then continue with various dashes.
- Click on the first empty box and move to the next until you get to em space (look for description in status bar).
- Click Copy.
Then you can simply go and edit your Google+ post and paste it as many times as you need to indent your code.
Following is the screenshot for the Character Map program with em space selected:
This procedure seems complicated, but it's not really. These are few fast and easy steps. It's also true that you most likely don't put code in all of your posts anyway.
Here's a link to Google+ post that also includes some indented code.
Google+ doesn't offer many formatting options. At best it offers a very watered down version of Markdown, with only bold, italic, and strikethrough.
So unless and until Google adds more options you're out of luck.
The only other possible option would be to create a GIF with the text of your code and include that in your post.
Google have apparently recently made a change to Google+ whereby the spaces at the beginning and/or end of a line for both posts and comments is retained rather than discarded, which was the previous behavior.
I just tested it and it works.
I use ⠂
to specify indent:
function factorial(x) {
⠂var result = 1;
⠂while(x > 1) {
⠂⠂result *= x;
⠂⠂x--;
⠂}
⠂return result;
}