lib/maruku/string_utils.rb
def spaces_before_first_char(s)
      s = MaRuKu::MDLine.new(s.gsub(/([^\t]*)(\t)/) { $1 + " " * (TAB_SIZE - $1.length % TAB_SIZE) })
      match = case s.md_type
        when :ulist
          # whitespace, followed by ('*'|'+'|'-') followed by
          # more whitespace, followed by an optional IAL, followed
          # by yet more whitespace
          s[/^\s*(\*|\+|\-)\s*(\{[:#\.].*?\})?\s*/]
        when :olist
          # whitespace, followed by a number, followed by a period,
          # more whitespace, an optional IAL, and more whitespace
          s[/^\s*\d+\.\s*(\{[:#\.].*?\})?\s*/]
        else
          tell_user "BUG (my bad): '#{s}' is not a list"
          ''
        end
      f = /\{(.*?)\}/.match(match)
      ial = f[1] if f
      [match.length, ial]
    end
# 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]
This returns the position of the first non-list character
in a list item.
This returns the position of the first non - list character in a list item .
def spaces_before_first_char(s)
      s = MaRuKu::MDLine.new(s.gsub(/([^\t]*)(\t)/) { $1 + " " * (TAB_SIZE - $1.length % TAB_SIZE) })
      match = case s.md_type
        when :ulist
          s[/^\s*(\*|\+|\-)\s*(\{[:#\.].*?\})?\s*/]
        when :olist
          s[/^\s*\d+\.\s*(\{[:#\.].*?\})?\s*/]
        else
          tell_user "BUG (my bad): '#{s}' is not a list"
          ''
        end
      f = /\{(.*?)\}/.match(match)
      ial = f[1] if f
      [match.length, ial]
    end
def spaces_before_first_char ( s ) s = MaRuKu :: MDLine . new ( s . gsub ( / ([^ \t ]*)( \t ) / ) { $1 + " " * ( TAB_SIZE - $1 . length % TAB_SIZE ) } ) match = case s . md_type when :ulist s [ / ^ \s *( \* | \+ | \- ) \s *( \{ [:# \. ].*? \} )? \s * / ] when :olist s [ / ^ \s * \d + \. \s *( \{ [:# \. ].*? \} )? \s * / ] else tell_user "BUG (my bad): '#{s}' is not a list" '' end f = / \{ (.*?) \} / . match ( match ) ial = f [ 1 ] if f [ match . length , ial ] end
This returns the position of the first non-list character
in a list item.
This returns the position of the first non - list character in a list item .
# whitespace, followed by ('*'|'+'|'-') followed by # more whitespace, followed by an optional IAL, followed # by yet more whitespace # whitespace, followed by a number, followed by a period, # more whitespace, an optional IAL, and more whitespace
None
Fixnum
s
None
example
None