Skip to content

Commit

Permalink
fix(core/inlines): support generic nullable type in inline var (#4709)
Browse files Browse the repository at this point in the history
Co-authored-by: Sid Vishnoi <8426945+sidvishnoi@users.noreply.github.com>
  • Loading branch information
nondebug and sidvishnoi authored May 14, 2024
1 parent 0b1e302 commit 046f651
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/core/inlines.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const l10n = getIntlData(localizationStrings);
// add support.
const inlineCodeRegExp = /(?:`[^`]+`)(?!`)/; // `code`
const inlineIdlReference = /(?:{{[^}]+\?*}})/; // {{ WebIDLThing }}, {{ WebIDLThing? }}
const inlineVariable = /\B\|\w[\w\s]*(?:\s*:[\w\s&;"<>]+\??)?\|\B/; // |var : Type?|
const inlineVariable = /\B\|\w[\w\s]*(?:\s*:[\w\s&;"?<>]+\??)?\|\B/; // |var : Type?|
const inlineCitation = /(?:\[\[(?:!|\\|\?)?[\w.-]+(?:|[^\]]+)?\]\])/; // [[citation]]
const inlineExpansion = /(?:\[\[\[(?:!|\\|\?)?#?[\w-.]+\]\]\])/; // [[[expand]]]
const inlineAnchor = /(?:\[=[^=]+=\])/; // Inline [= For/link =]
Expand Down
15 changes: 9 additions & 6 deletions tests/spec/core/inlines-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ describe("Core - Inlines", () => {
<p id="h"> TEXT |var: Generic&lt;int&gt;| TEXT |var2: Generic&lt;unsigned short int&gt;| </p>
</section>
<section>
<p id="nulls"> |var 1: null type spaces?| and |var 2 : NullableType?| </p>
<p id="nulls"> |var 1: null type spaces?| and |var 2 : NullableType?| and |var 3: Generic&lt;NullableType?&gt;|</p>
</section>
`;
const doc = await makeRSDoc(makeStandardOps(null, body));
Expand Down Expand Up @@ -223,11 +223,14 @@ describe("Core - Inlines", () => {
expect(h[1].textContent).toBe("var2");
expect(h[1].dataset.type).toBe("Generic<unsigned short int>");

const [nullVar1, nullVar2] = doc.querySelectorAll("#nulls > var");
expect(nullVar1.textContent).toBe("var 1");
expect(nullVar1.dataset.type).toBe("null type spaces?");
expect(nullVar2.textContent).toBe("var 2");
expect(nullVar2.dataset.type).toBe("NullableType?");
const nulls = doc.querySelectorAll("#nulls > var");
expect(nulls).toHaveSize(3);
expect(nulls[0].textContent).toBe("var 1");
expect(nulls[0].dataset.type).toBe("null type spaces?");
expect(nulls[1].textContent).toBe("var 2");
expect(nulls[1].dataset.type).toBe("NullableType?");
expect(nulls[2].textContent).toBe("var 3");
expect(nulls[2].dataset.type).toBe("Generic<NullableType?>");
});

it("expands inline references and they get classified as normative/informative correctly", async () => {
Expand Down

0 comments on commit 046f651

Please sign in to comment.