Inheritance: IMarkdownParsingContext
Beispiel #1
0
        private List <IMarkdownToken> TokenizeCore(SourceInfo sourceInfo)
        {
            var pc     = new MarkdownParsingContext(sourceInfo);
            var tokens = new List <IMarkdownToken>();

            while (pc.CurrentMarkdown.Length > 0)
            {
                var token = ApplyRules(pc);
                if (token == null)
                {
                    throw new MarkdownParsingException("Cannot parse markdown: No rule match.", pc.ToSourceInfo());
                }
                tokens.Add(token);
            }
            return(tokens);
        }
Beispiel #2
0
        private List <IMarkdownToken> TokenizeCore(SourceInfo sourceInfo)
        {
            var pc     = new MarkdownParsingContext(sourceInfo);
            var tokens = new List <IMarkdownToken>();

            while (pc.CurrentMarkdown.Length > 0)
            {
                var token = (from r in Context.Rules
                             select r.TryMatch(this, pc)).FirstOrDefault(t => t != null);
                if (token == null)
                {
                    throw new InvalidOperationException($"Cannot parse markdown for file {sourceInfo.File}, line {pc.LineNumber}.");
                }
                tokens.Add(token);
            }
            return(tokens);
        }
Beispiel #3
0
 private IMarkdownToken ApplyRules(MarkdownParsingContext pc)
 {
     foreach (var r in Context.Rules)
     {
         try
         {
             var token = r.TryMatch(this, pc);
             if (token != null)
             {
                 return(token);
             }
         }
         catch (Exception ex)
         {
             throw new MarkdownParsingException($"Cannot parse markdown: Rule {r.Name} is fault.", pc.ToSourceInfo(), ex);
         }
     }
     return(null);
 }
Beispiel #4
0
 private IMarkdownToken ApplyRules(MarkdownParsingContext pc)
 {
     foreach (var r in Context.Rules)
     {
         try
         {
             var token = r.TryMatch(this, pc);
             if (token != null)
             {
                 return token;
             }
         }
         catch (Exception ex)
         {
             throw new MarkdownParsingException($"Cannot parse markdown: Rule {r.Name} is fault.", pc.ToSourceInfo(), ex);
         }
     }
     return null;
 }
Beispiel #5
0
 private List<IMarkdownToken> TokenizeCore(SourceInfo sourceInfo)
 {
     var pc = new MarkdownParsingContext(sourceInfo);
     var tokens = new List<IMarkdownToken>();
     while (pc.CurrentMarkdown.Length > 0)
     {
         var token = ApplyRules(pc);
         if (token == null)
         {
             throw new MarkdownParsingException("Cannot parse markdown: No rule match.", pc.ToSourceInfo());
         }
         else if (token.Rule is MarkdownTextBlockRule)
         {
             pc.IsInParagraph = true;
         }
         else
         {
             pc.IsInParagraph = false;
         }
         tokens.Add(token);
     }
     return tokens;
 }