public string BuildTableOfContents(HierarchyCollection<Heading> headings)
        {
            if (headings == null || !headings.Any())
                return String.Empty;

            var tableOfContents = new StringBuilder();

            StartTableOfContents(tableOfContents);
            BuildTableOfContentsLayer(tableOfContents, headings);
            EndTableOfContents(tableOfContents);

            return tableOfContents.ToString();
        }
        public string BuildTableOfContents(HierarchyCollection <Heading> headings)
        {
            if (headings == null || !headings.Any())
            {
                return(String.Empty);
            }

            var tableOfContents = new StringBuilder();

            StartTableOfContents(tableOfContents);
            BuildTableOfContentsLayer(tableOfContents, headings);
            EndTableOfContents(tableOfContents);

            return(tableOfContents.ToString());
        }
        public virtual void BuildTableOfContentsLayer(StringBuilder builder, HierarchyCollection<Heading> hierarchyItems)
        {
            if (hierarchyItems == null || !hierarchyItems.Any())
                return;

            if (builder == null)
                throw new ArgumentNullException("builder");

            StartHierarchyList(builder);

            foreach (var hierarchyItem in hierarchyItems)
                BuildTableOfContentsItem(builder, hierarchyItem);

            EndHierarchyList(builder);
        }
        public virtual void BuildTableOfContentsLayer(StringBuilder builder, HierarchyCollection <Heading> hierarchyItems)
        {
            if (hierarchyItems == null || !hierarchyItems.Any())
            {
                return;
            }

            if (builder == null)
            {
                throw new ArgumentNullException("builder");
            }

            StartHierarchyList(builder);

            foreach (var hierarchyItem in hierarchyItems)
            {
                BuildTableOfContentsItem(builder, hierarchyItem);
            }

            EndHierarchyList(builder);
        }