How to paste code in your blog post with Visual Studio Dark Color Theme

I use a dark theme in Visual Studio, search for it

image

image

and I also post code from VS to this blog, I use Windows Live Writer for blogging which is an awesome tool, it comes with plugins too. There are a many Code plugins for Windows Live Writer but surprisingly none of them supports the Dark theme.

2013-12-30_17-05-17-460

I am using this plugin and let’s assume I have following C# code snippet that I want to post on this blog.

image

Using the above plugin it will render markup like the following, the good thing is that it embeds css styles in the markup which makes it easier to change, the default styles are

image

image

And this is what I need to do to get Dark theme, sort of.

image

I have changed font-size, color and background-color properties in .csharpcode pre style that the Insert Code plugin generated for me, I also changed the .kwrd and .str for to a different color. I chose to embed these styles into the cascading stylesheet of this blog, I did this because I post code snippets very often.

I also want to add a horizontal scroll for my code so I added a style attribute with overflow-x set to scroll on the container div element.

image

So here’s the final code snippet with the dark theme that I’m interested in.

   1:  public void On_commands_requested(SettingsPane sender, SettingsPaneCommandsRequestedEventArgs args)
   2:          {
   3:              var cmd = new SettingsCommand("RSSReader", "Manage Categories", x =>
   4:              {
   5:                  var settingsPanel = new Settings();
   6:                  settingsPanel.Show();
   7:              });
   8:  
   9:              var privacyCmd = new SettingsCommand("PrivacyPolicy", "Privacy Policy", x =>
  10:              {
  11:                  var privacyPolicyFlyout = new PrivacyPolicy {Width = 400};
  12:                  privacyPolicyFlyout.Show();
  13:              });
  14:  
  15:              args.Request.ApplicationCommands.Clear();
  16:              args.Request.ApplicationCommands.Add(cmd);
  17:              args.Request.ApplicationCommands.Add(privacyCmd);
  18:          }

Which plugins do you use dear reader?

FacebookTwitterLinkedInEmailGoogle+
  • B. Clay Shannon

    I use a plugin for my toaster, one for my cell phone, one for my laptop, one for my microwave oven, …. those are the plugins you’re talking about, right?