From 0372ee98a39f8e45c9f7c352f9a82caa9fdcbe80 Mon Sep 17 00:00:00 2001
From: Michele Dolfi <dol@zurich.ibm.com>
Date: Tue, 17 Dec 2024 10:00:15 +0100
Subject: [PATCH] fix: skip labels not included in the allow-list

Signed-off-by: Michele Dolfi <dol@zurich.ibm.com>
---
 docling_core/types/doc/document.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/docling_core/types/doc/document.py b/docling_core/types/doc/document.py
index 496c937b..4f1941e3 100644
--- a/docling_core/types/doc/document.py
+++ b/docling_core/types/doc/document.py
@@ -2038,6 +2038,9 @@ def export_to_markdown(  # noqa: C901
             if ix < from_element or to_element <= ix:
                 continue  # skip as many items as you want
 
+            if (isinstance(item, DocItem)) and (item.label not in labels):
+                continue  # skip any label that is not whitelisted
+
             # Handle newlines between different types of content
             if (
                 len(mdtexts) > 0