Consume lines for a code block
192531
protected function consumeCode($lines, $current)
	{
		// consume until }}}
		$content = [];
		for ($i = $current + 1, $count = count($lines); $i < $count; $i++) {
			$line = rtrim($lines[$i]);
			if (strcmp($line, '}}}') !== 0) {
				$content[] = $line;
			} else {
				break;
			}
		}
		$block = [
			'code',
			'content' => implode("\n", $content),
		];
		return [$block, $i];
	}
69386
def parse_block(self, stream, has_end):
        
        statements = []
        while 1:
            self.skip_whitespace_or_comment(stream)

            if has_end(stream):
                return statements

            statement = self.parse_statement(stream)
            if isinstance(statement, EmptyValueAtLine):
                if len(statements) == 0:
                    self.raise_unexpected(stream)
                self.skip_whitespace_or_comment(stream)
                value = self.parse_value(stream)
                last_statement = statements.pop(-1)
                fixed_last = (
                    last_statement[0],
                    statement
                )
                statements.append(fixed_last)
                statements.append((last_statement[1], value))

            else:
                statements.append(statement)
348555
function tokenizeAnnotatedBlockquote(eat, value, silent) {
    var self = this;
    var offsets = self.offset;
    var tokenizers = self.blockTokenizers;
    var interruptors = self.interruptBlockquote;
    var now = eat.now();
    var currentLine = now.line;
    var length = value.length;
    var values = [];
    var contents = [];
    var indents = [];
    var add;
    var index = 0;
    var character;
    var rest;
    var nextIndex;
    var content;
    var line;
    var startIndex;
    var prefixed;
    var exit;
    var blockType;

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

        if (
            character !== space &&
            character !== tab &&
            !character.match(/[A-Z]/)
        ) {
            break;
        }

        // store the block type
        if (character.match(/[A-Z]/)) {
            switch (character) {
                case "A":
                    blockType = "aside";
                    break;
                case "W":
                    blockType = "warning";
                    break;
                case "T":
                    blockType = "tip";
                    break;
                case "E":
                    blockType = "error";
                    break;
                case "I":
                    blockType = "information";
                    break;
                case "Q":
                    blockType = "questions";
                    break;
                case "D":
                    blockType = "discussions";
                    break;
                case "X":
                    blockType = "exercises";
                    break;
                default:
                    blockType = "generic";
            }
        }

        index++;
    }

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

    if (silent) {
        return true;
    }

    index = 0;

    while (index < length) {
        nextIndex = value.indexOf(lineFeed, index);
        startIndex = index;
        prefixed = false;

        if (nextIndex === -1) {
            nextIndex = length;
        }

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

            if (
                character !== space &&
                character !== tab &&
                !character.match(/[A-Z]/)
            ) {
                break;
            }

            index++;
        }

        if (value.charAt(index) === greaterThan) {
            index++;
            prefixed = true;

            if (value.charAt(index) === space) {
                index++;
            }
        } else {
            index = startIndex;
        }

        content = value.slice(index, nextIndex);

        if (!prefixed && !trim(content)) {
            index = startIndex;
            break;
        }

        if (!prefixed) {
            rest = value.slice(index);

            // Check if the following code contains a possible block.
            if (interrupt(interruptors, tokenizers, self, [eat, rest, true])) {
                break;
            }
        }

        line =
            startIndex === index ? content : value.slice(startIndex, nextIndex);

        indents.push(index - startIndex);
        values.push(line);
        contents.push(content);

        index = nextIndex + 1;
    }

    index = -1;
    length = indents.length;
    add = eat(values.join(lineFeed));

    while (++index < length) {
        offsets[currentLine] = (offsets[currentLine] || 0) + indents[index];
        currentLine++;
    }

    exit = self.enterBlock();
    contents = self.tokenizeBlock(contents.join(lineFeed), now);
    exit();

    return add({
        type: "blockquote",
        blockType: blockType,
        children: contents
    });
}
870960
def load_lines(self, key, noexpire=None):
        ''''''
        return line_iterator(self.load_fd(key, noexpire=noexpire))
382554
function parser ( temp, line, block, file, from, to, options ) {

    var parts           = line.replace( /.*@/, '' );
    var index           = indexer( parts, ' ' ) || indexer( parts, '\n' ) || indexer( parts, '\r' ) || parts.length;
    var name            = _dss.trim( parts.substr( 0, index ) );
    var output          = {
      options: options,
      file: file,
      name: name,
      line: {
        contents: _dss.trim( parts.substr( index ) ),
        from: block.indexOf( line ),
        to: block.indexOf( line )
      },
      block: {
        contents: block,
        from: from,
        to: to
      }
    };

    // find the next instance of a parser (if there is one based on the @ symbol)
    // in order to isolate the current multi-line parser
    var nextParserIndex = block.indexOf( '* @', output.line.from + 1 );
    var markupLength = ( nextParserIndex > -1 ) ? nextParserIndex - output.line.from : block.length;
    var contents = block.split( '' ).splice( output.line.from , markupLength ).join( '' );
    var parserMarker = '@' + name;
    contents = contents.replace( parserMarker, '' );

    // Redefine output contents to support multiline contents
    output.line.contents = ( function( contents ) {
      var ret = [];
      var lines = contents.split( '\n' );

      lines.forEach( function( line, i ) {

        var pattern = '*';
        var index = line.indexOf( pattern );

        if ( index >= 0 && index < 10 ) {
          line = line.split( '' ).splice( ( index + pattern.length ), line.length ).join( '' );
        }

        // Trim whitespace from the the first line in multiline contents
        if ( i === 0 ) {
          line = _dss.trim( line );
        }

        if ( line && line.indexOf( parserMarker ) == -1 ) {
          ret.push( line );
        }

      });

      return ret.join( '\n' );

    })( contents );

    line = {};
    line[ name ] = ( _dss.parsers[ name ] ) ? _dss.parsers[ name ].call( output ) : output.line.contents;

    if ( temp[ name ] ) {
      if ( !_dss.isArray( temp[ name ] ) ) {
        temp[name] = [ temp[ name ] ];
      }
      if ( !_dss.isArray( line[ name ] ) ) {
        temp[ name ].push( line[ name ] );
      } else {
        temp[ name ].push( line[ name ][ 0 ] );
      }
    } else {
      temp = _dss.extend( temp, line );
    }
    return temp;
  }
950065
def insert_line(self, line):
        """"""
        if self.current_block is not None:
            self.current_block.append(line)
        else:
            self.header.append(line)
348922
def block(self, *blocks, **kwargs) -> "CodeBlock":
        
        assert "name" not in kwargs
        kwargs.setdefault("code", self)
        code = CodeBlock(**kwargs)
        for block in blocks:
            if block is not None:
                code._blocks.append((0, block))
        return code
1163201
function(forBlock) {
		var entities = [];

		var endingOnValue = forBlock ? 'ENDBLK' : 'ENDSEC';

		if (!forBlock) {
			curr = scanner.next();
		}
		while(true) {

			if(curr.code === 0) {
				if(curr.value === endingOnValue) {
					break;
				}

				var entity;
				var handler = self._entityHandlers[curr.value];
				if(handler != null) {
					log.debug(curr.value + ' {');
					entity = handler.parseEntity(scanner, curr);
					curr = scanner.lastReadGroup;
					log.debug('}');
				} else {
					log.warn('Unhandled entity ' + curr.value);
					curr = scanner.next();
					continue;
				}
				ensureHandle(entity);
				entities.push(entity);
			} else {
				// ignored lines from unsupported entity
				curr = scanner.next();
			}
		}
		if(endingOnValue == 'ENDSEC') curr = scanner.next(); // swallow up ENDSEC, but not ENDBLK
		return entities;
	}
885643
function (block) {
        es.readArray([
          '<!--',
          '  processed by htmlbuild',
          '-->'
        ].map(function (str) {
          return block.indent + str;
        })).pipe(block);
      }
460678
def _get_blocks(lines):
    
    cur_block = []
    pre_lang = None
    pre_in_code = None
    for (l, in_code, cur_lang, _) in _parse_code_lines(lines):
        if in_code != pre_in_code:
            if pre_in_code and len(cur_block) >= 2:
                cur_block = cur_block[1:-1] # remove ```
            # remove empty lines at head
            while len(cur_block) > 0:
                if len(cur_block[0]) == 0:
                    cur_block.pop(0)
                else:
                    break
            # remove empty lines at tail
            while len(cur_block) > 0:
                if len(cur_block[-1]) == 0:
                    cur_block.pop()
                else:
                    break
            if len(cur_block):
                yield (pre_in_code, pre_lang, cur_block)
            cur_block = []
        cur_block.append(l)
        pre_lang = cur_lang
        pre_in_code = in_code
    if len(cur_block):
        yield (pre_in_code, pre_lang, cur_block)
373827
def tokenize_block(iterable, token_types):
    
    lines = FileWrapper(iterable)
    parse_buffer = ParseBuffer()
    line = lines.peek()
    while line is not None:
        for token_type in token_types:
            if token_type.start(line):
                result = token_type.read(lines)
                if result is not None:
                    parse_buffer.append((token_type, result))
                    break
        else:  # unmatched newlines
            next(lines)
            parse_buffer.loose = True
        line = lines.peek()
    return parse_buffer
1084379
def _filter(self, text, context, encoding):
        """"""

        content = []
        self.current_encoding = encoding
        self.line_num = 1
        self.prev_line = -1
        self.leading = ''
        self.block_comments = []
        self.line_comments = []

        self.find_content(text)
        self.extend_src(content, context)

        return content
580694
protected function consumeFencedCode($lines, $current) {
		list($block, $i) = parent::consumeFencedCode($lines, $current);

		if (empty($block['language'])) {
			$block['language'] = 'php';
		}
		return [$block, $i];
	}
1105022
function(block) {
  switch(block.t) {
    case 'Paragraph':
    case 'SetextHeader':
    case 'ATXHeader':
      block.inline_content =
        this.inlineParser.parse(block.string_content.trim(), this.refmap);
      block.string_content = "";
      break;
    default:
      break;
  }

  if (block.children) {
    for (var i = 0; i < block.children.length; i++) {
      this.processInlines(block.children[i]);
    }
  }

}
207308
function breaklines () {
  return through2.obj(function (chunk, _, cb) {
    String(chunk)
      .split('\n')
      .filter(Boolean)
      .forEach(line => this.push(line))
    cb()
  })
}
539351
def get_codeblock_node(self, code, language):
        

        # type: () -> List[nodes.Node]
        document = self.state.document
        location = self.state_machine.get_source_and_line(self.lineno)

        linespec = self.options.get('emphasize-lines')
        if linespec:
            try:
                nlines = len(code.split('\n'))
                hl_lines = parselinenos(linespec, nlines)
                if any(i >= nlines for i in hl_lines):
                    log.warning(__('line number spec is out of range(1-%d): %r') %
                                   (nlines, self.options['emphasize-lines']),
                                   location=location)

                hl_lines = [x + 1 for x in hl_lines if x < nlines]
            except ValueError as err:
                return [document.reporter.warning(str(err), line=self.lineno)]
        else:
            hl_lines = None

        if 'dedent' in self.options:
            location = self.state_machine.get_source_and_line(self.lineno)
            lines = code.split('\n')
            lines = dedent_lines(lines, self.options['dedent'], location=location)
            code = '\n'.join(lines)

        literal = nodes.literal_block(code, code)
        literal['language'] = language
        literal['linenos'] = 'linenos' in self.options or \
                             'lineno-start' in self.options
        literal['classes'] += self.options.get('class', [])
        extra_args = literal['highlight_args'] = {}
        if hl_lines is not None:
            extra_args['hl_lines'] = hl_lines
        if 'lineno-start' in self.options:
            extra_args['linenostart'] = self.options['lineno-start']
        set_source_info(self, literal)

        caption = self.options.get('caption')
        if caption:
            try:
                literal = container_wrapper(self, literal, caption)
            except ValueError as exc:
                return [document.reporter.warning(text_type(exc), line=self.lineno)]

        # literal will be note_implicit_target that is linked from caption and numref.
        # when options['name'] is provided, it should be primary ID.
        self.add_name(literal)

        return [literal]
1154567
def iterateBlocksFrom(block):
        
        count = 0
        while block.isValid() and count < MAX_SEARCH_OFFSET_LINES:
            yield block
            block = block.next()
            count += 1