# Syntax Normalization

Susy is divided into two layers: "Su" provides the core math functions with a stripped-down syntax, while "Susy" adds global settings, shorthand syntax, and other helpers. Each setting (e.g. span, location, columns, spread, etc.) has a single canonical syntax in Su.

This normalization module helps translate between those layers, transforming parsed Susy input into values that Su will understand.

### related

#### @function susy-normalize()

#### @function susy-normalize-span()

#### @function susy-normalize-columns()

#### @function susy-normalize-spread()

#### @function susy-normalize-location()

## @function susy-normalize()

### Description

Normalize the values in a configuration map. In addition to the global `$susy` properties, this map can include local span-related imformation, like `span` and `location`.

Normalization does not check that values are valid, which will happen in the Su math layer. These functions merely look for known Susy syntax – returning a map with those shorthand values converted into low-level data for Su. For example `span: all` and `location: first` will be converted into specific numbers.

### Parameters & Return

#### $config: (map)

Map of Susy configuration settings to normalize. See `$susy` and `susy-parse()` documentation for details.

#### $context: null (map | null)

Map of Susy configuration settings to use as global reference, or `null` to use global settings.

#### @return (map)

Map of Susy configuration settings, with all values normalized for Su math functions.

### related

#### $susy

#### @function susy-parse()

### requires

#### @function susy-normalize-spread()

#### @function susy-normalize-columns()

#### @function susy-get()

#### @function susy-normalize-span()

#### @function susy-normalize-location()

### used by

#### @function susy-compile()

## @function susy-normalize-span()

### Description

Normalize `span` shorthand for Su. Su span syntax allows an explicit length (e.g. `3em`), unitless column-span number (e.g. `3` columns), or an explicit list of columns (e.g. `(3 5 8)`).

Susy span syntax also allows the `all` keyword, which will be converted to a slice of the context in normalization.

### Parameters & Return

#### $span: (number | list | 'all')

Span value to normalize.

#### $columns: (list)

Normalized list of columns in the grid

#### @return (number | list)

Number or list value for `$span`

### used by

#### @function susy-normalize()

## @function susy-normalize-columns()

### Description

Normalize `column` shorthand for Su. Su column syntax only allows column lists (e.g. `120px 1 1 1 120px`).

Susy span syntax also allows a unitless `slice` number (e.g `of 5`), which will be converted to a slice of the context in normalization.

### Parameters & Return

#### $columns: (list | integer)

List of available columns, or unitless integer representing a slice of the available context.

#### $context: null (map | null)

Map of Susy configuration settings to use as global reference, or `null` to access global settings.

#### @return (list)

Columns list value, normalized for Su input.

#### @error

when attempting to access a slice of asymmetrical context

### requires

#### @function susy-settings()

#### @function _susy-flatten() [private]

#### @function susy-repeat()

#### @function _susy-error() [private]

### used by

#### @function susy-normalize()

## @function susy-normalize-spread()

### Description

Normalize `spread` shorthand for Su. Su spread syntax only allows the numbers `-1`, `0`, or `1` – representing the number of gutters covered in relation to columns spanned.

Susy spread syntax also allows keywords for each value – `narrow` for `-1`, `wide` for `0`, or `wider` for `1` – which will be converted to their respective integers in normalization.

### Parameters & Return

#### $spread: (0 | 1 | -1 | 'narrow' | 'wide' | 'wider')

Spread across adjacent gutters, relative to a column-count — either `narrow` (-1), `wide` (0), or `wider` (1)

#### @return (number)

Numeric value for `$spread`

### used by

#### @function susy-normalize()

## @function susy-normalize-location()

### Description

Normalize `location` shorthand for Su. Su location syntax requires the (1-indexed) number for a column.

Susy also allows the `first` and `last` keywords, where `first` is always `1`, and `last` is calculated based on span and column values. Both keywords are normalized into an integer index in normalization.

### Parameters & Return

#### $span: (number)

Number of grid-columns to be spanned

#### $location: (integer | 'first' | 'last')

Starting (1-indexed) column position of a span, or a named location keyword.

#### $columns: (list)

Already-normalized list of columns in the grid.

#### @return (integer)

Numeric value for `$location`

### used by

#### @function susy-normalize()