public Tuple <bool, IElement> Parse(int parentIndentation, int unit, IParent last) { var definitionListItems = DefinitionListItem.Parse(this, last); if (definitionListItems.Count > 0) { var definitionList = last.Parent as DefinitionList; if (last.Parent is DefinitionListItem) { definitionList = (DefinitionList)last.Parent.Parent; } if (definitionList != null) { foreach (var item in definitionListItems) { definitionList.Add(item); } return(new Tuple <bool, IElement>(true, definitionListItems.Last())); } definitionList = new DefinitionList(definitionListItems); definitionList.Parent = last; last.Add(definitionList); var listItem = definitionListItems.Last(); return(new Tuple <bool, IElement>(true, listItem)); } IElement newElement = this; if (Indentation > parentIndentation || TextAreas[0].IsQuoted) { var lastElement = last as IElement; var lastText = lastElement?.TextAreas?.LastOrDefault()?.Content.Text.TrimEnd(); if (lastText != null && lastText.EndsWith("::")) { newElement = new LiteralBlock(TextAreas); lastElement?.TextAreas.Last().Content.RemoveLiteral(); } else { var level = newElement.TextAreas[0].Indentation / unit; while (level > 0) { newElement = new BlockQuote(level * unit, unit, newElement); level--; } } } return(new Tuple <bool, IElement>(false, newElement)); }
public void Add(DefinitionListItem definitionListItem) { if (definitionListItem.Indentation == Indentation) { Items.Add(definitionListItem); definitionListItem.Parent = this; } else if (definitionListItem.Indentation > Indentation) { if (!(Items.Last().Definition.Elements.Last() is DefinitionList sublist)) { sublist = new DefinitionList(new List <DefinitionListItem> { definitionListItem }); sublist.Parent = this; Items.Last().Definition.Elements.Add(sublist); } else { sublist.Add(definitionListItem); } }