Skip to content

Conversation

@jonathanhefner
Copy link

⚠️ Disclaimer: This was vibe-coded. I am not a PHP developer, but I am helping https://github.com/modelcontextprotocol/php-sdk set up documentation using phpDocumentor, and I encountered this issue. I guided Claude through the investigation and self-review, but I am unable to personally judge the fix.


CodeBlockParser::parse() stored the fenced code info string in options['caption'] via withOptions(), but nothing ever read that value — CodeNode::getCaption() returns the typed $caption property, not getOption('caption'). As a result, CodeNode::getLanguage() always returned null for markdown code blocks, producing class="language-" in the rendered HTML and preventing syntax highlighting.

Replace the dead withOptions(['caption' => ...]) call with setLanguage() using getInfoWords()[0] from the CommonMark FencedCode node, matching both the RST parser's behavior (CodeBlockDirective) and league/commonmark's own FencedCodeRenderer.

`CodeBlockParser::parse()` stored the fenced code info string in
`options['caption']` via `withOptions()`, but nothing ever read that
value — `CodeNode::getCaption()` returns the typed `$caption` property,
not `getOption('caption')`. As a result, `CodeNode::getLanguage()`
always returned `null` for markdown code blocks, producing
`class="language-"` in the rendered HTML and preventing syntax
highlighting.

Replace the dead `withOptions(['caption' => ...])` call with
`setLanguage()` using `getInfoWords()[0]` from the CommonMark
`FencedCode` node, matching both the RST parser's behavior
(`CodeBlockDirective`) and league/commonmark's own `FencedCodeRenderer`.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant