Skip to content

Commit d5f6b5d

Browse files
authored
Use markdown escape sequences to avoid mangled output (#84)
* Use markdown escape sequences to avoid mangled output * Don't escape within code regions
1 parent cbb9ca1 commit d5f6b5d

File tree

3 files changed

+33
-6
lines changed

3 files changed

+33
-6
lines changed

package-lock.json

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@
1818
"glob": "^7.2.3",
1919
"js-yaml": "^4.1.0",
2020
"json5": "^2.2.1",
21+
"markdown-escape": "^1.1.0",
2122
"random-seed": "^0.3.0",
2223
"simple-git": "^3.10.0"
2324
},
2425
"devDependencies": {
2526
"@types/glob": "^7.2.0",
2627
"@types/jest": "^27.5.2",
2728
"@types/js-yaml": "^4.0.5",
29+
"@types/markdown-escape": "^1.1.0",
2830
"@types/node": "^14.18.21",
2931
"@types/random-seed": "^0.3.3",
3032
"jest": "^27.4.4",

src/main.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import ip = require("./utils/installPackages");
77
import ut = require("./utils/userTestUtils");
88
import fs = require("fs");
99
import path = require("path");
10+
import mdEscape = require("markdown-escape");
1011
import randomSeed = require("random-seed");
1112

1213
interface Params {
@@ -270,10 +271,10 @@ async function getTsServerRepoResult(
270271
: `Timed out after ${executionTimeout} ms`));
271272
}
272273

273-
const owner = repo.owner ? `${repo.owner}/` : "";
274+
const owner = repo.owner ? `${mdEscape(repo.owner)}/` : "";
274275
const url = repo.url ? `(${repo.url})` : "";
275276

276-
let summary = `## [${owner}${repo.name}]${url}\n`;
277+
let summary = `## [${owner}${mdEscape(repo.name)}]${url}\n`;
277278

278279
if (oldServerFailed) {
279280
const oldServerError = oldSpawnResult?.stdout
@@ -322,7 +323,7 @@ ${fs.readFileSync(replayScriptPath, { encoding: "utf-8" }).split(/\r?\n/).slice(
322323
summary += `<li>Download user test <code>${repo.name}</code></li>\n`;
323324
}
324325
else {
325-
summary += `<li><code>git clone ${repo.url} --recurse-submodules</code></li>\n`;
326+
summary += `<li><code>git clone ${repo.url!} --recurse-submodules</code></li>\n`;
326327

327328
try {
328329
console.log("Extracting commit SHA for repro steps");
@@ -420,12 +421,12 @@ export async function getTscRepoResult(
420421
}
421422

422423
let sawDifferentErrors = false;
423-
const owner = repo.owner ? `${repo.owner}/` : "";
424+
const owner = repo.owner ? `${mdEscape(repo.owner)}/` : "";
424425
const url = repo.url ?? "";
425426

426427
let summary = `<details open="true">
427428
<summary>
428-
<h2><a href="${url}">${owner}${repo.name}</a></h2>
429+
<h2><a href="${url}">${owner}${mdEscape(repo.name)}</a></h2>
429430
</summary>
430431
431432
`;
@@ -838,7 +839,7 @@ function makeMarkdownLink(url: string) {
838839
const match = /\/blob\/[a-f0-9]+\/(.+)$/.exec(url);
839840
return !match
840841
? url
841-
: `[${match[1]}](${url})`;
842+
: `[${mdEscape(match[1])}](${url})`;
842843
}
843844

844845
async function downloadTsAsync(cwd: string, params: GitParams | UserParams): Promise<{ oldTsEntrypointPath: string, oldTsResolvedVersion: string, newTsEntrypointPath: string, newTsResolvedVersion: string }> {

0 commit comments

Comments
 (0)