node_modules/remark/node_modules/remark-parse/lib/tokenize/heading-atx.js
/* Tokenise an ATX-style heading. */
Tokenise an ATX-style heading.
Tokenise an ATX - style heading .
function atxHeading(eat, value, silent) {
  var self = this;
  var settings = self.options;
  var length = value.length + 1;
  var index = -1;
  var now = eat.now();
  var subvalue = '';
  var content = '';
  var character;
  var queue;
  var depth;
  while (++index < length) {
    character = value.charAt(index);
    if (character !== C_SPACE && character !== C_TAB) {
      index--;
      break;
    }
    subvalue += character;
  }
  depth = 0;
  while (++index <= length) {
    character = value.charAt(index);
    if (character !== C_HASH) {
      index--;
      break;
    }
    subvalue += character;
    depth++;
  }
  if (depth > MAX_ATX_COUNT) {
    return;
  }
  if (
    !depth ||
    (!settings.pedantic && value.charAt(index + 1) === C_HASH)
  ) {
    return;
  }
  length = value.length + 1;
  queue = '';
  while (++index < length) {
    character = value.charAt(index);
    if (character !== C_SPACE && character !== C_TAB) {
      index--;
      break;
    }
    queue += character;
  }
  if (
    !settings.pedantic &&
    queue.length === 0 &&
    character &&
    character !== C_NEWLINE
  ) {
    return;
  }
  if (silent) {
    return true;
  }
  subvalue += queue;
  queue = '';
  content = '';
  while (++index < length) {
    character = value.charAt(index);
    if (!character || character === C_NEWLINE) {
      break;
    }
    if (
      character !== C_SPACE &&
      character !== C_TAB &&
      character !== C_HASH
    ) {
      content += queue + character;
      queue = '';
      continue;
    }
    while (character === C_SPACE || character === C_TAB) {
      queue += character;
      character = value.charAt(++index);
    }
    while (character === C_HASH) {
      queue += character;
      character = value.charAt(++index);
    }
    while (character === C_SPACE || character === C_TAB) {
      queue += character;
      character = value.charAt(++index);
    }
    index--;
  }
  now.column += subvalue.length;
  now.offset += subvalue.length;
  subvalue += content + queue;
  return eat(subvalue)({
    type: 'heading',
    depth: depth,
    children: self.tokenizeInline(content, now)
  });
}
function atxHeading ( eat , value , silent ) { var self = this ; var settings = self . options ; var length = value . length + 1 ; var index = - 1 ; var now = eat . now ( ) ; var subvalue = '' ; var content = '' ; var character ; var queue ; var depth ; while ( ++ index < length ) { character = value . charAt ( index ) ; if ( character !== C_SPACE && character !== C_TAB ) { index -- ; break ; } subvalue += character ; } depth = 0 ; while ( ++ index <= length ) { character = value . charAt ( index ) ; if ( character !== C_HASH ) { index -- ; break ; } subvalue += character ; depth ++ ; } if ( depth > MAX_ATX_COUNT ) { return ; } if ( ! depth || ( ! settings . pedantic && value . charAt ( index + 1 ) === C_HASH ) ) { return ; } length = value . length + 1 ; queue = '' ; while ( ++ index < length ) { character = value . charAt ( index ) ; if ( character !== C_SPACE && character !== C_TAB ) { index -- ; break ; } queue += character ; } if ( ! settings . pedantic && queue . length === 0 && character && character !== C_NEWLINE ) { return ; } if ( silent ) { return true ; } subvalue += queue ; queue = '' ; content = '' ; while ( ++ index < length ) { character = value . charAt ( index ) ; if ( ! character || character === C_NEWLINE ) { break ; } if ( character !== C_SPACE && character !== C_TAB && character !== C_HASH ) { content += queue + character ; queue = '' ; continue ; } while ( character === C_SPACE || character === C_TAB ) { queue += character ; character = value . charAt ( ++ index ) ; } while ( character === C_HASH ) { queue += character ; character = value . charAt ( ++ index ) ; } while ( character === C_SPACE || character === C_TAB ) { queue += character ; character = value . charAt ( ++ index ) ; } index -- ; } now . column += subvalue . length ; now . offset += subvalue . length ; subvalue += content + queue ; return eat ( subvalue ) ( { type : 'heading' , depth : depth , children : self . tokenizeInline ( content , now ) } ) ; }
Tokenise an ATX-style heading.
Tokenise an ATX - style heading .
/* Eat initial spacing. */ /* Eat hashes. */ /* Eat intermediate white-space. */ /* Exit when not in pedantic mode without spacing. */ /* Eat content. */