NLdoc.Conversion.Reader.Docx.AST.RunProperties (NLdoc.Conversion.Reader.Docx v1.1.2)

View Source

This module defines a struct that represents a w:rPr (run properties) object in a Word document.

See http://officeopenxml.com/WPtextFormatting.php for more information on what a w:rPr object may contain.

Summary

Types

t()

A struct representing the run properties of a run of text in a Word document.

Functions

Converts a RunProperties struct to a list of NLdoc.Spec.text_style() values. The list is sorted in alphabetical order to ensure consistent output.

Types

t()

@type t() :: %NLdoc.Conversion.Reader.Docx.AST.RunProperties{
  bold: boolean() | nil,
  code: boolean() | nil,
  fonts: NLdoc.Conversion.Reader.Docx.AST.Fonts.t(),
  italic: boolean() | nil,
  strike: boolean() | nil,
  style_id: String.t() | nil,
  subscript: boolean() | nil,
  superscript: boolean() | nil,
  underline: boolean() | nil
}

A struct representing the run properties of a run of text in a Word document.

Definition of values:

  • true: explicitly active
  • false: explicitly inactive
  • nil: implicitly inactive

Functions

merge(new, old)

@spec merge(new :: nil, old :: nil) :: nil
@spec merge(new :: nil, old :: t()) :: old :: t()
@spec merge(new :: t(), old :: nil) :: new :: t()
@spec merge(new :: t(), old :: t()) :: t()

parse(arg1, docx)

@spec parse(Saxy.XML.element() | nil, NLdoc.Conversion.Reader.Docx.t()) :: t()

parse_bool(arg1)

@spec parse_bool(nil) :: nil
@spec parse_bool(Saxy.XML.element()) :: boolean()

parse_vert_align(arg1)

@spec parse_vert_align(nil) :: nil
@spec parse_vert_align(Saxy.XML.element()) :: :subscript | :superscript | nil

to_text_styling(props)

@spec to_text_styling(t()) :: [NLdoc.Spec.text_style()]

Converts a RunProperties struct to a list of NLdoc.Spec.text_style() values. The list is sorted in alphabetical order to ensure consistent output.

Examples

iex> alias NLdoc.Conversion.Reader.Docx.AST.RunProperties
iex> props = %RunProperties{
...>   style_id: "test",
...>   bold: true,
...>   italic: false,
...>   underline: false,
...>   strike: false,
...>   superscript: false,
...>   subscript: false,
...>   code: false,
...>   fonts: nil
...> }
iex> RunProperties.to_text_styling(props)
[:bold]
iex> RunProperties.to_text_styling(%RunProperties{props | italic: true, underline: true})
[:bold, :italic, :underline]
iex> RunProperties.to_text_styling(%RunProperties{props | superscript: true, italic: true, underline: true})
[:bold, :italic, :superscript, :underline]
iex> RunProperties.to_text_styling(%RunProperties{style_id: "all", bold: true, italic: true, underline: true, strike: true, superscript: true, subscript: true, code: true, fonts: nil})
[:bold, :code, :italic, :strikethrough, :subscript, :superscript, :underline]