private void Process(TagHelperContent output, string source) { var reader = new SourceReader(source); var builder = new StringBuilder(); while (reader.MoveNext()) { if (reader.Current == '<' && reader.IsTag()) {//读取html标签 ReadHtml(output, builder, reader); continue; } if (reader.Current == '$' && reader.IsNextNonWhiteSpace('{')) {//代码块 Queue(output, builder); ReadInlineCode(output, reader); continue; } if (reader.Current == '`') {//字符串 ReadQuote(output, builder, reader); continue; } if (reader.Current == '<') {//代码里的小于号if(i < 0){} output.AppendHtml("<"); reader.Skip(); continue; } var code = reader.ReadUntil(new[] { '`', '<' }).Trim(); foreach (var s in code.Split(new[] { "\n" }, StringSplitOptions.RemoveEmptyEntries)) { if (string.IsNullOrWhiteSpace(s)) { continue; } output.AppendHtml(s.Trim()); } } }