Skip to content

Commit ef155be

Browse files
committed
codex: address PR review feedback (#1128)
1 parent 2c109bc commit ef155be

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

src/utils/InlineFieldParser.test.ts

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ type:: task
4747
expect(result.get("type")).toEqual(new Set(["task", "meeting"]));
4848
});
4949

50-
it("should ignore fields in code blocks", () => {
51-
const content = `
50+
it("should ignore fields in code blocks", () => {
51+
const content = `
5252
Real field:: value1
5353
\`\`\`
5454
code:: should-be-ignored
@@ -60,9 +60,23 @@ field2:: value2
6060

6161
expect(result.has("code")).toBe(false);
6262
expect(result.has("inline")).toBe(false);
63-
expect(result.get("Real field")).toEqual(new Set(["value1"]));
64-
expect(result.get("field2")).toEqual(new Set(["value2"]));
65-
});
63+
expect(result.get("Real field")).toEqual(new Set(["value1"]));
64+
expect(result.get("field2")).toEqual(new Set(["value2"]));
65+
});
66+
67+
it("should ignore inline fields in fenced blocks after an empty fenced block", () => {
68+
const content = `
69+
Id:: outside
70+
\`\`\`
71+
\`\`\`
72+
\`\`\`ad-note
73+
Id:: inside
74+
\`\`\`
75+
`;
76+
const result = InlineFieldParser.parseInlineFields(content);
77+
78+
expect(result.get("Id")).toEqual(new Set(["outside"]));
79+
});
6680

6781
it("should include fields inside allowlisted fenced code blocks", () => {
6882
const content = `

src/utils/InlineFieldParser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export class InlineFieldParser {
66

77
private static readonly FRONTMATTER_REGEX = /^---\r?\n[\s\S]*?\r?\n---\r?\n/;
88
private static readonly FENCED_CODE_BLOCK_REGEX =
9-
/(`{3,})([^\r\n`]*)\r?\n([\s\S]*?)\r?\n\1/g;
9+
/(`{3,})([^\r\n`]*)\r?\n([\s\S]*?)(?:\r?\n)?\1/g;
1010
private static readonly INLINE_CODE_SPAN_REGEX = /`[^`]*`/g;
1111

1212
/**

0 commit comments

Comments
 (0)