No longer updated: new and updated blog (including old content) at http://roy-t.nl

Archive for http://roy-t.nl, please update your bookmarks

Posts Tagged ‘Wordpress’

Code snippets from Visual Studio to WordPress.com

Posted by Roy Triesscheijn on Tuesday 30 September, 2008

To keep everything nice and tidy I was hoping for some feature in WordPress to allow me to instert C# (or any style) code nicely. But wordpress wont even remember the indenting makeing everything gibberish unless I manually add spaces instead of tabs.

Many people use the <pre> tag but after some whining at the forums there is an actual function that does syntax highlighting and everything if you spell it exactly right.

Fill in your code between: {sourcecode language=’cshar’} … {/sourcecode} but replace the ‘{‘ and  ‘}’ by the standard brackets ‘[‘ and ‘]’. This works really nicely like here below.

public partial class Form1 : Form
{
        public Form1()
        {
            InitializeComponent();
        }

        private void buttonGenerate_Click(object sender, EventArgs e)
        {
            string source = richTextSource.Text;
            textOutput.Text = source;
        }
}

The FAQ item can be found here
Special thanks to user ‘a sacred path’

Advertisements

Posted in General Coding | Tagged: , , , | 3 Comments »