Exemple #1
0
 public TagMaker(TagInfo tagInfo)
 {
     this.tagInfo = tagInfo;
 }
Exemple #2
0
 private bool IsValidTag(TagInfo tagInfo, char currentSymbol)
 {
     return(!tagInfo.InsideWord && (char.IsWhiteSpace(currentSymbol) || TextEnded) || !hasWhiteSpace);
 }
Exemple #3
0
        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;
            }
        }
Exemple #4
0
 private void PushTag(TagInfo tagInfo)
 {
     tagsStack.Push(tagInfo.TagType);
     parsedTags.Push(ParsedTag.Create(tagInfo));
     renderedParts.Push(new StringBuilder());
 }