graph TD
    A[Start] --> B[Split content into lines]
    B --> C{Is line a header?}
    C -->|No| D{Is it before first header?}
    D -->|Yes| E[Add to preHeaderContent]
    D -->|No| F[Add to currentContent]
    C -->|Yes| G{Is it the first header?}
    G -->|Yes| H[Add preHeaderContent to processedContent]
    G -->|No| I[Process previous header and content]
    I --> J[Generate hashes for header and content]
    J --> K[Add hashes to allHashes]
    K --> L[Add header, content, and hash info to processedContent]
    H & L --> M[Set currentHeader]
    M --> N[Add header to headers list]
    E & F & N --> O{Reached Footer?}
    O -->|No| C
    O -->|Yes| P[Process last header and content]
    P --> Q[Generate Table of Contents]
    Q --> R[Generate metahash from allHashes]
    R --> S[Add TOC and metahash to processedContent]
    S --> T[End]