Skip to content

feat(code): paste rich text as Markdown in the composer#2472

Open
richardsolomou wants to merge 2 commits into
mainfrom
posthog-code/paste-rich-text-as-markdown
Open

feat(code): paste rich text as Markdown in the composer#2472
richardsolomou wants to merge 2 commits into
mainfrom
posthog-code/paste-rich-text-as-markdown

Conversation

@richardsolomou
Copy link
Copy Markdown
Member

Problem

The composer is a plain-text Tiptap editor, so pasting rich text (web pages, Google Docs, Notion) dropped all formatting.

Changes

  • Convert clipboard text/html to Markdown on paste, so headings, lists, tables, and links survive as Markdown the agent can read.
  • Uses turndown + @joplin/turndown-plugin-gfm (the maintained gfm fork). Falls back to default plain-text paste when the HTML adds nothing.

How did you test this?

Added unit tests for the HTML to Markdown conversion (headings, lists, tables, code, no-op cases); all 6 pass. Biome and typecheck clean via pre-commit.

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

Created with PostHog Code

The composer is a plain-text Tiptap editor, so pasted formatting was
dropped. Convert clipboard HTML to Markdown so headings, lists, tables,
and links survive the paste.

Generated-By: PostHog Code
Task-Id: 5b5bfd18-72ac-40ff-9694-afc2494d96b9
@richardsolomou richardsolomou requested a review from a team June 3, 2026 13:38
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Jun 3, 2026

Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
apps/code/src/renderer/features/message-editor/utils/htmlToMarkdown.test.ts:4-29
The first four tests share the same structure (html input → expected markdown string) and would read more clearly as a single parameterised test using `it.each`. The custom engineering standard here prefers parameterised tests whenever multiple cases follow the same pattern.

```suggestion
describe("htmlToMarkdown", () => {
  it.each([
    [
      "headings, emphasis and links",
      "<h1>Title</h1><p>Some <strong>bold</strong> and <em>italic</em> with a <a href='https://posthog.com'>link</a>.</p>",
      "# Title\n\nSome **bold** and *italic* with a [link](https://posthog.com).",
    ],
    [
      "unordered lists",
      "<ul><li>one</li><li>two</li></ul>",
      "-   one\n-   two",
    ],
    [
      "tables via the gfm plugin",
      "<table><thead><tr><th>a</th><th>b</th></tr></thead><tbody><tr><td>1</td><td>2</td></tr></tbody></table>",
      "| a   | b   |\n| --- | --- |\n| 1   | 2   |",
    ],
    [
      "fenced code blocks",
      "<pre><code>const x = 1;</code></pre>",
      "```\nconst x = 1;\n```",
    ],
  ])("converts %s", (_, html, expected) => {
    expect(htmlToMarkdown(html)).toBe(expected);
  });
```

Reviews (1): Last reviewed commit: "feat(code): paste rich text as Markdown ..." | Re-trigger Greptile

Generated-By: PostHog Code
Task-Id: 5b5bfd18-72ac-40ff-9694-afc2494d96b9
Copy link
Copy Markdown
Contributor

@tatoalo tatoalo left a comment

Choose a reason for hiding this comment

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

thanks!

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.

2 participants