I am using the CodeColorer plugin to display source code in my WordPress. I am trying to have my code indented so that it displays properly on the website. However, when I try to add the following code to the WYSIWYG editor:
[cc lang="csharp"]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace LittleSoftwareStats
{
public static class Config
{
public static bool Enabled { get; set; }
internal static string ApiUrl
{
get
{
UriBuilder uri = new UriBuilder((Config.ApiSecure) ? ("https") : ("http"), Config.ApiHost, Config.ApiPort, Config.ApiPath);
return uri.ToString();
}
}
internal static string AppId { get; set; }
internal static string AppVer { get; set; }
internal const string ApiHost = "stats.yourwebsitehere.com";
internal const int ApiPort = 80;
internal const bool ApiSecure = false;
internal const string ApiPath = "api."+ApiFormat;
internal const string ApiFormat = "json";
internal const string ApiUserAgent = "LittleSoftwareStatsNET";
internal const int ApiTimeout = 25000;
}
}
[/cc]
When I update it, the code then becomes:
[cc lang="csharp"]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace LittleSoftwareStats
{
public static class Config
{
public static bool Enabled { get; set; }
internal static string ApiUrl
{
get
{
UriBuilder uri = new UriBuilder((Config.ApiSecure) ? ("https") : ("http"), Config.ApiHost, Config.ApiPort, Config.ApiPath);
return uri.ToString();
}
}
internal static string AppId { get; set; }
internal static string AppVer { get; set; }
internal const string ApiHost = "stats.yourwebsitehere.com";
internal const int ApiPort = 80;
internal const bool ApiSecure = false;
internal const string ApiPath = "api."+ApiFormat;
internal const string ApiFormat = "json";
internal const string ApiUserAgent = "LittleSoftwareStatsNET";
internal const int ApiTimeout = 25000;
}
}
[/cc]
I have also tried replacing the spaces with
, and
and the actual TAB character. If I add the TAB character in the Text editor then it will stay but once when I switch it to the Visual editor then it is all removed. I was wondering if anyone knows a trick to keeping the code indented or if there’s someway to fix it (without modifying the CodeColorer plugin)?
It looks like I figured it out. I installed SyntaxHighlighter Evolved and SyntaxHighlighter TinyMCE Button. When I select the code and use the TinyMCE button to highlight it, the spaces seem to stay. This also works in both TinyMCE’s Visual and Text editors.