NLdoc.Conversion.Reader.Docx.AST.RunProperties.Hex (NLdoc.Conversion.Reader.Docx v1.5.5)
View SourceNormalizes and validates hexadecimal color values found in DOCX run properties.
Accepts bare hexadecimal color strings (e.g. "FF0000" or "fff") and,
if valid, normalizes them to CSS-style color strings by prefixing a #.
Summary
Functions
Parses a DOCX hex color value and returns a CSS-style #RRGGBB or #RGB string.
Types
@type t() :: String.t()
Functions
Parses a DOCX hex color value and returns a CSS-style #RRGGBB or #RGB string.
The input must be a 3- or 6-character hexadecimal string (case-insensitive)
without a leading #. Any invalid value or non-binary term returns nil.
Any black color will be ignored, as that is the default color.
Examples
iex> alias NLdoc.Conversion.Reader.Docx.AST.RunProperties.Hex
iex> Hex.parse("fff")
"#fff"
iex> Hex.parse("FF0000")
"#FF0000"
iex> Hex.parse("00ff7A")
"#00ff7A"
iex> Hex.parse("ffff")
nil
iex> Hex.parse("xyz")
nil
iex> Hex.parse(nil)
nil