Refactor extractItemsFromContent.