packages/remark-cq/index.js
function tokenizeBlockInlineAttributeList(eat, value, silent) {
  var self = this;
  var index = -1;
  var length = value.length + 1;
  var subvalue = EMPTY;
  var character;
  var marker;
  var markerCount;
  var queue;

  // eat initial spacing
  while (++index < length) {
    character = value.charAt(index);

    if (character !== C_TAB && character !== C_SPACE) {
      break;
    }

    subvalue += character;
  }

  if (value.charAt(index) !== C_LEFT_BRACE) {
    return;
  }

  // ignore {{ thing }}
  if (value.charAt(index + 1) === C_LEFT_BRACE) {
    return;
  }

  // ignore {% thing %}
  if (value.charAt(index + 1) === C_PERCENT) {
    return;
  }

  marker = character;
  subvalue += character;
  markerCount = 1;
  queue = EMPTY;

  while (++index < length) {
    character = value.charAt(index);

    if (character !== C_RIGHT_BRACE) {
      // no newlines allowed in the attribute blocks
      if (character === C_NEWLINE) {
        return;
      }

      markerCount++;
      subvalue += queue + character;
      queue = EMPTY;
    } else if (character === C_RIGHT_BRACE) {
      subvalue += queue + C_RIGHT_BRACE;

      // eat trailing spacing because we don't even want this block to leave a linebreak in the output
      while (++index < length) {
        character = value.charAt(index);

        if (
          character !== C_TAB &&
          character !== C_SPACE &&
          character !== C_NEWLINE
        ) {
          break;
        }

        subvalue += character;
      }

      function parseBlockAttributes(attrString) {
        // e.g. {lang='JavaScript',starting-line=4,crop-start-line=4,crop-end-line=26}
        var matches = /{(.*?)}/.exec(attrString);
        var blockAttrs = {};

        if (!matches || !matches[1]) {
          console.log("WARNING: remark-cq unknown attrString", attrString);
          // hmm...
          return blockAttrs;
        }

        var pairs = splitNoParen(matches[1]);

        pairs.forEach(function(pair) {
          var kv = pair.split(/=\s*/);
          blockAttrs[kv[0]] = kv[1];
        });
        return blockAttrs;
      }

      __lastBlockAttributes = parseBlockAttributes(subvalue);

      if (__options.preserveEmptyLines) {
        return eat(subvalue)({ type: T_BREAK });
      } else {
        return eat(subvalue);
      }
    } else {
      return;
    }
  }
}
function tokenizeBlockInlineAttributeList(eat, value, silent) {
  var self = this;
  var index = -1;
  var length = value.length + 1;
  var subvalue = EMPTY;
  var character;
  var marker;
  var markerCount;
  var queue;

  // eat initial spacing
  while (++index < length) {
    character = value.charAt(index);

    if (character !== C_TAB && character !== C_SPACE) {
      break;
    }

    subvalue += character;
  }

  if (value.charAt(index) !== C_LEFT_BRACE) {
    return;
  }

  // ignore {{ thing }}
  if (value.charAt(index + 1) === C_LEFT_BRACE) {
    return;
  }

  // ignore {% thing %}
  if (value.charAt(index + 1) === C_PERCENT) {
    return;
  }

  marker = character;
  subvalue += character;
  markerCount = 1;
  queue = EMPTY;

  while (++index < length) {
    character = value.charAt(index);

    if (character !== C_RIGHT_BRACE) {
      // no newlines allowed in the attribute blocks
      if (character === C_NEWLINE) {
        return;
      }

      markerCount++;
      subvalue += queue + character;
      queue = EMPTY;
    } else if (character === C_RIGHT_BRACE) {
      subvalue += queue + C_RIGHT_BRACE;

      // eat trailing spacing because we don't even want this block to leave a linebreak in the output
      while (++index < length) {
        character = value.charAt(index);

        if (
          character !== C_TAB &&
          character !== C_SPACE &&
          character !== C_NEWLINE
        ) {
          break;
        }

        subvalue += character;
      }

      function parseBlockAttributes(attrString) {
        // e.g. {lang='JavaScript',starting-line=4,crop-start-line=4,crop-end-line=26}
        var matches = /{(.*?)}/.exec(attrString);
        var blockAttrs = {};

        if (!matches || !matches[1]) {
          console.log("WARNING: remark-cq unknown attrString", attrString);
          // hmm...
          return blockAttrs;
        }

        var pairs = splitNoParen(matches[1]);

        pairs.forEach(function(pair) {
          var kv = pair.split(/=\s*/);
          blockAttrs[kv[0]] = kv[1];
        });
        return blockAttrs;
      }

      __lastBlockAttributes = parseBlockAttributes(subvalue);

      if (__options.preserveEmptyLines) {
        return eat(subvalue)({ type: T_BREAK });
      } else {
        return eat(subvalue);
      }
    } else {
      return;
    }
  }
}
function tokenizeBlockInlineAttributeList ( eat , value , silent ) { var self = this ; var index = - 1 ; var length = value . length + 1 ; var subvalue = EMPTY ; var character ; var marker ; var markerCount ; var queue ; // eat initial spacing while ( ++ index < length ) { character = value . charAt ( index ) ; if ( character !== C_TAB && character !== C_SPACE ) { break ; } subvalue += character ; } if ( value . charAt ( index ) !== C_LEFT_BRACE ) { return ; } // ignore {{ thing }} if ( value . charAt ( index + 1 ) === C_LEFT_BRACE ) { return ; } // ignore {% thing %} if ( value . charAt ( index + 1 ) === C_PERCENT ) { return ; } marker = character ; subvalue += character ; markerCount = 1 ; queue = EMPTY ; while ( ++ index < length ) { character = value . charAt ( index ) ; if ( character !== C_RIGHT_BRACE ) { // no newlines allowed in the attribute blocks if ( character === C_NEWLINE ) { return ; } markerCount ++ ; subvalue += queue + character ; queue = EMPTY ; } else if ( character === C_RIGHT_BRACE ) { subvalue += queue + C_RIGHT_BRACE ; // eat trailing spacing because we don't even want this block to leave a linebreak in the output while ( ++ index < length ) { character = value . charAt ( index ) ; if ( character !== C_TAB && character !== C_SPACE && character !== C_NEWLINE ) { break ; } subvalue += character ; } function parseBlockAttributes ( attrString ) { // e.g. {lang='JavaScript',starting-line=4,crop-start-line=4,crop-end-line=26} var matches = / {(.*?)} / . exec ( attrString ) ; var blockAttrs = { } ; if ( ! matches || ! matches [ 1 ] ) { console . log ( "WARNING: remark-cq unknown attrString" , attrString ) ; // hmm... return blockAttrs ; } var pairs = splitNoParen ( matches [ 1 ] ) ; pairs . forEach ( function ( pair ) { var kv = pair . split ( / =\s* / ) ; blockAttrs [ kv [ 0 ] ] = kv [ 1 ] ; } ) ; return blockAttrs ; } __lastBlockAttributes = parseBlockAttributes ( subvalue ) ; if ( __options . preserveEmptyLines ) { return eat ( subvalue ) ( { type : T_BREAK } ) ; } else { return eat ( subvalue ) ; } } else { return ; } } }
Tokenise a block inline attribute list

@example
tokenizeBlockInlineAttributeList(eat, '{lang=javascript}');

@param {function(string)} eat - Eater.
@param {string} value - Rest of content.
@param {boolean?} [silent] - Whether this is a dry run.
@return {Node?|boolean} - `thematicBreak` node.
Tokenise a block inline attribute list