Supported File Extensions for Extraction in book-to-skill: Complete Reference
book-to-skill supports 15 file extensions spanning PDFs, e-books, markup formats, and HTML documents, all defined in the SUPPORTED_EXTENSIONS constant located in book_to_skill/config.py.
The open-source book-to-skill library extracts readable text from diverse document formats to power automated skill extraction workflows. Before processing your document collection, you must verify that your files match the supported extension list maintained in the project's configuration layer.
Overview of Extension Categories
The tool organizes supported formats into four logical groups. Each group maps to specific parser implementations within the codebase, ensuring robust text extraction across heterogeneous document types.
PDF and E-book Formats
The core document extraction targets industry-standard publishing formats. book-to-skill processes:
.pdf— Adobe Portable Document Format.epub— Electronic Publication (open e-book standard).docx— Microsoft Word Open XML format.rtf— Rich Text Format
Plain Text and Markup Languages
For lightweight documentation and version-controlled content, the library accepts multiple text and markup extensions defined in the TEXT_EXTENSIONS set:
.txtand.text— Standard plain text files.mdand.markdown— Markdown documentation.rst— reStructuredText (common in Python documentation).adocand.asciidoc— AsciiDoc markup format
HTML Variants
Web-based documentation and saved web pages extract cleanly through the HTML parser group (HTML_EXTENSIONS):
.htmland.htm— Standard HTML documents.xhtml— Extensible Hypertext Markup Language
Calibre E-book Formats
Amazon Kindle and legacy Mobipocket formats are supported via the CALIBRE_EBOOK_EXTENSIONS set:
.mobi— Mobipocket e-book format.azwand.azw3— Amazon Kindle formats (AZW3 being the newer KF8 standard)
Source Code Implementation
The definitive extension registry lives in book_to_skill/config.py. The SUPPORTED_EXTENSIONS constant is constructed as a union of specialized extension sets, making the configuration modular and maintainable:
# book_to_skill/config.py
TEXT_EXTENSIONS = {".txt", ".text", ".md", ".markdown", ".rst", ".adoc", ".asciidoc"}
HTML_EXTENSIONS = {".html", ".htm", ".xhtml"}
CALIBRE_EBOOK_EXTENSIONS = {".mobi", ".azw", ".azw3"}
SUPPORTED_EXTENSIONS = {
".pdf", ".epub", ".docx", ".rtf",
*TEXT_EXTENSIONS,
*HTML_EXTENSIONS,
*CALIBRE_EBOOK_EXTENSIONS,
}
During runtime, the extraction workflow in book_to_skill/utils.py validates input files against this constant. The resolve_input_files() function filters out unsupported extensions before passing valid paths to their respective parsers in book_to_skill/parsers/.
Validating Files Programmatically
You can verify file eligibility before invoking the extraction pipeline by importing the configuration constant directly:
from pathlib import Path
from book_to_skill.config import SUPPORTED_EXTENSIONS
def is_supported(file_path: Path) -> bool:
return file_path.suffix.lower() in SUPPORTED_EXTENSIONS
print(is_supported(Path("my_book.pdf"))) # → True
print(is_supported(Path("notes.txt"))) # → True
print(is_supported(Path("image.png"))) # → False
For batch processing, use the library's internal resolution utility to handle glob patterns and automatically filter unsupported files:
from book_to_skill.utils import resolve_input_files
# Accepts glob patterns; only returns files with supported extensions
files = resolve_input_files(["~/documents/*"])
print(files) # List[Path] of accepted files
Command-Line Usage
When running book-to-skill from the terminal, the tool automatically validates input files against SUPPORTED_EXTENSIONS. You can pass multiple files or glob patterns:
# Extract from a PDF and an EPUB simultaneously
book-to-skill *.pdf *.epub
# Process all supported documents in a directory
book-to-skill ./ebooks/*
The CLI entry point in scripts/extract.py invokes the same validation logic, returning errors for any file types not present in the configuration sets.
Summary
- book-to-skill supports 15 distinct file extensions across four categories: PDF/e-books, text/markup, HTML, and Calibre formats.
- The canonical list resides in
book_to_skill/config.pywithin theSUPPORTED_EXTENSIONSconstant. - Extension validation occurs in
book_to_skill/utils.pyvia theresolve_input_files()function. - Individual parsers for each format are implemented in
book_to_skill/parsers/. - Both CLI and programmatic interfaces enforce extension compatibility before text extraction begins.
Frequently Asked Questions
Does book-to-skill support Microsoft Word documents?
Yes, the library accepts .docx files (Microsoft Word Open XML format) as part of the core SUPPORTED_EXTENSIONS set. However, legacy .doc binary formats are not supported; you must convert older Word documents to .docx before processing.
How does the library handle unsupported file types?
When encountering unsupported extensions, book_to_skill/utils.py filters them out during the input resolution phase. If you attempt to process an unsupported file through the CLI, the tool will skip the file or return an error indicating that no suitable parser exists for the extension.
Can I extract text from Amazon Kindle AZW3 files?
Yes, book-to-skill includes dedicated support for Amazon Kindle formats through the CALIBRE_EBOOK_EXTENSIONS set in config.py. Both .azw (older Kindle format) and .azw3 (KF8 standard) are supported alongside .mobi files, leveraging the same extraction pipeline as other e-book formats.
Where is the extension validation logic implemented in the source code?
Extension validation is implemented in two locations: the constant definitions reside in book_to_skill/config.py (lines defining SUPPORTED_EXTENSIONS), while the runtime validation logic executes in book_to_skill/utils.py within the resolve_input_files() function. The CLI entry point at scripts/extract.py coordinates these components during command execution.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →