Fix entity handling in the main document content (attributes still broken)