Skip to content

fix: allow spaces around the language name in fenced code blocks (fixes #62) - #123

Open
Ultroncn wants to merge 2 commits into
developit:mainfrom
Ultroncn:fix/fenced-code-language-spaces
Open

Ultroncn wants to merge 2 commits into
developit:mainfrom
Ultroncn:fix/fenced-code-language-spaces

Conversation

@Ultroncn

Copy link
Copy Markdown

Problem

A fenced code block whose info string has spaces around the language name is not recognized at all and passes through literally:

snarkdown('```js \ncode\n```')
// before: "```js \ncode\n```"  (literal, unparsed)
// after:  "<pre class=\"code js\"><code class=\"language-js\">code</code></pre>"

Same for a trailing tab (js\t`) or spaces on both sides ( js ). A leading space already worked (^``` (\w)`), the trailing side did not. Reported in #62.

Change

One change in the tokenizer in src/index.js — the fence-opening pattern now allows spaces/tabs on both sides of the language name:

-(?:^``` *(\w*)\n...
+(?:^```[ \t]*(\w*)[ \t]*\n...

Tests

Added a test in test/index.js (code & quotes suite) covering trailing space, both-side spaces, trailing tab, and a bare fence with a trailing space. Verified it fails on the old code (first assertion: expected literal passthrough to equal the parsed <pre> output). Full suite: npm test (eslint + mocha) — 34 passing, 0 failing.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-18T00:21:38.198961Z c8c1a46 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c8c1a46c0c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/index.js Resolved
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