Handles adding/removing format strings to groups of lines
@param   {String} string  the entire string to use
@param   {Number[]}  selectionRange the starting and ending positions of the selection
@param   {String} type    ul or ol
@returns {Object} the new string, the updated selectionRange
function listHandler(string, selectionRange, type) {
  const start = startOfLine(string, selectionRange[0]);
  const end = endOfLine(string, selectionRange[1]);
  const lines = splitLines(string.substring(start, end));
  const boundaryRegex = /[~*`_[!]|[a-zA-Z]|\r|\n|$/gm;
  const newLines = [];

  lines.forEach((line, i) => {
    const symbol = type === 'ul' ? '- ' : `${i + 1}. `;
    let newLine;

    // If the line begins with an existing list symbol
    if (indexOfMatch(line, /^[0-9#>-]/m, 0) === 0) {
      const existingSymbol = line.substring(0, 0 + line.substring(0).search(boundaryRegex));

      // Remove the symbol
      newLine = line.substring(line.search(boundaryRegex), line.length);
      if (existingSymbol.trim() !== symbol.trim()) {
        newLine = symbol + line.substring(line.search(boundaryRegex), line.length);
      }
      return newLines.push(newLine);
    }
    newLine = symbol + line.substring(0, line.length);
    return newLines.push(newLine);
  });

  // Put it all together
  const joined = newLines.join('\r\n');
  const value = string.substring(0, start) + newLines.join('\r\n') + string.substring(end, string.length);
  return { value, range: [start, start + joined.replace(/\n/gm, '').length] };
}