Answered by:
Extra blank lines when posting a single-line code

Question
-
See my post here:
While in the editor, it looked OK. Upon saving, blank lines appeared.
Kalman Toth Database & OLAP Architect SQL Server 2014 Design & Programming
New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012
Answers
-
I've played around with this for a while. If you'd rather post code without the minimum height, you can remove the prettyprint class from the pre tag (you lose highlighting, but it's not great anyway). You'll need to surround the code with <hr style="width:100%">s to distinguish that you're posting code and you should adjust the font that you use for the code.
I'm stealing this method from Bill Stewart. I think that this is too much typing to get away from prettyprint personally, but now you've got a method you can use if you really want to. Here's an example, take a look at the page source to see what the tags look like:
Get-ADUser -Filter *
EDIT: Want to see some more fun you can have with prettyprint?
Don't retire TechNet! - (Don't give up yet - 13,085+ strong and growing)
- Edited by Mike Laughlin Friday, August 29, 2014 3:25 AM
- Proposed as answer by Dave PatrickMVP Saturday, September 20, 2014 10:40 PM
- Marked as answer by Ed Price - MSFTMicrosoft employee Thursday, November 20, 2014 8:47 PM
All replies
-
Hi Kalman,
The codeblock has a minimum height. I usually go into the html and add a <br /> tag to move the single line of code into the middle. I picked up that trick from one of derosnec's accounts, but I can't properly quote it and give credit where credit is due since I can't remember which account it was posted from (and I bet the post was deleted...).
Example:
Get-ADUser -Filter *
EDIT: Also, I should mention that the minimum height of the codeblock is by design. I think this changed about a month before or after the UI redesign, if I remember correctly.
Don't retire TechNet! - (Don't give up yet - 13,085+ strong and growing)
- Edited by Mike Laughlin Thursday, August 28, 2014 8:41 PM
- Proposed as answer by Just Karl Thursday, August 28, 2014 10:03 PM
- Unproposed as answer by Kalman Toth Friday, August 29, 2014 1:01 AM
-
Nonetheless it looks good in the Editor - a single line with borders.
It can't be by design to look different in the post and the editor, can it?
Kalman Toth Database & OLAP Architect SQL Server 2014 Design & Programming
New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012
- Edited by Kalman Toth Thursday, August 28, 2014 11:07 PM
-
Nonetheless it looks good in the Editor - a single line with borders.
It can't be by design to look different in the post and the editor, can it?
Don't retire TechNet! - (Don't give up yet - 13,085+ strong and growing)
-
I've played around with this for a while. If you'd rather post code without the minimum height, you can remove the prettyprint class from the pre tag (you lose highlighting, but it's not great anyway). You'll need to surround the code with <hr style="width:100%">s to distinguish that you're posting code and you should adjust the font that you use for the code.
I'm stealing this method from Bill Stewart. I think that this is too much typing to get away from prettyprint personally, but now you've got a method you can use if you really want to. Here's an example, take a look at the page source to see what the tags look like:
Get-ADUser -Filter *
EDIT: Want to see some more fun you can have with prettyprint?
Don't retire TechNet! - (Don't give up yet - 13,085+ strong and growing)
- Edited by Mike Laughlin Friday, August 29, 2014 3:25 AM
- Proposed as answer by Dave PatrickMVP Saturday, September 20, 2014 10:40 PM
- Marked as answer by Ed Price - MSFTMicrosoft employee Thursday, November 20, 2014 8:47 PM