GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(client-runtime): a line of inline triple-backtick code no longer … · pingdotgg/t3code@3808e2d

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • packages/client-runtime/src
    • pullRequestMarkdown.test.ts
    • pullRequestMarkdown.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/client-runtime/src/pullRequestMarkdown.test.ts‎

Copy file name to clipboardExpand all lines: packages/client-runtime/src/pullRequestMarkdown.test.ts
+22Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,28 @@ describe("pull request body segmentation", () => {
136136
]);
137137
});
138138

139+
it("does not open a fence on a line of inline triple-backtick code", () => {
140+
const code = "```\nhttps://example.com/b.png\n```";
141+
expect(
142+
splitPullRequestBody(
143+
`\`\`\`npm test\`\`\` passes.\n\nhttps://example.com/demo.mp4\n\n${code}`,
144+
),
145+
).toEqual([
146+
{ id: "markdown:0", kind: "markdown", text: "```npm test``` passes.", sourceOffset: 0 },
147+
{
148+
id: "attachment:1",
149+
kind: "attachment",
150+
url: "https://example.com/demo.mp4",
151+
media: "video",
152+
},
153+
{ id: "markdown:2", kind: "markdown", text: code, sourceOffset: 54 },
154+
]);
155+
const multilineSpan = "```foo`\nhttps://example.com/demo.mp4\nbar```";
156+
expect(splitPullRequestBody(multilineSpan)).toEqual([
157+
{ id: "markdown:0", kind: "markdown", text: multilineSpan, sourceOffset: 0 },
158+
]);
159+
});
160+
139161
it("leaves an indented code line alone even when it is only a video link", () => {
140162
const body = " https://example.com/demo.mp4";
141163
expect(splitPullRequestBody(body)).toEqual([
Collapse file

‎packages/client-runtime/src/pullRequestMarkdown.ts‎

Copy file name to clipboardExpand all lines: packages/client-runtime/src/pullRequestMarkdown.ts
+7-1Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,13 @@ function splitBodyAt(body: string, baseOffset: number): ReadonlyArray<PullReques
261261
const line = lines[index]!;
262262
if (markdown.length === 0) markdownStart = lineStart;
263263
const fenceMatch = FENCE_PATTERN.exec(line);
264-
if (fenceMatch !== null) {
264+
// ```` ```npm test``` ```` is a code span, not an opener that would flip every later fence.
265+
// A span that runs past this line is left an opener, so its lines stay out of media.
266+
const isInlineCode =
267+
openFence === null &&
268+
fenceMatch?.[1]![0] === "`" &&
269+
(fenceMatch[2]!.match(/`+/gu) ?? []).some((run) => run.length === fenceMatch[1]!.length);
270+
if (fenceMatch !== null && !isInlineCode) {
265271
const fence = fenceMatch[1]!;
266272
// A fence closes only on the same marker, at least as long as the one that opened it,
267273
// and with nothing after it: `~~~` cannot end a ``` block, and ```` ```ts ```` is an

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.