mostlylucid

scott galloway's personal blog...
posts - 916, comments - 758, trackbacks - 11

My Links

News

Archives

Post Categories

Misc. Coding

Testing out Colin Coller's new CopySourceAsHtml release...

Looks like the definitive method for formatting source for blogs has been made! The new version adds a whole lot of stuff (from Colin's blog):

  • You can turn word wrapping on and off. If "wrap words" is checked, lines are rendered in <p> blocks. Otherwise, lines are rendered in <pre> blocks. Check this if your blog layout isn't wide enough for your code.
  • You can strip line breaks from the generated HTML. Handy if your blog software converts newlines automatically.
  • You can add additional RSS rules to the file, line, and block styles. Use this to add borders, scroll bars, etc. to your code.
  • You can embed styles or use a stylesheet. If "embed styles" is checked, tags have style attributes. If "embed styles" is unchecked, tags have class attributes, and the generated HTML includes a style block.
  • You can change which menu items are added to the context menus from within the add-in.
  • The generated HTML is copied to the clipboard in text and CF_HTML formats.
  • The code is cleaner and more modular, and the object model should make it easy to add new features in future versions.
  • There's an "About" tab with the version, copyright, license, my contact information, and my Amazon.com wish list (just kidding :).

Also added is using the defined colouring from VS.NET for the colouring (not Resharper coluring though - but I suspect Resharper uses some sort of hack for this anyway...)

Anyway, an example of what this awesome tool can output is below (just a simple object serialization routine):

using System.IO;

using System.Text;

using System.Xml.Serialization;

 

namespace Notifier

{

    /// <summary>

    /// Summary description for Deserializer.

    /// </summary>

    public class Deserializer

    {

        public static string Serialize(Template theTemplate)

        {

            XmlSerializer xSer = new XmlSerializer(typeof(Template));

            MemoryStream writer = new MemoryStream();

                xSer.Serialize(writer,theTemplate);

                string outStr =  ASCIIEncoding.ASCII.GetString(writer.ToArray());

                writer.Close();

                return outStr;

        }

 

        public static Template DeSerialize(string serializedTemplate)

        {

            XmlSerializer xSer = new XmlSerializer(typeof(Template));

            byte[] bytArr = ASCIIEncoding.ASCII.GetBytes(serializedTemplate);

            using(MemoryStream stream= new MemoryStream(bytArr))

            {

                return xSer.Deserialize(stream) as Template;

            }

        }

    }

}

 

Print | posted on Wednesday, November 03, 2004 3:11 AM |

Comments have been closed on this topic.

Powered by: