protected static function consumePrefixedChunk()

in src/unparsed-blocks/BlockQuote.php [94:137]


  protected static function consumePrefixedChunk(
    Context $_context,
    Lines $lines,
  ): ?(vec<(int, string)>, Lines) {
    $contents = vec[];
    while (!$lines->isEmpty()) {
      list($col, $line, $rest) = $lines->getColumnFirstLineAndRest();
      list($_, $line, $n) = Lines::stripUpToNLeadingWhitespace(
        $line,
        3,
        $col,
      );
      $col = $col + $n;

      if (Str\starts_with($line, '> ')) {
        $line = Str\slice($line, 2);
        $col += 2;
      } else if (Str\starts_with($line, ">\t")) {
        $col += 1; // >
        $tab_width = 4 - ($col % 4);
        $col += 1; // \t

        $line = Str\slice($line, 2);

        if ($tab_width === 0) {
          $tab_width = 4;
        }
        $line = Str\repeat(' ', $tab_width - 1).$line;
      } else if (Str\starts_with($line, '>')) {
        $line = Str\slice($line, 1);
        $col += 1;
      } else {
        break;
      }

      $contents[] = tuple($col, $line);
      $lines = $rest;
    }

    if (C\is_empty($contents)) {
      return null;
    }
    return tuple($contents, $lines);
  }