private void TokenizerIteration(string text, ref int i, ref int textTokenLength, List <Token> tokens, List <TagElement> tagsCandidates) { if (IsEscapedSymbols(text, i)) { if (textTokenLength != 0) { tokens.Add(CreateTextToken(text, i - textTokenLength, textTokenLength)); textTokenLength = 0; } tokens.Add(CreateTextToken(text, i + 1, 1)); i++; return; } if (MarkdownTagsLibrary.TryToGetUsableTagInAssociations(text, i, out var element)) { if (textTokenLength != 0) { tokens.Add(CreateTextToken(text, i - textTokenLength, textTokenLength)); textTokenLength = 0; } TryCreateTokenAndAddToList(text, element, tagsCandidates, tokens); i += element.Length - 1; return; } textTokenLength++; }
public void ContainsInTagAssociations_InputSimpleString_ReturnFalseAndNullTag(string input, int index) { var containsBool = MarkdownTagsLibrary.TryToGetUsableTagInAssociations(input, index, out var result); containsBool.Should().BeFalse(); result.Should().BeNull(); }
private static bool IsEscapedSymbols(string text, int index) { var currentChar = text.TryGetChar(index); var nextChar = text.TryGetChar(index + 1); return(currentChar == '\\' && nextChar.HasValue && (nextChar == '\\' || MarkdownTagsLibrary.TryToGetUsableTagInAssociations(text, index + 1, out var _))); }
public void ContainsInTagAssociations_InputSimpleString_ReturnTrueAndExpectedTag(string input, int index, TagType expected) { var containsBool = MarkdownTagsLibrary.TryToGetUsableTagInAssociations(input, index, out var result); containsBool.Should().BeTrue(); result.Should().NotBeNull(); result.Type.Should().Be(expected); }