parameters: (string, keepends=False)
docstring: r"""
      Intended for Python code. In contrast to Python's :py:meth:`str.splitlines`,
      looks at form feeds and other special characters as normal text. Just
      splits ``\n`` and ``\r\n``.
      Also different: Returns ``[""]`` for an empty string input.
  
      In Python 2.7 form feeds are used as normal characters when using
      str.splitlines. However in Python 3 somewhere there was a decision to split
      also on form feeds.
docstring_summary: r"""
      Intended for Python code. In contrast to Python's :py:meth:`str.splitlines`,
      looks at form feeds and other special characters as normal text. Just
      splits ``\n`` and ``\r\n``.
      Also different: Returns ``[""]`` for an empty string input.
docstring_tokens: r Intended for Python code . In contrast to Python s : py : meth : str . splitlines looks at form feeds and other special characters as normal text . Just splits \ n and \ r \ n . Also different : Returns [ ] for an empty string input .
function: def split_lines(string, keepends=False):
      r"""
      Intended for Python code. In contrast to Python's :py:meth:`str.splitlines`,
      looks at form feeds and other special characters as normal text. Just
      splits ``\n`` and ``\r\n``.
      Also different: Returns ``[""]`` for an empty string input.
  
      In Python 2.7 form feeds are used as normal characters when using
      str.splitlines. However in Python 3 somewhere there was a decision to split
      also on form feeds.
      """
      if keepends:
          lst = string.splitlines(True)
  
          # We have to merge lines that were broken by form feed characters.
          merge = []
          for i, line in enumerate(lst):
              if line.endswith('\f'):
                  merge.append(i)
  
          for index in reversed(merge):
              try:
                  lst[index] = lst[index] + lst[index + 1]
                  del lst[index + 1]
              except IndexError:
                  # index + 1 can be empty and therefore there's no need to
                  # merge.
                  pass
  
          # The stdlib's implementation of the end is inconsistent when calling
          # it with/without keepends. One time there's an empty string in the
          # end, one time there's none.
          if string.endswith('\n') or string == '':
              lst.append('')
          return lst
      else:
          return re.split('\n|\r\n', string)
function_tokens: def split_lines ( string , keepends = False ) : if keepends : lst = string . splitlines ( True ) # We have to merge lines that were broken by form feed characters. merge = [ ] for i , line in enumerate ( lst ) : if line . endswith ( '\f' ) : merge . append ( i ) for index in reversed ( merge ) : try : lst [ index ] = lst [ index ] + lst [ index + 1 ] del lst [ index + 1 ] except IndexError : # index + 1 can be empty and therefore there's no need to # merge. pass # The stdlib's implementation of the end is inconsistent when calling # it with/without keepends. One time there's an empty string in the # end, one time there's none. if string . endswith ( '\n' ) or string == '' : lst . append ( '' ) return lst else : return re . split ( '\n|\r\n' , string )