Пример #1
0
 public override void AddLine(string line)
 {
     //end of a paragraph
     if (empty.IsMatch(line))
     {
         Flush(); return;
     }
     //paragraph or list
     if (!par)
     {             //handle lists
         var match = MDList.item.Match(line);
         if (match.Success)
         {
             var ind = match.Groups[1].Value.Length;
             if (list == null)
             {
                 new_list(ind);
             }
             else if (list.OrigIndent < ind)
             {
                 list = list.AddSublist(ind);
             }
             else if (list.OrigIndent > ind && list.Parent != null)
             {
                 list = list.Parent;
             }
             it = list.AddItem();
             it.AddLine(match.Groups[2].Value + " " + MD2Unity.ConvertEmphasis(match.Groups[3].Value));
             return;
         }
         else if (it != null)
         {
             it.AddLine(MD2Unity.ConvertEmphasis(line)); return;
         }
     }
     //append the line to the current paragraph
     if (par == null)
     {
         new_par();
     }
     if (hr.IsMatch(line))
     {
         par.AddLine(_hr);
     }
     else
     {
         par.AddLine(MD2Unity.ConvertEmphasis(line));
     }
 }
Пример #2
0
        public static MDSection Parse(StreamReader file)
        {
            var parser = new MD2Unity(file);

            return(parser.Parse());
        }