public static function consume()

in src/unparsed-blocks/Paragraph.php [23:65]


  public static function consume(
    Context $context,
    Lines $lines,
  ): ?(Paragraph, Lines) {
    if ($context->isInParagraphContinuation()) {
      return null;
    }

    list($first, $lines) = $lines->getFirstLineAndRest();
    $matched = vec[$first];

    while (!$lines->isEmpty()) {
      list($next, $rest) = $lines->getFirstLineAndRest();
      if (Lines::isBlankLine($next)) {
        break;
      }

      if (!_Private\is_paragraph_continuation_text($context, $lines)) {
        break;
      }
      $matched[] = $next;
      $lines = $rest;
    }

    return tuple(
      new self(
        $matched
        |> Vec\map(
          $$,
          $line ==> {
            $line = Str\trim_left($line);
            if (Str\ends_with($line, '  ')) {
              return $line;
            }
            return Str\trim_right($line);
          },
        )
        |> Str\join($$, "\n")
        |> Str\trim_right($$),
      ),
      $lines,
    );
  }