79454837

Date: 2025-02-20 14:33:08
Score: 0.5
Natty:
Report link

This script performs well for me:

from docx import Document

def extract_highlighted_text(docx_path):
    doc = Document(docx_path)
    highlighted_texts = []

    for para in doc.paragraphs:
        for run in para.runs:
            if run.font.highlight_color is not None:
                highlighted_texts.append(run.text)

    return highlighted_texts

docx_file = "text.docx"
highlighted_texts = extract_highlighted_text(docx_file)

print("Highlighted Texts:")
for text in highlighted_texts:
    print(text)

Output: Docx File

Result:

Result

Reasons:
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Subir Chowdhury