Beispiel #1
0
            internal static Section[] GetSections(IElement elem, Section[] sections = null)
            {
                if (sections == null)
                {
                    return(GetSections(elem, new Section[0]));
                }
                if (FiFiPageEntry.IsEnd(elem))
                {
                    return(sections);
                }

                var sectionHeadTags = new string[2] {
                    "H4", "H5"
                };

                if (sectionHeadTags.Contains(elem.TagName))
                {
                    // some sections have no text content
                    var  sectionElems = FiFiPage.GetElementsUntil(sectionHeadTags, elem.NextElementSibling);
                    bool hasContent   = sectionElems.Count() > 0 && sectionElems.Select(e => e.TextContent.Trim()).Aggregate((x, y) => x + y).Length > 0;

                    if (hasContent)
                    {
                        return(GetSections(elem.NextElementSibling, AddSection(sections, new Section(elem))));
                    }
                }

                return(GetSections(elem.NextElementSibling, sections));
            }