public function filter()

in src/MarkdownExt/SyntaxHighlightingFilter.hack [32:65]


  public function filter(
    Markdown\RenderContext $context,
    Markdown\ASTNode $node,
  ): vec<Markdown\ASTNode> {
    if (!$node is CodeBlock) {
      return vec[$node];
    }
    if ($context is namespace\RenderContext) {
      if ($context->getOutputFormat() !== OutputFormat::HTML) {
        return vec[$node];
      }
    }

    $info = $node->getInfoString();
    if ($info is null || (!C\contains_key(self::KEYWORDS, $info))) {
      return vec[$node];
    }

    try {
      /* HHAST_IGNORE_ERROR[DontUseAsioJoin] */
      $ast = \HH\Asio\join(HHAST\from_file_async(
        HHAST\File::fromPathAndContents('__DATA__', $node->getCode()),
      ));
    } catch (\Exception $_) {
      return vec[$node];
    }
    return vec[new Markdown\Blocks\HTMLBlock(
      '<pre><code class="language-'.
      $info.
      '">'.
      self::getHTML($ast).
      "</code></pre>\n",
    )];
  }