fix(changelog): preserve HTML blocks in custom changelog entry sections#786
Merged
fix(changelog): preserve HTML blocks in custom changelog entry sections#786
Conversation
2cbb378 to
c552c2d
Compare
Contributor
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Multi-line HTML blocks only indent first line
- Created renderIndentedHtml() helper function that properly indents every line of multi-line HTML blocks, consistent with code block handling.
Or push these changes by commenting:
@cursor push 4e8671910b
Preview (4e8671910b)
diff --git a/src/utils/__tests__/changelog-extract.test.ts b/src/utils/__tests__/changelog-extract.test.ts
--- a/src/utils/__tests__/changelog-extract.test.ts
+++ b/src/utils/__tests__/changelog-extract.test.ts
@@ -399,4 +399,42 @@
'src="https://github.com/user-attachments/assets/abc123"',
);
});
+
+ it('indents every line of multi-line HTML blocks', () => {
+ const prBody = `### Changelog Entry
+
+Add collapsible details section.
+
+<details>
+<summary>Click to expand</summary>
+This is the content.
+</details>`;
+
+ const result = extractChangelogEntry(prBody);
+ expect(result).toHaveLength(1);
+ expect(result![0].text).toBe('Add collapsible details section.');
+ expect(result![0].nestedContent).toBe(
+ ' <details>\n <summary>Click to expand</summary>\n This is the content.\n </details>',
+ );
+ });
+
+ it('indents every line of multi-line <table> HTML', () => {
+ const prBody = `### Changelog Entry
+
+Add comparison table.
+
+<table>
+<tr><th>Feature</th><th>Status</th></tr>
+<tr><td>A</td><td>Done</td></tr>
+</table>`;
+
+ const result = extractChangelogEntry(prBody);
+ expect(result).toHaveLength(1);
+ expect(result![0].text).toBe('Add comparison table.');
+ const lines = result![0].nestedContent!.split('\n');
+ expect(lines).toHaveLength(4);
+ for (const line of lines) {
+ expect(line).toMatch(/^ {2}/);
+ }
+ });
});
diff --git a/src/utils/changelog.ts b/src/utils/changelog.ts
--- a/src/utils/changelog.ts
+++ b/src/utils/changelog.ts
@@ -330,6 +330,17 @@
}
/**
+ * Renders HTML content with proper indentation on every line.
+ * Each line is prefixed with `indent` to ensure proper nesting under list items.
+ */
+function renderIndentedHtml(htmlContent: string, indent = ' '): string {
+ return htmlContent
+ .split('\n')
+ .map(line => `${indent}${line}`)
+ .join('\n');
+}
+
+/**
* Recursively extracts nested content from a list item's tokens.
*/
function extractNestedContent(tokens: Token[]): string {
@@ -434,9 +445,10 @@
const htmlContent = (token as Tokens.HTML).raw.trim();
if (htmlContent && entries.length > 0) {
const prev = entries[entries.length - 1];
+ const indentedHtml = renderIndentedHtml(htmlContent);
prev.nestedContent = prev.nestedContent
- ? `${prev.nestedContent}\n ${htmlContent}`
- : ` ${htmlContent}`;
+ ? `${prev.nestedContent}\n${indentedHtml}`
+ : indentedHtml;
}
// If no previous entry exists, skip — an orphaned HTML block
// without descriptive text isn't a meaningful changelog entry.This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.
GitHub stores uploaded images as standalone <img> HTML tags in PR bodies. The marked lexer tokenizes these as `html` type tokens, which `parseTokensToEntries()` did not handle — silently dropping them. Add an `html` token handler that preserves HTML blocks as nested content on the previous entry, following the same pattern used for code blocks.
c552c2d to
1e63943
Compare
Member
Author
|
Addressed the Cursor Bugbot feedback about multi-line HTML block indentation — now every line is indented with 2 spaces (matching the code block behavior), not just the first line. Added a dedicated test with a |
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.


Changelog Entry
Preserve HTML blocks (e.g.,
<img>tags from GitHub image uploads) in custom## Changelog EntryPR sections instead of silently dropping them.Summary
GitHub stores uploaded images as standalone
<img>HTML tags in PR bodies. Whenmarked.lexer()parses these, it produces tokens of typehtml. However,parseTokensToEntries()only handledlist,paragraph, andcodetoken types — silently dropping everything else.This adds an
htmltoken handler that preserves HTML blocks as nested content on the previous changelog entry, following the same pattern already used for fenced code blocks. Orphaned HTML blocks (with no preceding entry) are skipped, consistent with code block behavior.Discovered via getsentry/cli#555 where the screenshot was dropped from the 0.21.0 release notes.