PDF Page {page}
-""" - - # Convert PDF page to embedded image - pdf_path = os.path.join(pdf_folder, pdf_name) - try: - image_data = render_pdf_to_base64webp(pdf_path, page, 2048) - html += f"""Tests for Page {page}
-""" - - # Get the Markdown file and content for this page - md_file_path = None - md_content = None - try: - md_base = os.path.splitext(pdf_name)[0] - md_files = list(glob.glob(os.path.join(os.path.dirname(pdf_folder), candidate, f"{md_base}_pg{page}_repeat*.md"))) - if md_files: - md_file_path = md_files[0] # Use the first repeat as an example - with open(md_file_path, "r", encoding="utf-8") as f: - md_content = f.read() - except Exception as e: - md_content = f"Error loading Markdown content: {str(e)}" - - # Add a button to toggle the Markdown content display - if md_content: - html += f""" - -""" + for page in pages: + # Get tests for this PDF page tests = test_results_by_candidate[candidate][pdf_name][page] + for test, passed, explanation in tests: result_class = "pass" if passed else "fail" + status_text = "PASSED" if passed else "FAILED" + status_class = "pass-status" if passed else "fail-status" - # Start test div - html += f"""Test ID: {test.id} {status_text}
+PDF: {pdf_name} | Page: {page} | Type: {test.type}
+ +Text to find: "{text}"
\n""" elif test_type == "absent" and hasattr(test, "text"): text = getattr(test, "text", "") - html += f"""Text should not appear: "{text}"
\n""" elif test_type == "order" and hasattr(test, "before") and hasattr(test, "after"): before = getattr(test, "before", "") after = getattr(test, "after", "") - html += f"""Text order: "{before}" should appear before "{after}"
\n""" elif test_type == "table": if hasattr(test, "cell"): cell = getattr(test, "cell", "") - html += f"""Table cell: "{cell}"
\n""" if hasattr(test, "up") and getattr(test, "up", None): up = getattr(test, "up") - html += f"""Above: "{up}"
\n""" if hasattr(test, "down") and getattr(test, "down", None): down = getattr(test, "down") - html += f"""Below: "{down}"
\n""" if hasattr(test, "left") and getattr(test, "left", None): left = getattr(test, "left") - html += f"""Left: "{left}"
\n""" if hasattr(test, "right") and getattr(test, "right", None): right = getattr(test, "right") - html += f"""Right: "{right}"
\n""" elif test_type == "math" and hasattr(test, "math"): math = getattr(test, "math", "") - html += f"""Math equation: {math}
\n""" + + html += """PDF Render:
\n""" + image_data = render_pdf_to_base64webp(pdf_path, page, 1024) + html += f"""Error rendering PDF: {str(e)}
\n""" - html += """