func CountParagraphs(cbcs []*wml.EG_ContentBlockContent) int
CountParagraphs counts all paragraphs in the content blocks, including those wrapped in SDT or CustomXml blocks.
func CountTables(cbcs []*wml.EG_ContentBlockContent) int
CountTables counts all tables in the content blocks, including those wrapped in SDT or CustomXml blocks.
func ForEachParagraph(cbcs []*wml.EG_ContentBlockContent, fn func(*wml.CT_P) bool)
ForEachParagraph calls the provided function for each paragraph in the content blocks, including those wrapped in SDT or CustomXml blocks. If the function returns false, iteration stops.
func ForEachTable(cbcs []*wml.EG_ContentBlockContent, fn func(*wml.CT_Tbl) bool)
ForEachTable calls the provided function for each table in the content blocks, including those wrapped in SDT or CustomXml blocks. If the function returns false, iteration stops.
func HasParagraphs(cbcs []*wml.EG_ContentBlockContent) bool
HasParagraphs checks if the content blocks contain any paragraphs, including those wrapped in SDT or CustomXml blocks.
func HasTables(cbcs []*wml.EG_ContentBlockContent) bool
HasTables checks if the content blocks contain any tables, including those wrapped in SDT or CustomXml blocks.
func Iterate(cbcs []*wml.EG_ContentBlockContent) func(yield func(*wml.EG_ContentBlockContentChoice) bool)
Iterate returns an iterator function that yields unwrapped content blocks. It transparently descends into SDT and CustomXml wrappers, yielding the actual paragraphs, tables, and other content.
This is the preferred way to iterate over EG_ContentBlockContent slices as it handles all wrapper types consistently.
Usage:
for choice := range contentblocks.Iterate(cbcs) {
// Process choice.P, choice.Tbl, etc.
}
The iterator yields EG_ContentBlockContentChoice directly (the unwrapped content), skipping nil entries and recursively descending into SDT and CustomXml wrappers.
The iterator has a maximum recursion depth limit to prevent stack overflow on maliciously crafted documents with deeply nested structures.
func Unwrap(cbcs []*wml.EG_ContentBlockContent) []*wml.EG_ContentBlockContentChoice
Unwrap flattens a slice of content blocks by unwrapping all SDT and CustomXml wrappers. Returns a new slice containing only the actual content.
This is useful when you need a materialized slice rather than an iterator, for example when you need to know the count upfront or iterate multiple times.