IMG_TO_MARKDOWN_PROMPT = """
Convert the PDF page image to clean, well-structured Markdown. Include all meaningful text content while preserving hierarchy and formatting.

## Guidelines:
- Use appropriate Markdown syntax for headings, lists, tables, code blocks, and emphasis
- For multi-column layouts, read left-to-right, top-to-bottom
- Enclose math in `$$...$$`
- Skip page numbers and repetitive headers/footers unless explicitly marked as required below
- For images/charts, provide detailed descriptions in blockquotes:
  > **Image Description**: [detailed explanation]

## Special Elements:
- **Charts & Infographics**: Interpret and convert to Markdown format. Prefer table format when applicable
- **Logos**: Wrap in brackets. Ex: <logo>Coca-Cola</logo>
- **Watermarks**: Wrap in brackets. Ex: <watermark>OFFICIAL COPY</watermark>
- **Page Numbers**: Wrap in brackets. Ex: <page_number>14</page_number> or <page_number>9/22</page_number>
- **Checkboxes**: Use ☐ for empty checkboxes and ☑ for checked checkboxes

## Continuity (when previous page context provided):
- **Tables**: CRITICAL - If a table continues from the previous page, DO NOT repeat headers or table separators. Only provide the data rows that continue the table. NEVER add separator lines (|---|---|) when continuing a table - only provide data rows starting with |. Look for incomplete tables in the previous page context to determine if this page continues that table.
- **Lists**: Continue numbering from where the previous page left off. Maintain consistent formatting and indentation for nested items.
- **Text**: Ensure seamless flow by avoiding repetitive introductions or section breaks that duplicate previous page content.
- **Page Breaks**: When content flows across pages, treat it as one continuous document. Do not restart formatting or add unnecessary breaks.

Output only the Markdown content, no explanations. Do not include delimiters like ```markdown or ```html.
"""

POST_PROCESSING_PROMPT = """

You are provided with a Markdown document generated by converting a PDF using an OCR process, one page at a time. This initial conversion may exhibit inconsistencies such as:

- Inconsistent formatting
- Broken or misaligned tables
- Misplaced line breaks
- Duplicated headers, footers, or page numbers
- Fragmented sentences and paragraphs

## Goal:

Your objective is to meticulously clean up, reformat, and reorganize the provided Markdown. The final output should be a professional, highly readable, and consistently formatted document that preserves all original information and intent.

## Instructions:

1.  **Merge Related Content**: Identify and consolidate sections or information that may have been fragmented across multiple pages during the OCR process.
2.  **Structure with Headings**: Employ appropriate Markdown heading levels (`#`, `##`, `###`, etc.) to clearly delineate sections and subsections, creating a logical hierarchy.
3.  **Reconstruct Tables**: Carefully rebuild any broken or poorly formatted tables. Ensure that:
    - Table headers are consistent and correctly placed.
    - Columns are properly aligned.
    - All data is accurately represented within the table structure.
4.  **Eliminate Redundancy**: Remove any duplicated content, including but not limited to:
    - Repeated page headers or footers.
    - Page numbers.
5.  **Restore Text Flow**:
    - Fix fragmented sentences and paragraphs to ensure smooth readability.
    - Restore the intended structure and flow of the document.
6.  **Enhance Presentation**: Utilize Markdown elements such as bullet points (`*`, `-`), numbered lists, blockquotes (`>`), and code blocks where appropriate to improve clarity and visual presentation.
7.  **Ensure Consistency**: Apply consistent spacing, typography (e.g., bold, italics), and formatting throughout the entire document for a polished and professional appearance.
8.  **Preserve Critical Information**: All important notes, citations, disclaimers, and contextual comments from the original document must be preserved. Present them clearly and ensure they are located within the correct and relevant sections of the refined document.
9.  **No Omission of Information**: While reorganization for clarity is encouraged, **do not omit any information** present in the original Markdown.
10. **Summarize (If Applicable)**: If the document contains extensive data or key findings, consider creating summary tables or distinct sections to highlight this information effectively.

## Output:

Return a single, professionally formatted Markdown document that is:

- Easy to read and navigate.
- Logically organized.
- Visually consistent and appealing.

Output only the Markdown content, NO explanations. NEVER ADD YOUR OWN COMMENTARY AS IT DAMAGES THE INTEGRITY OF THE DOCUMENT. Do not include delimiters like ```markdown or ```html.
"""
