# `Redlines.DOCX`
[🔗](https://github.com/EnaiaInc/redlines/blob/v0.9.3/lib/redlines/docx.ex#L1)

Extract track changes from DOCX files by parsing `word/document.xml`.

# `clean_warning`

```elixir
@type clean_warning() :: %{
  type: :revision_markup,
  part: String.t(),
  element: String.t(),
  count: non_neg_integer()
}
```

# `clean`

```elixir
@spec clean(
  Path.t(),
  keyword()
) :: {:ok, binary()} | {:error, term()}
```

Accept tracked changes in a DOCX and return the cleaned DOCX bytes.

This rewrites XML parts inside the DOCX zip (by default just `word/document.xml`)
by removing deletions (`<w:del>…</w:del>`) and unwrapping insertions
(`<w:ins>…</w:ins>`).

## Options

- `:parts` - Zip entry names to clean (default `["word/document.xml"]`)

# `clean_binary`

```elixir
@spec clean_binary(
  binary(),
  keyword()
) :: {:ok, binary()} | {:error, term()}
```

Like `clean/2`, but accepts raw DOCX bytes.

# `clean_binary_with_warnings`

```elixir
@spec clean_binary_with_warnings(
  binary(),
  keyword()
) :: {:ok, binary(), [clean_warning()]} | {:error, term()}
```

Like `clean_binary/2`, but also returns informational warnings about revision
markup that was present while cleaning.

See `clean_with_warnings/2`.

# `clean_with_warnings`

```elixir
@spec clean_with_warnings(
  Path.t(),
  keyword()
) :: {:ok, binary(), [clean_warning()]} | {:error, term()}
```

Like `clean/2`, but also returns informational warnings about revision markup
that was present while cleaning.

Each warning includes the zip `:part` (e.g. `"word/document.xml"`), an `:element`
(e.g. `"w:rPrChange"`) and a `:count`.

## Options

- `:parts` - Zip entry names to clean (default `["word/document.xml"]`)

# `extract_track_changes`

```elixir
@spec extract_track_changes(Path.t()) :: {:ok, map()} | {:error, term()}
```

Extract raw DOCX track changes.

Returns a map with `:insertions` and `:deletions`, each containing a list of
maps with keys: `:id`, `:author`, `:date`, and `:text`.

# `to_changes`

```elixir
@spec to_changes(map()) :: [Redlines.Change.t()]
```

Convert a raw `%{insertions: [...], deletions: [...]}` map into normalized changes.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
