Socket
Book a DemoInstallSign in
Socket

auto_excerpt

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

auto_excerpt

0.7.1
bundlerRubygems
Version published
Maintainers
1
Created
Source

h1. AutoExcerpt

pre. [sudo] gem install auto_excerpt

Creates excerpts of html formatted text.

pre. AutoExcerpt.new("This is some fancy html formatted text homie", {:words => 5}) # => "This is some fancy html..."

h3. Features

  • There are 4 different ways to limit the length of an excerpt: characters, words, sentences, paragraphs
  • If the excerpt would be shorter than the limit that is set, the entire text will be shown.
  • If limiting by characters the gem will ensure that the excerpt does not cutoff in the middle of a word.
  • HTML can be stripped. You can also set specific tags that you don't want stripped.
  • HTML tags are automatically closed.

h3. Options

@:characters@ The number of characters to display from the text. Default: 150 (does not need to be set to 0 if you choose another option)

If you need to be 100% accurate in your character count, then remove the @:ending@

pre. AutoExcerpt.new("

Hello World!

", {:characters => 5, :ending => nil}) # =>

Hello

@:words@, @:sentences@, @:paragraphs@ The number of [which] to display from the text.

@:ending@ The text that will be displayed at the end of the excerpt when generating the excerpt by length or words. Set to @nil@ if you don't want it. Default: "..."

pre. AutoExcerpt.new("This is cool stuff man!", :ending => ". Srsly!", :words => 3) # => "This is cool. Srsly!"

@:strip_html@ Strips HTML tags from the excerpt that is displayed. Default: false

@:allowed_tags@ If using @:strip_html@ then this setting will allow the listed tags to be shown. default: []

pre. AutoExcerpt.new("

This is some formatted html

", {:strip_html => true, :allowed_tags => %w(p em)}) # => "

This is some formatted html

"

@:strip_paragraphs@ Strip all paragraph tags from the html. Default: false

@:skip_words@, @:skip_sentences@, @:skip_paragraphs@ The number of [which] to skip at the beginning of the html when returned. Default: 0

h3. Command Line

new: v0.7.1 Run @auto_excerpt@ from the command line with all of the options shown above! @$ auto_excerpt --words 10 "

Some html string

"@

h2. Help out on Github!

  • Fork the project.
  • Make your feature addition or bug fix.
  • Commit, do not mess with Rakefile, Version, or LICENSE.
  • Send me a pull request :)
  • Thanks for helping out!

h2. Credits

This is based on the rss_auto_excerpt plugin for Textpattern by the great "Rob Sable":http://www.wilshireone.com.

h3. Copyright

Copyright (c) 2010 Kabari Hendrick. See LICENSE for details.

FAQs

Package last updated on 23 Feb 2010

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.