-
Notifications
You must be signed in to change notification settings - Fork 300
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
kashin.aleksandr
committed
Dec 11, 2024
1 parent
593897b
commit 6f02ada
Showing
9 changed files
with
209 additions
and
160 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
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
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,33 @@ | ||
using System.Text; | ||
using Markdown.Tokenizer.Handlers; | ||
using Markdown.Tokenizer.Tags; | ||
|
||
namespace Markdown.Tokenizer; | ||
|
||
public class HandlerManager(IEnumerable<IHandler> handlers) : IHandlerManager | ||
{ | ||
private readonly List<IHandler> handlers = handlers.ToList(); | ||
|
||
public void TryHandle(TokenizerContext context, StringBuilder buffer, List<Token> tags, Stack<Token> tagStack) | ||
{ | ||
foreach (var handler in handlers) | ||
{ | ||
var tag = handler.ProceedSymbol(context); | ||
if (tag != null) | ||
{ | ||
if (buffer.Length > 0) | ||
{ | ||
var token = new TextToken(buffer.ToString()); | ||
tags.Add(token); | ||
buffer.Clear(); | ||
} | ||
|
||
tags.Add(tag); | ||
tagStack.Push(tag); | ||
return; | ||
} | ||
} | ||
|
||
buffer.Append(context.Current); | ||
} | ||
} |
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,9 @@ | ||
using System.Text; | ||
using Markdown.Tokenizer.Tags; | ||
|
||
namespace Markdown.Tokenizer; | ||
|
||
public interface IHandlerManager | ||
{ | ||
void TryHandle(TokenizerContext context, StringBuilder buffer, List<Token> tags, Stack<Token> tagStack); | ||
} |
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,8 @@ | ||
using Markdown.Tokenizer.Tags; | ||
|
||
namespace Markdown.Tokenizer; | ||
|
||
public interface ITagProcessor | ||
{ | ||
void Process(List<Token> tags, Stack<Token> tagStack); | ||
} |
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
Oops, something went wrong.