## utils.shorten_string()


Shorten a string to length `n` with an ellipsis in the middle if needed.


Usage

``` python
utils.shorten_string(
    string,
    n,
)
```


## Parameters


`string: str`  
The string to shorten.

`n: int`  
Maximum length of the returned string, including the ellipsis. Values below zero are treated as zero.


## Returns


`str`  
The original string if its length is \<= `n`, otherwise a shortened version with `...` inserted in the middle. The result never exceeds `n` characters. When `n` is too small to hold the `...` marker, the string is hard-truncated to `n` characters without a marker.
