Skip to content

Conversation

whilp
Copy link

@whilp whilp commented Aug 31, 2025

Fix fenced code block parsing to allow whitespace after opening backticks

The CommonMark specification (0.29 §4.5) allows whitespace between the opening code fence and the info string. Previously, parseInfo() would treat leading whitespace as part of parsing state, causing "``` sql" to be parsed as an empty tag instead of "sql".

This fix skips leading whitespace before parsing the tag name, ensuring both "sql" and " sql" are correctly recognized as SQL code blocks, per the CommonMark spec which states that the first word of the info string typically specifies the language for syntax highlighting.

Changes:

  • Modified parseInfo() in src/info.ts to skip leading whitespace before tag parsing
  • Updated test expectations to verify both formats work correctly
  • Both code blocks now properly render as Observable SQL blocks with hash IDs

I encountered this issue because I use comrak to autoformat markdown files. comrak normalizes markdown to include a space after the backticks.

…icks

The CommonMark specification (0.29 §4.5) allows whitespace between the opening
code fence and the info string. Previously, parseInfo() would treat leading
whitespace as part of parsing state, causing "``` sql" to be parsed as an empty
tag instead of "sql".

This fix skips leading whitespace before parsing the tag name, ensuring both
"```sql" and "``` sql" are correctly recognized as SQL code blocks, per the
CommonMark spec which states that the first word of the info string typically
specifies the language for syntax highlighting.

Changes:
- Modified parseInfo() in src/info.ts to skip leading whitespace before tag parsing
- Updated test expectations to verify both formats work correctly
- Both code blocks now properly render as Observable SQL blocks with hash IDs
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.

2 participants