Curtail
HTML tag-safe string truncation
Install / Use
/learn @seankay/CurtailREADME
Curtail
HTML tag safe string truncation.
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.
Related Skills
node-connect
349.2kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
109.5kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
349.2kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
349.2kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
