NLdoc.Conversion.Reader.Docx.State (NLdoc.Conversion.Reader.Docx v1.1.2)
View SourceThis module defines a struct that captures the state of the converter during a Docx conversion.
Summary
Functions
Gets the given field from the state object.
Modifies a state object by setting the given field to the value that field had in the old state.
Sets the given field on the state object to the given value.
Upserts the existence of an asset based on it's relative path.
Types
Functions
@spec get(t(), :has_title) :: boolean()
@spec get(t(), :hyperlink_target) :: String.t() | nil
@spec get(t(), :styling) :: NLdoc.Conversion.Reader.Docx.AST.RunProperties.t()
@spec get(t(), :assets) :: %{required(String.t()) => String.t()}
@spec get(t(), :numbering_id) :: String.t() | nil
Gets the given field from the state object.
This function only accepts fields of the state, which are :has_title, :hyperlink_target, :styling, :assets, :numbering_id. It will raise if the field is not valid.
@spec keep(t(), t(), :has_title) :: t()
@spec keep(t(), t(), :hyperlink_target) :: t()
@spec keep(t(), t(), :styling) :: t()
@spec keep(t(), t(), :assets) :: t()
@spec keep(t(), t(), :numbering_id) :: t()
Modifies a state object by setting the given field to the value that field had in the old state.
This function only accepts fields of the state, which are :has_title, :hyperlink_target, :styling, :assets, :numbering_id. It will raise if the field is not valid.
@spec set(t(), :has_title, boolean()) :: t()
@spec set(t(), :hyperlink_target, String.t() | nil) :: t()
@spec set(t(), :styling, NLdoc.Conversion.Reader.Docx.AST.RunProperties.t()) :: t()
@spec set(t(), :assets, %{required(String.t()) => String.t()}) :: t()
@spec set(t(), :numbering_id, String.t() | nil) :: t()
Sets the given field on the state object to the given value.
This function only accepts fields of the state, which are :has_title, :hyperlink_target, :styling, :assets, :numbering_id. It will raise if the field is not valid.
Upserts the existence of an asset based on it's relative path.
Examples
iex> alias NLdoc.Conversion.Reader.Docx.State
iex> {uuid, state} = State.upsert_asset(%State{}, "media/image.png")
iex> %{"media/image.png" => ^uuid} = state.assets
iex> alias NLdoc.Conversion.Reader.Docx.State
iex> {"xyz", state} = State.upsert_asset(%State{assets: %{"media/image.png" => "xyz"}}, "media/image.png")
iex> %{"media/image.png" => "xyz"} = state.assets