forked from CommunityToolkit/ColorCode-Universal
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCodeColorizerBase.cs
More file actions
42 lines (36 loc) · 1.72 KB
/
Copy pathCodeColorizerBase.cs
File metadata and controls
42 lines (36 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Copyright (c) Microsoft Corporation. All rights reserved.
using ColorCode.Compilation;
using ColorCode.Parsing;
using ColorCode.Styling;
using System.Collections.Generic;
namespace ColorCode
{
/// <summary>
/// Creates a <see cref="CodeColorizerBase"/>, for creating Syntax Highlighted code.
/// </summary>
/// <param name="Style">The Custom styles to Apply to the formatted Code.</param>
/// <param name="languageParser">The language parser that the <see cref="CodeColorizerBase"/> instance will use for its lifetime.</param>
public abstract class CodeColorizerBase
{
public CodeColorizerBase(StyleDictionary Styles, ILanguageParser languageParser)
{
this.languageParser = languageParser
?? new LanguageParser(new LanguageCompiler(Languages.CompiledLanguages, Languages.CompileLock), Languages.LanguageRepository);
this.Styles = Styles ?? StyleDictionary.DefaultLight;
}
/// <summary>
/// Writes the parsed source code to the ouput using the specified style sheet.
/// </summary>
/// <param name="parsedSourceCode">The parsed source code to format and write to the output.</param>
/// <param name="scopes">The captured scopes for the parsed source code.</param>
protected abstract void Write(string parsedSourceCode, IList<Scope> scopes);
/// <summary>
/// The language parser that the <see cref="CodeColorizerBase"/> instance will use for its lifetime.
/// </summary>
protected readonly ILanguageParser languageParser;
/// <summary>
/// The styles to Apply to the formatted Code.
/// </summary>
public readonly StyleDictionary Styles;
}
}