Converts office documents into GitHub-Flavored Markdown using Firecrawl's
anydoc Rust library.
All conversion happens locally. Formats with a content signature are detected
automatically; CSV bytes must be passed with the explicit :csv format.
Examples
{:ok, markdown} = ExAnydoc.to_markdown("report.docx")
bytes = File.read!("report.docx")
{:ok, markdown} = ExAnydoc.to_markdown_bytes(bytes)Functions return {:ok, result} or an error map suitable for pattern
matching. Invalid argument types are rejected at the function or NIF boundary.
Summary
Functions
Detects a format from document content, returning nil when unknown.
Returns the format represented by an extension, with or without a leading dot.
Returns the format represented by a path's extension.
Parses bytes into anydoc's information-preserving document model.
Converts the document at path to GitHub-Flavored Markdown.
Converts document bytes to Markdown.
Types
@type error() :: %{code: error_code(), message: String.t()}
@type error_code() ::
:unsupported
| :malformed
| :encrypted
| :resource_limit
| :missing_part
| :io_error
@type format() ::
:doc
| :docx
| :odt
| :pdf
| :ppt
| :pptx
| :rtf
| :epub
| :excel
| :ods
| :odp
| :csv
@type result(value) :: {:ok, value} | {:error, error()}
Functions
Detects a format from document content, returning nil when unknown.
Returns the format represented by an extension, with or without a leading dot.
Returns the format represented by a path's extension.
@spec to_document(binary(), format() | nil) :: result(ExAnydoc.Document.t())
Parses bytes into anydoc's information-preserving document model.
PDF does not have a document-model representation; use to_markdown_bytes/2.
Embedded assets are returned in ExAnydoc.Document.assets and may contain
large binaries.
Converts the document at path to GitHub-Flavored Markdown.
The format is inferred from the path and document contents.
Converts document bytes to Markdown.
The optional format overrides content detection. It is required for CSV.
Pass an explicit format when the bytes have no reliable signature or when detection is not desired:
ExAnydoc.to_markdown_bytes("name,scoreAda,10 ", :csv)