# `BUPE.Item`
[🔗](https://github.com/milmazz/bupe/blob/main/lib/bupe/item.ex#L1)

The [item][item] element definition from the EPUB manifest.

Each **Item** represents a [publication resource][pub-resource] bundled in an
EPUB (for example, XHTML content documents, images, or stylesheets).

The `content` field in the struct is not part of the EPUB spec; BUPE uses it
internally to hold the resource contents when parsing.

[item]: http://www.idpf.org/epub/31/spec/epub-packages.html#sec-manifest-elem
[pub-resource]: http://www.idpf.org/epub/31/spec/epub-spec.html#gloss-publication-resource-cmt-or-foreign

# `t`

```elixir
@type t() :: %BUPE.Item{
  content: nil | String.t(),
  description: nil | String.t(),
  duration: nil | String.t(),
  fallback: nil | String.t(),
  href: String.t(),
  id: nil | String.t(),
  media_overlay: nil | String.t(),
  media_type: nil | String.t(),
  properties: nil | String.t()
}
```

# `from_string`

> This function is deprecated. Use normalize/1 instead.

# `normalize`

```elixir
@spec normalize(t() | binary()) :: t()
```

Normalizes a binary path or `BUPE.Item` struct.

When fields are missing, this function fills in defaults:

- `id` becomes a generated UUID-based identifier.
- `description` defaults to the file name without extension.
- `media_type` is inferred from the `href` path.

## Examples

    iex> BUPE.Item.normalize(%BUPE.Item{
    ...>   id: "ode-to-bacon",
    ...>   href: "book/bacon.xhtml",
    ...>   description: "Ode to Bacon"
    ...> })
    %BUPE.Item{
      description: "Ode to Bacon",
      duration: nil,
      fallback: nil,
      href: "book/bacon.xhtml",
      id: "ode-to-bacon",
      media_overlay: nil,
      media_type: "application/xhtml+xml",
      properties: nil
    }

---

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