code: private int findCodeBlockStart(TextCursor cursor) {
          int offset = cursor.currentOffset;
          int index;
          while ((index = cursor.text.indexOf(CODE_BLOCK, offset)) >= 0) {
              if (isGoodAnchor(cursor.text, index - 1)) {
                  return index;
              }
              offset = index + 3;
          }
          return -1;
      }
docs: Searching for valid code block begin
  
  @param cursor text cursor
  @return code block start, -1 if not found