Exemplo n.º 1
0
        internal MarkdownMatch GetEarliestMatch(string markdown, DomItem parent, MarkdownParser recursiveParser)
        {
            Match minPositionMatch = null;
            Func <MarkdownMatch, DomItem> minRule = null;

            foreach (KeyValuePair <Regex, Func <MarkdownMatch, DomItem> > rule in this)
            {
                Match match = rule.Key.Match(markdown);

                if (match.Success && (minPositionMatch == null || match.Index < minPositionMatch.Index))
                {
                    minPositionMatch = match;
                    minRule          = rule.Value;
                }
            }

            if (minPositionMatch != null && minRule != null)
            {
                return(new MarkdownMatch(markdown, minPositionMatch, minRule, parent, recursiveParser));
            }

            return(null);
        }
Exemplo n.º 2
0
 public MarkdownMatch(string original, Match match, Func <MarkdownMatch, DomItem> transform, DomItem parent, MarkdownParser recursiveParser)
 {
     this.Original        = original;
     this.MatchValue      = match.Value;
     this.Groups          = match.Groups;
     this._transform      = transform;
     this.Parent          = parent;
     this.RecursiveParser = recursiveParser;
 }