private static function isRightFlankingDelimiterRun()

in src/inlines/Emphasis.php [406:433]


  private static function isRightFlankingDelimiterRun(
    string $markdown,
    int $start_offset,
    int $end_offset,
  ): bool {
    $len = Str\length($markdown);
    $next = $end_offset === $len ? '' : $markdown[$end_offset];
    $previous = $start_offset === 0 ? '' : $markdown[$start_offset - 1];

    if (self::endsWithWhitespace($markdown, $start_offset)) {
      return false;
    }

    $next_whitespace = self::startsWithWhitespace($markdown, $end_offset);
    $next_punctuation = C\contains_key(self::PUNCTUATION, $next);

    if ($next_whitespace || $next_punctuation) {
      return true;
    }

    // No intra-word `_` emphasis, but `*` is fine
    $previous_punctuation = C\contains_key(self::PUNCTUATION, $previous);
    if ((!$previous_punctuation) && $markdown[$start_offset] !== '_') {
      return true;
    }

    return false;
  }