GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(rich-markdown-editor): strict, provenance-aware markdown paste by waleedlatif1 · Pull Request #5463 · simstudioai/sim

Conversation

@waleedlatif1

@waleedlatif1 waleedlatif1 commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

Pasting code-like text such as 5 * width * height was being italicized ("width" became emphasis) by StarterKit's lenient mark paste rules. This makes markdown paste strict and correct — matching Obsidian/Linear.

  • Disable StarterKit's mark paste rules (enablePasteRules: false on both editor variants). Emphasis is owned by MarkdownPaste (strict CommonMark via marked) on the plain-text path and by real HTML tags on the DOM path. Input rules (typing *x* → italic) are unaffected — they're a separate mechanism.
  • Provenance-aware paste gate. Structural markdown (headings, lists, tables, blockquotes, fenced code, links, **bold**) always parses from the plain-text sibling — our parser is more faithful for GFM alignment/escaping. Inline-only marks (`*_ ~~ ``) parse for a plain-text-only paste, but defer to a rich HTML sibling (its presence signals a rich source that may carry structure the plain text can't — so a copied table isn't flattened).

Behavior (verified)

  • Renders: *italic*, _italic_, **bold**, __bold__, ~~strike~~, `code`, and all block constructs.
  • Stays literal (strict CommonMark flanking): 5 * width * height, def foo(*args, **kwargs), snake_case, file_path_here, URLs with underscores.
  • A copied table whose plain-text sibling contains an inline mark is preserved (not flattened).
  • Typing, read-only, and code-block paste all behave correctly.

Type of Change

  • Bug fix

Testing

Committed unit tests cover the full gate matrix (constructs render, inline-only defers to HTML, code-like text isn't emphasized, structural parses with an HTML sibling, read-only/code-block/empty). Behavior additionally verified end-to-end in a real-browser paste harness (25 cases + typing/input-rule audit).

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

greptile-apps[bot] reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@waleedlatif1
fix(rich-markdown-editor): strict, provenance-aware markdown paste
c92eb17
Pasting code-like text such as `5 * width * height` was italicized by StarterKit's lenient mark
paste rules. Own emphasis with the strict CommonMark parser instead:

- Disable StarterKit's mark paste rules (`enablePasteRules: false`); markdown paste is handled by
  MarkdownPaste (marked) and rich paste by real HTML tags. Input rules (typing) are unaffected.
- Split the paste gate by provenance: structural markdown always parses (faithful GFM tables and
  escaping), while inline-only marks parse for a plain-text paste but defer to a rich HTML sibling so
  a copied table isn't flattened.

Emphasis (`*_ ** __ ~~ ``) renders; `5 * width`, `*args`, and `snake_case` stay literal — matching
Obsidian/Linear.
@vercel

vercel Bot commented Jul 7, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Jul 7, 2026 2:49am

Request Review

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@cursor

cursor Bot commented Jul 7, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

PR Summary

Medium Risk
User-facing paste behavior changes across both editor surfaces, but scope is limited to the rich markdown editor and is covered by an expanded unit test matrix.

Overview
Fixes pasted code-like text (e.g. 5 * width * height) being wrongly emphasized by turning off StarterKit mark paste rules (enablePasteRules: false on the file editor and modal field). Inline formatting on paste now goes through strict CommonMark parsing or real HTML, not StarterKit’s lenient rules; typing input rules are unchanged.

MarkdownPaste now splits clipboard detection into structural hints (headings, lists, tables, links, **bold**, etc.)—always parsed from text/plain, even when text/html is present—and inline-only hints (*italic*, ~~strike~~, `code`), which parse only for plain-text-only pastes and defer to the HTML path when a rich sibling exists so tables and other structure aren’t flattened. Pastes inside inline code are skipped like code blocks.

Tests cover the full gate matrix: inline marks render on plain paste, defer with HTML, code-like strings stay literal under strict flanking, and inline-code paste stays literal.

Reviewed by Cursor Bugbot for commit aefb444. Configure here.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@greptile-apps

greptile-apps Bot commented Jul 7, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR replaces StarterKit's lenient mark paste rules with a provenance-aware two-tier markdown paste gate, fixing the bug where code-like expressions such as 5 * width * height were incorrectly italicized on paste.

  • STRUCTURAL_MARKDOWN_HINTS (headings, **bold**, links, lists, blockquotes, fenced code, GFM tables) always force the strict marked-based parser, even when an HTML sibling is present — preserving GFM table alignment and custom escaping.
  • INLINE_MARK_HINTS (*italic*, _italic_, ~~strike~~, `code`) parse only when no HTML sibling exists; if an HTML sibling is present the DOM path is used so rich structure is not flattened.
  • enablePasteRules: false is added to both editor variants to disable StarterKit's lenient mark paste rules; a new guard on editor.isActive('code') prevents the handler from intercepting pastes inside inline-code spans.

Confidence Score: 5/5

The change is safe to merge — it narrows a paste interception bug with a well-structured two-tier gate backed by a comprehensive test suite covering every branch of the new logic.

The two-tier gate (structural vs. inline-only), the HTML-sibling deferral, and the inline-code guard all correctly handle the edge cases described. The marked strict-CommonMark parser preserves non-markdown text byte-for-byte, so the over-claiming in INLINE_MARK_HINTS is provably safe. Tests cover the full gate matrix including the new paths. No data-loss or auth risk is introduced.

No files require special attention.

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/rich-markdown-editor/markdown-paste.ts Core logic rewritten: splits hints into STRUCTURAL (always parse) and INLINE (defer to HTML sibling if present), adds inline-code guard. Logic is sound and well-commented.
apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/rich-markdown-editor/markdown-paste.test.ts Test suite expanded with the full gate matrix: inline-code guard, deferral to HTML sibling, byte-for-byte literal pass-through for space-flanked asterisks/kwargs/snake_case, and underscore bold/italic variants.
apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/rich-markdown-editor/rich-markdown-editor.tsx Single-line change: adds enablePasteRules: false to the useEditor options to disable StarterKit's lenient mark paste rules.
apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/rich-markdown-editor/rich-markdown-field.tsx Single-line change: adds enablePasteRules: false to the useEditor options, mirroring the editor variant for consistency.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Paste event] --> B{editor.isEditable?}
    B -- No --> Z[return false\ndefault handler]
    B -- Yes --> C{isActive codeBlock\nor inline code?}
    C -- Yes --> Z
    C -- No --> D{text/plain present?}
    D -- No --> Z
    D -- Yes --> E{STRUCTURAL_MARKDOWN_HINTS\nmatch?}
    E -- Yes --> H[parseMarkdownToDoc\nmarked / strict CommonMark]
    E -- No --> F{INLINE_MARK_HINTS\nmatch?}
    F -- No --> Z
    F -- Yes --> G{text/html sibling\npresent?}
    G -- Yes --> Z2[return false\nDOM path handles HTML sibling]
    G -- No --> H
    H --> I{doc has content?}
    I -- No --> Z
    I -- Yes --> J[insertContent\nreturn true]
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A[Paste event] --> B{editor.isEditable?}
    B -- No --> Z[return false\ndefault handler]
    B -- Yes --> C{isActive codeBlock\nor inline code?}
    C -- Yes --> Z
    C -- No --> D{text/plain present?}
    D -- No --> Z
    D -- Yes --> E{STRUCTURAL_MARKDOWN_HINTS\nmatch?}
    E -- Yes --> H[parseMarkdownToDoc\nmarked / strict CommonMark]
    E -- No --> F{INLINE_MARK_HINTS\nmatch?}
    F -- No --> Z
    F -- Yes --> G{text/html sibling\npresent?}
    G -- Yes --> Z2[return false\nDOM path handles HTML sibling]
    G -- No --> H
    H --> I{doc has content?}
    I -- No --> Z
    I -- Yes --> J[insertContent\nreturn true]
Loading

Reviews (3): Last reviewed commit: "fix(rich-markdown-editor): keep paste li..." | Re-trigger Greptile

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

greptile-apps[bot]
greptile-apps Bot reviewed Jul 7, 2026
View reviewed changes
Comment thread .../workspace/[workspaceId]/files/components/file-viewer/rich-markdown-editor/markdown-paste.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

@waleedlatif1
test(rich-markdown-editor): assert code-like pastes are claimed but p…
4bf7547
…reserved byte-for-byte

The gate is intentionally lenient — a precise CommonMark-emphasis matcher would risk missing real
emphasis. Over-claiming is safe because the strict parser (marked) preserves non-markdown exactly;
assert the handler claims the paste and returns the input unchanged, not just that no mark is added.
@vercel
vercel Bot temporarily deployed to Preview July 7, 2026 02:32 Inactive
@waleedlatif1

waleedlatif1 commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator Author

@cursor review

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@waleedlatif1

waleedlatif1 commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator Author

@greptile review

greptile-apps[bot] reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

cursor[bot]
cursor Bot reviewed Jul 7, 2026
View reviewed changes
Comment thread .../workspace/[workspaceId]/files/components/file-viewer/rich-markdown-editor/markdown-paste.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

@waleedlatif1
fix(rich-markdown-editor): keep paste literal inside inline code too
aefb444
The paste handler skipped a fenced code block but not the inline code mark. Now that inline marks
gate the parse, pasting `*italic*` inside inline code would render rich instead of staying literal —
extend the code-context guard to editor.isActive('code').
@vercel
vercel Bot temporarily deployed to Preview July 7, 2026 02:49 Inactive
@waleedlatif1

waleedlatif1 commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator Author

@cursor review

cursor[bot] reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@waleedlatif1

waleedlatif1 commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator Author

@greptile review

greptile-apps[bot] reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

cursor[bot]
cursor Bot reviewed Jul 7, 2026
View reviewed changes

@cursor cursor Bot left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit aefb444. Configure here.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@waleedlatif1
waleedlatif1 merged commit b3175ae into staging Jul 7, 2026
18 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@waleedlatif1
waleedlatif1 deleted the fix/md-paste-strict branch July 7, 2026 03:06

This branch was previously deployed

1 inactive deployment
Preview — aefb4449 Deployed Jul 7, 2026 by vercel[bot]
View deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@greptile-apps greptile-apps[bot] greptile-apps[bot] left review comments
@cursor cursor[bot] cursor[bot] left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@waleedlatif1
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.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.