Saturday, February 03, 2007

Steve Dunn's Code Formatter

Steve just released the latest version for his excellent code formatter Plug-In for Windows Live Writer here.

Let's take it for a test spin...

 C# Code (no long lines)

using System; using System.Collections.Generic; using System.Text; using System.Management; using System.Management.Automation; using System.Collections; namespace DSS.PowerShell { [Cmdlet(VerbsDiagnostic.Ping, "Computer", SupportsShouldProcess = true)] public class PingComputerCmd : PSCmdlet { #region Properties private string[] _Name = {"localhost"}; private Boolean _All = false; private int _Output = 0; [Parameter(Position = 0, Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Help Text")] [ValidateNotNullOrEmpty] public string[] Name { get { return _Name; } set{ _Name = value; } }

 VB.NET Code (long lines)

 Word wrap still forced on but background colors and other elements work well. (Excuse the ugly blue).   I tried to manually remedy this to see why the scroll bars won't come on.  Something in the style for the DIV is in conflict.  My CSS is not the best so I am not able to pick it out.  It's possible that a div embedded in a div wil not inherit the "auto" style correctly.

Public Function Ping() As String Try Dim Query As SelectQuery Query = New SelectQuery("SELECT StatusCode FROM Win32_PingStatus WHERE Address = '" & Me.Name & "'") Dim Searcher As ManagementObjectSearcher Searcher = New ManagementObjectSearcher(Query) Dim result As ManagementObject For Each result In Searcher.Get If Not IsNothing(result.GetPropertyValue("StatusCode")) Then Dim x = result.GetPropertyValue("StatusCode") If result.GetPropertyValue("StatusCode") = 0 Then _Pingable = True Return "Pinged:" & Me.Name End If Else _Pingable = False End If Next Catch ex As Exception End Try Return "no hope" End Function

Here is DIV HTML as generated.

<div class="wlWriterEditableSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:1716bf5a-05d7-4f1a-9918-9ded3cc355da" contenteditable="false" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; width: 749px; padding-top: 0px">

Here is a DIV with scroll:

This is a very long line of continuing text a very very very long line that never ends anywhere

The above line wraps in WLW Web Layout mode but doesn't in Preview mode.  This is probably due to inheritance from the blog template.  There is a way in CSS to specify that a style blocks inheritance.  If I can find this I will experiment with it. 

By the way.  This was not the behavior of teh templates on the old blogspot blog site.  The newer templates are imposing more forced style rules somewhere.  Some of these may be unblockable.  I don't know yet.

 In any case this version of the formatter is much more flexible than the previous version.  Keep up the excellent work Steve.


After some testing with ode Formatter I have determined that the word wrap/scrollbar issue is being caused by settings in teh BlogSpot blog templates.  There is an entry in "main wrapper" that looks like this:

#main-wrapper { width: 600px; float: left; word-wrap: break-word; /* fix for long text breaking sidebar float in IE */ overflow: hidden; /* fix for long non-text content breaking IE sidebar float */ }

The comments indicate a patch for IE6.  Removing this patch seems to allow the scrollbars to display correctly.   ( I have not done this permanently on this blog yet so it still doesn't display the scroll bars.)

If Steve can find a way to block the inheritance of this style rule then his code will work under nearly all blog templates.  It it can't be done for some reason tehn I will alter this template so his code works correctly.

Testing with IE6 instead of IE7 shows that making template changes does break IE6.  Changes will not allow IE6 to display scrollbars.

There has to be a way to do this in all browsers. 

No comments:

Post a Comment