Пример #1
0
        public MDList AddSublist(int ind)
        {
            var lst = new MDList(ind);

            lst.Parent = this;
            lst.Level  = Level + 1;
            items.Add(lst);
            return(lst);
        }
Пример #2
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));
     }
 }
Пример #3
0
        public string ShowStructure()
        {
            var text    = "";
            var indent  = MDList.indent(Level);
            var pindent = indent + indent;

            text += indent + string.Format("Section: level {0}, title '{1}'\n", Level, Title);
            if (Subsections.Count > 0)
            {
                text += indent + Subsections.Aggregate("Subsections: ", (s, ss) => s + ss.Title + " : ") + "\n";
            }
            text += Pars.Aggregate("", (s, p) => s + pindent + p.GetType().Name + ":\n" + pindent + p);
            if (Subsections.Count > 0)
            {
                if (Pars.Count > 0)
                {
                    text += "\n";
                }
                text += Subsections.Aggregate("", (s, ss) => s + ss.ShowStructure());
            }
            return(text + "\n");
        }
Пример #4
0
 public void Flush()
 {
     par = null; list = null; it = null;
 }
Пример #5
0
 void new_list(int ind)
 {
     list = new MDList(ind);
     Pars.Add(list);
 }