Added support for Typescript colorizing

This commit is contained in:
bashirs 2013-02-14 13:06:41 -08:00
Родитель 55e7ba1fae
Коммит c9fba74c15
4 изменённых файлов: 102 добавлений и 0 удалений

Просмотреть файл

@ -88,6 +88,7 @@
</Compile>
<Compile Include="Compilation\Languages\Php.cs" />
<Compile Include="Compilation\Languages\PowerShell.cs" />
<Compile Include="Compilation\Languages\Typescript.cs" />
<Compile Include="Compilation\RuleCaptures.cs" />
<Compile Include="Compilation\RuleFormats.cs" />
<Compile Include="Compilation\Languages\Sql.cs">

Просмотреть файл

@ -15,6 +15,7 @@ namespace ColorCode.Common
public const string Html = "html";
public const string Java = "java";
public const string JavaScript = "javascript";
public const string TypeScript = "typescript";
public const string Php = "php";
public const string PowerShell = "powershell";
public const string Sql = "sql";

Просмотреть файл

@ -0,0 +1,90 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
using System.Collections.Generic;
using ColorCode.Common;
namespace ColorCode.Compilation.Languages
{
public class Typescript : ILanguage
{
public string Id
{
get { return LanguageId.TypeScript; }
}
public string Name
{
get { return "Typescript"; }
}
public string CssClassName
{
get { return "typescript"; }
}
public string FirstLinePattern
{
get
{
return null;
}
}
public IList<LanguageRule> Rules
{
get
{
return new List<LanguageRule>
{
new LanguageRule(
@"/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+/",
new Dictionary<int, string>
{
{ 0, ScopeName.Comment },
}),
new LanguageRule(
@"(//.*?)\r?$",
new Dictionary<int, string>
{
{ 1, ScopeName.Comment },
}),
new LanguageRule(
@"'[^\n]*?'",
new Dictionary<int, string>
{
{ 0, ScopeName.String },
}),
new LanguageRule(
@"""[^\n]*?""",
new Dictionary<int, string>
{
{ 0, ScopeName.String },
}),
new LanguageRule(
@"\b(abstract|any|bool|boolean|break|byte|case|catch|char|class|const|constructor|continue|debugger|declare|default|delete|do|double|else|enum|export|extends|false|final|finally|float|for|function|goto|if|implements|import|in|instanceof|int|interface|long|module|native|new|number|null|package|private|protected|public|return|short|static|string|super|switch|synchronized|this|throw|throws|transient|true|try|typeof|var|void|volatile|while|with)\b",
new Dictionary<int, string>
{
{ 1, ScopeName.Keyword },
}),
};
}
}
public bool HasAlias(string lang)
{
switch (lang.ToLower())
{
case "ts":
return true;
default:
return false;
}
}
public override string ToString()
{
return Name;
}
}
}

Просмотреть файл

@ -38,6 +38,7 @@ namespace ColorCode
Load<Cpp>();
Load<Java>();
Load<PowerShell>();
Load<Typescript>();
}
/// <summary>
@ -192,6 +193,15 @@ namespace ColorCode
get { return LanguageRepository.FindById(LanguageId.Cpp); }
}
/// <summary>
/// Language support for Typescript.
/// </summary>
/// <value>Language support for typescript.</value>
public static ILanguage Typescript
{
get { return LanguageRepository.FindById(LanguageId.TypeScript); }
}
/// <summary>
/// Finds a loaded language by the specified identifier.
/// </summary>