feat(code): paste rich text as Markdown in the composer#2472
Open
richardsolomou wants to merge 2 commits into
Open
feat(code): paste rich text as Markdown in the composer#2472richardsolomou wants to merge 2 commits into
richardsolomou wants to merge 2 commits into
Conversation
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
Contributor
Prompt To Fix All With AIFix 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
The composer is a plain-text Tiptap editor, so pasting rich text (web pages, Google Docs, Notion) dropped all formatting.
Changes
text/htmlto Markdown on paste, so headings, lists, tables, and links survive as Markdown the agent can read.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
Created with PostHog Code