self.return_each_element = return_each_element
        self.headers_to_split_on = sorted(headers_to_split_on)
[docs]    def aggregate_elements_to_chunks(
        self, elements: List[ElementType]
    ) -> List[Document]:
        """Combine elements with common metadata into chunks
        Args:
            elements: HTML element content with associated identifying info and metadata
        """
        aggregated_chunks: List[ElementType] = []
        for element in elements:
            if (
                aggregated_chunks
                and aggregated_chunks[-1]["metadata"] == element["metadata"]
            ):
                # If the last element in the aggregated list
                # has the same metadata as the current element,
                # append the current content to the last element's content
                aggregated_chunks[-1]["content"] += "  \n" + element["content"]
            else:
                # Otherwise, append the current element to the aggregated list
                aggregated_chunks.append(element)
        return [
            Document(page_content=chunk["content"], metadata=chunk["metadata"])
            for chunk in aggregated_chunks
        ]
[docs]    def split_text_from_url(self, url: str) -> List[Document]:
        """Split HTML from web URL
        Args:
            url: web URL
        """
        r = requests.get(url)
        return self.split_text_from_file(BytesIO(r.content))
[docs]    def split_text(self, text: str) -> List[Document]:
        """Split HTML text string
        Args:
            text: HTML text
        """
        return self.split_text_from_file(StringIO(text))
[docs]    def split_text_from_file(self, file: Any) -> List[Document]:
        """Split HTML file
        Args:
            file: HTML file
        """
        try: