3

Why doesn't a code block preserve whitespace in this PowerShell script? In the editor (using 4 spaces for the code block, and more spaces to indent) this looks like:

Screen capture of code block in editor

But I am not seeing any indentation whatsoever in IE9 (and neither in IE10/Win8 CP):

Screen capture of Markdown code block in IE9

And here's what you're seeing:

$site = new-object Microsoft.SharePoint.SPSite($url)
$sitelists =  foreach ($web in $site.AllWebs) 
{
    if ($web -eq "Search")
    {
        Write-Host "Come in"    
    }
}

Frankly I've gone to using <pre></pre> tags which can't be the right the way to do this but at least the results are readable - for now:

Screen capture of pre formatted text in IE9

And again, here's what you're seeing:

$site = new-object Microsoft.SharePoint.SPSite($url)
$sitelists =  foreach ($web in $site.AllWebs) 
{
    if ($web -eq "Search")
    {
        Write-Host "Come in"    
    }
}
6
  • 2
    Don't use tabs...
    – user7116
    Commented Mar 31, 2012 at 22:20
  • 3
    OK, removed the tabs -replaced with 4 spaces and it still looks isn't preserving the indentation.
    – Keith Hill
    Commented Mar 31, 2012 at 22:50
  • FWIW the code in the tagged PowerShell questions/answers used to look right but then sometime 6-9 months ago they started formatting like crap er with no indentation. AFAICT this isn't a tab vs space problem. This issue is seriously affecting the readability of PowerShell script on this forum. So downvote this question all you want but there is a problem for us PowerShellers. I guess there's always social.technet.microsoft.com/Forums/en-US/winserverpowershell/…. The PowerShell script formatting seems to work pretty well there.
    – Keith Hill
    Commented Mar 31, 2012 at 22:55
  • Keith, what differences do you see? Your two code examples look identical to me (Chrome 17, Windows 7), and both look identical to the raw editor text. Commented Mar 31, 2012 at 22:56
  • @MichaelPetrotta - thanks for the constructive question. :-) I attached image that shows what I'm seeing in IE9/IE10.
    – Keith Hill
    Commented Mar 31, 2012 at 23:02
  • I'm think I know what's going on. A while back I had enable "Compatibility View" on IE9 because the text editor didn't work very well. It seems if I disable that feature, it renders correctly and at this point the text editor seems to be working fine. Sorry for the false alarm folks.
    – Keith Hill
    Commented Mar 31, 2012 at 23:11

1 Answer 1

8

If anybody else runs into this with Internet Explorer 9/10 make sure you don't have "Compatibility View" (the broken page icon in the address bar) enabled for the site:

Compatibility mode icon in IE

3
  • 2
    BTW, according to Microsoft: "If Internet Explorer recognizes that the webpage isn't compatible, you'll see the Compatibility View button on the Address bar." I wonder why SO isn't recognized as compatible?
    – Keith Hill
    Commented Mar 31, 2012 at 23:24
  • And anther oddity: the first screen capture does preserve the double spaces in = foreach.
    – Arjan
    Commented Apr 1, 2012 at 20:54
  • And what about Firefox 16.0.2 (win 7 x64)? It's the such problem too.
    – sergzach
    Commented Nov 1, 2012 at 18:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .