-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
87c8998
commit 9f1bb92
Showing
6 changed files
with
68 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace DotMarkdown; | ||
|
||
public interface IMarkdownContextEscaper | ||
{ | ||
MarkdownCharEscaper GetEscaper(MarkdownEscapeContext context); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using System; | ||
|
||
namespace DotMarkdown; | ||
|
||
internal sealed class MarkdownContextEscaper : IMarkdownContextEscaper | ||
{ | ||
public static IMarkdownContextEscaper Default { get; } = new MarkdownContextEscaper(); | ||
|
||
public MarkdownCharEscaper GetEscaper(MarkdownEscapeContext context) | ||
{ | ||
return context switch | ||
{ | ||
MarkdownEscapeContext.Default => MarkdownCharEscaper.Default, | ||
MarkdownEscapeContext.LinkText => MarkdownCharEscaper.LinkText, | ||
MarkdownEscapeContext.LinkUrl => MarkdownCharEscaper.LinkUrl, | ||
MarkdownEscapeContext.LinkTitle => MarkdownCharEscaper.LinkTitle, | ||
MarkdownEscapeContext.AngleBrackets => MarkdownCharEscaper.AngleBrackets, | ||
MarkdownEscapeContext.InlineCodeInsideTable => MarkdownCharEscaper.InlineCodeInsideTable, | ||
MarkdownEscapeContext.NoEscape => MarkdownCharEscaper.NoEscape, | ||
_ => throw new ArgumentOutOfRangeException(nameof(context)), | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
namespace DotMarkdown; | ||
|
||
public enum MarkdownEscapeContext | ||
{ | ||
Default = 0, | ||
LinkText = 1, | ||
LinkUrl = 2, | ||
LinkTitle = 3, | ||
AngleBrackets = 4, | ||
InlineCodeInsideTable = 5, | ||
NoEscape = 6, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters