You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(submit): unwrap hard line breaks in generated PR descriptions
Commit message bodies are typically hard-wrapped at ~72 columns, but
GitHub renders single newlines as `<br>` in PR descriptions, resulting
in ugly narrow paragraphs. `generatePRBody` now unwraps paragraph
lines while preserving markdown structure (code blocks, lists, headers,
blockquotes, tables, horizontal rules). If HTML tags are detected, the
body is left as-is to avoid mangling intentional formatting.
in: "Some text.\n\n indented code line 1\n indented code line 2\n\nMore text.",
47
+
want: "Some text.\n\n indented code line 1\n indented code line 2\n\nMore text.",
48
+
},
49
+
{
50
+
name: "unordered list items preserved",
51
+
in: "Changes:\n\n- First item\n- Second item that is\n also long\n- Third item",
52
+
// The continuation line (2-space indent) is preserved as-is;
53
+
// GitHub's markdown renderer already handles this correctly.
54
+
want: "Changes:\n\n- First item\n- Second item that is\n also long\n- Third item",
55
+
},
56
+
{
57
+
name: "ordered list items preserved",
58
+
in: "Steps:\n\n1. First step\n2. Second step\n3. Third step",
59
+
want: "Steps:\n\n1. First step\n2. Second step\n3. Third step",
60
+
},
61
+
{
62
+
name: "headers preserved",
63
+
in: "## Section\n\nParagraph that is\nhard-wrapped here.\n\n### Subsection\n\nAnother para.",
64
+
want: "## Section\n\nParagraph that is hard-wrapped here.\n\n### Subsection\n\nAnother para.",
65
+
},
66
+
{
67
+
name: "blockquotes preserved",
68
+
in: "> This is a quote\n> that spans lines\n\nRegular text.",
69
+
want: "> This is a quote\n> that spans lines\n\nRegular text.",
70
+
},
71
+
{
72
+
name: "horizontal rule preserved",
73
+
in: "Above\n\n---\n\nBelow",
74
+
want: "Above\n\n---\n\nBelow",
75
+
},
76
+
{
77
+
name: "realistic commit message body",
78
+
in: "This commit refactors the authentication middleware to\nuse JWT tokens instead of session cookies. The change\nimproves scalability by removing server-side session\nstorage requirements.\n\nKey changes:\n\n- Replace session middleware with JWT validation\n- Add token refresh endpoint\n- Update tests to use new auth flow\n\nBreaking change: clients must now send an\n`Authorization: Bearer <token>` header instead of\nrelying on cookies.",
79
+
want: "This commit refactors the authentication middleware to use JWT tokens instead of session cookies. The change improves scalability by removing server-side session storage requirements.\n\nKey changes:\n\n- Replace session middleware with JWT validation\n- Add token refresh endpoint\n- Update tests to use new auth flow\n\nBreaking change: clients must now send an `Authorization: Bearer <token>` header instead of relying on cookies.",
80
+
},
81
+
{
82
+
name: "pipe tables preserved",
83
+
in: "Results:\n\n| Name | Value |\n|------|-------|\n| foo | 42 |",
84
+
want: "Results:\n\n| Name | Value |\n|------|-------|\n| foo | 42 |",
85
+
},
86
+
{
87
+
name: "trailing whitespace on wrapped lines is trimmed",
88
+
in: "Line one with trailing space \nline two.",
89
+
want: "Line one with trailing space line two.",
90
+
},
91
+
{
92
+
name: "HTML tags cause bail-out",
93
+
in: "Some text that is\nhard-wrapped.\n\n<details>\n<summary>Click me</summary>\nHidden content\n</details>",
94
+
want: "Some text that is\nhard-wrapped.\n\n<details>\n<summary>Click me</summary>\nHidden content\n</details>",
95
+
},
96
+
{
97
+
name: "inline HTML tag causes bail-out",
98
+
in: "This has a <br/> in it\nand wraps.",
99
+
want: "This has a <br/> in it\nand wraps.",
100
+
},
101
+
{
102
+
name: "angle bracket in non-HTML context still unwraps",
0 commit comments