November 24, 2007
02:00 PM

I just released a new version of my Windows Live Writer plugin Paste From Visual Studio.

The new version sports:

  • More compact HTML output
  • Support for non-ASCII characters
  • Automatic stripping of leading whitespace

Sample output:

public string CssColor(int i)
{
    if (i >= 0 && i < colors.Count)
    {
        string name = null;
        Color color = colors[i];

        if (namedColors.TryGetValue(color.ToArgb(), out name) && name.Length <= 7)
            return name.ToLower();
        else
            return string.Format("#{1:x2}{2:x2}{3:x2}", i, color.R, color.G, color.B);
    }
    else
        return "black";
}

Corresponding HTML:

<pre class="code"><span style="color:blue">public string </span>CssColor(<span style="color:blue">int </span>i)
{
    <span style="color:blue">if </span>(i &gt;= 0 &amp;&amp; i &lt; colors.Count)
    {
        <span style="color:blue">string </span>name = <span style="color:blue">null</span>;
        <span style="color:maroon">Color </span>color = colors[i];

        <span style="color:blue">if </span>(namedColors.TryGetValue(color.ToArgb(), <span style="color:blue">out </span>name) &amp;&amp; name.Length &lt;= 7)
            <span style="color: blue">return </span>name.ToLower();
        <span style="color:blue">else
            return string</span>.Format(<span style="background:yellow;color:#a31515">"#{1:x2}{2:x2}{3:x2}"</span>, i, color.R, color.G, color.B);
    }
    <span style="color:blue">else
        return </span><span style="background:yellow;color:#a31515">"black"</span>;
}</pre>
© Douglas Stockwell 2007
Creative Commons License Unless otherwise specified all "source code" examples are available for use under the Creative Commons Attribution-Noncommercial 3.0 License. Please contact me if you would like more flexible licensing terms.
Messenger Presence