fix(markup): restore code copy newline strip and fix copying rendered blocks (#39755)

1. Fix JS error when copying Mermaid and Math block sources, regression
from https://github.com/go-gitea/gitea/pull/39718.
1. Restore the newline trim which is consistent with the majority of
forges and markdown renderers as per
https://github.com/go-gitea/gitea/pull/39751#issuecomment-6129002625 and
my strong preference.

This is the minimal fixes to fix the bug and restore the existing
behaviour, more discussions and followups can be had in
https://github.com/go-gitea/gitea/pull/39751.
This commit is contained in:
silverwind authored and GitHub committed 2026-10-13 18:43:40 +00:00
1 parent a1cc651267
commit 0eb57b927a
2 files changed
+9 -4

No files matched your search

+4
View File
@@ -13,5 +13,9 @@ test('mermaid diagram in issue', async ({page, request}) => {
const svg = page.frameLocator('iframe.markup-content-iframe').locator('svg');
await expect(svg).toContainText(/Alpha[\s\S]*Beta[\s\S]*Gamma/);
await svg.hover();
await page.locator('.code-copy').click();
await expect.poll(() => page.evaluate(() => navigator.clipboard.readText())).toBe('flowchart LR\n Alpha --> Beta\n Beta --> Gamma');
await assertNoJsError(page);
});