Exemple #1
0
        public string Parse(string line, List <string> html, TokenMatch match, byte tabIndex)
        {
            switch (match.TokenType)
            {
            case TokenType.BoldItalic:
                line = Builder.RepaceInString(line,
                                              Renderer.BoldItalic(match.Value),
                                              match.StartIndex,
                                              match.EndIndex);
                break;

            case TokenType.Bold:
                line = Builder.RepaceInString(line,
                                              Renderer.Bold(match.Value),
                                              match.StartIndex,
                                              match.EndIndex);
                break;

            case TokenType.Italic:
                line = Builder.RepaceInString(line,
                                              Renderer.Italic(match.Value),
                                              match.StartIndex,
                                              match.EndIndex);
                break;

            case TokenType.Codeline:
                line = Builder.RepaceInString(line,
                                              Renderer.Code(match.Value),
                                              match.StartIndex,
                                              match.EndIndex);
                break;

            case TokenType.Header:
                lineContained = true;
                int weight = line.Length - line.Replace("#", "").Length;
                line = Builder.RepaceInString(line,
                                              Renderer.Heading(weight, match.Value),
                                              match.StartIndex,
                                              match.EndIndex);
                break;

            case TokenType.Image:
                line = Builder.RepaceInString(line,
                                              Renderer.Image(match.BaseMatch.Groups[1].Value, match.BaseMatch.Groups[2].Value),
                                              match.StartIndex,
                                              match.EndIndex);
                break;

            case TokenType.Link:
                line = Builder.RepaceInString(line,
                                              Renderer.Link(match.BaseMatch.Groups[1].Value, match.BaseMatch.Groups[2].Value),
                                              match.StartIndex,
                                              match.EndIndex);
                break;

            case TokenType.Line:
                line = Builder.RepaceInString(line,
                                              Renderer.Line(match.Value),
                                              match.StartIndex,
                                              match.EndIndex);
                break;

            case TokenType.BlockQuote:
                specialTokenFound = true;
                line = Builder.RepaceInString(line,
                                              "",
                                              match.StartIndex,
                                              match.StartIndex + 1);
                if (!ContainsToken(TokenType.BlockQuote))
                {
                    specialTokens.Push(TokenType.BlockQuote);
                    html.Add("<blockquote>");
                }
                break;

            case TokenType.UnorderedList:
                lineContained     = true;
                specialTokenFound = true;
                AddUnorderedHeader(html, line, tabIndex);
                line = Builder.RepaceInString(line,
                                              Renderer.ListItem(match.Value),
                                              match.StartIndex,
                                              match.EndIndex);
                break;

            case TokenType.OrderedList:
                lineContained     = true;
                specialTokenFound = true;
                AddOrderedHeader(html, line, tabIndex);
                line = Builder.RepaceInString(line,
                                              Renderer.ListItem(match.Value),
                                              match.StartIndex,
                                              match.EndIndex);
                break;

            default:
                break;
            }
            return(line);
        }