private void ResetFormattingForConflictingTags(Tag currentTag, Tag conflictedTag) { TagInfo.ResetFormatting(); State = States.Pop(); var temporaryStack = new Stack <TagInfo>(); TagInfo tagInfo; do { tagInfo = NestedTagInfos.Pop(); if (tagInfo.Tag != conflictedTag && tagInfo.Tag != currentTag) { break; } tagInfo.ResetFormatting(); temporaryStack.Push(tagInfo); State = States.Pop(); if (currentTag == tagInfo.Tag) { break; } } while (currentTag != tagInfo.Tag); TagInfo = tagInfo; }
private void ParseUnderscoreContent(int index) { if (TextEnded) { if (!PreviousIsSpace && UnderscoreCounter != 0) { CloseUnderscoreTag(Markdown.Length - 1); if (wordContainsDigits) { foreach (var tag in tagsInsideWord) { tag.ResetFormatting(true); } } } else { TagInfo.AddContent(new TagInfo(text: Markdown.Substring(PreviousIndex))); TagInfo.ResetFormatting(); TagInfo = NestedTagInfos.Pop(); State = States.Pop(); PreviousIndex = Markdown.Length; } } else if (Markdown[index] == UnderscoreSymbol && !ShouldEscaped(Markdown[index])) { UnderscoreCounter++; } else { if (Markdown[index] == LinkOpenSymbol && !ShouldEscaped(Markdown[index])) { PreviousIsSpace = false; SetLinkTag(index); return; } if (char.IsDigit(Markdown[index])) { wordContainsDigits = true; } if (UnderscoreCounter != 0) { if (!PreviousIsSpace) { CloseUnderscoreTag(index); } else if (PreviousIsSpace) { SetNewState(OpenUnderscoreTag); State(index); } } if (char.IsWhiteSpace(Markdown[index])) { hasWhiteSpace = true; UnderscoreCounter = 0; if (TagInfo.InsideWord) { TagInfo.ResetFormatting(); State = States.Pop(); } tagsInsideWord = new List <TagInfo>(); } if (wordContainsDigits) { foreach (var tag in tagsInsideWord) { tag.ResetFormatting(true); } } PreviousIsSpace = char.IsWhiteSpace(Markdown[index]) || Markdown[index] == '\\' && BackslashCounter % 2 == 0; } }