src/client/components/PlainMarkdownInput/slate/tokenizer.js
function parseEmphasis(tokens) {
  const newTokens = [];
  let i = 0;
  while (i < tokens.length) {
    if (typeof tokens[i] === 'string') {
      if (tokens[i] !== '') {
        newTokens.push(tokens[i]);
      }
      i++;
    } else {
      const currTag = tokens[i].type;
      if (INLINE_OPEN.indexOf(currTag) !== -1) {
        const closeTag = getCloseTag(currTag);
        const closePos = getClosePos(tokens, i, closeTag, tokens[i].markup);
        if (closePos !== -1) {
          let intEmphasis = getOneEmphasis(tokens, i, closePos);
          if (Array.isArray(intEmphasis) && intEmphasis.length === 0) {
            intEmphasis = '';
          }
          if (currTag === 'link_open') {
            newTokens.push(getUrlToken({ tokens, intEmphasis, num: i }));
          } else {
            newTokens.push(getEmphasisToken({ tokens, intEmphasis, currTag, num: i }));
          }
          i = closePos + 1;
          continue;
        }
      }
      newTokens.push(tokens[i]);
      i++;
    }
  }
  return newTokens;
}
function parseEmphasis(tokens) {
  const newTokens = [];
  let i = 0;
  while (i < tokens.length) {
    if (typeof tokens[i] === 'string') {
      if (tokens[i] !== '') {
        newTokens.push(tokens[i]);
      }
      i++;
    } else {
      const currTag = tokens[i].type;
      if (INLINE_OPEN.indexOf(currTag) !== -1) {
        const closeTag = getCloseTag(currTag);
        const closePos = getClosePos(tokens, i, closeTag, tokens[i].markup);
        if (closePos !== -1) {
          let intEmphasis = getOneEmphasis(tokens, i, closePos);
          if (Array.isArray(intEmphasis) && intEmphasis.length === 0) {
            intEmphasis = '';
          }
          if (currTag === 'link_open') {
            newTokens.push(getUrlToken({ tokens, intEmphasis, num: i }));
          } else {
            newTokens.push(getEmphasisToken({ tokens, intEmphasis, currTag, num: i }));
          }
          i = closePos + 1;
          continue;
        }
      }
      newTokens.push(tokens[i]);
      i++;
    }
  }
  return newTokens;
}
function parseEmphasis ( tokens ) { const newTokens = [ ] ; let i = 0 ; while ( i < tokens . length ) { if ( typeof tokens [ i ] === 'string' ) { if ( tokens [ i ] !== '' ) { newTokens . push ( tokens [ i ] ) ; } i ++ ; } else { const currTag = tokens [ i ] . type ; if ( INLINE_OPEN . indexOf ( currTag ) !== - 1 ) { const closeTag = getCloseTag ( currTag ) ; const closePos = getClosePos ( tokens , i , closeTag , tokens [ i ] . markup ) ; if ( closePos !== - 1 ) { let intEmphasis = getOneEmphasis ( tokens , i , closePos ) ; if ( Array . isArray ( intEmphasis ) && intEmphasis . length === 0 ) { intEmphasis = '' ; } if ( currTag === 'link_open' ) { newTokens . push ( getUrlToken ( { tokens , intEmphasis , num : i } ) ) ; } else { newTokens . push ( getEmphasisToken ( { tokens , intEmphasis , currTag , num : i } ) ) ; } i = closePos + 1 ; continue ; } } newTokens . push ( tokens [ i ] ) ; i ++ ; } } return newTokens ; }
parseEmphasis - Function parse inline and extract emphasis-tokens

@param tokens
@returns {Array}
parseEmphasis - Function parse inline and extract emphasis - tokens