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

These are strings utilities.

Methods

Constants

AttributeDefinitionList = /^\s{0,3}\{([\w\d\s]+)\}:\s*(.*)\s*$/   $1 = id $2 = attribute list
InlineAttributeList = /^\s{0,3}\{([:#\.].*)\}\s*$/  
Definition = %r{ ^ # begin of line [ ]{0,3} # up to 3 spaces : # colon \s* # whitespace (\S.*) # the text = $1 $ # end of line }x   Example:
    ^:blah blah
    ^: blah blah
    ^   : blah blah
Abbreviation = %r{ ^ # begin of line [ ]{0,3} # up to 3 spaces \* # one asterisk \[ # opening bracket ([^\]]+) # any non-closing bracket: id = $1 \] # closing bracket : # colon \s* # whitespace (\S.*\S)* # definition=$2 \s* # strip this whitespace $ # end of line }x   Example:
    *[HTML]: Hyper Text Markup Language
FootnoteText = %r{ ^ # begin of line [ ]{0,3} # up to 3 spaces \[(\^.+)\]: # id = $1 (including '^') \s*(\S.*)?$ # text = $2 (not obb.) }x
LinkRegex = %r{ ^[ ]{0,3}\[([^\[\]]+)\]: # id = $1 [ ]* <?([^>\s]+)>? # url = $2 [ ]* (?:# Titles are delimited by "quotes" or (parens). ["('] (.+?) # title = $3 [")'] # Matching ) or " \s*(.+)? # stuff = $4 )? # title is optional }x   This regex is taken from BlueCloth sources Link defs are in the form: ^[id]: \n? url "optional title"
IncompleteLink = %r{^[ ]{0,3}\[([^\[\]]+)\]:\s*$}
HeaderWithId = /^(.*)\{\#([\w_-]+)\}\s*$/
HeaderWithAttributes = /^(.*)\{(.*)\}\s*$/
MightBeTableHeader = %r{\|}   if contains a pipe, it could be a table header
Sep = /\s*(\:)?\s*-+\s*(\:)?\s*/   ————-:
TableSeparator = %r{^(\|?#{Sep}\|?)+\s*$}   | ————-:| —————————— |
EMailAddress = /<([^:]+@[^:]+)>/
TabSize = 4;

Public Instance methods

Keys are downcased, space becomes underscore, converted to symbols.

Counts the number of leading ’#’ in the string

Returns the number of leading spaces, considering that a tab counts as `TabSize` spaces.

This parses email headers. Returns an hash.

+hash[‘data’]+ is the message.

Keys are downcased, space becomes underscore, converted to symbols.

    My key: true

becomes:

    {:my_key => true}

change space to "_" and remove any non-word character

This returns the position of the first real char in a list item

For example:

    '*Hello' # => 1
    '* Hello' # => 2
    ' * Hello' # => 3
    ' *   Hello' # => 5
    '1.Hello' # => 2
    ' 1.  Hello' # => 5

Strips initial and final hashes

toglie al massimo n caratteri

removes initial quote

[Validate]