MarkdownDeep.SpanFormatter.ResolveEmphasisMarks_classic C# (CSharp) Méthode

ResolveEmphasisMarks_classic() public méthode

public ResolveEmphasisMarks_classic ( List tokens, List marks ) : void
tokens List
marks List
Résultat void
        public void ResolveEmphasisMarks_classic(List<Token> tokens, List<Token> marks)
        {
            // First pass, do <strong>
            for (int i = 0; i < marks.Count; i++)
            {
                // Get the next opening or internal mark
                Token opening_mark=marks[i];
                if (opening_mark.type!=TokenType.opening_mark && opening_mark.type!=TokenType.internal_mark)
                    continue;
                if (opening_mark.length < 2)
                    continue;

                // Look for a matching closing mark
                for (int j = i + 1; j < marks.Count; j++)
                {
                    // Get the next closing or internal mark
                    Token closing_mark = marks[j];
                    if (closing_mark.type != TokenType.closing_mark && closing_mark.type!=TokenType.internal_mark)
                        continue;

                    // Ignore if different type (ie: `*` vs `_`)
                    if (Input[opening_mark.startOffset] != Input[closing_mark.startOffset])
                        continue;

                    // Must be at least two
                    if (closing_mark.length < 2)
                        continue;

                    // Split the opening mark, keeping the LHS
                    if (opening_mark.length > 2)
                    {
                        SplitMarkToken(tokens, marks, opening_mark, 2);
                    }

                    // Split the closing mark, keeping the RHS
                    if (closing_mark.length > 2)
                    {
                        closing_mark=SplitMarkToken(tokens, marks, closing_mark, closing_mark.length-2);
                    }

                    // Connect them
                    opening_mark.type = TokenType.open_strong;
                    closing_mark.type = TokenType.close_strong;

                    // Continue after the closing mark
                    i = marks.IndexOf(closing_mark);
                    break;
                }
            }

            // Second pass, do <em>
            for (int i = 0; i < marks.Count; i++)
            {
                // Get the next opening or internal mark
                Token opening_mark = marks[i];
                if (opening_mark.type != TokenType.opening_mark && opening_mark.type != TokenType.internal_mark)
                    continue;

                // Look for a matching closing mark
                for (int j = i + 1; j < marks.Count; j++)
                {
                    // Get the next closing or internal mark
                    Token closing_mark = marks[j];
                    if (closing_mark.type != TokenType.closing_mark && closing_mark.type != TokenType.internal_mark)
                        continue;

                    // Ignore if different type (ie: `*` vs `_`)
                    if (Input[opening_mark.startOffset] != Input[closing_mark.startOffset])
                        continue;

                    // Split the opening mark, keeping the LHS
                    if (opening_mark.length > 1)
                    {
                        SplitMarkToken(tokens, marks, opening_mark, 1);
                    }

                    // Split the closing mark, keeping the RHS
                    if (closing_mark.length > 1)
                    {
                        closing_mark = SplitMarkToken(tokens, marks, closing_mark, closing_mark.length - 1);
                    }

                    // Connect them
                    opening_mark.type = TokenType.open_em;
                    closing_mark.type = TokenType.close_em;

                    // Continue after the closing mark
                    i = marks.IndexOf(closing_mark);
                    break;
                }
            }
        }