NLdoc.Conversion.Reader.Docx.AST.RunProperties (NLdoc.Conversion.Reader.Docx v1.1.2)
View SourceThis 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
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
@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 activefalse
: explicitly inactivenil
: implicitly inactive
Functions
@spec parse(Saxy.XML.element() | nil, NLdoc.Conversion.Reader.Docx.t()) :: t()
@spec parse_bool(nil) :: nil
@spec parse_bool(Saxy.XML.element()) :: boolean()
@spec parse_vert_align(nil) :: nil
@spec parse_vert_align(Saxy.XML.element()) :: :subscript | :superscript | nil
@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]