Skip to content

Conversation

gippole
Copy link

@gippole gippole commented Oct 4, 2025

Issue

Fixes CON-7465: Pycharm: Tables does not rendered correctly

Changes

  • The content of 'codeInline' was not included in the 'text' of the tree passed to remarkTables in remarkTables.tsx, so the content disappeared after rendering.
  • This has been fixed by adding the node contents within the paragraph.

Files Changed

remarkTables.tsx - Remark plugin for github-flavor markdown tables

Checklist

  • [] I've read the contributing guide
  • [] The relevant docs, if any, have been updated or created
  • [] The relevant tests, if any, have been updated or created

Screen recording or screenshot

before
before

after
after

Tests

Verified extension startup and functionality in VS Code debugging on macOS 15.6.1.


I have read the CLA Document and I hereby sign the CLA


Summary by cubic

Fixes CON-7465 by restoring correct GFM table rendering in Markdown previews. Inline content (like inline code and emphasis) inside table cells is now preserved.

  • Bug Fixes
    • Include all paragraph child nodes (not just text) when building the table parsing buffer.
    • Track node positions to split and keep content before/after tables.
    • Render inline nodes to strings for regex matching to avoid losing formatting.

@gippole gippole requested a review from a team as a code owner October 4, 2025 22:24
@gippole gippole requested review from sestinj and removed request for a team October 4, 2025 22:24
@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Oct 4, 2025
Copy link

github-actions bot commented Oct 4, 2025

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 1 file

Prompt for AI agents (all 1 issues)

Understand the root cause of the following 1 issues and fix them.


<file name="gui/src/components/StyledMarkdownPreview/utils/remarkTables.tsx">

<violation number="1" location="gui/src/components/StyledMarkdownPreview/utils/remarkTables.tsx:171">
Clearing the tracked child positions here means subsequent tables in the same paragraph keep their raw markdown text, so a second table renders twice (once as text, once as a table). This regresses multi-table paragraphs.</violation>
</file>


Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Ask questions if you need clarification on any suggestion

React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai to give feedback, ask questions, or re-run the review.

newNodes.push(...afterNodes);

// Mark positions as consumed
positions.length = 0;
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Oct 4, 2025

Choose a reason for hiding this comment

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

Clearing the tracked child positions here means subsequent tables in the same paragraph keep their raw markdown text, so a second table renders twice (once as text, once as a table). This regresses multi-table paragraphs.

Prompt for AI agents
Address the following comment on gui/src/components/StyledMarkdownPreview/utils/remarkTables.tsx at line 171:

<comment>Clearing the tracked child positions here means subsequent tables in the same paragraph keep their raw markdown text, so a second table renders twice (once as text, once as a table). This regresses multi-table paragraphs.</comment>

<file context>
@@ -104,16 +129,46 @@ export function remarkTables() {
+          newNodes.push(...afterNodes);
+
+          // Mark positions as consumed
+          positions.length = 0;
         } catch (e) {
           console.error(&quot;Failed to parse markdown table after regex match&quot;, e);
</file context>
Fix with Cubic

Copy link
Author

Choose a reason for hiding this comment

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

This is intentional. All elements in positions are consumed at this stage, so the variable won’t be referenced again later. Thanks for pointing it out, though!

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks, I've learnt: "In remarkTables, the positions array is fully consumed when constructing before/after nodes around a parsed table; it is not used later, so clearing positions.length = 0 at that point is intentional. In future reviews, verify whether a tracking array/variable is referenced later before flagging its clearing as a regression.".

Edit this learning here.

@gippole
Copy link
Author

gippole commented Oct 4, 2025

I have read the CLA Document and I hereby sign the CLA

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size:M This PR changes 30-99 lines, ignoring generated files.
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

1 participant