code: private int findSpanStart(TextCursor cursor, int limit) {
          for (int i = cursor.currentOffset; i < limit; i++) {
              char c = cursor.text.charAt(i);
              if (c == '*' || c == '_') {
                  // Check prev and next symbols
                  if (isGoodAnchor(cursor.text, i - 1) && isNotSymbol(cursor.text, i + 1, c)) {
                      return i;
                  }
              }
          }
          return -1;
      }
docs: Searching for valid formatting span start
  
  @param cursor text cursor
  @param limit  maximum index in cursor
  @return span start, -1 if not found