Module MaRuKu::Strings
In: lib/maruku.rb
lib/maruku/string_utils.rb

Utility functions for dealing with strings.

Methods

Constants

TAB_SIZE = 4

Public Instance methods

Parses email headers, returning a hash. `hash[:data]` is the message; that is, anything past the headers.

Keys are downcased and converted to symbols; spaces become underscores. For example:

    !!!plain
    My key: true

becomes:

    {:my_key => true}

@param s [String] The email @return [Symbol => String] The header values

Normalize a link reference.

@param s [String] @return [String]

This returns the position of the first non-list character in a list item.

@example spaces_before_first_char(’*Hello’) #=> 1 spaces_before_first_char(’* Hello’) #=> 2 spaces_before_first_char(’ * Hello’) #=> 3 spaces_before_first_char(’ * Hello’) #=> 5 spaces_before_first_char(‘1.Hello’) #=> 2 spaces_before_first_char(’ 1. Hello’) #=> 5

@param s [String] @return [Fixnum]

Split a string into multiple lines, on line feeds and/or carriage returns.

@param s [String] @return [String]

Removes indentation from the beginning of `s`, up to at most `n` spaces. Tabs are counted as {TAB_SIZE} spaces.

@param s [String] @param n [Fixnum] @return [String]

Remove line-initial `>` characters for a quotation.

@param s [String] @return [String]

[Validate]