Skip to content

Latest commit

 

History

51 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Curtail

HTML tag safe string truncation.

CI

Installation

def deps do
  [ {:curtail, "~> 3.0"} ]
end

Usage

Options

* length (default: 100)
* omission (default: "...")
* word_boundary (default: "~r/\S/")
* break_token (default: nil)

Truncate using default options:

  iex> Curtail.truncate("<p>Truncate me!</p>")
  "<p>Truncate me!</p>"

Truncate with custom length:

  iex> Curtail.truncate("<p>Truncate me!</p>", length: 12)
  "<p>Truncate...</p>"

Truncate without omission string:

iex> Curtail.truncate("<p>Truncate me!</p>", omission: "", length: 8)
"<p>Truncate</p>"

Truncate with custom word_boundary:

iex> Curtail.truncate("<p>Truncate. Me!</p>", word_boundary: ~r/\S[\.]/, length: 12, omission: "")
"<p>Truncate.</p>"

Truncate without word boundary:

iex> Curtail.truncate("<p>Truncate me</p>", word_boundary: false, length: 7)
"<p>Trun...</p>"

Truncate with custom break_token:

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.

About

HTML tag-safe string truncation

Resources

Stars

31 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages