Parse cell till its end and set content, lines_to_next_cell.
        Return the position of next cell start
174180
def find_cell_content(self, lines):
        """"""
        cell_end_marker, next_cell_start, self.explicit_eoc = self.find_cell_end(lines)

        # Metadata to dict
        if self.metadata is None:
            cell_start = 0
            self.metadata = {}
        else:
            cell_start = 1

        # Cell content
        source = lines[cell_start:cell_end_marker]
        self.org_content = [line for line in source]

        # Exactly two empty lines at the end of cell (caused by PEP8)?
        if self.ext == '.py' and self.explicit_eoc:
            if last_two_lines_blank(source):
                source = source[:-2]
                lines_to_end_of_cell_marker = 2
            else:
                lines_to_end_of_cell_marker = 0

            pep8_lines = pep8_lines_between_cells(source, lines[cell_end_marker:], self.ext)
            if lines_to_end_of_cell_marker != (0 if pep8_lines == 1 else 2):
                self.metadata['lines_to_end_of_cell_marker'] = lines_to_end_of_cell_marker

        if not is_active(self.ext, self.metadata) or \
                ('active' not in self.metadata and self.language and self.language != self.default_language):
            self.content = uncomment(source, self.comment if self.ext not in ['.r', '.R'] else '#')
        else:
            self.content = self.uncomment_code_and_magics(source)

        # Is this a raw cell?
        if ('active' in self.metadata and not is_active('ipynb', self.metadata)) or \
                (self.ext == '.md' and self.cell_type == 'code' and self.language is None):
            if self.metadata.get('active') == '':
                del self.metadata['active']
            self.cell_type = 'raw'

        # Explicit end of cell marker?
        if (next_cell_start + 1 < len(lines) and
                _BLANK_LINE.match(lines[next_cell_start]) and
                not _BLANK_LINE.match(lines[next_cell_start + 1])):
            next_cell_start += 1
        elif (self.explicit_eoc and next_cell_start + 2 < len(lines) and
              _BLANK_LINE.match(lines[next_cell_start]) and
              _BLANK_LINE.match(lines[next_cell_start + 1]) and
              not _BLANK_LINE.match(lines[next_cell_start + 2])):
            next_cell_start += 2

        self.lines_to_next_cell = count_lines_to_next_cell(
            cell_end_marker,
            next_cell_start,
            len(lines),
            self.explicit_eoc)

        return next_cell_start
529912
def get_cell(self, coords, cell_mode=CellMode.cooked):
    
    return self.parse_cell(self.get_row(coords[1])[coords[0]], coords, cell_mode)
673291
def find_cell_end(self, lines):
        """"""
        if self.metadata is None and not (self.cell_marker_end and self.end_code_re.match(lines[0])) \
                and paragraph_is_fully_commented(lines, self.comment, self.default_language):
            self.cell_type = 'markdown'
            for i, line in enumerate(lines):
                if _BLANK_LINE.match(line):
                    return i, i + 1, False
            return len(lines), len(lines), False

        if self.metadata is None:
            self.end_code_re = None
        elif not self.cell_marker_end:
            end_of_cell = self.metadata.get('endofcell', '-')
            self.end_code_re = re.compile('^' + self.comment + ' ' + end_of_cell + r'\s*$')

        return self.find_region_end(lines)
1303406
function positionToOffset(str, desiredLine, desiredCol) {
    if (desiredLine === 1) {
        return desiredCol - 1;
    }
    let line = 1;
    let lastNewLineOffset = -1;
    do {
        if (desiredLine === line) {
            return lastNewLineOffset + 1 + desiredCol - 1;
        }
        lastNewLineOffset = str.indexOf('\n', lastNewLineOffset + 1);
        line++;
    } while (lastNewLineOffset >= 0);
    return -1;
}
700352
function chunk(start, end) {
                // Slice, unescape and push onto result array.
                res.push(str.slice(start, end).replace(/\\\\/g, '\\').replace(/\\\./g, '.'));
                // Set starting position of next chunk.
                pos = end + 1;
            }
678964
def parse (cls, line, lineno, log, cmddict=None):
    
    start  = line.find('%')
    pos    = SeqPos(line, lineno, start + 1, len(line))
    result = None

    if start >= 0:
      result = cls(line[start:], pos)

    return result
1183631
function (startCell, endCell, callback) {
      var result = {
        index: [], // list of cell index: A1, A2, A3
        value: []  // list of cell value
      };

      var cols = {
        start: 0,
        end: 0
      };

      if (endCell.col >= startCell.col) {
        cols = {
          start: startCell.col,
          end: endCell.col
        };
      } else {
        cols = {
          start: endCell.col,
          end: startCell.col
        };
      }

      var rows = {
        start: 0,
        end: 0
      };

      if (endCell.row >= startCell.row) {
        rows = {
          start: startCell.row,
          end: endCell.row
        };
      } else {
        rows = {
          start: endCell.row,
          end: startCell.row
        };
      }

      for (var column = cols.start; column <= cols.end; column++) {
        for (var row = rows.start; row <= rows.end; row++) {
          var cellIndex = instance.utils.toChar(column) + (row + 1),
              cellValue = instance.helper.cellValue.call(this, cellIndex);

          result.index.push(cellIndex);
          result.value.push(cellValue);
        }
      }

      if (instance.utils.isFunction(callback)) {
        return callback.apply(callback, [result]);
      } else {
        return result;
      }
    }
775898
def next(self):
    """"""
    try:
      next_line = next(self._f)
    except StopIteration:
      self._FinalCheck()
      raise

    self._line_number += 1
    m_eol = re.search(r"[\x0a\x0d]*$", next_line)
    if m_eol.group() == "\x0d\x0a":
      self._crlf += 1
      if self._crlf <= 5:
        self._crlf_examples.append(self._line_number)
    elif m_eol.group() == "\x0a":
      self._lf += 1
      if self._lf <= 5:
        self._lf_examples.append(self._line_number)
    elif m_eol.group() == "":
      # Should only happen at the end of the file
      try:
        next(self._f)
        raise RuntimeError("Unexpected row without new line sequence")
      except StopIteration:
        # Will be raised again when EndOfLineChecker.next() is next called
        pass
    else:
      self._problems.InvalidLineEnd(
        codecs.getencoder('string_escape')(m_eol.group())[0],
        (self._name, self._line_number))
    next_line_contents = next_line[0:m_eol.start()]
    for seq, name in INVALID_LINE_SEPARATOR_UTF8.items():
      if next_line_contents.find(seq) != -1:
        self._problems.OtherProblem(
          "Line contains %s" % name,
          context=(self._name, self._line_number))
    return next_line_contents
140435
def coord_to_col( self, pos ):
        
        start,end = self.get_forward_strand_start(),self.get_forward_strand_end()
        if pos < start or pos > end:
            raise ValueError("Range error: %d not in %d-%d" % ( pos, start, end ))
        if not self.index:
            self.index = list()
            if (self.strand == '-'):
                # nota bene: for - strand self.index[x] maps to one column
                # higher than is actually associated with the position;  thus
                # when slice_by_component() and slice_by_coord() flip the ends,
                # the resulting slice is correct
                for x in range( len(self.text)-1,-1,-1 ):
                    if not self.text[x] == '-':
                        self.index.append( x + 1 )
                self.index.append( 0 )
            else:
                for x in range( len(self.text) ):
                    if not self.text[x] == '-':
                        self.index.append(x)
                self.index.append( len(self.text) )
        x = None
        try:
            x = self.index[ pos - start ]
        except:
            raise Exception("Error in index.")
        return x
898117
def read_last_line(fh, offset=256):
    
    fh.seek(0, 2)
    size = fh.tell()

    while offset < size:
        fh.seek(-offset, 2)
        lines = fh.readlines()
        if len(lines) > 1:
            return lines[-1]
        offset *= 2

    fh.seek(0, 0)
    return fh.readlines()[-1]
711226
def get_start_of_line_position(self, after_whitespace=False):
        
        if after_whitespace:
            current_line = self.current_line
            return len(current_line) - len(current_line.lstrip()) - self.cursor_position_col
        else:
            return - len(self.current_line_before_cursor)
754123
def find_next(lines, find_str, start_index):
    
    mode = None
    if isinstance(find_str, basestring):
        mode = 'normal'
        message = find_str
    elif isinstance(find_str, Invert):
        mode = 'invert'
        message = str(find_str)
    else:
        raise TypeError("Unsupported message type")
    for i in range(start_index, len(lines)):
        if re.search(message, lines[i]):
            return mode == 'normal', i, lines[i]
        elif message in lines[i]:
            return mode == 'normal', i, lines[i]
    if mode == 'invert':
        return True, len(lines), None
    raise LookupError("Not found")
696305
def get_position(self, row, col):
        """"""
        result = col
        self.log.debug('%s %s', row, col)
        lines = self.editor.getlines()[:row - 1]
        result += sum([len(l) + 1 for l in lines])
        self.log.debug(result)
        return result
708516
function parse_XLSBCell(data)/*:any*/ {
	var col = data.read_shift(4);
	var iStyleRef = data.read_shift(2);
	iStyleRef += data.read_shift(1) <<16;
	data.l++; //var fPhShow = data.read_shift(1);
	return { c:col, iStyleRef: iStyleRef };
}
940591
def slice_by_coord( self, start, end ):
        
        start_col = self.coord_to_col( start )
        end_col = self.coord_to_col( end )
        if (self.strand == '-'):
            (start_col,end_col) = (end_col,start_col)
        return self.slice( start_col, end_col )
628506
def end_of_paragraph(self, count=1, after=False):
        
        def match_func(text):
            return not text or text.isspace()

        line_index = self.find_next_matching_line(match_func=match_func, count=count)

        if line_index:
            add = 0 if after else 1
            return max(0, self.get_cursor_down_position(count=line_index) - add)
        else:
            return len(self.text_after_cursor)
1158997
def find_cell_content(self, lines):
        """"""
        cell_end_marker, next_cell_start, explicit_eoc = self.find_cell_end(lines)

        # Metadata to dict
        cell_start = 0
        if self.cell_type == 'markdown':
            if self.markdown_marker in ['"""', "'''"]:
                # Remove the triple quotes
                if lines[0].strip() == self.markdown_marker:
                    cell_start = 1
                else:
                    lines[0] = lines[0][3:]
                if not explicit_eoc:
                    last = lines[cell_end_marker - 1]
                    lines[cell_end_marker - 1] = last[:last.rfind(self.markdown_marker)]
            if self.twenty_hash.match(self.markdown_marker):
                cell_start = 1
        else:
            self.metadata = {}

        # Cell content
        source = lines[cell_start:cell_end_marker]
        self.org_content = [line for line in source]

        if self.cell_type == 'code' and self.comment_magics:
            uncomment_magic(source, self.language or self.default_language)

        if self.cell_type == 'markdown' and source:
            if self.markdown_marker.startswith(self.comment):
                source = uncomment(source, self.comment)
            if self.rst2md:
                if rst2md:
                    source = rst2md('\n'.join(source)).splitlines()
                else:
                    raise ImportError('Could not import rst2md from sphinx_gallery.notebook')

        self.content = source

        self.lines_to_next_cell = count_lines_to_next_cell(
            cell_end_marker,
            next_cell_start,
            len(lines),
            explicit_eoc)

        return next_cell_start