Skip to content

fix(ruby): stricter block params, allowing bitwise OR - #4188

Open
dysonreturns wants to merge 2 commits into
highlightjs:mainfrom
dysonreturns:fix-4187-bitwise-or-pipe-symbol
Open

fix(ruby): stricter block params, allowing bitwise OR#4188
dysonreturns wants to merge 2 commits into
highlightjs:mainfrom
dysonreturns:fix-4187-bitwise-or-pipe-symbol

Conversation

@dysonreturns

Copy link
Copy Markdown

Block parenthesis, which are two pipe symbols are applicable after a do |param| or inside of an inline block { |param| ... }.

Resolves #4187

Changes

This change ensures the pipes |param| are preceded by an open bracket { or a do.
By being specific when these parenthesis occur, bitwise OR operations | don't read what follows as params indefinitely.

Checklist

  • Added markup tests, or they don't apply here because...
  • Updated the changelog at CHANGES.md

@jimtng

jimtng commented Oct 3, 2025

Copy link
Copy Markdown

Thanks! I've just noticed this bug too

Comment thread src/languages/ruby.js

const BLOCK_PARAMS = {
className: 'params',
begin: /(do|\{)\s\|(?!=)/,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we need a look-ahead for the do? How do we know it's going to have params at all? I feel like we need some new markup test cases here to make sure we get the expected behavior here.

Wouldn't this break?

setup do
  # code
end

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ping.

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.

(ruby) Bitwise OR pipe confused with Block Parenthesis pipes

3 participants