public static function consume()

in src/inlines/RawHTML.php [42:76]


  public static function consume(
    Context $context,
    string $string,
    int $offset,
  ): ?(Inline, int) {
    if (!$context->isHTMLEnabled()) {
      return null;
    }
    if ($string[$offset] !== '<') {
      return null;
    }

    $slice = Str\slice($string, $offset);

    $matches = darray[];
    if (
      \preg_match_with_matches(
        '/^('.self::OPEN_TAG.'|'.self::CLOSING_TAG.'|'.self::DECLARATION.')/i',
        $slice,
        inout $matches,
      ) === 1
    ) {
      $match = $matches[0];
      $offset += Str\length($match);
      return tuple(
        new self($match),
        $offset,
      );
    }

    return
      self::consumeHtmlComment($string, $offset)
      ?? self::consumeProcessingInstruction($string, $offset)
      ?? self::consumeCDataSection($string, $offset);
  }