Redlines (redlines v0.6.0)

View Source

Extract and normalize tracked changes ("redlines") from documents.

This library provides a single normalized shape (Redlines.Change) across:

  • DOCX track changes (<w:ins>, <w:del>)
  • PDFs with embedded tracked-changes markup (via pdf_redlines)

Summary

Functions

Extract tracked changes from a file path, inferring type from the extension.

Format tracked changes for LLM prompts.

Types

doc_type()

@type doc_type() :: :pdf | :docx

Functions

extract(path, opts \\ [])

@spec extract(
  Path.t(),
  keyword()
) :: {:ok, Redlines.Result.t()} | {:error, term()}

Extract tracked changes from a file path, inferring type from the extension.

Options

  • :type - Override the inferred type (:pdf or :docx)
  • :pdf_opts - Options forwarded to PDFRedlines (only when extracting PDFs)

format_for_llm(input, opts \\ [])

@spec format_for_llm(
  Redlines.Result.t() | [Redlines.Change.t()] | map() | list(),
  keyword()
) :: String.t()

Format tracked changes for LLM prompts.

Accepts:

  • Redlines.Result
  • a list of Redlines.Change
  • a DOCX track_changes map (%{insertions: [...], deletions: [...]})
  • a list of PDF redline structs/maps (anything with :type, :deletion, :insertion, :location)