private static function isLeftFlankingDelimiterRun()

in src/inlines/Emphasis.php [377:404]


  private static function isLeftFlankingDelimiterRun(
    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::startsWithWhitespace($markdown, $end_offset)) {
      return false;
    }

    $previous_punctuation = C\contains_key(self::PUNCTUATION, $previous);
    $previous_whitespace = self::endsWithWhitespace($markdown, $start_offset);

    if ($previous_whitespace || $previous_punctuation) {
      return true;
    }

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

    return false;
  }