Syntax highlighting using Prism.parse_lex#1704
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request replaces the Ruby syntax-highlighting/tokenization pipeline with a Prism-based implementation (Prism.parse_lex), removing the prior Ripper-based lexer and adjusting HTML/CSS/test expectations accordingly. This aligns RDoc’s Ruby parsing/highlighting with Prism’s token stream while improving handling of interpolated literals and previously crashing edge cases.
Changes:
- Switch Ruby parsing/token collection to
Prism.parse_lexand introduceRDoc::Parser::RubyColorizerfor producing a colored token stream. - Update HTML generation + CSS to reflect new token kinds and finer-grained tokenization (no more
ruby-node). - Refresh and add tests covering partial colorization, interpolation, heredocs, multibyte content, and method token streams.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| lib/rdoc/parser/ruby.rb | Uses Prism.parse_lex tokens and delegates node-range highlighting to RubyColorizer. |
| lib/rdoc/parser/ruby_colorizer.rb | New Prism-based colorizer producing ColoredToken streams for full/partial ranges. |
| lib/rdoc/token_stream.rb | Updates token kind → CSS class mapping to match new colorizer output. |
| lib/rdoc/markup/to_html.rb | Uses RubyColorizer for Ruby verbatim highlighting instead of the removed Ripper lexer. |
| lib/rdoc/generator/markup.rb | Removes Ruby-specific indentation prepend that relied on :char_no from the old lexer. |
| lib/rdoc/parser/ripper_state_lex.rb | Removed (drops Ripper dependency for tokenization). |
| lib/rdoc/generator/template/darkfish/css/rdoc.css | Removes .ruby-node styling. |
| lib/rdoc/generator/template/aliki/css/rdoc.css | Removes .ruby-node styling (including dark theme selector). |
| test/rdoc/rdoc_token_stream_test.rb | Updates token kinds and expected HTML spans to match new mapping. |
| test/rdoc/parser/ruby_test.rb | Adds coverage for code-object token stream text output. |
| test/rdoc/parser/ruby_colorizer_test.rb | New tests validating Prism-based colorization across multiple Ruby constructs. |
| test/rdoc/markup/to_html_test.rb | Updates expectations to match new token splitting/interpolation handling. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+97
to
+101
| if ntok && (!ptok || ntok[2] <= ptok[1]) | ||
| token = normal_tokens.shift | ||
| else | ||
| token = prior_tokens.shift | ||
| end |
kou
approved these changes
May 10, 2026
st0012
approved these changes
May 10, 2026
Completely drops Ripper dependency
9fc7427 to
78ea670
Compare
Collaborator
|
🚀 Preview deployment available at: https://bd4fca4d.rdoc-6cd.pages.dev (commit: 78ea670) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Completely drops ripper dependency.
Drops
ruby-nodecss class used to colorize dstring and backrefbackref(
$&) is now colored as identifier, same as global variable.dstring(
"#{expr}",`#{expr}`) is now colored as string. Embedded expression parts are colored separately.Stops token squashing:
"string"was a single string token. Changed to"+string+""string#{:symbol}"was a single dstring token. Changed to string tokens"string#{}".:and `symbol is colorized as symbol color.So there should be lots of diff.
Before


After
Fix some unkown bugs