NLdoc.Conversion.Reader.Docx.Files.ContentTypes (NLdoc.Conversion.Reader.Docx v1.1.2)

View Source

Parsing for the "[Content_Types].xml" file inside a Docx document.

Summary

Functions

Parses the contents of a [Content_Types].xml file into a ContentTypes struct.

Returns the content type for a given filename.

Types

t()

@type t() :: %NLdoc.Conversion.Reader.Docx.Files.ContentTypes{
  defaults: %{required(String.t()) => String.t()},
  overrides: %{required(String.t()) => String.t()}
}

Functions

parse(arg)

@spec parse(Saxy.XML.element()) :: t()

Parses the contents of a [Content_Types].xml file into a ContentTypes struct.

type(content_types, filename)

Returns the content type for a given filename.

Examples

iex> content_types = %ContentTypes{
...>   defaults: %{
...>     "txt" => "text/plain",
...>     "xml" => "application/xml"
...>   },
...>   overrides: %{
...>     "/document.xml" => "application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"
...>   }
...> }
iex> content_types |> ContentTypes.type("/some/file.txt")
"text/plain"
iex> content_types |> ContentTypes.type("/file.xml")
"application/xml"
iex> content_types |> ContentTypes.type("/document.xml")
"application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"