@shinyaz

rehype-pretty-code breaks on code blocks without a language identifier

1 min read

A TIL entry's code block wasn't rendering correctly on the page. The fenced block started with bare ``` and had no language identifier.

This blog uses rehype-pretty-code for syntax highlighting. Without a language, the parser fails to tokenize the content properly and the resulting HTML structure breaks.

- ```
+ ```text
  # Content creation ({type}-guide)
  post-guide
  til-guide

For plain text, directory trees, or pseudo-code, text works as a safe default. This isn't specific to rehype-pretty-code — shiki-based highlighters generally expect a language identifier, so always specifying one in MDX is a good habit.

Share this post

Shinya Tahara

Shinya Tahara

Solutions Architect @ AWS

I'm a Solutions Architect at AWS, providing technical guidance primarily to financial industry customers. I share learnings about cloud architecture and AI/ML on this site.The views and opinions expressed on this site are my own and do not represent the official positions of my employer.