Fix render_markdown element#391
Conversation
|
All contributors have signed the CLA ✍️ ✅ |
|
I have read the CLA Document and I hereby sign the CLA |
Greptile SummaryFixes the root cause of issue #388 by changing Confidence Score: 4/5Safe to merge; one minor cosmetic issue with trailing newlines in highlighted code blocks Only P2 findings — the trailing-newline issue causes a cosmetic empty line in syntax-highlighted blocks but no functional breakage src/components/runbooks/editor/components/Markdown.tsx — trailing newline trim on code block content Important Files Changed
Reviews (1): Last reviewed commit: "feat(markdown_render): add syntax highli..." | Re-trigger Greptile |
| const firstChild = element.firstElementChild; | ||
| if (firstChild?.tagName === "CODE") { | ||
| return ( | ||
| <MarkdownCodeBlock |
There was a problem hiding this comment.
Trailing newline produces empty last line in highlighted blocks
micromark emits <code class="language-ts">const x = 1;\n</code> — the text content always ends with \n. Passing that directly to Highlight causes prism-react-renderer to emit a final empty token line, adding a blank row at the bottom of every highlighted code block.
| <MarkdownCodeBlock | |
| code={firstChild.textContent?.replace(/\n$/, "") ?? ""} |
Change Summary
This fixes markdown rendering and applies GitHub style CSS.
Motivation and details
The
render_markdownelement didn't properly render all markdown it would receive from a variable (see #388). This was caused by joining multiple lines with\ncharacters. After solving this issue, I have styled the rendered markdown according to GitHub's style.Note that OpenAI Codex was used with GPT 5.5 xhigh to assist during development of these changes. I have manually tested and confirmed the changes are good both in light mode and dark mode.
Before
After
Tasks
docs/(if any application behavior has changed)