module

Sterile

Constants

VERSION = "0.1.0"

Instance methods

decode_entities(string)

The reverse of +encode_entities+. Turns HTML or numeric entities into their Unicode counterparts.

Source
encode_entities(string)

Turn Unicode characters into their HTML equivilents. If a valid HTML entity is not possible, it will create a numeric entity.

q{“Economy Hits Bottom,” ran the headline}.encode_entities # => “Economy Hits Bottom,” ran the headline

Source
plain_format(string)
Source
plain_format_tags(string)

Like +plain_format+, but works with HTML/XML (somewhat).

Source
sluggerize(string, delimiter = "-")

Transliterate to ASCII, downcase and format for URL permalink/slug by stripping out all non-alphanumeric characters and replacing spaces with a delimiter (defaults to '-').

"Hello World!".sluggerize # => "hello-world"

Source
smart_format(string)

Format text with proper "curly" quotes, m-dashes, copyright, trademark, etc.

q{"He said, 'Away with you, Drake!'"}.smart_format # => “He said, ‘Away with you, Drake!’”

Source
smart_format_tags(string)

Like +smart_format+, but works with HTML/XML (somewhat).

Source
sterilize(string)

Transliterate to ASCII and strip out any HTML/XML tags.

"nåsty".sterilize # => "nasty"

Source
titlecase(string)
Source
to_ascii(*args, **kwargs)
Source
to_slug(*args, **kwargs)
Source
transliterate(string, optical = false)

Transliterate Unicode [and accented ASCII] characters to their plain-text ASCII equivalents. This is based on data from the stringex gem (https://github.com/rsl/stringex) which is in turn a port of Perl's Unidecode and ostensibly provides superior results to iconv. The optical conversion data is based on work by Eric Boehs at https://github.com/ericboehs/to_slug Passing an option of :optical => true will prefer optical mapping instead of more pedantic matches.

"ýůçký".transliterate # => "yucky"

Source
transmogrify(string, &)
Source
trim_whitespace(string)

Trim whitespace from start and end of string and remove any redundant whitespace in between.

" Hello world! ".transliterate # => "Hello world!"

Source

Nested types