Skip to content

[EPUB] Noisy Markdown output (XML/CSS) and missing chapters due to path resolution issues #1724

@pablomartinezmake-code

Description

@pablomartinezmake-code

Description

Currently, the _epub_converter.py in MarkItDown has two significant limitations when handling EPUB files:

  • Noise in output: XHTML files often include XML declarations and <style> blocks. If the BeautifulSoup search for <body> fails (common with namespaces), the entire raw file content is included in the Markdown output.
  • Missing Content: The simplistic path joining logic f"{base_path}/{manifest[item_id]}" fails to correctly resolve relative paths (e.g., ../Text/...) used in many commercial EPUB manifests.

Potential Solution

A more robust manifest parser that handles relative paths and a more aggressive XHTML cleaner would resolve these issues. I have implemented a workaround for a private project and would be happy to contribute a PR if interested.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions