Skip to content

prism: fix asm block highlighting - #61

Merged
gapry merged 1 commit into
mainfrom
asm-color
Nov 26, 2026
Merged

gapry merged 1 commit into
mainfrom
asm-color

Conversation

@gapry

@gapry gapry commented Nov 26, 2026

Copy link
Copy Markdown
Owner

No description provided.

@amazon-q-developer

Copy link
Copy Markdown

Warning

Amazon Q Developer for GitHub: end of support

On January 30, 2027, AWS will discontinue support for the Amazon Q Developer for GitHub App. New app installations will no longer be available starting November 18, 2026.

For capabilities similar to the Amazon Q Developer for GitHub App, explore Kiro and the Kiro GitHub App. For more information about the end of support, see Amazon Q Developer end-of-support announcement on the AWS DevOps Blog.

@amazon-q-developer amazon-q-developer 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.

Review Summary

This PR migrates ASM block highlighting from HLJS to custom Prism grammars (x86asm, armasm-objdump, radare2) and cleans up the renderer accordingly. The approach is correct in structure, but there are two blocking logic bugs:

1. MarkdownRenderer.jsx — Custom languages registered on the wrong instance
PrismLight and PrismHighlighter are distinct instances from react-syntax-highlighter. Registering languages on PrismLight while rendering with PrismHighlighter means the custom languages are invisible to the renderer, so all three custom language blocks will silently fall back to plain-text highlighting. The fix is to alias PrismLight as PrismHighlighter (using only the light bundle), or register languages on PrismHighlighter instead.

2. radare2.js — r2-comment-variable rule is dead code due to ordering
Prism grammars are order-sensitive: the r2-variable rule is declared before r2-comment-variable and its pattern will always match first on the same input prefix (; arg/; var), leaving r2-comment-variable unreachable. Moving r2-comment-variable above r2-variable will restore its intended behavior.

Both issues need to be resolved before merging.


You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.

import 'katex/dist/katex.min.css';
import { Prism as PrismHighlighter } from 'react-syntax-highlighter';
import { Light as HLJSHighlighter } from 'react-syntax-highlighter';
import { Prism as PrismHighlighter, PrismLight } from 'react-syntax-highlighter';

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛑 Logic Error: PrismLight and PrismHighlighter are two separate instances — custom languages registered on PrismLight are not available to PrismHighlighter. The PrismCodeBlock component uses PrismHighlighter for rendering, so it will never find x86asm, armasm-objdump, or radare2, causing those blocks to fall back to plain text. Either register languages on PrismHighlighter directly, or switch the renderer component to PrismLight as well.

Suggested change
import { Prism as PrismHighlighter, PrismLight } from 'react-syntax-highlighter';
import { PrismLight as PrismHighlighter } from 'react-syntax-highlighter';

Comment on lines +57 to +60
'r2-comment-variable': {
pattern: /; (?:arg|var)\w+[^;\n]*/,
alias: 'ansi-blue',
},

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛑 Logic Error: r2-comment-variable (line 57–60) is ordered after r2-variable (line 43–56) in the grammar object. Prism evaluates rules in declaration order, so r2-variable with pattern /; (?:arg|var) .*/ will consume any matching ;arg/;var comment lines first, making r2-comment-variable unreachable dead code that never matches. Move r2-comment-variable before r2-variable to give it priority.

@gapry
gapry merged commit 6b4db64 into main Nov 26, 2026
2 checks passed
@gapry
gapry deleted the asm-color branch November 26, 2026 09:38
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