Repository: deepset-ai/haystack

Issue:
fix: "list" support missing in ParsrConverter
**Describe the bug**
In the ParsrConverter, the "list" type is missing in haystack/nodes/file_converter/parsr.py line 176.

**Error message**
The contents of type "list" are missing in the output document.

**Expected behavior**
The contents should be appended and added to the final output.



Discussion:
I am picking this issue in the context of the first virtual community sprint [https://github.com/deepset-ai/haystack/discussions/4489](https://github.com/deepset-ai/haystack/discussions/4489)
I was playing with the code and I've confirmed the content of type "list" is not being mapped from a ParsrDocument into a Haystack Document (I've used "sample_4_pdf.pdf" for my tests, which is available in the unit test samples) (Parsr library creates this "list" type out of bullet points and numberings (as can be seen in the image I've submitted ), the pdf I've mentioned has one bullet point list!).

From what I've seen in the other converters and correct me if am wrong on this, Haystack converters separate the document content into two types and construct a Document for each type: Table and Text. 
Should we consider this list data as text and append it to the text content as it is done for the other content types besides "table"? This "list" object consider each line as of type "paragraph" in this case at least.

After this is cleared I plan to create a unit test to make sure this "list" information is being mapped correctly to a haystack document! 
Hopefully I was clear, thanks!
![image](https://user-images.githubusercontent.com/6846173/228819421-d4a29283-bf07-4a24-a40e-891692675207.png)


Resolving patch:
diff --git a/haystack/nodes/file_converter/parsr.py b/haystack/nodes/file_converter/parsr.py
--- a/haystack/nodes/file_converter/parsr.py
+++ b/haystack/nodes/file_converter/parsr.py
@@ -173,7 +173,7 @@ def convert(
             headlines = []
             for page_idx, page in enumerate(parsr_output["pages"]):
                 for elem_idx, element in enumerate(page["elements"]):
-                    if element["type"] in ["paragraph", "heading", "table-of-contents"]:
+                    if element["type"] in ["paragraph", "heading", "table-of-contents", "list"]:
                         current_paragraph = self._convert_text_element(element)
                         if current_paragraph:
                             if element["type"] == "heading" and extract_headlines:
@@ -236,12 +236,11 @@ def _convert_text_element(self, element: Dict[str, Any]) -> str:
             return ""
         if self.remove_page_footers and "isFooter" in element["properties"]:
             return ""
-        if element["type"] == "table-of-contents":
-            if self.remove_table_of_contents:
+        if element["type"] in ["table-of-contents", "list"]:
+            if self.remove_table_of_contents and element["type"] == "table-of-contents":
                 return ""
-            else:
-                current_paragraph = "\n".join([self._get_paragraph_string(elem) for elem in element["content"]])
-                return current_paragraph
+            current_paragraph = "\n".join([self._get_paragraph_string(elem) for elem in element["content"]])
+            return current_paragraph
 
         current_paragraph = self._get_paragraph_string(element)
         return current_paragraph


Test patch:
diff --git a/test/nodes/test_file_converter.py b/test/nodes/test_file_converter.py
--- a/test/nodes/test_file_converter.py
+++ b/test/nodes/test_file_converter.py
@@ -396,6 +396,20 @@ def test_parsr_converter_headline_extraction(samples_path):
                 assert extracted_headline["headline"] == doc.content[start_idx : start_idx + hl_len]
 
 
+@pytest.mark.integration
+@pytest.mark.skipif(sys.platform in ["win32", "cygwin"], reason="Parsr not running on Windows CI")
+def test_parsr_converter_list_mapping(samples_path):
+    # This exact line(without line break characters) only exists in the list object we want to make sure it's being mapped correctly
+    expected_list_line = "Maecenas tincidunt est efficitur ligula euismod, sit amet ornare est vulputate."
+
+    converter = ParsrConverter()
+
+    docs = converter.convert(file_path=str((samples_path / "pdf" / "sample_pdf_4.pdf").absolute()))
+    assert len(docs) == 2
+    assert docs[1].content_type == "text"
+    assert expected_list_line in docs[1].content
+
+
 @pytest.mark.unit
 def test_id_hash_keys_from_pipeline_params(samples_path):
     doc_path = samples_path / "docs" / "doc_1.txt"