getFormatting :: Attributes -> Formatting
getFormatting attr =
   Formatting
     { formatLang = Nothing
     , formatFontStyle =
          case lookupAttribute "font-style" attr of
            Just "italic"  -> Just ItalicFont
            Just "oblique" -> Just ObliqueFont
            Just "normal"  -> Just NormalFont
            _              -> Nothing
      , formatFontVariant =
          case lookupAttribute "font-variant" attr of
            Just "small-caps" -> Just SmallCapsVariant
            Just "normal"     -> Just NormalVariant
            _                 -> Nothing
      , formatFontWeight =
          case lookupAttribute "font-weight" attr of
            Just "bold"   -> Just BoldWeight
            Just "light"  -> Just LightWeight
            Just "normal" -> Just NormalWeight
            _             -> Nothing
      , formatTextDecoration =
          case lookupAttribute "text-decoration" attr of
            Just "underline" -> Just UnderlineDecoration
            Just "none"      -> Just NoDecoration
            _                -> Nothing
      , formatVerticalAlign =
          case lookupAttribute "vertical-align" attr of
            Just "sup"       -> Just SupAlign
            Just "sub"       -> Just SubAlign
            Just "baseline"  -> Just BaselineAlign
            _                -> Nothing
      , formatPrefix = lookupAttribute "prefix" attr
      , formatSuffix = lookupAttribute "suffix" attr
      , formatDisplay =
          case lookupAttribute "display" attr of
            Just "block"        -> Just DisplayBlock
            Just "left-margin"  -> Just DisplayLeftMargin
            Just "right-inline" -> Just DisplayRightInline
            Just "indent"       -> Just DisplayIndent
            _                   -> Nothing
      , formatTextCase =
          case lookupAttribute "text-case" attr of
            Just "lowercase"        -> Just Lowercase
            Just "uppercase"        -> Just Uppercase
            Just "capitalize-first" -> Just CapitalizeFirst
            Just "capitalize-all"   -> Just CapitalizeAll
            Just "sentence"         -> Just SentenceCase
            Just "title"            -> Just TitleCase
            _                       -> Nothing
      , formatDelimiter = lookupAttribute "delimiter" attr
      , formatStripPeriods =
          lookupAttribute "strip-periods" attr == Just "true"
      , formatQuotes =
          lookupAttribute "quotes" attr == Just "true"
      , formatAffixesInside = False -- should be true for layout only
      }
getFormatting :: Attributes -> Formatting
getFormatting attr =
   Formatting
     { formatLang = Nothing
     , formatFontStyle =
          case lookupAttribute "font-style" attr of
            Just "italic"  -> Just ItalicFont
            Just "oblique" -> Just ObliqueFont
            Just "normal"  -> Just NormalFont
            _              -> Nothing
      , formatFontVariant =
          case lookupAttribute "font-variant" attr of
            Just "small-caps" -> Just SmallCapsVariant
            Just "normal"     -> Just NormalVariant
            _                 -> Nothing
      , formatFontWeight =
          case lookupAttribute "font-weight" attr of
            Just "bold"   -> Just BoldWeight
            Just "light"  -> Just LightWeight
            Just "normal" -> Just NormalWeight
            _             -> Nothing
      , formatTextDecoration =
          case lookupAttribute "text-decoration" attr of
            Just "underline" -> Just UnderlineDecoration
            Just "none"      -> Just NoDecoration
            _                -> Nothing
      , formatVerticalAlign =
          case lookupAttribute "vertical-align" attr of
            Just "sup"       -> Just SupAlign
            Just "sub"       -> Just SubAlign
            Just "baseline"  -> Just BaselineAlign
            _                -> Nothing
      , formatPrefix = lookupAttribute "prefix" attr
      , formatSuffix = lookupAttribute "suffix" attr
      , formatDisplay =
          case lookupAttribute "display" attr of
            Just "block"        -> Just DisplayBlock
            Just "left-margin"  -> Just DisplayLeftMargin
            Just "right-inline" -> Just DisplayRightInline
            Just "indent"       -> Just DisplayIndent
            _                   -> Nothing
      , formatTextCase =
          case lookupAttribute "text-case" attr of
            Just "lowercase"        -> Just Lowercase
            Just "uppercase"        -> Just Uppercase
            Just "capitalize-first" -> Just CapitalizeFirst
            Just "capitalize-all"   -> Just CapitalizeAll
            Just "sentence"         -> Just SentenceCase
            Just "title"            -> Just TitleCase
            _                       -> Nothing
      , formatDelimiter = lookupAttribute "delimiter" attr
      , formatStripPeriods =
          lookupAttribute "strip-periods" attr == Just "true"
      , formatQuotes =
          lookupAttribute "quotes" attr == Just "true"
      , formatAffixesInside = False -- should be true for layout only
      }
getFormatting attr =
   Formatting
     { formatLang = Nothing
     , formatFontStyle =
          case lookupAttribute "font-style" attr of
            Just "italic"  -> Just ItalicFont
            Just "oblique" -> Just ObliqueFont
            Just "normal"  -> Just NormalFont
            _              -> Nothing
      , formatFontVariant =
          case lookupAttribute "font-variant" attr of
            Just "small-caps" -> Just SmallCapsVariant
            Just "normal"     -> Just NormalVariant
            _                 -> Nothing
      , formatFontWeight =
          case lookupAttribute "font-weight" attr of
            Just "bold"   -> Just BoldWeight
            Just "light"  -> Just LightWeight
            Just "normal" -> Just NormalWeight
            _             -> Nothing
      , formatTextDecoration =
          case lookupAttribute "text-decoration" attr of
            Just "underline" -> Just UnderlineDecoration
            Just "none"      -> Just NoDecoration
            _                -> Nothing
      , formatVerticalAlign =
          case lookupAttribute "vertical-align" attr of
            Just "sup"       -> Just SupAlign
            Just "sub"       -> Just SubAlign
            Just "baseline"  -> Just BaselineAlign
            _                -> Nothing
      , formatPrefix = lookupAttribute "prefix" attr
      , formatSuffix = lookupAttribute "suffix" attr
      , formatDisplay =
          case lookupAttribute "display" attr of
            Just "block"        -> Just DisplayBlock
            Just "left-margin"  -> Just DisplayLeftMargin
            Just "right-inline" -> Just DisplayRightInline
            Just "indent"       -> Just DisplayIndent
            _                   -> Nothing
      , formatTextCase =
          case lookupAttribute "text-case" attr of
            Just "lowercase"        -> Just Lowercase
            Just "uppercase"        -> Just Uppercase
            Just "capitalize-first" -> Just CapitalizeFirst
            Just "capitalize-all"   -> Just CapitalizeAll
            Just "sentence"         -> Just SentenceCase
            Just "title"            -> Just TitleCase
            _                       -> Nothing
      , formatDelimiter = lookupAttribute "delimiter" attr
      , formatStripPeriods =
          lookupAttribute "strip-periods" attr == Just "true"
      , formatQuotes =
          lookupAttribute "quotes" attr == Just "true"
      , formatAffixesInside = False -- should be true for layout only
      }