()
| 169 | |
| 170 | |
| 171 | def test_ordered_lists(): |
| 172 | test_set: list[tuple[bytes, str]] = [] |
| 173 | |
| 174 | test_set.append( |
| 175 | ( |
| 176 | b"<html><body><ol><li>1st item</li><li>2nd item</li></ol></body></html>", |
| 177 | "1. 1st item\n2. 2nd item", |
| 178 | ) |
| 179 | ) |
| 180 | test_set.append( |
| 181 | ( |
| 182 | b'<html><body><ol start="1"><li>1st item</li><li>2nd item</li></ol></body></html>', |
| 183 | "1. 1st item\n2. 2nd item", |
| 184 | ) |
| 185 | ) |
| 186 | test_set.append( |
| 187 | ( |
| 188 | b'<html><body><ol start="2"><li>1st item</li><li>2nd item</li></ol></body></html>', |
| 189 | "2. 1st item\n3. 2nd item", |
| 190 | ) |
| 191 | ) |
| 192 | test_set.append( |
| 193 | ( |
| 194 | b'<html><body><ol start="0"><li>1st item</li><li>2nd item</li></ol></body></html>', |
| 195 | "0. 1st item\n1. 2nd item", |
| 196 | ) |
| 197 | ) |
| 198 | test_set.append( |
| 199 | ( |
| 200 | b'<html><body><ol start="-5"><li>1st item</li><li>2nd item</li></ol></body></html>', |
| 201 | "1. 1st item\n2. 2nd item", |
| 202 | ) |
| 203 | ) |
| 204 | test_set.append( |
| 205 | ( |
| 206 | b'<html><body><ol start="foo"><li>1st item</li><li>2nd item</li></ol></body></html>', |
| 207 | "1. 1st item\n2. 2nd item", |
| 208 | ) |
| 209 | ) |
| 210 | |
| 211 | for idx, pair in enumerate(test_set): |
| 212 | in_doc = InputDocument( |
| 213 | path_or_stream=BytesIO(pair[0]), |
| 214 | format=InputFormat.HTML, |
| 215 | backend=HTMLDocumentBackend, |
| 216 | filename="test", |
| 217 | ) |
| 218 | backend = HTMLDocumentBackend( |
| 219 | in_doc=in_doc, |
| 220 | path_or_stream=BytesIO(pair[0]), |
| 221 | ) |
| 222 | doc: DoclingDocument = backend.convert() |
| 223 | assert doc |
| 224 | assert doc.export_to_markdown() == pair[1], f"Error in case {idx}" |
| 225 | |
| 226 | |
| 227 | def test_description_lists(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…