# Curtail
HTML tag safe string truncation.
[](https://github.com/seankay/curtail/actions/workflows/ci.yml)
# Installation
```elixir
def deps do
  [ {:curtail, "~> 2.0"} ]
end
```
# Usage
### Options
    * length (default: 100)
    * omission (default: "...")
    * word_boundary (default: "~r/\S/")
    * break_token (default: nil)
Truncate using default options:
```elixir
  iex> Curtail.truncate("<p>Truncate me!</p>")
  "<p>Truncate me!</p>"
```
Truncate with custom length:
```elixir
  iex> Curtail.truncate("<p>Truncate me!</p>", length: 12)
  "<p>Truncate...</p>"
```
Truncate without omission string:
```elixir
iex> Curtail.truncate("<p>Truncate me!</p>", omission: "", length: 8)
"<p>Truncate</p>"
```
Truncate with custom word_boundary:
```elixir
iex> Curtail.truncate("<p>Truncate. Me!</p>", word_boundary: ~r/\S[\.]/, length: 12, omission: "")
"<p>Truncate.</p>"
```
Truncate without word boundary:
```elixir
iex> Curtail.truncate("<p>Truncate me</p>", word_boundary: false, length: 7)
"<p>Trun...</p>"
```
Truncate with custom break_token:
```elixir
iex> Curtail.truncate("<p>This should be truncated here<break_here>!!</p>", break_token: "<break_here>")
"<p>This should be truncated here</p>"
```
# License
Released under [MIT License.](http://opensource.org/licenses/MIT)