public static Inline parse_inlines(Subject subj, Dictionary <string, Reference> refmap, Func <Subject, Inline>[] parsers, char[] specialCharacters) { var len = subj.Length; if (len == 0) { return(null); } var first = ParseInline(subj, parsers, specialCharacters); subj.LastInline = first.LastSibling; Inline cur; while (subj.Position < len) { cur = ParseInline(subj, parsers, specialCharacters); if (cur != null) { subj.LastInline.NextSibling = cur; subj.LastInline = cur.LastSibling; } } InlineStack.PostProcessInlineStack(subj, subj.FirstPendingInline, subj.LastPendingInline, InlineStack.InlineStackPriority.Maximum); return(first); }
/// <summary> /// Removes a subset of the stack. /// </summary> /// <param name="first">The first entry to be removed.</param> /// <param name="subj">The subject associated with this stack. Can be <c>null</c> if the pointers in the subject should not be updated.</param> /// <param name="last">The last entry to be removed. Can be <c>null</c> if everything starting from <paramref name="first"/> has to be removed.</param> public static void RemoveStackEntry(InlineStack first, Subject subj, InlineStack last) { var curPriority = first.Priority; if (last == null) { if (first.Previous != null) { first.Previous.Next = null; } else if (subj != null) { subj.FirstPendingInline = null; } if (subj != null) { last = subj.LastPendingInline; subj.LastPendingInline = first.Previous; } first = first.Next; } else { if (first.Previous != null) { first.Previous.Next = last.Next; } else if (subj != null) { subj.FirstPendingInline = last.Next; } if (last.Next != null) { last.Next.Previous = first.Previous; } else if (subj != null) { subj.LastPendingInline = first.Previous; } if (first == last) { return; } first = first.Next; last = last.Previous; } if (last == null || first == null) { return; } first.Previous = null; last.Next = null; // handle case like [*b*] (the whole [..] is being removed but the inner *..* must still be matched). // this is not done automatically because the initial * is recognized as a potential closer (assuming // potential scenario '*[*' ). InlineStack.PostProcessInlineStack(null, first, last, curPriority); }